public function store_constant(Node\Expr\FuncCall $function_call)
 {
     $name = $function_call->args[0]->value->value;
     $value = $function_call->args[1]->value->value;
     if ($comments = $function_call->getAttribute('comments')) {
         $phpdoc = new DocBlock($comments[0]->getText());
         $description = $phpdoc->getShortDescription();
         // short circuit @ignore functions
         if ($phpdoc->hasTag('ignore')) {
             return;
         }
     } else {
         $description = '';
     }
     $this->store_model('constants', array('constant' => $name, 'namespace' => !empty($function_call->namespacedName) ? implode('\\', array_slice($function_call->namespacedName->parts, 0, -1)) : '', 'file' => $this->_current_file, 'line' => $function_call->getLine(), 'value' => $value, 'type' => $this->get_type_for_node($function_call->args[1]->value), 'description' => $description));
 }
예제 #2
0
 public function pExpr_FuncCall(\PhpParser\Node\Expr\FuncCall $node)
 {
     $firstToken = '';
     $lastToken = '';
     if (count($node->args) > 0) {
         if ($node->getAttribute('startLine') != reset($node->args)->getAttribute('startLine')) {
             $firstToken = LF . $this->indentToken;
         }
         if ($node->getAttribute('startLine') != end($node->args)->getAttribute('startLine')) {
             $lastToken = LF;
         }
     }
     return $this->p($node->name) . '(' . $firstToken . $this->pParameterNodes($node->args) . $lastToken . ')';
 }
예제 #3
0
 public function rewriteExpr_FuncCall(\PhpParser\Node\Expr\FuncCall $Node)
 {
     $arg_is_ref = [];
     if ($Node->name instanceof \PhpParser\Node\Name) {
         $str = $Node->name->toString();
         if (isset(self::$ignore_functions[$str])) {
             return null;
         }
         if (isset(SoftMocks::$internal_functions[$str])) {
             foreach ((new \ReflectionFunction($str))->getParameters() as $Param) {
                 $arg_is_ref[] = $Param->isPassedByReference();
             }
         }
         $name = new \PhpParser\Node\Scalar\String_($str);
     } else {
         // Expr
         $name = $Node->name;
     }
     $NewNode = new \PhpParser\Node\Expr\StaticCall(new \PhpParser\Node\Name("\\" . SoftMocks::class), "callFunction", [self::getNamespaceArg(), $name, self::nodeArgsToArray($Node->args, $arg_is_ref)]);
     $NewNode->setLine($Node->getLine());
     return $NewNode;
 }