File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 22
33namespace PhpParser \Node ;
44
5+ use PhpParser \Modifiers ;
56use PhpParser \Node \Stmt \Return_ ;
67use PhpParser \NodeAbstract ;
78
@@ -58,6 +59,13 @@ public function getReturnType() {
5859 return null ;
5960 }
6061
62+ /**
63+ * Whether the property hook is final.
64+ */
65+ public function isFinal (): bool {
66+ return (bool ) ($ this ->flags & Modifiers::FINAL );
67+ }
68+
6169 public function getStmts (): ?array {
6270 if ($ this ->body instanceof Expr) {
6371 return [new Return_ ($ this ->body )];
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ namespace PhpParser \Node ;
4+
5+ use PhpParser \Modifiers ;
6+
7+ class PropertyHookTest extends \PHPUnit \Framework \TestCase {
8+ /**
9+ * @dataProvider provideModifiers
10+ */
11+ public function testModifiers ($ modifier ): void {
12+ $ node = new PropertyHook (
13+ 'get ' ,
14+ null ,
15+ [
16+ 'flags ' => constant (Modifiers::class . ':: ' . strtoupper ($ modifier )),
17+ ]
18+ );
19+
20+ $ this ->assertTrue ($ node ->{'is ' . $ modifier }());
21+ }
22+
23+ public function testNoModifiers (): void {
24+ $ node = new PropertyHook ('get ' , null );
25+
26+ $ this ->assertFalse ($ node ->isFinal ());
27+ }
28+
29+ public static function provideModifiers () {
30+ return [
31+ ['final ' ],
32+ ];
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments