From 5114dcee0b9940905a9f05b124191d385d3f2188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 23 Jun 2023 17:43:11 +0200 Subject: [PATCH 1/2] Work around slevomat/coding-standard issues I tweaked the code so that it would not fall victim to https://github.com/slevomat/coding-standard/issues/1585 or https://github.com/slevomat/coding-standard/issues/1586, thus fixing the phpcs job without losing information or breaking other jobs. --- lib/Doctrine/ORM/Configuration.php | 4 ++-- .../ORM/Internal/Hydration/ObjectHydrator.php | 1 - .../ORM/Query/Exec/AbstractSqlExecutor.php | 7 +++---- lib/Doctrine/ORM/Query/Parser.php | 3 ++- phpstan-baseline.neon | 15 --------------- .../Export/ClassMetadataExporterTestCase.php | 10 ++++++---- .../Tests/ORM/Tools/SchemaValidatorTest.php | 3 ++- 7 files changed, 15 insertions(+), 28 deletions(-) diff --git a/lib/Doctrine/ORM/Configuration.php b/lib/Doctrine/ORM/Configuration.php index aebd182d77..a8ad0d2712 100644 --- a/lib/Doctrine/ORM/Configuration.php +++ b/lib/Doctrine/ORM/Configuration.php @@ -208,10 +208,10 @@ public function newDefaultAnnotationDriver($paths = [], $useSimpleAnnotationRead } /** - * @deprecated No replacement planned. - * * Adds a namespace under a certain alias. * + * @deprecated No replacement planned. + * * @param string $alias * @param string $namespace * diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index c2fb4e99bc..74146dbf86 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -313,7 +313,6 @@ static function (string $fieldName) use ($data, $class) { * that belongs to a particular component/class. Afterwards, all these chunks * are processed, one after the other. For each chunk of class data only one of the * following code paths is executed: - * * Path A: The data chunk belongs to a joined/associated object and the association * is collection-valued. * Path B: The data chunk belongs to a joined/associated object and the association diff --git a/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php b/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php index 737d611a34..fc9660d1bb 100644 --- a/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php +++ b/lib/Doctrine/ORM/Query/Exec/AbstractSqlExecutor.php @@ -53,10 +53,9 @@ public function removeQueryCacheProfile() /** * Executes all sql statements. * - * @param Connection $conn The database connection that is used to execute the queries. - * @psalm-param list|array $params The parameters. - * @psalm-param array| - * array $types The parameter types. + * @param Connection $conn The database connection that is used to execute the queries. + * @param list|array $params The parameters. + * @param array|array $types The parameter types. * * @return Result|int */ diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index 318c21e9a1..4cfe233a1e 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -2566,7 +2566,8 @@ public function ConditionalPrimary() * EmptyCollectionComparisonExpression | CollectionMemberExpression | * InstanceOfExpression * - * @return AST\BetweenExpression| + * @return AST\Node + * @psalm-return AST\BetweenExpression| * AST\CollectionMemberExpression| * AST\ComparisonExpression| * AST\EmptyCollectionComparisonExpression| diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 4ed685ea39..42b40438d7 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -395,21 +395,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Query/Parser.php - - - message: """ - #^PHPDoc tag @return has invalid value \\(AST\\\\BetweenExpression\\| - AST\\\\CollectionMemberExpression\\| - AST\\\\ComparisonExpression\\| - AST\\\\EmptyCollectionComparisonExpression\\| - AST\\\\ExistsExpression\\| - AST\\\\InExpression\\| - AST\\\\InstanceOfExpression\\| - AST\\\\LikeExpression\\| - AST\\\\NullComparisonExpression\\)\\: Unexpected token "\\\\n \\* ", expected type at offset 344$# - """ - count: 1 - path: lib/Doctrine/ORM/Query/Parser.php - - message: "#^Parameter \\#2 \\$stringPattern of class Doctrine\\\\ORM\\\\Query\\\\AST\\\\LikeExpression constructor expects Doctrine\\\\ORM\\\\Query\\\\AST\\\\Functions\\\\FunctionNode\\|Doctrine\\\\ORM\\\\Query\\\\AST\\\\InputParameter\\|Doctrine\\\\ORM\\\\Query\\\\AST\\\\Literal\\|Doctrine\\\\ORM\\\\Query\\\\AST\\\\PathExpression, Doctrine\\\\ORM\\\\Query\\\\AST\\\\Node given\\.$#" count: 1 diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/ClassMetadataExporterTestCase.php b/tests/Doctrine/Tests/ORM/Tools/Export/ClassMetadataExporterTestCase.php index 8f1cad3c45..99bfa22b80 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Export/ClassMetadataExporterTestCase.php +++ b/tests/Doctrine/Tests/ORM/Tools/Export/ClassMetadataExporterTestCase.php @@ -15,6 +15,8 @@ use Doctrine\ORM\Mapping\Driver\AnnotationDriver; use Doctrine\ORM\Mapping\Driver\XmlDriver; use Doctrine\ORM\Mapping\Driver\YamlDriver; +use Doctrine\ORM\Mapping\PostPersist; +use Doctrine\ORM\Mapping\PrePersist; use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory; use Doctrine\ORM\Tools\EntityGenerator; use Doctrine\ORM\Tools\Export\ClassMetadataExporter; @@ -399,26 +401,26 @@ class Group } class UserListener { - /** @\Doctrine\ORM\Mapping\PrePersist */ + /** @PrePersist */ public function customPrePersist(): void { } - /** @\Doctrine\ORM\Mapping\PostPersist */ + /** @PostPersist */ public function customPostPersist(): void { } } class GroupListener { - /** @\Doctrine\ORM\Mapping\PrePersist */ + /** @PrePersist */ public function prePersist(): void { } } class AddressListener { - /** @\Doctrine\ORM\Mapping\PostPersist */ + /** @PostPersist */ public function customPostPersist(): void { } diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php index 3b1a9245bd..b4195d0e2e 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php @@ -384,7 +384,8 @@ class DDC1649Two { /** * @var DDC1649One - * @Id @ManyToOne(targetEntity="DDC1649One") + * @Id + * @ManyToOne(targetEntity="DDC1649One") */ public $one; } From 0e06d6b67d42bdbd39551f7fb97898d67cee30bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 23 Jun 2023 17:50:02 +0200 Subject: [PATCH 2/2] Apply latest coding standard rules --- tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php index f66cb82bfe..5790a54ad1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5804Test.php @@ -103,7 +103,7 @@ class GH5804Article * @Id * @Column(type="GH5804Type", length=255) * @GeneratedValue(strategy="CUSTOM") - * @CustomIdGenerator(class=\Doctrine\Tests\ORM\Functional\Ticket\GH5804Generator::class) + * @CustomIdGenerator(class=GH5804Generator::class) */ public $id;