Commit 402a3cae authored by webchick's avatar webchick

Issue #2138867 by chx: Allow dangling commas in annotations.

parent 6deedddb
......@@ -3,20 +3,20 @@
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
],
"hash": "4c727150110aeae10efe10a92ff256f5",
"hash": "414745173d1e926721e1d7511a65dcec",
"packages": [
{
"name": "doctrine/annotations",
"version": "v1.1.2",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/doctrine/annotations.git",
"reference": "v1.1.2"
"reference": "463d926a8dcc49271cb7db5a08364a70ed6e3cd3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/v1.1.2",
"reference": "v1.1.2",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/463d926a8dcc49271cb7db5a08364a70ed6e3cd3",
"reference": "463d926a8dcc49271cb7db5a08364a70ed6e3cd3",
"shasum": ""
},
"require": {
......@@ -45,7 +45,8 @@
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com",
"homepage": "http://www.jwage.com/"
"homepage": "http://www.jwage.com/",
"role": "Creator"
},
{
"name": "Guilherme Blanco",
......@@ -63,7 +64,7 @@
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com",
"homepage": "https://github.com/schmittjoh",
"homepage": "http://jmsyst.com",
"role": "Developer of wrapped JMSSerializerBundle"
}
],
......@@ -74,7 +75,7 @@
"docblock",
"parser"
],
"time": "2013-06-16 21:33:03"
"time": "2013-11-19 05:59:59"
},
{
"name": "doctrine/cache",
......@@ -2056,6 +2057,7 @@
"minimum-stability": "stable",
"stability-flags": {
"doctrine/common": 10,
"doctrine/annotations": 20,
"kriswallsmith/assetic": 15,
"symfony-cmf/routing": 15,
"easyrdf/easyrdf": 10
......
......@@ -4,4 +4,4 @@
require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInitdcdeef3a2347836a4b3309cb54064cf9::getLoader();
return ComposerAutoloaderInite23e221879b77f56988466576fc63488::getLoader();
......@@ -8,4 +8,4 @@
return array(
$vendorDir . '/kriswallsmith/assetic/src/functions.php',
$baseDir . '/core/lib/Drupal.php',
);
\ No newline at end of file
);
......@@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitdcdeef3a2347836a4b3309cb54064cf9
class ComposerAutoloaderInite23e221879b77f56988466576fc63488
{
private static $loader;
......@@ -19,9 +19,9 @@ public static function getLoader()
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitdcdeef3a2347836a4b3309cb54064cf9', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInite23e221879b77f56988466576fc63488', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitdcdeef3a2347836a4b3309cb54064cf9', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInite23e221879b77f56988466576fc63488', 'loadClassLoader'));
$vendorDir = dirname(__DIR__);
$baseDir = dirname(dirname($vendorDir));
......
......@@ -735,79 +735,6 @@
"parser"
]
},
{
"name": "doctrine/annotations",
"version": "v1.1.2",
"version_normalized": "1.1.2.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/annotations.git",
"reference": "v1.1.2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/v1.1.2",
"reference": "v1.1.2",
"shasum": ""
},
"require": {
"doctrine/lexer": "1.*",
"php": ">=5.3.2"
},
"require-dev": {
"doctrine/cache": "1.*"
},
"time": "2013-06-16 21:33:03",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Doctrine\\Common\\Annotations\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com",
"homepage": "http://www.jwage.com/"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com",
"homepage": "http://www.instaclick.com"
},
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com",
"homepage": "https://github.com/schmittjoh",
"role": "Developer of wrapped JMSSerializerBundle"
}
],
"description": "Docblock Annotations Parser",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"annotations",
"docblock",
"parser"
]
},
{
"name": "doctrine/collections",
"version": "v1.1",
......@@ -2115,5 +2042,79 @@
"filesystem",
"iterator"
]
},
{
"name": "doctrine/annotations",
"version": "dev-master",
"version_normalized": "9999999-dev",
"source": {
"type": "git",
"url": "https://github.com/doctrine/annotations.git",
"reference": "463d926a8dcc49271cb7db5a08364a70ed6e3cd3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/463d926a8dcc49271cb7db5a08364a70ed6e3cd3",
"reference": "463d926a8dcc49271cb7db5a08364a70ed6e3cd3",
"shasum": ""
},
"require": {
"doctrine/lexer": "1.*",
"php": ">=5.3.2"
},
"require-dev": {
"doctrine/cache": "1.*"
},
"time": "2013-11-19 05:59:59",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Doctrine\\Common\\Annotations\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com",
"homepage": "http://www.jwage.com/",
"role": "Creator"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com",
"homepage": "http://www.instaclick.com"
},
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com",
"homepage": "http://jmsyst.com",
"role": "Developer of wrapped JMSSerializerBundle"
}
],
"description": "Docblock Annotations Parser",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"annotations",
"docblock",
"parser"
]
}
]
......@@ -3,6 +3,7 @@ language: php
php:
- 5.3
- 5.4
- 5.5
before_script:
- composer --prefer-source --dev install
......
......@@ -69,7 +69,7 @@ class AnnotationReader implements Reader
'Required' => true, 'Attribute' => true, 'Attributes' => true,
'Target' => true, 'SuppressWarnings' => true,
'ingroup' => true, 'code' => true, 'endcode' => true,
'package_version' => true, 'fixme' => true
'package_version' => true, 'fixme' => true, 'noinspection' => true
);
/**
......
......@@ -19,11 +19,9 @@
namespace Doctrine\Common\Annotations;
use Closure;
use ReflectionClass;
use Doctrine\Common\Annotations\Annotation\Enum;
use Doctrine\Common\Annotations\Annotation\Target;
use Doctrine\Common\Annotations\Annotation\Attribute;
use Doctrine\Common\Annotations\Annotation\Attributes;
/**
......@@ -582,7 +580,7 @@ private function Annotations()
}
/**
* Annotation ::= "@" AnnotationName ["(" [Values] ")"]
* Annotation ::= "@" AnnotationName MethodCall
* AnnotationName ::= QualifiedName | SimpleName
* QualifiedName ::= NameSpacePart "\" {NameSpacePart "\"}* SimpleName
* NameSpacePart ::= identifier | null | false | true
......@@ -673,16 +671,7 @@ private function Annotation()
);
}
$values = array();
if ($this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) {
$this->match(DocLexer::T_OPEN_PARENTHESIS);
if ( ! $this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) {
$values = $this->Values();
}
$this->match(DocLexer::T_CLOSE_PARENTHESIS);
}
$values = $this->MethodCall();
if (isset(self::$annotationMetadata[$name]['enum'])) {
// checks all declared attributes
......@@ -736,6 +725,7 @@ private function Annotation()
}
$instance = new $name();
foreach ($values as $property => $value) {
if (!isset(self::$annotationMetadata[$name]['properties'][$property])) {
if ('value' !== $property) {
......@@ -755,7 +745,31 @@ private function Annotation()
}
/**
* Values ::= Array | Value {"," Value}*
* MethodCall ::= ["(" [Values] ")"]
*
* @return array
*/
private function MethodCall()
{
$values = array();
if ( ! $this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) {
return $values;
}
$this->match(DocLexer::T_OPEN_PARENTHESIS);
if ( ! $this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) {
$values = $this->Values();
}
$this->match(DocLexer::T_CLOSE_PARENTHESIS);
return $values;
}
/**
* Values ::= Array | Value {"," Value}* [","]
*
* @return array
*/
......@@ -766,6 +780,7 @@ private function Values()
// Handle the case of a single array as value, i.e. @Foo({....})
if ($this->lexer->isNextToken(DocLexer::T_OPEN_CURLY_BRACES)) {
$values['value'] = $this->Value();
return $values;
}
......@@ -773,6 +788,11 @@ private function Values()
while ($this->lexer->isNextToken(DocLexer::T_COMMA)) {
$this->match(DocLexer::T_COMMA);
if ($this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) {
break;
}
$token = $this->lexer->lookahead;
$value = $this->Value();
......@@ -812,12 +832,12 @@ private function Constant()
{
$identifier = $this->Identifier();
if (!defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) {
if ( ! defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) {
list($className, $const) = explode('::', $identifier);
$alias = (false === $pos = strpos($className, '\\'))? $className : substr($className, 0, $pos);
$alias = (false === $pos = strpos($className, '\\')) ? $className : substr($className, 0, $pos);
$found = false;
switch (true) {
case !empty ($this->namespaces):
foreach ($this->namespaces as $ns) {
......
......@@ -2,7 +2,6 @@
namespace Doctrine\Tests\Common\Annotations;
use Doctrine\Common\Annotations\Annotation\IgnorePhpDoc;
use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation;
use Doctrine\Common\Annotations\DocParser;
use Doctrine\Common\Annotations\AnnotationRegistry;
......@@ -321,7 +320,7 @@ public function testAnnotationTarget()
$docComment = $class->getDocComment();
$parser->setTarget(Target::TARGET_CLASS);
$parser->parse($class->getDocComment(),$context);
$parser->parse($docComment, $context);
$this->fail();
} catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
......@@ -337,7 +336,7 @@ public function testAnnotationTarget()
$context = 'method ' . $class->getName() . '::' . $method->getName() . '()';
$parser->setTarget(Target::TARGET_METHOD);
$parser->parse($docComment,$context);
$parser->parse($docComment, $context);
$this->fail();
} catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
......@@ -352,7 +351,7 @@ public function testAnnotationTarget()
$context = 'property ' . $class->getName() . "::\$" . $property->getName();
$parser->setTarget(Target::TARGET_PROPERTY);
$parser->parse($docComment,$context);
$parser->parse($docComment, $context);
$this->fail();
} catch (\Doctrine\Common\Annotations\AnnotationException $exc) {
......@@ -666,7 +665,7 @@ public function testAnnotationWithRequiredAttributesWithoutContructor()
}
/**
* @expectedException Doctrine\Common\Annotations\AnnotationException
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnum declared on property SomeClassName::invalidProperty. accept only [ONE, TWO, THREE], but got FOUR.
*/
public function testAnnotationEnumeratorException()
......@@ -681,7 +680,7 @@ public function testAnnotationEnumeratorException()
}
/**
* @expectedException Doctrine\Common\Annotations\AnnotationException
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage Attribute "value" of @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationEnumLiteral declared on property SomeClassName::invalidProperty. accept only [AnnotationEnumLiteral::ONE, AnnotationEnumLiteral::TWO, AnnotationEnumLiteral::THREE], but got 4.
*/
public function testAnnotationEnumeratorLiteralException()
......@@ -810,7 +809,7 @@ public function testSupportClassConstants($docblock, $expected)
}
/**
* @expectedException Doctrine\Common\Annotations\AnnotationException
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage The annotation @SomeAnnotationClassNameWithoutConstructorAndProperties declared on does not accept any values, but got {"value":"Foo"}.
*/
public function testWithoutConstructorWhenIsNotDefaultValue()
......@@ -828,7 +827,7 @@ public function testWithoutConstructorWhenIsNotDefaultValue()
}
/**
* @expectedException Doctrine\Common\Annotations\AnnotationException
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage The annotation @SomeAnnotationClassNameWithoutConstructorAndProperties declared on does not accept any values, but got {"value":"Foo"}.
*/
public function testWithoutConstructorWhenHasNoProperties()
......@@ -845,7 +844,7 @@ public function testWithoutConstructorWhenHasNoProperties()
}
/**
* @expectedException Doctrine\Common\Annotations\AnnotationException
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage Expected namespace separator or identifier, got ')' at position 24 in class @Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithTargetSyntaxError.
*/
public function testAnnotationTargetSyntaxError()
......@@ -944,7 +943,7 @@ public function testAnnotationWithoutClassIsIgnoredWithoutWarning()
}
/**
* @expectedException Doctrine\Common\Annotations\AnnotationException
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage Expected PlainValue, got ''' at position 10.
*/
public function testAnnotationDontAcceptSingleQuotes()
......@@ -966,12 +965,12 @@ public function testAnnotationDoesntThrowExceptionWhenAtSignIsNotFollowedByIdent
/**
* @group DCOM-41
* @expectedException Doctrine\Common\Annotations\AnnotationException
* @expectedException \Doctrine\Common\Annotations\AnnotationException
*/
public function testAnnotationThrowsExceptionWhenAtSignIsNotFollowedByIdentifierInNestedAnnotation()
{
$parser = new DocParser();
$result = $parser->parse("@Doctrine\Tests\Common\Annotations\Name(@')");
$parser->parse("@Doctrine\Tests\Common\Annotations\Name(@')");
}
/**
......@@ -1008,7 +1007,7 @@ public function createTestParser()
/**
* @group DDC-78
* @expectedException Doctrine\Common\Annotations\AnnotationException
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage Expected PlainValue, got ''' at position 10 in class \Doctrine\Tests\Common\Annotations\Name
*/
public function testSyntaxErrorWithContextDescription()
......@@ -1036,8 +1035,8 @@ class A {
try {
$parser = $this->createTestParser();
$result = $parser->parse($docblock);
} catch (Exception $e) {
$parser->parse($docblock);
} catch (\Exception $e) {
$this->fail($e->getMessage());
}
}
......@@ -1057,8 +1056,8 @@ class A {
try {
$parser = $this->createTestParser();
$result = $parser->parse($docblock);
} catch (Exception $e) {
$parser->parse($docblock);
} catch (\Exception $e) {
$this->fail($e->getMessage());
}
}
......@@ -1135,7 +1134,7 @@ public function testReservedKeywordsInAnnotations()
}
/**
* @expectedException Doctrine\Common\Annotations\AnnotationException
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage [Creation Error] The annotation @SomeAnnotationClassNameWithoutConstructor declared on some class does not have a property named "invalidaProperty". Available properties: data, name
*/
public function testSetValuesExeption()
......@@ -1150,7 +1149,7 @@ public function testSetValuesExeption()
}
/**
* @expectedException Doctrine\Common\Annotations\AnnotationException
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage [Syntax Error] Expected Doctrine\Common\Annotations\DocLexer::T_IDENTIFIER or Doctrine\Common\Annotations\DocLexer::T_TRUE or Doctrine\Common\Annotations\DocLexer::T_FALSE or Doctrine\Common\Annotations\DocLexer::T_NULL, got '3.42' at position 5.
*/
public function testInvalidIdentifierInAnnotation()
......@@ -1190,7 +1189,7 @@ public function testArrayWithColon()
}
/**
* @expectedException Doctrine\Common\Annotations\AnnotationException
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage [Semantical Error] Couldn't find constant foo.
*/
public function testInvalidContantName()
......
......@@ -33,7 +33,7 @@ public function testAttemptToCreateAnnotationCacheDir()
$this->assertFalse(is_dir($this->cacheDir));
$cache = new FileCacheReader(new AnnotationReader(), $this->cacheDir);
new FileCacheReader(new AnnotationReader(), $this->cacheDir);
$this->assertTrue(is_dir($this->cacheDir));
}
......
......@@ -61,7 +61,7 @@ public function testClassWithInvalidAnnotationTargetAtMethodDocBlock()
}
/**
* @expectedException Doctrine\Common\Annotations\AnnotationException
* @expectedException \Doctrine\Common\Annotations\AnnotationException
*/
public function testInvalidAnnotationUsageButIgnoredClass()
{
......
......@@ -3,6 +3,7 @@
namespace Doctrine\Tests\Common\Annotations\Ticket;
use Doctrine\Tests\Common\Annotations\Fixtures\Controller;
use Doctrine\Common\Annotations\AnnotationReader;
/**
* @group
......@@ -10,20 +11,20 @@
class DCOM55Test extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException Doctrine\Common\Annotations\AnnotationException
* @expectedException \Doctrine\Common\Annotations\AnnotationException
* @expectedExceptionMessage [Semantical Error] The class "Doctrine\Tests\Common\Annotations\Fixtures\Controller" is not annotated with @Annotation. Are you sure this class can be used as annotation? If so, then you need to add @Annotation to the _class_ doc comment of "Doctrine\Tests\Common\Annotations\Fixtures\Controller". If it is indeed no annotation, then you need to add @IgnoreAnnotation("Controller") to the _class_ doc comment of class Doctrine\Tests\Common\Annotations\Ticket\Dummy.
*/
public function testIssue()
{
$class = new \ReflectionClass(__NAMESPACE__ . '\\Dummy');
$reader = new \Doctrine\Common\Annotations\AnnotationReader();
$reader = new AnnotationReader();
$reader->getClassAnnotations($class);
}
public function testAnnotation()
{
$class = new \ReflectionClass(__NAMESPACE__ . '\\DCOM55Consumer');
$reader = new \Doctrine\Common\Annotations\AnnotationReader();
$reader = new AnnotationReader();
$annots = $reader->getClassAnnotations($class);
$this->assertEquals(1, count($annots));
......@@ -33,7 +34,7 @@ public function testAnnotation()
public function testParseAnnotationDocblocks()
{
$class = new \ReflectionClass(__NAMESPACE__ . '\\DCOM55Annotation');
$reader = new \Doctrine\Common\Annotations\AnnotationReader();
$reader = new AnnotationReader();
$annots = $reader->getClassAnnotations($class);
$this->assertEquals(0, count($annots));
......
<?php
namespace Doctrine\Tests\Common\Annotations\Ticket;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\DocParser;
use Doctrine\Common\Annotations\SimpleAnnotationReader;
//Some class named Entity in the global namespace
include __DIR__ .'/DCOM58Entity.php';
......@@ -11,7 +15,7 @@ class DCOM58Test extends \PHPUnit_Framework_TestCase
{
public function testIssue()
{
$reader = new \Doctrine\Common\Annotations\AnnotationReader();
$reader = new AnnotationReader();
$result = $reader->getClassAnnotations(new \ReflectionClass(__NAMESPACE__."\MappedClass"));
foreach ($result as $annot) {
......@@ -24,7 +28,7 @@ public function testIssue()
public function testIssueGlobalNamespace()
{
$docblock = "@Entity";
$parser = new \Doctrine\Common\Annotations\DocParser();
$parser = new DocParser();
$parser->setImports(array(
"__NAMESPACE__" =>"Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping"
));
......@@ -38,7 +42,7 @@ public function testIssueGlobalNamespace()
public function testIssueNamespaces()
{
$docblock = "@Entity";
$parser = new \Doctrine\Common\Annotations\DocParser();
$parser = new DocParser();
$parser->addNamespace("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM");
$annots = $parser->parse($docblock);
......@@ -50,7 +54,7 @@ public function testIssueNamespaces()
public function testIssueMultipleNamespaces()
{
$docblock = "@Entity";
$parser = new \Doctrine\Common\Annotations\DocParser();
$parser = new DocParser();
$parser->addNamespace("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping");
$parser->addNamespace("Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM");
......@@ -63,7 +67,7 @@ public function testIssueMultipleNamespaces()
public function testIssueWithNamespacesOrImports()
{
$docblock = "@Entity";
$parser = new \Doctrine\Common\Annotations\DocParser();
$parser = new DocParser();
$annots = $parser->parse($docblock);
$this->assertEquals(1, count($annots));
......@@ -74,7 +78,7 @@ public function testIssueWithNamespacesOrImports()
public function testIssueSimpleAnnotationReader()
{
$reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader();
$reader = new SimpleAnnotationReader();
$reader->addNamespace('Doctrine\Tests\Common\Annotations\Ticket\Doctrine\ORM\Mapping');
$annots = $reader->getClassAnnotations(new \ReflectionClass(__NAMESPACE__."\MappedClass"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment