forked from nikic/PHP-Parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
PropertyHook::isFinal()
helper method with tests
- Loading branch information
1 parent
96d40b0
commit ee47429
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PhpParser\Node; | ||
|
||
use PhpParser\Modifiers; | ||
|
||
class PropertyHookTest extends \PHPUnit\Framework\TestCase { | ||
/** | ||
* @dataProvider provideModifiers | ||
*/ | ||
public function testModifiers($modifier): void { | ||
$node = new PropertyHook( | ||
'get', | ||
null, | ||
[ | ||
'flags' => constant(Modifiers::class . '::' . strtoupper($modifier)), | ||
] | ||
); | ||
|
||
$this->assertTrue($node->{'is' . $modifier}()); | ||
} | ||
|
||
public function testNoModifiers(): void { | ||
$node = new PropertyHook('get', null); | ||
|
||
$this->assertFalse($node->isFinal()); | ||
} | ||
|
||
public static function provideModifiers() { | ||
return [ | ||
['final'], | ||
]; | ||
} | ||
} |