Skip to content

Commit

Permalink
update stan
Browse files Browse the repository at this point in the history
  • Loading branch information
LordSimal committed Nov 17, 2024
1 parent 86a342a commit f7be0fb
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpstan" version="1.11.9" installed="1.11.9" location="./tools/phpstan" copy="false"/>
<phar name="psalm" version="5.25.0" installed="5.25.0" location="./tools/psalm" copy="false"/>
<phar name="phpstan" version="2.0.1" installed="2.0.1" location="./tools/phpstan" copy="false"/>
<phar name="psalm" version="5.26.1" installed="5.26.1" location="./tools/psalm" copy="false"/>
</phive>
37 changes: 37 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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: '#^Method Authorization\\Controller\\Component\\AuthorizationComponent\:\:implementedEvents\(\) should return array\<string, mixed\> but returns array\<int\|string, string\>\.$#'
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
5 changes: 4 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
includes:
- phpstan-baseline.neon

parameters:
level: 6
level: 7
treatPhpDocTypesAsCertain: false
paths:
- src/
Expand Down
20 changes: 10 additions & 10 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.20.0@3f284e96c9d9be6fe6b15c79416e1d1903dcfef4">
<file src="src/Command/PolicyCommand.php">
<RiskyTruthyFalsyComparison>
<code>!$name</code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/IdentityDecorator.php">
<RiskyTruthyFalsyComparison>
<code><![CDATA[$this->identity]]></code>
</RiskyTruthyFalsyComparison>
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
<file src="src/Controller/Component/AuthorizationComponent.php">
<InvalidReturnStatement>
<code><![CDATA[$this->performCheck($resource, $action)]]></code>
<code><![CDATA[$this->performCheck($resource, $action, 'canResult')]]></code>
</InvalidReturnStatement>
<InvalidReturnType>
<code><![CDATA[\Authorization\Policy\ResultInterface]]></code>
<code><![CDATA[bool]]></code>
</InvalidReturnType>
</file>
</files>
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
<MissingClosureParamType errorLevel="info" />

<RedundantConditionGivenDocblockType errorLevel="info" />
<RiskyTruthyFalsyComparison errorLevel="info" />
</issueHandlers>
</psalm>
4 changes: 0 additions & 4 deletions src/Controller/Component/AuthorizationComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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');
}

Expand Down
1 change: 0 additions & 1 deletion src/Identity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
3 changes: 2 additions & 1 deletion src/IdentityDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -111,6 +110,8 @@ public function __call(string $method, array $args): mixed
}
$call = [$this->identity, $method];

assert(is_callable($call), 'Method does not exist');

return $call(...$args);
}

Expand Down

0 comments on commit f7be0fb

Please sign in to comment.