/**
  * {@inheritdoc}
  */
 public function get($id)
 {
     $all = new NodeCollection([]);
     $files = $this->getQuery(['file'])->distinct(TRUE)->condition('id', $id)->execute()->fetchCol();
     array_walk($files, function ($file) use($all, $id) {
         $all->add($this->target->open($file)->find(Filter::isFunctionCall($id)));
     });
     return $all;
 }
Exemplo n.º 2
0
 /**
  * Get the values of the array.
  *
  * @param boolean $recursive
  *   (optional) TRUE to get values of array elements that are also arrays.
  *
  * @return NodeCollection
  */
 public function getValues($recursive = TRUE)
 {
     $values = new NodeCollection();
     foreach ($this->elements->getItems() as $element) {
         if ($element instanceof ArrayPairNode) {
             $value = $element->getValue();
             if ($recursive && $value instanceof ArrayNode) {
                 $values->add($value->getValues($recursive));
             } else {
                 $values->add($value);
             }
         } else {
             $values->add($element);
         }
     }
     return $values;
 }
Exemplo n.º 3
0
 /**
  * Finds every rewritable expression in the function body.
  *
  * @param \Pharborist\Functions\ParameterNode $parameter
  *  The parameter on which the rewrite is based.
  *
  * @return \Pharborist\NodeCollection
  */
 protected function getExpressions(ParameterNode $parameter)
 {
     $filter = Filter::isInstanceOf('\\Pharborist\\ArrayLookupNode', '\\Pharborist\\Objects\\ObjectPropertyNode');
     $expressions = new NodeCollection();
     $parameter->getFunction()->find(Filter::isInstanceOf('\\Pharborist\\Variables\\VariableNode'))->filter(function (VariableNode $variable) use($parameter) {
         return $variable->getName() == $parameter->getName();
     })->each(function (VariableNode $variable) use($filter, $expressions) {
         $root = $variable->furthest($filter);
         if ($root) {
             $expressions->add($root);
         }
     });
     return $expressions;
 }
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testInvalidAdd()
 {
     $collection = new NodeCollection([], FALSE);
     $collection->add(NULL);
 }