ArrayItem.php 1.2 KB

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