Property.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace PhpParser\Node\Stmt;
  3. use PhpParser\Node;
  4. class Property extends Node\Stmt
  5. {
  6. /** @var int Modifiers */
  7. public $flags;
  8. /** @var PropertyProperty[] Properties */
  9. public $props;
  10. /** @deprecated Use $flags instead */
  11. public $type;
  12. /**
  13. * Constructs a class property list node.
  14. *
  15. * @param int $flags Modifiers
  16. * @param PropertyProperty[] $props Properties
  17. * @param array $attributes Additional attributes
  18. */
  19. public function __construct($flags, array $props, array $attributes = array()) {
  20. parent::__construct($attributes);
  21. $this->flags = $flags;
  22. $this->type = $flags;
  23. $this->props = $props;
  24. }
  25. public function getSubNodeNames() {
  26. return array('flags', 'props');
  27. }
  28. public function isPublic() {
  29. return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0
  30. || ($this->flags & Class_::VISIBILITY_MODIFER_MASK) === 0;
  31. }
  32. public function isProtected() {
  33. return (bool) ($this->flags & Class_::MODIFIER_PROTECTED);
  34. }
  35. public function isPrivate() {
  36. return (bool) ($this->flags & Class_::MODIFIER_PRIVATE);
  37. }
  38. public function isStatic() {
  39. return (bool) ($this->flags & Class_::MODIFIER_STATIC);
  40. }
  41. }