Issues (49)

src/ReaderFactory.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\Annotated;
6
7
use Doctrine\Common\Annotations\Reader as DoctrineReader;
8
use Spiral\Attributes\AnnotationReader;
9
use Spiral\Attributes\AttributeReader;
10
use Spiral\Attributes\Composite\SelectiveReader;
11
use Spiral\Attributes\ReaderInterface;
12
13
final class ReaderFactory
14
{
15 1062
    public static function create(DoctrineReader|ReaderInterface $reader = null): ReaderInterface
16
    {
17
        return match (true) {
18 1062
            $reader instanceof ReaderInterface => $reader,
19 20
            $reader instanceof DoctrineReader => new AnnotationReader($reader),
0 ignored issues
show
It seems like $reader can also be of type Spiral\Attributes\ReaderInterface; however, parameter $reader of Spiral\Attributes\AnnotationReader::__construct() does only seem to accept Doctrine\Common\Annotations\Reader|null, 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

19
            $reader instanceof DoctrineReader => new AnnotationReader(/** @scrutinizer ignore-type */ $reader),
Loading history...
20 10
            $reader === null => new SelectiveReader([
21 10
                new AttributeReader(),
22 1062
                new AnnotationReader(),
23
            ]),
24
        };
25
    }
26
}
27