diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 3ae99378a..83fd68b5e 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -12,4 +12,4 @@ on: jobs: coding-standards: name: "Coding Standards" - uses: "doctrine/.github/.github/workflows/coding-standards.yml@1.5.1" + uses: "doctrine/.github/.github/workflows/coding-standards.yml@2.1.0" diff --git a/.github/workflows/composer-lint.yml b/.github/workflows/composer-lint.yml index ae17b7af3..091b491c3 100644 --- a/.github/workflows/composer-lint.yml +++ b/.github/workflows/composer-lint.yml @@ -15,4 +15,4 @@ on: jobs: composer-lint: name: "Composer Lint" - uses: "doctrine/.github/.github/workflows/composer-lint.yml@1.5.1" + uses: "doctrine/.github/.github/workflows/composer-lint.yml@2.1.0" diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index ac5f75bb6..f160d3efb 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -14,6 +14,6 @@ env: jobs: phpunit: name: "PHPUnit" - uses: "doctrine/.github/.github/workflows/continuous-integration.yml@1.5.1" + uses: "doctrine/.github/.github/workflows/continuous-integration.yml@2.1.0" with: - php-versions: '["7.1", "7.2", "7.3", "7.4", "8.0"]' + php-versions: '["7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2"]' diff --git a/.github/workflows/release-on-milestone-closed.yml b/.github/workflows/release-on-milestone-closed.yml index d32d76ef7..949de8201 100644 --- a/.github/workflows/release-on-milestone-closed.yml +++ b/.github/workflows/release-on-milestone-closed.yml @@ -8,7 +8,7 @@ on: jobs: release: name: "Git tag, release & create merge-up PR" - uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@1.5.1" + uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@2.1.0" secrets: GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }} GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }} diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 4150ff29b..0adc3d08e 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -12,4 +12,4 @@ on: jobs: static-analysis: name: "Static Analysis" - uses: "doctrine/.github/.github/workflows/static-analysis.yml@1.5.1" + uses: "doctrine/.github/.github/workflows/static-analysis.yml@2.1.0" diff --git a/README.md b/README.md index c2c7eb7ba..6b8c0359b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +⚠️ PHP 8 introduced +[attributes](https://www.php.net/manual/en/language.attributes.overview.php), +which are a native replacement for annotations. As such, this library is +considered feature complete, and should receive exclusively bugfixes and +security fixes. + # Doctrine Annotations [![Build Status](https://github.com/doctrine/annotations/workflows/Continuous%20Integration/badge.svg?label=build)](https://github.com/doctrine/persistence/actions) diff --git a/composer.json b/composer.json index b4dfbd390..47971b5cc 100644 --- a/composer.json +++ b/composer.json @@ -39,12 +39,15 @@ }, "require-dev": { "doctrine/cache": "^1.11 || ^2.0", - "doctrine/coding-standard": "^6.0 || ^8.1", - "phpstan/phpstan": "^1.4.10 || ^1.8.0", - "phpunit/phpunit": "^7.5 || ^8.0 || ^9.1.5", - "symfony/cache": "^4.4 || ^5.2", + "doctrine/coding-standard": "^9 || ^10", + "phpstan/phpstan": "~1.4.10 || ^1.8.0", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "symfony/cache": "^4.4 || ^5.4 || ^6", "vimeo/psalm": "^4.10" }, + "suggest": { + "php": "PHP 8.0 or higher comes with attributes, a native replacement for annotations" + }, "autoload": { "psr-4": { "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" diff --git a/docs/en/custom.rst b/docs/en/custom.rst index 11fbe1a31..e8f79af71 100644 --- a/docs/en/custom.rst +++ b/docs/en/custom.rst @@ -69,7 +69,7 @@ When using the ``@NamedArgumentConstructor`` tag, the first argument of the constructor is considered as the default one. -Usage with the ``@NamedArgumentContrustor`` tag +Usage with the ``@NamedArgumentConstructor`` tag .. code-block:: php diff --git a/docs/en/index.rst b/docs/en/index.rst index 95476c313..7caffb50a 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -1,3 +1,12 @@ +Deprecation notice +================== + +PHP 8 introduced `attributes +`_, +which are a native replacement for annotations. As such, this library is +considered feature complete, and should receive exclusively bugfixes and +security fixes. + Introduction ============ diff --git a/lib/Doctrine/Common/Annotations/Annotation.php b/lib/Doctrine/Common/Annotations/Annotation.php index 750270e42..9cae3dacd 100644 --- a/lib/Doctrine/Common/Annotations/Annotation.php +++ b/lib/Doctrine/Common/Annotations/Annotation.php @@ -18,9 +18,7 @@ class Annotation */ public $value; - /** - * @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. */ final public function __construct(array $data) { foreach ($data as $key => $value) { diff --git a/lib/Doctrine/Common/Annotations/Annotation/Enum.php b/lib/Doctrine/Common/Annotations/Annotation/Enum.php index 35d6410b1..6f24d9f1b 100644 --- a/lib/Doctrine/Common/Annotations/Annotation/Enum.php +++ b/lib/Doctrine/Common/Annotations/Annotation/Enum.php @@ -34,9 +34,9 @@ final class Enum public $literal; /** - * @throws InvalidArgumentException - * * @phpstan-param array{literal?: mixed[], value: list} $values + * + * @throws InvalidArgumentException */ public function __construct(array $values) { diff --git a/lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php b/lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php index ae60f7d5b..97a15c257 100644 --- a/lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php +++ b/lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php @@ -21,9 +21,9 @@ final class IgnoreAnnotation public $names; /** - * @throws RuntimeException - * * @phpstan-param array{value: string|list} $values + * + * @throws RuntimeException */ public function __construct(array $values) { diff --git a/lib/Doctrine/Common/Annotations/Annotation/Target.php b/lib/Doctrine/Common/Annotations/Annotation/Target.php index 7fd75e2bb..ba1d489ac 100644 --- a/lib/Doctrine/Common/Annotations/Annotation/Target.php +++ b/lib/Doctrine/Common/Annotations/Annotation/Target.php @@ -56,9 +56,9 @@ final class Target public $literal; /** - * @throws InvalidArgumentException - * * @phpstan-param array{value?: string|list} $values + * + * @throws InvalidArgumentException */ public function __construct(array $values) { diff --git a/lib/Doctrine/Common/Annotations/AnnotationException.php b/lib/Doctrine/Common/Annotations/AnnotationException.php index 4d91825e5..dcdfe4df6 100644 --- a/lib/Doctrine/Common/Annotations/AnnotationException.php +++ b/lib/Doctrine/Common/Annotations/AnnotationException.php @@ -133,10 +133,9 @@ public static function requiredError($attributeName, $annotationName, $context, * @param string $annotationName * @param string $context * @param mixed $given + * @phpstan-param list $available * * @return AnnotationException - * - * @phpstan-param list $available */ public static function enumeratorError($attributeName, $annotationName, $context, $available, $given) { @@ -150,9 +149,7 @@ public static function enumeratorError($attributeName, $annotationName, $context )); } - /** - * @return AnnotationException - */ + /** @return AnnotationException */ public static function optimizerPlusSaveComments() { return new self( @@ -160,9 +157,7 @@ public static function optimizerPlusSaveComments() ); } - /** - * @return AnnotationException - */ + /** @return AnnotationException */ public static function optimizerPlusLoadComments() { return new self( diff --git a/lib/Doctrine/Common/Annotations/CachedReader.php b/lib/Doctrine/Common/Annotations/CachedReader.php index c036b2dab..85dbefab5 100644 --- a/lib/Doctrine/Common/Annotations/CachedReader.php +++ b/lib/Doctrine/Common/Annotations/CachedReader.php @@ -38,9 +38,7 @@ final class CachedReader implements Reader /** @var int[] */ private $loadedFilemtimes = []; - /** - * @param bool $debug - */ + /** @param bool $debug */ public function __construct(Reader $reader, Cache $cache, $debug = false) { $this->delegate = $reader; diff --git a/lib/Doctrine/Common/Annotations/DocParser.php b/lib/Doctrine/Common/Annotations/DocParser.php index 80f307cab..4133fe5f4 100644 --- a/lib/Doctrine/Common/Annotations/DocParser.php +++ b/lib/Doctrine/Common/Annotations/DocParser.php @@ -357,10 +357,10 @@ public function setTarget($target) * @param string $input The docblock string to parse. * @param string $context The parsing context. * + * @phpstan-return list Array of annotations. If no annotations are found, an empty array is returned. + * * @throws AnnotationException * @throws ReflectionException - * - * @phpstan-return list Array of annotations. If no annotations are found, an empty array is returned. */ public function parse($input, $context = '') { @@ -426,9 +426,9 @@ private function match(int $token): bool * If any of them matches, this method updates the lookahead token; otherwise * a syntax error is raised. * - * @throws AnnotationException - * * @phpstan-param list $tokens + * + * @throws AnnotationException */ private function matchAny(array $tokens): bool { @@ -674,10 +674,10 @@ private function collectAttributeTypeMetadata(array &$metadata, Attribute $attri /** * Annotations ::= Annotation {[ "*" ]* [Annotation]}* * + * @phpstan-return list + * * @throws AnnotationException * @throws ReflectionException - * - * @phpstan-return list */ private function Annotations(): array { @@ -1166,9 +1166,7 @@ private function identifierEndsWithClassConstant(string $identifier): bool return $this->getClassConstantPositionInIdentifier($identifier) === strlen($identifier) - strlen('::class'); } - /** - * @return int|false - */ + /** @return int|false */ private function getClassConstantPositionInIdentifier(string $identifier) { return stripos($identifier, '::class'); @@ -1357,10 +1355,10 @@ private function Arrayx(): array * KeyValuePair ::= Key ("=" | ":") PlainValue | Constant * Key ::= string | integer | Constant * + * @phpstan-return array{mixed, mixed} + * * @throws AnnotationException * @throws ReflectionException - * - * @phpstan-return array{mixed, mixed} */ private function ArrayEntry(): array { diff --git a/lib/Doctrine/Common/Annotations/TokenParser.php b/lib/Doctrine/Common/Annotations/TokenParser.php index 9605fb8dd..69259fccf 100644 --- a/lib/Doctrine/Common/Annotations/TokenParser.php +++ b/lib/Doctrine/Common/Annotations/TokenParser.php @@ -46,9 +46,7 @@ class TokenParser */ private $pointer = 0; - /** - * @param string $contents - */ + /** @param string $contents */ public function __construct($contents) { $this->tokens = token_get_all($contents); diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 038d03b00..eeadabad2 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -12,6 +12,8 @@ + + lib tests @@ -105,16 +107,6 @@ */tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithRequire.php - - - */tests/Doctrine/Tests/Common/Annotations/Fixtures/SingleClassLOC1000.php - */tests/Doctrine/Tests/Common/Annotations/Fixtures/NamespacedSingleClassLOC1000.php - - - - */tests/Doctrine/Tests/Common/Annotations/Fixtures/Controller.php - - */tests/Doctrine/Tests/Common/Annotations/Fixtures/SingleClassLOC1000.php @@ -156,4 +148,9 @@ */tests/Doctrine/Tests/Common/Annotations/Fixtures/functions.php + + + + */tests + diff --git a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php index 5e6f35cb2..297d7e90c 100644 --- a/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php +++ b/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php @@ -130,7 +130,7 @@ public function testBasicAnnotations(): void self::assertEquals('value2', $annot->value[1]['key2']); // Complete docblock - $docblock = <<setIgnoreNotImportedAnnotations(true); - $docblock = <<createTestParser(); - $docblock = <<createTestParser(); - $docblock = <<data); self::assertEquals($annot->data, 'Some data'); - $docblock = <<name, 'Some Name'); self::assertEquals($annot->data, 'Some data'); - $docblock = <<data, 'Some data'); self::assertNull($annot->name); - $docblock = <<name, 'Some name'); self::assertNull($annot->data); - $docblock = <<data, 'Some data'); self::assertNull($annot->name); - $docblock = <<name, 'Some name'); self::assertEquals($annot->data, 'Some data'); - $docblock = <<name, 'Some name'); self::assertEquals($annot->data, 'Some data'); - $docblock = <<createTestParser(); - $docblock = <<createTestParser(); - $docblock = <<createTestParser(); $context = 'class SomeClassName'; - $docblock = <<createTestParser(); $context = 'class SomeClassName'; - $docblock = <<createTestParser(); $context = 'class SomeClassName'; - $docblock = <<createTestParser(); - $docblock = <<markTestSkipped('This test requires mbstring function overloading is turned on'); } - $docblock = <<