/**
  * @param Collection $collection
  * @return Collection
  */
 protected function findTokens(Collection $collection)
 {
     $query = new Query();
     $query->valueLike('!\\n[ ]+\\n!');
     $query->typeIs(T_WHITESPACE);
     return $collection->find($query);
 }
 /**
  * Updates the value of the constant named $key to $value
  *
  * @param mixed $key
  * @param mixed $value
  * @return string
  */
 public function modify($key, $value)
 {
     $tokens = Collection::createFromString($this->source);
     $query = new Query();
     $query->typeIs(T_CONST);
     $constants = $tokens->find($query);
     foreach ($constants as $constant) {
         $this->handleConstant($tokens, $constant, $key, $value);
     }
     return $tokens->assemble();
 }
Example #3
0
 /**
  * @param \Funivan\PhpTokenizer\Collection $collection
  * @return \Funivan\PhpTokenizer\Collection
  */
 protected function findTags(Collection $collection)
 {
     $query = new Query();
     $query->typeIs(T_OPEN_TAG);
     if ($this->useShortTags()) {
         $query->valueLike('!^<\\?php\\s+!');
         // long php tag contains also spaces
     } else {
         $query->valueIs('<?');
     }
     return $collection->find($query);
 }