PropertyItem.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php declare(strict_types=1);
  2. namespace PhpParser\Node;
  3. use PhpParser\Node;
  4. use PhpParser\NodeAbstract;
  5. class PropertyItem extends NodeAbstract {
  6. /** @var Node\VarLikeIdentifier Name */
  7. public VarLikeIdentifier $name;
  8. /** @var null|Node\Expr Default */
  9. public ?Expr $default;
  10. /**
  11. * Constructs a class property item node.
  12. *
  13. * @param string|Node\VarLikeIdentifier $name Name
  14. * @param null|Node\Expr $default Default value
  15. * @param array<string, mixed> $attributes Additional attributes
  16. */
  17. public function __construct($name, ?Node\Expr $default = null, array $attributes = []) {
  18. $this->attributes = $attributes;
  19. $this->name = \is_string($name) ? new Node\VarLikeIdentifier($name) : $name;
  20. $this->default = $default;
  21. }
  22. public function getSubNodeNames(): array {
  23. return ['name', 'default'];
  24. }
  25. public function getType(): string {
  26. return 'PropertyItem';
  27. }
  28. }
  29. // @deprecated compatibility alias
  30. class_alias(PropertyItem::class, Stmt\PropertyProperty::class);