1: | <?php declare(strict_types=1); |
2: | |
3: | namespace PhpParser\Node\Stmt; |
4: | |
5: | use PhpParser\Modifiers; |
6: | use PhpParser\Node; |
7: | |
8: | class Class_ extends ClassLike { |
9: | |
10: | public const MODIFIER_PUBLIC = 1; |
11: | |
12: | public const MODIFIER_PROTECTED = 2; |
13: | |
14: | public const MODIFIER_PRIVATE = 4; |
15: | |
16: | public const MODIFIER_STATIC = 8; |
17: | |
18: | public const MODIFIER_ABSTRACT = 16; |
19: | |
20: | public const MODIFIER_FINAL = 32; |
21: | |
22: | public const MODIFIER_READONLY = 64; |
23: | |
24: | |
25: | public const VISIBILITY_MODIFIER_MASK = 7; |
26: | |
27: | |
28: | public int $flags; |
29: | |
30: | public ?Node\Name $extends; |
31: | |
32: | public array $implements; |
33: | |
34: | |
35: | |
36: | |
37: | |
38: | |
39: | |
40: | |
41: | |
42: | |
43: | |
44: | |
45: | |
46: | |
47: | |
48: | |
49: | |
50: | |
51: | |
52: | public function __construct($name, array $subNodes = [], array $attributes = []) { |
53: | $this->attributes = $attributes; |
54: | $this->flags = $subNodes['flags'] ?? $subNodes['type'] ?? 0; |
55: | $this->name = \is_string($name) ? new Node\Identifier($name) : $name; |
56: | $this->extends = $subNodes['extends'] ?? null; |
57: | $this->implements = $subNodes['implements'] ?? []; |
58: | $this->stmts = $subNodes['stmts'] ?? []; |
59: | $this->attrGroups = $subNodes['attrGroups'] ?? []; |
60: | } |
61: | |
62: | public function getSubNodeNames(): array { |
63: | return ['attrGroups', 'flags', 'name', 'extends', 'implements', 'stmts']; |
64: | } |
65: | |
66: | |
67: | |
68: | |
69: | public function isAbstract(): bool { |
70: | return (bool) ($this->flags & Modifiers::ABSTRACT); |
71: | } |
72: | |
73: | |
74: | |
75: | |
76: | public function isFinal(): bool { |
77: | return (bool) ($this->flags & Modifiers::FINAL); |
78: | } |
79: | |
80: | public function isReadonly(): bool { |
81: | return (bool) ($this->flags & Modifiers::READONLY); |
82: | } |
83: | |
84: | |
85: | |
86: | |
87: | public function isAnonymous(): bool { |
88: | return null === $this->name; |
89: | } |
90: | |
91: | public function getType(): string { |
92: | return 'Stmt_Class'; |
93: | } |
94: | } |
95: | |