From f2673b372340fe65e7bdd51ee46734c7aca571fd Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Sun, 17 Nov 2024 15:32:21 +0100 Subject: [PATCH] update stan --- .phive/phars.xml | 4 +- phpstan-baseline.neon | 3 +- psalm-baseline.xml | 64 +-------------------- psalm.xml | 1 + src/AuthenticationService.php | 4 +- src/Authenticator/CookieAuthenticator.php | 4 +- src/Identity.php | 1 - src/Middleware/AuthenticationMiddleware.php | 1 - 8 files changed, 11 insertions(+), 71 deletions(-) diff --git a/.phive/phars.xml b/.phive/phars.xml index 726b7777..d311bfa5 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,5 +1,5 @@ - - + + diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index a0020612..e65ff0cb 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,6 +1,7 @@ parameters: ignoreErrors: - - message: "#^Strict comparison using \\=\\=\\= between string and false will always evaluate to false\\.$#" + message: '#^Strict comparison using \=\=\= between string and false will always evaluate to false\.$#' + identifier: identical.alwaysFalse count: 1 path: src/Authenticator/HttpDigestAuthenticator.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 647854e4..5c064bb4 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,64 +1,2 @@ - - - - - - - - - - empty($identity) - - - - - empty($data) - empty($user) - - - - - empty($user) - - - - - empty($digest) - empty($user) - - - - - empty($user) - - - - - empty($data) - - - - - empty($user) - empty($user) - - - - - empty($headerLine) - empty($queryParam) - empty($user) - - - - - $result - - - - - $url - - - + diff --git a/psalm.xml b/psalm.xml index 8e05d909..030432ff 100644 --- a/psalm.xml +++ b/psalm.xml @@ -27,5 +27,6 @@ + diff --git a/src/AuthenticationService.php b/src/AuthenticationService.php index 5d005bc2..f41c76cd 100644 --- a/src/AuthenticationService.php +++ b/src/AuthenticationService.php @@ -492,8 +492,10 @@ public function isImpersonating(ServerRequestInterface $request): bool */ protected function getImpersonationProvider(): ImpersonationInterface { - /** @var \Authentication\Authenticator\ImpersonationInterface $provider */ $provider = $this->getAuthenticationProvider(); + if ($provider === null) { + throw new InvalidArgumentException('No AuthenticationProvider present.'); + } if (!($provider instanceof ImpersonationInterface)) { $className = get_class($provider); throw new InvalidArgumentException( diff --git a/src/Authenticator/CookieAuthenticator.php b/src/Authenticator/CookieAuthenticator.php index 0d569b21..b820b393 100644 --- a/src/Authenticator/CookieAuthenticator.php +++ b/src/Authenticator/CookieAuthenticator.php @@ -184,6 +184,7 @@ protected function _createPlainToken(ArrayAccess|array $identity): string * * @param \ArrayAccess|array $identity Identity data. * @return string + * @throws \JsonException */ protected function _createToken(ArrayAccess|array $identity): string { @@ -192,8 +193,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], JSON_THROW_ON_ERROR); } /** diff --git a/src/Identity.php b/src/Identity.php index 80a325c6..d91fb635 100644 --- a/src/Identity.php +++ b/src/Identity.php @@ -52,7 +52,6 @@ class Identity implements IdentityInterface * * @param \ArrayAccess|array $data Identity data * @param array $config Config options - * @throws \InvalidArgumentException When invalid identity data is passed. */ public function __construct(ArrayAccess|array $data, array $config = []) { diff --git a/src/Middleware/AuthenticationMiddleware.php b/src/Middleware/AuthenticationMiddleware.php index 79616eaf..d987ad3f 100644 --- a/src/Middleware/AuthenticationMiddleware.php +++ b/src/Middleware/AuthenticationMiddleware.php @@ -56,7 +56,6 @@ class AuthenticationMiddleware implements MiddlewareInterface * * @param \Authentication\AuthenticationServiceInterface|\Authentication\AuthenticationServiceProviderInterface $subject Authentication service or application instance. * @param \Cake\Core\ContainerInterface|null $container The container instance from the application. - * @throws \InvalidArgumentException When invalid subject has been passed. */ public function __construct( AuthenticationServiceInterface|AuthenticationServiceProviderInterface $subject,