Debian Codegraph @

vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassConst.php

raw
1 <?php declare(strict_types=1);
2
3 namespace PhpParser\Node\Stmt;
4
5 use PhpParser\Modifiers;
6 use PhpParser\Node;
7
8 class ClassConst extends Node\Stmt {
9 /** @var int Modifiers */
10 public int $flags;
11 /** @var Node\Const_[] Constant declarations */
12 public array $consts;
13 /** @var Node\AttributeGroup[] PHP attribute groups */
14 public array $attrGroups;
15 /** @var Node\Identifier|Node\Name|Node\ComplexType|null Type declaration */
16 public ?Node $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<string, mixed> $attributes Additional attributes
24 * @param list<Node\AttributeGroup> $attrGroups PHP attribute groups
25 * @param null|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 ?Node $type = null
33 ) {
34 $this->attributes = $attributes;
35 $this->flags = $flags;
36 $this->consts = $consts;
37 $this->attrGroups = $attrGroups;
38 $this->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 public function isPublic(): bool {
49 return ($this->flags & Modifiers::PUBLIC) !== 0
50 || ($this->flags & Modifiers::VISIBILITY_MASK) === 0;
51 }
52
53 /**
54 * Whether constant is protected.
55 */
56 public function isProtected(): bool {
57 return (bool) ($this->flags & Modifiers::PROTECTED);
58 }
59
60 /**
61 * Whether constant is private.
62 */
63 public function isPrivate(): bool {
64 return (bool) ($this->flags & Modifiers::PRIVATE);
65 }
66
67 /**
68 * Whether constant is final.
69 */
70 public function isFinal(): bool {
71 return (bool) ($this->flags & Modifiers::FINAL);
72 }
73
74 public function getType(): string {
75 return 'Stmt_ClassConst';
76 }
77 }