Ejemplo n.º 1
0
 /**
  * Extracts calls of method
  *
  * @param ReflectedMethod $method
  * @param integer $n
  * @param TokenCollection $tokens
  * @return $this
  */
 private function extractCalls(ReflectedMethod $method, $n, TokenCollection $tokens)
 {
     // $this->foo(), $c->foo()
     if (preg_match_all('!(\\$[\\w]*)\\-\\>(\\w*?)\\(!', $method->getContent(), $matches, PREG_SET_ORDER)) {
         foreach ($matches as $m) {
             $function = $m[2];
             if ('$this' == $m[1]) {
                 $method->pushInternalCall($function);
             } else {
                 $method->pushExternalCall($m[1], $function);
             }
         }
     }
     // (new X)->foo()
     if (preg_match_all('!\\(new (\\w+?).*?\\)\\->(\\w+)\\(!', $method->getContent(), $matches, PREG_SET_ORDER)) {
         foreach ($matches as $m) {
             $method->pushExternalCall($m[1], $m[2]);
         }
     }
 }