1: <?php declare(strict_types=1);
2:
3: namespace PhpParser\Node\Stmt;
4:
5: use PhpParser\Node;
6:
7: class ClassConst extends Node\Stmt
8: {
9: /** @var int Modifiers */
10: public $flags;
11: /** @var Node\Const_[] Constant declarations */
12: public $consts;
13: /** @var Node\AttributeGroup[] PHP attribute groups */
14: public $attrGroups;
15: /** @var Node\Identifier|Node\Name|Node\ComplexType|null Type declaration */
16: public $type;
17:
18: /**
19: * Constructs a class const list node.
20: *
21: * @param Node\Const_[] $consts Constant declarations
22: * @param int $flags Modifiers
23: * @param array $attributes Additional attributes
24: * @param Node\AttributeGroup[] $attrGroups PHP attribute groups
25: * @param null|string|Node\Identifier|Node\Name|Node\ComplexType $type Type declaration
26: */
27: public function __construct(
28: array $consts,
29: int $flags = 0,
30: array $attributes = [],
31: array $attrGroups = [],
32: $type = null
33: ) {
34: $this->attributes = $attributes;
35: $this->flags = $flags;
36: $this->consts = $consts;
37: $this->attrGroups = $attrGroups;
38: $this->type = \is_string($type) ? new Node\Identifier($type) : $type;
39: }
40:
41: public function getSubNodeNames() : array {
42: return ['attrGroups', 'flags', 'type', 'consts'];
43: }
44:
45: /**
46: * Whether constant is explicitly or implicitly public.
47: *
48: * @return bool
49: */
50: public function isPublic() : bool {
51: return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0
52: || ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0;
53: }
54:
55: /**
56: * Whether constant is protected.
57: *
58: * @return bool
59: */
60: public function isProtected() : bool {
61: return (bool) ($this->flags & Class_::MODIFIER_PROTECTED);
62: }
63:
64: /**
65: * Whether constant is private.
66: *
67: * @return bool
68: */
69: public function isPrivate() : bool {
70: return (bool) ($this->flags & Class_::MODIFIER_PRIVATE);
71: }
72:
73: /**
74: * Whether constant is final.
75: *
76: * @return bool
77: */
78: public function isFinal() : bool {
79: return (bool) ($this->flags & Class_::MODIFIER_FINAL);
80: }
81:
82: public function getType() : string {
83: return 'Stmt_ClassConst';
84: }
85: }
86: