mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-11-27 04:14:44 +01:00
Merge branch '1.x'
This commit is contained in:
commit
90ab32f046
@ -75,7 +75,8 @@ class ClassMethod extends Node\Stmt implements FunctionLike
|
||||
}
|
||||
|
||||
public function isPublic() {
|
||||
return ($this->type & Class_::MODIFIER_PUBLIC) !== 0 || $this->type === 0;
|
||||
return ($this->type & Class_::MODIFIER_PUBLIC) !== 0
|
||||
|| ($this->type & Class_::VISIBILITY_MODIFER_MASK) === 0;
|
||||
}
|
||||
|
||||
public function isProtected() {
|
||||
|
@ -38,7 +38,8 @@ class Property extends Node\Stmt
|
||||
}
|
||||
|
||||
public function isPublic() {
|
||||
return ($this->type & Class_::MODIFIER_PUBLIC) !== 0 || $this->type === 0;
|
||||
return ($this->type & Class_::MODIFIER_PUBLIC) !== 0
|
||||
|| ($this->type & Class_::VISIBILITY_MODIFER_MASK) === 0;
|
||||
}
|
||||
|
||||
public function isProtected() {
|
||||
|
@ -36,4 +36,28 @@ class ClassMethodTest extends \PHPUnit_Framework_TestCase
|
||||
array('static'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that implicit public modifier detection for method is working
|
||||
*
|
||||
* @dataProvider implicitPublicModifiers
|
||||
*
|
||||
* @param integer $modifier Node type modifier
|
||||
*/
|
||||
public function testImplicitPublic($modifier)
|
||||
{
|
||||
$node = new ClassMethod('foo', array(
|
||||
'type' => constant('PhpParser\Node\Stmt\Class_::MODIFIER_' . strtoupper($modifier))
|
||||
));
|
||||
|
||||
$this->assertTrue($node->isPublic(), 'Node should be implicitly public');
|
||||
}
|
||||
|
||||
public function implicitPublicModifiers() {
|
||||
return array(
|
||||
array('abstract'),
|
||||
array('final'),
|
||||
array('static'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,14 @@ class PropertyTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertFalse($node->isStatic());
|
||||
}
|
||||
|
||||
public function testStaticImplicitlyPublic() {
|
||||
$node = new Property(Class_::MODIFIER_STATIC, array());
|
||||
$this->assertTrue($node->isPublic());
|
||||
$this->assertFalse($node->isProtected());
|
||||
$this->assertFalse($node->isPrivate());
|
||||
$this->assertTrue($node->isStatic());
|
||||
}
|
||||
|
||||
public function provideModifiers() {
|
||||
return array(
|
||||
array('public'),
|
||||
|
Loading…
Reference in New Issue
Block a user