ArrayItem.php 985 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php declare(strict_types=1);
  2. namespace PhpParser\Node\Expr;
  3. use PhpParser\Node\Expr;
  4. class ArrayItem extends Expr
  5. {
  6. /** @var null|Expr Key */
  7. public $key;
  8. /** @var Expr Value */
  9. public $value;
  10. /** @var bool Whether to assign by reference */
  11. public $byRef;
  12. /**
  13. * Constructs an array item node.
  14. *
  15. * @param Expr $value Value
  16. * @param null|Expr $key Key
  17. * @param bool $byRef Whether to assign by reference
  18. * @param array $attributes Additional attributes
  19. */
  20. public function __construct(Expr $value, Expr $key = null, bool $byRef = false, array $attributes = []) {
  21. parent::__construct($attributes);
  22. $this->key = $key;
  23. $this->value = $value;
  24. $this->byRef = $byRef;
  25. }
  26. public function getSubNodeNames() : array {
  27. return ['key', 'value', 'byRef'];
  28. }
  29. public function getType() : string {
  30. return 'Expr_ArrayItem';
  31. }
  32. }