/**
  * Tests if a function contains logic: any branching operator, function
  * call, or object instantiation.
  *
  * @param \Pharborist\ParentNode $node
  *  The node to test.
  *
  * @return boolean
  */
 public function __invoke(ParentNode $node)
 {
     $function_calls = $node->find(Filter::isInstanceOf('\\Pharborist\\Functions\\FunctionCallNode'))->not(function (FunctionCallNode $call) {
         return in_array($call->getName()->getText(), $this->whitelist);
     });
     if ($function_calls->isEmpty()) {
         $filter = call_user_func_array('\\Pharborist\\Filter::isInstanceOf', static::$logic);
         return (bool) $node->find($filter)->count();
     } else {
         return TRUE;
     }
 }
示例#2
0
文件: Node.php 项目: kidaa30/redcat
 /**
  * Get a unique key for sorting this node.
  *
  * Used to sort nodes into tree order. That is top to bottom and then left
  * to right.
  *
  * @return string
  */
 public function sortKey()
 {
     if ($this instanceof RootNode) {
         return spl_object_hash($this);
     }
     if (!$this->parent) {
         return '~/' . spl_object_hash($this);
     }
     $path = $this->parent->sortKey() . '/';
     $position = 0;
     $previous = $this->previous;
     while ($previous) {
         $position++;
         $previous = $previous->previous;
     }
     $path .= $position;
     return $path;
 }
示例#3
0
文件: Parser.php 项目: kidaa30/redcat
 /**
  * Match doc comment and its following skipped tokens to $parent.
  * @param ParentNode $parent
  * @param string $property_name
  */
 private function matchDocComment(ParentNode $parent, $property_name = 'docComment')
 {
     if ($this->docComment) {
         $parent->addChild($this->docComment, $property_name);
         $parent->addChildren($this->getSkipNodes($this->skippedDocComment));
         $this->skippedDocComment = [];
         $this->docComment = NULL;
     }
     $this->skipParent = NULL;
 }