Skip to content

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

Merged
merged 1 commit into from
Nov 17, 2024
Merged

3.x update stan #682

merged 1 commit into from
Nov 17, 2024

Conversation

LordSimal
Copy link
Contributor

No description provided.

@LordSimal LordSimal added this to the 3.x milestone Nov 17, 2024
@@ -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]) ?: '';
Copy link
Member

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.

Copy link
Contributor Author

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 😅

Copy link
Member

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.

Copy link
Contributor Author

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

@@ -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();
Copy link
Member

@ADmad ADmad Nov 17, 2024

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.

Copy link
Contributor Author

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]) ?: '';
Copy link
Member

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.

@ADmad ADmad merged commit 6b6a2ef into 3.x Nov 17, 2024
6 of 8 checks passed
@ADmad ADmad deleted the 3.x-update-stan branch November 17, 2024 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants