1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-26 20:04:48 +01:00

Fix implicit visibility for properties as well

Also switch to using PPP mask.
This commit is contained in:
Nikita Popov 2015-07-05 20:15:02 +02:00
parent 0fbb5f90a1
commit 7434a682e5
3 changed files with 12 additions and 2 deletions

View File

@ -75,7 +75,8 @@ class ClassMethod extends Node\Stmt implements FunctionLike
}
public function isPublic() {
return ($this->type & Class_::MODIFIER_PUBLIC) !== 0 || (!$this->isPrivate() && !$this->isProtected());
return ($this->type & Class_::MODIFIER_PUBLIC) !== 0
|| ($this->type & Class_::VISIBILITY_MODIFER_MASK) === 0;
}
public function isProtected() {

View File

@ -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() {

View File

@ -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'),