Issues (141)

server/Application/Acl/Assertion/CanUpdateCard.php (3 issues)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Acl\Assertion;
6
7
use Application\Model\File;
8
use Ecodev\Felix\Acl\Assertion\NamedAssertion;
9
use Ecodev\Felix\Acl\ModelResource;
10
use Laminas\Permissions\Acl\Acl;
11
use Laminas\Permissions\Acl\Resource\ResourceInterface;
12
use Laminas\Permissions\Acl\Role\RoleInterface;
13
14
class CanUpdateCard implements NamedAssertion
15
{
16
    public function getName(): string
17
    {
18
        return 'je peux éditer la fiche';
19
    }
20
21
    /**
22
     * Assert that the card that the object belongs to can be updated.
23
     *
24
     * @param \Application\Acl\Acl $acl
25
     * @param ModelResource $resource
26
     * @param string $privilege
27
     *
28
     * @return bool
29
     */
30
    public function assert(Acl $acl, ?RoleInterface $role = null, ?ResourceInterface $resource = null, $privilege = null)
31
    {
32
        /** @var File $object */
33
        $object = $resource->getInstance();
0 ignored issues
show
The method getInstance() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

33
        /** @scrutinizer ignore-call */ 
34
        $object = $resource->getInstance();

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.

Loading history...
The method getInstance() does not exist on Laminas\Permissions\Acl\Resource\ResourceInterface. It seems like you code against a sub-type of Laminas\Permissions\Acl\Resource\ResourceInterface such as Ecodev\Felix\Acl\ModelResource. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

33
        /** @scrutinizer ignore-call */ 
34
        $object = $resource->getInstance();
Loading history...
34
        $card = $object->getCard();
35
36
        return $acl->isCurrentUserAllowed($card, 'update');
0 ignored issues
show
The method isCurrentUserAllowed() does not exist on Laminas\Permissions\Acl\Acl. It seems like you code against a sub-type of Laminas\Permissions\Acl\Acl such as Ecodev\Felix\Acl\Acl. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
        return $acl->/** @scrutinizer ignore-call */ isCurrentUserAllowed($card, 'update');
Loading history...
37
    }
38
}
39