From 140192e82572921a007e7dd5ced2805b9fad3dd1 Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo <1102197+priyadi@users.noreply.github.com> Date: Wed, 13 Nov 2024 16:39:20 +0700 Subject: [PATCH] chore: rector run (#255) --- CHANGELOG.md | 4 ++++ src/MapperFactory.php | 8 ++------ .../ObjectProcessor/DefaultObjectProcessorFactory.php | 1 + .../Processor/ObjectProcessor/ObjectProcessor.php | 1 + tests/src/Common/FrameworkTestCase.php | 1 + .../ObjectWithConstructorAndSetter.php | 6 +++--- .../ObjectWithConstructorArgumentsAndGetters.php | 6 +++--- .../ObjectWithIdOnlyOnConstructor.php | 3 ++- .../src/Fixtures/ConstructorAndProperty/SourceObject.php | 2 ++ .../Fixtures/LazyObject/ObjectWithIdInConstructorDto.php | 1 + tests/src/Fixtures/NullSource/TargetString.php | 2 +- tests/src/Fixtures/NullSource/TargetUuid.php | 2 +- tests/src/Fixtures/ObjectMapper/MoneyDto.php | 2 ++ tests/src/Fixtures/ObjectMapper/MoneyDtoToo.php | 2 ++ tests/src/Services/Issue232/BigDecimalTransformer.php | 2 ++ tests/src/Services/Issue232/CurrencyTransformer.php | 2 ++ tests/src/Services/TestLogger.php | 1 + 17 files changed, 31 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f45813..717cd2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 1.13.6 + +* chore: rector run + ## 1.13.5 * fix: infinite loop in `MapperFactory` diff --git a/src/MapperFactory.php b/src/MapperFactory.php index 320928b..04d0837 100644 --- a/src/MapperFactory.php +++ b/src/MapperFactory.php @@ -215,8 +215,6 @@ class MapperFactory private ?Application $application = null; - private LoggerInterface $logger; - /** * @param array $additionalTransformers */ @@ -227,10 +225,8 @@ public function __construct( private readonly ?NormalizerInterface $normalizer = null, private readonly ?DenormalizerInterface $denormalizer = null, private readonly CacheItemPoolInterface $propertyInfoExtractorCache = new ArrayAdapter(), - ?LoggerInterface $logger = null, - ) { - $this->logger = $logger ?? new NullLogger(); - } + private readonly LoggerInterface $logger = new NullLogger() + ) {} /** * @param class-string $sourceClass diff --git a/src/Transformer/Processor/ObjectProcessor/DefaultObjectProcessorFactory.php b/src/Transformer/Processor/ObjectProcessor/DefaultObjectProcessorFactory.php index 9a805ef..16dd20f 100644 --- a/src/Transformer/Processor/ObjectProcessor/DefaultObjectProcessorFactory.php +++ b/src/Transformer/Processor/ObjectProcessor/DefaultObjectProcessorFactory.php @@ -38,6 +38,7 @@ public function __construct( private readonly LoggerInterface $logger, ) {} + #[\Override] public function getObjectProcessor( ObjectToObjectMetadata $metadata, ): ObjectProcessorInterface { diff --git a/src/Transformer/Processor/ObjectProcessor/ObjectProcessor.php b/src/Transformer/Processor/ObjectProcessor/ObjectProcessor.php index 950eed9..ed369c9 100644 --- a/src/Transformer/Processor/ObjectProcessor/ObjectProcessor.php +++ b/src/Transformer/Processor/ObjectProcessor/ObjectProcessor.php @@ -60,6 +60,7 @@ public function __construct( private LoggerInterface $logger, ) {} + #[\Override] public function transform( object $source, ?object $target, diff --git a/tests/src/Common/FrameworkTestCase.php b/tests/src/Common/FrameworkTestCase.php index 2750bd3..5e331b3 100644 --- a/tests/src/Common/FrameworkTestCase.php +++ b/tests/src/Common/FrameworkTestCase.php @@ -68,6 +68,7 @@ public function get(string $serviceId): object return $result; } + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/src/Fixtures/ConstructorAndProperty/ObjectWithConstructorAndSetter.php b/tests/src/Fixtures/ConstructorAndProperty/ObjectWithConstructorAndSetter.php index e90f829..12df228 100644 --- a/tests/src/Fixtures/ConstructorAndProperty/ObjectWithConstructorAndSetter.php +++ b/tests/src/Fixtures/ConstructorAndProperty/ObjectWithConstructorAndSetter.php @@ -16,9 +16,9 @@ class ObjectWithConstructorAndSetter { public function __construct( - private string $id, - private string $name, - private string $description, + private readonly string $id, + private readonly string $name, + private readonly string $description, ) {} public function setId(string $id): void diff --git a/tests/src/Fixtures/ConstructorAndProperty/ObjectWithConstructorArgumentsAndGetters.php b/tests/src/Fixtures/ConstructorAndProperty/ObjectWithConstructorArgumentsAndGetters.php index d42feb9..3f1957a 100644 --- a/tests/src/Fixtures/ConstructorAndProperty/ObjectWithConstructorArgumentsAndGetters.php +++ b/tests/src/Fixtures/ConstructorAndProperty/ObjectWithConstructorArgumentsAndGetters.php @@ -16,9 +16,9 @@ class ObjectWithConstructorArgumentsAndGetters { public function __construct( - private string $id, - private string $name, - private string $description, + private readonly string $id, + private readonly string $name, + private readonly string $description, ) {} public function getId(): string diff --git a/tests/src/Fixtures/ConstructorAndProperty/ObjectWithIdOnlyOnConstructor.php b/tests/src/Fixtures/ConstructorAndProperty/ObjectWithIdOnlyOnConstructor.php index 1ac5b43..2873d2b 100644 --- a/tests/src/Fixtures/ConstructorAndProperty/ObjectWithIdOnlyOnConstructor.php +++ b/tests/src/Fixtures/ConstructorAndProperty/ObjectWithIdOnlyOnConstructor.php @@ -16,10 +16,11 @@ class ObjectWithIdOnlyOnConstructor { public function __construct( - private string $id, + private readonly string $id, ) {} private string $name = ''; + private string $description = ''; public function getId(): string diff --git a/tests/src/Fixtures/ConstructorAndProperty/SourceObject.php b/tests/src/Fixtures/ConstructorAndProperty/SourceObject.php index 43c497a..ebd242c 100644 --- a/tests/src/Fixtures/ConstructorAndProperty/SourceObject.php +++ b/tests/src/Fixtures/ConstructorAndProperty/SourceObject.php @@ -16,6 +16,8 @@ class SourceObject { public string $id = 'id'; + public string $name = 'name'; + public string $description = 'description'; } diff --git a/tests/src/Fixtures/LazyObject/ObjectWithIdInConstructorDto.php b/tests/src/Fixtures/LazyObject/ObjectWithIdInConstructorDto.php index 01ae342..2df03d1 100644 --- a/tests/src/Fixtures/LazyObject/ObjectWithIdInConstructorDto.php +++ b/tests/src/Fixtures/LazyObject/ObjectWithIdInConstructorDto.php @@ -20,5 +20,6 @@ public function __construct( ) {} public ?string $name = null; + public ?string $other = null; } diff --git a/tests/src/Fixtures/NullSource/TargetString.php b/tests/src/Fixtures/NullSource/TargetString.php index b7588bb..13e2dca 100644 --- a/tests/src/Fixtures/NullSource/TargetString.php +++ b/tests/src/Fixtures/NullSource/TargetString.php @@ -17,7 +17,7 @@ class TargetString { - private string $property; + private readonly string $property; public function __construct() { diff --git a/tests/src/Fixtures/NullSource/TargetUuid.php b/tests/src/Fixtures/NullSource/TargetUuid.php index a5c0842..cb6050c 100644 --- a/tests/src/Fixtures/NullSource/TargetUuid.php +++ b/tests/src/Fixtures/NullSource/TargetUuid.php @@ -17,7 +17,7 @@ class TargetUuid { - private Uuid $property; + private readonly Uuid $property; public function __construct() { diff --git a/tests/src/Fixtures/ObjectMapper/MoneyDto.php b/tests/src/Fixtures/ObjectMapper/MoneyDto.php index 47172e3..bac93f2 100644 --- a/tests/src/Fixtures/ObjectMapper/MoneyDto.php +++ b/tests/src/Fixtures/ObjectMapper/MoneyDto.php @@ -20,11 +20,13 @@ public function __construct( private string $currency, ) {} + #[\Override] public function getAmount(): string { return $this->amount; } + #[\Override] public function getCurrency(): string { return $this->currency; diff --git a/tests/src/Fixtures/ObjectMapper/MoneyDtoToo.php b/tests/src/Fixtures/ObjectMapper/MoneyDtoToo.php index 220064d..78cad5d 100644 --- a/tests/src/Fixtures/ObjectMapper/MoneyDtoToo.php +++ b/tests/src/Fixtures/ObjectMapper/MoneyDtoToo.php @@ -20,11 +20,13 @@ public function __construct( private string $currency, ) {} + #[\Override] public function getAmount(): string { return $this->amount; } + #[\Override] public function getCurrency(): string { return $this->currency; diff --git a/tests/src/Services/Issue232/BigDecimalTransformer.php b/tests/src/Services/Issue232/BigDecimalTransformer.php index 262d6ad..bcee5b0 100644 --- a/tests/src/Services/Issue232/BigDecimalTransformer.php +++ b/tests/src/Services/Issue232/BigDecimalTransformer.php @@ -22,6 +22,7 @@ final readonly class BigDecimalTransformer implements TransformerInterface { + #[\Override] public function transform( mixed $source, mixed $target, @@ -40,6 +41,7 @@ public function transform( return BigDecimal::of($source)->toBigDecimal(); } + #[\Override] public function getSupportedTransformation(): iterable { yield new TypeMapping( diff --git a/tests/src/Services/Issue232/CurrencyTransformer.php b/tests/src/Services/Issue232/CurrencyTransformer.php index f9689c6..30d9246 100644 --- a/tests/src/Services/Issue232/CurrencyTransformer.php +++ b/tests/src/Services/Issue232/CurrencyTransformer.php @@ -22,6 +22,7 @@ final readonly class CurrencyTransformer implements TransformerInterface { + #[\Override] public function transform( mixed $source, mixed $target, @@ -36,6 +37,7 @@ public function transform( return Currency::of($source); } + #[\Override] public function getSupportedTransformation(): iterable { yield new TypeMapping( diff --git a/tests/src/Services/TestLogger.php b/tests/src/Services/TestLogger.php index 51dd379..20e14c8 100644 --- a/tests/src/Services/TestLogger.php +++ b/tests/src/Services/TestLogger.php @@ -31,6 +31,7 @@ public function __construct( private readonly LoggerInterface $logger, ) {} + #[\Override] public function reset(): void { $this->messages = [];