Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 1.13.x into 1.14.x #458

Merged
merged 10 commits into from Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion .github/workflows/composer-lint.yml
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions .github/workflows/continuous-integration.yml
Expand Up @@ -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"]'
2 changes: 1 addition & 1 deletion .github/workflows/release-on-milestone-closed.yml
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Expand Up @@ -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"
6 changes: 6 additions & 0 deletions 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)
Expand Down
11 changes: 7 additions & 4 deletions composer.json
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion docs/en/custom.rst
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions docs/en/index.rst
@@ -1,3 +1,12 @@
Deprecation notice
==================

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.

Introduction
============

Expand Down
4 changes: 1 addition & 3 deletions lib/Doctrine/Common/Annotations/Annotation.php
Expand Up @@ -18,9 +18,7 @@ class Annotation
*/
public $value;

/**
* @param array<string, mixed> $data Key-value for properties to be defined in this class.
*/
/** @param array<string, mixed> $data Key-value for properties to be defined in this class. */
final public function __construct(array $data)
{
foreach ($data as $key => $value) {
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/Common/Annotations/Annotation/Enum.php
Expand Up @@ -34,9 +34,9 @@ final class Enum
public $literal;

/**
* @throws InvalidArgumentException
*
* @phpstan-param array{literal?: mixed[], value: list<scalar>} $values
*
* @throws InvalidArgumentException
*/
public function __construct(array $values)
{
Expand Down
Expand Up @@ -21,9 +21,9 @@ final class IgnoreAnnotation
public $names;

/**
* @throws RuntimeException
*
* @phpstan-param array{value: string|list<string>} $values
*
* @throws RuntimeException
*/
public function __construct(array $values)
{
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/Common/Annotations/Annotation/Target.php
Expand Up @@ -56,9 +56,9 @@ final class Target
public $literal;

/**
* @throws InvalidArgumentException
*
* @phpstan-param array{value?: string|list<string>} $values
*
* @throws InvalidArgumentException
*/
public function __construct(array $values)
{
Expand Down
11 changes: 3 additions & 8 deletions lib/Doctrine/Common/Annotations/AnnotationException.php
Expand Up @@ -133,10 +133,9 @@ public static function requiredError($attributeName, $annotationName, $context,
* @param string $annotationName
* @param string $context
* @param mixed $given
* @phpstan-param list<string> $available
*
* @return AnnotationException
*
* @phpstan-param list<string> $available
*/
public static function enumeratorError($attributeName, $annotationName, $context, $available, $given)
{
Expand All @@ -150,19 +149,15 @@ public static function enumeratorError($attributeName, $annotationName, $context
));
}

/**
* @return AnnotationException
*/
/** @return AnnotationException */
public static function optimizerPlusSaveComments()
{
return new self(
'You have to enable opcache.save_comments=1 or zend_optimizerplus.save_comments=1.'
);
}

/**
* @return AnnotationException
*/
/** @return AnnotationException */
public static function optimizerPlusLoadComments()
{
return new self(
Expand Down
4 changes: 1 addition & 3 deletions lib/Doctrine/Common/Annotations/CachedReader.php
Expand Up @@ -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;
Expand Down
20 changes: 9 additions & 11 deletions lib/Doctrine/Common/Annotations/DocParser.php
Expand Up @@ -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<object> Array of annotations. If no annotations are found, an empty array is returned.
*
* @throws AnnotationException
* @throws ReflectionException
*
* @phpstan-return list<object> Array of annotations. If no annotations are found, an empty array is returned.
*/
public function parse($input, $context = '')
{
Expand Down Expand Up @@ -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<mixed[]> $tokens
*
* @throws AnnotationException
*/
private function matchAny(array $tokens): bool
{
Expand Down Expand Up @@ -674,10 +674,10 @@ private function collectAttributeTypeMetadata(array &$metadata, Attribute $attri
/**
* Annotations ::= Annotation {[ "*" ]* [Annotation]}*
*
* @phpstan-return list<object>
*
* @throws AnnotationException
* @throws ReflectionException
*
* @phpstan-return list<object>
*/
private function Annotations(): array
{
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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
{
Expand Down
4 changes: 1 addition & 3 deletions lib/Doctrine/Common/Annotations/TokenParser.php
Expand Up @@ -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);
Expand Down
17 changes: 7 additions & 10 deletions phpcs.xml.dist
Expand Up @@ -12,6 +12,8 @@
<!-- Show progress of the run and show sniff names -->
<arg value="ps"/>

<config name="php_version" value="70100"/>

<file>lib</file>
<file>tests</file>

Expand Down Expand Up @@ -105,16 +107,6 @@
<exclude-pattern>*/tests/Doctrine/Tests/Common/Annotations/Fixtures/ClassWithRequire.php</exclude-pattern>
</rule>

<!-- these classes have unused properties, and is unused in a benchmark for the parser -->
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedProperty">
<exclude-pattern>*/tests/Doctrine/Tests/Common/Annotations/Fixtures/SingleClassLOC1000.php</exclude-pattern>
<exclude-pattern>*/tests/Doctrine/Tests/Common/Annotations/Fixtures/NamespacedSingleClassLOC1000.php</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedMethod">
<exclude-pattern>*/tests/Doctrine/Tests/Common/Annotations/Fixtures/Controller.php</exclude-pattern>
</rule>

<!-- these classes do not have a namespace on purpose -->
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
<exclude-pattern>*/tests/Doctrine/Tests/Common/Annotations/Fixtures/SingleClassLOC1000.php</exclude-pattern>
Expand Down Expand Up @@ -156,4 +148,9 @@
<rule ref="Squiz.Functions.GlobalFunction.Found">
<exclude-pattern>*/tests/Doctrine/Tests/Common/Annotations/Fixtures/functions.php</exclude-pattern>
</rule>

<!-- Single-line PHPDoc blocks will confuse PHPUnit 7.5 -->
<rule ref="SlevomatCodingStandard.Commenting.RequireOneLineDocComment.MultiLineDocComment">
<exclude-pattern>*/tests</exclude-pattern>
</rule>
</ruleset>