From 324b93d12ea5e86e5a85eaca890edd425f21e50d Mon Sep 17 00:00:00 2001 From: Ronald Marfoldi Date: Fri, 13 Feb 2026 09:08:25 +0100 Subject: [PATCH 1/3] Resolve deprecations for Symfony 8 --- composer.json | 2 +- src/Handler/HandlerResolver.php | 6 ++--- src/Handler/Handlers/AbstractHandler.php | 6 ++--- src/Handler/Handlers/BasicHandler.php | 20 +++++++-------- src/Handler/Handlers/DateTimeHandler.php | 4 +-- src/Handler/Handlers/EntityIdHandler.php | 6 ++--- src/Handler/Handlers/EnumHandler.php | 4 +-- src/Handler/Handlers/ObjectHandler.php | 16 ++++++------ src/Handler/Handlers/UuidHandler.php | 4 +-- src/Helper/SerializerHelper.php | 8 +++--- src/Metadata/MetadataFactory.php | 8 +++--- src/Metadata/MetadataRegistry.php | 2 +- src/OpenApi/SerializerModelDescriber.php | 32 ++++++++++++++---------- 13 files changed, 62 insertions(+), 56 deletions(-) diff --git a/composer.json b/composer.json index 9cde964..d5b58f9 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "ext-json": "*", "doctrine/common": "^3.3", "nelmio/api-doc-bundle": "^5.9", - "symfony/property-info": "^6.3|^7.0" + "symfony/type-info": "^7.0|^8.0" }, "require-dev": { "doctrine/doctrine-bundle": "^2.18", diff --git a/src/Handler/HandlerResolver.php b/src/Handler/HandlerResolver.php index 7fc36df..ab8bd47 100644 --- a/src/Handler/HandlerResolver.php +++ b/src/Handler/HandlerResolver.php @@ -11,11 +11,11 @@ use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; -final class HandlerResolver +final readonly class HandlerResolver { public function __construct( - private readonly ContainerInterface $handlerLocator, - private readonly array $handlers, + private ContainerInterface $handlerLocator, + private array $handlers, ) { } diff --git a/src/Handler/Handlers/AbstractHandler.php b/src/Handler/Handlers/AbstractHandler.php index eef98fb..b4a1d8c 100644 --- a/src/Handler/Handlers/AbstractHandler.php +++ b/src/Handler/Handlers/AbstractHandler.php @@ -6,7 +6,7 @@ use AnzuSystems\SerializerBundle\Helper\SerializerHelper; use AnzuSystems\SerializerBundle\Metadata\Metadata; -use Symfony\Component\PropertyInfo\Type; +use Symfony\Component\TypeInfo\TypeIdentifier; abstract class AbstractHandler implements HandlerInterface { @@ -36,7 +36,7 @@ public function describe(string $property, Metadata $metadata): array 'property' => $property, 'type' => SerializerHelper::getOaFriendlyType($metadata->type), ]; - if (Type::BUILTIN_TYPE_FLOAT === $metadata->type) { + if (TypeIdentifier::FLOAT->value === $metadata->type) { $description['format'] = 'float'; } if (null === $metadata->setter) { @@ -45,7 +45,7 @@ public function describe(string $property, Metadata $metadata): array if ($metadata->isNullable) { $description['nullable'] = true; } - if (Type::BUILTIN_TYPE_ARRAY === $metadata->type) { + if (TypeIdentifier::ARRAY->value === $metadata->type) { $itemType = []; if (null !== $metadata->customType && '' !== $metadata->customType) { $itemType = ['type' => $metadata->customType]; diff --git a/src/Handler/Handlers/BasicHandler.php b/src/Handler/Handlers/BasicHandler.php index cc3e0bb..db585a0 100644 --- a/src/Handler/Handlers/BasicHandler.php +++ b/src/Handler/Handlers/BasicHandler.php @@ -6,15 +6,15 @@ use AnzuSystems\SerializerBundle\Context\SerializationContext; use AnzuSystems\SerializerBundle\Metadata\Metadata; -use Symfony\Component\PropertyInfo\Type; +use Symfony\Component\TypeInfo\TypeIdentifier; final class BasicHandler extends AbstractHandler { - public const BASIC_TYPES = [ - Type::BUILTIN_TYPE_INT, - Type::BUILTIN_TYPE_STRING, - Type::BUILTIN_TYPE_FLOAT, - Type::BUILTIN_TYPE_BOOL, + public const array BASIC_TYPES = [ + TypeIdentifier::INT->value, + TypeIdentifier::STRING->value, + TypeIdentifier::FLOAT->value, + TypeIdentifier::BOOL->value, ]; public static function getPriority(): int @@ -44,10 +44,10 @@ public function deserialize(mixed $value, Metadata $metadata): string|int|bool|n } return match ($metadata->type) { - Type::BUILTIN_TYPE_STRING => (string) $value, - Type::BUILTIN_TYPE_INT => (int) $value, - Type::BUILTIN_TYPE_FLOAT => (float) $value, - Type::BUILTIN_TYPE_BOOL => filter_var($value, FILTER_VALIDATE_BOOL) + TypeIdentifier::STRING->value => (string) $value, + TypeIdentifier::INT->value => (int) $value, + TypeIdentifier::FLOAT->value => (float) $value, + TypeIdentifier::BOOL->value => filter_var($value, FILTER_VALIDATE_BOOL) }; } diff --git a/src/Handler/Handlers/DateTimeHandler.php b/src/Handler/Handlers/DateTimeHandler.php index 66f8790..3d06c4f 100644 --- a/src/Handler/Handlers/DateTimeHandler.php +++ b/src/Handler/Handlers/DateTimeHandler.php @@ -11,7 +11,7 @@ use DateTimeImmutable; use DateTimeInterface; use DateTimeZone; -use Symfony\Component\PropertyInfo\Type; +use Symfony\Component\TypeInfo\TypeIdentifier; final class DateTimeHandler extends AbstractHandler { @@ -66,7 +66,7 @@ public static function supportsDescribe(string $property, Metadata $metadata): b public function describe(string $property, Metadata $metadata): array { $description = parent::describe($property, $metadata); - $description['type'] = Type::BUILTIN_TYPE_STRING; + $description['type'] = TypeIdentifier::STRING->value; $description['format'] = 'date-time, format: "' . ($metadata->customType ?? $this->serializerDateFormat) . '"'; return $description; diff --git a/src/Handler/Handlers/EntityIdHandler.php b/src/Handler/Handlers/EntityIdHandler.php index aef6631..af356e7 100644 --- a/src/Handler/Handlers/EntityIdHandler.php +++ b/src/Handler/Handlers/EntityIdHandler.php @@ -15,7 +15,7 @@ use ReflectionException; use ReflectionMethod; use ReflectionNamedType; -use Symfony\Component\PropertyInfo\Type; +use Symfony\Component\TypeInfo\TypeIdentifier; use Symfony\Component\Uid\Uuid; final class EntityIdHandler extends AbstractHandler @@ -98,8 +98,8 @@ public function describe(string $property, Metadata $metadata): array { $description = parent::describe($property, $metadata); if (is_a($metadata->type, Collection::class, true) - || Type::BUILTIN_TYPE_ARRAY === $metadata->type) { - $description['type'] = Type::BUILTIN_TYPE_ARRAY; + || TypeIdentifier::ARRAY->value === $metadata->type) { + $description['type'] = TypeIdentifier::ARRAY->value; $description['title'] = SerializerHelper::getClassBaseName((string) $metadata->customType) . ' IDs'; $description['items'] = ['type' => $this->describeReturnType((string) $metadata->customType)]; diff --git a/src/Handler/Handlers/EnumHandler.php b/src/Handler/Handlers/EnumHandler.php index 8b9dfab..012ff5e 100644 --- a/src/Handler/Handlers/EnumHandler.php +++ b/src/Handler/Handlers/EnumHandler.php @@ -9,7 +9,7 @@ use AnzuSystems\SerializerBundle\Exception\SerializerException; use AnzuSystems\SerializerBundle\Metadata\Metadata; use BackedEnum; -use Symfony\Component\PropertyInfo\Type; +use Symfony\Component\TypeInfo\TypeIdentifier; use UnitEnum; final class EnumHandler extends AbstractHandler @@ -83,7 +83,7 @@ public function describe(string $property, Metadata $metadata): array $enums[] = $enumCase->value; } $description['enum'] = $enums; - $description['type'] = Type::BUILTIN_TYPE_STRING; + $description['type'] = TypeIdentifier::STRING->value; return $description; } diff --git a/src/Handler/Handlers/ObjectHandler.php b/src/Handler/Handlers/ObjectHandler.php index 61a9333..80e85d4 100644 --- a/src/Handler/Handlers/ObjectHandler.php +++ b/src/Handler/Handlers/ObjectHandler.php @@ -15,7 +15,7 @@ use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Selectable; -use Symfony\Component\PropertyInfo\Type; +use Symfony\Component\TypeInfo\TypeIdentifier; final class ObjectHandler extends AbstractHandler { @@ -54,7 +54,7 @@ public function serialize(mixed $value, Metadata $metadata, SerializationContext public static function supportsDeserialize(mixed $value, string $type): bool { - return is_array($value) || ($value instanceof \stdClass && Type::BUILTIN_TYPE_ARRAY === $type); + return is_array($value) || ($value instanceof \stdClass && TypeIdentifier::ARRAY->value === $type); } /** @@ -64,7 +64,7 @@ public static function supportsDeserialize(mixed $value, string $type): bool */ public function deserialize(mixed $value, Metadata $metadata): object|iterable { - if ($value instanceof \stdClass && Type::BUILTIN_TYPE_ARRAY === $metadata->type) { + if ($value instanceof \stdClass && TypeIdentifier::ARRAY->value === $metadata->type) { return (array) $value; } if (is_a($metadata->type, Collection::class, true)) { @@ -81,7 +81,7 @@ public function deserialize(mixed $value, Metadata $metadata): object|iterable return $collection; } - if (Type::BUILTIN_TYPE_ARRAY === $metadata->type) { + if (TypeIdentifier::ARRAY->value === $metadata->type) { if ($metadata->customType || $metadata->discriminatorMap) { $array = []; foreach ($value as $key => $item) { @@ -108,11 +108,11 @@ public function describe(string $property, Metadata $metadata): array { $description = parent::describe($property, $metadata); if (is_a($metadata->type, Collection::class, true) - || Type::BUILTIN_TYPE_ARRAY === $metadata->type) { - $description['type'] = Type::BUILTIN_TYPE_ARRAY; + || TypeIdentifier::ARRAY->value === $metadata->type) { + $description['type'] = TypeIdentifier::ARRAY->value; $description['items'] = null; if (Serialize::KEYS_VALUES === $metadata->strategy) { - $description['type'] = Type::BUILTIN_TYPE_OBJECT; + $description['type'] = TypeIdentifier::OBJECT->value; $description['title'] = 'Custom key-value data.'; return $description; @@ -120,7 +120,7 @@ public function describe(string $property, Metadata $metadata): array if (null !== $metadata->customType && class_exists($metadata->customType)) { $description['title'] = 'Array of ' . SerializerHelper::getClassBaseName($metadata->customType); $description['items'] = [ - 'type' => Type::BUILTIN_TYPE_OBJECT, + 'type' => TypeIdentifier::OBJECT->value, SerializerModelDescriber::NESTED_CLASS => $metadata->customType, ]; } diff --git a/src/Handler/Handlers/UuidHandler.php b/src/Handler/Handlers/UuidHandler.php index c26adc7..b1a4c26 100644 --- a/src/Handler/Handlers/UuidHandler.php +++ b/src/Handler/Handlers/UuidHandler.php @@ -6,7 +6,7 @@ use AnzuSystems\SerializerBundle\Context\SerializationContext; use AnzuSystems\SerializerBundle\Metadata\Metadata; -use Symfony\Component\PropertyInfo\Type; +use Symfony\Component\TypeInfo\TypeIdentifier; use Symfony\Component\Uid\AbstractUid; use Symfony\Component\Uid\MaxUuid; use Symfony\Component\Uid\NilUuid; @@ -55,7 +55,7 @@ public static function supportsDescribe(string $property, Metadata $metadata): b public function describe(string $property, Metadata $metadata): array { $description = parent::describe($property, $metadata); - $description['type'] = Type::BUILTIN_TYPE_STRING; + $description['type'] = TypeIdentifier::STRING->value; $description['title'] = 'UUID'; $description['format'] = 'uuid'; diff --git a/src/Helper/SerializerHelper.php b/src/Helper/SerializerHelper.php index 9bc7e58..34e08e2 100644 --- a/src/Helper/SerializerHelper.php +++ b/src/Helper/SerializerHelper.php @@ -4,16 +4,16 @@ namespace AnzuSystems\SerializerBundle\Helper; -use Symfony\Component\PropertyInfo\Type; +use Symfony\Component\TypeInfo\TypeIdentifier; final class SerializerHelper { public static function getOaFriendlyType(string $type): string { return match ($type) { - Type::BUILTIN_TYPE_INT => 'integer', - Type::BUILTIN_TYPE_BOOL => 'boolean', - Type::BUILTIN_TYPE_FLOAT => 'number', + TypeIdentifier::INT->value => 'integer', + TypeIdentifier::BOOL->value => 'boolean', + TypeIdentifier::FLOAT->value => 'number', default => $type, }; } diff --git a/src/Metadata/MetadataFactory.php b/src/Metadata/MetadataFactory.php index 9f298e0..74fefb9 100644 --- a/src/Metadata/MetadataFactory.php +++ b/src/Metadata/MetadataFactory.php @@ -14,13 +14,13 @@ use ReflectionProperty; use ReflectionUnionType; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; -use Symfony\Component\PropertyInfo\Type; +use Symfony\Component\TypeInfo\TypeIdentifier; use const PHP_VERSION; -final class MetadataFactory +final readonly class MetadataFactory { public function __construct( - private readonly ParameterBagInterface $parameterBag + private ParameterBagInterface $parameterBag ) { } @@ -195,7 +195,7 @@ private function getPropertyMetadata(ReflectionProperty $property, Serialize $at $type = ''; if ($propertyType instanceof ReflectionNamedType) { $type = $propertyType->getName(); - if (Type::BUILTIN_TYPE_BOOL === $type) { + if (TypeIdentifier::BOOL->value === $type) { $getterPrefix = 'is'; } } diff --git a/src/Metadata/MetadataRegistry.php b/src/Metadata/MetadataRegistry.php index 5e10d39..6e525c5 100644 --- a/src/Metadata/MetadataRegistry.php +++ b/src/Metadata/MetadataRegistry.php @@ -13,7 +13,7 @@ final class MetadataRegistry { - private const CACHE_PREFIX = 'anzu_serialz_'; + private const string CACHE_PREFIX = 'anzu_serialz_'; /** * @var array diff --git a/src/OpenApi/SerializerModelDescriber.php b/src/OpenApi/SerializerModelDescriber.php index 2bfe7d0..3cf7f3e 100644 --- a/src/OpenApi/SerializerModelDescriber.php +++ b/src/OpenApi/SerializerModelDescriber.php @@ -18,12 +18,14 @@ use ReflectionException; use ReflectionMethod; use ReflectionProperty; -use Symfony\Component\PropertyInfo\Type; +use Symfony\Component\TypeInfo\Type; +use Symfony\Component\TypeInfo\Type\ObjectType; +use Symfony\Component\TypeInfo\TypeIdentifier; use const PHP_EOL; final class SerializerModelDescriber implements ModelDescriberInterface { - public const NESTED_CLASS = 'nested_object'; + public const string NESTED_CLASS = 'nested_object'; private ?SymfonyConstraintAnnotationReader $symfonyConstraintAnnotationReader = null; @@ -43,10 +45,9 @@ public function supports(Model $model): bool */ public function describe(Model $model, Schema $schema): void { - $schema->type = Type::BUILTIN_TYPE_OBJECT; + $schema->type = TypeIdentifier::OBJECT->value; $properties = []; foreach ($this->getMetadata($model) as $propertyName => $metadata) { - /** @var Metadata $metadata */ $handler = $this->handlerResolver->getDescriptionHandler($propertyName, $metadata); $description = $handler->describe($propertyName, $metadata); @@ -61,21 +62,22 @@ public function describe(Model $model, Schema $schema): void } $this->describeNestedItems($description); $property = new Property($description); + $typeInfo = $model->getTypeInfo(); // Describe symfony constraints and property docBlock description. - if (null !== $metadata->property && null !== $model->getType()->getClassName()) { + if (is_string($metadata->property) && $typeInfo instanceof ObjectType && false === empty($typeInfo->getClassName())) { /** @psalm-suppress ArgumentTypeCoercion */ - $propertyReflection = new ReflectionProperty($model->getType()->getClassName(), $metadata->property); + $propertyReflection = new ReflectionProperty($typeInfo->getClassName(), $metadata->property); $this->getSymfonyConstraintAnnotationReader()->updateProperty($propertyReflection, $property); $this->addDocBlockDescription($propertyReflection, $property); } // Method docBlock description. - if (null === $metadata->setter && null !== $model->getType()->getClassName()) { + if (is_string($metadata->setter) && $typeInfo instanceof ObjectType && false === empty($typeInfo->getClassName())) { /** @psalm-suppress ArgumentTypeCoercion */ $methodReflection = $metadata->getterSetterStrategy - ? new ReflectionMethod($model->getType()->getClassName(), $metadata->getter) - : new ReflectionProperty($model->getType()->getClassName(), $metadata->getter) + ? new ReflectionMethod($typeInfo->getClassName(), $metadata->getter) + : new ReflectionProperty($typeInfo->getClassName(), $metadata->getter) ; $this->addDocBlockDescription($methodReflection, $property); } @@ -133,7 +135,7 @@ private function addDocBlockDescription(ReflectionProperty|ReflectionMethod $ref private function describeNested(string $property, array $description): ?Property { $className = $description[self::NESTED_CLASS]; - $nestedModel = new Model(new Type(Type::BUILTIN_TYPE_OBJECT, class: $className)); + $nestedModel = new Model(Type::object($className)); $nestedSchema = new Property([ 'property' => $property, 'title' => SerializerHelper::getClassBaseName($className), @@ -156,7 +158,7 @@ private function describeNestedItems(array &$description): void { if (isset($description['items'][self::NESTED_CLASS])) { $nestedItems = new Items(['title' => SerializerHelper::getClassBaseName($description['items'][self::NESTED_CLASS])]); - $nestedItemsModel = new Model(new Type(Type::BUILTIN_TYPE_OBJECT, class: $description['items'][self::NESTED_CLASS])); + $nestedItemsModel = new Model(Type::object($description['items'][self::NESTED_CLASS])); if ($this->supports($nestedItemsModel)) { $this->describe($nestedItemsModel, $nestedItems); @@ -171,8 +173,12 @@ private function describeNestedItems(array &$description): void */ private function getMetadata(Model $model): array { - $className = $model->getType()->getClassName(); - if (null !== $className && '' !== $className && class_exists($className)) { + $typeInfo = $model->getTypeInfo(); + if (false === ($typeInfo instanceof ObjectType)) { + return []; + } + $className = $typeInfo->getClassName(); + if (class_exists($className)) { try { return $this->metadataRegistry->get($className)->getAll(); } catch (SerializerException) { From 33a7d748a927385b7027c6df88f5521cdc15d595 Mon Sep 17 00:00:00 2001 From: Ronald Marfoldi Date: Fri, 13 Feb 2026 11:01:04 +0100 Subject: [PATCH 2/3] Update dev dependencies --- composer.json | 10 +- ecs.php | 231 ++++++++++------------------ tests/config/packages/doctrine.yaml | 1 + 3 files changed, 88 insertions(+), 154 deletions(-) diff --git a/composer.json b/composer.json index d5b58f9..a0845a0 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ } ], "require": { - "php": ">=8.3", + "php": ">=8.4", "ext-json": "*", "doctrine/common": "^3.3", "nelmio/api-doc-bundle": "^5.9", @@ -21,11 +21,11 @@ "doctrine/doctrine-bundle": "^2.18", "doctrine/orm": "^3.5", "slevomat/coding-standard": "8.22", - "symfony/dotenv": "^6.3|^7.0", + "symfony/dotenv": "^7.0|^8.0", "symfony/test-pack": "^1.1", - "symfony/uid": "^6.3|^7.0", - "symfony/var-exporter": "^6.3|^7.0", - "symplify/easy-coding-standard": "^12.0", + "symfony/uid": "^7.0|^8.0", + "symfony/var-exporter": "^7.0|^8.0", + "symplify/easy-coding-standard": "^13.0", "vimeo/psalm": "^6.8" }, "suggest": { diff --git a/ecs.php b/ecs.php index 7b6b60a..0188f08 100644 --- a/ecs.php +++ b/ecs.php @@ -2,7 +2,6 @@ declare(strict_types=1); -use AnzuSystems\SerializerBundle\DependencyInjection\Configuration; use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff; use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer; use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer; @@ -14,24 +13,19 @@ use PhpCsFixer\Fixer\DoctrineAnnotation\DoctrineAnnotationIndentationFixer; use PhpCsFixer\Fixer\DoctrineAnnotation\DoctrineAnnotationSpacesFixer; use PhpCsFixer\Fixer\FunctionNotation\SingleLineThrowFixer; +use PhpCsFixer\Fixer\Import\OrderedImportsFixer; use PhpCsFixer\Fixer\ListNotation\ListSyntaxFixer; use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer; use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocTagRenameFixer; use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer; use PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer; -use PhpCsFixer\Fixer\Phpdoc\PhpdocAnnotationWithoutDotFixer; use PhpCsFixer\Fixer\Phpdoc\PhpdocInlineTagNormalizerFixer; -use PhpCsFixer\Fixer\Phpdoc\PhpdocSeparationFixer; use PhpCsFixer\Fixer\Phpdoc\PhpdocToCommentFixer; -use PhpCsFixer\Fixer\Phpdoc\PhpdocTypesOrderFixer; use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer; -use PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer; use PhpCsFixer\Fixer\Whitespace\MethodChainingIndentationFixer; -use SlevomatCodingStandard\Sniffs\Classes\MethodSpacingSniff; use SlevomatCodingStandard\Sniffs\Classes\ModernClassNameReferenceSniff; use SlevomatCodingStandard\Sniffs\Classes\ParentCallSpacingSniff; use SlevomatCodingStandard\Sniffs\Classes\PropertySpacingSniff; -use SlevomatCodingStandard\Sniffs\Commenting\DocCommentSpacingSniff; use SlevomatCodingStandard\Sniffs\Commenting\UselessInheritDocCommentSniff; use SlevomatCodingStandard\Sniffs\ControlStructures\RequireNullCoalesceOperatorSniff; use SlevomatCodingStandard\Sniffs\Functions\ArrowFunctionDeclarationSniff; @@ -43,22 +37,19 @@ use SlevomatCodingStandard\Sniffs\Namespaces\UseFromSameNamespaceSniff; use SlevomatCodingStandard\Sniffs\Numbers\RequireNumericLiteralSeparatorSniff; use SlevomatCodingStandard\Sniffs\PHP\UselessParenthesesSniff; -use SlevomatCodingStandard\Sniffs\TypeHints\UselessConstantTypeHintSniff; use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayListItemNewlineFixer; use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer; use Symplify\EasyCodingStandard\Config\ECSConfig; -use Symplify\EasyCodingStandard\ValueObject\Set\SetList; -return static function (ECSConfig $ecsConfig): void { - $ecsConfig->import(SetList::CLEAN_CODE); - $ecsConfig->import(SetList::PSR_12); - $ecsConfig->import(SetList::COMMON); - - $ecsConfig->cacheDirectory(__DIR__ . '/var/ecs_cache'); - - $ecsConfig->skip([ - Configuration::class, - PhpdocTypesOrderFixer::class, +return ECSConfig::configure() + ->withPreparedSets(psr12: true, common: true, cleanCode: true) + ->withParallel() + ->withCache(directory: __DIR__ . '/var/ecs_cache') + ->withPaths(paths: [ + __DIR__ . '/src', + __DIR__ . '/tests', + ]) + ->withSkip([ ArrayListItemNewlineFixer::class => null, PhpdocToCommentFixer::class => null, PhpdocAlignFixer::class => null, @@ -71,134 +62,76 @@ DoctrineAnnotationBracesFixer::class => null, NotOperatorWithSuccessorSpaceFixer::class => null, UselessParenthesesSniff::class => null, - PhpdocSeparationFixer::class => null, - MethodChainingIndentationFixer::class => ['DependencyInjection/*Configuration.php'], - 'SlevomatCodingStandard\Sniffs\Whitespaces\DuplicateSpacesSniff.DuplicateDeclareStrictTypesSpaces' => null, + OrderedImportsFixer::class => null, + MethodChainingIndentationFixer::class => ['src/DependencyInjection/*Configuration.php'], + 'SlevomatCodingStandard\Sniffs\Classes\UnusedPrivateElementsSniff.WriteOnlyProperty' => ['src/Entity/User.php'], + 'SlevomatCodingStandard\Sniffs\Whitespaces\DuplicateSpacesSniff.DuplicateSpaces' => null, 'SlevomatCodingStandard\Sniffs\Commenting\DisallowCommentAfterCodeSniff.DisallowedCommentAfterCode' => null, - PhpdocAnnotationWithoutDotFixer::class => null, - PhpCsFixer\Fixer\Import\NoUnusedImportsFixer::class => null, - ]); - - $ecsConfig->extend( - NoSuperfluousPhpdocTagsFixer::class, - function (NoSuperfluousPhpdocTagsFixer $noSuperfluousPhpdocTagsFixer) { - $noSuperfluousPhpdocTagsFixer->configure(['remove_inheritdoc' => false, 'allow_mixed' => false]); - - return $noSuperfluousPhpdocTagsFixer; - } - ); - - $ecsConfig->extend(ClassDefinitionFixer::class, function (ClassDefinitionFixer $classDefinitionFixer) { - $classDefinitionFixer->configure(['multi_line_extends_each_single_line' => false]); - - return $classDefinitionFixer; - }); - - $ecsConfig->extend( - ClassAttributesSeparationFixer::class, - function (ClassAttributesSeparationFixer $classAttributesSeparationFixer) { - $classAttributesSeparationFixer->configure(['elements' => ['method', 'property']]); - - return $classAttributesSeparationFixer; - } - ); - - $ecsConfig->ruleWithConfiguration(DocCommentSpacingSniff::class, [ - 'annotationsGroups' => [ - '@inheritDoc', - '@template, @extends, @implements, @template-implements @template-extends', - '@var, @psalm-var, @param, @psalm-param', - '@return, @psalm-return', - '@throws', - '@psalm-suppress', - ], - ]); - - $ecsConfig->ruleWithConfiguration(UnusedUsesSniff::class, [ - 'searchAnnotations' => true, - ]); - - $ecsConfig->ruleWithConfiguration(PropertySpacingSniff::class, [ - 'minLinesCountBeforeWithComment' => 1, - 'maxLinesCountBeforeWithComment' => 1, - 'maxLinesCountBeforeWithoutComment' => 0, - ]); - - $ecsConfig->rule(AlphabeticallySortedUsesSniff::class); - $ecsConfig->rule(StrictCallSniff::class); - $ecsConfig->rule(DeclareStrictTypesFixer::class); - $ecsConfig->rule(MethodSpacingSniff::class); - $ecsConfig->rule(NoNullPropertyInitializationFixer::class); - $ecsConfig->rule(ArrowFunctionDeclarationSniff::class); - $ecsConfig->rule(UseDoesNotStartWithBackslashSniff::class); - $ecsConfig->rule(RequireNumericLiteralSeparatorSniff::class); - $ecsConfig->rule(UselessParenthesesSniff::class); - $ecsConfig->rule(RequireNullCoalesceOperatorSniff::class); - $ecsConfig->rule(ModernClassNameReferenceSniff::class); - $ecsConfig->rule(UselessInheritDocCommentSniff::class); - $ecsConfig->rule(UseFromSameNamespaceSniff::class); - $ecsConfig->rule(UnusedInheritedVariablePassedToClosureSniff::class); - $ecsConfig->rule(UselessConstantTypeHintSniff::class); - $ecsConfig->rule(DoctrineAnnotationArrayAssignmentFixer::class); - $ecsConfig->rule(DoctrineAnnotationIndentationFixer::class); - $ecsConfig->rule(DoctrineAnnotationSpacesFixer::class); - $ecsConfig->rule(BlankLineBeforeStatementFixer::class); - - $ecsConfig->ruleWithConfiguration( - YodaStyleFixer::class, - ['equal' => true, 'identical' => true, 'less_and_greater' => null] - ); - - $ecsConfig->ruleWithConfiguration(ForbiddenFunctionsSniff::class, [ - 'forbiddenFunctions' => [ - 'chop' => 'rtrim', - 'close' => 'closedir', - 'delete' => 'unset', - 'doubleval' => 'floatval', - 'fputs' => 'fwrite', - 'imap_create' => 'createmailbox', - 'imap_fetchtext' => 'body', - 'imap_header' => 'headerinfo', - 'imap_listmailbox' => 'list', - 'imap_listsubscribed' => 'lsub', - 'imap_rename' => 'renamemailbox', - 'imap_scan' => 'listscan', - 'imap_scanmailbox' => 'listscan', - 'mt_rand' => 'random_int', - 'ini_alter' => 'set', - 'is_double' => 'is_float', - 'is_integer' => 'is_int', - 'is_null' => '!== null', - 'is_real' => 'is_float', - 'is_writeable' => 'is_writable', - 'join' => 'implode', - 'key_exists' => 'array_key_exists', - 'magic_quotes_runtime' => 'set_magic_quotes_runtime', - 'pos' => 'current', - 'rand' => 'random_int', - 'show_source' => 'file', - 'sizeof' => 'count', - 'strchr' => 'strstr', - 'create_function' => null, - 'call_user_func' => null, - 'call_user_func_array' => null, - 'forward_static_call' => null, - 'forward_static_call_array' => null, - 'dump' => null, - 'die' => null, - 'exit' => null, - 'var_dump' => null, - ], - ]); - - $ecsConfig->extend(ArraySyntaxFixer::class, function (ArraySyntaxFixer $arraySyntaxFixer) { - $arraySyntaxFixer->configure(['syntax' => 'short']); - - return $arraySyntaxFixer; - }); - - $ecsConfig->ruleWithConfiguration(ListSyntaxFixer::class, [ - 'syntax' => 'short', - ]); - -}; + ]) + ->withConfiguredRule(NoSuperfluousPhpdocTagsFixer::class, ['remove_inheritdoc' => false, 'allow_mixed' => false]) + ->withConfiguredRule(ClassDefinitionFixer::class, ['multi_line_extends_each_single_line' => false]) + ->withConfiguredRule(ClassAttributesSeparationFixer::class, ['elements' => ['method', 'property']]) + ->withConfiguredRule(ArraySyntaxFixer::class, ['syntax' => 'short']) + ->withConfiguredRule(ListSyntaxFixer::class, ['syntax' => 'short']) + ->withConfiguredRule(PropertySpacingSniff::class, ['minLinesCountBeforeWithComment' => 1, 'maxLinesCountBeforeWithComment' => 1, 'maxLinesCountBeforeWithoutComment' => 0]) + ->withConfiguredRule(UnusedUsesSniff::class, ['searchAnnotations' => true]) + ->withConfiguredRule(YodaStyleFixer::class, ['identical' => true]) + ->withConfiguredRule(ForbiddenFunctionsSniff::class, ['forbiddenFunctions' => [ + 'chop' => 'rtrim', + 'close' => 'closedir', + 'delete' => 'unset', + 'doubleval' => 'floatval', + 'fputs' => 'fwrite', + 'imap_create' => 'createmailbox', + 'imap_fetchtext' => 'body', + 'imap_header' => 'headerinfo', + 'imap_listmailbox' => 'list', + 'imap_listsubscribed' => 'lsub', + 'imap_rename' => 'renamemailbox', + 'imap_scan' => 'listscan', + 'imap_scanmailbox' => 'listscan', + 'mt_rand' => 'random_int', + 'ini_alter' => 'set', + 'is_double' => 'is_float', + 'is_integer' => 'is_int', + 'is_null' => '!== null', + 'is_real' => 'is_float', + 'is_writeable' => 'is_writable', + 'join' => 'implode', + 'key_exists' => 'array_key_exists', + 'magic_quotes_runtime' => 'set_magic_quotes_runtime', + 'pos' => 'current', + 'rand' => 'random_int', + 'show_source' => 'file', + 'sizeof' => 'count', + 'strchr' => 'strstr', + 'create_function' => null, + 'call_user_func' => null, + 'call_user_func_array' => null, + 'forward_static_call' => null, + 'forward_static_call_array' => null, + 'dump' => null, + 'die' => null, + 'dd' => null, + 'echo' => null, + 'var_dump' => null, + ]]) + ->withRules([ + DeclareStrictTypesFixer::class, + NoNullPropertyInitializationFixer::class, + ArrowFunctionDeclarationSniff::class, + StrictCallSniff::class, + UseDoesNotStartWithBackslashSniff::class, + AlphabeticallySortedUsesSniff::class, + RequireNumericLiteralSeparatorSniff::class, + UselessParenthesesSniff::class, + RequireNullCoalesceOperatorSniff::class, + ModernClassNameReferenceSniff::class, + UselessInheritDocCommentSniff::class, + UseFromSameNamespaceSniff::class, + UnusedInheritedVariablePassedToClosureSniff::class, + DoctrineAnnotationArrayAssignmentFixer::class, + DoctrineAnnotationIndentationFixer::class, + DoctrineAnnotationSpacesFixer::class, + ]) +; diff --git a/tests/config/packages/doctrine.yaml b/tests/config/packages/doctrine.yaml index a90c8c1..73ed907 100644 --- a/tests/config/packages/doctrine.yaml +++ b/tests/config/packages/doctrine.yaml @@ -3,6 +3,7 @@ doctrine: url: '%env(resolve:DB_BUNDLE_URL)%' orm: auto_generate_proxy_classes: true + enable_native_lazy_objects: true naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware auto_mapping: false mappings: From 6baec236ff03a76fd8884e4d73e12df1a211f954 Mon Sep 17 00:00:00 2001 From: Ronald Marfoldi Date: Fri, 13 Feb 2026 11:02:52 +0100 Subject: [PATCH 3/3] Update dev dependencies --- .github/workflows/php.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index ae1de29..c9a2dfd 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -10,8 +10,6 @@ jobs: strategy: matrix: include: - - php-version: 8.3 - docker-image: 'anzusystems/php:4.0.0-php83-cli' - php-version: 8.4 docker-image: 'anzusystems/php:5.0.1-php84-cli' - php-version: 8.5