Completed
Push — master ( 6366df...fbe022 )
by Kirill
23s queued 19s
created

Decorator::getFunctionMetadata()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * This file is part of Spiral Framework package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Attributes\Internal;
13
14
use Spiral\Attributes\Reader;
15
use Spiral\Attributes\ReaderInterface;
16
17
/**
18
 * @internal Decorator is an internal library class, please do not use it in your code.
19
 * @psalm-internal Spiral\Attributes
20
 */
21
abstract class Decorator extends Reader
22
{
23
    /**
24
     * @var FallbackAttributeReader|NativeAttributeReader
25
     */
26
    private $reader;
27
28
    /**
29
     * @param ReaderInterface $reader
30
     */
31
    public function __construct(ReaderInterface $reader)
32
    {
33
        $this->reader = $reader;
0 ignored issues
show
Documentation Bug introduced by
$reader is of type Spiral\Attributes\ReaderInterface, but the property $reader was declared to be of type Spiral\Attributes\Intern...l\NativeAttributeReader. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
34
    }
35
36
    /**
37
     * {@inheritDoc}
38
     */
39
    public function getClassMetadata(\ReflectionClass $class, string $name = null): iterable
40
    {
41
        return $this->reader->getClassMetadata($class, $name);
42
    }
43
44
    /**
45
     * {@inheritDoc}
46
     */
47
    public function getFunctionMetadata(\ReflectionFunctionAbstract $function, string $name = null): iterable
48
    {
49
        return $this->reader->getFunctionMetadata($function, $name);
50
    }
51
52
    /**
53
     * {@inheritDoc}
54
     */
55
    public function getPropertyMetadata(\ReflectionProperty $property, string $name = null): iterable
56
    {
57
        return $this->reader->getPropertyMetadata($property, $name);
58
    }
59
60
    /**
61
     * {@inheritDoc}
62
     */
63
    public function getConstantMetadata(\ReflectionClassConstant $constant, string $name = null): iterable
64
    {
65
        return $this->reader->getConstantMetadata($constant, $name);
66
    }
67
68
    /**
69
     * {@inheritDoc}
70
     */
71
    public function getParameterMetadata(\ReflectionParameter $parameter, string $name = null): iterable
72
    {
73
        return $this->reader->getParameterMetadata($parameter, $name);
74
    }
75
}
76