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