From 15c538bce7ce18019e7aca27cebc13407cd38684 Mon Sep 17 00:00:00 2001 From: Xavier Marchegay Date: Tue, 9 Dec 2025 15:48:00 +0100 Subject: [PATCH 1/3] =?UTF-8?q?#40=20-=20Mise=20=C3=A0=20jour=20de=20la=20?= =?UTF-8?q?configuration=20pour=20PHP=208.5=20et=20ajustements=20divers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docker/php/Dockerfile | 5 +- .php-cs-fixer.dist.php | 5 +- composer.json | 46 +++++++++---------- phpunit.xml.dist | 21 ++++----- rector.php | 6 +-- src/Controller/Admin/Process/LaunchAction.php | 4 +- .../Admin/Process/UploadAndExecuteAction.php | 2 +- src/Entity/ProcessSchedule.php | 7 +-- .../ProcessEventSubscriber.php | 11 ++--- src/Http/Model/HttpProcessExecution.php | 13 ++---- .../HttpProcessExecuteValueResolver.php | 7 +-- .../ProcessConfigurationValueResolver.php | 9 ++-- src/Manager/ProcessConfigurationsManager.php | 7 +-- src/Message/CronProcessMessage.php | 7 +-- src/Message/CronProcessMessageHandler.php | 7 +-- src/Message/ProcessExecuteHandler.php | 7 +-- src/Message/ProcessExecuteMessage.php | 7 +-- src/Scheduler/CronScheduler.php | 11 ++--- .../HttpProcessExecutionAuthenticator.php | 2 +- .../ProcessExecutionExtensionRuntime.php | 9 ++-- 20 files changed, 74 insertions(+), 119 deletions(-) diff --git a/.docker/php/Dockerfile b/.docker/php/Dockerfile index 33dd796..82be215 100644 --- a/.docker/php/Dockerfile +++ b/.docker/php/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.4-fpm-alpine +FROM php:8.5-fpm-alpine ARG UID ARG GID @@ -13,8 +13,7 @@ RUN apk update && apk add \ bash \ icu-dev \ && docker-php-ext-configure intl \ - && docker-php-ext-install intl opcache \ - && docker-php-ext-enable opcache + && docker-php-ext-install intl RUN ln -s /usr/share/zoneinfo/Europe/Paris /etc/localtime \ && sed -i "s/^;date.timezone =.*/date.timezone = Europe\/Paris/" $PHP_INI_DIR/php.ini diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index ed5c8c5..d097551 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -24,9 +24,8 @@ return (new PhpCsFixer\Config()) ->setRules([ - '@PHP71Migration' => true, - '@PHP82Migration' => true, - '@PHPUnit75Migration:risky' => true, + '@PHP8x2Migration' => true, + '@PHPUnit7x5Migration:risky' => true, '@Symfony' => true, '@Symfony:risky' => true, '@DoctrineAnnotation' => true, diff --git a/composer.json b/composer.json index cb0eff3..6204644 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ { "name": "Xavier Marchegay", "email": "xmarchegay@clever-age.com", - "role": "Developer" + "role": "Lead Developer" } ], "autoload": { @@ -36,24 +36,24 @@ } }, "require": { - "php": ">=8.1", + "php": ">=8.2", "ext-ctype": "*", "ext-iconv": "*", - "cleverage/process-bundle": "^4.0", - "doctrine/common": "^3.0", - "doctrine/dbal": "^2.9 || ^3.0", - "doctrine/doctrine-bundle": "^2.5", - "doctrine/doctrine-migrations-bundle": "^3.2", - "doctrine/orm": "^2.9 || ^3.0", - "dragonmantank/cron-expression": "^3.4", - "easycorp/easyadmin-bundle": "^4.8", - "symfony/doctrine-messenger": "^6.4|^7.3", - "symfony/dotenv": "^6.4|^7.3", - "symfony/messenger": "^6.4|^7.3", - "symfony/runtime": "^6.4|^7.3", - "symfony/scheduler": "^6.4|^7.3", - "symfony/string": "^6.4|^7.3", - "symfony/uid": "^6.4|^7.3" + "cleverage/process-bundle": "^5.0", + "doctrine/common": "^3.5", + "doctrine/dbal": "^3.10 || ^4.4", + "doctrine/doctrine-bundle": "^2.18 || ^3.1", + "doctrine/doctrine-migrations-bundle": "^3.7 || ^4", + "doctrine/orm": "^2.20 || ^3.5", + "dragonmantank/cron-expression": "^3.6", + "easycorp/easyadmin-bundle": "^4.27", + "symfony/doctrine-messenger": "^6.4 || ^7.4 || ^8", + "symfony/dotenv": "^6.4 || ^7.4 || ^8", + "symfony/messenger":"^6.4 || ^7.4 || ^8", + "symfony/runtime": "^6.4 || ^7.4 || ^8", + "symfony/scheduler": "^6.4 || ^7.4 || ^8", + "symfony/string":"^6.4 || ^7.4 || ^8", + "symfony/uid": "^6.4 || ^7.4 || ^8" }, "require-dev": { "doctrine/doctrine-fixtures-bundle": "^3.4", @@ -62,15 +62,15 @@ "phpstan/phpstan": "*", "phpstan/phpstan-doctrine": "*", "phpstan/phpstan-symfony": "*", - "phpunit/phpunit": "<10.0", + "phpunit/phpunit": "*", "rector/rector": "*", "roave/security-advisories": "dev-latest", - "symfony/browser-kit": "^6.4|^7.3", - "symfony/css-selector": "^6.4|^7.3", - "symfony/debug-bundle": "^6.4|^7.3", + "symfony/browser-kit": "^6.4 || ^7.4 || ^8", + "symfony/css-selector": "^6.4 || ^7.4 || ^8", + "symfony/debug-bundle": "^6.4 || ^7.4 || ^8", "symfony/maker-bundle": "^1.31", - "symfony/web-profiler-bundle": "^6.4|^7.3", - "vincentlanglet/twig-cs-fixer": "^3.3" + "symfony/web-profiler-bundle": "^6.4 || ^7.4 || ^8", + "vincentlanglet/twig-cs-fixer": "^3.11" }, "conflict": { "symfony/twig-bridge": "7.2.0", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 766495c..c3e7947 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,27 +1,22 @@ + failOnWarning="true"> tests - - + src - - + + \ No newline at end of file diff --git a/rector.php b/rector.php index 9f9d327..ed9c222 100644 --- a/rector.php +++ b/rector.php @@ -8,18 +8,18 @@ use Rector\ValueObject\PhpVersion; return RectorConfig::configure() - ->withPhpVersion(PhpVersion::PHP_84) + ->withPhpVersion(PhpVersion::PHP_85) ->withPaths([ __DIR__.'/src', __DIR__.'/tests', ]) - ->withPhpSets(php81: true) + ->withPhpSets(php82: true) // here we can define, what prepared sets of rules will be applied ->withComposerBased(doctrine: true) ->withPreparedSets(deadCode: true, codeQuality: true, doctrineCodeQuality: true, symfonyCodeQuality: true) ->withAttributesSets(symfony: true, doctrine: true) ->withSets([ - LevelSetList::UP_TO_PHP_81, + LevelSetList::UP_TO_PHP_85, SymfonySetList::SYMFONY_64, SymfonySetList::SYMFONY_CODE_QUALITY, SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION, diff --git a/src/Controller/Admin/Process/LaunchAction.php b/src/Controller/Admin/Process/LaunchAction.php index 8f6bed5..78adcf2 100644 --- a/src/Controller/Admin/Process/LaunchAction.php +++ b/src/Controller/Admin/Process/LaunchAction.php @@ -50,8 +50,8 @@ public function __invoke( ProcessConfigurationsManager $processConfigurationsManager, AdminContext $context, ): Response { - $processCode = $requestStack->getMainRequest()?->get('process'); - if (null === $processCode) { + $processCode = (string) $requestStack->getMainRequest()?->request->get('process'); + if ('' === $processCode) { throw new MissingProcessException(); } $uiOptions = $processConfigurationsManager->getUiOptions($processCode); diff --git a/src/Controller/Admin/Process/UploadAndExecuteAction.php b/src/Controller/Admin/Process/UploadAndExecuteAction.php index 8392263..2255892 100644 --- a/src/Controller/Admin/Process/UploadAndExecuteAction.php +++ b/src/Controller/Admin/Process/UploadAndExecuteAction.php @@ -49,7 +49,7 @@ public function __invoke( $form = $this->createForm( ProcessUploadFileType::class, null, - ['process_code' => $requestStack->getMainRequest()?->get('process')] + ['process_code' => $requestStack->getMainRequest()?->request->get('process')] ); $form->handleRequest($requestStack->getMainRequest()); if ($form->isSubmitted() && $form->isValid()) { diff --git a/src/Entity/ProcessSchedule.php b/src/Entity/ProcessSchedule.php index 2132202..8eea928 100644 --- a/src/Entity/ProcessSchedule.php +++ b/src/Entity/ProcessSchedule.php @@ -87,12 +87,7 @@ public function setContext(array $context): void $this->context = $context; } - /** - * PHP 8.1 Fatal error: Null can not be used as a standalone type. - * - * @phpstan-ignore missingType.return - */ - public function getNextExecution() + public function getNextExecution(): null { return null; } diff --git a/src/EventSubscriber/ProcessEventSubscriber.php b/src/EventSubscriber/ProcessEventSubscriber.php index 66e3f4f..2631b0f 100644 --- a/src/EventSubscriber/ProcessEventSubscriber.php +++ b/src/EventSubscriber/ProcessEventSubscriber.php @@ -22,15 +22,12 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Uid\Uuid; -/** - * PHP 8.2 : Replace by readonly class. - */ -final class ProcessEventSubscriber implements EventSubscriberInterface +readonly final class ProcessEventSubscriber implements EventSubscriberInterface { public function __construct( - private readonly ProcessHandler $processHandler, - private readonly DoctrineProcessHandler $doctrineProcessHandler, - private readonly ProcessExecutionManager $processExecutionManager, + private ProcessHandler $processHandler, + private DoctrineProcessHandler $doctrineProcessHandler, + private ProcessExecutionManager $processExecutionManager, ) { } diff --git a/src/Http/Model/HttpProcessExecution.php b/src/Http/Model/HttpProcessExecution.php index 7ae3e92..3c78a4a 100644 --- a/src/Http/Model/HttpProcessExecution.php +++ b/src/Http/Model/HttpProcessExecution.php @@ -20,21 +20,18 @@ use Symfony\Component\Validator\Constraints\Sequentially; use Symfony\Component\Validator\Constraints\Type; -/** - * PHP 8.2 : Replace by readonly class. - */ -final class HttpProcessExecution +final readonly class HttpProcessExecution { /** * @param string|array $context */ public function __construct( #[Sequentially(constraints: [new NotNull(message: 'Process code is required.'), new IsValidProcessCode()])] - public readonly ?string $code = null, - public readonly ?string $input = null, + public ?string $code = null, + public ?string $input = null, #[AtLeastOneOf(constraints: [new Json(), new Type('array')])] - public readonly string|array $context = [], - public readonly bool $queue = true, + public string|array $context = [], + public bool $queue = true, ) { } } diff --git a/src/Http/ValueResolver/HttpProcessExecuteValueResolver.php b/src/Http/ValueResolver/HttpProcessExecuteValueResolver.php index d1689b2..31ee50a 100644 --- a/src/Http/ValueResolver/HttpProcessExecuteValueResolver.php +++ b/src/Http/ValueResolver/HttpProcessExecuteValueResolver.php @@ -22,13 +22,10 @@ use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; use Symfony\Component\Serializer\SerializerInterface; -/** - * PHP 8.2 : Replace by readonly class. - */ #[AsTargetedValueResolver('http_process_execution')] -class HttpProcessExecuteValueResolver implements ValueResolverInterface +readonly class HttpProcessExecuteValueResolver implements ValueResolverInterface { - public function __construct(private readonly string $storageDir, private readonly SerializerInterface $serializer) + public function __construct(private string $storageDir, private SerializerInterface $serializer) { } diff --git a/src/Http/ValueResolver/ProcessConfigurationValueResolver.php b/src/Http/ValueResolver/ProcessConfigurationValueResolver.php index ef06496..39325da 100644 --- a/src/Http/ValueResolver/ProcessConfigurationValueResolver.php +++ b/src/Http/ValueResolver/ProcessConfigurationValueResolver.php @@ -20,13 +20,10 @@ use Symfony\Component\HttpKernel\Controller\ValueResolverInterface; use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata; -/** - * PHP 8.2 : Replace by readonly class. - */ #[AsTargetedValueResolver('process')] -class ProcessConfigurationValueResolver implements ValueResolverInterface +readonly class ProcessConfigurationValueResolver implements ValueResolverInterface { - public function __construct(private readonly ProcessConfigurationRegistry $registry) + public function __construct(private ProcessConfigurationRegistry $registry) { } @@ -35,6 +32,6 @@ public function __construct(private readonly ProcessConfigurationRegistry $regis */ public function resolve(Request $request, ArgumentMetadata $argument): iterable { - return [$this->registry->getProcessConfiguration($request->get('process'))]; + return [$this->registry->getProcessConfiguration((string)$request->request->get('process'))]; } } diff --git a/src/Manager/ProcessConfigurationsManager.php b/src/Manager/ProcessConfigurationsManager.php index 00ad111..dd962af 100644 --- a/src/Manager/ProcessConfigurationsManager.php +++ b/src/Manager/ProcessConfigurationsManager.php @@ -20,9 +20,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Validator\Constraint; -/** - * PHP 8.2 : Replace by readonly class. - */ /** * @phpstan-type UiOptions array{ * 'source': ?string, @@ -35,9 +32,9 @@ * 'default': array{'input': mixed, 'context': array{array{'key': 'int|text', 'value':'int|text'}}} * } */ -final class ProcessConfigurationsManager +readonly final class ProcessConfigurationsManager { - public function __construct(private readonly ProcessConfigurationRegistry $registry) + public function __construct(private ProcessConfigurationRegistry $registry) { } diff --git a/src/Message/CronProcessMessage.php b/src/Message/CronProcessMessage.php index a8449d7..2c1b97d 100644 --- a/src/Message/CronProcessMessage.php +++ b/src/Message/CronProcessMessage.php @@ -15,12 +15,9 @@ use CleverAge\UiProcessBundle\Entity\ProcessSchedule; -/** - * PHP 8.2 : Replace by readonly class. - */ -final class CronProcessMessage +readonly final class CronProcessMessage { - public function __construct(public readonly ProcessSchedule $processSchedule) + public function __construct(public ProcessSchedule $processSchedule) { } } diff --git a/src/Message/CronProcessMessageHandler.php b/src/Message/CronProcessMessageHandler.php index 285742a..6e370d2 100644 --- a/src/Message/CronProcessMessageHandler.php +++ b/src/Message/CronProcessMessageHandler.php @@ -16,13 +16,10 @@ use Symfony\Component\Messenger\Attribute\AsMessageHandler; use Symfony\Component\Messenger\MessageBusInterface; -/** - * PHP 8.2 : Replace by readonly class. - */ #[AsMessageHandler] -final class CronProcessMessageHandler +readonly final class CronProcessMessageHandler { - public function __construct(private readonly MessageBusInterface $bus) + public function __construct(private MessageBusInterface $bus) { } diff --git a/src/Message/ProcessExecuteHandler.php b/src/Message/ProcessExecuteHandler.php index 3443541..a76c0e1 100644 --- a/src/Message/ProcessExecuteHandler.php +++ b/src/Message/ProcessExecuteHandler.php @@ -17,13 +17,10 @@ use CleverAge\UiProcessBundle\Monolog\Handler\ProcessHandler; use Symfony\Component\Messenger\Attribute\AsMessageHandler; -/** - * PHP 8.2 : Replace by readonly class. - */ #[AsMessageHandler] -class ProcessExecuteHandler +readonly class ProcessExecuteHandler { - public function __construct(private readonly ProcessManager $manager, private readonly ProcessHandler $processHandler) + public function __construct(private ProcessManager $manager, private ProcessHandler $processHandler) { } diff --git a/src/Message/ProcessExecuteMessage.php b/src/Message/ProcessExecuteMessage.php index 39c45bb..84fddb0 100644 --- a/src/Message/ProcessExecuteMessage.php +++ b/src/Message/ProcessExecuteMessage.php @@ -13,15 +13,12 @@ namespace CleverAge\UiProcessBundle\Message; -/** - * PHP 8.2 : Replace by readonly class. - */ -class ProcessExecuteMessage +readonly class ProcessExecuteMessage { /** * @param mixed[] $context */ - public function __construct(public readonly string $code, public readonly mixed $input, public readonly array $context = []) + public function __construct(public string $code, public mixed $input, public array $context = []) { } } diff --git a/src/Scheduler/CronScheduler.php b/src/Scheduler/CronScheduler.php index 48bc202..b12fd20 100644 --- a/src/Scheduler/CronScheduler.php +++ b/src/Scheduler/CronScheduler.php @@ -22,15 +22,12 @@ use Symfony\Component\Scheduler\ScheduleProviderInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; -/** - * PHP 8.2 : Replace by readonly class. - */ -class CronScheduler implements ScheduleProviderInterface +readonly class CronScheduler implements ScheduleProviderInterface { public function __construct( - private readonly ProcessScheduleRepository $repository, - private readonly ValidatorInterface $validator, - private readonly LoggerInterface $logger, + private ProcessScheduleRepository $repository, + private ValidatorInterface $validator, + private LoggerInterface $logger, ) { } diff --git a/src/Security/HttpProcessExecutionAuthenticator.php b/src/Security/HttpProcessExecutionAuthenticator.php index 85734f9..cfb91c9 100644 --- a/src/Security/HttpProcessExecutionAuthenticator.php +++ b/src/Security/HttpProcessExecutionAuthenticator.php @@ -34,7 +34,7 @@ public function __construct(private readonly EntityManagerInterface $entityManag public function supports(Request $request): ?bool { - return 'http_process_execute' === $request->get('_route') && $request->isMethod(Request::METHOD_POST); + return 'http_process_execute' === $request->request->get('_route') && $request->isMethod(Request::METHOD_POST); } public function authenticate(Request $request): Passport diff --git a/src/Twig/Runtime/ProcessExecutionExtensionRuntime.php b/src/Twig/Runtime/ProcessExecutionExtensionRuntime.php index 90e4967..592f1e4 100644 --- a/src/Twig/Runtime/ProcessExecutionExtensionRuntime.php +++ b/src/Twig/Runtime/ProcessExecutionExtensionRuntime.php @@ -18,14 +18,11 @@ use CleverAge\UiProcessBundle\Repository\ProcessExecutionRepository; use Twig\Extension\RuntimeExtensionInterface; -/** - * PHP 8.2 : Replace by readonly class. - */ -class ProcessExecutionExtensionRuntime implements RuntimeExtensionInterface +readonly class ProcessExecutionExtensionRuntime implements RuntimeExtensionInterface { public function __construct( - private readonly ProcessExecutionRepository $processExecutionRepository, - private readonly ProcessConfigurationsManager $processConfigurationsManager, + private ProcessExecutionRepository $processExecutionRepository, + private ProcessConfigurationsManager $processConfigurationsManager, ) { } From aaa3ed4fd2be67cc2f2c45cac38ea20c588c2083 Mon Sep 17 00:00:00 2001 From: xmarchegay Date: Tue, 9 Dec 2025 20:02:29 +0100 Subject: [PATCH 2/3] #40 - update template syntax for compatibility with EasyAdmin 4 --- templates/admin/process/launch.html.twig | 4 ++-- templates/admin/process/list.html.twig | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/admin/process/launch.html.twig b/templates/admin/process/launch.html.twig index 88d0f7b..7e4e560 100644 --- a/templates/admin/process/launch.html.twig +++ b/templates/admin/process/launch.html.twig @@ -1,5 +1,5 @@ -{% extends ea.templatePath('layout') %} -{% trans_default_domain ea.i18n.translationDomain %} +{% extends ea().templatePath('layout') %} +{% trans_default_domain ea().i18n.translationDomain %} {% block main %} {% form_theme form '@EasyAdmin/crud/form_theme.html.twig' %} diff --git a/templates/admin/process/list.html.twig b/templates/admin/process/list.html.twig index 2a34372..6a1432c 100644 --- a/templates/admin/process/list.html.twig +++ b/templates/admin/process/list.html.twig @@ -1,6 +1,6 @@ {# @var urlGenerator \EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator #} -{% extends ea.templatePath('layout') %} -{% trans_default_domain ea.i18n.translationDomain %} +{% extends ea().templatePath('layout') %} +{% trans_default_domain ea().i18n.translationDomain %} {% block content_title %}{{ 'Processes'|trans }}{% endblock %} From 2d7a4cf69ccf071b3c7184b1cf8445ce818d1000 Mon Sep 17 00:00:00 2001 From: xmarchegay Date: Tue, 9 Dec 2025 20:13:14 +0100 Subject: [PATCH 3/3] #40 - add EasyAdmin routes configuration file --- config/routes/easyadmin.yaml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 config/routes/easyadmin.yaml diff --git a/config/routes/easyadmin.yaml b/config/routes/easyadmin.yaml new file mode 100644 index 0000000..a88552e --- /dev/null +++ b/config/routes/easyadmin.yaml @@ -0,0 +1,3 @@ +easyadmin: + resource: . + type: easyadmin.routes \ No newline at end of file