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));
 }
Beispiel #2
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;
 }