Skip to content

Commit 73b160f

Browse files
ondrejmirtesnikic
authored andcommitted
Add flags helper methods Property::isAbstract() and Property::isFinal()
1 parent 4f9dc8b commit 73b160f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

lib/PhpParser/Node/Stmt/Property.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,20 @@ public function isReadonly(): bool {
8080
return (bool) ($this->flags & Modifiers::READONLY);
8181
}
8282

83+
/**
84+
* Whether the property is abstract.
85+
*/
86+
public function isAbstract(): bool {
87+
return (bool) ($this->flags & Modifiers::ABSTRACT);
88+
}
89+
90+
/**
91+
* Whether the property is final.
92+
*/
93+
public function isFinal(): bool {
94+
return (bool) ($this->flags & Modifiers::FINAL);
95+
}
96+
8397
/**
8498
* Whether the property has explicit public(set) visibility.
8599
*/

test/PhpParser/Node/Stmt/PropertyTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,14 @@ public function testSetVisibility() {
5757
$node = new Property(Modifiers::PUBLIC_SET, []);
5858
$this->assertTrue($node->isPublicSet());
5959
}
60+
61+
public function testIsFinal() {
62+
$node = new Property(Modifiers::FINAL, []);
63+
$this->assertTrue($node->isFinal());
64+
}
65+
66+
public function testIsAbstract() {
67+
$node = new Property(Modifiers::ABSTRACT, []);
68+
$this->assertTrue($node->isAbstract());
69+
}
6070
}

0 commit comments

Comments
 (0)