From 04e4f03c7085f3950edcb45ec71d4abe4b5babd0 Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Tue, 9 Sep 2014 20:26:03 +0100 Subject: [PATCH] Issue #2325779 by astrocling | not_chx: Upgrade to Doctrine v1.2.0. --- composer.json | 2 +- composer.lock | 20 +- core/vendor/composer/installed.json | 149 ++++----- core/vendor/doctrine/annotations/.gitignore | 3 + core/vendor/doctrine/annotations/.travis.yml | 3 +- core/vendor/doctrine/annotations/LICENSE | 19 ++ core/vendor/doctrine/annotations/README.md | 12 +- .../vendor/doctrine/annotations/composer.json | 5 +- .../Common/Annotations/Annotation.php | 20 +- .../Common/Annotations/Annotation/Enum.php | 5 +- .../Annotation/IgnoreAnnotation.php | 2 +- .../Common/Annotations/Annotation/Target.php | 14 +- .../Annotations/AnnotationException.php | 85 +++-- .../Common/Annotations/AnnotationReader.php | 196 +++++++---- .../Common/Annotations/AnnotationRegistry.php | 26 +- .../Common/Annotations/CachedReader.php | 61 ++-- .../Doctrine/Common/Annotations/DocLexer.php | 12 +- .../Doctrine/Common/Annotations/DocParser.php | 310 +++++++++++------- .../Common/Annotations/FileCacheReader.php | 63 ++-- .../Common/Annotations/IndexedReader.php | 42 +-- .../Doctrine/Common/Annotations/PhpParser.php | 12 +- .../Doctrine/Common/Annotations/Reader.php | 52 ++- .../Annotations/SimpleAnnotationReader.php | 46 +-- .../Common/Annotations/TokenParser.php | 34 +- .../Common/Annotations/AbstractReaderTest.php | 72 +++- .../Annotations/Annotation/TargetTest.php | 47 +++ .../Annotations/AnnotationReaderTest.php | 46 +++ .../Tests/Common/Annotations/DocLexerTest.php | 26 +- .../Common/Annotations/DocParserTest.php | 97 +++++- .../Fixtures/AnnotationWithAttributes.php | 10 + .../Fixtures/AnnotationWithVarType.php | 5 + .../Fixtures/ClassNoNamespaceNoComment.php | 7 + .../Fixtures/ClassOverwritesTrait.php | 25 ++ .../Annotations/Fixtures/ClassUsesTrait.php | 30 ++ .../ClassWithAtInDescriptionAndAnnotation.php | 34 ++ .../Fixtures/ClassWithClassAnnotationOnly.php | 13 + .../Fixtures/ClassWithConstants.php | 7 +- .../Fixtures/ClassWithIgnoreAnnotation.php | 14 + .../Fixtures/IgnoreAnnotationClass.php | 7 + .../Fixtures/TraitWithAnnotatedMethod.php | 19 ++ .../SimpleAnnotationReaderTest.php | 7 +- 41 files changed, 1121 insertions(+), 538 deletions(-) create mode 100644 core/vendor/doctrine/annotations/.gitignore create mode 100644 core/vendor/doctrine/annotations/LICENSE create mode 100644 core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Annotation/TargetTest.php create mode 100644 core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassNoNamespaceNoComment.php create mode 100644 core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassOverwritesTrait.php create mode 100644 core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassUsesTrait.php create mode 100644 core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithAtInDescriptionAndAnnotation.php create mode 100644 core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithClassAnnotationOnly.php create mode 100644 core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithIgnoreAnnotation.php create mode 100644 core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/IgnoreAnnotationClass.php create mode 100644 core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/TraitWithAnnotatedMethod.php diff --git a/composer.json b/composer.json index ac5d6faea175..9120f56b7b6a 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "symfony/yaml": "dev-master#e49a47d60348665261f6e279ba383241deb73cab", "twig/twig": "1.15.*", "doctrine/common": "dev-master#a45d110f71c323e29f41eb0696fa230e3fa1b1b5", - "doctrine/annotations": "dev-master#463d926a8dcc49271cb7db5a08364a70ed6e3cd3", + "doctrine/annotations": "1.2.*", "guzzlehttp/guzzle": "4.1.*", "kriswallsmith/assetic": "1.1.*@alpha", "symfony-cmf/routing": "1.2.*", diff --git a/composer.lock b/composer.lock index 981d888e3947..a6bab03d9f05 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "8afb97667c2791fec2fb1fc43853da24", + "hash": "7d34fdcf5f05caf22258954b560e70f6", "packages": [ { "name": "doctrine/annotations", - "version": "dev-master", + "version": "v1.2.0", "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "463d926a8dcc49271cb7db5a08364a70ed6e3cd3" + "reference": "d9b1a37e9351ddde1f19f09a02e3d6ee92e82efd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/463d926a8dcc49271cb7db5a08364a70ed6e3cd3", - "reference": "463d926a8dcc49271cb7db5a08364a70ed6e3cd3", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/d9b1a37e9351ddde1f19f09a02e3d6ee92e82efd", + "reference": "d9b1a37e9351ddde1f19f09a02e3d6ee92e82efd", "shasum": "" }, "require": { @@ -25,12 +25,13 @@ "php": ">=5.3.2" }, "require-dev": { - "doctrine/cache": "1.*" + "doctrine/cache": "1.*", + "phpunit/phpunit": "4.*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.3.x-dev" } }, "autoload": { @@ -65,7 +66,7 @@ { "name": "Johannes Schmitt", "email": "schmittjoh@gmail.com", - "homepage": "http://jmsyst.com", + "homepage": "https://github.com/schmittjoh", "role": "Developer of wrapped JMSSerializerBundle" } ], @@ -76,7 +77,7 @@ "docblock", "parser" ], - "time": "2013-11-19 05:59:59" + "time": "2014-07-06 15:52:21" }, { "name": "doctrine/cache", @@ -2493,7 +2494,6 @@ "stability-flags": { "symfony/yaml": 20, "doctrine/common": 20, - "doctrine/annotations": 20, "kriswallsmith/assetic": 15, "phpunit/phpunit-mock-objects": 20 }, diff --git a/core/vendor/composer/installed.json b/core/vendor/composer/installed.json index 5b56c2add953..f146fd9ca59f 100644 --- a/core/vendor/composer/installed.json +++ b/core/vendor/composer/installed.json @@ -711,80 +711,6 @@ "spl" ] }, - { - "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" - ] - }, { "name": "twig/twig", "version": "v1.15.0", @@ -2564,5 +2490,80 @@ "keywords": [ "stack" ] + }, + { + "name": "doctrine/annotations", + "version": "v1.2.0", + "version_normalized": "1.2.0.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "d9b1a37e9351ddde1f19f09a02e3d6ee92e82efd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/d9b1a37e9351ddde1f19f09a02e3d6ee92e82efd", + "reference": "d9b1a37e9351ddde1f19f09a02e3d6ee92e82efd", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "php": ">=5.3.2" + }, + "require-dev": { + "doctrine/cache": "1.*", + "phpunit/phpunit": "4.*" + }, + "time": "2014-07-06 15:52:21", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.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": "https://github.com/schmittjoh", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "docblock", + "parser" + ] } ] diff --git a/core/vendor/doctrine/annotations/.gitignore b/core/vendor/doctrine/annotations/.gitignore new file mode 100644 index 000000000000..164c3466290a --- /dev/null +++ b/core/vendor/doctrine/annotations/.gitignore @@ -0,0 +1,3 @@ +vendor/ +composer.lock +composer.phar diff --git a/core/vendor/doctrine/annotations/.travis.yml b/core/vendor/doctrine/annotations/.travis.yml index 862a38597095..7f6c0efe4570 100644 --- a/core/vendor/doctrine/annotations/.travis.yml +++ b/core/vendor/doctrine/annotations/.travis.yml @@ -4,7 +4,8 @@ php: - 5.3 - 5.4 - 5.5 + - 5.6 + - hhvm before_script: - composer --prefer-source --dev install - - phpunit diff --git a/core/vendor/doctrine/annotations/LICENSE b/core/vendor/doctrine/annotations/LICENSE new file mode 100644 index 000000000000..5e781fce4bb5 --- /dev/null +++ b/core/vendor/doctrine/annotations/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2006-2013 Doctrine Project + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/core/vendor/doctrine/annotations/README.md b/core/vendor/doctrine/annotations/README.md index faad51fcfc25..ebb30e0bca4b 100644 --- a/core/vendor/doctrine/annotations/README.md +++ b/core/vendor/doctrine/annotations/README.md @@ -2,10 +2,18 @@ [](https://travis-ci.org/doctrine/annotations) -Docblock Annotations Parser library (extracted from Doctrine Common). +Docblock Annotations Parser library (extracted from [Doctrine Common](https://github.com/doctrine/common)). ## Changelog +### v1.2.0 + + * HHVM support + * Allowing dangling comma in annotations + * Excluded annotations are no longer autoloaded + * Importing namespaces also in traits + * Added support for `::class` 5.5-style constant, works also in 5.3 and 5.4 + ### v1.1 -* Add Exception when ZendOptimizer+ or Opcache is configured to drop comments + * Add Exception when ZendOptimizer+ or Opcache is configured to drop comments diff --git a/core/vendor/doctrine/annotations/composer.json b/core/vendor/doctrine/annotations/composer.json index 3569cf4c2be6..1c65f6cd35a7 100644 --- a/core/vendor/doctrine/annotations/composer.json +++ b/core/vendor/doctrine/annotations/composer.json @@ -17,14 +17,15 @@ "doctrine/lexer": "1.*" }, "require-dev": { - "doctrine/cache": "1.*" + "doctrine/cache": "1.*", + "phpunit/phpunit": "4.*" }, "autoload": { "psr-0": { "Doctrine\\Common\\Annotations\\": "lib/" } }, "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.3.x-dev" } } } diff --git a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation.php b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation.php index 6a1390af882f..a79a0f8f0a18 100644 --- a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation.php +++ b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation.php @@ -20,12 +20,12 @@ namespace Doctrine\Common\Annotations; /** - * Annotations class + * Annotations class. * - * @author Benjamin Eberlei <kontakt@beberlei.de> - * @author Guilherme Blanco <guilhermeblanco@hotmail.com> - * @author Jonathan Wage <jonwage@gmail.com> - * @author Roman Borschel <roman@code-factory.org> + * @author Benjamin Eberlei <kontakt@beberlei.de> + * @author Guilherme Blanco <guilhermeblanco@hotmail.com> + * @author Jonathan Wage <jonwage@gmail.com> + * @author Roman Borschel <roman@code-factory.org> */ class Annotation { @@ -37,9 +37,9 @@ class Annotation public $value; /** - * Constructor + * Constructor. * - * @param array $data Key-value for properties to be defined in this class + * @param array $data Key-value for properties to be defined in this class. */ public final function __construct(array $data) { @@ -51,7 +51,7 @@ public final function __construct(array $data) /** * Error handler for unknown property accessor in Annotation class. * - * @param string $name Unknown property name + * @param string $name Unknown property name. * * @throws \BadMethodCallException */ @@ -65,8 +65,8 @@ public function __get($name) /** * Error handler for unknown property mutator in Annotation class. * - * @param string $name Unkown property name - * @param mixed $value Property value + * @param string $name Unknown property name. + * @param mixed $value Property value. * * @throws \BadMethodCallException */ diff --git a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Enum.php b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Enum.php index 315812f59243..e122a7535881 100644 --- a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Enum.php +++ b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Enum.php @@ -48,7 +48,7 @@ final class Enum public $literal; /** - * Annotation construct + * Annotation constructor. * * @param array $values * @@ -81,5 +81,4 @@ public function __construct(array $values) $this->value = $values['value']; $this->literal = $values['literal']; } - -} \ No newline at end of file +} diff --git a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php index a84a4f516e92..175226a67152 100644 --- a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php +++ b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php @@ -34,7 +34,7 @@ final class IgnoreAnnotation public $names; /** - * Constructor + * Constructor. * * @param array $values * diff --git a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Target.php b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Target.php index 64655ef61bbc..f6c544535934 100644 --- a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Target.php +++ b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Target.php @@ -40,11 +40,11 @@ final class Target * @var array */ private static $map = array( - 'ALL' => self::TARGET_ALL, - 'CLASS' => self::TARGET_CLASS, - 'METHOD' => self::TARGET_METHOD, - 'PROPERTY' => self::TARGET_PROPERTY, - 'ANNOTATION' => self::TARGET_ANNOTATION, + 'ALL' => self::TARGET_ALL, + 'CLASS' => self::TARGET_CLASS, + 'METHOD' => self::TARGET_METHOD, + 'PROPERTY' => self::TARGET_PROPERTY, + 'ANNOTATION' => self::TARGET_ANNOTATION, ); /** @@ -67,7 +67,7 @@ final class Target public $literal; /** - * Annotation construct + * Annotation constructor. * * @param array $values * @@ -97,7 +97,7 @@ public function __construct(array $values) $literal, implode(', ', array_keys(self::$map))) ); } - $bitmask += self::$map[$literal]; + $bitmask |= self::$map[$literal]; } $this->targets = $bitmask; diff --git a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php index 6cdb6615f38a..a7537cb05bbb 100644 --- a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php +++ b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php @@ -22,11 +22,11 @@ /** * Description of AnnotationException * - * @since 2.0 - * @author Benjamin Eberlei <kontakt@beberlei.de> - * @author Guilherme Blanco <guilhermeblanco@hotmail.com> - * @author Jonathan Wage <jonwage@gmail.com> - * @author Roman Borschel <roman@code-factory.org> + * @since 2.0 + * @author Benjamin Eberlei <kontakt@beberlei.de> + * @author Guilherme Blanco <guilhermeblanco@hotmail.com> + * @author Jonathan Wage <jonwage@gmail.com> + * @author Roman Borschel <roman@code-factory.org> */ class AnnotationException extends \Exception { @@ -34,6 +34,7 @@ class AnnotationException extends \Exception * Creates a new AnnotationException describing a Syntax error. * * @param string $message Exception message + * * @return AnnotationException */ public static function syntaxError($message) @@ -45,6 +46,7 @@ public static function syntaxError($message) * Creates a new AnnotationException describing a Semantical error. * * @param string $message Exception message + * * @return AnnotationException */ public static function semanticalError($message) @@ -53,54 +55,75 @@ public static function semanticalError($message) } /** - * Creates a new AnnotationException describing a constant semantical error. + * Creates a new AnnotationException describing an error which occurred during + * the creation of the annotation. + * + * @since 2.2 + * + * @param string $message * - * @since 2.3 - * @param string $identifier - * @param string $context * @return AnnotationException */ - public static function semanticalErrorConstants($identifier, $context = null) + public static function creationError($message) { - return self::semanticalError(sprintf( - "Couldn't find constant %s%s", $identifier, - $context ? ", $context." : "." - )); + return new self('[Creation Error] ' . $message); } /** - * Creates a new AnnotationException describing an error which occurred during - * the creation of the annotation. + * Creates a new AnnotationException describing a type error. + * + * @since 1.1 * - * @since 2.2 * @param string $message + * * @return AnnotationException */ - public static function creationError($message) + public static function typeError($message) { - return new self('[Creation Error] ' . $message); + return new self('[Type Error] ' . $message); + } + + /** + * Creates a new AnnotationException describing a constant semantical error. + * + * @since 2.3 + * + * @param string $identifier + * @param string $context + * + * @return AnnotationException + */ + public static function semanticalErrorConstants($identifier, $context = null) + { + return self::semanticalError(sprintf( + "Couldn't find constant %s%s.", + $identifier, + $context ? ', ' . $context : '' + )); } /** * Creates a new AnnotationException describing an type error of an attribute. * * @since 2.2 + * * @param string $attributeName * @param string $annotationName * @param string $context * @param string $expected - * @param mixed $actual + * @param mixed $actual + * * @return AnnotationException */ - public static function typeError($attributeName, $annotationName, $context, $expected, $actual) + public static function attributeTypeError($attributeName, $annotationName, $context, $expected, $actual) { - return new self(sprintf( - '[Type Error] Attribute "%s" of @%s declared on %s expects %s, but got %s.', + return self::typeError(sprintf( + 'Attribute "%s" of @%s declared on %s expects %s, but got %s.', $attributeName, $annotationName, $context, $expected, - is_object($actual) ? 'an instance of '.get_class($actual) : gettype($actual) + is_object($actual) ? 'an instance of ' . get_class($actual) : gettype($actual) )); } @@ -108,16 +131,18 @@ public static function typeError($attributeName, $annotationName, $context, $exp * Creates a new AnnotationException describing an required error of an attribute. * * @since 2.2 + * * @param string $attributeName * @param string $annotationName * @param string $context * @param string $expected + * * @return AnnotationException */ public static function requiredError($attributeName, $annotationName, $context, $expected) { - return new self(sprintf( - '[Type Error] Attribute "%s" of @%s declared on %s expects %s. This value should not be null.', + return self::typeError(sprintf( + 'Attribute "%s" of @%s declared on %s expects %s. This value should not be null.', $attributeName, $annotationName, $context, @@ -129,16 +154,18 @@ public static function requiredError($attributeName, $annotationName, $context, * Creates a new AnnotationException describing a invalid enummerator. * * @since 2.4 + * * @param string $attributeName * @param string $annotationName * @param string $context * @param array $available * @param mixed $given + * * @return AnnotationException */ public static function enumeratorError($attributeName, $annotationName, $context, $available, $given) { - throw new self(sprintf( + return new self(sprintf( '[Enum Error] Attribute "%s" of @%s declared on %s accept only [%s], but got %s.', $attributeName, $annotationName, @@ -153,6 +180,8 @@ public static function enumeratorError($attributeName, $annotationName, $context */ public static function optimizerPlusSaveComments() { - throw new self("You have to enable opcache.save_comments=1 or zend_optimizerplus.save_comments=1."); + return new self( + "You have to enable opcache.save_comments=1 or zend_optimizerplus.save_comments=1." + ); } } diff --git a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php index 1d17fea8008b..c6645a24c84a 100644 --- a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php +++ b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php @@ -21,7 +21,6 @@ use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation; use Doctrine\Common\Annotations\Annotation\Target; -use Closure; use ReflectionClass; use ReflectionMethod; use ReflectionProperty; @@ -54,22 +53,53 @@ class AnnotationReader implements Reader * @var array */ private static $globalIgnoredNames = array( - 'access'=> true, 'author'=> true, 'copyright'=> true, 'deprecated'=> true, - 'example'=> true, 'ignore'=> true, 'internal'=> true, 'link'=> true, 'see'=> true, - 'since'=> true, 'tutorial'=> true, 'version'=> true, 'package'=> true, - 'subpackage'=> true, 'name'=> true, 'global'=> true, 'param'=> true, - 'return'=> true, 'staticvar'=> true, 'category'=> true, 'staticVar'=> true, - 'static'=> true, 'var'=> true, 'throws'=> true, 'inheritdoc'=> true, - 'inheritDoc'=> true, 'license'=> true, 'todo'=> true, 'TODO'=> true, - 'deprec'=> true, 'property' => true, 'method' => true, - 'abstract'=> true, 'exception'=> true, 'magic' => true, 'api' => true, - 'final'=> true, 'filesource'=> true, 'throw' => true, 'uses' => true, - 'usedby'=> true, 'private' => true, 'Annotation' => true, 'override' => true, + // Annotation tags + 'Annotation' => true, 'Attribute' => true, 'Attributes' => true, + /* Can we enable this? 'Enum' => true, */ + 'Required' => true, + 'Target' => true, + // Widely used tags (but not existent in phpdoc) + 'fix' => true , 'fixme' => true, + 'override' => true, + // PHPDocumentor 1 tags + 'abstract'=> true, 'access'=> true, + 'code' => true, + 'deprec'=> true, + 'endcode' => true, 'exception'=> true, + 'final'=> true, + 'ingroup' => true, 'inheritdoc'=> true, 'inheritDoc'=> true, + 'magic' => true, + 'name'=> true, + 'toc' => true, 'tutorial'=> true, + 'private' => true, + 'static'=> true, 'staticvar'=> true, 'staticVar'=> true, + 'throw' => true, + // PHPDocumentor 2 tags. + 'api' => true, 'author'=> true, + 'category'=> true, 'copyright'=> true, + 'deprecated'=> true, + 'example'=> true, + 'filesource'=> true, + 'global'=> true, + 'ignore'=> true, /* Can we enable this? 'index' => true, */ 'internal'=> true, + 'license'=> true, 'link'=> true, + 'method' => true, + 'package'=> true, 'param'=> true, 'property' => true, 'property-read' => true, 'property-write' => true, + 'return'=> true, + 'see'=> true, 'since'=> true, 'source' => true, 'subpackage'=> true, + 'throws'=> true, 'todo'=> true, 'TODO'=> true, + 'usedby'=> true, 'uses' => true, + 'var'=> true, 'version'=> true, + // PHPUnit tags 'codeCoverageIgnore' => true, 'codeCoverageIgnoreStart' => true, 'codeCoverageIgnoreEnd' => true, - 'Required' => true, 'Attribute' => true, 'Attributes' => true, - 'Target' => true, 'SuppressWarnings' => true, - 'ingroup' => true, 'code' => true, 'endcode' => true, - 'package_version' => true, 'fixme' => true, 'noinspection' => true + // PHPCheckStyle + 'SuppressWarnings' => true, + // PHPStorm + 'noinspection' => true, + // PEAR + 'package_version' => true, + // PlantUML + 'startuml' => true, 'enduml' => true, ); /** @@ -83,21 +113,21 @@ static public function addGlobalIgnoredName($name) } /** - * Annotations Parser + * Annotations parser. * * @var \Doctrine\Common\Annotations\DocParser */ private $parser; /** - * Annotations Parser used to collect parsing metadata + * Annotations parser used to collect parsing metadata. * * @var \Doctrine\Common\Annotations\DocParser */ private $preParser; /** - * PHP Parser used to collect imports. + * PHP parser used to collect imports. * * @var \Doctrine\Common\Annotations\PhpParser */ @@ -128,15 +158,15 @@ public function __construct() throw AnnotationException::optimizerPlusSaveComments(); } - if (extension_loaded('opcache') && ini_get('opcache.save_comments') == 0) { + if (extension_loaded('Zend OPcache') && ini_get('opcache.save_comments') == 0) { throw AnnotationException::optimizerPlusSaveComments(); } AnnotationRegistry::registerFile(__DIR__ . '/Annotation/IgnoreAnnotation.php'); - $this->parser = new DocParser; - + $this->parser = new DocParser; $this->preParser = new DocParser; + $this->preParser->setImports(self::$globalImports); $this->preParser->setIgnoreNotImportedAnnotations(true); @@ -144,28 +174,19 @@ public function __construct() } /** - * Gets the annotations applied to a class. - * - * @param ReflectionClass $class The ReflectionClass of the class from which - * the class annotations should be read. - * @return array An array of Annotations. + * {@inheritDoc} */ public function getClassAnnotations(ReflectionClass $class) { $this->parser->setTarget(Target::TARGET_CLASS); - $this->parser->setImports($this->getImports($class)); + $this->parser->setImports($this->getClassImports($class)); $this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class)); return $this->parser->parse($class->getDocComment(), 'class ' . $class->getName()); } /** - * Gets a class annotation. - * - * @param ReflectionClass $class The ReflectionClass of the class from which - * the class annotations should be read. - * @param string $annotationName The name of the annotation. - * @return mixed The Annotation or NULL, if the requested annotation does not exist. + * {@inheritDoc} */ public function getClassAnnotation(ReflectionClass $class, $annotationName) { @@ -181,29 +202,22 @@ public function getClassAnnotation(ReflectionClass $class, $annotationName) } /** - * Gets the annotations applied to a property. - * - * @param ReflectionProperty $property The ReflectionProperty of the property - * from which the annotations should be read. - * @return array An array of Annotations. + * {@inheritDoc} */ public function getPropertyAnnotations(ReflectionProperty $property) { - $class = $property->getDeclaringClass(); + $class = $property->getDeclaringClass(); $context = 'property ' . $class->getName() . "::\$" . $property->getName(); + $this->parser->setTarget(Target::TARGET_PROPERTY); - $this->parser->setImports($this->getImports($class)); + $this->parser->setImports($this->getPropertyImports($property)); $this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class)); return $this->parser->parse($property->getDocComment(), $context); } /** - * Gets a property annotation. - * - * @param ReflectionProperty $property - * @param string $annotationName The name of the annotation. - * @return mixed The Annotation or NULL, if the requested annotation does not exist. + * {@inheritDoc} */ public function getPropertyAnnotation(ReflectionProperty $property, $annotationName) { @@ -219,30 +233,22 @@ public function getPropertyAnnotation(ReflectionProperty $property, $annotationN } /** - * Gets the annotations applied to a method. - * - * @param \ReflectionMethod $method The ReflectionMethod of the method from which - * the annotations should be read. - * - * @return array An array of Annotations. + * {@inheritDoc} */ public function getMethodAnnotations(ReflectionMethod $method) { - $class = $method->getDeclaringClass(); + $class = $method->getDeclaringClass(); $context = 'method ' . $class->getName() . '::' . $method->getName() . '()'; + $this->parser->setTarget(Target::TARGET_METHOD); - $this->parser->setImports($this->getImports($class)); + $this->parser->setImports($this->getMethodImports($method)); $this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class)); return $this->parser->parse($method->getDocComment(), $context); } /** - * Gets a method annotation. - * - * @param ReflectionMethod $method - * @param string $annotationName The name of the annotation. - * @return mixed The Annotation or NULL, if the requested annotation does not exist. + * {@inheritDoc} */ public function getMethodAnnotation(ReflectionMethod $method, $annotationName) { @@ -260,7 +266,8 @@ public function getMethodAnnotation(ReflectionMethod $method, $annotationName) /** * Returns the ignored annotations for the given class. * - * @param ReflectionClass $class + * @param \ReflectionClass $class + * * @return array */ private function getIgnoredAnnotationNames(ReflectionClass $class) @@ -268,37 +275,94 @@ private function getIgnoredAnnotationNames(ReflectionClass $class) if (isset($this->ignoredAnnotationNames[$name = $class->getName()])) { return $this->ignoredAnnotationNames[$name]; } + $this->collectParsingMetadata($class); return $this->ignoredAnnotationNames[$name]; } /** - * Retrieve imports + * Retrieves imports. * * @param \ReflectionClass $class + * * @return array */ - private function getImports(ReflectionClass $class) + private function getClassImports(ReflectionClass $class) { if (isset($this->imports[$name = $class->getName()])) { return $this->imports[$name]; } + $this->collectParsingMetadata($class); return $this->imports[$name]; } /** - * Collects parsing metadata for a given class + * Retrieves imports for methods. + * + * @param \ReflectionMethod $method * - * @param ReflectionClass $class + * @return array + */ + private function getMethodImports(ReflectionMethod $method) + { + $class = $method->getDeclaringClass(); + $classImports = $this->getClassImports($class); + if (!method_exists($class, 'getTraits')) { + return $classImports; + } + + $traitImports = array(); + + foreach ($class->getTraits() as $trait) { + if ($trait->hasMethod($method->getName()) + && $trait->getFileName() === $method->getFileName() + ) { + $traitImports = array_merge($traitImports, $this->phpParser->parseClass($trait)); + } + } + + return array_merge($classImports, $traitImports); + } + + /** + * Retrieves imports for properties. + * + * @param \ReflectionProperty $property + * + * @return array + */ + private function getPropertyImports(ReflectionProperty $property) + { + $class = $property->getDeclaringClass(); + $classImports = $this->getClassImports($class); + if (!method_exists($class, 'getTraits')) { + return $classImports; + } + + $traitImports = array(); + + foreach ($class->getTraits() as $trait) { + if ($trait->hasProperty($property->getName())) { + $traitImports = array_merge($traitImports, $this->phpParser->parseClass($trait)); + } + } + + return array_merge($classImports, $traitImports); + } + + /** + * Collects parsing metadata for a given class. + * + * @param \ReflectionClass $class */ private function collectParsingMetadata(ReflectionClass $class) { $ignoredAnnotationNames = self::$globalIgnoredNames; + $annotations = $this->preParser->parse($class->getDocComment(), 'class ' . $class->name); - $annotations = $this->preParser->parse($class->getDocComment(), 'class '.$class->name); foreach ($annotations as $annotation) { if ($annotation instanceof IgnoreAnnotation) { foreach ($annotation->names AS $annot) { @@ -308,11 +372,13 @@ private function collectParsingMetadata(ReflectionClass $class) } $name = $class->getName(); + $this->imports[$name] = array_merge( self::$globalImports, $this->phpParser->parseClass($class), array('__NAMESPACE__' => $class->getNamespaceName()) ); + $this->ignoredAnnotationNames[$name] = $ignoredAnnotationNames; } } diff --git a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php index 6135f53d3d3c..13ceb6348b33 100644 --- a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php +++ b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php @@ -20,7 +20,7 @@ namespace Doctrine\Common\Annotations; /** - * AnnotationRegistry + * AnnotationRegistry. */ final class AnnotationRegistry { @@ -43,6 +43,9 @@ final class AnnotationRegistry */ static private $loaders = array(); + /** + * @return void + */ static public function reset() { self::$autoloadNamespaces = array(); @@ -50,9 +53,11 @@ static public function reset() } /** - * Register file + * Registers file. * * @param string $file + * + * @return void */ static public function registerFile($file) { @@ -60,12 +65,14 @@ static public function registerFile($file) } /** - * Add a namespace with one or many directories to look for files or null for the include path. + * Adds a namespace with one or many directories to look for files or null for the include path. * * Loading of this namespaces will be done with a PSR-0 namespace loading algorithm. * - * @param string $namespace + * @param string $namespace * @param string|array|null $dirs + * + * @return void */ static public function registerAutoloadNamespace($namespace, $dirs = null) { @@ -73,11 +80,13 @@ static public function registerAutoloadNamespace($namespace, $dirs = null) } /** - * Register multiple namespaces + * Registers multiple namespaces. * * Loading of this namespaces will be done with a PSR-0 namespace loading algorithm. * * @param array $namespaces + * + * @return void */ static public function registerAutoloadNamespaces(array $namespaces) { @@ -85,13 +94,15 @@ static public function registerAutoloadNamespaces(array $namespaces) } /** - * Register an autoloading callable for annotations, much like spl_autoload_register(). + * Registers an autoloading callable for annotations, much like spl_autoload_register(). * * NOTE: These class loaders HAVE to be silent when a class was not found! * IMPORTANT: Loaders have to return true if they loaded a class that could contain the searched annotation class. * * @param callable $callable * + * @return void + * * @throws \InvalidArgumentException */ static public function registerLoader($callable) @@ -103,9 +114,10 @@ static public function registerLoader($callable) } /** - * Autoload an annotation class silently. + * Autoloads an annotation class silently. * * @param string $class + * * @return boolean */ static public function loadAnnotationClass($class) diff --git a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/CachedReader.php b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/CachedReader.php index e377e3b31473..e6dc59329a5f 100644 --- a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/CachedReader.php +++ b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/CachedReader.php @@ -52,27 +52,24 @@ final class CachedReader implements Reader /** * @var array */ - private $loadedAnnotations; + private $loadedAnnotations = array(); /** - * Constructor + * Constructor. * * @param Reader $reader - * @param Cache $cache - * @param bool $debug + * @param Cache $cache + * @param bool $debug */ public function __construct(Reader $reader, Cache $cache, $debug = false) { $this->delegate = $reader; $this->cache = $cache; - $this->debug = (Boolean) $debug; + $this->debug = (boolean) $debug; } /** - * Get annotations for class - * - * @param \ReflectionClass $class - * @return array + * {@inheritDoc} */ public function getClassAnnotations(\ReflectionClass $class) { @@ -91,11 +88,7 @@ public function getClassAnnotations(\ReflectionClass $class) } /** - * Get selected annotation for class - * - * @param \ReflectionClass $class - * @param string $annotationName - * @return null + * {@inheritDoc} */ public function getClassAnnotation(\ReflectionClass $class, $annotationName) { @@ -109,10 +102,7 @@ public function getClassAnnotation(\ReflectionClass $class, $annotationName) } /** - * Get annotations for property - * - * @param \ReflectionProperty $property - * @return array + * {@inheritDoc} */ public function getPropertyAnnotations(\ReflectionProperty $property) { @@ -132,11 +122,7 @@ public function getPropertyAnnotations(\ReflectionProperty $property) } /** - * Get selected annotation for property - * - * @param \ReflectionProperty $property - * @param string $annotationName - * @return null + * {@inheritDoc} */ public function getPropertyAnnotation(\ReflectionProperty $property, $annotationName) { @@ -150,10 +136,7 @@ public function getPropertyAnnotation(\ReflectionProperty $property, $annotation } /** - * Get method annotations - * - * @param \ReflectionMethod $method - * @return array + * {@inheritDoc} */ public function getMethodAnnotations(\ReflectionMethod $method) { @@ -173,11 +156,7 @@ public function getMethodAnnotations(\ReflectionMethod $method) } /** - * Get selected method annotation - * - * @param \ReflectionMethod $method - * @param string $annotationName - * @return null + * {@inheritDoc} */ public function getMethodAnnotation(\ReflectionMethod $method, $annotationName) { @@ -191,7 +170,9 @@ public function getMethodAnnotation(\ReflectionMethod $method, $annotationName) } /** - * Clear loaded annotations + * Clears loaded annotations. + * + * @return void */ public function clearLoadedAnnotations() { @@ -203,7 +184,8 @@ public function clearLoadedAnnotations() * * @param string $rawCacheKey The cache key. * @param \ReflectionClass $class The related class. - * @return mixed|boolean The cached value or false when the value is not in cache. + * + * @return mixed The cached value or false when the value is not in cache. */ private function fetchFromCache($rawCacheKey, \ReflectionClass $class) { @@ -218,10 +200,12 @@ private function fetchFromCache($rawCacheKey, \ReflectionClass $class) } /** - * Saves a value to the cache + * Saves a value to the cache. * * @param string $rawCacheKey The cache key. * @param mixed $value The value. + * + * @return void */ private function saveToCache($rawCacheKey, $value) { @@ -233,11 +217,12 @@ private function saveToCache($rawCacheKey, $value) } /** - * Check if cache is fresh + * Checks if the cache is fresh. * - * @param string $cacheKey + * @param string $cacheKey * @param \ReflectionClass $class - * @return bool + * + * @return boolean */ private function isCacheFresh($cacheKey, \ReflectionClass $class) { diff --git a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocLexer.php b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocLexer.php index ddc84d6990aa..330afd3657fd 100644 --- a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocLexer.php +++ b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocLexer.php @@ -52,6 +52,9 @@ final class DocLexer extends AbstractLexer const T_NULL = 111; const T_COLON = 112; + /** + * @var array + */ protected $noCase = array( '@' => self::T_AT, ',' => self::T_COMMA, @@ -64,6 +67,9 @@ final class DocLexer extends AbstractLexer '\\' => self::T_NAMESPACE_SEPARATOR ); + /** + * @var array + */ protected $withCase = array( 'true' => self::T_TRUE, 'false' => self::T_FALSE, @@ -76,7 +82,7 @@ final class DocLexer extends AbstractLexer protected function getCatchablePatterns() { return array( - '[a-z_\\\][a-z0-9_\:\\\]*[a-z]{1}', + '[a-z_\\\][a-z0-9_\:\\\]*[a-z_][a-z0-9_]*', '(?:[+-]?[0-9]+(?:[\.][0-9]+)*)(?:[eE][+-]?[0-9]+)?', '"(?:[^"]|"")*"', ); @@ -92,10 +98,6 @@ protected function getNonCatchablePatterns() /** * {@inheritdoc} - * - * @param string $value - * - * @return int */ protected function getType(&$value) { diff --git a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php index 46eb0445ee88..c245fa7bb627 100644 --- a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php +++ b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php @@ -19,6 +19,7 @@ namespace Doctrine\Common\Annotations; +use Doctrine\Common\Annotations\Annotation\Attribute; use ReflectionClass; use Doctrine\Common\Annotations\Annotation\Enum; use Doctrine\Common\Annotations\Annotation\Target; @@ -43,7 +44,12 @@ final class DocParser * * @var array */ - private static $classIdentifiers = array(DocLexer::T_IDENTIFIER, DocLexer::T_TRUE, DocLexer::T_FALSE, DocLexer::T_NULL); + private static $classIdentifiers = array( + DocLexer::T_IDENTIFIER, + DocLexer::T_TRUE, + DocLexer::T_FALSE, + DocLexer::T_NULL + ); /** * The lexer. @@ -53,14 +59,14 @@ final class DocParser private $lexer; /** - * Current target context + * Current target context. * * @var string */ private $target; /** - * Doc Parser used to collect annotation target + * Doc parser used to collect annotation target. * * @var \Doctrine\Common\Annotations\DocParser */ @@ -119,7 +125,8 @@ final class DocParser private $context = ''; /** - * Hash-map for caching annotation metadata + * Hash-map for caching annotation metadata. + * * @var array */ private static $annotationMetadata = array( @@ -209,7 +216,7 @@ final class DocParser ); /** - * Hash-map for handle types declaration + * Hash-map for handle types declaration. * * @var array */ @@ -236,6 +243,8 @@ public function __construct() * fully qualified class names. * * @param array $names + * + * @return void */ public function setIgnoredAnnotationNames(array $names) { @@ -243,13 +252,15 @@ public function setIgnoredAnnotationNames(array $names) } /** - * Sets ignore on not-imported annotations + * Sets ignore on not-imported annotations. * - * @param $bool + * @param boolean $bool + * + * @return void */ public function setIgnoreNotImportedAnnotations($bool) { - $this->ignoreNotImportedAnnotations = (Boolean) $bool; + $this->ignoreNotImportedAnnotations = (boolean) $bool; } /** @@ -257,6 +268,8 @@ public function setIgnoreNotImportedAnnotations($bool) * * @param array $namespace * + * @return void + * * @throws \RuntimeException */ public function addNamespace($namespace) @@ -264,13 +277,17 @@ public function addNamespace($namespace) if ($this->imports) { throw new \RuntimeException('You must either use addNamespace(), or setImports(), but not both.'); } + $this->namespaces[] = $namespace; } /** - * Sets the imports + * Sets the imports. * * @param array $imports + * + * @return void + * * @throws \RuntimeException */ public function setImports(array $imports) @@ -278,13 +295,16 @@ public function setImports(array $imports) if ($this->namespaces) { throw new \RuntimeException('You must either use addNamespace(), or setImports(), but not both.'); } + $this->imports = $imports; } - /** + /** * Sets current target context as bitmask. * * @param integer $target + * + * @return void */ public function setTarget($target) { @@ -294,34 +314,55 @@ public function setTarget($target) /** * Parses the given docblock string for annotations. * - * @param string $input The docblock string to parse. + * @param string $input The docblock string to parse. * @param string $context The parsing context. + * * @return array Array of annotations. If no annotations are found, an empty array is returned. */ public function parse($input, $context = '') { - if (false === $pos = strpos($input, '@')) { + $pos = $this->findInitialTokenPosition($input); + if ($pos === null) { return array(); } - // also parse whatever character is before the @ - if ($pos > 0) { - $pos -= 1; - } - $this->context = $context; + $this->lexer->setInput(trim(substr($input, $pos), '* /')); $this->lexer->moveNext(); return $this->Annotations(); } + /** + * Finds the first valid annotation + * + * @param string $input The docblock string to parse + * + * @return int|null + */ + private function findInitialTokenPosition($input) + { + $pos = 0; + + // search for first valid annotation + while (($pos = strpos($input, '@', $pos)) !== false) { + // if the @ is preceded by a space or * it is valid + if ($pos === 0 || $input[$pos - 1] === ' ' || $input[$pos - 1] === '*') { + return $pos; + } + + $pos++; + } + } + /** * Attempts to match the given token with the current lookahead token. * If they match, updates the lookahead token; otherwise raises a syntax error. * - * @param int $token type of Token. - * @return bool True if tokens match; false otherwise. + * @param integer $token Type of token. + * + * @return boolean True if tokens match; false otherwise. */ private function match($token) { @@ -339,7 +380,8 @@ private function match($token) * a syntax error is raised. * * @param array $tokens - * @return bool + * + * @return boolean */ private function matchAny(array $tokens) { @@ -353,8 +395,10 @@ private function matchAny(array $tokens) /** * Generates a new syntax error. * - * @param string $expected Expected string. - * @param array $token Optional token. + * @param string $expected Expected string. + * @param array|null $token Optional token. + * + * @return void * * @throws AnnotationException */ @@ -364,13 +408,10 @@ private function syntaxError($expected, $token = null) $token = $this->lexer->lookahead; } - $message = "Expected {$expected}, got "; - - if ($this->lexer->lookahead === null) { - $message .= 'end of string'; - } else { - $message .= "'{$token['value']}' at position {$token['position']}"; - } + $message = sprintf('Expected %s, got ', $expected); + $message .= ($this->lexer->lookahead === null) + ? 'end of string' + : sprintf("'%s' at position %s", $token['value'], $token['position']); if (strlen($this->context)) { $message .= ' in ' . $this->context; @@ -382,10 +423,11 @@ private function syntaxError($expected, $token = null) } /** - * Attempt to check if a class exists or not. This never goes through the PHP autoloading mechanism + * Attempts to check if a class exists or not. This never goes through the PHP autoloading mechanism * but uses the {@link AnnotationRegistry} to load classes. * * @param string $fqcn + * * @return boolean */ private function classExists($fqcn) @@ -407,11 +449,14 @@ private function classExists($fqcn) * Collects parsing metadata for a given annotation class * * @param string $name The annotation name + * + * @return void */ private function collectAnnotationMetadata($name) { - if (self::$metadataParser == null){ + if (self::$metadataParser === null) { self::$metadataParser = new self(); + self::$metadataParser->setIgnoreNotImportedAnnotations(true); self::$metadataParser->setIgnoredAnnotationNames($this->ignoredAnnotationNames); self::$metadataParser->setImports(array( @@ -420,6 +465,7 @@ private function collectAnnotationMetadata($name) 'attribute' => 'Doctrine\Common\Annotations\Annotation\Attribute', 'attributes' => 'Doctrine\Common\Annotations\Annotation\Attributes' )); + AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Enum.php'); AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Target.php'); AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Attribute.php'); @@ -443,7 +489,6 @@ private function collectAnnotationMetadata($name) // verify that the class is really meant to be an annotation if ($metadata['is_annotation']) { - self::$metadataParser->setTarget(Target::TARGET_CLASS); foreach (self::$metadataParser->parse($docComment, 'class @' . $name) as $annotation) { @@ -451,29 +496,12 @@ private function collectAnnotationMetadata($name) $metadata['targets'] = $annotation->targets; $metadata['targets_literal'] = $annotation->literal; - } elseif ($annotation instanceof Attributes) { - foreach ($annotation->value as $attrib) { - // handle internal type declaration - $type = isset(self::$typeMap[$attrib->type]) ? self::$typeMap[$attrib->type] : $attrib->type; - - // handle the case if the property type is mixed - if ('mixed' !== $type) { - // Checks if the property has array<type> - if (false !== $pos = strpos($type, '<')) { - $arrayType = substr($type, $pos+1, -1); - $type = 'array'; - - if (isset(self::$typeMap[$arrayType])) { - $arrayType = self::$typeMap[$arrayType]; - } - - $metadata['attribute_types'][$attrib->name]['array_type'] = $arrayType; - } + continue; + } - $metadata['attribute_types'][$attrib->name]['type'] = $type; - $metadata['attribute_types'][$attrib->name]['value'] = $attrib->type; - $metadata['attribute_types'][$attrib->name]['required'] = $attrib->required; - } + if ($annotation instanceof Attributes) { + foreach ($annotation->value as $attribute) { + $this->collectAttributeTypeMetadata($metadata, $attribute); } } } @@ -483,51 +511,36 @@ private function collectAnnotationMetadata($name) // collect all public properties foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { $metadata['properties'][$property->name] = $property->name; - - if(false === ($propertyComment = $property->getDocComment())) { + + if (false === ($propertyComment = $property->getDocComment())) { continue; } - // checks if the property has @var annotation - if (false !== strpos($propertyComment, '@var') - && preg_match('/@var\s+([^\s]+)/',$propertyComment, $matches)) { - // literal type declaration - $value = $matches[1]; - - // handle internal type declaration - $type = isset(self::$typeMap[$value]) ? self::$typeMap[$value] : $value; - - // handle the case if the property type is mixed - if ('mixed' !== $type) { - // Checks if the property has @var array<type> annotation - if (false !== $pos = strpos($type, '<')) { - $arrayType = substr($type, $pos+1, -1); - $type = 'array'; - - if (isset(self::$typeMap[$arrayType])) { - $arrayType = self::$typeMap[$arrayType]; - } + $attribute = new Attribute(); - $metadata['attribute_types'][$property->name]['array_type'] = $arrayType; - } + $attribute->required = (false !== strpos($propertyComment, '@Required')); + $attribute->name = $property->name; + $attribute->type = (false !== strpos($propertyComment, '@var') && preg_match('/@var\s+([^\s]+)/',$propertyComment, $matches)) + ? $matches[1] + : 'mixed'; - $metadata['attribute_types'][$property->name]['type'] = $type; - $metadata['attribute_types'][$property->name]['value'] = $value; - $metadata['attribute_types'][$property->name]['required'] = false !== strpos($propertyComment, '@Required'); - } - } + $this->collectAttributeTypeMetadata($metadata, $attribute); // checks if the property has @Enum - if (false !== strpos($propertyComment, '@Enum')){ - + if (false !== strpos($propertyComment, '@Enum')) { $context = 'property ' . $class->name . "::\$" . $property->name; + self::$metadataParser->setTarget(Target::TARGET_PROPERTY); foreach (self::$metadataParser->parse($propertyComment, $context) as $annotation) { - if($annotation instanceof Enum) { - $metadata['enum'][$property->name]['value'] = $annotation->value; - $metadata['enum'][$property->name]['literal'] = ! empty($annotation->literal) ? $annotation->literal : $annotation->value; + if ( ! $annotation instanceof Enum) { + continue; } + + $metadata['enum'][$property->name]['value'] = $annotation->value; + $metadata['enum'][$property->name]['literal'] = ( ! empty($annotation->literal)) + ? $annotation->literal + : $annotation->value; } } } @@ -540,6 +553,58 @@ private function collectAnnotationMetadata($name) self::$annotationMetadata[$name] = $metadata; } + /** + * Collects parsing metadata for a given attribute. + * + * @param array $metadata + * @param Attribute $attribute + * + * @return void + */ + private function collectAttributeTypeMetadata(&$metadata, Attribute $attribute) + { + // handle internal type declaration + $type = isset(self::$typeMap[$attribute->type]) + ? self::$typeMap[$attribute->type] + : $attribute->type; + + // handle the case if the property type is mixed + if ('mixed' === $type) { + return; + } + + // Evaluate type + switch (true) { + // Checks if the property has array<type> + case (false !== $pos = strpos($type, '<')): + $arrayType = substr($type, $pos + 1, -1); + $type = 'array'; + + if (isset(self::$typeMap[$arrayType])) { + $arrayType = self::$typeMap[$arrayType]; + } + + $metadata['attribute_types'][$attribute->name]['array_type'] = $arrayType; + break; + + // Checks if the property has type[] + case (false !== $pos = strrpos($type, '[')): + $arrayType = substr($type, 0, $pos); + $type = 'array'; + + if (isset(self::$typeMap[$arrayType])) { + $arrayType = self::$typeMap[$arrayType]; + } + + $metadata['attribute_types'][$attribute->name]['array_type'] = $arrayType; + break; + } + + $metadata['attribute_types'][$attribute->name]['type'] = $type; + $metadata['attribute_types'][$attribute->name]['value'] = $attribute->type; + $metadata['attribute_types'][$attribute->name]['required'] = $attribute->required; + } + /** * Annotations ::= Annotation {[ "*" ]* [Annotation]}* * @@ -586,8 +651,9 @@ private function Annotations() * NameSpacePart ::= identifier | null | false | true * SimpleName ::= identifier | null | false | true * - * @throws AnnotationException * @return mixed False if it is not a valid annotation. + * + * @throws AnnotationException */ private function Annotation() { @@ -599,10 +665,11 @@ private function Annotation() // only process names which are not fully qualified, yet // fully qualified names must start with a \ $originalName = $name; + if ('\\' !== $name[0]) { $alias = (false === $pos = strpos($name, '\\'))? $name : substr($name, 0, $pos); - $found = false; + if ($this->namespaces) { foreach ($this->namespaces as $namespace) { if ($this->classExists($namespace.'\\'.$name)) { @@ -612,20 +679,21 @@ private function Annotation() } } } elseif (isset($this->imports[$loweredAlias = strtolower($alias)])) { - if (false !== $pos) { - $name = $this->imports[$loweredAlias].substr($name, $pos); - } else { - $name = $this->imports[$loweredAlias]; - } $found = true; - } elseif (isset($this->imports['__NAMESPACE__']) && $this->classExists($this->imports['__NAMESPACE__'].'\\'.$name)) { - $name = $this->imports['__NAMESPACE__'].'\\'.$name; - $found = true; - } elseif ($this->classExists($name)) { + $name = (false !== $pos) + ? $this->imports[$loweredAlias] . substr($name, $pos) + : $this->imports[$loweredAlias]; + } elseif ( ! isset($this->ignoredAnnotationNames[$name]) + && isset($this->imports['__NAMESPACE__']) + && $this->classExists($this->imports['__NAMESPACE__'] . '\\' . $name) + ) { + $name = $this->imports['__NAMESPACE__'].'\\'.$name; + $found = true; + } elseif (! isset($this->ignoredAnnotationNames[$name]) && $this->classExists($name)) { $found = true; } - if (!$found) { + if ( ! $found) { if ($this->ignoreNotImportedAnnotations || isset($this->ignoredAnnotationNames[$name])) { return false; } @@ -634,7 +702,7 @@ private function Annotation() } } - if (!$this->classExists($name)) { + if ( ! $this->classExists($name)) { throw AnnotationException::semanticalError(sprintf('The annotation "@%s" in %s does not exist, or could not be auto-loaded.', $name, $this->context)); } @@ -644,7 +712,7 @@ private function Annotation() // collects the metadata annotation only if there is not yet - if (!isset(self::$annotationMetadata[$name])) { + if ( ! isset(self::$annotationMetadata[$name])) { $this->collectAnnotationMetadata($name); } @@ -709,12 +777,12 @@ private function Annotation() if (isset($type['array_type'])) { foreach ($values[$property] as $item) { if (gettype($item) !== $type['array_type'] && !$item instanceof $type['array_type']) { - throw AnnotationException::typeError($property, $originalName, $this->context, 'either a(n) '.$type['array_type'].', or an array of '.$type['array_type'].'s', $item); + throw AnnotationException::attributeTypeError($property, $originalName, $this->context, 'either a(n) '.$type['array_type'].', or an array of '.$type['array_type'].'s', $item); } } } } elseif (gettype($values[$property]) !== $type['type'] && !$values[$property] instanceof $type['type']) { - throw AnnotationException::typeError($property, $originalName, $this->context, 'a(n) '.$type['value'], $values[$property]); + throw AnnotationException::attributeTypeError($property, $originalName, $this->context, 'a(n) '.$type['value'], $values[$property]); } } @@ -733,7 +801,7 @@ private function Annotation() } // handle the case if the property has no annotations - if (!$property = self::$annotationMetadata[$name]['default_property']) { + if ( ! $property = self::$annotationMetadata[$name]['default_property']) { throw AnnotationException::creationError(sprintf('The annotation @%s declared on %s does not accept any values, but got %s.', $originalName, $this->context, json_encode($values))); } } @@ -825,8 +893,9 @@ private function Values() /** * Constant ::= integer | string | float | boolean * - * @throws AnnotationException * @return mixed + * + * @throws AnnotationException */ private function Constant() { @@ -850,20 +919,19 @@ private function Constant() break; case isset($this->imports[$loweredAlias = strtolower($alias)]): - $found = true; - if (false !== $pos) { - $className = $this->imports[$loweredAlias].substr($className, $pos); - } else { - $className = $this->imports[$loweredAlias]; - } + $found = true; + $className = (false !== $pos) + ? $this->imports[$loweredAlias] . substr($className, $pos) + : $this->imports[$loweredAlias]; break; default: if(isset($this->imports['__NAMESPACE__'])) { $ns = $this->imports['__NAMESPACE__']; + if (class_exists($ns.'\\'.$className) || interface_exists($ns.'\\'.$className)) { - $className = $ns.'\\'.$className; - $found = true; + $className = $ns.'\\'.$className; + $found = true; } } break; @@ -874,6 +942,12 @@ private function Constant() } } + // checks if identifier ends with ::class, \strlen('::class') === 7 + $classPos = stripos($identifier, '::class'); + if ($classPos === strlen($identifier) - 7) { + return substr($identifier, 0, $classPos); + } + if (!defined($identifier)) { throw AnnotationException::semanticalErrorConstants($identifier, $this->context); } @@ -889,18 +963,20 @@ private function Constant() private function Identifier() { // check if we have an annotation - if ($this->lexer->isNextTokenAny(self::$classIdentifiers)) { - $this->lexer->moveNext(); - $className = $this->lexer->token['value']; - } else { + if ( ! $this->lexer->isNextTokenAny(self::$classIdentifiers)) { $this->syntaxError('namespace separator or identifier'); } + $this->lexer->moveNext(); + + $className = $this->lexer->token['value']; + while ($this->lexer->lookahead['position'] === ($this->lexer->token['position'] + strlen($this->lexer->token['value'])) && $this->lexer->isNextToken(DocLexer::T_NAMESPACE_SEPARATOR)) { $this->match(DocLexer::T_NAMESPACE_SEPARATOR); $this->matchAny(self::$classIdentifiers); + $className .= '\\' . $this->lexer->token['value']; } diff --git a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/FileCacheReader.php b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/FileCacheReader.php index 5e937a861592..e9b29af18709 100644 --- a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/FileCacheReader.php +++ b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/FileCacheReader.php @@ -19,7 +19,6 @@ namespace Doctrine\Common\Annotations; - /** * File cache reader for annotations. * @@ -48,14 +47,17 @@ class FileCacheReader implements Reader */ private $loadedAnnotations = array(); + /** + * @var array + */ private $classNameHashes = array(); /** - * Constructor + * Constructor. * - * @param Reader $reader - * @param string $cacheDir - * @param bool $debug + * @param Reader $reader + * @param string $cacheDir + * @param boolean $debug * * @throws \InvalidArgumentException */ @@ -65,19 +67,13 @@ public function __construct(Reader $reader, $cacheDir, $debug = false) if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777, true)) { throw new \InvalidArgumentException(sprintf('The directory "%s" does not exist and could not be created.', $cacheDir)); } - if (!is_writable($cacheDir)) { - throw new \InvalidArgumentException(sprintf('The directory "%s" is not writable. Both, the webserver and the console user need access. You can manage access rights for multiple users with "chmod +a". If your system does not support this, check out the acl package.', $cacheDir)); - } $this->dir = rtrim($cacheDir, '\\/'); $this->debug = $debug; } /** - * Retrieve annotations for class - * - * @param \ReflectionClass $class - * @return array + * {@inheritDoc} */ public function getClassAnnotations(\ReflectionClass $class) { @@ -111,10 +107,7 @@ public function getClassAnnotations(\ReflectionClass $class) } /** - * Get annotations for property - * - * @param \ReflectionProperty $property - * @return array + * {@inheritDoc} */ public function getPropertyAnnotations(\ReflectionProperty $property) { @@ -149,10 +142,7 @@ public function getPropertyAnnotations(\ReflectionProperty $property) } /** - * Retrieve annotations for method - * - * @param \ReflectionMethod $method - * @return array + * {@inheritDoc} */ public function getMethodAnnotations(\ReflectionMethod $method) { @@ -187,24 +177,23 @@ public function getMethodAnnotations(\ReflectionMethod $method) } /** - * Save cache file + * Saves the cache file. * * @param string $path - * @param mixed $data + * @param mixed $data + * + * @return void */ private function saveCacheFile($path, $data) { + if (!is_writable($this->dir)) { + throw new \InvalidArgumentException(sprintf('The directory "%s" is not writable. Both, the webserver and the console user need access. You can manage access rights for multiple users with "chmod +a". If your system does not support this, check out the acl package.', $this->dir)); + } file_put_contents($path, '<?php return unserialize('.var_export(serialize($data), true).');'); } /** - * Gets a class annotation. - * - * @param \ReflectionClass $class The ReflectionClass of the class from which - * the class annotations should be read. - * @param string $annotationName The name of the annotation. - * - * @return mixed The Annotation or NULL, if the requested annotation does not exist. + * {@inheritDoc} */ public function getClassAnnotation(\ReflectionClass $class, $annotationName) { @@ -220,11 +209,7 @@ public function getClassAnnotation(\ReflectionClass $class, $annotationName) } /** - * Gets a method annotation. - * - * @param \ReflectionMethod $method - * @param string $annotationName The name of the annotation. - * @return mixed The Annotation or NULL, if the requested annotation does not exist. + * {@inheritDoc} */ public function getMethodAnnotation(\ReflectionMethod $method, $annotationName) { @@ -240,11 +225,7 @@ public function getMethodAnnotation(\ReflectionMethod $method, $annotationName) } /** - * Gets a property annotation. - * - * @param \ReflectionProperty $property - * @param string $annotationName The name of the annotation. - * @return mixed The Annotation or NULL, if the requested annotation does not exist. + * {@inheritDoc} */ public function getPropertyAnnotation(\ReflectionProperty $property, $annotationName) { @@ -260,7 +241,9 @@ public function getPropertyAnnotation(\ReflectionProperty $property, $annotation } /** - * Clear stores annotations + * Clears loaded annotations. + * + * @return void */ public function clearLoadedAnnotations() { diff --git a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/IndexedReader.php b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/IndexedReader.php index 2dfdd4da18db..bf7fbdcdd3de 100644 --- a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/IndexedReader.php +++ b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/IndexedReader.php @@ -19,8 +19,6 @@ namespace Doctrine\Common\Annotations; -use Doctrine\Common\Annotations\Reader; - /** * Allows the reader to be used in-place of Doctrine's reader. * @@ -34,7 +32,7 @@ class IndexedReader implements Reader private $delegate; /** - * Constructor + * Constructor. * * @param Reader $reader */ @@ -44,10 +42,7 @@ public function __construct(Reader $reader) } /** - * Get Annotations for class - * - * @param \ReflectionClass $class - * @return array + * {@inheritDoc} */ public function getClassAnnotations(\ReflectionClass $class) { @@ -60,11 +55,7 @@ public function getClassAnnotations(\ReflectionClass $class) } /** - * Get selected annotation for class - * - * @param \ReflectionClass $class - * @param string $annotation - * @return mixed + * {@inheritDoc} */ public function getClassAnnotation(\ReflectionClass $class, $annotation) { @@ -72,10 +63,7 @@ public function getClassAnnotation(\ReflectionClass $class, $annotation) } /** - * Get Annotations for method - * - * @param \ReflectionMethod $method - * @return array + * {@inheritDoc} */ public function getMethodAnnotations(\ReflectionMethod $method) { @@ -88,11 +76,7 @@ public function getMethodAnnotations(\ReflectionMethod $method) } /** - * Get selected annotation for method - * - * @param \ReflectionMethod $method - * @param string $annotation - * @return mixed + * {@inheritDoc} */ public function getMethodAnnotation(\ReflectionMethod $method, $annotation) { @@ -100,10 +84,7 @@ public function getMethodAnnotation(\ReflectionMethod $method, $annotation) } /** - * Get annotations for property - * - * @param \ReflectionProperty $property - * @return array + * {@inheritDoc} */ public function getPropertyAnnotations(\ReflectionProperty $property) { @@ -116,11 +97,7 @@ public function getPropertyAnnotations(\ReflectionProperty $property) } /** - * Get selected annotation for property - * - * @param \ReflectionProperty $property - * @param string $annotation - * @return mixed + * {@inheritDoc} */ public function getPropertyAnnotation(\ReflectionProperty $property, $annotation) { @@ -128,10 +105,11 @@ public function getPropertyAnnotation(\ReflectionProperty $property, $annotation } /** - * Proxy all methods to the delegate. + * Proxies all methods to the delegate. * * @param string $method - * @param array $args + * @param array $args + * * @return mixed */ public function __call($method, $args) diff --git a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/PhpParser.php b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/PhpParser.php index 9d61020d36d4..21ee7cc90301 100644 --- a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/PhpParser.php +++ b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/PhpParser.php @@ -32,8 +32,9 @@ final class PhpParser /** * Parses a class. * - * @param \ReflectionClass $class A <code>ReflectionClass</code> object. - * @return array A list with use statements in the form (Alias => FQN). + * @param \ReflectionClass $class A <code>ReflectionClass</code> object. + * + * @return array A list with use statements in the form (Alias => FQN). */ public function parseClass(\ReflectionClass $class) { @@ -61,10 +62,11 @@ public function parseClass(\ReflectionClass $class) } /** - * Get the content of the file right up to the given line number. + * Gets the content of the file right up to the given line number. + * + * @param string $filename The name of the file to load. + * @param integer $lineNumber The number of lines to read from file. * - * @param string $filename The name of the file to load. - * @param int $lineNumber The number of lines to read from file. * @return string The content of the file. */ private function getFileContent($filename, $lineNumber) diff --git a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Reader.php b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Reader.php index 6a01cb4a56b2..4774f87312bf 100644 --- a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Reader.php +++ b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Reader.php @@ -27,41 +27,63 @@ interface Reader { /** - * @param \ReflectionClass $class - * @return mixed + * Gets the annotations applied to a class. + * + * @param \ReflectionClass $class The ReflectionClass of the class from which + * the class annotations should be read. + * + * @return array An array of Annotations. */ function getClassAnnotations(\ReflectionClass $class); /** - * @param \ReflectionClass $class - * @param string $annotationName - * @return mixed + * Gets a class annotation. + * + * @param \ReflectionClass $class The ReflectionClass of the class from which + * the class annotations should be read. + * @param string $annotationName The name of the annotation. + * + * @return object|null The Annotation or NULL, if the requested annotation does not exist. */ function getClassAnnotation(\ReflectionClass $class, $annotationName); /** - * @param \ReflectionMethod $method - * @return mixed + * Gets the annotations applied to a method. + * + * @param \ReflectionMethod $method The ReflectionMethod of the method from which + * the annotations should be read. + * + * @return array An array of Annotations. */ function getMethodAnnotations(\ReflectionMethod $method); /** - * @param \ReflectionMethod $method - * @param string $annotationName - * @return mixed + * Gets a method annotation. + * + * @param \ReflectionMethod $method The ReflectionMethod to read the annotations from. + * @param string $annotationName The name of the annotation. + * + * @return object|null The Annotation or NULL, if the requested annotation does not exist. */ function getMethodAnnotation(\ReflectionMethod $method, $annotationName); /** - * @param \ReflectionProperty $property - * @return mixed + * Gets the annotations applied to a property. + * + * @param \ReflectionProperty $property The ReflectionProperty of the property + * from which the annotations should be read. + * + * @return array An array of Annotations. */ function getPropertyAnnotations(\ReflectionProperty $property); /** - * @param \ReflectionProperty $property - * @param string $annotationName - * @return mixed + * Gets a property annotation. + * + * @param \ReflectionProperty $property The ReflectionProperty to read the annotations from. + * @param string $annotationName The name of the annotation. + * + * @return object|null The Annotation or NULL, if the requested annotation does not exist. */ function getPropertyAnnotation(\ReflectionProperty $property, $annotationName); } diff --git a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/SimpleAnnotationReader.php b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/SimpleAnnotationReader.php index 4210d9018455..d4757eea2fb5 100644 --- a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/SimpleAnnotationReader.php +++ b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/SimpleAnnotationReader.php @@ -19,8 +19,6 @@ namespace Doctrine\Common\Annotations; -use Doctrine\Common\Annotations\Annotation\Target; - /** * Simple Annotation Reader. * @@ -53,6 +51,8 @@ public function __construct() * Adds a namespace in which we will look for annotations. * * @param string $namespace + * + * @return void */ public function addNamespace($namespace) { @@ -60,12 +60,7 @@ public function addNamespace($namespace) } /** - * Gets the annotations applied to a class. - * - * @param \ReflectionClass $class The ReflectionClass of the class from which - * the class annotations should be read. - * - * @return array An array of Annotations. + * {@inheritDoc} */ public function getClassAnnotations(\ReflectionClass $class) { @@ -73,12 +68,7 @@ public function getClassAnnotations(\ReflectionClass $class) } /** - * Gets the annotations applied to a method. - * - * @param \ReflectionMethod $method The ReflectionMethod of the method from which - * the annotations should be read. - * - * @return array An array of Annotations. + * {@inheritDoc} */ public function getMethodAnnotations(\ReflectionMethod $method) { @@ -86,12 +76,7 @@ public function getMethodAnnotations(\ReflectionMethod $method) } /** - * Gets the annotations applied to a property. - * - * @param \ReflectionProperty $property The ReflectionProperty of the property - * from which the annotations should be read. - * - * @return array An array of Annotations. + * {@inheritDoc} */ public function getPropertyAnnotations(\ReflectionProperty $property) { @@ -99,13 +84,7 @@ public function getPropertyAnnotations(\ReflectionProperty $property) } /** - * Gets a class annotation. - * - * @param \ReflectionClass $class The ReflectionClass of the class from which - * the class annotations should be read. - * @param string $annotationName The name of the annotation. - * - * @return mixed The Annotation or NULL, if the requested annotation does not exist. + * {@inheritDoc} */ public function getClassAnnotation(\ReflectionClass $class, $annotationName) { @@ -119,12 +98,7 @@ public function getClassAnnotation(\ReflectionClass $class, $annotationName) } /** - * Gets a method annotation. - * - * @param \ReflectionMethod $method - * @param string $annotationName The name of the annotation. - * - * @return mixed The Annotation or NULL, if the requested annotation does not exist. + * {@inheritDoc} */ public function getMethodAnnotation(\ReflectionMethod $method, $annotationName) { @@ -138,11 +112,7 @@ public function getMethodAnnotation(\ReflectionMethod $method, $annotationName) } /** - * Gets a property annotation. - * - * @param \ReflectionProperty $property - * @param string $annotationName The name of the annotation. - * @return mixed The Annotation or NULL, if the requested annotation does not exist. + * {@inheritDoc} */ public function getPropertyAnnotation(\ReflectionProperty $property, $annotationName) { diff --git a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/TokenParser.php b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/TokenParser.php index a1ef1154f011..9bdcccec92d2 100644 --- a/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/TokenParser.php +++ b/core/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/TokenParser.php @@ -39,7 +39,7 @@ class TokenParser * * @var int */ - private $numTokens = 0; + private $numTokens; /** * The current array pointer. @@ -48,21 +48,32 @@ class TokenParser */ private $pointer = 0; + /** + * @param string $contents + */ public function __construct($contents) { $this->tokens = token_get_all($contents); + + // The PHP parser sets internal compiler globals for certain things. Annoyingly, the last docblock comment it + // saw gets stored in doc_comment. When it comes to compile the next thing to be include()d this stored + // doc_comment becomes owned by the first thing the compiler sees in the file that it considers might have a + // docblock. If the first thing in the file is a class without a doc block this would cause calls to + // getDocBlock() on said class to return our long lost doc_comment. Argh. + // To workaround, cause the parser to parse an empty docblock. Sure getDocBlock() will return this, but at least + // it's harmless to us. + token_get_all("<?php\n/**\n *\n */"); + $this->numTokens = count($this->tokens); - $this->pointer = 0; } /** * Gets the next non whitespace and non comment token. * - * @param $docCommentIsComment - * If TRUE then a doc comment is considered a comment and skipped. - * If FALSE then only whitespace and normal comments are skipped. + * @param boolean $docCommentIsComment If TRUE then a doc comment is considered a comment and skipped. + * If FALSE then only whitespace and normal comments are skipped. * - * @return array The token if exists, null otherwise. + * @return array|null The token if exists, null otherwise. */ public function next($docCommentIsComment = TRUE) { @@ -82,7 +93,7 @@ public function next($docCommentIsComment = TRUE) } /** - * Parse a single use statement. + * Parses a single use statement. * * @return array A list with all found class names for a use statement. */ @@ -119,9 +130,10 @@ public function parseUseStatement() } /** - * Get all use statements. + * Gets all use statements. * * @param string $namespaceName The namespace name of the reflected class. + * * @return array A list with all found use statements. */ public function parseUseStatements($namespaceName) @@ -146,7 +158,7 @@ public function parseUseStatements($namespaceName) } /** - * Get the namespace. + * Gets the namespace. * * @return string The found namespace. */ @@ -161,9 +173,9 @@ public function parseNamespace() } /** - * Get the class name. + * Gets the class name. * - * @return string The foundclass name. + * @return string The found class name. */ public function parseClass() { diff --git a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php index 1e4a95ed4f70..dd324bdf124c 100644 --- a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php +++ b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/AbstractReaderTest.php @@ -4,6 +4,7 @@ use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation; use Doctrine\Common\Annotations\Annotation; +use Doctrine\Common\Annotations\Reader; use ReflectionClass, Doctrine\Common\Annotations\AnnotationReader; require_once __DIR__ . '/TopLevelAnnotation.php'; @@ -84,6 +85,18 @@ public function testAnnotationsWithVarType() $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', $barAnnot[0]->annotation); } + public function testAtInDescription() + { + $reader = $this->getReader(); + $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithAtInDescriptionAndAnnotation'); + + $this->assertEquals(1, count($fooAnnot = $reader->getPropertyAnnotations($class->getProperty('foo')))); + $this->assertEquals(1, count($barAnnot = $reader->getPropertyAnnotations($class->getProperty('bar')))); + + $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetPropertyMethod', $fooAnnot[0]); + $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetPropertyMethod', $barAnnot[0]); + } + public function testClassWithWithDanglingComma() { $reader = $this->getReader(); @@ -241,6 +254,14 @@ public function testNonAnnotationProblem() $this->assertInstanceOf($name, $annot); } + public function testIncludeIgnoreAnnotation() + { + $reader = $this->getReader(); + + $reader->getPropertyAnnotations(new \ReflectionProperty('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithIgnoreAnnotation', 'foo')); + $this->assertFalse(class_exists('Doctrine\Tests\Common\Annotations\Fixtures\IgnoreAnnotationClass', false)); + } + public function testImportWithConcreteAnnotation() { $reader = $this->getReader(); @@ -303,6 +324,53 @@ public function testIgnoresAnnotationsNotPrefixedWithWhitespace() $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Name', $annotation); } + private static $testResetsPhpParserAfterUseRun = false; + + /** + * When getUseStatements isn't available on ReflectionClass the PhpParser has to use token_get_all(). If that + * happens various PHP compiler globals get set, and these can have seriously bad effects on the next file to be + * parsed. + * Notably the doc_comment compiler global can end up containing a docblock comment. The next file to be parsed + * on an include() will have this docblock comment attached to the first thing in the file that the compiler + * considers to own comments. If this is a class then any later calls to getDocComment() for that class will have + * undesirable effects. *sigh* + */ + public function testResetsPhpParserAfterUse() + { + // If someone has already included our main test fixture this test is invalid. It's important that our require + // causes this file to be parsed and compiled at a certain point. + $this->assertFalse(!self::$testResetsPhpParserAfterUseRun && class_exists('Doctrine_Tests_Common_Annotations_Fixtures_ClassNoNamespaceNoComment'), 'Test invalid if class has already been compiled'); + self::$testResetsPhpParserAfterUseRun = true; + + $reader = $this->getReader(); + + // First make sure the annotation cache knows about the annotations we want to use. + // If we don't do this then loading of annotations into the cache will cause the parser to get out of the bad + // state we want to test. + $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithValidAnnotationTarget'); + $reader->getClassAnnotations($class); + + // Now import an incredibly dull class which makes use of the same class level annotation that the previous class does. + $class = new ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassWithClassAnnotationOnly'); + $annotations = $reader->getClassAnnotations($class); + + // This include needs to be here since we need the PHP compiler to run over it as the next thing the PHP + // parser sees since PhpParser called token_get_all() on the intro to ClassWithClassAnnotationOnly. + // Our test class cannot be in a namespace (some versions of PHP reset the doc_comment compiler global when + // you hit a namespace declaration), so cannot be autoloaded. + require_once __DIR__ . '/Fixtures/ClassNoNamespaceNoComment.php'; + + // So, hopefully, if all has gone OK, our class with class annotations should actually have them. + // If this fails then something is quite badly wrong elsewhere. + // Note that if this happens before the require it can cause other PHP files to be included, resetting the + // compiler global state, and invalidating this test case. + $this->assertNotEmpty($annotations); + + $annotations = $reader->getClassAnnotations(new \ReflectionClass(new \Doctrine_Tests_Common_Annotations_Fixtures_ClassNoNamespaceNoComment())); + // And if our workaround for this bug is OK, our class with no doc comment should not have any class annotations. + $this->assertEmpty($annotations); + } + /** * @expectedException \Doctrine\Common\Annotations\AnnotationException * @expectedExceptionMessage The class "Doctrine\Tests\Common\Annotations\Fixtures\NoAnnotation" 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\NoAnnotation". If it is indeed no annotation, then you need to add @IgnoreAnnotation("NoAnnotation") to the _class_ doc comment of class Doctrine\Tests\Common\Annotations\Fixtures\InvalidAnnotationUsageClass. @@ -373,7 +441,7 @@ public function testIgnoreFixMeAndUpperCaseToDo() $ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\DCOM106'); $reader->getClassAnnotations($ref); } - + /** * @return AnnotationReader */ @@ -557,7 +625,7 @@ class DummyClassWithEmail */ class DCOM106 { - + } namespace Doctrine\Tests\Common\Annotations\Foo; diff --git a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Annotation/TargetTest.php b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Annotation/TargetTest.php new file mode 100644 index 000000000000..7627f76368de --- /dev/null +++ b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Annotation/TargetTest.php @@ -0,0 +1,47 @@ +<?php +/* + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * and is licensed under the MIT license. For more information, see + * <http://www.doctrine-project.org>. + */ + +namespace Doctrine\Tests\Common\Annotations\Annotation; + +use Doctrine\Common\Annotations\Annotation\Target; + +/** + * Tests for {@see \Doctrine\Common\Annotations\Annotation\Target} + * + * @covers \Doctrine\Common\Annotations\Annotation\Target + */ +class TargetTest extends \PHPUnit_Framework_TestCase +{ + /** + * @group DDC-3006 + */ + public function testValidMixedTargets() + { + $target = new Target(array("value" => array("ALL"))); + $this->assertEquals(Target::TARGET_ALL, $target->targets); + + $target = new Target(array("value" => array("METHOD", "METHOD"))); + $this->assertEquals(Target::TARGET_METHOD, $target->targets); + $this->assertNotEquals(Target::TARGET_PROPERTY, $target->targets); + + $target = new Target(array("value" => array("PROPERTY", "METHOD"))); + $this->assertEquals(Target::TARGET_METHOD | Target::TARGET_PROPERTY, $target->targets); + } +} + diff --git a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php index d2cc6678d520..d6dd05638906 100644 --- a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php +++ b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/AnnotationReaderTest.php @@ -10,4 +10,50 @@ protected function getReader() { return new AnnotationReader(); } + + public function testMethodAnnotationFromTrait() + { + if (PHP_VERSION_ID < 50400) { + $this->markTestSkipped('This test requires PHP 5.4 or later.'); + } + + $reader = $this->getReader(); + $ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassUsesTrait'); + + $annotations = $reader->getMethodAnnotations($ref->getMethod('someMethod')); + $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Bar\Autoload', $annotations[0]); + + $annotations = $reader->getMethodAnnotations($ref->getMethod('traitMethod')); + $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload', $annotations[0]); + } + + public function testMethodAnnotationFromOverwrittenTrait() + { + if (PHP_VERSION_ID < 50400) { + $this->markTestSkipped('This test requires PHP 5.4 or later.'); + } + + $reader = $this->getReader(); + $ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassOverwritesTrait'); + + $annotations = $reader->getMethodAnnotations($ref->getMethod('traitMethod')); + $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Bar2\Autoload', $annotations[0]); + } + + public function testPropertyAnnotationFromTrait() + { + if (PHP_VERSION_ID < 50400) { + $this->markTestSkipped('This test requires PHP 5.4 or later.'); + } + + $reader = $this->getReader(); + $ref = new \ReflectionClass('Doctrine\Tests\Common\Annotations\Fixtures\ClassUsesTrait'); + + $annotations = $reader->getPropertyAnnotations($ref->getProperty('aProperty')); + $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Bar\Autoload', $annotations[0]); + + $annotations = $reader->getPropertyAnnotations($ref->getProperty('traitProperty')); + $this->assertInstanceOf('Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload', $annotations[0]); + } + } \ No newline at end of file diff --git a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php index 03a55c805404..844619d0d1f9 100644 --- a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php +++ b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/DocLexerTest.php @@ -28,7 +28,7 @@ public function testMarkerAnnotation() public function testScannerTokenizesDocBlockWhitConstants() { $lexer = new DocLexer(); - $docblock = '@AnnotationWithConstants(PHP_EOL, ClassWithConstants::SOME_VALUE, \Doctrine\Tests\Common\Annotations\Fixtures\IntefaceWithConstants::SOME_VALUE)'; + $docblock = '@AnnotationWithConstants(PHP_EOL, ClassWithConstants::SOME_VALUE, ClassWithConstants::CONSTANT_, ClassWithConstants::CONST_ANT3, \Doctrine\Tests\Common\Annotations\Fixtures\IntefaceWithConstants::SOME_VALUE)'; $tokens = array ( array( @@ -67,13 +67,33 @@ public function testScannerTokenizesDocBlockWhitConstants() 'type' => DocLexer::T_COMMA, ), array( - 'value' => '\\Doctrine\\Tests\\Common\\Annotations\\Fixtures\\IntefaceWithConstants::SOME_VALUE', + 'value' => 'ClassWithConstants::CONSTANT_', 'position' => 66, 'type' => DocLexer::T_IDENTIFIER, ), + array( + 'value' => ',', + 'position' => 95, + 'type' => DocLexer::T_COMMA, + ), + array( + 'value' => 'ClassWithConstants::CONST_ANT3', + 'position' => 97, + 'type' => DocLexer::T_IDENTIFIER, + ), + array( + 'value' => ',', + 'position' => 127, + 'type' => DocLexer::T_COMMA, + ), + array( + 'value' => '\\Doctrine\\Tests\\Common\\Annotations\\Fixtures\\IntefaceWithConstants::SOME_VALUE', + 'position' => 129, + 'type' => DocLexer::T_IDENTIFIER, + ), array( 'value' => ')', - 'position' => 143, + 'position' => 206, 'type' => DocLexer::T_CLOSE_PARENTHESIS, ) diff --git a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index 5b99787aea48..a7191d3a75c4 100644 --- a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -470,20 +470,26 @@ public function getAnnotationVarTypeArrayProviderInvalid() { //({attribute name}, {type declared type}, {attribute value} , {given type or class}) return array( - array('arrayOfIntegers','integer', 'true','boolean'), - array('arrayOfIntegers','integer', 'false','boolean'), - array('arrayOfIntegers','integer', '{true,true}','boolean'), - array('arrayOfIntegers','integer', '{1,true}','boolean'), - array('arrayOfIntegers','integer', '{1,2,1.2}','double'), - array('arrayOfIntegers','integer', '{1,2,"str"}','string'), - - - array('arrayOfAnnotations','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', 'true','boolean'), - array('arrayOfAnnotations','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', 'false','boolean'), - array('arrayOfAnnotations','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,true}','boolean'), - array('arrayOfAnnotations','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,true}','boolean'), - array('arrayOfAnnotations','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,1.2}','double'), - array('arrayOfAnnotations','Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,@AnnotationExtendsAnnotationTargetAll,"str"}','string'), + array('arrayOfIntegers', 'integer', 'true', 'boolean'), + array('arrayOfIntegers', 'integer', 'false', 'boolean'), + array('arrayOfIntegers', 'integer', '{true,true}', 'boolean'), + array('arrayOfIntegers', 'integer', '{1,true}', 'boolean'), + array('arrayOfIntegers', 'integer', '{1,2,1.2}', 'double'), + array('arrayOfIntegers', 'integer', '{1,2,"str"}', 'string'), + + array('arrayOfStrings', 'string', 'true', 'boolean'), + array('arrayOfStrings', 'string', 'false', 'boolean'), + array('arrayOfStrings', 'string', '{true,true}', 'boolean'), + array('arrayOfStrings', 'string', '{"foo",true}', 'boolean'), + array('arrayOfStrings', 'string', '{"foo","bar",1.2}', 'double'), + array('arrayOfStrings', 'string', '1', 'integer'), + + array('arrayOfAnnotations', 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', 'true', 'boolean'), + array('arrayOfAnnotations', 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', 'false', 'boolean'), + array('arrayOfAnnotations', 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,true}', 'boolean'), + array('arrayOfAnnotations', 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,true}', 'boolean'), + array('arrayOfAnnotations', 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,1.2}', 'double'), + array('arrayOfAnnotations', 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll', '{@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll,@AnnotationExtendsAnnotationTargetAll,"str"}', 'string'), ); } @@ -693,7 +699,7 @@ public function testAnnotationEnumeratorLiteralException() $parser->setTarget(Target::TARGET_PROPERTY); $parser->parse($docblock, $context); } - + /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage @Enum supports only scalar values "array" given. @@ -719,7 +725,7 @@ public function testAnnotationEnumInvalidLiteralDeclarationException() $parser->setIgnoreNotImportedAnnotations(false); $parser->parse($docblock); } - + public function getConstantsProvider() { $provider[] = array( @@ -742,6 +748,14 @@ public function getConstantsProvider() '@AnnotationWithConstants(ClassWithConstants::SOME_VALUE)', ClassWithConstants::SOME_VALUE ); + $provider[] = array( + '@AnnotationWithConstants(ClassWithConstants::OTHER_KEY_)', + ClassWithConstants::OTHER_KEY_ + ); + $provider[] = array( + '@AnnotationWithConstants(ClassWithConstants::OTHER_KEY_2)', + ClassWithConstants::OTHER_KEY_2 + ); $provider[] = array( '@AnnotationWithConstants(Doctrine\Tests\Common\Annotations\Fixtures\ClassWithConstants::SOME_VALUE)', ClassWithConstants::SOME_VALUE @@ -788,6 +802,22 @@ public function getConstantsProvider() ClassWithConstants::SOME_KEY => IntefaceWithConstants::SOME_VALUE ) ); + $provider[] = array( + '@AnnotationWithConstants(AnnotationWithConstants::class)', + 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants' + ); + $provider[] = array( + '@AnnotationWithConstants({AnnotationWithConstants::class = AnnotationWithConstants::class})', + array('Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants' => 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants') + ); + $provider[] = array( + '@AnnotationWithConstants(Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants::class)', + 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants' + ); + $provider[] = array( + '@Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants(Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants::class)', + 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants' + ); return $provider; } @@ -802,7 +832,7 @@ public function testSupportClassConstants($docblock, $expected) 'intefacewithconstants' => 'Doctrine\Tests\Common\Annotations\Fixtures\IntefaceWithConstants', 'annotationwithconstants' => 'Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants' )); - + $result = $parser->parse($docblock); $this->assertInstanceOf('\Doctrine\Tests\Common\Annotations\Fixtures\AnnotationWithConstants', $annotation = $result[0]); $this->assertEquals($expected, $annotation->value); @@ -942,6 +972,19 @@ public function testAnnotationWithoutClassIsIgnoredWithoutWarning() $this->assertEquals(0, count($result)); } + /** + * @group DCOM-168 + */ + public function testNotAnAnnotationClassIsIgnoredWithoutWarning() + { + $parser = new DocParser(); + $parser->setIgnoreNotImportedAnnotations(true); + $parser->setIgnoredAnnotationNames(array('PHPUnit_Framework_TestCase' => true)); + $result = $parser->parse('@PHPUnit_Framework_TestCase'); + + $this->assertEquals(0, count($result)); + } + /** * @expectedException \Doctrine\Common\Annotations\AnnotationException * @expectedExceptionMessage Expected PlainValue, got ''' at position 10. @@ -1209,6 +1252,26 @@ public function testEmptyArray() $this->assertEquals(1, count($annots)); $this->assertEquals(array('foo' => array()), $annots[0]->value); } + + public function testKeyHasNumber() + { + $parser = $this->createTestParser(); + $annots = $parser->parse('@SettingsAnnotation(foo="test", bar2="test")'); + + $this->assertEquals(1, count($annots)); + $this->assertEquals(array('foo' => 'test', 'bar2' => 'test'), $annots[0]->settings); + } +} + +/** @Annotation */ +class SettingsAnnotation +{ + public $settings; + + public function __construct($settings) + { + $this->settings = $settings; + } } /** @Annotation */ diff --git a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithAttributes.php b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithAttributes.php index def24d364f63..e3b5be7b7f79 100644 --- a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithAttributes.php +++ b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithAttributes.php @@ -14,6 +14,7 @@ @Attribute("integer", type = "integer"), @Attribute("array", type = "array"), @Attribute("arrayOfIntegers", type = "array<integer>"), + @Attribute("arrayOfStrings", type = "string[]"), @Attribute("annotation", type = "Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll"), @Attribute("arrayOfAnnotations", type = "array<Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll>"), }) @@ -37,6 +38,7 @@ public final function __construct(array $data) private $array; private $annotation; private $arrayOfIntegers; + private $arrayOfStrings; private $arrayOfAnnotations; /** @@ -100,6 +102,14 @@ public function getAnnotation() return $this->annotation; } + /** + * @return string[] + */ + public function getArrayOfStrings() + { + return $this->arrayOfIntegers; + } + /** * @return array<integer> */ diff --git a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithVarType.php b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithVarType.php index f8706003a0ae..dc1d6ddbf46b 100644 --- a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithVarType.php +++ b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/AnnotationWithVarType.php @@ -54,6 +54,11 @@ final class AnnotationWithVarType */ public $arrayOfIntegers; + /** + * @var string[] + */ + public $arrayOfStrings; + /** * @var array<Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetAll> */ diff --git a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassNoNamespaceNoComment.php b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassNoNamespaceNoComment.php new file mode 100644 index 000000000000..ca64c12d5e84 --- /dev/null +++ b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassNoNamespaceNoComment.php @@ -0,0 +1,7 @@ +<?php + +use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetClass; + +class Doctrine_Tests_Common_Annotations_Fixtures_ClassNoNamespaceNoComment { + +} \ No newline at end of file diff --git a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassOverwritesTrait.php b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassOverwritesTrait.php new file mode 100644 index 000000000000..8caa8ac156e1 --- /dev/null +++ b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassOverwritesTrait.php @@ -0,0 +1,25 @@ +<?php + +namespace Doctrine\Tests\Common\Annotations\Fixtures; + +use Doctrine\Tests\Common\Annotations\Bar2\Autoload; + +class ClassOverwritesTrait { + use TraitWithAnnotatedMethod; + + /** + * @Autoload + */ + public function traitMethod() + { + + } +} + + +namespace Doctrine\Tests\Common\Annotations\Bar2; + +/** @Annotation */ +class Autoload +{ +} diff --git a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassUsesTrait.php b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassUsesTrait.php new file mode 100644 index 000000000000..8797ac26b8cb --- /dev/null +++ b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassUsesTrait.php @@ -0,0 +1,30 @@ +<?php + +namespace Doctrine\Tests\Common\Annotations\Fixtures; + +use Doctrine\Tests\Common\Annotations\Bar\Autoload; + +class ClassUsesTrait { + use TraitWithAnnotatedMethod; + + /** + * @Autoload + */ + public $aProperty; + + /** + * @Autoload + */ + public function someMethod() + { + + } +} + + +namespace Doctrine\Tests\Common\Annotations\Bar; + +/** @Annotation */ +class Autoload +{ +} diff --git a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithAtInDescriptionAndAnnotation.php b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithAtInDescriptionAndAnnotation.php new file mode 100644 index 000000000000..5acc1b9a3af7 --- /dev/null +++ b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithAtInDescriptionAndAnnotation.php @@ -0,0 +1,34 @@ +<?php + +namespace Doctrine\Tests\Common\Annotations\Fixtures; + +use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetPropertyMethod; + +class ClassWithAtInDescriptionAndAnnotation +{ + /** + * Lala + * + * { + * "email": "foo@example.com", + * "email2": "123@example.com", + * "email3": "@example.com" + * } + * + * @AnnotationTargetPropertyMethod("Bar") + */ + public $foo; + + /** + * Lala + * + * { + * "email": "foo@example.com", + * "email2": "123@example.com", + * "email3": "@example.com" + * } + * + *@AnnotationTargetPropertyMethod("Bar") + */ + public $bar; +} diff --git a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithClassAnnotationOnly.php b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithClassAnnotationOnly.php new file mode 100644 index 000000000000..5d08b1d6230c --- /dev/null +++ b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithClassAnnotationOnly.php @@ -0,0 +1,13 @@ +<?php + +namespace Doctrine\Tests\Common\Annotations\Fixtures; + +use Doctrine\Tests\Common\Annotations\Fixtures\AnnotationTargetClass; + +/** + * @AnnotationTargetClass("Some data") + */ +class ClassWithClassAnnotationOnly +{ + +} \ No newline at end of file diff --git a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithConstants.php b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithConstants.php index 055e245c08af..719d68f6c5c5 100644 --- a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithConstants.php +++ b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithConstants.php @@ -4,7 +4,8 @@ class ClassWithConstants { - - const SOME_VALUE = 'ClassWithConstants.SOME_VALUE'; - const SOME_KEY = 'ClassWithConstants.SOME_KEY'; + const SOME_VALUE = 'ClassWithConstants.SOME_VALUE'; + const SOME_KEY = 'ClassWithConstants.SOME_KEY'; + const OTHER_KEY_ = 'ClassWithConstants.OTHER_KEY_'; + const OTHER_KEY_2 = 'ClassWithConstants.OTHER_KEY_2'; } \ No newline at end of file diff --git a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithIgnoreAnnotation.php b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithIgnoreAnnotation.php new file mode 100644 index 000000000000..a763d2ee6e40 --- /dev/null +++ b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithIgnoreAnnotation.php @@ -0,0 +1,14 @@ +<?php + +namespace Doctrine\Tests\Common\Annotations\Fixtures; + +/** + * @ignoreAnnotation("IgnoreAnnotationClass") + */ +class ClassWithIgnoreAnnotation +{ + /** + * @IgnoreAnnotationClass + */ + public $foo; +} diff --git a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/IgnoreAnnotationClass.php b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/IgnoreAnnotationClass.php new file mode 100644 index 000000000000..578589d4b43d --- /dev/null +++ b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/IgnoreAnnotationClass.php @@ -0,0 +1,7 @@ +<?php + +namespace Doctrine\Tests\Common\Annotations\Fixtures; + +class IgnoreAnnotationClass +{ +} diff --git a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/TraitWithAnnotatedMethod.php b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/TraitWithAnnotatedMethod.php new file mode 100644 index 000000000000..051957966f58 --- /dev/null +++ b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/Fixtures/TraitWithAnnotatedMethod.php @@ -0,0 +1,19 @@ +<?php +namespace Doctrine\Tests\Common\Annotations\Fixtures; + +use Doctrine\Tests\Common\Annotations\Fixtures\Annotation\Autoload; + +trait TraitWithAnnotatedMethod { + + /** + * @Autoload + */ + public $traitProperty; + + /** + * @Autoload + */ + public function traitMethod() + { + } +} diff --git a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php index c19eec29710a..51b932a617d7 100644 --- a/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php +++ b/core/vendor/doctrine/annotations/tests/Doctrine/Tests/Common/Annotations/SimpleAnnotationReaderTest.php @@ -68,6 +68,11 @@ public function testInvalidAnnotationUsageButIgnoredClass() parent::testInvalidAnnotationUsageButIgnoredClass(); } + public function testIncludeIgnoreAnnotation() + { + $this->markTestSkipped('The simplified annotation reader would always autoload annotations'); + } + /** * @group DDC-1660 * @group regression @@ -84,7 +89,7 @@ public function testInvalidAnnotationButIgnored() $this->assertCount(1, $reader->getMethodAnnotations($class->getMethod('bar'))); $this->assertCount(1, $reader->getPropertyAnnotations($class->getProperty('foo'))); } - + protected function getReader() { $reader = new SimpleAnnotationReader(); -- GitLab