Skip to content

chore(cs): update cs fixer for php 8.4 support #288

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions castor.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
#[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',
]);
}

#[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',
]);
}
Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/MapFromListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/MapListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/MapProviderListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/MapToContextListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
final readonly class MapToContextListener
{
public function __construct(
private ReflectionExtractor $extractor
private ReflectionExtractor $extractor,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/MapToListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
final readonly class AdvancedNameConverterListener
{
public function __construct(
private AdvancedNameConverterInterface|NameConverterInterface $nameConverter
private AdvancedNameConverterInterface|NameConverterInterface $nameConverter,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/Symfony/SerializerGroupListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
final readonly class SerializerGroupListener
{
public function __construct(
private ClassMetadataFactoryInterface $classMetadataFactory
private ClassMetadataFactoryInterface $classMetadataFactory,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/Symfony/SerializerIgnoreListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
final readonly class SerializerIgnoreListener
{
public function __construct(
private ClassMetadataFactoryInterface $classMetadataFactory
private ClassMetadataFactoryInterface $classMetadataFactory,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/Symfony/SerializerMaxDepthListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
final readonly class SerializerMaxDepthListener
{
public function __construct(
private ClassMetadataFactoryInterface $classMetadataFactory
private ClassMetadataFactoryInterface $classMetadataFactory,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/ReadOnlyTargetException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
4 changes: 2 additions & 2 deletions src/Generator/CreateTargetStatementsGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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_([
Expand Down Expand Up @@ -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_([
Expand Down
2 changes: 1 addition & 1 deletion src/Generator/MapMethodStatementsGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Generator/MapperGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/Generator/PropertyStatementsGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
final readonly class PropertyStatementsGenerator
{
public function __construct(
private PropertyConditionsGenerator $propertyConditionsGenerator
private PropertyConditionsGenerator $propertyConditionsGenerator,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Loader/FileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
4 changes: 2 additions & 2 deletions src/MapperContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Metadata/MapperMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(
}

/** @var class-string<object> $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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Provider/ApiPlatform/IriProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{
public function __construct(
private LegacyIriConverterInterface|IriConverterInterface $iriConverter,
private LegacyResourceClassResolverInterface|ResourceClassResolverInterface $resourceClassResolver
private LegacyResourceClassResolverInterface|ResourceClassResolverInterface $resourceClassResolver,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Provider/EarlyReturn.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class EarlyReturn
* @param object|array<mixed>|null $value
*/
public function __construct(
public object|array|null $value
public object|array|null $value,
) {
}
}
2 changes: 1 addition & 1 deletion src/Provider/ProviderRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bundle/CacheWarmup/CacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
}

Expand All @@ -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),
);
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Bundle/Command/DebugMapperCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
final class DebugMapperCommand extends Command
{
public function __construct(
private readonly MetadataFactory $metadataFactory
private readonly MetadataFactory $metadataFactory,
) {
parent::__construct('debug:mapper');
}
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/ExpressionLanguageProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* @param ServiceProviderInterface<\Closure> $functions
*/
public function __construct(
private ServiceProviderInterface $functions
private ServiceProviderInterface $functions,
) {
}

Expand All @@ -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)
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Transformer/ApiPlatform/JsonLdIdTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
final readonly class JsonLdIdTransformer implements PropertyTransformerInterface
{
public function __construct(
private LegacyIriConverterInterface|IriConverterInterface $iriConverter
private LegacyIriConverterInterface|IriConverterInterface $iriConverter,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Transformer/ChainTransformerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class ChainTransformerFactory implements TransformerFactoryInterface
* @param array<TransformerFactoryInterface> $factories
*/
public function __construct(
private array $factories = []
private array $factories = [],
) {
foreach ($this->factories as $factory) {
if ($factory instanceof ChainTransformerFactoryAwareInterface) {
Expand Down
Loading
Loading