|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace PhpParser\Node\Expr; |
| 4 | + |
| 5 | +use PhpParser\Node; |
| 6 | +use PhpParser\NodeAbstract; |
| 7 | +use PhpParser\Node\Arg; |
| 8 | +use PhpParser\Node\Expr; |
| 9 | +use PhpParser\Node\Identifier; |
| 10 | +use PhpParser\Node\VariadicPlaceholder; |
| 11 | +use PhpParser\Node\FunctionLike; |
| 12 | + |
| 13 | +abstract class CallLike extends Expr { |
| 14 | + /** |
| 15 | + * Return raw arguments, which may be actual Args, or VariadicPlaceholders for first-class |
| 16 | + * callables. |
| 17 | + * |
| 18 | + * @return list<Arg|VariadicPlaceholder> |
| 19 | + */ |
| 20 | + abstract public function getRawArgs(): array; |
| 21 | + /** |
| 22 | + * Assert that this is not a first-class callable and return only ordinary Args. |
| 23 | + * |
| 24 | + * @return list<Arg> |
| 25 | + */ |
| 26 | + public function getArgs(): array { |
| 27 | + assert(!$this->isFirstClassCallable()); |
| 28 | + return $this->getRawArgs(); |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +class FuncCall extends CallLike { |
| 33 | + /** @var list<Node\Arg|Node\VariadicPlaceholder> Arguments */ |
| 34 | + public array $args; |
| 35 | + |
| 36 | + /** |
| 37 | + * Constructs a function call node. |
| 38 | + * |
| 39 | + * @param Node\Name|Expr $name Function name |
| 40 | + * @param list<Node\Arg|Node\VariadicPlaceholder> $args Arguments |
| 41 | + * @param array<string, mixed> $attributes Additional attributes |
| 42 | + */ |
| 43 | + public function __construct(Node $name, array $args = [], array $attributes = []) {} |
| 44 | +} |
| 45 | + |
| 46 | +class MethodCall extends CallLike { |
| 47 | + /** @var list<Node\Arg|Node\VariadicPlaceholder> Arguments */ |
| 48 | + public array $args; |
| 49 | + |
| 50 | + /** |
| 51 | + * Constructs a function call node. |
| 52 | + * |
| 53 | + * @param Expr $var Variable holding object |
| 54 | + * @param string|Identifier|Expr $name Method name |
| 55 | + * @param list<Arg|VariadicPlaceholder> $args Arguments |
| 56 | + * @param array<string, mixed> $attributes Additional attributes |
| 57 | + */ |
| 58 | + public function __construct(Expr $var, $name, array $args = [], array $attributes = []) {} |
| 59 | +} |
| 60 | + |
| 61 | +class New_ extends CallLike { |
| 62 | + /** @var list<Arg|VariadicPlaceholder> Arguments */ |
| 63 | + public array $args; |
| 64 | + |
| 65 | + /** |
| 66 | + * Constructs a function call node. |
| 67 | + * |
| 68 | + * @param Node\Name|Expr|Node\Stmt\Class_ $class Class name (or class node for anonymous classes) |
| 69 | + * @param list<Arg|VariadicPlaceholder> $args Arguments |
| 70 | + * @param array<string, mixed> $attributes Additional attributes |
| 71 | + */ |
| 72 | + public function __construct(Node $class, array $args = [], array $attributes = []) {} |
| 73 | +} |
| 74 | + |
| 75 | +class NullsafeMethodCall extends CallLike { |
| 76 | + /** @var list<Arg|VariadicPlaceholder> Arguments */ |
| 77 | + public array $args; |
| 78 | + |
| 79 | + /** |
| 80 | + * Constructs a nullsafe method call node. |
| 81 | + * |
| 82 | + * @param Expr $var Variable holding object |
| 83 | + * @param string|Identifier|Expr $name Method name |
| 84 | + * @param list<Arg|VariadicPlaceholder> $args Arguments |
| 85 | + * @param array<string, mixed> $attributes Additional attributes |
| 86 | + */ |
| 87 | + public function __construct(Expr $var, $name, array $args = [], array $attributes = []) {} |
| 88 | +} |
| 89 | + |
| 90 | +class StaticCall extends CallLike { |
| 91 | + /** @var list<Arg|VariadicPlaceholder> Arguments */ |
| 92 | + public array $args; |
| 93 | + |
| 94 | + /** |
| 95 | + * Constructs a static method call node. |
| 96 | + * |
| 97 | + * @param Node\Name|Expr $class Class name |
| 98 | + * @param string|Identifier|Expr $name Method name |
| 99 | + * @param list<Arg|VariadicPlaceholder> $args Arguments |
| 100 | + * @param array<string, mixed> $attributes Additional attributes |
| 101 | + */ |
| 102 | + public function __construct(Node $class, $name, array $args = [], array $attributes = []) {} |
| 103 | +} |
| 104 | + |
| 105 | +class Closure extends Expr implements FunctionLike { |
| 106 | + /** @var list<Node\Stmt> Statements */ |
| 107 | + public array $stmts; |
| 108 | +} |
0 commit comments