-
Notifications
You must be signed in to change notification settings - Fork 106
3.x update stan #682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3.x update stan #682
Conversation
@@ -192,8 +192,7 @@ protected function _createToken(ArrayAccess|array $identity): string | |||
|
|||
$usernameField = $this->getConfig('fields.username'); | |||
|
|||
/** @var string */ | |||
return json_encode([$identity[$usernameField], $hash]); | |||
return json_encode([$identity[$usernameField], $hash]) ?: ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just (string) cast it usually. But both works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to prevent using the PHP casting system where possible 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it stop complaining about the false
return if you use the JSON_THROW_ON_ERROR flag?
We should do that anyway instead of silently returning an empty string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does stop complaining. thanks
src/AuthenticationService.php
Outdated
@@ -492,8 +493,7 @@ public function isImpersonating(ServerRequestInterface $request): bool | |||
*/ | |||
protected function getImpersonationProvider(): ImpersonationInterface | |||
{ | |||
/** @var \Authentication\Authenticator\ImpersonationInterface $provider */ | |||
$provider = $this->getAuthenticationProvider(); | |||
$provider = $this->getAuthenticationProvider() ?? new stdClass(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is silly. No need to create a stdClass
instance if null
is returned. Instead change the next line to if ($provider === null)
and the code after as necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that but phpstan doesn't like having get_class
getting passed a null
Therefore I added a separate if with a separate exception.
@@ -192,8 +192,7 @@ protected function _createToken(ArrayAccess|array $identity): string | |||
|
|||
$usernameField = $this->getConfig('fields.username'); | |||
|
|||
/** @var string */ | |||
return json_encode([$identity[$usernameField], $hash]); | |||
return json_encode([$identity[$usernameField], $hash]) ?: ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it stop complaining about the false
return if you use the JSON_THROW_ON_ERROR flag?
We should do that anyway instead of silently returning an empty string.
8a1a979
to
f2673b3
Compare
No description provided.