diff --git a/lib/Rozier/src/AjaxControllers/AjaxAbstractFieldsController.php b/lib/Rozier/src/AjaxControllers/AjaxAbstractFieldsController.php index 832660ba..43146921 100644 --- a/lib/Rozier/src/AjaxControllers/AjaxAbstractFieldsController.php +++ b/lib/Rozier/src/AjaxControllers/AjaxAbstractFieldsController.php @@ -12,14 +12,8 @@ abstract class AjaxAbstractFieldsController extends AbstractAjaxController { - private HandlerFactoryInterface $handlerFactory; - - /** - * @param HandlerFactoryInterface $handlerFactory - */ - public function __construct(HandlerFactoryInterface $handlerFactory) + public function __construct(protected readonly HandlerFactoryInterface $handlerFactory) { - $this->handlerFactory = $handlerFactory; } /** @@ -30,7 +24,7 @@ public function __construct(HandlerFactoryInterface $handlerFactory) * * @return null|Response */ - protected function handleFieldActions(Request $request, AbstractField $field = null) + protected function handleFieldActions(Request $request, AbstractField $field = null): ?Response { /* * Validate diff --git a/lib/Rozier/src/AjaxControllers/AjaxAttributeValuesController.php b/lib/Rozier/src/AjaxControllers/AjaxAttributeValuesController.php index a10af158..d0593e9a 100644 --- a/lib/Rozier/src/AjaxControllers/AjaxAttributeValuesController.php +++ b/lib/Rozier/src/AjaxControllers/AjaxAttributeValuesController.php @@ -63,13 +63,7 @@ public function editAction(Request $request, int $attributeValueId): Response ); } - /** - * @param array $parameters - * @param AttributeValue $attributeValue - * - * @return array - */ - protected function updatePosition($parameters, AttributeValue $attributeValue): array + protected function updatePosition(array $parameters, AttributeValue $attributeValue): array { $attributable = $attributeValue->getAttributable(); $details = [ diff --git a/lib/Rozier/src/AjaxControllers/AjaxCustomFormFieldsController.php b/lib/Rozier/src/AjaxControllers/AjaxCustomFormFieldsController.php index fe2e10e8..fc2307d4 100644 --- a/lib/Rozier/src/AjaxControllers/AjaxCustomFormFieldsController.php +++ b/lib/Rozier/src/AjaxControllers/AjaxCustomFormFieldsController.php @@ -15,11 +15,11 @@ class AjaxCustomFormFieldsController extends AjaxAbstractFieldsController * such as coming from widgets. * * @param Request $request - * @param int $customFormFieldId + * @param int $customFormFieldId * * @return Response JSON response */ - public function editAction(Request $request, int $customFormFieldId) + public function editAction(Request $request, int $customFormFieldId): Response { /* * Validate diff --git a/lib/Rozier/src/AjaxControllers/AjaxCustomFormsExplorerController.php b/lib/Rozier/src/AjaxControllers/AjaxCustomFormsExplorerController.php index d4e3e152..8c8707f2 100644 --- a/lib/Rozier/src/AjaxControllers/AjaxCustomFormsExplorerController.php +++ b/lib/Rozier/src/AjaxControllers/AjaxCustomFormsExplorerController.php @@ -15,11 +15,8 @@ class AjaxCustomFormsExplorerController extends AbstractAjaxController { - private UrlGeneratorInterface $urlGenerator; - - public function __construct(UrlGeneratorInterface $urlGenerator) + public function __construct(private readonly UrlGeneratorInterface $urlGenerator) { - $this->urlGenerator = $urlGenerator; } /** @@ -108,7 +105,7 @@ public function listAction(Request $request): Response * @param array|\Traversable $customForms * @return array */ - private function normalizeCustomForms($customForms) + private function normalizeCustomForms(iterable $customForms): array { $customFormsArray = []; diff --git a/lib/Rozier/src/AjaxControllers/AjaxDocumentsExplorerController.php b/lib/Rozier/src/AjaxControllers/AjaxDocumentsExplorerController.php index dfc32b9b..5936a864 100644 --- a/lib/Rozier/src/AjaxControllers/AjaxDocumentsExplorerController.php +++ b/lib/Rozier/src/AjaxControllers/AjaxDocumentsExplorerController.php @@ -11,28 +11,18 @@ use RZ\Roadiz\Documents\UrlGenerators\DocumentUrlGeneratorInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Exception\InvalidParameterException; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Themes\Rozier\Models\DocumentModel; class AjaxDocumentsExplorerController extends AbstractAjaxController { - private RendererInterface $renderer; - private DocumentUrlGeneratorInterface $documentUrlGenerator; - private UrlGeneratorInterface $urlGenerator; - private EmbedFinderFactory $embedFinderFactory; - public function __construct( - RendererInterface $renderer, - DocumentUrlGeneratorInterface $documentUrlGenerator, - UrlGeneratorInterface $urlGenerator, - EmbedFinderFactory $embedFinderFactory + private readonly RendererInterface $renderer, + private readonly DocumentUrlGeneratorInterface $documentUrlGenerator, + private readonly UrlGeneratorInterface $urlGenerator, + private readonly EmbedFinderFactory $embedFinderFactory ) { - $this->renderer = $renderer; - $this->documentUrlGenerator = $documentUrlGenerator; - $this->urlGenerator = $urlGenerator; - $this->embedFinderFactory = $embedFinderFactory; } public static array $thumbnailArray = [ @@ -40,12 +30,8 @@ public function __construct( "quality" => 50, "inline" => false, ]; - /** - * @param Request $request - * - * @return Response JSON response - */ - public function indexAction(Request $request) + + public function indexAction(Request $request): JsonResponse { $this->denyAccessUnlessGranted('ROLE_ACCESS_DOCUMENTS'); @@ -108,7 +94,7 @@ public function indexAction(Request $request) * @param Request $request * @return JsonResponse */ - public function listAction(Request $request) + public function listAction(Request $request): JsonResponse { $this->denyAccessUnlessGranted('ROLE_ACCESS_DOCUMENTS'); diff --git a/lib/Rozier/src/AjaxControllers/AjaxEntitiesExplorerController.php b/lib/Rozier/src/AjaxControllers/AjaxEntitiesExplorerController.php index d22ae0c1..e7fb58ce 100644 --- a/lib/Rozier/src/AjaxControllers/AjaxEntitiesExplorerController.php +++ b/lib/Rozier/src/AjaxControllers/AjaxEntitiesExplorerController.php @@ -28,21 +28,12 @@ class AjaxEntitiesExplorerController extends AbstractAjaxController { - private RendererInterface $renderer; - private DocumentUrlGeneratorInterface $documentUrlGenerator; - private UrlGeneratorInterface $urlGenerator; - private EmbedFinderFactory $embedFinderFactory; - public function __construct( - RendererInterface $renderer, - DocumentUrlGeneratorInterface $documentUrlGenerator, - UrlGeneratorInterface $urlGenerator, - EmbedFinderFactory $embedFinderFactory + private readonly RendererInterface $renderer, + private readonly DocumentUrlGeneratorInterface $documentUrlGenerator, + private readonly UrlGeneratorInterface $urlGenerator, + private readonly EmbedFinderFactory $embedFinderFactory ) { - $this->renderer = $renderer; - $this->documentUrlGenerator = $documentUrlGenerator; - $this->urlGenerator = $urlGenerator; - $this->embedFinderFactory = $embedFinderFactory; } /** @@ -118,12 +109,6 @@ public function indexAction(Request $request): JsonResponse ); } - /** - * Get a Node list from an array of id. - * - * @param Request $request - * @return JsonResponse - */ public function listAction(Request $request): JsonResponse { if (!$request->query->has('nodeTypeFieldId')) { diff --git a/lib/Rozier/src/AjaxControllers/AjaxExplorerProviderController.php b/lib/Rozier/src/AjaxControllers/AjaxExplorerProviderController.php index c09b77cd..3ea4fe98 100644 --- a/lib/Rozier/src/AjaxControllers/AjaxExplorerProviderController.php +++ b/lib/Rozier/src/AjaxControllers/AjaxExplorerProviderController.php @@ -17,11 +17,8 @@ class AjaxExplorerProviderController extends AbstractAjaxController { - private ContainerInterface $psrContainer; - - public function __construct(ContainerInterface $psrContainer) + public function __construct(private readonly ContainerInterface $psrContainer) { - $this->psrContainer = $psrContainer; } /** diff --git a/lib/Rozier/src/AjaxControllers/AjaxFolderTreeController.php b/lib/Rozier/src/AjaxControllers/AjaxFolderTreeController.php index 68237a36..1d934a54 100644 --- a/lib/Rozier/src/AjaxControllers/AjaxFolderTreeController.php +++ b/lib/Rozier/src/AjaxControllers/AjaxFolderTreeController.php @@ -12,11 +12,8 @@ class AjaxFolderTreeController extends AbstractAjaxController { - private TreeWidgetFactory $treeWidgetFactory; - - public function __construct(TreeWidgetFactory $treeWidgetFactory) + public function __construct(private readonly TreeWidgetFactory $treeWidgetFactory) { - $this->treeWidgetFactory = $treeWidgetFactory; } public function getTreeAction(Request $request): JsonResponse diff --git a/lib/Rozier/src/AjaxControllers/AjaxFoldersController.php b/lib/Rozier/src/AjaxControllers/AjaxFoldersController.php index 1b5586e2..b0867002 100644 --- a/lib/Rozier/src/AjaxControllers/AjaxFoldersController.php +++ b/lib/Rozier/src/AjaxControllers/AjaxFoldersController.php @@ -13,23 +13,15 @@ class AjaxFoldersController extends AbstractAjaxController { - private HandlerFactoryInterface $handlerFactory; - - public function __construct(HandlerFactoryInterface $handlerFactory) + public function __construct(private readonly HandlerFactoryInterface $handlerFactory) { - $this->handlerFactory = $handlerFactory; } - /** + /* * Handle AJAX edition requests for Folder * such as coming from tag-tree widgets. - * - * @param Request $request - * @param int $folderId - * - * @return Response JSON response */ - public function editAction(Request $request, int $folderId) + public function editAction(Request $request, int $folderId): JsonResponse { $this->validateRequest($request); $this->denyAccessUnlessGranted('ROLE_ACCESS_DOCUMENTS'); @@ -81,7 +73,7 @@ public function editAction(Request $request, int $folderId) * @param Request $request * @return JsonResponse */ - public function searchAction(Request $request) + public function searchAction(Request $request): JsonResponse { $this->denyAccessUnlessGranted('ROLE_ACCESS_DOCUMENTS'); @@ -111,11 +103,7 @@ public function searchAction(Request $request) throw $this->createNotFoundException($this->getTranslator()->trans('no.folder.found')); } - /** - * @param array $parameters - * @param Folder $folder - */ - protected function updatePosition($parameters, Folder $folder): void + protected function updatePosition(array $parameters, Folder $folder): void { /* * First, we set the new parent diff --git a/lib/Rozier/src/AjaxControllers/AjaxFoldersExplorerController.php b/lib/Rozier/src/AjaxControllers/AjaxFoldersExplorerController.php index b4a72be2..8133a0a0 100644 --- a/lib/Rozier/src/AjaxControllers/AjaxFoldersExplorerController.php +++ b/lib/Rozier/src/AjaxControllers/AjaxFoldersExplorerController.php @@ -11,12 +11,7 @@ class AjaxFoldersExplorerController extends AbstractAjaxController { - /** - * @param Request $request - * - * @return Response JSON response - */ - public function indexAction(Request $request) + public function indexAction(Request $request): JsonResponse { $this->denyAccessUnlessGranted('ROLE_ACCESS_DOCUMENTS'); diff --git a/lib/Rozier/src/AjaxControllers/AjaxNodeTypesController.php b/lib/Rozier/src/AjaxControllers/AjaxNodeTypesController.php index 2fa6ffa4..6fd2457e 100644 --- a/lib/Rozier/src/AjaxControllers/AjaxNodeTypesController.php +++ b/lib/Rozier/src/AjaxControllers/AjaxNodeTypesController.php @@ -100,7 +100,7 @@ public function listAction(Request $request): Response * @param array|\Traversable $nodeTypes * @return array */ - private function normalizeNodeType($nodeTypes) + private function normalizeNodeType(iterable $nodeTypes): array { $nodeTypesArray = []; diff --git a/lib/Rozier/src/AjaxControllers/AjaxNodesController.php b/lib/Rozier/src/AjaxControllers/AjaxNodesController.php index bc0ee5c3..e459d81c 100644 --- a/lib/Rozier/src/AjaxControllers/AjaxNodesController.php +++ b/lib/Rozier/src/AjaxControllers/AjaxNodesController.php @@ -5,7 +5,6 @@ namespace Themes\Rozier\AjaxControllers; use Psr\Log\LoggerInterface; -use RZ\Roadiz\CoreBundle\Security\Authorization\Chroot\NodeChrootResolver; use RZ\Roadiz\CoreBundle\Entity\Node; use RZ\Roadiz\CoreBundle\Entity\Tag; use RZ\Roadiz\CoreBundle\Event\Node\NodeCreatedEvent; @@ -19,6 +18,7 @@ use RZ\Roadiz\CoreBundle\Node\NodeMover; use RZ\Roadiz\CoreBundle\Node\NodeNamePolicyInterface; use RZ\Roadiz\CoreBundle\Node\UniqueNodeGenerator; +use RZ\Roadiz\CoreBundle\Security\Authorization\Chroot\NodeChrootResolver; use RZ\Roadiz\CoreBundle\Security\Authorization\Voter\NodeVoter; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; @@ -29,27 +29,14 @@ class AjaxNodesController extends AbstractAjaxController { - private NodeNamePolicyInterface $nodeNamePolicy; - private LoggerInterface $logger; - private NodeMover $nodeMover; - private NodeChrootResolver $nodeChrootResolver; - private Registry $workflowRegistry; - private UniqueNodeGenerator $uniqueNodeGenerator; - public function __construct( - NodeNamePolicyInterface $nodeNamePolicy, - LoggerInterface $logger, - NodeMover $nodeMover, - NodeChrootResolver $nodeChrootResolver, - Registry $workflowRegistry, - UniqueNodeGenerator $uniqueNodeGenerator + private readonly NodeNamePolicyInterface $nodeNamePolicy, + private readonly LoggerInterface $logger, + private readonly NodeMover $nodeMover, + private readonly NodeChrootResolver $nodeChrootResolver, + private readonly Registry $workflowRegistry, + private readonly UniqueNodeGenerator $uniqueNodeGenerator ) { - $this->nodeNamePolicy = $nodeNamePolicy; - $this->logger = $logger; - $this->nodeMover = $nodeMover; - $this->nodeChrootResolver = $nodeChrootResolver; - $this->workflowRegistry = $workflowRegistry; - $this->uniqueNodeGenerator = $uniqueNodeGenerator; } /** @@ -248,10 +235,7 @@ protected function parsePosition(array $parameters, float $default = 0.0): float * Update node's status. * * @param Request $request - * * @return JsonResponse - * @throws \Doctrine\ORM\ORMException - * @throws \Doctrine\ORM\OptimisticLockException */ public function statusesAction(Request $request): JsonResponse { diff --git a/lib/Rozier/src/AjaxControllers/AjaxNodesExplorerController.php b/lib/Rozier/src/AjaxControllers/AjaxNodesExplorerController.php index 9911551e..f9914e3c 100644 --- a/lib/Rozier/src/AjaxControllers/AjaxNodesExplorerController.php +++ b/lib/Rozier/src/AjaxControllers/AjaxNodesExplorerController.php @@ -26,27 +26,14 @@ final class AjaxNodesExplorerController extends AbstractAjaxController { - private SerializerInterface $serializer; - private ClientRegistry $clientRegistry; - private NodeSourceSearchHandlerInterface $nodeSourceSearchHandler; - private NodeTypeApi $nodeTypeApi; - private UrlGeneratorInterface $urlGenerator; - private Security $security; - public function __construct( - SerializerInterface $serializer, - ClientRegistry $clientRegistry, - NodeSourceSearchHandlerInterface $nodeSourceSearchHandler, - NodeTypeApi $nodeTypeApi, - UrlGeneratorInterface $urlGenerator, - Security $security, + private readonly SerializerInterface $serializer, + private readonly ClientRegistry $clientRegistry, + private readonly NodeSourceSearchHandlerInterface $nodeSourceSearchHandler, + private readonly NodeTypeApi $nodeTypeApi, + private readonly UrlGeneratorInterface $urlGenerator, + private readonly Security $security, ) { - $this->nodeSourceSearchHandler = $nodeSourceSearchHandler; - $this->nodeTypeApi = $nodeTypeApi; - $this->serializer = $serializer; - $this->urlGenerator = $urlGenerator; - $this->clientRegistry = $clientRegistry; - $this->security = $security; } protected function getItemPerPage(): int diff --git a/lib/Rozier/src/AjaxControllers/AjaxSearchNodesSourcesController.php b/lib/Rozier/src/AjaxControllers/AjaxSearchNodesSourcesController.php index 298d3083..d90719c4 100644 --- a/lib/Rozier/src/AjaxControllers/AjaxSearchNodesSourcesController.php +++ b/lib/Rozier/src/AjaxControllers/AjaxSearchNodesSourcesController.php @@ -21,8 +21,8 @@ class AjaxSearchNodesSourcesController extends AbstractAjaxController public const RESULT_COUNT = 10; public function __construct( - private DocumentUrlGeneratorInterface $documentUrlGenerator, - private Security $security + private readonly DocumentUrlGeneratorInterface $documentUrlGenerator, + private readonly Security $security ) { } diff --git a/lib/Rozier/src/AjaxControllers/AjaxTagsController.php b/lib/Rozier/src/AjaxControllers/AjaxTagsController.php index 20f2e836..6a3d5b24 100644 --- a/lib/Rozier/src/AjaxControllers/AjaxTagsController.php +++ b/lib/Rozier/src/AjaxControllers/AjaxTagsController.php @@ -21,13 +21,10 @@ class AjaxTagsController extends AbstractAjaxController { - private HandlerFactoryInterface $handlerFactory; - private UrlGeneratorInterface $urlGenerator; - - public function __construct(HandlerFactoryInterface $handlerFactory, UrlGeneratorInterface $urlGenerator) - { - $this->handlerFactory = $handlerFactory; - $this->urlGenerator = $urlGenerator; + public function __construct( + private readonly HandlerFactoryInterface $handlerFactory, + private readonly UrlGeneratorInterface $urlGenerator + ) { } /** diff --git a/lib/Rozier/src/Widgets/AbstractWidget.php b/lib/Rozier/src/Widgets/AbstractWidget.php index c7d973cc..a8851a88 100644 --- a/lib/Rozier/src/Widgets/AbstractWidget.php +++ b/lib/Rozier/src/Widgets/AbstractWidget.php @@ -17,18 +17,10 @@ */ abstract class AbstractWidget { - protected RequestStack $requestStack; - protected ManagerRegistry $managerRegistry; protected ?TranslationInterface $defaultTranslation = null; - /** - * @param RequestStack $requestStack - * @param ManagerRegistry $managerRegistry - */ - public function __construct(RequestStack $requestStack, ManagerRegistry $managerRegistry) + public function __construct(protected RequestStack $requestStack, protected ManagerRegistry $managerRegistry) { - $this->managerRegistry = $managerRegistry; - $this->requestStack = $requestStack; } /** diff --git a/lib/Rozier/src/Widgets/FolderTreeWidget.php b/lib/Rozier/src/Widgets/FolderTreeWidget.php index 405fd011..08bad9d7 100644 --- a/lib/Rozier/src/Widgets/FolderTreeWidget.php +++ b/lib/Rozier/src/Widgets/FolderTreeWidget.php @@ -14,19 +14,15 @@ */ final class FolderTreeWidget extends AbstractWidget { - private ?Folder $parentFolder = null; private ?iterable $folders = null; - private ?TranslationInterface $translation; public function __construct( RequestStack $requestStack, ManagerRegistry $managerRegistry, - ?Folder $parent = null, - ?TranslationInterface $translation = null, + private readonly ?Folder $parentFolder = null, + private readonly ?TranslationInterface $translation = null, ) { parent::__construct($requestStack, $managerRegistry); - $this->parentFolder = $parent; - $this->translation = $translation; } /** diff --git a/lib/Rozier/src/Widgets/NodeTreeWidget.php b/lib/Rozier/src/Widgets/NodeTreeWidget.php index 76a3b749..e38d8e2c 100644 --- a/lib/Rozier/src/Widgets/NodeTreeWidget.php +++ b/lib/Rozier/src/Widgets/NodeTreeWidget.php @@ -18,35 +18,28 @@ final class NodeTreeWidget extends AbstractWidget { public const SESSION_ITEM_PER_PAGE = 'nodetree_item_per_page'; - private ?Node $parentNode = null; private ?iterable $nodes = null; private ?Tag $tag = null; - private ?TranslationInterface $translation = null; private bool $stackTree = false; private ?array $filters = null; private bool $canReorder = true; private array $additionalCriteria = []; - private bool $includeRootNode; /** * @param RequestStack $requestStack * @param ManagerRegistry $managerRegistry - * @param Node|null $parent Entry point of NodeTreeWidget, set null if it's root + * @param Node|null $parentNode Entry point of NodeTreeWidget, set null if it's root * @param TranslationInterface|null $translation NodeTree translation * @param bool $includeRootNode */ public function __construct( RequestStack $requestStack, ManagerRegistry $managerRegistry, - ?Node $parent = null, - ?TranslationInterface $translation = null, - bool $includeRootNode = false + private readonly ?Node $parentNode = null, + private readonly ?TranslationInterface $translation = null, + private readonly bool $includeRootNode = false ) { parent::__construct($requestStack, $managerRegistry); - - $this->parentNode = $parent; - $this->translation = $translation; - $this->includeRootNode = $includeRootNode; } /** diff --git a/lib/Rozier/src/Widgets/TagTreeWidget.php b/lib/Rozier/src/Widgets/TagTreeWidget.php index 63986f38..0821b38c 100644 --- a/lib/Rozier/src/Widgets/TagTreeWidget.php +++ b/lib/Rozier/src/Widgets/TagTreeWidget.php @@ -15,24 +15,17 @@ */ final class TagTreeWidget extends AbstractWidget { - protected ?Tag $parentTag = null; - protected ?iterable $tags = null; - protected bool $canReorder = true; - protected bool $forceTranslation = false; - private ?TranslationInterface $translation; + private ?iterable $tags = null; + private bool $canReorder = true; public function __construct( RequestStack $requestStack, ManagerRegistry $managerRegistry, - Tag $parent = null, - ?TranslationInterface $translation = null, - bool $forceTranslation = false + private readonly ?Tag $parentTag = null, + private readonly ?TranslationInterface $translation = null, + private readonly bool $forceTranslation = false ) { parent::__construct($requestStack, $managerRegistry); - - $this->parentTag = $parent; - $this->forceTranslation = $forceTranslation; - $this->translation = $translation; } /** diff --git a/lib/Rozier/src/Widgets/TreeWidgetFactory.php b/lib/Rozier/src/Widgets/TreeWidgetFactory.php index 9344192e..818f6cce 100644 --- a/lib/Rozier/src/Widgets/TreeWidgetFactory.php +++ b/lib/Rozier/src/Widgets/TreeWidgetFactory.php @@ -13,17 +13,10 @@ final class TreeWidgetFactory { - private RequestStack $requestStack; - private ManagerRegistry $managerRegistry; - - /** - * @param RequestStack $requestStack - * @param ManagerRegistry $managerRegistry - */ - public function __construct(RequestStack $requestStack, ManagerRegistry $managerRegistry) - { - $this->requestStack = $requestStack; - $this->managerRegistry = $managerRegistry; + public function __construct( + private readonly RequestStack $requestStack, + private readonly ManagerRegistry $managerRegistry + ) { } public function createNodeTree(?Node $root = null, ?TranslationInterface $translation = null): NodeTreeWidget