This method returns all direct children of the actual node.
public getChildren ( ) : PDepend\Source\AST\ASTNode[] | ||
return | PDepend\Source\AST\ASTNode[] |
/** * Calculates the expression sum of the given node. * * @param \PDepend\Source\AST\ASTNode $node The currently visited node. * * @return string * @since 0.9.12 * @todo I don't like this method implementation, it should be possible to * implement this method with more visitor behavior for the boolean * and logical expressions. */ public function sumComplexity($node) { $sum = '0'; if ($node instanceof ASTConditionalExpression) { $sum = MathUtil::add($sum, $node->accept($this, 1)); } elseif ($node instanceof ASTBooleanAndExpression || $node instanceof ASTBooleanOrExpression || $node instanceof ASTLogicalAndExpression || $node instanceof ASTLogicalOrExpression || $node instanceof ASTLogicalXorExpression) { $sum = MathUtil::add($sum, '1'); } else { foreach ($node->getChildren() as $child) { $expr = $this->sumComplexity($child); $sum = MathUtil::add($sum, $expr); } } return $sum; }
/** * Collects all children from a given node. * * @param \PDepend\Source\AST\ASTNode $node The current root node. * * @return array */ protected static function collectGraph(ASTNode $node) { $graph = array(); foreach ($node->getChildren() as $child) { $graph[] = get_class($child) . ' (' . $child->getImage() . ')'; if (0 < count($child->getChildren())) { $graph[] = self::collectGraph($child); } } return $graph; }