Skip to content

Commit f71d98b

Browse files
committed
minor #58094 Use Stringable whenever possible (fabpot)
This PR was merged into the 7.2 branch. Discussion ---------- Use Stringable whenever possible | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Issues | n/a | License | MIT <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the latest branch. - For new features, provide some code snippets to help understand usage. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> Commits ------- 06b49968a5 Use Stringable whenever possible
2 parents 77490c6 + bd03e49 commit f71d98b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Authenticator/FormLoginAuthenticator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,15 @@ private function getCredentials(Request $request): array
133133

134134
$request->getSession()->set(SecurityRequestAttributes::LAST_USERNAME, $credentials['username']);
135135

136-
if (!\is_string($credentials['password']) && (!\is_object($credentials['password']) || !method_exists($credentials['password'], '__toString'))) {
136+
if (!\is_string($credentials['password']) && !$credentials['password'] instanceof \Stringable) {
137137
throw new BadRequestHttpException(\sprintf('The key "%s" must be a string, "%s" given.', $this->options['password_parameter'], \gettype($credentials['password'])));
138138
}
139139

140140
if ('' === (string) $credentials['password']) {
141141
throw new BadCredentialsException(\sprintf('The key "%s" must be a non-empty string.', $this->options['password_parameter']));
142142
}
143143

144-
if (!\is_string($credentials['csrf_token'] ?? '') && (!\is_object($credentials['csrf_token']) || !method_exists($credentials['csrf_token'], '__toString'))) {
144+
if (!\is_string($credentials['csrf_token'] ?? '') && !$credentials['csrf_token'] instanceof \Stringable) {
145145
throw new BadRequestHttpException(\sprintf('The key "%s" must be a string, "%s" given.', $this->options['csrf_parameter'], \gettype($credentials['csrf_token'])));
146146
}
147147

0 commit comments

Comments
 (0)