From c2ce6104d3f7f15434f947aa6842e0bccb0d9964 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 22 Jun 2021 17:31:33 +0200 Subject: [PATCH] remove extra parma in value object --- config/set/downgrade-php80.php | 2 +- .../Class_/DowngradeAttributeToAnnotationRector.php | 5 +---- .../ValueObject/DowngradeAttributeToAnnotation.php | 8 ++++++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/config/set/downgrade-php80.php b/config/set/downgrade-php80.php index ed96ca63c11..7eda432b654 100644 --- a/config/set/downgrade-php80.php +++ b/config/set/downgrade-php80.php @@ -38,7 +38,7 @@ $services->set(DowngradeAttributeToAnnotationRector::class) ->call('configure', [[ DowngradeAttributeToAnnotationRector::ATTRIBUTE_TO_ANNOTATION => ValueObjectInliner::inline([ - new DowngradeAttributeToAnnotation('Attribute', 'Attribute'), + new DowngradeAttributeToAnnotation('Attribute'), ]), ]]); diff --git a/rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php b/rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php index 6d3de094879..cc6a60080ed 100644 --- a/rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php +++ b/rules/DowngradePhp80/Rector/Class_/DowngradeAttributeToAnnotationRector.php @@ -73,10 +73,7 @@ public function action() , [ self::ATTRIBUTE_TO_ANNOTATION => [ - new DowngradeAttributeToAnnotation( - 'Symfony\Component\Routing\Annotation\Route', - 'Symfony\Component\Routing\Annotation\Route' - ), + new DowngradeAttributeToAnnotation('Symfony\Component\Routing\Annotation\Route'), ], ] ), diff --git a/rules/DowngradePhp80/ValueObject/DowngradeAttributeToAnnotation.php b/rules/DowngradePhp80/ValueObject/DowngradeAttributeToAnnotation.php index fa25600c96e..f2a9b19c483 100644 --- a/rules/DowngradePhp80/ValueObject/DowngradeAttributeToAnnotation.php +++ b/rules/DowngradePhp80/ValueObject/DowngradeAttributeToAnnotation.php @@ -8,11 +8,11 @@ final class DowngradeAttributeToAnnotation { /** * @param class-string $attributeClass - * @param class-string|string $tag + * @param class-string|string|null $tag */ public function __construct( private string $attributeClass, - private string $tag + private ?string $tag = null ) { } @@ -23,6 +23,10 @@ public function getAttributeClass(): string public function getTag(): string { + if ($this->tag === null) { + return $this->attributeClass; + } + return $this->tag; } }