Beispiel #1
0
 /**
  * collect method calls
  *
  * @param PHPParser_Node_Stmt $stmt
  * @return int Number of called methods
  */
 protected function _collectMethodCalls($stmt, $xmlTree)
 {
     $numberOfMethodCalls = 0;
     $methodCallXPath = '//node:Expr_MethodCall | //node:Expr_StaticCall';
     $methodCalls = $xmlTree->xpath($methodCallXPath);
     foreach ($methodCalls as $call) {
         $methodName = $call->xpath('./subNode:name/scalar:string/text()');
         if (false === $methodName) {
             continue;
         }
         $methodName = current($methodName);
         if (is_array($methodName)) {
             $methodName = current($methodName);
         }
         $variable = current($call->xpath('./subNode:var | ./subNode:class'));
         $object = $this->_getResultType($variable);
         if (false == $object) {
             continue;
         }
         if ($this->_isPhpMethod($object, $methodName)) {
             continue;
         }
         if ($this->_isCallabilityChecked($call, $object, $methodName)) {
             Logger::addComment($this->_extensionPath, 'MageCompatibility', sprintf('<info>Found version switch</info> for %s::%s', $object, $methodName));
             continue;
         }
         if (false == $this->_isExtensionMethod($object, $methodName)) {
             $method = new Method((string) $methodName, $this->_getArgs($call), array('class' => $object));
             ++$numberOfMethodCalls;
             $this->_usedMethods->add($method);
         }
     }
     return $numberOfMethodCalls;
 }