From 1eec9f211b9b475db2782ae7b1cf5e792cbe273b Mon Sep 17 00:00:00 2001 From: beberlei Date: Fri, 30 Oct 2009 00:20:17 +0000 Subject: [PATCH] [2.0] Fixed DDC-77 - Prevent PHP Warning on certain annotation constallations --- lib/Doctrine/Common/Annotations/Parser.php | 5 +++-- .../Tests/Common/Annotations/ParserTest.php | 21 ++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/Doctrine/Common/Annotations/Parser.php b/lib/Doctrine/Common/Annotations/Parser.php index 5babb1dcc..f08248cd5 100644 --- a/lib/Doctrine/Common/Annotations/Parser.php +++ b/lib/Doctrine/Common/Annotations/Parser.php @@ -235,9 +235,10 @@ class Parser // If it really an annotation class? if ( - ! $this->_isNestedAnnotation && $this->_lexer->lookahead != null && + (! $this->_isNestedAnnotation && $this->_lexer->lookahead != null && ! $this->_lexer->isNextToken('(') && - ! $this->_lexer->isNextToken('@') || + ! $this->_lexer->isNextToken('@')) || + ! class_exists($name) || ! is_subclass_of($name, 'Doctrine\Common\Annotations\Annotation') ) { $this->_lexer->skipUntil('@'); diff --git a/tests/Doctrine/Tests/Common/Annotations/ParserTest.php b/tests/Doctrine/Tests/Common/Annotations/ParserTest.php index 9aaf36037..1d27be0b3 100644 --- a/tests/Doctrine/Tests/Common/Annotations/ParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/ParserTest.php @@ -73,11 +73,22 @@ DOCBLOCK; */ DOCBLOCK; - $result = $parser->parse($docblock); - $this->assertEquals(1, count($result)); - $annot = $result['Doctrine\Tests\Common\Annotations\Name']; - $this->assertTrue($annot instanceof Name); - $this->assertEquals("bar", $annot->foo); + $result = $parser->parse($docblock); + $this->assertEquals(1, count($result)); + $annot = $result['Doctrine\Tests\Common\Annotations\Name']; + $this->assertTrue($annot instanceof Name); + $this->assertEquals("bar", $annot->foo); + } + + /** + * @group DDC-77 + */ + public function testAnnotationWithoutClassIsIgnoredWithoutWarning() + { + $parser = new Parser(); + $result = $parser->parse("@param"); + + $this->assertEquals(0, count($result)); } }