ClassConst.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php declare(strict_types=1);
  2. namespace PhpParser\Node\Stmt;
  3. use PhpParser\Node;
  4. class ClassConst extends Node\Stmt
  5. {
  6. /** @var int Modifiers */
  7. public $flags;
  8. /** @var Node\Const_[] Constant declarations */
  9. public $consts;
  10. /**
  11. * Constructs a class const list node.
  12. *
  13. * @param Node\Const_[] $consts Constant declarations
  14. * @param int $flags Modifiers
  15. * @param array $attributes Additional attributes
  16. */
  17. public function __construct(array $consts, int $flags = 0, array $attributes = []) {
  18. parent::__construct($attributes);
  19. $this->flags = $flags;
  20. $this->consts = $consts;
  21. }
  22. public function getSubNodeNames() : array {
  23. return ['flags', 'consts'];
  24. }
  25. /**
  26. * Whether constant is explicitly or implicitly public.
  27. *
  28. * @return bool
  29. */
  30. public function isPublic() : bool {
  31. return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0
  32. || ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0;
  33. }
  34. /**
  35. * Whether constant is protected.
  36. *
  37. * @return bool
  38. */
  39. public function isProtected() : bool {
  40. return (bool) ($this->flags & Class_::MODIFIER_PROTECTED);
  41. }
  42. /**
  43. * Whether constant is private.
  44. *
  45. * @return bool
  46. */
  47. public function isPrivate() : bool {
  48. return (bool) ($this->flags & Class_::MODIFIER_PRIVATE);
  49. }
  50. public function getType() : string {
  51. return 'Stmt_ClassConst';
  52. }
  53. }