22
22
use PhpParser \Node \Name ;
23
23
use PhpParser \Node \Stmt \Property as PropertyNode ;
24
24
25
+ use function method_exists ;
26
+
25
27
/**
26
28
* This class acts like a combination of a PropertyNode and PropertyProperty to
27
29
* be able to create property descriptors using a normal strategy.
@@ -48,6 +50,20 @@ public function isPublic(): bool
48
50
return $ this ->property ->isPublic ();
49
51
}
50
52
53
+ /**
54
+ * Returns async accessor value for current property.
55
+ *
56
+ * This method will return the same value as {@see self::isPublic()} when your phpparser version is < 5.2
57
+ */
58
+ public function isPublicSet (): bool
59
+ {
60
+ if ($ this ->isAsync () === false ) {
61
+ return $ this ->isPublic ();
62
+ }
63
+
64
+ return $ this ->property ->isPublic ();
65
+ }
66
+
51
67
/**
52
68
* returns true when the current property is protected.
53
69
*/
@@ -56,6 +72,20 @@ public function isProtected(): bool
56
72
return $ this ->property ->isProtected ();
57
73
}
58
74
75
+ /**
76
+ * Returns async accessor value for current property.
77
+ *
78
+ * This method will return the same value as {@see self::isProtected()} when your phpparser version is < 5.2
79
+ */
80
+ public function isProtectedSet (): bool
81
+ {
82
+ if ($ this ->isAsync () === false ) {
83
+ return $ this ->isProtected ();
84
+ }
85
+
86
+ return $ this ->property ->isProtectedSet ();
87
+ }
88
+
59
89
/**
60
90
* returns true when the current property is private.
61
91
*/
@@ -64,6 +94,34 @@ public function isPrivate(): bool
64
94
return $ this ->property ->isPrivate ();
65
95
}
66
96
97
+ /**
98
+ * Returns async accessor value for current property.
99
+ *
100
+ * This method will return the same value as {@see self::isPrivate()} when your phpparser version is < 5.2
101
+ */
102
+ public function isPrivateSet (): bool
103
+ {
104
+ if ($ this ->isAsync () === false ) {
105
+ return $ this ->isPrivate ();
106
+ }
107
+
108
+ return $ this ->property ->isPrivateSet ();
109
+ }
110
+
111
+ /**
112
+ * Returns true when current property has async accessors.
113
+ *
114
+ * This method will always return false when your phpparser version is < 5.2
115
+ */
116
+ public function isAsync (): bool
117
+ {
118
+ if (method_exists ($ this ->property , 'isPrivateSet ' ) === false ) {
119
+ return false ;
120
+ }
121
+
122
+ return $ this ->property ->isPublicSet () || $ this ->property ->isProtected () || $ this ->property ->isPrivateSet ();
123
+ }
124
+
67
125
/**
68
126
* returns true when the current property is static.
69
127
*/
0 commit comments