| Conditions | 5 |
| Paths | 5 |
| Total Lines | 19 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 5 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | 6 | public function apply(AbstractNode $node) |
|
| 21 | { |
||
| 22 | 6 | if (false === $this->isController($node)) { |
|
|
|
|||
| 23 | 4 | return; |
|
| 24 | } |
||
| 25 | |||
| 26 | 2 | $allowedMethodNames = explode($this->getStringProperty('delimiter'), $this->getStringProperty('allowedMethodNames')); |
|
| 27 | |||
| 28 | /** @var MethodNode $method */ |
||
| 29 | 2 | foreach ($node->getMethods() as $method) { |
|
| 30 | 2 | if (true === in_array($method->getImage(), $allowedMethodNames)) { |
|
| 31 | 2 | continue; |
|
| 32 | } |
||
| 33 | |||
| 34 | 2 | if ('Action' !== substr($method->getImage(), -6, 6)) { |
|
| 35 | 2 | $this->addViolation($method); |
|
| 36 | 2 | } |
|
| 37 | 2 | } |
|
| 38 | 2 | } |
|
| 39 | |||
| 58 |
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.