2222use PhpParser \Node \Name ;
2323use PhpParser \Node \Stmt \Property as PropertyNode ;
2424
25+ use function method_exists ;
26+
2527/**
2628 * This class acts like a combination of a PropertyNode and PropertyProperty to
2729 * be able to create property descriptors using a normal strategy.
@@ -48,6 +50,20 @@ public function isPublic(): bool
4850 return $ this ->property ->isPublic ();
4951 }
5052
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+
5167 /**
5268 * returns true when the current property is protected.
5369 */
@@ -56,6 +72,20 @@ public function isProtected(): bool
5672 return $ this ->property ->isProtected ();
5773 }
5874
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+
5989 /**
6090 * returns true when the current property is private.
6191 */
@@ -64,6 +94,34 @@ public function isPrivate(): bool
6494 return $ this ->property ->isPrivate ();
6595 }
6696
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+
67125 /**
68126 * returns true when the current property is static.
69127 */
0 commit comments