Ecodev /
felix
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Ecodev\Felix\Acl\Assertion; |
||
| 6 | |||
| 7 | use Ecodev\Felix\Model\CurrentUser; |
||
| 8 | use Laminas\Permissions\Acl\Acl; |
||
| 9 | use Laminas\Permissions\Acl\Assertion\AssertionInterface; |
||
| 10 | use Laminas\Permissions\Acl\Resource\ResourceInterface; |
||
| 11 | use Laminas\Permissions\Acl\Role\RoleInterface; |
||
| 12 | |||
| 13 | final class IsMyself implements AssertionInterface |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * Assert that the user is the current user himself. |
||
| 17 | * |
||
| 18 | * @param \Ecodev\Felix\Acl\Acl $acl |
||
| 19 | * @param RoleInterface $role |
||
| 20 | * @param ResourceInterface $resource |
||
| 21 | * @param string $privilege |
||
| 22 | * |
||
| 23 | * @return bool |
||
| 24 | */ |
||
| 25 | 2 | public function assert(Acl $acl, ?RoleInterface $role = null, ?ResourceInterface $resource = null, $privilege = null) |
|
| 26 | { |
||
| 27 | 2 | $user = $resource->getInstance(); |
|
|
0 ignored issues
–
show
|
|||
| 28 | |||
| 29 | 2 | if (CurrentUser::get() && CurrentUser::get() === $user) { |
|
| 30 | return true; |
||
| 31 | } |
||
| 32 | |||
| 33 | 2 | return $acl->reject('it is not himself'); |
|
| 34 | } |
||
| 35 | } |
||
| 36 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.