Conditions | 5 |
Paths | 5 |
Total Lines | 20 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 5.0144 |
Changes | 3 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
24 | 3 | public function apply(AbstractNode $node) |
|
25 | { |
||
26 | 3 | if (false === $this->isController($node)) { |
|
|
|||
27 | 2 | return; |
|
28 | } |
||
29 | |||
30 | 1 | $allowedMethodNames = explode($this->getStringProperty('delimiter'), $this->getStringProperty('allowedMethodNames')); |
|
31 | |||
32 | /** @var MethodNode $method */ |
||
33 | 1 | foreach ($node->getMethods() as $method) { |
|
34 | // Check if method is whitelisted |
||
35 | 1 | if (in_array($method->getImage(), $allowedMethodNames)) { |
|
36 | continue; |
||
37 | } |
||
38 | |||
39 | 1 | if ('Action' !== substr($method->getImage(), -6, 6)) { |
|
40 | 1 | $this->addViolation($method); |
|
41 | 1 | } |
|
42 | 1 | } |
|
43 | 1 | } |
|
44 | |||
63 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.