| Conditions | 4 |
| Paths | 4 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | public function apply(AbstractNode $node) |
||
| 21 | { |
||
| 22 | $allowedChildren = $this->getStringProperty('allowedChildren'); |
||
| 23 | $allowedClasses = $this->getAllowedClasses($allowedChildren); |
||
| 24 | $returnStatements = $node->findChildrenOfType('ReturnStatement'); |
||
| 25 | |||
| 26 | /** @var AbstractNode|ASTReturnStatement $returnStatement */ |
||
| 27 | foreach ($returnStatements as $returnStatement) { |
||
| 28 | foreach ($returnStatement->getChildren() as $child) { |
||
| 29 | $reflectChild = new \ReflectionClass($child); |
||
| 30 | |||
| 31 | if (false === in_array($reflectChild->getShortName(), $allowedClasses)) { |
||
| 32 | $this->addViolation($returnStatement, [$allowedChildren]); |
||
| 33 | } |
||
| 34 | } |
||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 55 |