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: {
9: /** @var Expr Condition */
10: public $cond;
11: /** @var null|Expr Expression for true */
12: public $if;
13: /** @var Expr Expression for false */
14: public $else;
15:
16: /**
17: * Constructs a ternary operator node.
18: *
19: * @param Expr $cond Condition
20: * @param null|Expr $if Expression for true
21: * @param Expr $else Expression for false
22: * @param array $attributes Additional attributes
23: */
24: public function __construct(Expr $cond, $if, Expr $else, array $attributes = []) {
25: $this->attributes = $attributes;
26: $this->cond = $cond;
27: $this->if = $if;
28: $this->else = $else;
29: }
30:
31: public function getSubNodeNames() : array {
32: return ['cond', 'if', 'else'];
33: }
34:
35: public function getType() : string {
36: return 'Expr_Ternary';
37: }
38: }
39: