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