ArrayItem.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. /** @var bool Whether to unpack the argument */
  13. public $unpack;
  14. /**
  15. * Constructs an array item node.
  16. *
  17. * @param Expr $value Value
  18. * @param null|Expr $key Key
  19. * @param bool $byRef Whether to assign by reference
  20. * @param array $attributes Additional attributes
  21. */
  22. public function __construct(Expr $value, Expr $key = null, bool $byRef = false, array $attributes = [], bool $unpack = false) {
  23. $this->attributes = $attributes;
  24. $this->key = $key;
  25. $this->value = $value;
  26. $this->byRef = $byRef;
  27. $this->unpack = $unpack;
  28. }
  29. public function getSubNodeNames() : array {
  30. return ['key', 'value', 'byRef', 'unpack'];
  31. }
  32. public function getType() : string {
  33. return 'Expr_ArrayItem';
  34. }
  35. }