1 | <?php |
||
25 | class DetectorVisitor extends NodeVisitorAbstract |
||
26 | { |
||
27 | /** |
||
28 | * @var FileReport |
||
29 | */ |
||
30 | private $fileReport; |
||
31 | |||
32 | /** |
||
33 | * @var Option |
||
34 | */ |
||
35 | private $option; |
||
36 | |||
37 | /** |
||
38 | * @param FileReport $fileReport |
||
39 | * @param Option $option |
||
40 | */ |
||
41 | public function __construct(FileReport $fileReport, Option $option) |
||
46 | |||
47 | /** |
||
48 | * @inheritdoc |
||
49 | */ |
||
50 | public function enterNode(Node $node) |
||
76 | |||
77 | /** |
||
78 | * @param Node $node |
||
79 | * |
||
80 | * @return bool |
||
81 | */ |
||
82 | private function isNumber(Node $node) |
||
83 | { |
||
84 | $isNumber = ( |
||
85 | $node instanceof LNumber || |
||
86 | $node instanceof DNumber || |
||
87 | $this->isValidNumeric($node) |
||
88 | ); |
||
89 | |||
90 | return $isNumber && false === $this->ignoreNumber($node); |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * @param Node $node |
||
95 | * |
||
96 | * @return bool |
||
97 | */ |
||
98 | private function isString(Node $node) |
||
102 | |||
103 | /** |
||
104 | * @param LNumber|DNumber|Node $node |
||
105 | * |
||
106 | * @return bool |
||
107 | */ |
||
108 | private function ignoreNumber(Node $node) |
||
112 | |||
113 | /** |
||
114 | * @param String_|Node $node |
||
115 | * |
||
116 | * @return bool |
||
117 | */ |
||
118 | private function ignoreString(Node $node) |
||
122 | |||
123 | /** |
||
124 | * @param Node $node |
||
125 | * |
||
126 | * @return bool |
||
127 | */ |
||
128 | private function hasSign(Node $node) |
||
132 | |||
133 | /** |
||
134 | * @param Node $node |
||
135 | * |
||
136 | * @return bool |
||
137 | */ |
||
138 | private function isMinus(Node $node) |
||
142 | |||
143 | /** |
||
144 | * @param Node $node |
||
145 | * @param Extension $extension |
||
146 | * |
||
147 | * @return bool |
||
148 | */ |
||
149 | private function ignoreFunc(Node $node, Extension $extension) |
||
157 | |||
158 | /** |
||
159 | * @param Node $node |
||
160 | * @return bool |
||
161 | */ |
||
162 | private function isValidNumeric(Node $node) |
||
169 | } |
||
170 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: