Issues (12)

src/Blade/CheckableDirective.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @author enea dhack <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Enea\Authorization\Blade;
13
14
use Enea\Authorization\Contracts\Authorizable;
15
use Enea\Authorization\Facades\Helper;
16
17
abstract class CheckableDirective
18
{
19
    abstract public function name(): string;
20
21
    abstract protected function check(Authorizable $authorizable, string $grantable): bool;
22
23 4
    public function isAuthorized(string $grantable, ?string $guard = null): bool
24
    {
25 4
        $authenticated = Helper::authenticated($guard);
26 4
        return $authenticated !== null ? $this->check($authenticated, $grantable) : false;
0 ignored issues
show
It seems like $authenticated can also be of type Illuminate\Database\Eloquent\Model; however, parameter $authorizable of Enea\Authorization\Blade...kableDirective::check() does only seem to accept Enea\Authorization\Contracts\Authorizable, maybe add an additional type check? ( Ignorable by Annotation )

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

26
        return $authenticated !== null ? $this->check(/** @scrutinizer ignore-type */ $authenticated, $grantable) : false;
Loading history...
27
    }
28
}
29