Completed
Push — 2.x ( 00ddbc...cd9545 )
by Akihito
01:13
created

src/Matcher/AnnotatedWithMatcher.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\Aop\Matcher;
6
7
use Doctrine\Common\Annotations\AnnotationException;
8
use Doctrine\Common\Annotations\AnnotationReader;
9
use Ray\Aop\AbstractMatcher;
10
use ReflectionClass;
11
use ReflectionMethod;
12
13
final class AnnotatedWithMatcher extends AbstractMatcher
14
{
15
    /** @var AnnotationReader */
16
    private $reader;
17
18
    /**
19
     * @throws AnnotationException
20
     */
21 5
    public function __construct()
22
    {
23 5
        parent::__construct();
24 5
        $this->reader = new AnnotationReader();
25 5
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30 2
    public function matchesClass(ReflectionClass $class, array $arguments): bool
31
    {
32 2
        /** @var array<class-string> $arguments */
0 ignored issues
show
The doc-type array<class-string> could not be parsed: Unknown type name "class-string" at position 6. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
33 2
        [$annotation] = $arguments;
34
        $annotation = $this->reader->getClassAnnotation($class, $annotation);
35 2
36
        return (bool) $annotation;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41 3
     */
42
    public function matchesMethod(ReflectionMethod $method, array $arguments): bool
43 3
    {
44 3
        /** @var array<class-string> $arguments */
0 ignored issues
show
The doc-type array<class-string> could not be parsed: Unknown type name "class-string" at position 6. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
45
        [$annotation] = $arguments;
46 3
        $annotation = $this->reader->getMethodAnnotation($method, $annotation);
47
48
        return (bool) $annotation;
49
    }
50
}
51