Closed
Description
Description
I have seen that there are several different ways to get a parameter from the parameter bag. For example
getBoolean()
getInteger()
getAlpha()
getAlnum()
- etc.
It would be a nice small feature to add a function which returns a string
. Benefit would be you dont have to cast the type always by yourself and have a strict type
Example
// src/Security/FormAuthenticator.php
class FormAuthenticator extends AbstractLoginFormAuthenticator
{
// ...
public function authenticate(Request $request): Passport
{
-$username = (string)$request->request->get('username', '');
+$username = $request->request->getString('username');
-$password = (string)$request->request->get('password', '');
+$password = $request->request->getString('password');
-$csrfToken = (string)$request->request->get('_csrf_token', '');
+$csrfToken = $request->request->getString('_csrf_token');
return new Passport(
new UserBadge($username),
new PasswordCredentials($password),
[new CsrfTokenBadge('authentication', $csrfToken)],
);
}
// ...
}