Chris@0
|
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@4
|
6 use PhpParser\Node\Identifier;
|
Chris@4
|
7 use PhpParser\Node\Name;
|
Chris@4
|
8 use PhpParser\Node\NullableType;
|
Chris@0
|
9
|
Chris@0
|
10 class Property extends Node\Stmt
|
Chris@0
|
11 {
|
Chris@0
|
12 /** @var int Modifiers */
|
Chris@0
|
13 public $flags;
|
Chris@0
|
14 /** @var PropertyProperty[] Properties */
|
Chris@0
|
15 public $props;
|
Chris@4
|
16 /** @var null|Identifier|Name|NullableType Type declaration */
|
Chris@4
|
17 public $type;
|
Chris@0
|
18
|
Chris@0
|
19 /**
|
Chris@0
|
20 * Constructs a class property list node.
|
Chris@0
|
21 *
|
Chris@4
|
22 * @param int $flags Modifiers
|
Chris@4
|
23 * @param PropertyProperty[] $props Properties
|
Chris@4
|
24 * @param array $attributes Additional attributes
|
Chris@4
|
25 * @param null|string|Identifier|Name|NullableType $type Type declaration
|
Chris@0
|
26 */
|
Chris@4
|
27 public function __construct(int $flags, array $props, array $attributes = [], $type = null) {
|
Chris@0
|
28 parent::__construct($attributes);
|
Chris@0
|
29 $this->flags = $flags;
|
Chris@0
|
30 $this->props = $props;
|
Chris@4
|
31 $this->type = \is_string($type) ? new Identifier($type) : $type;
|
Chris@0
|
32 }
|
Chris@0
|
33
|
Chris@0
|
34 public function getSubNodeNames() : array {
|
Chris@4
|
35 return ['flags', 'type', 'props'];
|
Chris@0
|
36 }
|
Chris@0
|
37
|
Chris@0
|
38 /**
|
Chris@0
|
39 * Whether the property is explicitly or implicitly public.
|
Chris@0
|
40 *
|
Chris@0
|
41 * @return bool
|
Chris@0
|
42 */
|
Chris@0
|
43 public function isPublic() : bool {
|
Chris@0
|
44 return ($this->flags & Class_::MODIFIER_PUBLIC) !== 0
|
Chris@0
|
45 || ($this->flags & Class_::VISIBILITY_MODIFIER_MASK) === 0;
|
Chris@0
|
46 }
|
Chris@0
|
47
|
Chris@0
|
48 /**
|
Chris@0
|
49 * Whether the property is protected.
|
Chris@0
|
50 *
|
Chris@0
|
51 * @return bool
|
Chris@0
|
52 */
|
Chris@0
|
53 public function isProtected() : bool {
|
Chris@0
|
54 return (bool) ($this->flags & Class_::MODIFIER_PROTECTED);
|
Chris@0
|
55 }
|
Chris@0
|
56
|
Chris@0
|
57 /**
|
Chris@0
|
58 * Whether the property is private.
|
Chris@0
|
59 *
|
Chris@0
|
60 * @return bool
|
Chris@0
|
61 */
|
Chris@0
|
62 public function isPrivate() : bool {
|
Chris@0
|
63 return (bool) ($this->flags & Class_::MODIFIER_PRIVATE);
|
Chris@0
|
64 }
|
Chris@0
|
65
|
Chris@0
|
66 /**
|
Chris@0
|
67 * Whether the property is static.
|
Chris@0
|
68 *
|
Chris@0
|
69 * @return bool
|
Chris@0
|
70 */
|
Chris@0
|
71 public function isStatic() : bool {
|
Chris@0
|
72 return (bool) ($this->flags & Class_::MODIFIER_STATIC);
|
Chris@0
|
73 }
|
Chris@4
|
74
|
Chris@0
|
75 public function getType() : string {
|
Chris@0
|
76 return 'Stmt_Property';
|
Chris@0
|
77 }
|
Chris@0
|
78 }
|