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; |
|
|
|
|
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
|
|
|
|
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.