ClassConst.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. /** @var Node\AttributeGroup[] */
  11. public $attrGroups;
  12. /**
  13. * Constructs a class const list node.
  14. *
  15. * @param Node\Const_[] $consts Constant declarations
  16. * @param int $flags Modifiers
  17. * @param array $attributes Additional attributes
  18. * @param Node\AttributeGroup[] $attrGroups PHP attribute groups
  19. */
  20. public function __construct(
  21. array $consts,
  22. int $flags = 0,
  23. array $attributes = [],
  24. array $attrGroups = []
  25. ) {
  26. $this->attributes = $attributes;
  27. $this->flags = $flags;
  28. $this->consts = $consts;
  29. $this->attrGroups = $attrGroups;
  30. }
  31. public function getSubNodeNames() : array {
  32. return ['attrGroups', 'flags', 'consts'];
  33. }
  34. /**
  35. * Whether constant is explicitly or implicitly public.
  36. *
  37. * @return bool
  38. */
  39. public function isPublic() : bool {
  40. return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0
  41. || ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0;
  42. }
  43. /**
  44. * Whether constant is protected.
  45. *
  46. * @return bool
  47. */
  48. public function isProtected() : bool {
  49. return (bool) ($this->flags & Class_::MODIFIER_PROTECTED);
  50. }
  51. /**
  52. * Whether constant is private.
  53. *
  54. * @return bool
  55. */
  56. public function isPrivate() : bool {
  57. return (bool) ($this->flags & Class_::MODIFIER_PRIVATE);
  58. }
  59. public function getType() : string {
  60. return 'Stmt_ClassConst';
  61. }
  62. }