/**
  * Constructs a new field declaration.
  */
 public function __construct()
 {
     parent::__construct(self::IMAGE);
 }
Beispiel #2
0
 /**
  * Collects all children from a given node.
  *
  * @param PHP_Depend_Code_ASTNode $node   The current root node.
  * @param array                   $actual Previous filled list.
  *
  * @return array(string)
  */
 protected function collectChildNodes(PHP_Depend_Code_ASTNode $node, array $actual = array())
 {
     foreach ($node->getChildren() as $child) {
         $actual[] = get_class($child);
         $actual = $this->collectChildNodes($child, $actual);
     }
     return $actual;
 }
Beispiel #3
0
 /**
  * Magic sleep method that returns an array with those property names that
  * should be cached for this node instance.
  *
  * @return array(string)
  */
 public function __sleep()
 {
     return array_merge(array('value'), parent::__sleep());
 }
Beispiel #4
0
 /**
  * This method parses the contents of a string or here-/now-doc node. It
  * will not consume the given stop token, so it is up to the calling method
  * to consume the stop token. The return value of this method is the prepared
  * input string node.
  *
  * @param PHP_Depend_Code_ASTNode $node      The parent string or nowdoc node.
  * @param integer                 $stopToken The stop token type.
  *
  * @return PHP_Depend_Code_ASTNode
  * @since 0.9.12
  */
 private function _parseStringExpressions(PHP_Depend_Code_ASTNode $node, $stopToken)
 {
     while (($tokenType = $this->tokenizer->peek()) != self::T_EOF) {
         switch ($tokenType) {
             case $stopToken:
                 break 2;
             case self::T_BACKSLASH:
                 $node->addChild($this->_parseEscapedASTLiteralString());
                 break;
             case self::T_DOLLAR:
                 $node->addChild($this->_parseCompoundVariableOrLiteral());
                 break;
             case self::T_VARIABLE:
                 $node->addChild($this->_parseVariable());
                 break;
             case self::T_CURLY_BRACE_OPEN:
                 $node->addChild($this->_parseCompoundExpressionOrLiteral());
                 break;
             default:
                 $node->addChild($this->_parseLiteral());
                 break;
         }
     }
     return $node;
 }
Beispiel #5
0
 /**
  * This method adds a new child node to this node instance.
  *
  * @param PHP_Depend_Code_ASTNode $node The new child node.
  *
  * @return void
  */
 public function addChild(PHP_Depend_Code_ASTNode $node)
 {
     $this->nodes[] = $node;
     $node->setParent($this);
 }
Beispiel #6
0
 /**
  * The magic sleep method will be called by PHP's runtime environment right
  * before an instance of this class gets serialized. It should return an
  * array with those property names that should be serialized for this class.
  *
  * @return array(string)
  * @since 0.10.0
  */
 public function __sleep()
 {
     return array_merge(array('default'), parent::__sleep());
 }
Beispiel #7
0
 /**
  * Collects all children from a given node.
  *
  * @param PHP_Depend_Code_ASTNode $node The current root node.
  *
  * @return array
  */
 protected static function collectGraph(PHP_Depend_Code_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;
 }
Beispiel #8
0
 /**
  * Constructs a new field declaration.
  */
 public function __construct()
 {
     parent::__construct(self::CLAZZ);
 }
Beispiel #9
0
 /**
  * Returns the name of the declaring source file.
  *
  * @return string
  */
 public function getFileName()
 {
     return (string) $this->_node->getSourceFile();
 }
Beispiel #10
0
 /**
  * The magic sleep method will be called by PHP's runtime environment right
  * before an instance of this class gets serialized. It should return an
  * array with those property names that should be serialized for this class.
  *
  * @return array(string)
  * @since 0.10.0
  */
 public function __sleep()
 {
     return array_merge(array('passedByReference'), parent::__sleep());
 }
Beispiel #11
0
 /**
  * Calculates the expression sum of the given node.
  *
  * @param PHP_Depend_Code_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 PHP_Depend_Code_ASTConditionalExpression) {
         $sum = PHP_Depend_Util_MathUtil::add($sum, $node->accept($this, 1));
     } else {
         if ($node instanceof PHP_Depend_Code_ASTBooleanAndExpression || $node instanceof PHP_Depend_Code_ASTBooleanOrExpression || $node instanceof PHP_Depend_Code_ASTLogicalAndExpression || $node instanceof PHP_Depend_Code_ASTLogicalOrExpression || $node instanceof PHP_Depend_Code_ASTLogicalXorExpression) {
             $sum = PHP_Depend_Util_MathUtil::add($sum, '1');
         } else {
             foreach ($node->getChildren() as $child) {
                 $expr = $this->sumComplexity($child);
                 $sum = PHP_Depend_Util_MathUtil::add($sum, $expr);
             }
         }
     }
     return $sum;
 }
Beispiel #12
0
 /**
  * The magic sleep method will be called by PHP's runtime environment right
  * before an instance of this class gets serialized. It should return an
  * array with those property names that should be serialized for this class.
  *
  * @return array(string)
  * @since 0.10.0
  */
 public function __sleep()
 {
     return array_merge(array('modifiers'), parent::__sleep());
 }
Beispiel #13
0
 /**
  * Visits a switch label.
  *
  * @param PHP_Depend_Code_ASTNode $node The currently visited node.
  * @param array(string=>integer)   $data The previously calculated ccn values.
  *
  * @return array(string=>integer)
  * @since 0.9.8
  */
 public function visitSwitchLabel($node, $data)
 {
     if (!$node->isDefault()) {
         ++$data[self::M_CYCLOMATIC_COMPLEXITY_1];
         ++$data[self::M_CYCLOMATIC_COMPLEXITY_2];
     }
     return $this->visit($node, $data);
 }