diff --git a/castor.php b/castor.php index 08b1b0c1..c31ffe21 100644 --- a/castor.php +++ b/castor.php @@ -10,7 +10,7 @@ #[AsTask('cs:check', namespace: 'qa', description: 'Check for coding standards without fixing them')] function qa_cs_check() { - php_cs_fixer(['fix', '--config', __DIR__ . '/.php-cs-fixer.php', '--dry-run', '--diff'], '3.50', [ + php_cs_fixer(['fix', '--config', __DIR__ . '/.php-cs-fixer.php', '--dry-run', '--diff'], '3.85.1', [ 'kubawerlos/php-cs-fixer-custom-fixers' => '^3.21', ]); } @@ -18,7 +18,7 @@ function qa_cs_check() #[AsTask('cs:fix', namespace: 'qa', description: 'Fix all coding standards', aliases: ['cs'])] function qa_cs_fix() { - php_cs_fixer(['fix', '--config', __DIR__ . '/.php-cs-fixer.php', '-v'], '3.50', [ + php_cs_fixer(['fix', '--config', __DIR__ . '/.php-cs-fixer.php', '-v'], '3.85.1', [ 'kubawerlos/php-cs-fixer-custom-fixers' => '^3.21', ]); } diff --git a/src/EventListener/MapFromListener.php b/src/EventListener/MapFromListener.php index 782e5a09..073e9b0f 100644 --- a/src/EventListener/MapFromListener.php +++ b/src/EventListener/MapFromListener.php @@ -39,11 +39,11 @@ public function __invoke(GenerateMapperEvent $event): void if ($reflectionClassOrPropertyOrMethod instanceof \ReflectionClass) { if ($mapFromAttributeInstance->property === null) { - throw new BadMapDefinitionException(sprintf('Required `property` property in the "%s" attribute on "%s" class.', MapFrom::class, $reflectionClassOrPropertyOrMethod->getName())); + throw new BadMapDefinitionException(\sprintf('Required `property` property in the "%s" attribute on "%s" class.', MapFrom::class, $reflectionClassOrPropertyOrMethod->getName())); } if ($mapFromAttributeInstance->transformer === null) { - throw new BadMapDefinitionException(sprintf('Required `transformer` property in the "%s" attribute on "%s" class.', MapFrom::class, $reflectionClassOrPropertyOrMethod->getName())); + throw new BadMapDefinitionException(\sprintf('Required `transformer` property in the "%s" attribute on "%s" class.', MapFrom::class, $reflectionClassOrPropertyOrMethod->getName())); } $property = $mapFromAttributeInstance->property; diff --git a/src/EventListener/MapListener.php b/src/EventListener/MapListener.php index f1600610..87d4d0c6 100644 --- a/src/EventListener/MapListener.php +++ b/src/EventListener/MapListener.php @@ -62,12 +62,12 @@ protected function getTransformerFromMapAttribute(string $class, MapTo|MapFrom $ try { $expression = $this->expressionLanguage->compile($transformerCallable, ['value' => 'source', 'context']); } catch (SyntaxError $e) { - throw new BadMapDefinitionException(sprintf('Transformer "%s" targeted by %s transformer on class "%s" is not valid.', $transformerCallable, $attribute::class, $class), 0, $e); + throw new BadMapDefinitionException(\sprintf('Transformer "%s" targeted by %s transformer on class "%s" is not valid.', $transformerCallable, $attribute::class, $class), 0, $e); } $transformer = new ExpressionLanguageTransformer($expression); } else { - throw new BadMapDefinitionException(sprintf('Callable "%s" targeted by %s transformer on class "%s" is not valid.', json_encode($transformerCallable), $attribute::class, $class)); + throw new BadMapDefinitionException(\sprintf('Callable "%s" targeted by %s transformer on class "%s" is not valid.', json_encode($transformerCallable), $attribute::class, $class)); } } diff --git a/src/EventListener/MapProviderListener.php b/src/EventListener/MapProviderListener.php index d6b27b16..8065d72e 100644 --- a/src/EventListener/MapProviderListener.php +++ b/src/EventListener/MapProviderListener.php @@ -38,13 +38,13 @@ public function __invoke(GenerateMapperEvent $event): void if ($mapProvider->source === null) { if ($defaultMapProvider !== null) { - throw new BadMapDefinitionException(sprintf('multiple default providers found for class "%s"', $event->mapperMetadata->targetReflectionClass->getName())); + throw new BadMapDefinitionException(\sprintf('multiple default providers found for class "%s"', $event->mapperMetadata->targetReflectionClass->getName())); } $defaultMapProvider = $mapProvider->provider; } elseif ($mapProvider->source === $event->mapperMetadata->source) { if ($provider !== null) { - throw new BadMapDefinitionException(sprintf('multiple providers found for class "%s"', $event->mapperMetadata->targetReflectionClass->getName())); + throw new BadMapDefinitionException(\sprintf('multiple providers found for class "%s"', $event->mapperMetadata->targetReflectionClass->getName())); } $provider = $mapProvider->provider; diff --git a/src/EventListener/MapToContextListener.php b/src/EventListener/MapToContextListener.php index 205d17d5..2aad9904 100644 --- a/src/EventListener/MapToContextListener.php +++ b/src/EventListener/MapToContextListener.php @@ -16,7 +16,7 @@ final readonly class MapToContextListener { public function __construct( - private ReflectionExtractor $extractor + private ReflectionExtractor $extractor, ) { } diff --git a/src/EventListener/MapToListener.php b/src/EventListener/MapToListener.php index 0a436d1f..affaeb2f 100644 --- a/src/EventListener/MapToListener.php +++ b/src/EventListener/MapToListener.php @@ -38,11 +38,11 @@ public function __invoke(GenerateMapperEvent $event): void if ($reflectionClassOrPropertyOrMethod instanceof \ReflectionClass) { if ($mapToAttributeInstance->property === null) { - throw new BadMapDefinitionException(sprintf('Required `property` property in the "%s" attribute on "%s" class.', MapTo::class, $reflectionClassOrPropertyOrMethod->getName())); + throw new BadMapDefinitionException(\sprintf('Required `property` property in the "%s" attribute on "%s" class.', MapTo::class, $reflectionClassOrPropertyOrMethod->getName())); } if ($mapToAttributeInstance->transformer === null) { - throw new BadMapDefinitionException(sprintf('Required `transformer` property in the "%s" attribute on "%s" class.', MapTo::class, $reflectionClassOrPropertyOrMethod->getName())); + throw new BadMapDefinitionException(\sprintf('Required `transformer` property in the "%s" attribute on "%s" class.', MapTo::class, $reflectionClassOrPropertyOrMethod->getName())); } $property = $mapToAttributeInstance->property; diff --git a/src/EventListener/Symfony/AdvancedNameConverterListener.php b/src/EventListener/Symfony/AdvancedNameConverterListener.php index 5d22819b..c5d6dce2 100644 --- a/src/EventListener/Symfony/AdvancedNameConverterListener.php +++ b/src/EventListener/Symfony/AdvancedNameConverterListener.php @@ -11,7 +11,7 @@ final readonly class AdvancedNameConverterListener { public function __construct( - private AdvancedNameConverterInterface|NameConverterInterface $nameConverter + private AdvancedNameConverterInterface|NameConverterInterface $nameConverter, ) { } diff --git a/src/EventListener/Symfony/SerializerGroupListener.php b/src/EventListener/Symfony/SerializerGroupListener.php index 74b5e33d..94a69907 100644 --- a/src/EventListener/Symfony/SerializerGroupListener.php +++ b/src/EventListener/Symfony/SerializerGroupListener.php @@ -10,7 +10,7 @@ final readonly class SerializerGroupListener { public function __construct( - private ClassMetadataFactoryInterface $classMetadataFactory + private ClassMetadataFactoryInterface $classMetadataFactory, ) { } diff --git a/src/EventListener/Symfony/SerializerIgnoreListener.php b/src/EventListener/Symfony/SerializerIgnoreListener.php index 414a2ad3..d641e33f 100644 --- a/src/EventListener/Symfony/SerializerIgnoreListener.php +++ b/src/EventListener/Symfony/SerializerIgnoreListener.php @@ -10,7 +10,7 @@ final readonly class SerializerIgnoreListener { public function __construct( - private ClassMetadataFactoryInterface $classMetadataFactory + private ClassMetadataFactoryInterface $classMetadataFactory, ) { } diff --git a/src/EventListener/Symfony/SerializerMaxDepthListener.php b/src/EventListener/Symfony/SerializerMaxDepthListener.php index e850898e..24569438 100644 --- a/src/EventListener/Symfony/SerializerMaxDepthListener.php +++ b/src/EventListener/Symfony/SerializerMaxDepthListener.php @@ -10,7 +10,7 @@ final readonly class SerializerMaxDepthListener { public function __construct( - private ClassMetadataFactoryInterface $classMetadataFactory + private ClassMetadataFactoryInterface $classMetadataFactory, ) { } diff --git a/src/Exception/ReadOnlyTargetException.php b/src/Exception/ReadOnlyTargetException.php index 69fc8eb4..f5b2e699 100644 --- a/src/Exception/ReadOnlyTargetException.php +++ b/src/Exception/ReadOnlyTargetException.php @@ -13,6 +13,6 @@ final class ReadOnlyTargetException extends RuntimeException { public function __construct(int $code = 0, ?\Throwable $previous = null) { - parent::__construct(sprintf('Cannot use readonly class as an object to populate. You can opt-out this behavior by using the context "%s"', MapperContext::ALLOW_READONLY_TARGET_TO_POPULATE), $code, $previous); + parent::__construct(\sprintf('Cannot use readonly class as an object to populate. You can opt-out this behavior by using the context "%s"', MapperContext::ALLOW_READONLY_TARGET_TO_POPULATE), $code, $previous); } } diff --git a/src/Generator/CreateTargetStatementsGenerator.php b/src/Generator/CreateTargetStatementsGenerator.php index 1a5da7ed..b250ff00 100644 --- a/src/Generator/CreateTargetStatementsGenerator.php +++ b/src/Generator/CreateTargetStatementsGenerator.php @@ -204,7 +204,7 @@ private function constructorArgument(Expr\ArrayDimFetch $assignVar, GeneratorMet $defaultValueExpr = new Expr\ConstFetch(new Name('null')); } else { $defaultValueExpr = new Expr\Throw_(new Expr\New_(new Name\FullyQualified(MissingConstructorArgumentsException::class), [ - new Arg(new Scalar\String_(sprintf('Cannot create an instance of "%s" from mapping data because its constructor requires the following parameters to be present : "$%s".', $metadata->mapperMetadata->target, $propertyMetadata->target->property))), + new Arg(new Scalar\String_(\sprintf('Cannot create an instance of "%s" from mapping data because its constructor requires the following parameters to be present : "$%s".', $metadata->mapperMetadata->target, $propertyMetadata->target->property))), new Arg(create_scalar_int(0)), new Arg(new Expr\ConstFetch(new Name('null'))), new Arg(new Expr\Array_([ @@ -296,7 +296,7 @@ private function constructorArgumentWithoutSource(Expr\ArrayDimFetch $assignVar, $defaultValueExpr = new Expr\ConstFetch(new Name('null')); } else { $defaultValueExpr = new Expr\Throw_(new Expr\New_(new Name\FullyQualified(MissingConstructorArgumentsException::class), [ - new Arg(new Scalar\String_(sprintf('Cannot create an instance of "%s" from mapping data because its constructor requires the following parameters to be present : "$%s".', $metadata->mapperMetadata->target, $constructorParameter->getName()))), + new Arg(new Scalar\String_(\sprintf('Cannot create an instance of "%s" from mapping data because its constructor requires the following parameters to be present : "$%s".', $metadata->mapperMetadata->target, $constructorParameter->getName()))), new Arg(create_scalar_int(0)), new Arg(new Expr\ConstFetch(new Name('null'))), new Arg(new Expr\Array_([ diff --git a/src/Generator/MapMethodStatementsGenerator.php b/src/Generator/MapMethodStatementsGenerator.php index cd6297d6..e287d63a 100644 --- a/src/Generator/MapMethodStatementsGenerator.php +++ b/src/Generator/MapMethodStatementsGenerator.php @@ -244,7 +244,7 @@ private function initializeTargetToPopulate(GeneratorMetadata $metadata): array $variableRegistry->getResult(), new Expr\BinaryOp\Coalesce($targetToPopulate, new Expr\ConstFetch(new Name('null'))) ), - ['comments' => [new Comment(sprintf('/** @var %s|null $result */', $metadata->mapperMetadata->target === 'array' ? $metadata->mapperMetadata->target : '\\' . $metadata->mapperMetadata->target))]] + ['comments' => [new Comment(\sprintf('/** @var %s|null $result */', $metadata->mapperMetadata->target === 'array' ? $metadata->mapperMetadata->target : '\\' . $metadata->mapperMetadata->target))]] ); if (!$metadata->allowReadOnlyTargetToPopulate && $metadata->isTargetReadOnlyClass()) { diff --git a/src/Generator/MapperGenerator.php b/src/Generator/MapperGenerator.php index 33b3eee7..cc4b9a61 100644 --- a/src/Generator/MapperGenerator.php +++ b/src/Generator/MapperGenerator.php @@ -140,7 +140,7 @@ private function mapMethod(GeneratorMetadata $metadata): Stmt\ClassMethod ->addParam(new Param($metadata->variableRegistry->getContext(), default: new Expr\Array_(), type: new Name('array'))) ->addStmts($this->mapMethodStatementsGenerator->getStatements($metadata)) ->setDocComment( - sprintf( + \sprintf( '/** @param %s $%s */', $metadata->mapperMetadata->source === 'array' ? $metadata->mapperMetadata->source : '\\' . $metadata->mapperMetadata->source, 'value' diff --git a/src/Generator/PropertyStatementsGenerator.php b/src/Generator/PropertyStatementsGenerator.php index 1d315087..c053ae76 100644 --- a/src/Generator/PropertyStatementsGenerator.php +++ b/src/Generator/PropertyStatementsGenerator.php @@ -19,7 +19,7 @@ final readonly class PropertyStatementsGenerator { public function __construct( - private PropertyConditionsGenerator $propertyConditionsGenerator + private PropertyConditionsGenerator $propertyConditionsGenerator, ) { } diff --git a/src/Loader/FileLoader.php b/src/Loader/FileLoader.php index 331f19ad..afd4eb15 100644 --- a/src/Loader/FileLoader.php +++ b/src/Loader/FileLoader.php @@ -140,7 +140,7 @@ private function write(string $file, string $contents): void $fp = fopen($file, 'w'); if (false === $fp) { - throw new CompileException(sprintf('Could not open file "%s"', $file)); + throw new CompileException(\sprintf('Could not open file "%s"', $file)); } if (flock($fp, LOCK_EX)) { diff --git a/src/MapperContext.php b/src/MapperContext.php index e36c949b..0b02d337 100644 --- a/src/MapperContext.php +++ b/src/MapperContext.php @@ -199,7 +199,7 @@ public static function &handleCircularReference(array &$context, string $referen if (null !== $circularReferenceLimit) { if ($circularReferenceLimit <= ($context[self::CIRCULAR_COUNT_REFERENCE_REGISTRY][$reference] ?? 0)) { - throw new CircularReferenceException(sprintf('A circular reference has been detected when mapping the object of type "%s" (configured limit: %d).', \is_object($object) ? $object::class : 'array', $circularReferenceLimit)); + throw new CircularReferenceException(\sprintf('A circular reference has been detected when mapping the object of type "%s" (configured limit: %d).', \is_object($object) ? $object::class : 'array', $circularReferenceLimit)); } $context[self::CIRCULAR_COUNT_REFERENCE_REGISTRY][$reference] ??= 0; @@ -210,7 +210,7 @@ public static function &handleCircularReference(array &$context, string $referen $context[self::CIRCULAR_REFERENCE_REGISTRY] ??= []; if (!\array_key_exists($reference, $context[self::CIRCULAR_REFERENCE_REGISTRY])) { - throw new CircularReferenceException(sprintf('Circular reference detected for reference "%s" but no object found in the registry.', $reference)); + throw new CircularReferenceException(\sprintf('Circular reference detected for reference "%s" but no object found in the registry.', $reference)); } // When no limit defined return the object referenced diff --git a/src/Metadata/MapperMetadata.php b/src/Metadata/MapperMetadata.php index 019b6b85..52932b7c 100644 --- a/src/Metadata/MapperMetadata.php +++ b/src/Metadata/MapperMetadata.php @@ -43,7 +43,7 @@ public function __construct( } /** @var class-string $className */ - $className = sprintf('%s%s_%s', $this->classPrefix, str_replace('\\', '_', $this->source), str_replace('\\', '_', $this->target)); + $className = \sprintf('%s%s_%s', $this->classPrefix, str_replace('\\', '_', $this->source), str_replace('\\', '_', $this->target)); $this->className = $className; } diff --git a/src/Provider/ApiPlatform/IriProvider.php b/src/Provider/ApiPlatform/IriProvider.php index 2a2496e0..db1c62e4 100644 --- a/src/Provider/ApiPlatform/IriProvider.php +++ b/src/Provider/ApiPlatform/IriProvider.php @@ -16,7 +16,7 @@ { public function __construct( private LegacyIriConverterInterface|IriConverterInterface $iriConverter, - private LegacyResourceClassResolverInterface|ResourceClassResolverInterface $resourceClassResolver + private LegacyResourceClassResolverInterface|ResourceClassResolverInterface $resourceClassResolver, ) { } diff --git a/src/Provider/EarlyReturn.php b/src/Provider/EarlyReturn.php index 68d22e23..627a1715 100644 --- a/src/Provider/EarlyReturn.php +++ b/src/Provider/EarlyReturn.php @@ -13,7 +13,7 @@ final class EarlyReturn * @param object|array|null $value */ public function __construct( - public object|array|null $value + public object|array|null $value, ) { } } diff --git a/src/Provider/ProviderRegistry.php b/src/Provider/ProviderRegistry.php index 274d0db1..447720d2 100644 --- a/src/Provider/ProviderRegistry.php +++ b/src/Provider/ProviderRegistry.php @@ -36,7 +36,7 @@ public function __construct(iterable $providers) public function getProvider(string $id): ProviderInterface { if (!\array_key_exists($id, $this->providers)) { - throw new InvalidArgumentException(sprintf('Provider with id "%s" not found.', $id)); + throw new InvalidArgumentException(\sprintf('Provider with id "%s" not found.', $id)); } return $this->providers[$id]; diff --git a/src/Symfony/Bundle/CacheWarmup/CacheWarmer.php b/src/Symfony/Bundle/CacheWarmup/CacheWarmer.php index 14108430..2785b7e9 100644 --- a/src/Symfony/Bundle/CacheWarmup/CacheWarmer.php +++ b/src/Symfony/Bundle/CacheWarmup/CacheWarmer.php @@ -18,7 +18,7 @@ public function __construct( private readonly MetadataRegistry $mapping, private readonly MetadataFactory $metadataFactory, private readonly ClassLoaderInterface $classLoader, - private readonly string $autoMapperCacheDirectory + private readonly string $autoMapperCacheDirectory, ) { } @@ -43,7 +43,7 @@ public function warmUp(string $cacheDir, ?string $buildDir = null): array return array_map( function ($mapperMetadata) { - return sprintf('%s/%s.php', $this->autoMapperCacheDirectory, $mapperMetadata->className); + return \sprintf('%s/%s.php', $this->autoMapperCacheDirectory, $mapperMetadata->className); }, iterator_to_array($mapping), ); diff --git a/src/Symfony/Bundle/Command/DebugMapperCommand.php b/src/Symfony/Bundle/Command/DebugMapperCommand.php index c6f933b7..9a0ee51b 100644 --- a/src/Symfony/Bundle/Command/DebugMapperCommand.php +++ b/src/Symfony/Bundle/Command/DebugMapperCommand.php @@ -16,7 +16,7 @@ final class DebugMapperCommand extends Command { public function __construct( - private readonly MetadataFactory $metadataFactory + private readonly MetadataFactory $metadataFactory, ) { parent::__construct('debug:mapper'); } @@ -72,7 +72,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $style->section('Used Properties:'); $style->table( - [sprintf('%s -> %s', $source, $target), 'If', 'Transformer', 'Groups', 'MaxDepth'], + [\sprintf('%s -> %s', $source, $target), 'If', 'Transformer', 'Groups', 'MaxDepth'], array_map( fn (PropertyMetadata $property) => [ $property->source->property . ' -> ' . $property->target->property, @@ -88,7 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $style->section('Not Used Properties:'); $style->table( - [sprintf('%s -> %s', $source, $target), 'Not used reason'], + [\sprintf('%s -> %s', $source, $target), 'Not used reason'], array_map( fn (PropertyMetadata $property) => [ $property->source->property . ' -> ' . $property->target->property, diff --git a/src/Symfony/ExpressionLanguageProvider.php b/src/Symfony/ExpressionLanguageProvider.php index f16156fd..bbce7a2e 100644 --- a/src/Symfony/ExpressionLanguageProvider.php +++ b/src/Symfony/ExpressionLanguageProvider.php @@ -17,7 +17,7 @@ * @param ServiceProviderInterface<\Closure> $functions */ public function __construct( - private ServiceProviderInterface $functions + private ServiceProviderInterface $functions, ) { } @@ -28,7 +28,7 @@ public function getFunctions(): array foreach ($this->functions->getProvidedServices() as $function => $type) { $functions[] = new ExpressionFunction( $function, - static fn (...$args) => sprintf('($this->expressionLanguageProvider->get(%s)(%s))', var_export($function, true), implode(', ', $args)), + static fn (...$args) => \sprintf('($this->expressionLanguageProvider->get(%s)(%s))', var_export($function, true), implode(', ', $args)), fn ($values, ...$args) => $this->get($function)(...$args) ); } diff --git a/src/Transformer/ApiPlatform/JsonLdIdTransformer.php b/src/Transformer/ApiPlatform/JsonLdIdTransformer.php index 4f81ab23..27402893 100644 --- a/src/Transformer/ApiPlatform/JsonLdIdTransformer.php +++ b/src/Transformer/ApiPlatform/JsonLdIdTransformer.php @@ -11,7 +11,7 @@ final readonly class JsonLdIdTransformer implements PropertyTransformerInterface { public function __construct( - private LegacyIriConverterInterface|IriConverterInterface $iriConverter + private LegacyIriConverterInterface|IriConverterInterface $iriConverter, ) { } diff --git a/src/Transformer/ChainTransformerFactory.php b/src/Transformer/ChainTransformerFactory.php index 84dee5c3..ed5514d7 100644 --- a/src/Transformer/ChainTransformerFactory.php +++ b/src/Transformer/ChainTransformerFactory.php @@ -20,7 +20,7 @@ final class ChainTransformerFactory implements TransformerFactoryInterface * @param array $factories */ public function __construct( - private array $factories = [] + private array $factories = [], ) { foreach ($this->factories as $factory) { if ($factory instanceof ChainTransformerFactoryAwareInterface) { diff --git a/tests/AutoMapperTest.php b/tests/AutoMapperTest.php index 37cc4b15..c0c5a57f 100644 --- a/tests/AutoMapperTest.php +++ b/tests/AutoMapperTest.php @@ -622,7 +622,7 @@ public function testIgnoredAttributes(): void public function testNameConverter(): void { if (Kernel::MAJOR_VERSION >= 7 && Kernel::MINOR_VERSION >= 2) { - $nameConverter = new class() implements NameConverterInterface { + $nameConverter = new class implements NameConverterInterface { public function normalize($propertyName, ?string $class = null, ?string $format = null, array $context = []): string { if ('id' === $propertyName) { @@ -642,7 +642,7 @@ public function denormalize($propertyName, ?string $class = null, ?string $forma } }; } else { - $nameConverter = new class() implements AdvancedNameConverterInterface { + $nameConverter = new class implements AdvancedNameConverterInterface { public function normalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string { if ('id' === $propertyName) { @@ -1345,11 +1345,11 @@ public function testAutoMapperFixtures(string $mapFile, string $directory): void try { $targets = require $mapFile; } catch (\Throwable $e) { - throw new \LogicException(sprintf('Unable to load map file "%s".', $mapFile), 0, $e); + throw new \LogicException(\sprintf('Unable to load map file "%s".', $mapFile), 0, $e); } if (1 === $targets) { - throw new \LogicException(sprintf('The map file "%s" does not return a value.', $mapFile)); + throw new \LogicException(\sprintf('The map file "%s" does not return a value.', $mapFile)); } if (!$targets instanceof \Generator) { @@ -1360,9 +1360,9 @@ public function testAutoMapperFixtures(string $mapFile, string $directory): void $dump = $this->getDump($target); if (0 === $key) { - $expectedFile = sprintf('%s/expected.data', $directory); + $expectedFile = \sprintf('%s/expected.data', $directory); } else { - $expectedFile = sprintf('%s/expected.%s.data', $directory, $key); + $expectedFile = \sprintf('%s/expected.%s.data', $directory, $key); } if ($_SERVER['UPDATE_FIXTURES'] ?? false) { @@ -1370,12 +1370,12 @@ public function testAutoMapperFixtures(string $mapFile, string $directory): void } if (!file_exists($expectedFile)) { - throw new \LogicException(sprintf('The expected file "%s" does not exist.', $expectedFile)); + throw new \LogicException(\sprintf('The expected file "%s" does not exist.', $expectedFile)); } $expected = trim(file_get_contents($expectedFile)); - $this->assertSame($expected, $dump, sprintf('The dump of the map file "%s" is not as expected.', $key)); + $this->assertSame($expected, $dump, \sprintf('The dump of the map file "%s" is not as expected.', $key)); } } @@ -1404,7 +1404,7 @@ public static function provideAutoMapperFixturesTests(): iterable $mapFile = $directory->getRealPath() . '/map.php'; if (!file_exists($mapFile)) { - throw new \LogicException(sprintf('The map file "%s" does not exist.', $mapFile)); + throw new \LogicException(\sprintf('The map file "%s" does not exist.', $mapFile)); } yield $directory->getBasename() => [$mapFile, $directory->getRealPath()]; diff --git a/tests/AutoMapperTest/BuiltinClass/map.php b/tests/AutoMapperTest/BuiltinClass/map.php index 97158256..930f481c 100644 --- a/tests/AutoMapperTest/BuiltinClass/map.php +++ b/tests/AutoMapperTest/BuiltinClass/map.php @@ -9,7 +9,7 @@ class BuiltinClass { public function __construct( - public \DateInterval $dateInterval + public \DateInterval $dateInterval, ) { } } diff --git a/tests/AutoMapperTest/ConstructorPropertyPromoted/map.php b/tests/AutoMapperTest/ConstructorPropertyPromoted/map.php index c8c61e1a..f390d8bf 100644 --- a/tests/AutoMapperTest/ConstructorPropertyPromoted/map.php +++ b/tests/AutoMapperTest/ConstructorPropertyPromoted/map.php @@ -20,7 +20,7 @@ class AddressDTO * @param array $addresses */ public function __construct( - public array $addresses + public array $addresses, ) { } } diff --git a/tests/AutoMapperTest/ConstructorWithSerializedName/map.php b/tests/AutoMapperTest/ConstructorWithSerializedName/map.php index 531214d8..5f978eba 100644 --- a/tests/AutoMapperTest/ConstructorWithSerializedName/map.php +++ b/tests/AutoMapperTest/ConstructorWithSerializedName/map.php @@ -11,7 +11,7 @@ { public function __construct( #[SerializedName('is_static')] - public bool $isStatic + public bool $isStatic, ) { } } diff --git a/tests/AutoMapperTest/DifferentSetterGetterType/map.php b/tests/AutoMapperTest/DifferentSetterGetterType/map.php index 6f70013c..2e0617ff 100644 --- a/tests/AutoMapperTest/DifferentSetterGetterType/map.php +++ b/tests/AutoMapperTest/DifferentSetterGetterType/map.php @@ -17,7 +17,7 @@ class DifferentSetterGetterType private AddressType $addressDocBlock; public function __construct( - private AddressType $address + private AddressType $address, ) { $this->addressDocBlock = $address; } diff --git a/tests/AutoMapperTest/DoctrineCollections/map.php b/tests/AutoMapperTest/DoctrineCollections/map.php index a1ee9abd..6eba093d 100644 --- a/tests/AutoMapperTest/DoctrineCollections/map.php +++ b/tests/AutoMapperTest/DoctrineCollections/map.php @@ -11,7 +11,7 @@ class Book { public function __construct( - public string $name + public string $name, ) { } } diff --git a/tests/AutoMapperTest/Issue111/map.php b/tests/AutoMapperTest/Issue111/map.php index 5f7285de..60ff7ad5 100644 --- a/tests/AutoMapperTest/Issue111/map.php +++ b/tests/AutoMapperTest/Issue111/map.php @@ -17,7 +17,7 @@ class FooDto class Colour { public function __construct( - public string $name + public string $name, ) { } } diff --git a/tests/AutoMapperTest/Issue284/map.php b/tests/AutoMapperTest/Issue284/map.php index 96daceff..c3265185 100644 --- a/tests/AutoMapperTest/Issue284/map.php +++ b/tests/AutoMapperTest/Issue284/map.php @@ -9,7 +9,7 @@ abstract readonly class Fruit { public function __construct( - public int $weight + public int $weight, ) { } } diff --git a/tests/AutoMapperTest/Provider/map.php b/tests/AutoMapperTest/Provider/map.php index 7d4a7ed2..d91ac8cf 100644 --- a/tests/AutoMapperTest/Provider/map.php +++ b/tests/AutoMapperTest/Provider/map.php @@ -12,7 +12,7 @@ final readonly class CustomProvider implements ProviderInterface { public function __construct( - private object|array|null $value + private object|array|null $value, ) { } diff --git a/tests/AutoMapperTest/UnionProperty/map.php b/tests/AutoMapperTest/UnionProperty/map.php index 4c3c2034..42faa8c9 100644 --- a/tests/AutoMapperTest/UnionProperty/map.php +++ b/tests/AutoMapperTest/UnionProperty/map.php @@ -9,7 +9,7 @@ final readonly class Bar { public function __construct( - public string $bar + public string $bar, ) { } } @@ -17,7 +17,7 @@ public function __construct( final readonly class Foo { public function __construct( - public string $foo + public string $foo, ) { } } @@ -25,7 +25,7 @@ public function __construct( final readonly class ObjectsUnionProperty { public function __construct( - public Foo|Bar $prop + public Foo|Bar $prop, ) { } } diff --git a/tests/Bundle/Resources/App/AppKernel.php b/tests/Bundle/Resources/App/AppKernel.php index 980fec0c..14607255 100644 --- a/tests/Bundle/Resources/App/AppKernel.php +++ b/tests/Bundle/Resources/App/AppKernel.php @@ -15,7 +15,7 @@ class AppKernel extends Kernel public function __construct( string $environment, bool $debug, - private ?string $additionalConfigFile = null + private ?string $additionalConfigFile = null, ) { parent::__construct($environment, $debug); } diff --git a/tests/Bundle/Resources/App/Controller/HomeController.php b/tests/Bundle/Resources/App/Controller/HomeController.php index 993cb823..7a186cdf 100644 --- a/tests/Bundle/Resources/App/Controller/HomeController.php +++ b/tests/Bundle/Resources/App/Controller/HomeController.php @@ -19,7 +19,7 @@ class HomeController extends AbstractController public function __construct( private AutoMapperInterface $autoMapper, #[Autowire('@serializer.normalizer.object')] - private NormalizerInterface $serializer + private NormalizerInterface $serializer, ) { } diff --git a/tests/Bundle/Resources/App/Entity/ClassWithPrivateProperty.php b/tests/Bundle/Resources/App/Entity/ClassWithPrivateProperty.php index 57bd7266..119ad15d 100644 --- a/tests/Bundle/Resources/App/Entity/ClassWithPrivateProperty.php +++ b/tests/Bundle/Resources/App/Entity/ClassWithPrivateProperty.php @@ -7,7 +7,7 @@ class ClassWithPrivateProperty { public function __construct( - private string $foo + private string $foo, ) { } diff --git a/tests/Bundle/Resources/App/Entity/FooMapTo.php b/tests/Bundle/Resources/App/Entity/FooMapTo.php index a84a9814..a25afbfe 100644 --- a/tests/Bundle/Resources/App/Entity/FooMapTo.php +++ b/tests/Bundle/Resources/App/Entity/FooMapTo.php @@ -17,7 +17,7 @@ public function __construct( #[MapTo('array', property: 'transformFromStringInstance', transformer: 'transformFromStringInstance')] #[MapTo('array', property: 'transformFromStringStatic', transformer: 'transformFromStringStatic')] #[MapTo('array', property: 'transformFromExpressionLanguage', transformer: "source.foo === 'foo' ? 'transformed' : 'not transformed'")] - public string $foo + public string $foo, ) { } diff --git a/tests/Fixtures/AddressDTOReadonlyClass.php b/tests/Fixtures/AddressDTOReadonlyClass.php index bc1e9984..f697cb6b 100644 --- a/tests/Fixtures/AddressDTOReadonlyClass.php +++ b/tests/Fixtures/AddressDTOReadonlyClass.php @@ -7,7 +7,7 @@ readonly class AddressDTOReadonlyClass { public function __construct( - public string $city + public string $city, ) { } } diff --git a/tests/Fixtures/AddressDTOSecondReadonlyClass.php b/tests/Fixtures/AddressDTOSecondReadonlyClass.php index 9ee7b2b5..cdff1929 100644 --- a/tests/Fixtures/AddressDTOSecondReadonlyClass.php +++ b/tests/Fixtures/AddressDTOSecondReadonlyClass.php @@ -8,7 +8,7 @@ { public function __construct( public string $city, - public string $postalCode + public string $postalCode, ) { } } diff --git a/tests/Fixtures/AddressDTOWithReadonlyPromotedProperty.php b/tests/Fixtures/AddressDTOWithReadonlyPromotedProperty.php index 8ab29878..897dfb4f 100644 --- a/tests/Fixtures/AddressDTOWithReadonlyPromotedProperty.php +++ b/tests/Fixtures/AddressDTOWithReadonlyPromotedProperty.php @@ -7,7 +7,7 @@ final class AddressDTOWithReadonlyPromotedProperty { public function __construct( - public readonly string $city + public readonly string $city, ) { } } diff --git a/tests/Fixtures/Category.php b/tests/Fixtures/Category.php index fa54138f..939ebefe 100644 --- a/tests/Fixtures/Category.php +++ b/tests/Fixtures/Category.php @@ -10,7 +10,7 @@ class Category public array $posts = []; public function __construct( - public string $name + public string $name, ) { } } diff --git a/tests/Fixtures/ClassWithNullablePropertyInConstructor.php b/tests/Fixtures/ClassWithNullablePropertyInConstructor.php index 0647c9ba..62ee16bc 100644 --- a/tests/Fixtures/ClassWithNullablePropertyInConstructor.php +++ b/tests/Fixtures/ClassWithNullablePropertyInConstructor.php @@ -8,7 +8,7 @@ { public function __construct( public int $foo, - public ?int $bar = null + public ?int $bar = null, ) { } } diff --git a/tests/Fixtures/ClassWithPrivateProperty.php b/tests/Fixtures/ClassWithPrivateProperty.php index 2ec43e22..c74c03ad 100644 --- a/tests/Fixtures/ClassWithPrivateProperty.php +++ b/tests/Fixtures/ClassWithPrivateProperty.php @@ -7,7 +7,7 @@ class ClassWithPrivateProperty { public function __construct( - private string $foo + private string $foo, ) { } diff --git a/tests/Fixtures/MapTo/BadMapToTransformer.php b/tests/Fixtures/MapTo/BadMapToTransformer.php index 4ae05aab..bb447ff7 100644 --- a/tests/Fixtures/MapTo/BadMapToTransformer.php +++ b/tests/Fixtures/MapTo/BadMapToTransformer.php @@ -11,7 +11,7 @@ class BadMapToTransformer public function __construct( // Not valid because it is not static #[MapTo(transformer: [self::class, 'transformFoo'])] - public string $foo + public string $foo, ) { } diff --git a/tests/Fixtures/MapTo/FooMapTo.php b/tests/Fixtures/MapTo/FooMapTo.php index c4fb0d57..bc245ea8 100644 --- a/tests/Fixtures/MapTo/FooMapTo.php +++ b/tests/Fixtures/MapTo/FooMapTo.php @@ -19,7 +19,7 @@ public function __construct( #[MapTo('array', property: 'transformFromStringStatic', transformer: 'transformFromStringStatic')] #[MapTo('array', property: 'transformFromCustomTransformerService', transformer: TransformerWithDependency::class)] #[MapTo('array', property: 'transformFromExpressionLanguage', transformer: "source.foo === 'foo' ? 'transformed' : 'not transformed'")] - public string $foo + public string $foo, ) { } diff --git a/tests/Fixtures/MapTo/PriorityMapTo.php b/tests/Fixtures/MapTo/PriorityMapTo.php index eaa759b5..74378157 100644 --- a/tests/Fixtures/MapTo/PriorityMapTo.php +++ b/tests/Fixtures/MapTo/PriorityMapTo.php @@ -11,7 +11,7 @@ class PriorityMapTo public function __construct( #[MapTo('array', ignore: true, priority: 0)] #[MapTo('array', ignore: false, priority: 10)] - public string $foo + public string $foo, ) { } } diff --git a/tests/Fixtures/Post.php b/tests/Fixtures/Post.php index 879cc899..56ced6d7 100644 --- a/tests/Fixtures/Post.php +++ b/tests/Fixtures/Post.php @@ -8,7 +8,7 @@ class Post { public function __construct( public string $name, - public Category $category + public Category $category, ) { } } diff --git a/tests/Fixtures/Transformer/CustomTransformer/TransformerWithDependency.php b/tests/Fixtures/Transformer/CustomTransformer/TransformerWithDependency.php index 9c1f65df..822cd28e 100644 --- a/tests/Fixtures/Transformer/CustomTransformer/TransformerWithDependency.php +++ b/tests/Fixtures/Transformer/CustomTransformer/TransformerWithDependency.php @@ -15,7 +15,7 @@ final readonly class TransformerWithDependency implements PropertyTransformerInterface, PropertyTransformerSupportInterface { public function __construct( - private FooDependency $fooDependency + private FooDependency $fooDependency, ) { } diff --git a/tests/Normalizer/AutoMapperNormalizerTest.php b/tests/Normalizer/AutoMapperNormalizerTest.php index 1ba6c949..c54ec819 100644 --- a/tests/Normalizer/AutoMapperNormalizerTest.php +++ b/tests/Normalizer/AutoMapperNormalizerTest.php @@ -109,7 +109,7 @@ public function testSupportsNormalization(): void self::assertFalse($this->normalizer->supportsNormalization(['foo'])); self::assertFalse($this->normalizer->supportsNormalization('{"foo":1}')); - $iterator = new class() implements \IteratorAggregate { + $iterator = new class implements \IteratorAggregate { public function getIterator(): \Traversable { yield 'id' => 1; @@ -156,7 +156,7 @@ public function testNormalizeWithNoReturnType(): void public function testItUsesSerializerContext(): void { $normalizer = new AutoMapperNormalizer( - new class() implements AutoMapperInterface, AutoMapperRegistryInterface { + new class implements AutoMapperInterface, AutoMapperRegistryInterface { public function map(array|object|null $source, string|array|object $target, array $context = []): array|object|null { return $context; @@ -169,7 +169,7 @@ public function mapCollection(iterable $collection, string $target, array $conte public function getMapper(string $source, string $target): MapperInterface { - return new class() implements MapperInterface { + return new class implements MapperInterface { public function &map($value, array $context = []): mixed { return $value; diff --git a/tests/Normalizer/Features/CallbacksTestTrait.php b/tests/Normalizer/Features/CallbacksTestTrait.php index 317d0f7a..92c81980 100644 --- a/tests/Normalizer/Features/CallbacksTestTrait.php +++ b/tests/Normalizer/Features/CallbacksTestTrait.php @@ -95,7 +95,7 @@ public function testDenormalizeCallbacksWithNoConstructorArgument($callbacks, $v $normalizer = $this->getNormalizerForCallbacksWithPropertyTypeExtractor(); - $objWithNoConstructorArgument = new class() extends CallbacksObject { + $objWithNoConstructorArgument = new class extends CallbacksObject { public function __construct() { } diff --git a/tests/Normalizer/Features/CircularReferenceTestTrait.php b/tests/Normalizer/Features/CircularReferenceTestTrait.php index 01c7a00e..10f103d4 100644 --- a/tests/Normalizer/Features/CircularReferenceTestTrait.php +++ b/tests/Normalizer/Features/CircularReferenceTestTrait.php @@ -43,7 +43,7 @@ public function testUnableToNormalizeCircularReference(array $context, int $expe $obj = $this->getSelfReferencingModel(); $this->expectException(CircularReferenceException::class); - $this->expectExceptionMessage(sprintf('A circular reference has been detected when mapping the object of type "%s" (configured limit: %d).', $obj::class, $expectedLimit)); + $this->expectExceptionMessage(\sprintf('A circular reference has been detected when mapping the object of type "%s" (configured limit: %d).', $obj::class, $expectedLimit)); $normalizer->normalize($obj, null, $context); } diff --git a/tests/Normalizer/Features/ConstructorArgumentsTestTrait.php b/tests/Normalizer/Features/ConstructorArgumentsTestTrait.php index 6d11a503..722c4e88 100644 --- a/tests/Normalizer/Features/ConstructorArgumentsTestTrait.php +++ b/tests/Normalizer/Features/ConstructorArgumentsTestTrait.php @@ -65,10 +65,10 @@ public function testConstructorWithMissingData() $normalizer = $this->getDenormalizerForConstructArguments(); try { $normalizer->denormalize($data, ConstructorArgumentsObject::class); - self::fail(sprintf('Failed asserting that exception of type "%s" is thrown.', MissingConstructorArgumentsException::class)); + self::fail(\sprintf('Failed asserting that exception of type "%s" is thrown.', MissingConstructorArgumentsException::class)); } catch (MissingConstructorArgumentsException $e) { self::assertSame(ConstructorArgumentsObject::class, $e->getClass()); - self::assertSame(sprintf('Cannot create an instance of "%s" from mapping data because its constructor requires the following parameters to be present : "$foo".', ConstructorArgumentsObject::class), $e->getMessage()); + self::assertSame(\sprintf('Cannot create an instance of "%s" from mapping data because its constructor requires the following parameters to be present : "$foo".', ConstructorArgumentsObject::class), $e->getMessage()); self::assertSame(['foo'], $e->getMissingConstructorArguments()); } } diff --git a/tests/Transformer/ObjectTransformerTest.php b/tests/Transformer/ObjectTransformerTest.php index a5bdcc6d..460fd339 100644 --- a/tests/Transformer/ObjectTransformerTest.php +++ b/tests/Transformer/ObjectTransformerTest.php @@ -17,12 +17,12 @@ public function testObjectTransformer(): void $transformer = new ObjectTransformer(new Type('object', false, Foo::class), new Type('object', false, Foo::class)); $function = $this->createTransformerFunction($transformer); - $class = new class() { + $class = new class { public $mappers; public function __construct() { - $this->mappers['Mapper_' . Foo::class . '_' . Foo::class] = new class() { + $this->mappers['Mapper_' . Foo::class . '_' . Foo::class] = new class { public function map() { return new Foo();