PhpMigration\Utils\ParserHelper::isDynamicCall PHP Method

isDynamicCall() public static method

public static isDynamicCall ( PhpParser\Node $node )
$node PhpParser\Node
    public static function isDynamicCall(Node $node)
    {
        /**
         * Due to the mechanism of dynamic script programming language,
         * it's TOO hard to guess what the callname exactly references to.
         * eg: $_GET['func']($arg)
         */
        if ($node instanceof Expr\MethodCall) {
            return !is_string($node->name);
        } elseif ($node instanceof Expr\StaticCall) {
            return !is_string($node->name) || $node->class instanceof Expr\Variable;
        } elseif ($node instanceof Expr\FuncCall) {
            return !$node->name instanceof Name;
        } else {
            throw new \Exception('Invalid function, method call node (' . get_class($node) . ')');
        }
    }

Usage Example

 public function leaveNode($node)
 {
     /**
      * {Description}
      * These words have special meaning in PHP. Some of them represent
      * things which look like functions, some look like constants, and so
      * on - but they're not, really: they are language constructs. You
      * cannot use any of the following words as constants, class names,
      * function or method names. Using them as variable names is generally
      * OK, but could lead to confusion.
      *
      * {Reference}
      * http://php.net/manual/en/reserved.keywords.php
      */
     $name = null;
     if ($node instanceof Stmt\ClassLike || $node instanceof Stmt\Function_ || $node instanceof Stmt\ClassMethod || $node instanceof Expr\MethodCall || $node instanceof Expr\StaticCall || $node instanceof Expr\ConstFetch || $node instanceof Expr\FuncCall && !ParserHelper::isDynamicCall($node)) {
         $name = $node->migName;
     }
     if (!is_null($name) && $this->wordTable->has($name)) {
         $this->addSpot('FATAL', true, 'Keyword "' . $name . '" is reserved');
     }
 }
All Usage Examples Of PhpMigration\Utils\ParserHelper::isDynamicCall