diff --git a/lib/PhpParser/Node/Expr/NullsafeMethodCall.php b/lib/PhpParser/Node/Expr/NullsafeMethodCall.php index 361e446..07a571f 100644 --- a/lib/PhpParser/Node/Expr/NullsafeMethodCall.php +++ b/lib/PhpParser/Node/Expr/NullsafeMethodCall.php @@ -5,23 +5,24 @@ namespace PhpParser\Node\Expr; use PhpParser\Node\Arg; use PhpParser\Node\Expr; use PhpParser\Node\Identifier; +use PhpParser\Node\VariadicPlaceholder; -class NullsafeMethodCall extends Expr +class NullsafeMethodCall extends CallLike { /** @var Expr Variable holding object */ public $var; /** @var Identifier|Expr Method name */ public $name; - /** @var Arg[] Arguments */ + /** @var array Arguments */ public $args; /** * Constructs a nullsafe method call node. * - * @param Expr $var Variable holding object - * @param string|Identifier|Expr $name Method name - * @param Arg[] $args Arguments - * @param array $attributes Additional attributes + * @param Expr $var Variable holding object + * @param string|Identifier|Expr $name Method name + * @param array $args Arguments + * @param array $attributes Additional attributes */ public function __construct(Expr $var, $name, array $args = [], array $attributes = []) { $this->attributes = $attributes; @@ -37,4 +38,8 @@ class NullsafeMethodCall extends Expr public function getType() : string { return 'Expr_NullsafeMethodCall'; } + + public function getRawArgs(): array { + return $this->args; + } } diff --git a/test/code/parser/expr/firstClassCallables.test b/test/code/parser/expr/firstClassCallables.test index 1e15a98..0b2ff3d 100644 --- a/test/code/parser/expr/firstClassCallables.test +++ b/test/code/parser/expr/firstClassCallables.test @@ -7,6 +7,7 @@ A::foo(...); // These are invalid, but accepted on the parser level. new Foo(...); +$this?->foo(...); #[Foo(...)] function foo() {} @@ -75,7 +76,21 @@ array( 0: // These are invalid, but accepted on the parser level. ) ) - 4: Stmt_Function( + 4: Stmt_Expression( + expr: Expr_NullsafeMethodCall( + var: Expr_Variable( + name: this + ) + name: Identifier( + name: foo + ) + args: array( + 0: VariadicPlaceholder( + ) + ) + ) + ) + 5: Stmt_Function( attrGroups: array( 0: AttributeGroup( attrs: array(