xref: /PHP-Parser/lib/PhpParser/Node/Arg.php (revision 2d3dd4e2)
1<?php declare(strict_types=1);
2
3namespace PhpParser\Node;
4
5use PhpParser\NodeAbstract;
6
7class Arg extends NodeAbstract {
8    /** @var Identifier|null Parameter name (for named parameters) */
9    public ?Identifier $name;
10    /** @var Expr Value to pass */
11    public Expr $value;
12    /** @var bool Whether to pass by ref */
13    public bool $byRef;
14    /** @var bool Whether to unpack the argument */
15    public bool $unpack;
16
17    /**
18     * Constructs a function call argument node.
19     *
20     * @param Expr $value Value to pass
21     * @param bool $byRef Whether to pass by ref
22     * @param bool $unpack Whether to unpack the argument
23     * @param array<string, mixed> $attributes Additional attributes
24     * @param Identifier|null $name Parameter name (for named parameters)
25     */
26    public function __construct(
27        Expr $value, bool $byRef = false, bool $unpack = false, array $attributes = [],
28        ?Identifier $name = null
29    ) {
30        $this->attributes = $attributes;
31        $this->name = $name;
32        $this->value = $value;
33        $this->byRef = $byRef;
34        $this->unpack = $unpack;
35    }
36
37    public function getSubNodeNames(): array {
38        return ['name', 'value', 'byRef', 'unpack'];
39    }
40
41    public function getType(): string {
42        return 'Arg';
43    }
44}
45