No Description

ClassConst.php 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. /**
  60. * Whether constant is final.
  61. *
  62. * @return bool
  63. */
  64. public function isFinal() : bool {
  65. return (bool) ($this->flags & Class_::MODIFIER_FINAL);
  66. }
  67. public function getType() : string {
  68. return 'Stmt_ClassConst';
  69. }
  70. }