Completed
Push — 2.x ( 6946d0...9e5583 )
by Akihito
29s queued 15s
created

AssistedInjectMatcher::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 LogicException;
8
use Ray\Aop\AbstractMatcher;
9
use Ray\Di\Di\Inject;
10
use Ray\Di\Di\InjectInterface;
11
use ReflectionAttribute;
12
use ReflectionClass;
13
use ReflectionMethod;
14
15
final class AssistedInjectMatcher extends AbstractMatcher
16
{
17
    /**
18
     * {@inheritdoc}
19
     *
20
     * @codeCoverageIgnore
21
     */
22
    public function matchesClass(ReflectionClass $class, array $arguments): bool
23
    {
24
        throw new LogicException('Should not used in class matcher');
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function matchesMethod(ReflectionMethod $method, array $arguments): bool
31
    {
32
        $params = $method->getParameters();
33
        foreach ($params as $param) {
34
            /** @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...
35
            $attributes = $param->getAttributes(InjectInterface::class, ReflectionAttribute::IS_INSTANCEOF);
36
            if (isset($attributes[0])) {
37
                return true;
38
            }
39
        }
40
41
        return false;
42
    }
43
}
44