ParamTest.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php declare(strict_types=1);
  2. namespace PhpParser\Node;
  3. use PhpParser\Modifiers;
  4. use PhpParser\Node\Expr\Variable;
  5. class ParamTest extends \PHPUnit\Framework\TestCase {
  6. public function testNoModifiers(): void {
  7. $node = new Param(new Variable('foo'));
  8. $this->assertFalse($node->isPromoted());
  9. $this->assertFalse($node->isPrivate());
  10. $this->assertFalse($node->isProtected());
  11. $this->assertFalse($node->isPrivate());
  12. $this->assertFalse($node->isReadonly());
  13. }
  14. /**
  15. * @dataProvider provideModifiers
  16. */
  17. public function testModifiers(string $modifier): void {
  18. $node = new Param(new Variable('foo'));
  19. $node->flags = constant(Modifiers::class . '::' . strtoupper($modifier));
  20. $this->assertTrue($node->isPromoted());
  21. $this->assertTrue($node->{'is' . $modifier}());
  22. }
  23. public static function provideModifiers() {
  24. return [
  25. ['public'],
  26. ['protected'],
  27. ['private'],
  28. ['readonly'],
  29. ];
  30. }
  31. }