From 681e819ec1e88ddd6a510b49ac74195ffaddfd71 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Sun, 17 Nov 2024 15:41:36 +0100 Subject: [PATCH] update stan --- .phive/phars.xml | 4 +-- phpstan-baseline.neon | 31 +++++++++++++++++++ phpstan.neon | 5 ++- psalm-baseline.xml | 20 ++++++------ psalm.xml | 1 + .../Component/AuthorizationComponent.php | 6 +--- src/Identity.php | 1 - src/IdentityDecorator.php | 2 +- 8 files changed, 50 insertions(+), 20 deletions(-) create mode 100644 phpstan-baseline.neon 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 new file mode 100644 index 00000000..3143a09f --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,31 @@ +parameters: + ignoreErrors: + - + message: '#^Creating callable from array\{mixed, non\-falsy\-string\} but it might not be a callable\.$#' + identifier: callable.nonCallable + count: 2 + path: src/AuthorizationService.php + + - + message: '#^Method Authorization\\Controller\\Component\\AuthorizationComponent\:\:can\(\) should return bool but returns Authorization\\Policy\\ResultInterface\|bool\.$#' + identifier: return.type + count: 1 + path: src/Controller/Component/AuthorizationComponent.php + + - + message: '#^Method Authorization\\Controller\\Component\\AuthorizationComponent\:\:canResult\(\) should return Authorization\\Policy\\ResultInterface but returns Authorization\\Policy\\ResultInterface\|bool\.$#' + identifier: return.type + count: 1 + path: src/Controller/Component/AuthorizationComponent.php + + - + message: '#^Cannot call method getIdentifier\(\) on array\|Authentication\\IdentityInterface\.$#' + identifier: method.nonObject + count: 1 + path: src/Identity.php + + - + message: '#^Cannot call method getOriginalData\(\) on array\|Authentication\\IdentityInterface\.$#' + identifier: method.nonObject + count: 1 + path: src/Identity.php diff --git a/phpstan.neon b/phpstan.neon index eac7bd53..f045a145 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,8 @@ +includes: + - phpstan-baseline.neon + parameters: - level: 6 + level: 7 treatPhpDocTypesAsCertain: false paths: - src/ diff --git a/psalm-baseline.xml b/psalm-baseline.xml index e5544a4b..c2de9577 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,13 +1,13 @@ - - - - !$name - - - - - identity]]> - + + + + performCheck($resource, $action)]]> + performCheck($resource, $action, 'canResult')]]> + + + + + diff --git a/psalm.xml b/psalm.xml index 8f778137..237111df 100644 --- a/psalm.xml +++ b/psalm.xml @@ -24,5 +24,6 @@ + diff --git a/src/Controller/Component/AuthorizationComponent.php b/src/Controller/Component/AuthorizationComponent.php index d684999b..3d7bffeb 100644 --- a/src/Controller/Component/AuthorizationComponent.php +++ b/src/Controller/Component/AuthorizationComponent.php @@ -91,11 +91,9 @@ public function authorize(mixed $resource, ?string $action = null): void * @param mixed $resource The resource to check authorization on. * @param string|null $action The action to check authorization for. * @return bool - * @psalm-suppress InvalidReturnType */ public function can(mixed $resource, ?string $action = null): bool { - /** @psalm-suppress InvalidReturnStatement */ return $this->performCheck($resource, $action); } @@ -108,11 +106,9 @@ public function can(mixed $resource, ?string $action = null): bool * @param mixed $resource The resource to check authorization on. * @param string|null $action The action to check authorization for. * @return \Authorization\Policy\ResultInterface - * @psalm-suppress InvalidReturnType */ public function canResult(mixed $resource, ?string $action = null): ResultInterface { - /** @psalm-suppress InvalidReturnStatement */ return $this->performCheck($resource, $action, 'canResult'); } @@ -348,7 +344,7 @@ protected function getDefaultAction(ServerRequest $request): string public function implementedEvents(): array { return [ - $this->getConfig('authorizationEvent') => 'authorizeAction', + (string)$this->getConfig('authorizationEvent') => 'authorizeAction', ]; } } diff --git a/src/Identity.php b/src/Identity.php index 38c70ac4..ff63c12a 100644 --- a/src/Identity.php +++ b/src/Identity.php @@ -38,7 +38,6 @@ class Identity extends IdentityDecorator implements AuthenIdentityInterface * * @param \Authorization\AuthorizationServiceInterface $service The authorization service. * @param \Authentication\IdentityInterface $identity Identity data - * @throws \InvalidArgumentException When invalid identity data is passed. */ public function __construct(AuthorizationServiceInterface $service, AuthenIdentityInterface $identity) { diff --git a/src/IdentityDecorator.php b/src/IdentityDecorator.php index f754bcc0..64ad190a 100644 --- a/src/IdentityDecorator.php +++ b/src/IdentityDecorator.php @@ -49,7 +49,6 @@ class IdentityDecorator implements IdentityInterface * * @param \Authorization\AuthorizationServiceInterface $service The authorization service. * @param \ArrayAccess|array $identity Identity data - * @throws \InvalidArgumentException When invalid identity data is passed. */ public function __construct(AuthorizationServiceInterface $service, ArrayAccess|array $identity) { @@ -111,6 +110,7 @@ public function __call(string $method, array $args): mixed } $call = [$this->identity, $method]; + /** @phpstan-ignore callable.nonCallable */ return $call(...$args); }