Completed
Pull Request — 2.x (#228)
by Akihito
02:41 queued 01:28
created

ParamInjectMatcher::matchesClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\Di\Matcher;
6
7
use Ray\Aop\AbstractMatcher;
8
use Ray\Di\Di\Inject;
9
use ReflectionAttribute;
10
use ReflectionClass;
11
use ReflectionMethod;
12
13
final class ParamInjectMatcher extends AbstractMatcher
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18
    public function matchesClass(ReflectionClass $class, array $arguments): bool
19
    {
20
        return true;
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function matchesMethod(ReflectionMethod $method, array $arguments): bool
27
    {
28
        $params = $method->getParameters();
29
        foreach ($params as $param) {
30
            /** @var list<ReflectionAttribute> $attributes */
0 ignored issues
show
Documentation introduced by
The doc-type list<ReflectionAttribute> could not be parsed: Expected "|" or "end of type", but got "<" at position 4. (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...
31
            $attributes = $param->getAttributes(Inject::class);
32
            if (isset($attributes[0])) {
33
                return true;
34
            }
35
        }
36
37
        return false;
38
    }
39
}
40