1 | <?php |
||
7 | class Property extends ReflectionProperty |
||
8 | { |
||
9 | /** @var array */ |
||
10 | protected static $typeMapping = [ |
||
11 | 'int' => 'integer', |
||
12 | 'bool' => 'boolean', |
||
13 | ]; |
||
14 | |||
15 | /** @var \Spatie\ValueObject\ValueObject */ |
||
16 | protected $valueObject; |
||
17 | |||
18 | /** @var bool */ |
||
19 | protected $hasTypeDeclaration = false; |
||
20 | |||
21 | /** @var bool */ |
||
22 | protected $isNullable = false; |
||
23 | |||
24 | /** @var bool */ |
||
25 | protected $isInitialised = false; |
||
26 | |||
27 | /** @var array */ |
||
28 | protected $types = []; |
||
29 | |||
30 | public static function fromReflection(ValueObject $valueObject, ReflectionProperty $reflectionProperty) |
||
34 | |||
35 | public function __construct(ValueObject $valueObject, ReflectionProperty $reflectionProperty) |
||
43 | |||
44 | public function set($value) |
||
59 | |||
60 | public function getTypes(): array |
||
64 | |||
65 | public function getFqn(): string |
||
69 | |||
70 | protected function resolveTypeDefinition() |
||
92 | |||
93 | protected function isValidType($value): bool |
||
113 | |||
114 | protected function assertTypeEquals(string $type, $value): bool |
||
126 | } |
||
127 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.