Conditions | 5 |
Paths | 5 |
Total Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Tests | 17 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
20 | 23 | public function apply(AbstractNode $node) |
|
21 | { |
||
22 | 23 | $forbiddenChildTypes = explode( |
|
23 | 23 | $this->getStringProperty('delimiter'), |
|
24 | 23 | $this->getStringProperty('forbiddenChildren') |
|
25 | 23 | ); |
|
26 | |||
27 | /** @var AbstractNode|ASTReturnStatement $returnStatement */ |
||
28 | 23 | foreach ($node->findChildrenOfType('ReturnStatement') as $returnStatement) { |
|
29 | 13 | foreach ($forbiddenChildTypes as $forbiddenChildType) { |
|
30 | 13 | $child = $returnStatement->getFirstChildOfType($forbiddenChildType); |
|
31 | |||
32 | 13 | if (null === $child) { |
|
33 | 13 | continue; |
|
34 | } |
||
35 | |||
36 | 2 | $reflectChild = new \ReflectionClass($child->getNode()); |
|
37 | |||
38 | 2 | if ('AST' . $forbiddenChildType === $reflectChild->getShortName()) { |
|
39 | 1 | $this->addViolation($returnStatement, [$forbiddenChildType]); |
|
40 | 1 | } |
|
41 | 13 | } |
|
42 | 23 | } |
|
43 | 23 | } |
|
44 | } |
||
46 |