From 35cd34c1e7211f5409dc1619c7a8d0ff366c3b69 Mon Sep 17 00:00:00 2001 From: roadiz-ci Date: Fri, 12 Jul 2024 22:08:35 +0000 Subject: [PATCH] Merge tag v2.3.19 into develop --- .github/workflows/run-test.yml | 2 + Makefile | 3 - composer.json | 5 ++ config/services.yaml | 12 +++- phpunit.xml.dist | 6 +- src/Api/Breadcrumbs/Breadcrumbs.php | 17 ++---- .../NodesSourcesBreadcrumbsFactory.php | 5 +- src/Api/Extension/ArchiveExtension.php | 9 +-- .../AttributeValueQueryExtension.php | 5 +- .../AttributeValueRealmExtension.php | 4 +- src/Api/Extension/NodeQueryExtension.php | 5 +- .../Extension/NodesSourcesQueryExtension.php | 9 +-- src/Api/Extension/NodesTagsQueryExtension.php | 5 +- src/Api/Filter/LocaleFilter.php | 5 +- src/Api/ListManager/SolrPaginator.php | 7 +-- src/Api/ListManager/SolrSearchListManager.php | 4 +- src/Api/OpenApi/JwtDecorator.php | 5 +- src/Api/OpenApi/PreviewDecorator.php | 5 +- src/Api/OpenApi/WebResponseDecorator.php | 5 +- .../DefinitionFactoryConfiguration.php | 17 ++---- .../MultiTypeChildrenDefinition.php | 4 +- .../NonReachableNodeSourceBlockDefinition.php | 10 ++-- .../ReachableNodeSourceDefinition.php | 10 ++-- .../TreeWalker/NodeSourceWalkerContext.php | 2 + src/Controller/CustomFormController.php | 11 +++- src/Controller/RedirectionController.php | 5 -- src/CustomForm/CustomFormAnswerSerializer.php | 9 ++- src/CustomForm/CustomFormHelper.php | 9 +-- src/Doctrine/Event/QueryNodesSourcesEvent.php | 8 +-- .../NodesSourcesInheritanceSubscriber.php | 8 +-- .../Filter/NodesSourcesReachableFilter.php | 8 +-- src/Doctrine/SchemaUpdater.php | 17 ++---- src/Document/DocumentFactory.php | 5 +- src/Document/DocumentFinder.php | 8 +-- .../DocumentMessageDispatchSubscriber.php | 8 +-- src/Entity/CustomForm.php | 2 +- src/EntityHandler/CustomFormFieldHandler.php | 20 +++---- src/EntityHandler/TagHandler.php | 4 +- .../DocumentTranslationIndexingEvent.php | 33 ++--------- .../DocumentTranslationUpdatedEvent.php | 9 ++- .../NodesSourcesIndexingEvent.php | 41 ++------------ src/Event/User/UserJoinedGroupEvent.php | 5 +- src/Event/User/UserLeavedGroupEvent.php | 5 +- src/EventSubscriber/NodeNameSubscriber.php | 20 ++----- .../NodesSourcesUrlsCacheEventSubscriber.php | 8 +-- .../RealmNodeInheritanceSubscriber.php | 8 +-- .../ReverseProxyCacheEventSubscriber.php | 18 +----- src/Filesystem/RoadizFileDirectories.php | 8 +-- src/Form/AttributeChoiceType.php | 2 +- .../AttributeDocumentsTransformer.php | 11 +--- src/Form/Error/FormErrorSerializer.php | 8 +-- src/Form/RealmChoiceType.php | 5 +- src/Form/RoleEntityType.php | 11 ++-- src/Form/UserCollectionType.php | 5 +- src/Importer/AttributeImporter.php | 8 +-- src/Logger/DoctrineHandler.php | 17 ++---- src/Mailer/ContactFormManager.php | 8 +-- .../ApplyRealmNodeInheritanceMessage.php | 11 ++-- .../CleanRealmNodeInheritanceMessage.php | 11 ++-- src/Message/DeleteNodeTypeMessage.php | 8 +-- src/Message/GuzzleRequestMessage.php | 8 +-- src/Message/PurgeReverseProxyCacheMessage.php | 8 +-- .../SearchRealmNodeInheritanceMessage.php | 5 +- src/Message/UpdateNodeTypeSchemaMessage.php | 8 +-- src/Node/NodeDuplicator.php | 26 ++------- src/Node/NodeNamePolicyFactory.php | 15 ++--- src/Node/NodeTranslator.php | 15 ++--- src/Node/UniversalDataDuplicator.php | 8 +-- src/NodeType/DefaultValuesResolver.php | 9 +-- src/NodeType/NodeTypeResolver.php | 5 +- src/Preview/RequestPreviewRevolver.php | 9 +-- src/Preview/User/PreviewUserProvider.php | 15 ++--- src/Repository/AttributeGroupRepository.php | 6 +- src/Repository/AttributeRepository.php | 6 +- .../AttributeTranslationRepository.php | 6 +- .../AttributeValueTranslationRepository.php | 6 +- src/Repository/CustomFormAnswerRepository.php | 6 +- .../CustomFormFieldAttributeRepository.php | 6 +- src/Repository/CustomFormFieldRepository.php | 6 +- .../FolderTranslationRepository.php | 6 +- src/Repository/GroupRepository.php | 6 +- src/Repository/RedirectionRepository.php | 6 +- src/Repository/TagTranslationRepository.php | 6 +- src/Repository/WebhookRepository.php | 6 +- src/SearchEngine/ClientRegistry.php | 8 +-- src/SearchEngine/SolariumLogger.php | 13 ++--- src/SearchEngine/SolrSearchResultItem.php | 4 +- .../Subscriber/SolariumSubscriber.php | 5 +- .../TreeWalkerIndexingEventSubscriber.php | 17 ++---- src/Tag/TagFactory.php | 8 +-- src/Translation/TranslationViewer.php | 22 ++------ src/TwigExtension/RoutingExtension.php | 3 +- .../TooManyWebhookTriggeredException.php | 5 +- .../Message/GenericJsonPostMessage.php | 17 ++---- .../Message/GitlabPipelineTriggerMessage.php | 25 +++------ .../Message/NetlifyBuildHookMessage.php | 17 ++---- src/Webhook/ThrottledWebhookDispatcher.php | 13 +---- .../Event/NodeStatusGuardListener.php | 8 +-- src/Xlsx/AbstractXlsxSerializer.php | 9 +-- src/Xlsx/NodeSourceXlsxSerializer.php | 31 +++------- src/Xlsx/SerializerInterface.php | 1 + src/Xlsx/XlsxExporter.php | 11 ++-- .../customForm/base_custom_form.html.twig | 56 +++++++++++-------- templates/customForm/customForm.html.twig | 2 +- templates/customForm/customFormSent.html.twig | 2 +- .../NodeType/ApiResourceGeneratorTest.php | 30 +++++----- tests/bootstrap.php | 7 ++- 107 files changed, 347 insertions(+), 713 deletions(-) delete mode 100644 Makefile rename {src/Test => tests}/NodeType/ApiResourceGeneratorTest.php (75%) diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml index 189e3a55..2fe1003b 100644 --- a/.github/workflows/run-test.yml +++ b/.github/workflows/run-test.yml @@ -39,3 +39,5 @@ jobs: run: vendor/bin/phpcs -p ./src - name: Run PHPStan run: vendor/bin/phpstan analyse --no-progress -c phpstan.neon + - name: Run PHP Unit + run: vendor/bin/phpunit -v diff --git a/Makefile b/Makefile deleted file mode 100644 index 16ef8148..00000000 --- a/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -test: - php -d "memory_limit=-1" vendor/bin/phpcbf --report=full --report-file=./report.txt -p ./src - php -d "memory_limit=-1" vendor/bin/phpstan analyse -c phpstan.neon diff --git a/composer.json b/composer.json index 39a2187e..12385bbd 100644 --- a/composer.json +++ b/composer.json @@ -124,6 +124,11 @@ "RZ\\Roadiz\\CoreBundle\\": "src/" } }, + "autoload-dev": { + "psr-4": { + "RZ\\Roadiz\\CoreBundle\\Tests\\": "tests/" + } + }, "scripts": { "auto-scripts": { "cache:clear": "symfony-cmd", diff --git a/config/services.yaml b/config/services.yaml index d1fb0dce..385bac36 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -61,6 +61,7 @@ services: - '../src/Traits/' - '../src/Kernel.php' - '../src/Tests/' + - '../src/DataCollector/' - '../src/Event/' - '../src/Model/' - '../src/ListManager/' @@ -73,6 +74,13 @@ services: shared: false public: true + RZ\Roadiz\CoreBundle\Xlsx\: + resource: '../src/Xlsx/' + deprecated: + message: 'The "%service_id%" service is deprecated and will be removed in Roadiz 2.4. Use CSV serialization instead.' + package: roadiz/core-bundle + version: '2.3.19' + RZ\Roadiz\CoreBundle\Document\MediaFinder\YoutubeEmbedFinder: tags: [ { name: 'roadiz_core.media_finder', platform: 'youtube' } ] RZ\Roadiz\CoreBundle\Document\MediaFinder\VimeoEmbedFinder: @@ -342,7 +350,7 @@ services: # Recreate manager for each usage shared: false deprecated: - message: 'The "%service_id%" service is deprecated and will be removed in Roadiz 3.0. Use RZ\Roadiz\CoreBundle\Mailer\EmailManagerFactory instead.' + message: 'The "%service_id%" service is deprecated and will be removed in Roadiz 2.4. Use RZ\Roadiz\CoreBundle\Mailer\EmailManagerFactory instead.' package: roadiz/core-bundle version: '2.3.18' @@ -350,7 +358,7 @@ services: # Recreate manager for each usage shared: false deprecated: - message: 'The "%service_id%" service is deprecated and will be removed in Roadiz 3.0. Use RZ\Roadiz\CoreBundle\Mailer\ContactFormManagerFactory instead.' + message: 'The "%service_id%" service is deprecated and will be removed in Roadiz 2.4. Use RZ\Roadiz\CoreBundle\Mailer\ContactFormManagerFactory instead.' package: roadiz/core-bundle version: '2.3.18' diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c0f0120e..9cb64081 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -16,6 +16,8 @@ + + @@ -40,8 +42,8 @@ - - src/Test + + tests diff --git a/src/Api/Breadcrumbs/Breadcrumbs.php b/src/Api/Breadcrumbs/Breadcrumbs.php index 1105ff4a..6d0fb068 100644 --- a/src/Api/Breadcrumbs/Breadcrumbs.php +++ b/src/Api/Breadcrumbs/Breadcrumbs.php @@ -10,18 +10,13 @@ final class Breadcrumbs implements BreadcrumbsInterface { /** - * @var array + * @param PersistableInterface[] $items */ - #[Serializer\Groups(["breadcrumbs", "web_response"])] - #[Serializer\MaxDepth(1)] - private array $items; - - /** - * @param array $items - */ - public function __construct(array $items) - { - $this->items = $items; + public function __construct( + #[Serializer\Groups(["breadcrumbs", "web_response"])] + #[Serializer\MaxDepth(1)] + private readonly array $items + ) { } /** diff --git a/src/Api/Breadcrumbs/NodesSourcesBreadcrumbsFactory.php b/src/Api/Breadcrumbs/NodesSourcesBreadcrumbsFactory.php index 6f02c639..93cb2ee1 100644 --- a/src/Api/Breadcrumbs/NodesSourcesBreadcrumbsFactory.php +++ b/src/Api/Breadcrumbs/NodesSourcesBreadcrumbsFactory.php @@ -19,11 +19,10 @@ public function create(?PersistableInterface $entity): ?BreadcrumbsInterface return null; } - if ( - !$entity->isReachable() - ) { + if (!$entity->isReachable()) { return null; } + $parents = []; while (null !== $entity = $entity->getParent()) { diff --git a/src/Api/Extension/ArchiveExtension.php b/src/Api/Extension/ArchiveExtension.php index e61a3305..14c615c6 100644 --- a/src/Api/Extension/ArchiveExtension.php +++ b/src/Api/Extension/ArchiveExtension.php @@ -43,15 +43,10 @@ */ final class ArchiveExtension implements QueryResultCollectionExtensionInterface { - private RequestStack $requestStack; - private string $defaultPublicationFieldName; - public function __construct( - RequestStack $requestStack, - string $defaultPublicationFieldName = 'publishedAt' + private readonly RequestStack $requestStack, + private readonly string $defaultPublicationFieldName = 'publishedAt' ) { - $this->requestStack = $requestStack; - $this->defaultPublicationFieldName = $defaultPublicationFieldName; } public function applyToCollection( diff --git a/src/Api/Extension/AttributeValueQueryExtension.php b/src/Api/Extension/AttributeValueQueryExtension.php index 3a095af7..889d8ef4 100644 --- a/src/Api/Extension/AttributeValueQueryExtension.php +++ b/src/Api/Extension/AttributeValueQueryExtension.php @@ -16,12 +16,9 @@ final class AttributeValueQueryExtension implements QueryItemExtensionInterface, QueryCollectionExtensionInterface { - private PreviewResolverInterface $previewResolver; - public function __construct( - PreviewResolverInterface $previewResolver + private readonly PreviewResolverInterface $previewResolver ) { - $this->previewResolver = $previewResolver; } public function applyToItem( diff --git a/src/Api/Extension/AttributeValueRealmExtension.php b/src/Api/Extension/AttributeValueRealmExtension.php index fb8f06c9..d14b3437 100644 --- a/src/Api/Extension/AttributeValueRealmExtension.php +++ b/src/Api/Extension/AttributeValueRealmExtension.php @@ -17,8 +17,8 @@ final class AttributeValueRealmExtension implements QueryCollectionExtensionInterface, QueryItemExtensionInterface { public function __construct( - private Security $security, - private RealmResolverInterface $realmResolver + private readonly Security $security, + private readonly RealmResolverInterface $realmResolver ) { } diff --git a/src/Api/Extension/NodeQueryExtension.php b/src/Api/Extension/NodeQueryExtension.php index 0b15784e..9a4ee6c6 100644 --- a/src/Api/Extension/NodeQueryExtension.php +++ b/src/Api/Extension/NodeQueryExtension.php @@ -16,12 +16,9 @@ final class NodeQueryExtension implements QueryItemExtensionInterface, QueryCollectionExtensionInterface { - private PreviewResolverInterface $previewResolver; - public function __construct( - PreviewResolverInterface $previewResolver + private readonly PreviewResolverInterface $previewResolver ) { - $this->previewResolver = $previewResolver; } public function applyToItem( diff --git a/src/Api/Extension/NodesSourcesQueryExtension.php b/src/Api/Extension/NodesSourcesQueryExtension.php index 2e5b3960..aca8ba43 100644 --- a/src/Api/Extension/NodesSourcesQueryExtension.php +++ b/src/Api/Extension/NodesSourcesQueryExtension.php @@ -17,15 +17,10 @@ final class NodesSourcesQueryExtension implements QueryItemExtensionInterface, QueryCollectionExtensionInterface { - private PreviewResolverInterface $previewResolver; - private string $generatedEntityNamespacePattern; - public function __construct( - PreviewResolverInterface $previewResolver, - string $generatedEntityNamespacePattern = '#^App\\\GeneratedEntity\\\NS(?:[a-zA-Z]+)$#' + private readonly PreviewResolverInterface $previewResolver, + private readonly string $generatedEntityNamespacePattern = '#^App\\\GeneratedEntity\\\NS(?:[a-zA-Z]+)$#' ) { - $this->previewResolver = $previewResolver; - $this->generatedEntityNamespacePattern = $generatedEntityNamespacePattern; } public function applyToItem( diff --git a/src/Api/Extension/NodesTagsQueryExtension.php b/src/Api/Extension/NodesTagsQueryExtension.php index a5ea3cb3..37afa629 100644 --- a/src/Api/Extension/NodesTagsQueryExtension.php +++ b/src/Api/Extension/NodesTagsQueryExtension.php @@ -16,12 +16,9 @@ final class NodesTagsQueryExtension implements QueryItemExtensionInterface, QueryCollectionExtensionInterface { - private PreviewResolverInterface $previewResolver; - public function __construct( - PreviewResolverInterface $previewResolver + private readonly PreviewResolverInterface $previewResolver ) { - $this->previewResolver = $previewResolver; } public function applyToItem( diff --git a/src/Api/Filter/LocaleFilter.php b/src/Api/Filter/LocaleFilter.php index a4579ec5..aaefd4a5 100644 --- a/src/Api/Filter/LocaleFilter.php +++ b/src/Api/Filter/LocaleFilter.php @@ -19,10 +19,8 @@ final class LocaleFilter extends GeneratedEntityFilter { public const PROPERTY = '_locale'; - private PreviewResolverInterface $previewResolver; - public function __construct( - PreviewResolverInterface $previewResolver, + private readonly PreviewResolverInterface $previewResolver, ManagerRegistry $managerRegistry, LoggerInterface $logger = null, array $properties = null, @@ -30,7 +28,6 @@ public function __construct( string $generatedEntityNamespacePattern = '#^App\\\GeneratedEntity\\\NS(?:[a-zA-Z]+)$#' ) { parent::__construct($managerRegistry, $logger, $properties, $nameConverter, $generatedEntityNamespacePattern); - $this->previewResolver = $previewResolver; } protected function filterProperty( diff --git a/src/Api/ListManager/SolrPaginator.php b/src/Api/ListManager/SolrPaginator.php index a1f1e78b..7ff11677 100644 --- a/src/Api/ListManager/SolrPaginator.php +++ b/src/Api/ListManager/SolrPaginator.php @@ -5,7 +5,9 @@ namespace RZ\Roadiz\CoreBundle\Api\ListManager; use ApiPlatform\State\Pagination\PaginatorInterface; +use Symfony\Component\DependencyInjection\Attribute\Exclude; +#[Exclude] final class SolrPaginator implements PaginatorInterface, \IteratorAggregate { private bool $handled = false; @@ -57,9 +59,6 @@ public function getIterator(): \Traversable { $this->handleOnce(); $entities = $this->listManager->getEntities(); - if (\is_array($entities)) { - return new \ArrayIterator($entities); - } - return $entities->getIterator(); + return new \ArrayIterator($entities); } } diff --git a/src/Api/ListManager/SolrSearchListManager.php b/src/Api/ListManager/SolrSearchListManager.php index 871e5587..edacc39f 100644 --- a/src/Api/ListManager/SolrSearchListManager.php +++ b/src/Api/ListManager/SolrSearchListManager.php @@ -7,11 +7,13 @@ use RZ\Roadiz\CoreBundle\ListManager\AbstractEntityListManager; use RZ\Roadiz\CoreBundle\SearchEngine\SearchHandlerInterface; use RZ\Roadiz\CoreBundle\SearchEngine\SearchResultsInterface; +use Symfony\Component\DependencyInjection\Attribute\Exclude; use Symfony\Component\HttpFoundation\Request; +#[Exclude] final class SolrSearchListManager extends AbstractEntityListManager { - protected ?SearchResultsInterface $searchResults; + private ?SearchResultsInterface $searchResults; private ?string $query = null; public function __construct( diff --git a/src/Api/OpenApi/JwtDecorator.php b/src/Api/OpenApi/JwtDecorator.php index 2a449446..cb41dee7 100644 --- a/src/Api/OpenApi/JwtDecorator.php +++ b/src/Api/OpenApi/JwtDecorator.php @@ -10,12 +10,9 @@ final class JwtDecorator implements OpenApiFactoryInterface { - private OpenApiFactoryInterface $decorated; - public function __construct( - OpenApiFactoryInterface $decorated + private readonly OpenApiFactoryInterface $decorated ) { - $this->decorated = $decorated; } public function __invoke(array $context = []): OpenApi diff --git a/src/Api/OpenApi/PreviewDecorator.php b/src/Api/OpenApi/PreviewDecorator.php index f63c706e..7dcecaae 100644 --- a/src/Api/OpenApi/PreviewDecorator.php +++ b/src/Api/OpenApi/PreviewDecorator.php @@ -11,12 +11,9 @@ final class PreviewDecorator implements OpenApiFactoryInterface { - private OpenApiFactoryInterface $decorated; - public function __construct( - OpenApiFactoryInterface $decorated + private readonly OpenApiFactoryInterface $decorated ) { - $this->decorated = $decorated; } public function __invoke(array $context = []): OpenApi diff --git a/src/Api/OpenApi/WebResponseDecorator.php b/src/Api/OpenApi/WebResponseDecorator.php index 21131a1e..e76a1947 100644 --- a/src/Api/OpenApi/WebResponseDecorator.php +++ b/src/Api/OpenApi/WebResponseDecorator.php @@ -10,12 +10,9 @@ final class WebResponseDecorator implements OpenApiFactoryInterface { - private OpenApiFactoryInterface $decorated; - public function __construct( - OpenApiFactoryInterface $decorated + private readonly OpenApiFactoryInterface $decorated ) { - $this->decorated = $decorated; } public function __invoke(array $context = []): OpenApi diff --git a/src/Api/TreeWalker/Definition/DefinitionFactoryConfiguration.php b/src/Api/TreeWalker/Definition/DefinitionFactoryConfiguration.php index a63ca9c1..a4326a3e 100644 --- a/src/Api/TreeWalker/Definition/DefinitionFactoryConfiguration.php +++ b/src/Api/TreeWalker/Definition/DefinitionFactoryConfiguration.php @@ -6,22 +6,15 @@ final class DefinitionFactoryConfiguration { - /** - * @var class-string - */ - public string $classname; - public bool $onlyVisible; - public DefinitionFactoryInterface $definitionFactory; - /** * @param class-string $classname * @param DefinitionFactoryInterface $definitionFactory * @param bool $onlyVisible */ - public function __construct(string $classname, DefinitionFactoryInterface $definitionFactory, bool $onlyVisible) - { - $this->classname = $classname; - $this->onlyVisible = $onlyVisible; - $this->definitionFactory = $definitionFactory; + public function __construct( + public readonly string $classname, + public readonly DefinitionFactoryInterface $definitionFactory, + public readonly bool $onlyVisible + ) { } } diff --git a/src/Api/TreeWalker/Definition/MultiTypeChildrenDefinition.php b/src/Api/TreeWalker/Definition/MultiTypeChildrenDefinition.php index 4764fd36..aa3d441f 100644 --- a/src/Api/TreeWalker/Definition/MultiTypeChildrenDefinition.php +++ b/src/Api/TreeWalker/Definition/MultiTypeChildrenDefinition.php @@ -20,11 +20,10 @@ final class MultiTypeChildrenDefinition * @param bool $onlyVisible */ public function __construct( - WalkerContextInterface $context, + private readonly WalkerContextInterface $context, private readonly array $types, private readonly bool $onlyVisible = true ) { - $this->context = $context; } /** @@ -63,6 +62,7 @@ public function __invoke(NodesSources $source): array ->findBy($criteria, [ 'node.position' => 'ASC', ]); + $this->context->getStopwatch()->stop(self::class); return $children; diff --git a/src/Api/TreeWalker/Definition/NonReachableNodeSourceBlockDefinition.php b/src/Api/TreeWalker/Definition/NonReachableNodeSourceBlockDefinition.php index b9fea2d9..26a5a482 100644 --- a/src/Api/TreeWalker/Definition/NonReachableNodeSourceBlockDefinition.php +++ b/src/Api/TreeWalker/Definition/NonReachableNodeSourceBlockDefinition.php @@ -8,16 +8,16 @@ use RZ\Roadiz\CoreBundle\Api\TreeWalker\NodeSourceWalkerContext; use RZ\Roadiz\CoreBundle\Entity\NodesSources; use RZ\TreeWalker\Definition\ContextualDefinitionTrait; +use RZ\TreeWalker\WalkerContextInterface; final class NonReachableNodeSourceBlockDefinition { use ContextualDefinitionTrait; - private bool $onlyVisible; - - public function __construct(bool $onlyVisible = true) - { - $this->onlyVisible = $onlyVisible; + public function __construct( + private readonly WalkerContextInterface $context, + private readonly bool $onlyVisible = true + ) { } /** diff --git a/src/Api/TreeWalker/Definition/ReachableNodeSourceDefinition.php b/src/Api/TreeWalker/Definition/ReachableNodeSourceDefinition.php index 477cef9f..0d193896 100644 --- a/src/Api/TreeWalker/Definition/ReachableNodeSourceDefinition.php +++ b/src/Api/TreeWalker/Definition/ReachableNodeSourceDefinition.php @@ -8,16 +8,16 @@ use RZ\Roadiz\CoreBundle\Api\TreeWalker\NodeSourceWalkerContext; use RZ\Roadiz\CoreBundle\Entity\NodesSources; use RZ\TreeWalker\Definition\ContextualDefinitionTrait; +use RZ\TreeWalker\WalkerContextInterface; final class ReachableNodeSourceDefinition { use ContextualDefinitionTrait; - private bool $onlyVisible; - - public function __construct(bool $onlyVisible = true) - { - $this->onlyVisible = $onlyVisible; + public function __construct( + private readonly WalkerContextInterface $context, + private readonly bool $onlyVisible = true + ) { } /** diff --git a/src/Api/TreeWalker/NodeSourceWalkerContext.php b/src/Api/TreeWalker/NodeSourceWalkerContext.php index a82be345..928d0241 100644 --- a/src/Api/TreeWalker/NodeSourceWalkerContext.php +++ b/src/Api/TreeWalker/NodeSourceWalkerContext.php @@ -12,10 +12,12 @@ use RZ\Roadiz\CoreBundle\NodeType\NodeTypeResolver; use RZ\Roadiz\CoreBundle\Preview\PreviewResolverInterface; use RZ\TreeWalker\WalkerContextInterface; +use Symfony\Component\DependencyInjection\Attribute\Exclude; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Stopwatch\Stopwatch; +#[Exclude] class NodeSourceWalkerContext implements WalkerContextInterface { public function __construct( diff --git a/src/Controller/CustomFormController.php b/src/Controller/CustomFormController.php index 364c12ee..9088bb0d 100644 --- a/src/Controller/CustomFormController.php +++ b/src/Controller/CustomFormController.php @@ -207,9 +207,14 @@ private function prepareAndHandleCustomFormAssignation( ?string $emailSender = null, bool $prefix = true ) { - $assignation = []; - $assignation['customForm'] = $customFormsEntity; - $assignation['fields'] = $customFormsEntity->getFields(); + $assignation = [ + 'customForm' => $customFormsEntity, + 'fields' => $customFormsEntity->getFields(), + 'head' => [ + 'siteTitle' => $this->settingsBag->get('site_name'), + 'mainColor' => $this->settingsBag->get('main_color'), + ] + ]; $helper = $this->customFormHelperFactory->createHelper($customFormsEntity); $form = $helper->getForm( $request, diff --git a/src/Controller/RedirectionController.php b/src/Controller/RedirectionController.php index 1f6f3f52..6ede96a6 100644 --- a/src/Controller/RedirectionController.php +++ b/src/Controller/RedirectionController.php @@ -18,11 +18,6 @@ public function __construct(private readonly UrlGeneratorInterface $urlGenerator { } - /** - * @param Request $request - * @param Redirection $redirection - * @return RedirectResponse - */ public function redirectAction(Request $request, Redirection $redirection): RedirectResponse { if (null !== $redirection->getRedirectNodeSource()) { diff --git a/src/CustomForm/CustomFormAnswerSerializer.php b/src/CustomForm/CustomFormAnswerSerializer.php index f33062ab..6259d353 100644 --- a/src/CustomForm/CustomFormAnswerSerializer.php +++ b/src/CustomForm/CustomFormAnswerSerializer.php @@ -20,18 +20,21 @@ public function __construct(private readonly UrlGeneratorInterface $urlGenerator */ public function toSimpleArray(CustomFormAnswer $answer): array { - $answers = []; + $answers = [ + 'ip' => $answer->getIp(), + 'submitted.date' => $answer->getSubmittedAt() + ]; /** @var CustomFormFieldAttribute $answerAttr */ foreach ($answer->getAnswerFields() as $answerAttr) { $field = $answerAttr->getCustomFormField(); if ($field->isDocuments()) { - $answers[$field->getName()] = implode(PHP_EOL, $answerAttr->getDocuments()->map(function (Document $document) { + $answers[$field->getLabel()] = implode(PHP_EOL, $answerAttr->getDocuments()->map(function (Document $document) { return $this->urlGenerator->generate('documentsDownloadPage', [ 'documentId' => $document->getId() ], UrlGeneratorInterface::ABSOLUTE_URL); })->toArray()); } else { - $answers[$field->getName()] = $answerAttr->getValue(); + $answers[$field->getLabel()] = $answerAttr->getValue(); } } return $answers; diff --git a/src/CustomForm/CustomFormHelper.php b/src/CustomForm/CustomFormHelper.php index 2a0eeaef..2e57ed4d 100644 --- a/src/CustomForm/CustomFormHelper.php +++ b/src/CustomForm/CustomFormHelper.php @@ -176,9 +176,6 @@ protected function handleUploadedFile( return $document; } - /** - * @return Folder|null - */ protected function getDocumentFolderForCustomForm(): ?Folder { return $this->em->getRepository(Folder::class) @@ -189,11 +186,7 @@ protected function getDocumentFolderForCustomForm(): ?Folder ); } - /** - * @param mixed $rawValue - * @return string - */ - private function formValueToString($rawValue): string + private function formValueToString(mixed $rawValue): string { if ($rawValue instanceof \DateTimeInterface) { return $rawValue->format('Y-m-d H:i:s'); diff --git a/src/Doctrine/Event/QueryNodesSourcesEvent.php b/src/Doctrine/Event/QueryNodesSourcesEvent.php index 03d2c385..07999c22 100644 --- a/src/Doctrine/Event/QueryNodesSourcesEvent.php +++ b/src/Doctrine/Event/QueryNodesSourcesEvent.php @@ -9,19 +9,13 @@ final class QueryNodesSourcesEvent extends QueryEvent { - /** - * @var class-string - */ - protected string $actualEntityName; - /** * @param Query $query * @param class-string $actualEntityName */ - public function __construct(Query $query, string $actualEntityName) + public function __construct(Query $query, private readonly string $actualEntityName) { parent::__construct($query, NodesSources::class); - $this->actualEntityName = $actualEntityName; } /** diff --git a/src/Doctrine/EventSubscriber/NodesSourcesInheritanceSubscriber.php b/src/Doctrine/EventSubscriber/NodesSourcesInheritanceSubscriber.php index ddb6b199..935f4c67 100644 --- a/src/Doctrine/EventSubscriber/NodesSourcesInheritanceSubscriber.php +++ b/src/Doctrine/EventSubscriber/NodesSourcesInheritanceSubscriber.php @@ -19,13 +19,9 @@ #[AsDoctrineListener(event: Events::loadClassMetadata)] final class NodesSourcesInheritanceSubscriber { - /** - * @param NodeTypes $nodeTypes - * @param string $inheritanceType - */ public function __construct( - private NodeTypes $nodeTypes, - private string $inheritanceType + private readonly NodeTypes $nodeTypes, + private readonly string $inheritanceType ) { } diff --git a/src/Doctrine/ORM/Filter/NodesSourcesReachableFilter.php b/src/Doctrine/ORM/Filter/NodesSourcesReachableFilter.php index 03528da7..6f524f5c 100644 --- a/src/Doctrine/ORM/Filter/NodesSourcesReachableFilter.php +++ b/src/Doctrine/ORM/Filter/NodesSourcesReachableFilter.php @@ -18,19 +18,13 @@ */ final class NodesSourcesReachableFilter implements EventSubscriberInterface { - private NodeTypes $nodeTypesBag; - public const PARAMETER = [ 'node.nodeType.reachable', 'reachable' ]; - /** - * @param NodeTypes $nodeTypesBag - */ - public function __construct(NodeTypes $nodeTypesBag) + public function __construct(private readonly NodeTypes $nodeTypesBag) { - $this->nodeTypesBag = $nodeTypesBag; } public static function getSubscribedEvents(): array diff --git a/src/Doctrine/SchemaUpdater.php b/src/Doctrine/SchemaUpdater.php index a176b299..bd1ccdeb 100644 --- a/src/Doctrine/SchemaUpdater.php +++ b/src/Doctrine/SchemaUpdater.php @@ -11,21 +11,12 @@ final class SchemaUpdater { - private LoggerInterface $logger; - private OPCacheClearer $opCacheClearer; - private string $projectDir; - private CacheClearerInterface $cacheClearer; - public function __construct( - CacheClearerInterface $cacheClearer, - OPCacheClearer $opCacheClearer, - LoggerInterface $logger, - string $projectDir + private readonly CacheClearerInterface $cacheClearer, + private readonly OPCacheClearer $opCacheClearer, + private readonly LoggerInterface $logger, + private readonly string $projectDir ) { - $this->logger = $logger; - $this->opCacheClearer = $opCacheClearer; - $this->projectDir = $projectDir; - $this->cacheClearer = $cacheClearer; } public function clearMetadata(): void diff --git a/src/Document/DocumentFactory.php b/src/Document/DocumentFactory.php index 5f088b40..91f6f612 100644 --- a/src/Document/DocumentFactory.php +++ b/src/Document/DocumentFactory.php @@ -19,16 +19,13 @@ */ final class DocumentFactory extends AbstractDocumentFactory { - private ManagerRegistry $managerRegistry; - public function __construct( - ManagerRegistry $managerRegistry, + private readonly ManagerRegistry $managerRegistry, FilesystemOperator $documentsStorage, DocumentFinderInterface $documentFinder, ?LoggerInterface $logger = null ) { parent::__construct($documentsStorage, $documentFinder, $logger); - $this->managerRegistry = $managerRegistry; } protected function persistDocument(DocumentInterface $document): void diff --git a/src/Document/DocumentFinder.php b/src/Document/DocumentFinder.php index 1978621d..7de00596 100644 --- a/src/Document/DocumentFinder.php +++ b/src/Document/DocumentFinder.php @@ -12,14 +12,8 @@ final class DocumentFinder extends AbstractDocumentFinder { - private ManagerRegistry $managerRegistry; - - /** - * @param ManagerRegistry $managerRegistry - */ - public function __construct(ManagerRegistry $managerRegistry) + public function __construct(private readonly ManagerRegistry $managerRegistry) { - $this->managerRegistry = $managerRegistry; } /** diff --git a/src/Document/EventSubscriber/DocumentMessageDispatchSubscriber.php b/src/Document/EventSubscriber/DocumentMessageDispatchSubscriber.php index 8dfb1350..cf6a6844 100644 --- a/src/Document/EventSubscriber/DocumentMessageDispatchSubscriber.php +++ b/src/Document/EventSubscriber/DocumentMessageDispatchSubscriber.php @@ -22,14 +22,8 @@ final class DocumentMessageDispatchSubscriber implements EventSubscriberInterface { - private MessageBusInterface $bus; - - /** - * @param MessageBusInterface $bus - */ - public function __construct(MessageBusInterface $bus) + public function __construct(private readonly MessageBusInterface $bus) { - $this->bus = $bus; } /** diff --git a/src/Entity/CustomForm.php b/src/Entity/CustomForm.php index 9f91c796..b4f9be4e 100644 --- a/src/Entity/CustomForm.php +++ b/src/Entity/CustomForm.php @@ -351,7 +351,7 @@ public function removeField(CustomFormField $field): CustomForm } /** - * @return Collection + * @return Collection */ public function getCustomFormAnswers(): Collection { diff --git a/src/EntityHandler/CustomFormFieldHandler.php b/src/EntityHandler/CustomFormFieldHandler.php index e7b8cbd5..dfa24595 100644 --- a/src/EntityHandler/CustomFormFieldHandler.php +++ b/src/EntityHandler/CustomFormFieldHandler.php @@ -15,16 +15,6 @@ final class CustomFormFieldHandler extends AbstractHandler { private ?CustomFormField $customFormField = null; - /** - * @param CustomFormField $customFormField - * @return $this - */ - public function setCustomFormField(CustomFormField $customFormField): self - { - $this->customFormField = $customFormField; - return $this; - } - /** * @param ObjectManager $objectManager * @param CustomFormHandler $customFormHandler @@ -36,6 +26,16 @@ public function __construct( parent::__construct($objectManager); } + /** + * @param CustomFormField $customFormField + * @return $this + */ + public function setCustomFormField(CustomFormField $customFormField): self + { + $this->customFormField = $customFormField; + return $this; + } + /** * Clean position for current customForm siblings. * diff --git a/src/EntityHandler/TagHandler.php b/src/EntityHandler/TagHandler.php index b995f460..355d583a 100644 --- a/src/EntityHandler/TagHandler.php +++ b/src/EntityHandler/TagHandler.php @@ -5,10 +5,8 @@ namespace RZ\Roadiz\CoreBundle\EntityHandler; use Doctrine\Common\Collections\Criteria; -use Doctrine\ORM\NoResultException; -use Doctrine\ORM\Query; -use RZ\Roadiz\CoreBundle\Entity\Tag; use RZ\Roadiz\Core\Handlers\AbstractHandler; +use RZ\Roadiz\CoreBundle\Entity\Tag; /** * Handle operations with tags entities. diff --git a/src/Event/Document/DocumentTranslationIndexingEvent.php b/src/Event/Document/DocumentTranslationIndexingEvent.php index 6417e77c..1130fb58 100644 --- a/src/Event/Document/DocumentTranslationIndexingEvent.php +++ b/src/Event/Document/DocumentTranslationIndexingEvent.php @@ -10,27 +10,12 @@ final class DocumentTranslationIndexingEvent extends Event { - protected DocumentTranslation $documentTranslation; - protected array $associations; - protected AbstractSolarium $solariumDocument; - protected bool $subResource; - - /** - * @param DocumentTranslation $documentTranslation - * @param array $associations - * @param AbstractSolarium $solariumDocument - * @param bool $subResource - */ public function __construct( - DocumentTranslation $documentTranslation, - array $associations, - AbstractSolarium $solariumDocument, - bool $subResource = false + private readonly DocumentTranslation $documentTranslation, + private array $associations, + private readonly AbstractSolarium $solariumDocument, + private readonly bool $subResource = false ) { - $this->documentTranslation = $documentTranslation; - $this->associations = $associations; - $this->solariumDocument = $solariumDocument; - $this->subResource = $subResource; } /** @@ -74,14 +59,4 @@ public function setAssociations(array $associations): DocumentTranslationIndexin $this->associations = $associations; return $this; } - - /** - * @param AbstractSolarium $solariumDocument - * @return DocumentTranslationIndexingEvent - */ - public function setSolariumDocument(AbstractSolarium $solariumDocument): DocumentTranslationIndexingEvent - { - $this->solariumDocument = $solariumDocument; - return $this; - } } diff --git a/src/Event/Document/DocumentTranslationUpdatedEvent.php b/src/Event/Document/DocumentTranslationUpdatedEvent.php index 8abf8b0e..bf889883 100644 --- a/src/Event/Document/DocumentTranslationUpdatedEvent.php +++ b/src/Event/Document/DocumentTranslationUpdatedEvent.php @@ -10,12 +10,11 @@ final class DocumentTranslationUpdatedEvent extends FilterDocumentEvent { - protected ?DocumentTranslation $documentTranslation; - - public function __construct(DocumentInterface $document, ?DocumentTranslation $documentTranslation = null) - { + public function __construct( + DocumentInterface $document, + private readonly ?DocumentTranslation $documentTranslation = null + ) { parent::__construct($document); - $this->documentTranslation = $documentTranslation; } /** diff --git a/src/Event/NodesSources/NodesSourcesIndexingEvent.php b/src/Event/NodesSources/NodesSourcesIndexingEvent.php index aea95c47..9e8381e0 100644 --- a/src/Event/NodesSources/NodesSourcesIndexingEvent.php +++ b/src/Event/NodesSources/NodesSourcesIndexingEvent.php @@ -10,27 +10,12 @@ final class NodesSourcesIndexingEvent extends Event { - protected NodesSources $nodeSource; - protected array $associations; - protected AbstractSolarium $solariumDocument; - protected bool $subResource; - - /** - * @param NodesSources $nodeSource - * @param array $associations - * @param AbstractSolarium $solariumDocument - * @param bool $subResource - */ public function __construct( - NodesSources $nodeSource, - array $associations, - AbstractSolarium $solariumDocument, - bool $subResource = false + private readonly NodesSources $nodeSource, + private array $associations, + private readonly AbstractSolarium $solariumDocument, + private readonly bool $subResource = false ) { - $this->nodeSource = $nodeSource; - $this->associations = $associations; - $this->solariumDocument = $solariumDocument; - $this->subResource = $subResource; } public function getNodeSource(): NodesSources @@ -60,29 +45,11 @@ public function setAssociations(array $associations): NodesSourcesIndexingEvent return $this; } - /** - * @return AbstractSolarium - */ public function getSolariumDocument(): AbstractSolarium { return $this->solariumDocument; } - /** - * @param AbstractSolarium $solariumDocument - * - * @return NodesSourcesIndexingEvent - */ - public function setSolariumDocument(AbstractSolarium $solariumDocument): NodesSourcesIndexingEvent - { - $this->solariumDocument = $solariumDocument; - - return $this; - } - - /** - * @return bool - */ public function isSubResource(): bool { return $this->subResource; diff --git a/src/Event/User/UserJoinedGroupEvent.php b/src/Event/User/UserJoinedGroupEvent.php index 9f6393ff..77c1ef3b 100644 --- a/src/Event/User/UserJoinedGroupEvent.php +++ b/src/Event/User/UserJoinedGroupEvent.php @@ -10,12 +10,9 @@ final class UserJoinedGroupEvent extends FilterUserEvent { - private Group $group; - - public function __construct(User $user, Group $group) + public function __construct(User $user, private readonly Group $group) { parent::__construct($user); - $this->group = $group; } /** diff --git a/src/Event/User/UserLeavedGroupEvent.php b/src/Event/User/UserLeavedGroupEvent.php index aa250160..e776a374 100644 --- a/src/Event/User/UserLeavedGroupEvent.php +++ b/src/Event/User/UserLeavedGroupEvent.php @@ -10,12 +10,9 @@ final class UserLeavedGroupEvent extends FilterUserEvent { - private Group $group; - - public function __construct(User $user, Group $group) + public function __construct(User $user, private readonly Group $group) { parent::__construct($user); - $this->group = $group; } /** diff --git a/src/EventSubscriber/NodeNameSubscriber.php b/src/EventSubscriber/NodeNameSubscriber.php index 91659409..6f9288a9 100644 --- a/src/EventSubscriber/NodeNameSubscriber.php +++ b/src/EventSubscriber/NodeNameSubscriber.php @@ -5,7 +5,6 @@ namespace RZ\Roadiz\CoreBundle\EventSubscriber; use Psr\Log\LoggerInterface; -use Psr\Log\NullLogger; use RZ\Roadiz\CoreBundle\Event\Node\NodePathChangedEvent; use RZ\Roadiz\CoreBundle\Event\Node\NodeUpdatedEvent; use RZ\Roadiz\CoreBundle\Event\NodesSources\NodesSourcesPreUpdatedEvent; @@ -20,20 +19,11 @@ */ final class NodeNameSubscriber implements EventSubscriberInterface { - private NodeMover $nodeMover; - private LoggerInterface $logger; - private NodeNamePolicyInterface $nodeNamePolicy; - - /** - * @param LoggerInterface|null $logger - * @param NodeNamePolicyInterface $nodeNamePolicy - * @param NodeMover $nodeMover - */ - public function __construct(?LoggerInterface $logger, NodeNamePolicyInterface $nodeNamePolicy, NodeMover $nodeMover) - { - $this->logger = $logger ?? new NullLogger(); - $this->nodeNamePolicy = $nodeNamePolicy; - $this->nodeMover = $nodeMover; + public function __construct( + private readonly LoggerInterface $logger, + private readonly NodeNamePolicyInterface $nodeNamePolicy, + private readonly NodeMover $nodeMover + ) { } /** diff --git a/src/EventSubscriber/NodesSourcesUrlsCacheEventSubscriber.php b/src/EventSubscriber/NodesSourcesUrlsCacheEventSubscriber.php index 19a51cbd..d6d9ccae 100644 --- a/src/EventSubscriber/NodesSourcesUrlsCacheEventSubscriber.php +++ b/src/EventSubscriber/NodesSourcesUrlsCacheEventSubscriber.php @@ -20,14 +20,8 @@ final class NodesSourcesUrlsCacheEventSubscriber implements EventSubscriberInterface { - private NodesSourcesUrlsCacheClearer $cacheClearer; - - /** - * @param NodesSourcesUrlsCacheClearer $cacheClearer - */ - public function __construct(NodesSourcesUrlsCacheClearer $cacheClearer) + public function __construct(private readonly NodesSourcesUrlsCacheClearer $cacheClearer) { - $this->cacheClearer = $cacheClearer; } /** diff --git a/src/EventSubscriber/RealmNodeInheritanceSubscriber.php b/src/EventSubscriber/RealmNodeInheritanceSubscriber.php index 22ffbd6f..d41b9d7e 100644 --- a/src/EventSubscriber/RealmNodeInheritanceSubscriber.php +++ b/src/EventSubscriber/RealmNodeInheritanceSubscriber.php @@ -19,14 +19,8 @@ final class RealmNodeInheritanceSubscriber implements EventSubscriberInterface { - private MessageBusInterface $bus; - - /** - * @param MessageBusInterface $bus - */ - public function __construct(MessageBusInterface $bus) + public function __construct(private readonly MessageBusInterface $bus) { - $this->bus = $bus; } /** diff --git a/src/EventSubscriber/ReverseProxyCacheEventSubscriber.php b/src/EventSubscriber/ReverseProxyCacheEventSubscriber.php index d59055fc..4285e7f4 100644 --- a/src/EventSubscriber/ReverseProxyCacheEventSubscriber.php +++ b/src/EventSubscriber/ReverseProxyCacheEventSubscriber.php @@ -21,23 +21,11 @@ final class ReverseProxyCacheEventSubscriber implements EventSubscriberInterface { - private ReverseProxyCacheLocator $reverseProxyCacheLocator; - private LoggerInterface $logger; - private MessageBusInterface $bus; - - /** - * @param ReverseProxyCacheLocator $reverseProxyCacheLocator - * @param MessageBusInterface $bus - * @param LoggerInterface $logger - */ public function __construct( - ReverseProxyCacheLocator $reverseProxyCacheLocator, - MessageBusInterface $bus, - LoggerInterface $logger + private readonly ReverseProxyCacheLocator $reverseProxyCacheLocator, + private readonly MessageBusInterface $bus, + private readonly LoggerInterface $logger ) { - $this->logger = $logger; - $this->bus = $bus; - $this->reverseProxyCacheLocator = $reverseProxyCacheLocator; } /** * @inheritDoc diff --git a/src/Filesystem/RoadizFileDirectories.php b/src/Filesystem/RoadizFileDirectories.php index 691e2f35..8a475cb9 100644 --- a/src/Filesystem/RoadizFileDirectories.php +++ b/src/Filesystem/RoadizFileDirectories.php @@ -8,14 +8,8 @@ final class RoadizFileDirectories implements FileAwareInterface { - private string $projectDir; - - /** - * @param string $projectDir - */ - public function __construct(string $projectDir) + public function __construct(private readonly string $projectDir) { - $this->projectDir = $projectDir; } public function getPublicFilesPath(): string diff --git a/src/Form/AttributeChoiceType.php b/src/Form/AttributeChoiceType.php index 5c421243..1a385c3e 100644 --- a/src/Form/AttributeChoiceType.php +++ b/src/Form/AttributeChoiceType.php @@ -16,7 +16,7 @@ final class AttributeChoiceType extends AbstractType { - public function __construct(private ManagerRegistry $managerRegistry) + public function __construct(private readonly ManagerRegistry $managerRegistry) { } diff --git a/src/Form/DataTransformer/AttributeDocumentsTransformer.php b/src/Form/DataTransformer/AttributeDocumentsTransformer.php index 61343456..da372aef 100644 --- a/src/Form/DataTransformer/AttributeDocumentsTransformer.php +++ b/src/Form/DataTransformer/AttributeDocumentsTransformer.php @@ -14,17 +14,8 @@ final class AttributeDocumentsTransformer implements DataTransformerInterface { - private ObjectManager $manager; - private Attribute $attribute; - - /** - * @param ObjectManager $manager - * @param Attribute $attribute - */ - public function __construct(ObjectManager $manager, Attribute $attribute) + public function __construct(private readonly ObjectManager $manager, private readonly Attribute $attribute) { - $this->manager = $manager; - $this->attribute = $attribute; } /** diff --git a/src/Form/Error/FormErrorSerializer.php b/src/Form/Error/FormErrorSerializer.php index 6c7b062e..4837bdc5 100644 --- a/src/Form/Error/FormErrorSerializer.php +++ b/src/Form/Error/FormErrorSerializer.php @@ -11,14 +11,8 @@ final class FormErrorSerializer implements FormErrorSerializerInterface { - private TranslatorInterface $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) + public function __construct(private readonly TranslatorInterface $translator) { - $this->translator = $translator; } public function getErrorsAsArray(FormInterface $form): array diff --git a/src/Form/RealmChoiceType.php b/src/Form/RealmChoiceType.php index a6f466fe..a92877b4 100644 --- a/src/Form/RealmChoiceType.php +++ b/src/Form/RealmChoiceType.php @@ -12,11 +12,8 @@ final class RealmChoiceType extends AbstractType { - private ManagerRegistry $managerRegistry; - - public function __construct(ManagerRegistry $managerRegistry) + public function __construct(private readonly ManagerRegistry $managerRegistry) { - $this->managerRegistry = $managerRegistry; } /** diff --git a/src/Form/RoleEntityType.php b/src/Form/RoleEntityType.php index 44d53e57..0ac24b40 100644 --- a/src/Form/RoleEntityType.php +++ b/src/Form/RoleEntityType.php @@ -14,13 +14,10 @@ final class RoleEntityType extends AbstractType { - private ManagerRegistry $managerRegistry; - private Security $security; - - public function __construct(ManagerRegistry $managerRegistry, Security $security) - { - $this->managerRegistry = $managerRegistry; - $this->security = $security; + public function __construct( + private readonly ManagerRegistry $managerRegistry, + private readonly Security $security + ) { } /** diff --git a/src/Form/UserCollectionType.php b/src/Form/UserCollectionType.php index ecef8dc5..e372ff50 100644 --- a/src/Form/UserCollectionType.php +++ b/src/Form/UserCollectionType.php @@ -14,11 +14,8 @@ final class UserCollectionType extends AbstractType { - private ManagerRegistry $managerRegistry; - - public function __construct(ManagerRegistry $managerRegistry) + public function __construct(private readonly ManagerRegistry $managerRegistry) { - $this->managerRegistry = $managerRegistry; } public function buildForm(FormBuilderInterface $builder, array $options): void diff --git a/src/Importer/AttributeImporter.php b/src/Importer/AttributeImporter.php index a47127db..a3c96fcb 100644 --- a/src/Importer/AttributeImporter.php +++ b/src/Importer/AttributeImporter.php @@ -11,14 +11,8 @@ final class AttributeImporter implements EntityImporterInterface { - protected SerializerInterface $serializer; - - /** - * @param SerializerInterface $serializer - */ - public function __construct(SerializerInterface $serializer) + public function __construct(private readonly SerializerInterface $serializer) { - $this->serializer = $serializer; } /** diff --git a/src/Logger/DoctrineHandler.php b/src/Logger/DoctrineHandler.php index bcc9e42c..99c540fd 100644 --- a/src/Logger/DoctrineHandler.php +++ b/src/Logger/DoctrineHandler.php @@ -24,24 +24,15 @@ */ final class DoctrineHandler extends AbstractProcessingHandler { - private ManagerRegistry $managerRegistry; - private TokenStorageInterface $tokenStorage; - private RequestStack $requestStack; - private DocumentUrlGeneratorInterface $documentUrlGenerator; - public function __construct( - ManagerRegistry $managerRegistry, - TokenStorageInterface $tokenStorage, - RequestStack $requestStack, - DocumentUrlGeneratorInterface $documentUrlGenerator, + private readonly ManagerRegistry $managerRegistry, + private readonly TokenStorageInterface $tokenStorage, + private readonly RequestStack $requestStack, + private readonly DocumentUrlGeneratorInterface $documentUrlGenerator, $level = Logger::INFO, $bubble = true ) { parent::__construct($level, $bubble); - $this->tokenStorage = $tokenStorage; - $this->requestStack = $requestStack; - $this->managerRegistry = $managerRegistry; - $this->documentUrlGenerator = $documentUrlGenerator; } protected function getThumbnailSourcePath(?DocumentInterface $thumbnail): ?string diff --git a/src/Mailer/ContactFormManager.php b/src/Mailer/ContactFormManager.php index 42e99289..2476885d 100644 --- a/src/Mailer/ContactFormManager.php +++ b/src/Mailer/ContactFormManager.php @@ -71,10 +71,10 @@ public function __construct( MailerInterface $mailer, Settings $settingsBag, DocumentUrlGeneratorInterface $documentUrlGenerator, - protected readonly FormFactoryInterface $formFactory, - protected readonly FormErrorSerializerInterface $formErrorSerializer, - protected readonly ?string $recaptchaPrivateKey, - protected readonly ?string $recaptchaPublicKey + private readonly FormFactoryInterface $formFactory, + private readonly FormErrorSerializerInterface $formErrorSerializer, + private readonly ?string $recaptchaPrivateKey, + private readonly ?string $recaptchaPublicKey ) { parent::__construct($requestStack, $translator, $templating, $mailer, $settingsBag, $documentUrlGenerator); diff --git a/src/Message/ApplyRealmNodeInheritanceMessage.php b/src/Message/ApplyRealmNodeInheritanceMessage.php index 7943f8a8..f00d994c 100644 --- a/src/Message/ApplyRealmNodeInheritanceMessage.php +++ b/src/Message/ApplyRealmNodeInheritanceMessage.php @@ -6,13 +6,10 @@ final class ApplyRealmNodeInheritanceMessage implements AsyncMessage { - private int|string|null $nodeId; - private int|string|null $realmId; - - public function __construct(int|string|null $nodeId, int|string|null $realmId) - { - $this->nodeId = $nodeId; - $this->realmId = $realmId; + public function __construct( + private readonly int|string|null $nodeId, + private readonly int|string|null $realmId + ) { } /** diff --git a/src/Message/CleanRealmNodeInheritanceMessage.php b/src/Message/CleanRealmNodeInheritanceMessage.php index cf1d1201..107e5b76 100644 --- a/src/Message/CleanRealmNodeInheritanceMessage.php +++ b/src/Message/CleanRealmNodeInheritanceMessage.php @@ -6,13 +6,10 @@ final class CleanRealmNodeInheritanceMessage implements AsyncMessage { - private int|string|null $nodeId; - private int|string|null $realmId; - - public function __construct(int|string|null $nodeId, int|string|null $realmId) - { - $this->nodeId = $nodeId; - $this->realmId = $realmId; + public function __construct( + private readonly int|string|null $nodeId, + private readonly int|string|null $realmId + ) { } /** diff --git a/src/Message/DeleteNodeTypeMessage.php b/src/Message/DeleteNodeTypeMessage.php index 0f3caca1..ca7566d8 100644 --- a/src/Message/DeleteNodeTypeMessage.php +++ b/src/Message/DeleteNodeTypeMessage.php @@ -6,14 +6,8 @@ final class DeleteNodeTypeMessage implements AsyncMessage { - private int|string|null $nodeTypeId; - - /** - * @param int|string|null $nodeTypeId - */ - public function __construct(int|string|null $nodeTypeId) + public function __construct(private readonly int|string|null $nodeTypeId) { - $this->nodeTypeId = $nodeTypeId; } /** diff --git a/src/Message/GuzzleRequestMessage.php b/src/Message/GuzzleRequestMessage.php index 458e8c8e..65bb93f7 100644 --- a/src/Message/GuzzleRequestMessage.php +++ b/src/Message/GuzzleRequestMessage.php @@ -8,16 +8,16 @@ final class GuzzleRequestMessage implements AsyncMessage, HttpRequestMessage { - private RequestInterface $request; private array $options; /** * @param RequestInterface $request * @param array $options */ - public function __construct(RequestInterface $request, array $options = []) - { - $this->request = $request; + public function __construct( + private readonly RequestInterface $request, + array $options = [] + ) { $this->options = array_merge([ 'debug' => false, 'timeout' => 3 diff --git a/src/Message/PurgeReverseProxyCacheMessage.php b/src/Message/PurgeReverseProxyCacheMessage.php index be0c54c0..d8a47f51 100644 --- a/src/Message/PurgeReverseProxyCacheMessage.php +++ b/src/Message/PurgeReverseProxyCacheMessage.php @@ -6,14 +6,8 @@ final class PurgeReverseProxyCacheMessage implements AsyncMessage { - private int|string|null $nodeSourceId; - - /** - * @param int|string|null $nodeSourceId - */ - public function __construct(int|string|null $nodeSourceId) + public function __construct(private readonly int|string|null $nodeSourceId) { - $this->nodeSourceId = $nodeSourceId; } /** diff --git a/src/Message/SearchRealmNodeInheritanceMessage.php b/src/Message/SearchRealmNodeInheritanceMessage.php index c9ec45ff..a1a634f2 100644 --- a/src/Message/SearchRealmNodeInheritanceMessage.php +++ b/src/Message/SearchRealmNodeInheritanceMessage.php @@ -6,11 +6,8 @@ final class SearchRealmNodeInheritanceMessage implements AsyncMessage { - private int|string|null $nodeId; - - public function __construct(int|string|null $nodeId) + public function __construct(private readonly int|string|null $nodeId) { - $this->nodeId = $nodeId; } /** diff --git a/src/Message/UpdateNodeTypeSchemaMessage.php b/src/Message/UpdateNodeTypeSchemaMessage.php index f4a309a5..33b36324 100644 --- a/src/Message/UpdateNodeTypeSchemaMessage.php +++ b/src/Message/UpdateNodeTypeSchemaMessage.php @@ -9,14 +9,8 @@ */ final class UpdateNodeTypeSchemaMessage { - private int|string|null $nodeTypeId; - - /** - * @param int|string|null $nodeTypeId - */ - public function __construct(int|string|null $nodeTypeId) + public function __construct(private readonly int|string|null $nodeTypeId) { - $this->nodeTypeId = $nodeTypeId; } /** diff --git a/src/Node/NodeDuplicator.php b/src/Node/NodeDuplicator.php index da995e69..f1b6c5a6 100644 --- a/src/Node/NodeDuplicator.php +++ b/src/Node/NodeDuplicator.php @@ -4,36 +4,25 @@ namespace RZ\Roadiz\CoreBundle\Node; -use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Persistence\ObjectManager; use RZ\Roadiz\CoreBundle\Entity\AttributeValue; use RZ\Roadiz\CoreBundle\Entity\Node; use RZ\Roadiz\CoreBundle\Entity\NodesSources; use RZ\Roadiz\CoreBundle\Entity\NodesSourcesDocuments; use RZ\Roadiz\CoreBundle\Entity\NodesToNodes; +use Symfony\Component\DependencyInjection\Attribute\Exclude; /** * Handles node duplication. */ +#[Exclude] final class NodeDuplicator { - private Node $originalNode; - private ObjectManager $objectManager; - private NodeNamePolicyInterface $nodeNamePolicy; - - /** - * @param Node $originalNode - * @param ObjectManager $objectManager - * @param NodeNamePolicyInterface $nodeNamePolicy - */ public function __construct( - Node $originalNode, - ObjectManager $objectManager, - NodeNamePolicyInterface $nodeNamePolicy + private readonly Node $originalNode, + private readonly ObjectManager $objectManager, + private readonly NodeNamePolicyInterface $nodeNamePolicy ) { - $this->objectManager = $objectManager; - $this->originalNode = $originalNode; - $this->nodeNamePolicy = $nodeNamePolicy; } /** @@ -136,9 +125,8 @@ private function doDuplicate(Node &$node): Node * Warning, do not do any FLUSH here to preserve transactional integrity. * * @param Node $node - * @return Node */ - private function doDuplicateNodeRelations(Node $node): Node + private function doDuplicateNodeRelations(Node $node): void { /** @var NodesToNodes[] $nodeRelations */ $nodeRelations = $node->getBNodes()->toArray(); @@ -148,7 +136,5 @@ private function doDuplicateNodeRelations(Node $node): Node $ntn->setPosition($position); $this->objectManager->persist($ntn); } - - return $node; } } diff --git a/src/Node/NodeNamePolicyFactory.php b/src/Node/NodeNamePolicyFactory.php index 20c78008..2eefaa2a 100644 --- a/src/Node/NodeNamePolicyFactory.php +++ b/src/Node/NodeNamePolicyFactory.php @@ -8,17 +8,10 @@ final class NodeNamePolicyFactory { - private ManagerRegistry $registry; - private bool $useTypedNodeNames; - - /** - * @param ManagerRegistry $registry - * @param bool $useTypedNodeNames - */ - public function __construct(ManagerRegistry $registry, bool $useTypedNodeNames) - { - $this->registry = $registry; - $this->useTypedNodeNames = $useTypedNodeNames; + public function __construct( + private readonly ManagerRegistry $registry, + private readonly bool $useTypedNodeNames + ) { } public function create(): NodeNamePolicyInterface diff --git a/src/Node/NodeTranslator.php b/src/Node/NodeTranslator.php index c4dbbb1c..be1d63ca 100644 --- a/src/Node/NodeTranslator.php +++ b/src/Node/NodeTranslator.php @@ -13,17 +13,10 @@ final class NodeTranslator { - private ManagerRegistry $managerRegistry; - private EventDispatcherInterface $dispatcher; - - /** - * @param ManagerRegistry $managerRegistry - * @param EventDispatcherInterface $dispatcher - */ - public function __construct(ManagerRegistry $managerRegistry, EventDispatcherInterface $dispatcher) - { - $this->managerRegistry = $managerRegistry; - $this->dispatcher = $dispatcher; + public function __construct( + private readonly ManagerRegistry $managerRegistry, + private readonly EventDispatcherInterface $dispatcher + ) { } public function translateNode( diff --git a/src/Node/UniversalDataDuplicator.php b/src/Node/UniversalDataDuplicator.php index c806f3ae..0f8c9803 100644 --- a/src/Node/UniversalDataDuplicator.php +++ b/src/Node/UniversalDataDuplicator.php @@ -16,14 +16,8 @@ final class UniversalDataDuplicator { - private ManagerRegistry $managerRegistry; - - /** - * @param ManagerRegistry $managerRegistry - */ - public function __construct(ManagerRegistry $managerRegistry) + public function __construct(private readonly ManagerRegistry $managerRegistry) { - $this->managerRegistry = $managerRegistry; } /** diff --git a/src/NodeType/DefaultValuesResolver.php b/src/NodeType/DefaultValuesResolver.php index e2180403..28739dd7 100644 --- a/src/NodeType/DefaultValuesResolver.php +++ b/src/NodeType/DefaultValuesResolver.php @@ -12,15 +12,10 @@ final class DefaultValuesResolver implements DefaultValuesResolverInterface { - private ManagerRegistry $managerRegistry; - private string $inheritanceType; - public function __construct( - ManagerRegistry $managerRegistry, - string $inheritanceType + private readonly ManagerRegistry $managerRegistry, + private readonly string $inheritanceType ) { - $this->managerRegistry = $managerRegistry; - $this->inheritanceType = $inheritanceType; } public function getDefaultValuesAmongAllFields(NodeTypeFieldInterface $field): array diff --git a/src/NodeType/NodeTypeResolver.php b/src/NodeType/NodeTypeResolver.php index d8dfdd67..687fa7b9 100644 --- a/src/NodeType/NodeTypeResolver.php +++ b/src/NodeType/NodeTypeResolver.php @@ -11,11 +11,8 @@ final class NodeTypeResolver { - private CacheItemPoolInterface $cacheAdapter; - - public function __construct(CacheItemPoolInterface $cacheAdapter) + public function __construct(private readonly CacheItemPoolInterface $cacheAdapter) { - $this->cacheAdapter = $cacheAdapter; } /** diff --git a/src/Preview/RequestPreviewRevolver.php b/src/Preview/RequestPreviewRevolver.php index b11944fb..46ff3646 100644 --- a/src/Preview/RequestPreviewRevolver.php +++ b/src/Preview/RequestPreviewRevolver.php @@ -13,15 +13,10 @@ */ final class RequestPreviewRevolver implements PreviewResolverInterface { - private RequestStack $requestStack; - private string $requiredRole; - public function __construct( - RequestStack $requestStack, - string $requiredRole + private readonly RequestStack $requestStack, + private readonly string $requiredRole ) { - $this->requestStack = $requestStack; - $this->requiredRole = $requiredRole; } /** diff --git a/src/Preview/User/PreviewUserProvider.php b/src/Preview/User/PreviewUserProvider.php index 70e07fb8..9184f8ef 100644 --- a/src/Preview/User/PreviewUserProvider.php +++ b/src/Preview/User/PreviewUserProvider.php @@ -11,17 +11,10 @@ final class PreviewUserProvider implements PreviewUserProviderInterface { - private PreviewResolverInterface $previewResolver; - private Security $security; - - /** - * @param PreviewResolverInterface $previewResolver - * @param Security $security - */ - public function __construct(PreviewResolverInterface $previewResolver, Security $security) - { - $this->previewResolver = $previewResolver; - $this->security = $security; + public function __construct( + private readonly PreviewResolverInterface $previewResolver, + private readonly Security $security + ) { } public function createFromSecurity(): UserInterface diff --git a/src/Repository/AttributeGroupRepository.php b/src/Repository/AttributeGroupRepository.php index b913a8da..45dd1b0c 100644 --- a/src/Repository/AttributeGroupRepository.php +++ b/src/Repository/AttributeGroupRepository.php @@ -13,8 +13,10 @@ */ final class AttributeGroupRepository extends EntityRepository { - public function __construct(ManagerRegistry $registry, EventDispatcherInterface $dispatcher) - { + public function __construct( + ManagerRegistry $registry, + EventDispatcherInterface $dispatcher + ) { parent::__construct($registry, AttributeGroup::class, $dispatcher); } } diff --git a/src/Repository/AttributeRepository.php b/src/Repository/AttributeRepository.php index a7d7da19..111e992f 100644 --- a/src/Repository/AttributeRepository.php +++ b/src/Repository/AttributeRepository.php @@ -13,8 +13,10 @@ */ final class AttributeRepository extends EntityRepository { - public function __construct(ManagerRegistry $registry, EventDispatcherInterface $dispatcher) - { + public function __construct( + ManagerRegistry $registry, + EventDispatcherInterface $dispatcher + ) { parent::__construct($registry, Attribute::class, $dispatcher); } } diff --git a/src/Repository/AttributeTranslationRepository.php b/src/Repository/AttributeTranslationRepository.php index 785d0faf..0fcb735a 100644 --- a/src/Repository/AttributeTranslationRepository.php +++ b/src/Repository/AttributeTranslationRepository.php @@ -13,8 +13,10 @@ */ final class AttributeTranslationRepository extends EntityRepository { - public function __construct(ManagerRegistry $registry, EventDispatcherInterface $dispatcher) - { + public function __construct( + ManagerRegistry $registry, + EventDispatcherInterface $dispatcher + ) { parent::__construct($registry, AttributeTranslation::class, $dispatcher); } } diff --git a/src/Repository/AttributeValueTranslationRepository.php b/src/Repository/AttributeValueTranslationRepository.php index eb3cb6e5..553db03c 100644 --- a/src/Repository/AttributeValueTranslationRepository.php +++ b/src/Repository/AttributeValueTranslationRepository.php @@ -13,8 +13,10 @@ */ final class AttributeValueTranslationRepository extends EntityRepository { - public function __construct(ManagerRegistry $registry, EventDispatcherInterface $dispatcher) - { + public function __construct( + ManagerRegistry $registry, + EventDispatcherInterface $dispatcher + ) { parent::__construct($registry, AttributeValueTranslation::class, $dispatcher); } } diff --git a/src/Repository/CustomFormAnswerRepository.php b/src/Repository/CustomFormAnswerRepository.php index d7774a73..36870df2 100644 --- a/src/Repository/CustomFormAnswerRepository.php +++ b/src/Repository/CustomFormAnswerRepository.php @@ -15,8 +15,10 @@ final class CustomFormAnswerRepository extends EntityRepository { - public function __construct(ManagerRegistry $registry, EventDispatcherInterface $dispatcher) - { + public function __construct( + ManagerRegistry $registry, + EventDispatcherInterface $dispatcher + ) { parent::__construct($registry, CustomFormAnswer::class, $dispatcher); } diff --git a/src/Repository/CustomFormFieldAttributeRepository.php b/src/Repository/CustomFormFieldAttributeRepository.php index fe4f039d..f89b32bd 100644 --- a/src/Repository/CustomFormFieldAttributeRepository.php +++ b/src/Repository/CustomFormFieldAttributeRepository.php @@ -13,8 +13,10 @@ */ final class CustomFormFieldAttributeRepository extends EntityRepository { - public function __construct(ManagerRegistry $registry, EventDispatcherInterface $dispatcher) - { + public function __construct( + ManagerRegistry $registry, + EventDispatcherInterface $dispatcher + ) { parent::__construct($registry, CustomFormFieldAttribute::class, $dispatcher); } } diff --git a/src/Repository/CustomFormFieldRepository.php b/src/Repository/CustomFormFieldRepository.php index 254ed1ff..117fe365 100644 --- a/src/Repository/CustomFormFieldRepository.php +++ b/src/Repository/CustomFormFieldRepository.php @@ -14,8 +14,10 @@ */ final class CustomFormFieldRepository extends EntityRepository { - public function __construct(ManagerRegistry $registry, EventDispatcherInterface $dispatcher) - { + public function __construct( + ManagerRegistry $registry, + EventDispatcherInterface $dispatcher + ) { parent::__construct($registry, CustomFormField::class, $dispatcher); } diff --git a/src/Repository/FolderTranslationRepository.php b/src/Repository/FolderTranslationRepository.php index 3224fcfa..3b78c003 100644 --- a/src/Repository/FolderTranslationRepository.php +++ b/src/Repository/FolderTranslationRepository.php @@ -13,8 +13,10 @@ */ final class FolderTranslationRepository extends EntityRepository { - public function __construct(ManagerRegistry $registry, EventDispatcherInterface $dispatcher) - { + public function __construct( + ManagerRegistry $registry, + EventDispatcherInterface $dispatcher + ) { parent::__construct($registry, FolderTranslation::class, $dispatcher); } } diff --git a/src/Repository/GroupRepository.php b/src/Repository/GroupRepository.php index d3660fd2..557e0166 100644 --- a/src/Repository/GroupRepository.php +++ b/src/Repository/GroupRepository.php @@ -18,8 +18,10 @@ */ final class GroupRepository extends EntityRepository { - public function __construct(ManagerRegistry $registry, EventDispatcherInterface $dispatcher) - { + public function __construct( + ManagerRegistry $registry, + EventDispatcherInterface $dispatcher + ) { parent::__construct($registry, Group::class, $dispatcher); } } diff --git a/src/Repository/RedirectionRepository.php b/src/Repository/RedirectionRepository.php index 507b4989..24cf7709 100644 --- a/src/Repository/RedirectionRepository.php +++ b/src/Repository/RedirectionRepository.php @@ -18,8 +18,10 @@ */ final class RedirectionRepository extends EntityRepository { - public function __construct(ManagerRegistry $registry, EventDispatcherInterface $dispatcher) - { + public function __construct( + ManagerRegistry $registry, + EventDispatcherInterface $dispatcher + ) { parent::__construct($registry, Redirection::class, $dispatcher); } } diff --git a/src/Repository/TagTranslationRepository.php b/src/Repository/TagTranslationRepository.php index 8c74f408..1683b98f 100644 --- a/src/Repository/TagTranslationRepository.php +++ b/src/Repository/TagTranslationRepository.php @@ -18,8 +18,10 @@ */ final class TagTranslationRepository extends EntityRepository { - public function __construct(ManagerRegistry $registry, EventDispatcherInterface $dispatcher) - { + public function __construct( + ManagerRegistry $registry, + EventDispatcherInterface $dispatcher + ) { parent::__construct($registry, TagTranslation::class, $dispatcher); } } diff --git a/src/Repository/WebhookRepository.php b/src/Repository/WebhookRepository.php index 7592cea6..cecbbc79 100644 --- a/src/Repository/WebhookRepository.php +++ b/src/Repository/WebhookRepository.php @@ -18,8 +18,10 @@ */ final class WebhookRepository extends EntityRepository { - public function __construct(ManagerRegistry $registry, EventDispatcherInterface $dispatcher) - { + public function __construct( + ManagerRegistry $registry, + EventDispatcherInterface $dispatcher + ) { parent::__construct($registry, Webhook::class, $dispatcher); } } diff --git a/src/SearchEngine/ClientRegistry.php b/src/SearchEngine/ClientRegistry.php index 0e9cae6c..85ef24f8 100644 --- a/src/SearchEngine/ClientRegistry.php +++ b/src/SearchEngine/ClientRegistry.php @@ -9,14 +9,8 @@ final class ClientRegistry { - protected ContainerInterface $container; - - /** - * @param ContainerInterface $container - */ - public function __construct(ContainerInterface $container) + public function __construct(private readonly ContainerInterface $container) { - $this->container = $container; } public function getClient(): ?Client diff --git a/src/SearchEngine/SolariumLogger.php b/src/SearchEngine/SolariumLogger.php index 120b0a67..fb0f7e19 100644 --- a/src/SearchEngine/SolariumLogger.php +++ b/src/SearchEngine/SolariumLogger.php @@ -29,14 +29,12 @@ final class SolariumLogger extends SolariumPlugin implements DataCollectorInterf private ?SolariumRequest $currentRequest = null; private ?float $currentStartTime = null; private ?SolariumEndpoint $currentEndpoint = null; - private LoggerInterface $logger; - private Stopwatch $stopwatch; - public function __construct(LoggerInterface $searchEngineLogger, Stopwatch $stopwatch) - { + public function __construct( + private readonly LoggerInterface $searchEngineLogger, + private readonly Stopwatch $stopwatch + ) { parent::__construct(); - $this->logger = $searchEngineLogger; - $this->stopwatch = $stopwatch; } public static function getSubscribedEvents(): array @@ -107,8 +105,7 @@ public function preExecuteRequest(SolariumPreExecuteRequestEvent $event): void $this->currentRequest = $event->getRequest(); $this->currentEndpoint = $event->getEndpoint(); - - $this->logger->debug($this->getEndpointBaseUrl($this->currentEndpoint) . $this->currentRequest->getUri()); + $this->searchEngineLogger->debug($this->getEndpointBaseUrl($this->currentEndpoint) . $this->currentRequest->getUri()); $this->currentStartTime = microtime(true); } diff --git a/src/SearchEngine/SolrSearchResultItem.php b/src/SearchEngine/SolrSearchResultItem.php index 9f26b97c..ac474955 100644 --- a/src/SearchEngine/SolrSearchResultItem.php +++ b/src/SearchEngine/SolrSearchResultItem.php @@ -21,8 +21,8 @@ final class SolrSearchResultItem * @param array> $highlighting */ public function __construct( - protected readonly object $item, - protected readonly array $highlighting = [] + private readonly object $item, + private readonly array $highlighting = [] ) { } diff --git a/src/SearchEngine/Subscriber/SolariumSubscriber.php b/src/SearchEngine/Subscriber/SolariumSubscriber.php index 05868eca..397b1455 100644 --- a/src/SearchEngine/Subscriber/SolariumSubscriber.php +++ b/src/SearchEngine/Subscriber/SolariumSubscriber.php @@ -36,11 +36,8 @@ final class SolariumSubscriber implements EventSubscriberInterface { - protected MessageBusInterface $messageBus; - - public function __construct(MessageBusInterface $messageBus) + public function __construct(private readonly MessageBusInterface $messageBus) { - $this->messageBus = $messageBus; } public static function getSubscribedEvents(): array diff --git a/src/SearchEngine/Subscriber/TreeWalkerIndexingEventSubscriber.php b/src/SearchEngine/Subscriber/TreeWalkerIndexingEventSubscriber.php index 76ccc9ef..cc104e46 100644 --- a/src/SearchEngine/Subscriber/TreeWalkerIndexingEventSubscriber.php +++ b/src/SearchEngine/Subscriber/TreeWalkerIndexingEventSubscriber.php @@ -16,21 +16,12 @@ */ final class TreeWalkerIndexingEventSubscriber extends AbstractIndexingSubscriber { - private WalkerContextInterface $walkerContext; - private SolariumFactoryInterface $solariumFactory; - private int $maxLevel; - private string $defaultLocale; - public function __construct( - WalkerContextInterface $walkerContext, - SolariumFactoryInterface $solariumFactory, - int $maxLevel = 5, - string $defaultLocale = 'en' + private readonly WalkerContextInterface $walkerContext, + private readonly SolariumFactoryInterface $solariumFactory, + private readonly int $maxLevel = 5, + private readonly string $defaultLocale = 'en' ) { - $this->walkerContext = $walkerContext; - $this->solariumFactory = $solariumFactory; - $this->maxLevel = $maxLevel; - $this->defaultLocale = $defaultLocale; } /** diff --git a/src/Tag/TagFactory.php b/src/Tag/TagFactory.php index 4a3f7828..9a7c79fa 100644 --- a/src/Tag/TagFactory.php +++ b/src/Tag/TagFactory.php @@ -13,14 +13,8 @@ final class TagFactory { - private ManagerRegistry $managerRegistry; - - /** - * @param ManagerRegistry $managerRegistry - */ - public function __construct(ManagerRegistry $managerRegistry) + public function __construct(private readonly ManagerRegistry $managerRegistry) { - $this->managerRegistry = $managerRegistry; } /** diff --git a/src/Translation/TranslationViewer.php b/src/Translation/TranslationViewer.php index af42958e..450d746b 100644 --- a/src/Translation/TranslationViewer.php +++ b/src/Translation/TranslationViewer.php @@ -21,28 +21,14 @@ final class TranslationViewer { - private Settings $settingsBag; - private ManagerRegistry $managerRegistry; - private RouterInterface $router; - private PreviewResolverInterface $previewResolver; private ?TranslationInterface $translation = null; - /** - * @param ManagerRegistry $managerRegistry - * @param Settings $settingsBag - * @param RouterInterface $router - * @param PreviewResolverInterface $previewResolver - */ public function __construct( - ManagerRegistry $managerRegistry, - Settings $settingsBag, - RouterInterface $router, - PreviewResolverInterface $previewResolver + private readonly ManagerRegistry $managerRegistry, + private readonly Settings $settingsBag, + private readonly RouterInterface $router, + private readonly PreviewResolverInterface $previewResolver ) { - $this->settingsBag = $settingsBag; - $this->router = $router; - $this->previewResolver = $previewResolver; - $this->managerRegistry = $managerRegistry; } /** diff --git a/src/TwigExtension/RoutingExtension.php b/src/TwigExtension/RoutingExtension.php index f78d3dd3..adb4d9ac 100644 --- a/src/TwigExtension/RoutingExtension.php +++ b/src/TwigExtension/RoutingExtension.php @@ -4,6 +4,7 @@ namespace RZ\Roadiz\CoreBundle\TwigExtension; +use Symfony\Bridge\Twig\Extension\RoutingExtension as BaseRoutingExtension; use Symfony\Cmf\Component\Routing\RouteObjectInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Twig\Error\RuntimeError; @@ -17,7 +18,7 @@ final class RoutingExtension extends AbstractExtension { public function __construct( - private readonly \Symfony\Bridge\Twig\Extension\RoutingExtension $decorated, + private readonly BaseRoutingExtension $decorated, private readonly UrlGeneratorInterface $generator ) { } diff --git a/src/Webhook/Exception/TooManyWebhookTriggeredException.php b/src/Webhook/Exception/TooManyWebhookTriggeredException.php index 67163dae..c53c4b58 100644 --- a/src/Webhook/Exception/TooManyWebhookTriggeredException.php +++ b/src/Webhook/Exception/TooManyWebhookTriggeredException.php @@ -8,16 +8,13 @@ final class TooManyWebhookTriggeredException extends \RuntimeException { - private ?\DateTimeImmutable $doNotTriggerBefore; - public function __construct( - ?\DateTimeImmutable $doNotTriggerBefore = null, + private readonly ?\DateTimeImmutable $doNotTriggerBefore = null, string $message = "", int $code = 0, Throwable $previous = null ) { parent::__construct($message, $code, $previous); - $this->doNotTriggerBefore = $doNotTriggerBefore; } /** diff --git a/src/Webhook/Message/GenericJsonPostMessage.php b/src/Webhook/Message/GenericJsonPostMessage.php index 8d9f739f..cd8d9c4b 100644 --- a/src/Webhook/Message/GenericJsonPostMessage.php +++ b/src/Webhook/Message/GenericJsonPostMessage.php @@ -13,17 +13,10 @@ final class GenericJsonPostMessage implements AsyncMessage, HttpRequestMessage, WebhookMessage { - private string $uri; - private ?array $payload; - - /** - * @param string $uri - * @param array|null $payload - */ - public function __construct(string $uri, ?array $payload = null) - { - $this->uri = $uri; - $this->payload = $payload; + public function __construct( + private readonly string $uri, + private readonly ?array $payload = null + ) { } public function getRequest(): RequestInterface @@ -54,7 +47,7 @@ public function getOptions(): array * @param Webhook $webhook * @return static */ - public static function fromWebhook(WebhookInterface $webhook) + public static function fromWebhook(WebhookInterface $webhook): self { return new self($webhook->getUri(), $webhook->getPayload()); } diff --git a/src/Webhook/Message/GitlabPipelineTriggerMessage.php b/src/Webhook/Message/GitlabPipelineTriggerMessage.php index 875d856d..8783c286 100644 --- a/src/Webhook/Message/GitlabPipelineTriggerMessage.php +++ b/src/Webhook/Message/GitlabPipelineTriggerMessage.php @@ -12,23 +12,12 @@ final class GitlabPipelineTriggerMessage implements AsyncMessage, HttpRequestMessage, WebhookMessage { - private string $uri; - private string $token; - private string $ref; - private ?array $variables; - - /** - * @param string $uri - * @param string $token - * @param string $ref - * @param array|null $variables - */ - public function __construct(string $uri, string $token, string $ref = 'main', ?array $variables = null) - { - $this->uri = $uri; - $this->token = $token; - $this->ref = $ref; - $this->variables = $variables; + public function __construct( + private readonly string $uri, + private readonly string $token, + private readonly string $ref = 'main', + private readonly ?array $variables = null + ) { } public function getRequest(): RequestInterface @@ -67,7 +56,7 @@ public function getOptions(): array * @param WebhookInterface $webhook * @return static */ - public static function fromWebhook(WebhookInterface $webhook) + public static function fromWebhook(WebhookInterface $webhook): self { $payload = $webhook->getPayload(); return new self( diff --git a/src/Webhook/Message/NetlifyBuildHookMessage.php b/src/Webhook/Message/NetlifyBuildHookMessage.php index 76cdf7e1..dc0ee797 100644 --- a/src/Webhook/Message/NetlifyBuildHookMessage.php +++ b/src/Webhook/Message/NetlifyBuildHookMessage.php @@ -12,17 +12,10 @@ final class NetlifyBuildHookMessage implements AsyncMessage, HttpRequestMessage, WebhookMessage { - private string $uri; - private ?array $payload; - - /** - * @param string $uri - * @param array|null $payload - */ - public function __construct(string $uri, ?array $payload = null) - { - $this->uri = $uri; - $this->payload = $payload; + public function __construct( + private readonly string $uri, + private readonly ?array $payload = null + ) { } public function getRequest(): RequestInterface @@ -56,7 +49,7 @@ public function getOptions(): array * @param WebhookInterface $webhook * @return static */ - public static function fromWebhook(WebhookInterface $webhook) + public static function fromWebhook(WebhookInterface $webhook): self { return new self($webhook->getUri(), $webhook->getPayload()); } diff --git a/src/Webhook/ThrottledWebhookDispatcher.php b/src/Webhook/ThrottledWebhookDispatcher.php index 48810428..82e08d8d 100644 --- a/src/Webhook/ThrottledWebhookDispatcher.php +++ b/src/Webhook/ThrottledWebhookDispatcher.php @@ -12,18 +12,11 @@ final class ThrottledWebhookDispatcher implements WebhookDispatcher { - private WebhookMessageFactoryInterface $messageFactory; - private MessageBusInterface $messageBus; - private RateLimiterFactory $throttledWebhooksLimiter; - public function __construct( - WebhookMessageFactoryInterface $messageFactory, - MessageBusInterface $messageBus, - RateLimiterFactory $throttledWebhooksLimiter + private readonly WebhookMessageFactoryInterface $messageFactory, + private readonly MessageBusInterface $messageBus, + private readonly RateLimiterFactory $throttledWebhooksLimiter ) { - $this->messageFactory = $messageFactory; - $this->messageBus = $messageBus; - $this->throttledWebhooksLimiter = $throttledWebhooksLimiter; } /** diff --git a/src/Workflow/Event/NodeStatusGuardListener.php b/src/Workflow/Event/NodeStatusGuardListener.php index edc6b66e..742fa04c 100644 --- a/src/Workflow/Event/NodeStatusGuardListener.php +++ b/src/Workflow/Event/NodeStatusGuardListener.php @@ -13,14 +13,8 @@ final class NodeStatusGuardListener implements EventSubscriberInterface { - private Security $security; - - /** - * @param Security $security - */ - public function __construct(Security $security) + public function __construct(private readonly Security $security) { - $this->security = $security; } /** diff --git a/src/Xlsx/AbstractXlsxSerializer.php b/src/Xlsx/AbstractXlsxSerializer.php index 4e6340d4..664457b4 100644 --- a/src/Xlsx/AbstractXlsxSerializer.php +++ b/src/Xlsx/AbstractXlsxSerializer.php @@ -7,18 +7,13 @@ use Symfony\Contracts\Translation\TranslatorInterface; /** + * @deprecated XLSX serialization is deprecated and will be removed in next major version. * Define basic serialize operations for XLSX data type. */ abstract class AbstractXlsxSerializer implements SerializerInterface { - protected TranslatorInterface $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) + public function __construct(protected readonly TranslatorInterface $translator) { - $this->translator = $translator; } /** diff --git a/src/Xlsx/NodeSourceXlsxSerializer.php b/src/Xlsx/NodeSourceXlsxSerializer.php index 56e19597..40747f99 100644 --- a/src/Xlsx/NodeSourceXlsxSerializer.php +++ b/src/Xlsx/NodeSourceXlsxSerializer.php @@ -4,49 +4,36 @@ namespace RZ\Roadiz\CoreBundle\Xlsx; -use Doctrine\Common\Collections\Collection; use Doctrine\Persistence\ObjectManager; use RZ\Roadiz\Contracts\NodeType\NodeTypeInterface; use RZ\Roadiz\Core\AbstractEntities\AbstractField; use RZ\Roadiz\CoreBundle\Entity\NodesSources; use RZ\Roadiz\CoreBundle\Entity\NodeTypeField; use Symfony\Cmf\Component\Routing\RouteObjectInterface; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Contracts\Translation\TranslatorInterface; /** + * @deprecated XLSX serialization is deprecated and will be removed in next major version. * XLSX Serialization handler for NodeSource. */ -class NodeSourceXlsxSerializer extends AbstractXlsxSerializer +final class NodeSourceXlsxSerializer extends AbstractXlsxSerializer { - protected ObjectManager $objectManager; - protected Request $request; - protected UrlGeneratorInterface $urlGenerator; - protected bool $forceLocale = false; protected bool $addUrls = false; protected bool $onlyTexts = false; - /** - * - * @param ObjectManager $objectManager - * @param TranslatorInterface $translator - * @param UrlGeneratorInterface $urlGenerator - */ public function __construct( - ObjectManager $objectManager, TranslatorInterface $translator, - UrlGeneratorInterface $urlGenerator + private readonly ObjectManager $objectManager, + private readonly UrlGeneratorInterface $urlGenerator ) { parent::__construct($translator); - $this->objectManager = $objectManager; - $this->urlGenerator = $urlGenerator; } /** * Create a simple associative array with a NodeSource. * - * @param NodesSources|Collection|array|null $nodeSource + * @param NodesSources|iterable|null $nodeSource * @return array */ public function toArray($nodeSource): array @@ -71,7 +58,7 @@ public function toArray($nodeSource): array $data['meta_description'] = $nodeSource->getMetaDescription(); $data = array_merge($data, $this->getSourceFields($nodeSource)); - } elseif ($nodeSource instanceof Collection || is_array($nodeSource)) { + } elseif (is_iterable($nodeSource)) { /* * If asked to serialize a nodeSource collection */ @@ -165,15 +152,11 @@ public function setOnlyTexts(bool $onlyTexts = true): self } /** - * @param Request $request - * @param bool $forceLocale * @return NodeSourceXlsxSerializer */ - public function addUrls(Request $request, bool $forceLocale = false): self + public function addUrls(): self { $this->addUrls = true; - $this->request = $request; - $this->forceLocale = $forceLocale; return $this; } } diff --git a/src/Xlsx/SerializerInterface.php b/src/Xlsx/SerializerInterface.php index 07229172..7cfde0e3 100644 --- a/src/Xlsx/SerializerInterface.php +++ b/src/Xlsx/SerializerInterface.php @@ -5,6 +5,7 @@ namespace RZ\Roadiz\CoreBundle\Xlsx; /** + * @deprecated XLSX serialization is deprecated and will be removed in next major version. * EntitySerializer that implements simple serialization/deserialization methods. */ interface SerializerInterface diff --git a/src/Xlsx/XlsxExporter.php b/src/Xlsx/XlsxExporter.php index 633d7017..e82e931f 100644 --- a/src/Xlsx/XlsxExporter.php +++ b/src/Xlsx/XlsxExporter.php @@ -11,16 +11,13 @@ use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use Symfony\Contracts\Translation\TranslatorInterface; +/** + * @deprecated XLSX serialization is deprecated and will be removed in next major version. + */ class XlsxExporter { - protected TranslatorInterface $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) + public function __construct(protected readonly TranslatorInterface $translator) { - $this->translator = $translator; } /** diff --git a/templates/customForm/base_custom_form.html.twig b/templates/customForm/base_custom_form.html.twig index 0111cce7..e1b14ada 100644 --- a/templates/customForm/base_custom_form.html.twig +++ b/templates/customForm/base_custom_form.html.twig @@ -1,26 +1,34 @@ -{% set formattedLocale = request.locale|replace({'_': '-'})|lower %} +{% set formattedLocale = app.request.locale|replace({'_': '-'})|lower %} - - - - - {% block title %}{{ head.siteTitle }}{% endblock %} - - - - {% include '@RoadizRozier/partials/css-inject.html.twig' %} - - - - - - -
- {% block content %} -

{% trans %}Welcome{% endtrans %}

- {% endblock %} -
- - - + + + + + {% block title %}{{ head.siteTitle }}{% endblock %} + + + {% include '@RoadizRozier/admin/meta-icon.html.twig' %} + {# CSS scripts inclusions / Using webpack #} + {% include '@RoadizRozier/partials/css-inject.html.twig' %} + {% if head.mainColor %} + + {% endif %} + + + +{% include '@RoadizRozier/includes/messages.html.twig' %} +
+ {% block content %} +

{% trans %}Welcome{% endtrans %}

+ {% endblock %} +
+{% block customScripts %}{% endblock %} + diff --git a/templates/customForm/customForm.html.twig b/templates/customForm/customForm.html.twig index 86d9b857..893ceff0 100644 --- a/templates/customForm/customForm.html.twig +++ b/templates/customForm/customForm.html.twig @@ -1,6 +1,6 @@ {% extends '@RoadizCore/customForm/base_custom_form.html.twig' %} -{% block title %}{{ customForm.displayName }}{% endblock %} +{% block title %}{{ customForm.displayName }} | {{ parent() }}{% endblock %} {% block content %}
diff --git a/templates/customForm/customFormSent.html.twig b/templates/customForm/customFormSent.html.twig index e9c4a655..2127bfd2 100644 --- a/templates/customForm/customFormSent.html.twig +++ b/templates/customForm/customFormSent.html.twig @@ -1,6 +1,6 @@ {% extends '@RoadizCore/customForm/base_custom_form.html.twig' %} -{% block title %}{{ customForm.displayName }}{% endblock %} +{% block title %}{{ customForm.displayName }} | {{ parent() }}{% endblock %} {% block content %}
diff --git a/src/Test/NodeType/ApiResourceGeneratorTest.php b/tests/NodeType/ApiResourceGeneratorTest.php similarity index 75% rename from src/Test/NodeType/ApiResourceGeneratorTest.php rename to tests/NodeType/ApiResourceGeneratorTest.php index 138a8efc..6af763db 100644 --- a/src/Test/NodeType/ApiResourceGeneratorTest.php +++ b/tests/NodeType/ApiResourceGeneratorTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace RZ\Roadiz\CoreBundle\Test\NodeType; +namespace RZ\Roadiz\CoreBundle\Tests\NodeType; use Psr\Log\NullLogger; use RZ\Roadiz\CoreBundle\Api\Model\WebResponse; @@ -16,7 +16,7 @@ class ApiResourceGeneratorTest extends KernelTestCase { protected static function getGeneratedPath(): string { - return dirname(__DIR__) . '/../../tests/generated_api_resources'; + return dirname(__DIR__) . '/generated_api_resources'; } protected function getApiResourceGenerator(): ApiResourceGenerator @@ -43,7 +43,7 @@ public function testGenerate(): void $resourcePath = $apiResourceGenerator->getResourcePath($nodeType); $this->assertFileExists($resourcePath); $this->assertFileEquals( - dirname(__DIR__) . '/../../tests/expected_api_resources/nstest.yml', + dirname(__DIR__) . '/expected_api_resources/nstest.yml', $resourcePath ); } @@ -59,14 +59,14 @@ public function testReachableGenerate(): void $apiResourceGenerator->generate($nodeType); $resourcePath = $apiResourceGenerator->getResourcePath($nodeType); $this->assertFileExists($resourcePath); - $this->assertFileExists(dirname(__DIR__) . '/../../tests/generated_api_resources/web_response.yml'); + $this->assertFileExists(dirname(__DIR__) . '/generated_api_resources/web_response.yml'); $this->assertFileEquals( - dirname(__DIR__) . '/../../tests/expected_api_resources/nstest.yml', + dirname(__DIR__) . '/expected_api_resources/nstest.yml', $resourcePath ); $this->assertFileEquals( - dirname(__DIR__) . '/../../tests/expected_api_resources/web_response.yml', - dirname(__DIR__) . '/../../tests/generated_api_resources/web_response.yml', + dirname(__DIR__) . '/expected_api_resources/web_response.yml', + dirname(__DIR__) . '/generated_api_resources/web_response.yml', ); } @@ -86,7 +86,7 @@ public function testMultipleGenerate(): void $resourcePath = $apiResourceGenerator->getResourcePath($nodeType); $this->assertFileExists($resourcePath); $this->assertFileEquals( - dirname(__DIR__) . '/../../tests/expected_api_resources/nstest.yml', + dirname(__DIR__) . '/expected_api_resources/nstest.yml', $resourcePath ); @@ -94,14 +94,14 @@ public function testMultipleGenerate(): void $resourcePath2 = $apiResourceGenerator->getResourcePath($nodeType2); $this->assertFileExists($resourcePath2); $this->assertFileEquals( - dirname(__DIR__) . '/../../tests/expected_api_resources/nssecondtest.yml', + dirname(__DIR__) . '/expected_api_resources/nssecondtest.yml', $resourcePath2 ); - $this->assertFileExists(dirname(__DIR__) . '/../../tests/generated_api_resources/web_response.yml'); + $this->assertFileExists(dirname(__DIR__) . '/generated_api_resources/web_response.yml'); $this->assertFileEquals( - dirname(__DIR__) . '/../../tests/expected_api_resources/web_response_multiple.yml', - dirname(__DIR__) . '/../../tests/generated_api_resources/web_response.yml', + dirname(__DIR__) . '/expected_api_resources/web_response_multiple.yml', + dirname(__DIR__) . '/generated_api_resources/web_response.yml', ); } @@ -126,10 +126,10 @@ public function testRemoveGenerate(): void $resourcePath2 = $apiResourceGenerator->getResourcePath($nodeType2); $this->assertFileDoesNotExist($resourcePath2); - $this->assertFileExists(dirname(__DIR__) . '/../../tests/generated_api_resources/web_response.yml'); + $this->assertFileExists(dirname(__DIR__) . '/generated_api_resources/web_response.yml'); $this->assertFileEquals( - dirname(__DIR__) . '/../../tests/expected_api_resources/web_response.yml', - dirname(__DIR__) . '/../../tests/generated_api_resources/web_response.yml', + dirname(__DIR__) . '/expected_api_resources/web_response.yml', + dirname(__DIR__) . '/generated_api_resources/web_response.yml', ); } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 469dccee..7cfee6d9 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,7 +2,12 @@ use Symfony\Component\Dotenv\Dotenv; -require dirname(__DIR__).'/vendor/autoload.php'; +// Allow testing in Monorepo environment +if (file_exists(dirname(__DIR__).'/vendor/autoload.php')) { + require dirname(__DIR__).'/vendor/autoload.php'; +} elseif (file_exists(dirname(__DIR__).'/../../vendor/autoload.php')) { + require dirname(__DIR__).'/../../vendor/autoload.php'; +} if (file_exists(dirname(__DIR__).'/config/bootstrap.php')) { require dirname(__DIR__).'/config/bootstrap.php';