2022-07-19 21:10:35 +02:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
|
2022-09-11 16:11:32 +02:00
|
|
|
namespace PhpParser\Node;
|
2022-07-19 21:10:35 +02:00
|
|
|
|
2022-09-11 16:11:32 +02:00
|
|
|
use PhpParser\Modifiers;
|
2022-07-19 21:10:35 +02:00
|
|
|
use PhpParser\Node\Expr\Variable;
|
|
|
|
|
2022-09-11 16:11:32 +02:00
|
|
|
class ParamTest extends \PHPUnit\Framework\TestCase {
|
2022-07-19 21:10:35 +02:00
|
|
|
public function testNoModifiers() {
|
|
|
|
$node = new Param(new Variable('foo'));
|
|
|
|
|
2022-09-11 16:11:32 +02:00
|
|
|
$this->assertFalse($node->isPromoted());
|
|
|
|
$this->assertFalse($node->isPrivate());
|
|
|
|
$this->assertFalse($node->isProtected());
|
|
|
|
$this->assertFalse($node->isPrivate());
|
2022-07-19 21:10:35 +02:00
|
|
|
$this->assertFalse($node->isReadonly());
|
|
|
|
}
|
|
|
|
|
2022-09-11 16:11:32 +02:00
|
|
|
/**
|
|
|
|
* @dataProvider provideModifiers
|
|
|
|
*/
|
|
|
|
public function testModifiers(string $modifier) {
|
|
|
|
$node = new Param(new Variable('foo'));
|
|
|
|
$node->flags = constant(Modifiers::class . '::' . strtoupper($modifier));
|
|
|
|
$this->assertTrue($node->isPromoted());
|
|
|
|
$this->assertTrue($node->{'is' . $modifier}());
|
|
|
|
}
|
2022-07-19 21:10:35 +02:00
|
|
|
|
2022-09-11 16:11:32 +02:00
|
|
|
public function provideModifiers() {
|
|
|
|
return [
|
|
|
|
['public'],
|
|
|
|
['protected'],
|
|
|
|
['private'],
|
|
|
|
['readonly'],
|
|
|
|
];
|
2022-07-19 21:10:35 +02:00
|
|
|
}
|
|
|
|
}
|