diff --git a/lib/PhpParser/Node/Stmt/ClassMethod.php b/lib/PhpParser/Node/Stmt/ClassMethod.php index 41f099d..c1bd577 100644 --- a/lib/PhpParser/Node/Stmt/ClassMethod.php +++ b/lib/PhpParser/Node/Stmt/ClassMethod.php @@ -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() { diff --git a/lib/PhpParser/Node/Stmt/Property.php b/lib/PhpParser/Node/Stmt/Property.php index 295f369..58052f7 100644 --- a/lib/PhpParser/Node/Stmt/Property.php +++ b/lib/PhpParser/Node/Stmt/Property.php @@ -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() { diff --git a/test/PhpParser/Node/Stmt/PropertyTest.php b/test/PhpParser/Node/Stmt/PropertyTest.php index a7efcd3..bcfc0c6 100644 --- a/test/PhpParser/Node/Stmt/PropertyTest.php +++ b/test/PhpParser/Node/Stmt/PropertyTest.php @@ -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'),