1: <?php declare(strict_types=1);
2:
3: namespace PhpParser\Node\Expr;
4:
5: use PhpParser\Node\Expr;
6:
7: class Ternary extends Expr {
8: /** @var Expr Condition */
9: public Expr $cond;
10: /** @var null|Expr Expression for true */
11: public ?Expr $if;
12: /** @var Expr Expression for false */
13: public Expr $else;
14:
15: /**
16: * Constructs a ternary operator node.
17: *
18: * @param Expr $cond Condition
19: * @param null|Expr $if Expression for true
20: * @param Expr $else Expression for false
21: * @param array<string, mixed> $attributes Additional attributes
22: */
23: public function __construct(Expr $cond, ?Expr $if, Expr $else, array $attributes = []) {
24: $this->attributes = $attributes;
25: $this->cond = $cond;
26: $this->if = $if;
27: $this->else = $else;
28: }
29:
30: public function getSubNodeNames(): array {
31: return ['cond', 'if', 'else'];
32: }
33:
34: public function getType(): string {
35: return 'Expr_Ternary';
36: }
37: }
38: