From a8e6ddbb9ed91f419bcd11c29e177b501e4fa84c Mon Sep 17 00:00:00 2001 From: Ronald Marfoldi Date: Fri, 13 Feb 2026 09:35:29 +0100 Subject: [PATCH 1/3] Resolve deprecations for Symfony 8 --- .github/workflows/php.yml | 2 - composer.json | 34 +-- ecs.php | 205 +++++++----------- src/AnzuTap/AnzuTapBodyPostprocessor.php | 7 +- src/AnzuTap/AnzuTapBodyPreprocessor.php | 2 + src/AnzuTap/AnzuTapEditor.php | 1 - .../Mark/AbstractMarkNodeTransformer.php | 1 - .../Mark/AnzuMarkTransformerInterface.php | 2 - .../Transformer/Mark/LinkNodeTransformer.php | 2 +- .../Node/BulletListTransformer.php | 1 - .../Node/HorizontalRuleTransformer.php | 1 - .../Transformer/Node/TableCellTransformer.php | 2 +- src/ApiFilter/ApiQuery.php | 5 +- .../AnzuSystemsCommonExtension.php | 2 +- src/Doctrine/Type/AbstractEnumType.php | 2 + src/Domain/Job/JobRunner.php | 4 +- src/Domain/User/UserSyncFacade.php | 3 - src/Helper/CollectionHelper.php | 8 +- src/Model/AnzuTap/EditorsConfiguration.php | 2 + src/Model/AnzuTap/EmbedContainer.php | 1 - src/Model/OpenApi/Get/OAGetList.php | 1 - src/Model/User/BaseUserDto.php | 6 - src/Model/User/UserDto.php | 9 - src/Monolog/ContextProcessor.php | 1 - src/Repository/AbstractAnzuRepository.php | 6 +- .../Handler/Handlers/GeolocationHandler.php | 8 +- .../Handler/Handlers/ValueObjectHandler.php | 4 +- src/Validator/Constraints/UniqueEntity.php | 8 +- src/Validator/Constraints/UniqueEntityDto.php | 12 +- .../Traits/EntityClassResolverTrait.php | 2 +- 30 files changed, 146 insertions(+), 198 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 280a7a6..169b8c3 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.1.0-php83-cli' - php-version: 8.4 docker-image: 'anzusystems/php:5.0.1-php84-cli' - php-version: 8.5 diff --git a/composer.json b/composer.json index f423bfa..c561f62 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ } ], "require": { - "php": ">=8.3", + "php": ">=8.4", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", @@ -27,25 +27,25 @@ "mongodb/mongodb": "^2.0", "monolog/monolog": "^2.0|^3.0", "nelmio/api-doc-bundle": "^5.9", - "symfony/cache": "^7.0", - "symfony/console": "^6.0|^7.0", - "symfony/dependency-injection": "^6.0|^7.0", - "symfony/dotenv": "^6.0|^7.0", - "symfony/event-dispatcher": "^6.0|^7.0", - "symfony/expression-language": "^6.0|^7.0", - "symfony/framework-bundle": "^6.0|^7.0", + "symfony/cache": "^7.0|^8.0", + "symfony/console": "^7.0|^8.0", + "symfony/dependency-injection": "^7.0|^8.0", + "symfony/dotenv": "^7.0|^8.0", + "symfony/event-dispatcher": "^7.0|^8.0", + "symfony/expression-language": "^7.0|^8.0", + "symfony/framework-bundle": "^7.0|^8.0", "symfony/http-client-contracts": "^3.1", - "symfony/http-kernel": "^6.0|^7.0", - "symfony/lock": "^6.0|^7.0", - "symfony/messenger": "^6.0|^7.0", + "symfony/http-kernel": "^7.0|^8.0", + "symfony/lock": "^7.0|^8.0", + "symfony/messenger": "^7.0|^8.0", "symfony/monolog-bundle": ">=3.9", "symfony/polyfill-uuid": "^1.23", - "symfony/runtime": "^6.0|^7.0", - "symfony/security-bundle": "^6.0|^7.0", - "symfony/uid": "^6.0|^7.0", - "symfony/validator": "^6.0|^7.0", + "symfony/runtime": "^7.0|^8.0", + "symfony/security-bundle": "^7.0|^8.0", + "symfony/uid": "^7.0|^8.0", + "symfony/validator": "^7.0|^8.0", "symfony/var-exporter": "^6.4|^7.0", - "symfony/yaml": "^6.0|^7.0" + "symfony/yaml": "^7.0|^8.0" }, "require-dev": { "doctrine/doctrine-bundle": "^2.4", @@ -53,7 +53,7 @@ "phpunit/phpunit": "^9.5", "slevomat/coding-standard": "8.20", "symfony/test-pack": "^1.0", - "symplify/easy-coding-standard": "^11.0", + "symplify/easy-coding-standard": "^13.0", "vimeo/psalm": "^6.10" }, "autoload": { diff --git a/ecs.php b/ecs.php index e302683..84c2785 100644 --- a/ecs.php +++ b/ecs.php @@ -1,7 +1,7 @@ import(SetList::CLEAN_CODE); - $ECSConfig->import(SetList::PSR_12); - $ECSConfig->import(SetList::COMMON); - - $parameters = $ECSConfig->parameters(); - $parameters->set(Option::PARALLEL, true); - $parameters->set(Option::DEBUG, true); - - $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, @@ -74,105 +61,75 @@ DoctrineAnnotationBracesFixer::class => null, NotOperatorWithSuccessorSpaceFixer::class => null, UselessParenthesesSniff::class => null, - PhpdocSeparationFixer::class => null, // some bug with infinity applied checker - MethodChainingIndentationFixer::class => ['DependencyInjection/*Configuration.php'], - 'SlevomatCodingStandard\Sniffs\Whitespaces\DuplicateSpacesSniff.DuplicateDeclareStrictTypesSpaces' => 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, - 'src/Model/Enum/*.php', - PhpCsFixer\Fixer\Import\NoUnusedImportsFixer::class => null // bug: removes usages of attributes if attributes are in one line i.e. #[OARequest, OAResponse] - ]); - - $services = $ECSConfig->services(); - - $services->set(NoSuperfluousPhpdocTagsFixer::class) - ->call('configure', [['remove_inheritdoc' => false, 'allow_mixed' => false]]); - - $services->set(ClassDefinitionFixer::class) - ->call('configure', [['multi_line_extends_each_single_line' => false]]); - - $services->set(ClassAttributesSeparationFixer::class) - ->call('configure', [['elements' => ['method', 'property']]]); - - $services->set(DocCommentSpacingSniff::class) - ->property('annotationsGroups', [ - '@inheritDoc', - '@template, @extends, @implements, @template-implements @template-extends', - '@var, @psalm-var, @param, @psalm-param', - '@return, @psalm-return', - '@throws', - '@psalm-suppress', - ]) - ; - - $services->set(MethodSpacingSniff::class); - $services->set(PropertySpacingSniff::class) - ->property('minLinesCountBeforeWithComment', 1) - ->property('maxLinesCountBeforeWithComment', 1) - ->property('maxLinesCountBeforeWithoutComment', 0); - - $services->set(UnusedUsesSniff::class) - ->property('searchAnnotations', true); - - $services->set(DeclareStrictTypesFixer::class); - $services->set(NoNullPropertyInitializationFixer::class); - $services->set(YodaStyleFixer::class); - $services->set(ArrowFunctionDeclarationSniff::class); - $services->set(StrictCallSniff::class); - $services->set(UseDoesNotStartWithBackslashSniff::class); - $services->set(AlphabeticallySortedUsesSniff::class); - $services->set(RequireNumericLiteralSeparatorSniff::class); - $services->set(UselessParenthesesSniff::class); - $services->set(RequireNullCoalesceOperatorSniff::class); - $services->set(ModernClassNameReferenceSniff::class); - $services->set(UselessInheritDocCommentSniff::class); - $services->set(UseFromSameNamespaceSniff::class); - $services->set(UnusedInheritedVariablePassedToClosureSniff::class); - $services->set(UselessConstantTypeHintSniff::class); - $services->set(DoctrineAnnotationArrayAssignmentFixer::class); - $services->set(DoctrineAnnotationIndentationFixer::class); - $services->set(DoctrineAnnotationSpacesFixer::class); - - $services->set(ForbiddenFunctionsSniff::class) - ->property('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, - ]); - - $services->set(ArraySyntaxFixer::class) - ->call('configure', [['syntax' => 'short']]); - - $services->set(ListSyntaxFixer::class) - ->call('configure', [['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/src/AnzuTap/AnzuTapBodyPostprocessor.php b/src/AnzuTap/AnzuTapBodyPostprocessor.php index a3f08a7..15baedb 100644 --- a/src/AnzuTap/AnzuTapBodyPostprocessor.php +++ b/src/AnzuTap/AnzuTapBodyPostprocessor.php @@ -1,5 +1,7 @@ removeInvalidNodes($body); } - protected function removeInvalidNodes(AnzuTapDocNode $body): void { $body->setContent(array_filter( @@ -54,7 +55,7 @@ protected function removeInvalidNodes(AnzuTapDocNode $body): void protected function fixParagraphs(AnzuTapNodeInterface $body): void { foreach ($body->getContent() as $node) { - if ($node->getType() === AnzuTapParagraphNode::NODE_NAME) { + if (AnzuTapParagraphNode::NODE_NAME === $node->getType()) { $this->fixNode($node, self::PARAGRAPH_ALLOWED_CONTENT_TYPES); } @@ -97,7 +98,7 @@ protected function shakeNodes(AnzuTapDocNode $body, array $nodeTypesToShake): vo // Check if root node was paragraph and after shaking, it lost content. foreach ($shakenNodes as $shakenNode) { if ($shakenNode === $node && - $shakenNode->getType() === AnzuTapParagraphNode::NODE_NAME && + AnzuTapParagraphNode::NODE_NAME === $shakenNode->getType() && 0 === count($shakenNode->getContent()) && 0 < $contentCount ) { diff --git a/src/AnzuTap/AnzuTapBodyPreprocessor.php b/src/AnzuTap/AnzuTapBodyPreprocessor.php index 5c91ab7..ccd868f 100644 --- a/src/AnzuTap/AnzuTapBodyPreprocessor.php +++ b/src/AnzuTap/AnzuTapBodyPreprocessor.php @@ -1,5 +1,7 @@ nodeName; - if ($nodeName === self::NODE_NAME_TH) { + if (self::NODE_NAME_TH === $nodeName) { return new AnzuTapTableHeaderNode(attrs: $attrs); } diff --git a/src/ApiFilter/ApiQuery.php b/src/ApiFilter/ApiQuery.php index 728eb75..240e51b 100644 --- a/src/ApiFilter/ApiQuery.php +++ b/src/ApiFilter/ApiQuery.php @@ -4,7 +4,6 @@ namespace AnzuSystems\CommonBundle\ApiFilter; -use Closure; use DateTime; use DateTimeImmutable; use Doctrine\DBAL\Types\Types; @@ -26,7 +25,6 @@ class ApiQuery */ protected array $customInnerFilters = []; - /** * @var array> */ @@ -44,7 +42,8 @@ public function __construct( protected EntityManagerInterface $entityManager, protected ClassMetadata $metadata, protected ApiParams $apiParams, - #[Deprecated] protected ?CustomFilterInterface $customFilter = null, + #[Deprecated] + protected ?CustomFilterInterface $customFilter = null, protected bool $fetchOneAdditionalRecord = false, protected array $customFilters = [], protected array $customOrders = [], diff --git a/src/DependencyInjection/AnzuSystemsCommonExtension.php b/src/DependencyInjection/AnzuSystemsCommonExtension.php index 3cdd190..efbc734 100644 --- a/src/DependencyInjection/AnzuSystemsCommonExtension.php +++ b/src/DependencyInjection/AnzuSystemsCommonExtension.php @@ -332,7 +332,7 @@ private function loadErrors(ContainerBuilder $container): void /** @psalm-var callable(class-string):bool $hasHandler */ $hasHandler = static fn (string $handler): bool => in_array($handler, $handlers, true); - $debug = $container->getParameter('kernel.environment') !== 'prod'; + $debug = 'prod' !== $container->getParameter('kernel.environment'); if (DefaultExceptionHandler::class === $errors['default_exception_handler']) { $definition = new Definition(DefaultExceptionHandler::class); diff --git a/src/Doctrine/Type/AbstractEnumType.php b/src/Doctrine/Type/AbstractEnumType.php index 6e0af25..81eb24d 100644 --- a/src/Doctrine/Type/AbstractEnumType.php +++ b/src/Doctrine/Type/AbstractEnumType.php @@ -1,5 +1,7 @@ */ + /** + * @var int<0, max> + */ private readonly int $noJobIdleTime, ) { } diff --git a/src/Domain/User/UserSyncFacade.php b/src/Domain/User/UserSyncFacade.php index c33b014..fc585c5 100644 --- a/src/Domain/User/UserSyncFacade.php +++ b/src/Domain/User/UserSyncFacade.php @@ -4,11 +4,8 @@ namespace AnzuSystems\CommonBundle\Domain\User; -use AnzuSystems\CommonBundle\Domain\AbstractManager; use AnzuSystems\CommonBundle\Exception\ValidationException; -use AnzuSystems\CommonBundle\Model\User\BaseUserDto; use AnzuSystems\CommonBundle\Model\User\UserDto; -use AnzuSystems\CommonBundle\Tests\Data\Entity\User; use AnzuSystems\CommonBundle\Validator\Validator; use AnzuSystems\Contracts\Entity\AnzuUser; use Doctrine\ORM\EntityManagerInterface; diff --git a/src/Helper/CollectionHelper.php b/src/Helper/CollectionHelper.php index 3e99c36..c22fb3e 100644 --- a/src/Helper/CollectionHelper.php +++ b/src/Helper/CollectionHelper.php @@ -8,7 +8,7 @@ use Closure; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; -use Symfony\Component\PropertyInfo\Type; +use Symfony\Component\TypeInfo\TypeIdentifier; use Traversable; class CollectionHelper @@ -28,12 +28,12 @@ public static function traversableToIds(Traversable $traversable, ?Closure $getI ); } - public static function arrayStringToArray(string $array, string $type = Type::BUILTIN_TYPE_INT): array + public static function arrayStringToArray(string $array, string $type = TypeIdentifier::INT->value): array { return array_map( fn (string $item): string|int|float => match ($type) { - Type::BUILTIN_TYPE_INT => (int) $item, - Type::BUILTIN_TYPE_FLOAT => (float) $item, + TypeIdentifier::INT->value => (int) $item, + TypeIdentifier::FLOAT->value => (float) $item, default => trim($item), }, explode(',', $array) diff --git a/src/Model/AnzuTap/EditorsConfiguration.php b/src/Model/AnzuTap/EditorsConfiguration.php index abe8ea4..5289e2b 100644 --- a/src/Model/AnzuTap/EditorsConfiguration.php +++ b/src/Model/AnzuTap/EditorsConfiguration.php @@ -1,5 +1,7 @@ value; $description['title'] = SerializerHelper::getClassBaseName(Geolocation::class); $description['properties'] = [ new Property([ 'property' => self::LON, 'title' => 'Longitude', 'type' => 'number', - 'format' => Type::BUILTIN_TYPE_FLOAT, + 'format' => TypeIdentifier::FLOAT->value, 'minimum' => -180, 'maximum' => 180, ]), @@ -89,7 +89,7 @@ public function describe(string $property, Metadata $metadata): array 'property' => self::LAT, 'title' => 'Latitude', 'type' => 'number', - 'format' => Type::BUILTIN_TYPE_FLOAT, + 'format' => TypeIdentifier::FLOAT->value, 'minimum' => -90, 'maximum' => 90, ]), diff --git a/src/Serializer/Handler/Handlers/ValueObjectHandler.php b/src/Serializer/Handler/Handlers/ValueObjectHandler.php index 8ca832c..bfb50a0 100644 --- a/src/Serializer/Handler/Handlers/ValueObjectHandler.php +++ b/src/Serializer/Handler/Handlers/ValueObjectHandler.php @@ -9,7 +9,7 @@ use AnzuSystems\SerializerBundle\Context\SerializationContext; use AnzuSystems\SerializerBundle\Handler\Handlers\AbstractHandler; use AnzuSystems\SerializerBundle\Metadata\Metadata; -use Symfony\Component\PropertyInfo\Type; +use Symfony\Component\TypeInfo\TypeIdentifier; final class ValueObjectHandler extends AbstractHandler { @@ -48,7 +48,7 @@ public function describe(string $property, Metadata $metadata): array /** @var AbstractValueObject $valueObjectClass */ $valueObjectClass = $metadata->type; $description['enum'] = $valueObjectClass::AVAILABLE_VALUES; - $description['type'] = Type::BUILTIN_TYPE_STRING; + $description['type'] = TypeIdentifier::STRING->value; $description['default'] = $valueObjectClass::DEFAULT_VALUE; return $description; diff --git a/src/Validator/Constraints/UniqueEntity.php b/src/Validator/Constraints/UniqueEntity.php index b35c23b..7936c01 100644 --- a/src/Validator/Constraints/UniqueEntity.php +++ b/src/Validator/Constraints/UniqueEntity.php @@ -14,9 +14,13 @@ final class UniqueEntity extends Constraint public string $message = ValidationException::ERROR_FIELD_UNIQUE; public function __construct( - /** @var non-empty-list */ + /** + * @var non-empty-list + */ public readonly array $fields, - /** @var list */ + /** + * @var list + */ public readonly array $errorAtPath = [], mixed $options = null, ?array $groups = null, diff --git a/src/Validator/Constraints/UniqueEntityDto.php b/src/Validator/Constraints/UniqueEntityDto.php index 1a8851d..9cf78af 100644 --- a/src/Validator/Constraints/UniqueEntityDto.php +++ b/src/Validator/Constraints/UniqueEntityDto.php @@ -14,11 +14,17 @@ final class UniqueEntityDto extends Constraint public string $message = ValidationException::ERROR_FIELD_UNIQUE; public function __construct( - /** @var class-string */ + /** + * @var class-string + */ public readonly string $entity, - /** @var non-empty-list */ + /** + * @var non-empty-list + */ public readonly array $fields, - /** @var list */ + /** + * @var list + */ public readonly array $errorAtPath = [], mixed $options = null, ?array $groups = null, diff --git a/src/Validator/Traits/EntityClassResolverTrait.php b/src/Validator/Traits/EntityClassResolverTrait.php index 1ff92f2..86ce1e8 100644 --- a/src/Validator/Traits/EntityClassResolverTrait.php +++ b/src/Validator/Traits/EntityClassResolverTrait.php @@ -20,7 +20,7 @@ trait EntityClassResolverTrait */ private function resolveEntityClass(string $entityClass): string { - if ($entityClass === AnzuUser::class) { + if (AnzuUser::class === $entityClass) { return $this->userEntityClass; } From 953c24ad2748089b66fa4203e82006636a73a1ec Mon Sep 17 00:00:00 2001 From: Ronald Marfoldi Date: Fri, 13 Feb 2026 09:39:32 +0100 Subject: [PATCH 2/3] Resolve deprecations for Symfony 8 --- bin/ecs | 8 +- tests/AnzuSerializer/AnzuSerializerTest.php | 106 +++++++++--------- tests/AnzuTap/AnzuTapTransformerTest.php | 44 ++++---- tests/AnzuTap/TestAnzuTapEditor.php | 2 + tests/Controller/AbstractControllerTest.php | 14 +-- tests/Controller/JobControllerTest.php | 4 +- tests/Controller/LogControllerTest.php | 7 +- .../ValueResolverControllerTest.php | 14 ++- tests/Doctrine/Type/DummyEnumType.php | 2 + tests/Helper/UuidHelperTest.php | 4 +- tests/bootstrap.php | 4 +- tests/config/services/services.php | 1 - tests/data/Controller/DummyController.php | 3 +- tests/data/Entity/ExampleJoinedEntity.php | 6 +- tests/data/Entity/User.php | 31 +++-- tests/data/Fixtures/ExampleFixtures.php | 1 - 16 files changed, 131 insertions(+), 120 deletions(-) diff --git a/bin/ecs b/bin/ecs index 7aa1d12..849d834 100755 --- a/bin/ecs +++ b/bin/ecs @@ -1,15 +1,13 @@ #!/bin/bash -# Script used to run ECS check in the application docker container +# Script used to run ECS check in the application container PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)" -CHECK_DIR=${1:-src} cd "${PROJECT_ROOT}" || exit 1 if [ -f /.dockerenv ]; then - echo "[INFO] Running ECS check" - vendor/bin/ecs check --fix --config=ecs.php "${CHECK_DIR}" + vendor/bin/ecs check --fix --config=ecs.php exit fi -bin/docker-compose run --rm app bash -c \'bin/ecs "${CHECK_DIR}"\' +bin/docker-compose run --rm app bash -c \'bin/ecs\' diff --git a/tests/AnzuSerializer/AnzuSerializerTest.php b/tests/AnzuSerializer/AnzuSerializerTest.php index 7f725d6..47bf43a 100644 --- a/tests/AnzuSerializer/AnzuSerializerTest.php +++ b/tests/AnzuSerializer/AnzuSerializerTest.php @@ -62,59 +62,59 @@ public function serializeProvider(): array return [ [ - (new SerializerTestDto()) - ->setName('test') - ->setPosition(1) - ->setDummyDto((new DummyDto())->setData('bla')) - ->setDummyValueObject(new DummyValueObject(DummyValueObject::ANZU)) - ->setDummyEnum(DummyEnum::StateTwo) - ->setCreatedAt(new DateTimeImmutable('1986-08-04T23:28:12Z')) - ->setCreatedAtFormat1(new DateTimeImmutable('1986-08-04T23:28:12Z')) - ->setItems($itemsWithKeys) - ->setItemsKeysValues($itemsWithKeys) - ->setItemsArray($itemsWithKeys->toArray()) - ->setItemsArrayKeysValues($itemsWithKeys->toArray()), - '{' - . '"name":"test",' - . '"position":1,' - . '"dummyDto":{"data":"bla"},' - . '"createdAt":"1986-08-04T23:28:12.000000Z",' - . '"createdAtFormat1":"04.08.1986 23:28:12",' - . '"dummyValueObject":"anzu",' - . '"dummyEnum":"state_two",' - . '"items":[{"data":"one"},{"data":"two"},{"data":"three"}],' - . '"itemsKeysValues":{"A":{"data":"one"},"B":{"data":"two"},"C":{"data":"three"}},' - . '"itemsArray":[{"data":"one"},{"data":"two"},{"data":"three"}],' - . '"itemsArrayKeysValues":{"A":{"data":"one"},"B":{"data":"two"},"C":{"data":"three"}},' - . '"createdAtTimestamp":523582092' - . '}' - ],[ - (new SerializerTestDto()) - ->setName('test') - ->setPosition(1) - ->setDummyDto((new DummyDto())->setData('bla')) - ->setDummyValueObject(new DummyValueObject(DummyValueObject::ANZU)) - ->setDummyEnum(DummyEnum::StateTwo) - ->setCreatedAt(new DateTimeImmutable('1986-08-04T23:28:12Z')) - ->setCreatedAtFormat1(new DateTimeImmutable('1986-08-04T23:28:12Z')) - ->setItems($items) - ->setItemsArray($items->toArray()) - ->setItemsKeysValues($items) - ->setItemsArrayKeysValues($items->toArray()), - '{' - . '"name":"test",' - . '"position":1,' - . '"dummyDto":{"data":"bla"},' - . '"createdAt":"1986-08-04T23:28:12.000000Z",' - . '"createdAtFormat1":"04.08.1986 23:28:12",' - . '"dummyValueObject":"anzu",' - . '"dummyEnum":"state_two",' - . '"items":[{"data":"one"},{"data":"two"},{"data":"three"}],' - . '"itemsKeysValues":[{"data":"one"},{"data":"two"},{"data":"three"}],' - . '"itemsArray":[{"data":"one"},{"data":"two"},{"data":"three"}],' - . '"itemsArrayKeysValues":[{"data":"one"},{"data":"two"},{"data":"three"}],' - . '"createdAtTimestamp":523582092' - . '}' + (new SerializerTestDto()) + ->setName('test') + ->setPosition(1) + ->setDummyDto((new DummyDto())->setData('bla')) + ->setDummyValueObject(new DummyValueObject(DummyValueObject::ANZU)) + ->setDummyEnum(DummyEnum::StateTwo) + ->setCreatedAt(new DateTimeImmutable('1986-08-04T23:28:12Z')) + ->setCreatedAtFormat1(new DateTimeImmutable('1986-08-04T23:28:12Z')) + ->setItems($itemsWithKeys) + ->setItemsKeysValues($itemsWithKeys) + ->setItemsArray($itemsWithKeys->toArray()) + ->setItemsArrayKeysValues($itemsWithKeys->toArray()), + '{' + . '"name":"test",' + . '"position":1,' + . '"dummyDto":{"data":"bla"},' + . '"createdAt":"1986-08-04T23:28:12.000000Z",' + . '"createdAtFormat1":"04.08.1986 23:28:12",' + . '"dummyValueObject":"anzu",' + . '"dummyEnum":"state_two",' + . '"items":[{"data":"one"},{"data":"two"},{"data":"three"}],' + . '"itemsKeysValues":{"A":{"data":"one"},"B":{"data":"two"},"C":{"data":"three"}},' + . '"itemsArray":[{"data":"one"},{"data":"two"},{"data":"three"}],' + . '"itemsArrayKeysValues":{"A":{"data":"one"},"B":{"data":"two"},"C":{"data":"three"}},' + . '"createdAtTimestamp":523582092' + . '}', + ], [ + (new SerializerTestDto()) + ->setName('test') + ->setPosition(1) + ->setDummyDto((new DummyDto())->setData('bla')) + ->setDummyValueObject(new DummyValueObject(DummyValueObject::ANZU)) + ->setDummyEnum(DummyEnum::StateTwo) + ->setCreatedAt(new DateTimeImmutable('1986-08-04T23:28:12Z')) + ->setCreatedAtFormat1(new DateTimeImmutable('1986-08-04T23:28:12Z')) + ->setItems($items) + ->setItemsArray($items->toArray()) + ->setItemsKeysValues($items) + ->setItemsArrayKeysValues($items->toArray()), + '{' + . '"name":"test",' + . '"position":1,' + . '"dummyDto":{"data":"bla"},' + . '"createdAt":"1986-08-04T23:28:12.000000Z",' + . '"createdAtFormat1":"04.08.1986 23:28:12",' + . '"dummyValueObject":"anzu",' + . '"dummyEnum":"state_two",' + . '"items":[{"data":"one"},{"data":"two"},{"data":"three"}],' + . '"itemsKeysValues":[{"data":"one"},{"data":"two"},{"data":"three"}],' + . '"itemsArray":[{"data":"one"},{"data":"two"},{"data":"three"}],' + . '"itemsArrayKeysValues":[{"data":"one"},{"data":"two"},{"data":"three"}],' + . '"createdAtTimestamp":523582092' + . '}', ], ]; } diff --git a/tests/AnzuTap/AnzuTapTransformerTest.php b/tests/AnzuTap/AnzuTapTransformerTest.php index ed83e38..6cdfbd5 100644 --- a/tests/AnzuTap/AnzuTapTransformerTest.php +++ b/tests/AnzuTap/AnzuTapTransformerTest.php @@ -1,5 +1,7 @@ editor = static::getContainer()->get(TestAnzuTapEditor::class); } @@ -32,7 +34,7 @@ public function transformerDataProvider(): array [ 'type' => 'paragraph', 'attrs' => [ - 'anchor' => 'pp-1' + 'anchor' => 'pp-1', ], 'content' => [ ['type' => 'text', 'marks' => [ @@ -43,11 +45,11 @@ public function transformerDataProvider(): array 'external' => false, ]], ], - 'text' => 'Anchor link' + 'text' => 'Anchor link', ], - ] - ] - ]] + ], + ], + ]], ], [ 'html' => 'Simple Text double italic', @@ -57,9 +59,9 @@ public function transformerDataProvider(): array 'content' => [ ['type' => 'text', 'text' => 'Simple Text '], ['type' => 'text', 'marks' => [['type' => 'italic'], ['type' => 'bold']], 'text' => 'double italic'], - ] - ] - ]] + ], + ], + ]], ], [ 'html' => '
  • li1
  • li2
  • ', @@ -69,17 +71,17 @@ public function transformerDataProvider(): array 'content' => [ ['type' => 'listItem', 'content' => [ ['type' => 'paragraph', 'content' => [ - ['type' => 'text', 'text' => 'li1'] - ]] + ['type' => 'text', 'text' => 'li1'], + ]], ]], ['type' => 'listItem', 'content' => [ ['type' => 'paragraph', 'content' => [ - ['type' => 'text', 'text' => 'li2'] - ]] - ]] - ] - ] - ]] + ['type' => 'text', 'text' => 'li2'], + ]], + ]], + ], + ], + ]], ], [ 'html' => '

    Text before jolo@sme.sk.

    ', @@ -95,12 +97,12 @@ public function transformerDataProvider(): array 'variant' => 'email', ]], ], - 'text' => 'jolo@sme.sk' + 'text' => 'jolo@sme.sk', ], ['type' => 'text', 'marks' => [['type' => 'italic']], 'text' => '.'], - ] - ] - ]] + ], + ], + ]], ], ]; } diff --git a/tests/AnzuTap/TestAnzuTapEditor.php b/tests/AnzuTap/TestAnzuTapEditor.php index 5cb8355..0e8c7e9 100644 --- a/tests/AnzuTap/TestAnzuTapEditor.php +++ b/tests/AnzuTap/TestAnzuTapEditor.php @@ -1,5 +1,7 @@ serializer = self::getContainer()->get(Serializer::class); } + protected function tearDown(): void + { + self::getContainer()->get('doctrine.orm.entity_manager')->detach($this->user); + parent::tearDown(); + } + protected function loginUser(array $roles = []): void { $this->user = (new User())->setId(AnzuApp::getUserIdAnonymous())->setRoles($roles); @@ -123,10 +129,4 @@ protected function deserializeResponse(string $deserializationClass = null): obj $deserializationClass ); } - - protected function tearDown(): void - { - self::getContainer()->get('doctrine.orm.entity_manager')->detach($this->user); - parent::tearDown(); - } } diff --git a/tests/Controller/JobControllerTest.php b/tests/Controller/JobControllerTest.php index 08b046b..f1b296e 100644 --- a/tests/Controller/JobControllerTest.php +++ b/tests/Controller/JobControllerTest.php @@ -26,7 +26,9 @@ public function testCrud(): void ->setAnonymizeUser(true) ; $response = $this->post('/job/user-data-delete', $job); - $this->assertValidationErrors($response, ['targetUserId' => [EntityExists::MESSAGE]]); + $this->assertValidationErrors($response, [ + 'targetUserId' => [EntityExists::MESSAGE], + ]); // 1.b Creation successfully $job = (new JobUserDataDelete()) diff --git a/tests/Controller/LogControllerTest.php b/tests/Controller/LogControllerTest.php index e43eec2..0387e1c 100644 --- a/tests/Controller/LogControllerTest.php +++ b/tests/Controller/LogControllerTest.php @@ -6,7 +6,6 @@ use AnzuSystems\CommonBundle\ApiFilter\ApiResponseList; use AnzuSystems\CommonBundle\Document\Log; -use AnzuSystems\CommonBundle\Document\LogContext; use AnzuSystems\CommonBundle\Log\Factory\LogContextFactory; use AnzuSystems\CommonBundle\Log\Model\LogDto; use AnzuSystems\Contracts\Model\Enum\LogLevel; @@ -28,7 +27,7 @@ public function testJournalLogs(): void self::assertContainsOnlyInstancesOf(Log::class, $response->getData()); $log = $response->getData()[0]; - $response = $this->get(uri: '/log/journal/' .$log->getId(), deserializationClass: Log::class); + $response = $this->get(uri: '/log/journal/' . $log->getId(), deserializationClass: Log::class); self::assertResponseIsSuccessful(); self::assertSame($response->getId(), $log->getId()); } @@ -45,7 +44,7 @@ public function testAuditLogs(): void self::assertContainsOnlyInstancesOf(Log::class, $response->getData()); $log = $response->getData()[0]; - $response = $this->get(uri: '/log/audit/' .$log->getId(), deserializationClass: Log::class); + $response = $this->get(uri: '/log/audit/' . $log->getId(), deserializationClass: Log::class); self::assertResponseIsSuccessful(); self::assertSame($response->getId(), $log->getId()); self::assertSame('test', $log->getContext()->getResourceName()); @@ -72,7 +71,7 @@ public function testCustomLog(): void self::assertEquals($logDto->getContextId(), $log->getContext()->getContextId()); $filterLog = [ - 'filter_eq' => ['context.contextId' => $log->getContext()->getContextId()] + 'filter_eq' => ['context.contextId' => $log->getContext()->getContextId()], ]; $logs = $this->getList('/log/journal', Log::class, $filterLog); /** @var Log $foundLog */ diff --git a/tests/Controller/ValueResolverControllerTest.php b/tests/Controller/ValueResolverControllerTest.php index 08efa6f..5462eff 100644 --- a/tests/Controller/ValueResolverControllerTest.php +++ b/tests/Controller/ValueResolverControllerTest.php @@ -59,15 +59,23 @@ public function testApiFilterValueResolver(): void 'limit' => 50, 'offset' => 10, 'bigTable' => false, - 'filter_' . ApiParams::FILTER_EQ => ['test' => 'rest'], - 'order' => ['id' => 'desc'], + 'filter_' . ApiParams::FILTER_EQ => [ + 'test' => 'rest', + ], + 'order' => [ + 'id' => 'desc', + ], ], ); self::assertResponseIsSuccessful(); self::assertSame(50, $response->getLimit()); self::assertSame(10, $response->getOffset()); self::assertFalse($response->isBigTable()); - self::assertSame([ApiParams::FILTER_EQ => ['test' => 'rest']], $response->getFilter()); + self::assertSame([ + ApiParams::FILTER_EQ => [ + 'test' => 'rest', + ], + ], $response->getFilter()); self::assertSame(['id' => 'desc'], $response->getOrder()); } diff --git a/tests/Doctrine/Type/DummyEnumType.php b/tests/Doctrine/Type/DummyEnumType.php index 02ca103..e0c920c 100644 --- a/tests/Doctrine/Type/DummyEnumType.php +++ b/tests/Doctrine/Type/DummyEnumType.php @@ -1,5 +1,7 @@ setId(10) + ->setId(10), ], [ 'user0000-test-0000-0000-000999999999', (new User()) - ->setId(999_999_999) + ->setId(999_999_999), ], ]; } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index dffb7cb..1f3899b 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -8,9 +8,9 @@ use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Dotenv\Dotenv; -require dirname(__DIR__).'/vendor/autoload.php'; +require dirname(__DIR__) . '/vendor/autoload.php'; -(new Dotenv())->bootEnv(dirname(__DIR__).'/.env'); +(new Dotenv())->bootEnv(dirname(__DIR__) . '/.env'); $kernel = new AnzuTestKernel( appNamespace: 'petitpress', diff --git a/tests/config/services/services.php b/tests/config/services/services.php index 7bb8f9c..0330f15 100644 --- a/tests/config/services/services.php +++ b/tests/config/services/services.php @@ -15,7 +15,6 @@ use AnzuSystems\CommonBundle\Tests\Data\Repository\UserRepository; use AnzuSystems\CommonBundle\Util\ResourceLocker; use AnzuSystems\SerializerBundle\Serializer; -use App\Tests\AnzuTap\ArtemisAnzuTapEditor; use Doctrine\ORM\EntityManagerInterface; use Doctrine\Persistence\ManagerRegistry; use Redis; diff --git a/tests/data/Controller/DummyController.php b/tests/data/Controller/DummyController.php index 4e140aa..32db101 100644 --- a/tests/data/Controller/DummyController.php +++ b/tests/data/Controller/DummyController.php @@ -56,7 +56,8 @@ public function apiFilterValueResolverTest(ApiParams $dummy): JsonResponse #[Route('/value-resolver/array-string/{dummy}', methods: [Request::METHOD_GET])] public function apiFilterConverterTest( - #[ArrayStringParam(itemsLimit: 3, itemNormalizer: 'intval', separator: ',')] array $dummy, + #[ArrayStringParam(itemsLimit: 3, itemNormalizer: 'intval', separator: ',')] + array $dummy, ): JsonResponse { return $this->okResponse($dummy); } diff --git a/tests/data/Entity/ExampleJoinedEntity.php b/tests/data/Entity/ExampleJoinedEntity.php index 6ca6571..5c34ab4 100644 --- a/tests/data/Entity/ExampleJoinedEntity.php +++ b/tests/data/Entity/ExampleJoinedEntity.php @@ -30,7 +30,7 @@ public function __construct() { $this->setId(0); $this->setName(''); - $this->setJoinedEntity(new ExampleJoinedEntity()); + $this->setJoinedEntity(new self()); } public function getId(): int @@ -55,12 +55,12 @@ public function setName(string $name): self return $this; } - public function getJoinedEntity(): ExampleJoinedEntity + public function getJoinedEntity(): self { return $this->joinedEntity; } - public function setJoinedEntity(ExampleJoinedEntity $joinedEntity): self + public function setJoinedEntity(self $joinedEntity): self { $this->joinedEntity = $joinedEntity; diff --git a/tests/data/Entity/User.php b/tests/data/Entity/User.php index e52d798..7ba2956 100644 --- a/tests/data/Entity/User.php +++ b/tests/data/Entity/User.php @@ -16,18 +16,17 @@ #[ORM\Entity(repositoryClass: UserRepository::class)] class User extends AnzuUser implements CopyableInterface { - #[ORM\Column(type: Types::STRING)] - private string $name; - /** * Assigned permission groups. * * Override in your project to get relations: */ - #[ORM\ManyToMany(targetEntity: PermissionGroup::class, inversedBy: 'users', fetch: 'EXTRA_LAZY', indexBy: 'id')] - #[ORM\JoinTable] - #[Serialize(handler: EntityIdHandler::class, type: PermissionGroup::class)] + #[ORM\ManyToMany(targetEntity: PermissionGroup::class, inversedBy: 'users', fetch: 'EXTRA_LAZY', indexBy: 'id')] + #[ORM\JoinTable] + #[Serialize(handler: EntityIdHandler::class, type: PermissionGroup::class)] protected Collection $permissionGroups; + #[ORM\Column(type: Types::STRING)] + private string $name; public function __construct() { @@ -38,6 +37,15 @@ public function __construct() $this->setEnabled(true); } + public function __copy(): self + { + return (new self()) + ->setName('Tester') + ->setRoles([]) + ->setEnabled(false) + ; + } + public function getUsername(): string { return $this->getUserIdentifier(); @@ -53,19 +61,10 @@ public function getName(): string return $this->name; } - public function setName(string $name): User + public function setName(string $name): self { $this->name = $name; return $this; } - - public function __copy(): self - { - return (new self()) - ->setName('Tester') - ->setRoles([]) - ->setEnabled(false) - ; - } } diff --git a/tests/data/Fixtures/ExampleFixtures.php b/tests/data/Fixtures/ExampleFixtures.php index 2b777dd..bd46319 100644 --- a/tests/data/Fixtures/ExampleFixtures.php +++ b/tests/data/Fixtures/ExampleFixtures.php @@ -6,7 +6,6 @@ use AnzuSystems\CommonBundle\AnzuSystemsCommonBundle; use AnzuSystems\CommonBundle\DataFixtures\Fixtures\AbstractFixtures; -use AnzuSystems\CommonBundle\DataFixtures\Interfaces\FixturesInterface; use AnzuSystems\CommonBundle\Tests\Data\Entity\Example; use AnzuSystems\CommonBundle\Tests\Data\Model\Enum\DummyEnum; use Generator; From f715fb704b7b1700bd6ff94d090b2cc11987852c Mon Sep 17 00:00:00 2001 From: Ronald Marfoldi Date: Fri, 13 Feb 2026 09:41:10 +0100 Subject: [PATCH 3/3] Resolve deprecations for Symfony 8 --- tests/data/Entity/User.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/data/Entity/User.php b/tests/data/Entity/User.php index 7ba2956..634a415 100644 --- a/tests/data/Entity/User.php +++ b/tests/data/Entity/User.php @@ -25,6 +25,7 @@ class User extends AnzuUser implements CopyableInterface #[ORM\JoinTable] #[Serialize(handler: EntityIdHandler::class, type: PermissionGroup::class)] protected Collection $permissionGroups; + #[ORM\Column(type: Types::STRING)] private string $name;