From 824ad8a488b68947543692cfc598c21354d800e9 Mon Sep 17 00:00:00 2001 From: MateuszKolankowski Date: Thu, 14 Aug 2025 12:47:40 +0200 Subject: [PATCH] Switch nullable type hints for consistent parameter definitions --- phpstan-baseline.neon | 60 --- .../Controller/ContentTypeController.php | 82 +--- .../Templating/Twig/IconPathExtension.php | 2 +- .../ContentActionsMenuContext.php | 2 +- .../BrowserContext/ContentViewContext.php | 4 +- .../BrowserContext/NavigationContext.php | 2 +- src/lib/Behat/Page/ContentViewPage.php | 2 +- src/lib/Component/LinkComponent.php | 12 +- src/lib/Component/ScriptComponent.php | 19 +- .../ContentTypeIconNotFoundException.php | 2 +- src/lib/Exception/NoValidResultException.php | 3 +- .../Exception/ValidationFailedException.php | 2 +- .../ValueMapperNotFoundException.php | 2 +- .../Form/Data/Asset/ImageAssetUploadData.php | 22 +- .../Content/ContentVisibilityUpdateData.php | 23 +- .../ContentMainLocationUpdateData.php | 20 +- .../Translation/TranslationAddData.php | 35 +- .../Translation/TranslationAddData.php | 46 +- .../Translation/TranslationRemoveData.php | 22 +- src/lib/Form/Data/ContentTypeGroupData.php | 7 +- .../Form/Data/Language/LanguageUpdateData.php | 25 +- .../Location/AbstractLocationCopyData.php | 18 +- .../Form/Data/Location/LocationMoveData.php | 18 +- .../Form/Data/Location/LocationSwapData.php | 18 +- .../ContentObjectStateUpdateData.php | 29 +- src/lib/Form/Data/TrashItemData.php | 16 +- .../Form/Factory/ContentTypeFormFactory.php | 24 +- src/lib/Form/Factory/FormFactory.php | 415 +++--------------- src/lib/Form/Factory/TrashFormFactory.php | 2 +- src/lib/Service/Role/RoleService.php | 2 +- .../Siteaccess/NonAdminSiteaccessResolver.php | 5 +- src/lib/Siteaccess/SiteaccessResolver.php | 8 +- .../SiteaccessResolverInterface.php | 8 +- .../UI/Dataset/ContentDraftListDataset.php | 9 +- src/lib/UI/Dataset/ContentDraftsDataset.php | 7 +- .../Builder/ContentTranslateViewBuilder.php | 29 +- .../LimitationValueRenderingExtensionTest.php | 2 +- .../SetViewParametersListenerTest.php | 4 +- .../DataTransformer/UserTransformerTest.php | 7 +- .../Processor/PreviewFormProcessorTest.php | 8 +- 40 files changed, 129 insertions(+), 894 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index cac6d76a16..b1a2450da3 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -5118,36 +5118,12 @@ parameters: count: 1 path: src/lib/Form/Data/ContentType/ContentTypesDeleteData.php - - - message: '#^PHPDoc tag @param for parameter \$baseLanguage with type Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Language\|null is not subtype of native type Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Language\.$#' - identifier: parameter.phpDocType - count: 1 - path: src/lib/Form/Data/ContentType/Translation/TranslationAddData.php - - - - message: '#^PHPDoc tag @param for parameter \$contentType with type Ibexa\\Contracts\\Core\\Repository\\Values\\ContentType\\ContentType\|null is not subtype of native type Ibexa\\Contracts\\Core\\Repository\\Values\\ContentType\\ContentType\.$#' - identifier: parameter.phpDocType - count: 1 - path: src/lib/Form/Data/ContentType/Translation/TranslationAddData.php - - - - message: '#^PHPDoc tag @param for parameter \$language with type Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Language\|null is not subtype of native type Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Language\.$#' - identifier: parameter.phpDocType - count: 1 - path: src/lib/Form/Data/ContentType/Translation/TranslationAddData.php - - message: '#^Method Ibexa\\AdminUi\\Form\\Data\\ContentType\\Translation\\TranslationRemoveData\:\:__construct\(\) has parameter \$languageCodes with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 path: src/lib/Form/Data/ContentType/Translation/TranslationRemoveData.php - - - message: '#^PHPDoc tag @param for parameter \$contentType with type Ibexa\\Contracts\\Core\\Repository\\Values\\ContentType\\ContentType\|null is not subtype of native type Ibexa\\Contracts\\Core\\Repository\\Values\\ContentType\\ContentType\.$#' - identifier: parameter.phpDocType - count: 1 - path: src/lib/Form/Data/ContentType/Translation/TranslationRemoveData.php - - message: '#^Method Ibexa\\AdminUi\\Form\\Data\\ContentTypeGroup\\ContentTypeGroupCreateData\:\:setIdentifier\(\) has no return type specified\.$#' identifier: missingType.return @@ -5532,24 +5508,6 @@ parameters: count: 1 path: src/lib/Form/Data/Location/AbstractLocationCopyData.php - - - message: '#^PHPDoc tag @param has invalid value \(\\Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|\|null \$location\)\: Unexpected token "\|", expected type at offset 75 on line 2$#' - identifier: phpDoc.parseError - count: 1 - path: src/lib/Form/Data/Location/AbstractLocationCopyData.php - - - - message: '#^PHPDoc tag @param has invalid value \(\\Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|\|null \$newParentLocation\)\: Unexpected token "\|", expected type at offset 75 on line 2$#' - identifier: phpDoc.parseError - count: 1 - path: src/lib/Form/Data/Location/AbstractLocationCopyData.php - - - - message: '#^PHPDoc tag @return has invalid value \(\\Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|\|null\)\: Unexpected token "\|", expected type at offset 76 on line 2$#' - identifier: phpDoc.parseError - count: 2 - path: src/lib/Form/Data/Location/AbstractLocationCopyData.php - - message: '#^Method Ibexa\\AdminUi\\Form\\Data\\Location\\LocationMoveData\:\:setLocation\(\) has no return type specified\.$#' identifier: missingType.return @@ -7266,12 +7224,6 @@ parameters: count: 1 path: src/lib/Form/Factory/ContentTypeFormFactory.php - - - message: '#^PHPDoc tag @param has invalid value \(\\Ibexa\\AdminUi\\Form\\Data\\ContentType\\ContentTypeEditData\)\: Unexpected token "\\n \* ", expected variable at offset 74 on line 2$#' - identifier: phpDoc.parseError - count: 1 - path: src/lib/Form/Factory/ContentTypeFormFactory.php - - message: '#^Parameter \#1 \$name of method Symfony\\Component\\Form\\FormFactoryInterface\:\:createNamed\(\) expects string, string\|null given\.$#' identifier: argument.type @@ -7716,24 +7668,12 @@ parameters: count: 1 path: src/lib/Form/Factory/FormFactory.php - - - message: '#^PHPDoc tag @param for parameter \$data with type Ibexa\\AdminUi\\Form\\Data\\Search\\SearchData\|null is not subtype of native type Ibexa\\Bundle\\Search\\Form\\Data\\SearchData\|null\.$#' - identifier: parameter.phpDocType - count: 1 - path: src/lib/Form/Factory/FormFactory.php - - message: '#^Parameter \#1 \$name of method Symfony\\Component\\Form\\FormFactoryInterface\:\:createNamed\(\) expects string, string\|null given\.$#' identifier: argument.type count: 42 path: src/lib/Form/Factory/FormFactory.php - - - message: '#^Parameter \$data of method Ibexa\\AdminUi\\Form\\Factory\\FormFactory\:\:createSearchForm\(\) has invalid type Ibexa\\AdminUi\\Form\\Data\\Search\\SearchData\.$#' - identifier: class.notFound - count: 1 - path: src/lib/Form/Factory/FormFactory.php - - message: '#^Property Ibexa\\AdminUi\\Form\\Factory\\FormFactory\:\:\$translator is never read, only written\.$#' identifier: property.onlyWritten diff --git a/src/bundle/Controller/ContentTypeController.php b/src/bundle/Controller/ContentTypeController.php index 6ea304ffcc..5f0d946114 100644 --- a/src/bundle/Controller/ContentTypeController.php +++ b/src/bundle/Controller/ContentTypeController.php @@ -122,12 +122,6 @@ public function __construct( } /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $group - * @param string $routeName - * @param int $page - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException * @throws \Pagerfanta\Exception\OutOfRangeCurrentPageException * @throws \Pagerfanta\Exception\NotIntegerCurrentPageException @@ -180,8 +174,6 @@ public function listAction(ContentTypeGroup $group, string $routeName, int $page } /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $group - * * @return \Symfony\Component\HttpFoundation\Response|\Ibexa\AdminUi\View\ContentTypeCreateView * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException @@ -227,11 +219,6 @@ public function addAction(ContentTypeGroup $group) return $view; } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function addTranslationAction(Request $request): Response { $form = $this->contentTypeFormFactory->addContentTypeTranslation( @@ -287,11 +274,6 @@ public function addTranslationAction(Request $request): Response ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function removeTranslationAction(Request $request): Response { $form = $this->contentTypeFormFactory->removeContentTypeTranslation( @@ -349,11 +331,6 @@ public function removeTranslationAction(Request $request): Response } /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $group - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType $contentType - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException */ @@ -415,11 +392,6 @@ public function editAction(Request $request, ContentTypeGroup $group, ContentTyp } /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $group - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType $contentType - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException */ public function copyAction(Request $request, ContentTypeGroup $group, ContentType $contentType): Response @@ -472,12 +444,6 @@ public function copyAction(Request $request, ContentTypeGroup $group, ContentTyp } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $group - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeDraft $contentTypeDraft - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language|null $language - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language|null $baseLanguage - * * @return \Symfony\Component\HttpFoundation\Response|\Ibexa\AdminUi\View\ContentTypeEditView * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException @@ -486,8 +452,8 @@ public function updateAction( Request $request, ContentTypeGroup $group, ContentTypeDraft $contentTypeDraft, - Language $language = null, - Language $baseLanguage = null + ?Language $language = null, + ?Language $baseLanguage = null ) { if (!$language) { $language = $this->getDefaultLanguage($contentTypeDraft); @@ -599,12 +565,6 @@ public function addFieldDefinitionFormAction( } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $group - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType $contentType - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException */ public function deleteAction(Request $request, ContentTypeGroup $group, ContentType $contentType): Response @@ -638,11 +598,6 @@ public function deleteAction(Request $request, ContentTypeGroup $group, ContentT /** * Handles removing content types based on submitted form. * - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $group - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException * @throws \InvalidArgumentException @@ -680,11 +635,6 @@ public function bulkDeleteAction(Request $request, ContentTypeGroup $group): Res } /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $group - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType $contentType - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException */ public function viewAction( @@ -737,18 +687,10 @@ public function viewAction( ]); } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $contentTypeGroup - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeDraft $contentTypeDraft - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language|null $language - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language|null $baseLanguage - * - * @return \Symfony\Component\Form\FormInterface - */ public function createUpdateForm( ContentTypeGroup $contentTypeGroup, ContentTypeDraft $contentTypeDraft, - Language $language = null, + ?Language $language = null, ?Language $baseLanguage = null ): FormInterface { $this->metaFieldDefinitionService->addMetaFieldDefinitions($contentTypeDraft, $language); @@ -773,12 +715,6 @@ public function createUpdateForm( ]); } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $group - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType $contentType - * - * @return \Symfony\Component\Form\FormInterface - */ protected function createDeleteForm(ContentTypeGroup $group, ContentType $contentType): FormInterface { $formBuilder = $this->createFormBuilder(null, [ @@ -805,10 +741,6 @@ private function getContentTypesNumbers(array $contentTypes): array } /** - * @param int $userId - * - * @return string|null - * * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException */ private function getUserNameById(int $userId): ?string @@ -828,10 +760,6 @@ private function getUserNameById(int $userId): ?string } /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeDraft $contentTypeDraft - * - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Language - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException */ private function getDefaultLanguage(ContentTypeDraft $contentTypeDraft): Language @@ -850,10 +778,6 @@ private function getDefaultLanguage(ContentTypeDraft $contentTypeDraft): Languag } /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType $contentType - * - * @return \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeDraft - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException */ diff --git a/src/bundle/Templating/Twig/IconPathExtension.php b/src/bundle/Templating/Twig/IconPathExtension.php index 2fcfea94be..e9d32d2396 100644 --- a/src/bundle/Templating/Twig/IconPathExtension.php +++ b/src/bundle/Templating/Twig/IconPathExtension.php @@ -44,7 +44,7 @@ public function getFunctions(): array ]; } - public function getIconPath(string $icon, string $set = null): string + public function getIconPath(string $icon, ?string $set = null): string { return $this->iconPathResolver->resolve($icon, $set); } diff --git a/src/lib/Behat/BrowserContext/ContentActionsMenuContext.php b/src/lib/Behat/BrowserContext/ContentActionsMenuContext.php index 9aed9054de..bc46b00ceb 100644 --- a/src/lib/Behat/BrowserContext/ContentActionsMenuContext.php +++ b/src/lib/Behat/BrowserContext/ContentActionsMenuContext.php @@ -28,7 +28,7 @@ public function __construct(ContentActionsMenu $contentActionsMenu) * @Given I perform the :buttonName action * @Given I perform the :buttonName action from the :groupName group */ - public function clickEditActionBar(string $buttonName, string $groupName = null): void + public function clickEditActionBar(string $buttonName, ?string $groupName = null): void { $this->contentActionsMenu->clickButton($buttonName, $groupName); } diff --git a/src/lib/Behat/BrowserContext/ContentViewContext.php b/src/lib/Behat/BrowserContext/ContentViewContext.php index beb42ac816..69b4303f38 100644 --- a/src/lib/Behat/BrowserContext/ContentViewContext.php +++ b/src/lib/Behat/BrowserContext/ContentViewContext.php @@ -39,7 +39,7 @@ public function __construct( * @Given I start creating a new Content :contentType * @Given I start creating a new Content :contentType in :language language */ - public function startCreatingContent(string $contentType, string $language = null): void + public function startCreatingContent(string $contentType, ?string $language = null): void { $this->contentViewPage->startCreatingContent($contentType, $language); } @@ -107,7 +107,7 @@ public function startCreatingUser(string $contentTypeName = 'User'): void * @Given I start editing the current content * @Given I start editing the current content in :language language */ - public function startEditingContent(string $language = null): void + public function startEditingContent(?string $language = null): void { $this->contentViewPage->editContent($language); } diff --git a/src/lib/Behat/BrowserContext/NavigationContext.php b/src/lib/Behat/BrowserContext/NavigationContext.php index 287782c354..70f05ae0b8 100644 --- a/src/lib/Behat/BrowserContext/NavigationContext.php +++ b/src/lib/Behat/BrowserContext/NavigationContext.php @@ -137,7 +137,7 @@ public function iClickOnBreadcrumbLink(string $element): void /** * @Given I navigate to content :contentName of type :contentType in :path */ - public function iNavigateToContent(string $contentName, string $contentType, string $path = null) + public function iNavigateToContent(string $contentName, string $contentType, ?string $path = null) { $expectedContentPath = sprintf('%s/%s', $path, $contentName); $pathParts = explode('/', $expectedContentPath); diff --git a/src/lib/Behat/Page/ContentViewPage.php b/src/lib/Behat/Page/ContentViewPage.php index 7ab43e378a..52fe1183e0 100644 --- a/src/lib/Behat/Page/ContentViewPage.php +++ b/src/lib/Behat/Page/ContentViewPage.php @@ -120,7 +120,7 @@ public function __construct( $this->deleteContentDialog = $deleteContentDialog; } - public function startCreatingContent(string $contentTypeName, string $language = null) + public function startCreatingContent(string $contentTypeName, ?string $language = null) { $this->contentActionsMenu->clickButton('Create content'); $this->contentTypePicker->verifyIsLoaded(); diff --git a/src/lib/Component/LinkComponent.php b/src/lib/Component/LinkComponent.php index ea95e2d000..4837dd911a 100644 --- a/src/lib/Component/LinkComponent.php +++ b/src/lib/Component/LinkComponent.php @@ -35,21 +35,13 @@ class LinkComponent implements ComponentInterface /** @var string|null */ protected $integrity; - /** - * @param \Twig\Environment $twig - * @param string $href - * @param string $type - * @param string $rel - * @param string|null $crossorigin - * @param string|null $integrity - */ public function __construct( Environment $twig, string $href, string $type = 'text/css', string $rel = 'stylesheet', - string $crossorigin = null, - string $integrity = null + ?string $crossorigin = null, + ?string $integrity = null ) { $this->twig = $twig; $this->href = $href; diff --git a/src/lib/Component/ScriptComponent.php b/src/lib/Component/ScriptComponent.php index 708e57fdd3..91bc4f29fa 100644 --- a/src/lib/Component/ScriptComponent.php +++ b/src/lib/Component/ScriptComponent.php @@ -38,23 +38,14 @@ class ScriptComponent implements ComponentInterface /** @var string|null */ protected $integrity; - /** - * @param \Twig\Environment $twig - * @param string $src - * @param string $type - * @param string|null $async - * @param string|null $defer - * @param string|null $crossorigin - * @param string|null $integrity - */ public function __construct( Environment $twig, string $src, string $type = 'text/javascript', - string $async = null, - string $defer = null, - string $crossorigin = null, - string $integrity = null + ?string $async = null, + ?string $defer = null, + ?string $crossorigin = null, + ?string $integrity = null ) { $this->twig = $twig; $this->src = $src; @@ -67,8 +58,6 @@ public function __construct( /** * @param array $parameters - * - * @return string */ public function render(array $parameters = []): string { diff --git a/src/lib/Exception/ContentTypeIconNotFoundException.php b/src/lib/Exception/ContentTypeIconNotFoundException.php index ebc40d91d3..9e01bc3296 100644 --- a/src/lib/Exception/ContentTypeIconNotFoundException.php +++ b/src/lib/Exception/ContentTypeIconNotFoundException.php @@ -13,7 +13,7 @@ class ContentTypeIconNotFoundException extends RuntimeException { - public function __construct($contentType, $code = 0, Exception $previous = null) + public function __construct($contentType, $code = 0, ?Exception $previous = null) { parent::__construct("No icon found for '$contentType' content type", $code, $previous); } diff --git a/src/lib/Exception/NoValidResultException.php b/src/lib/Exception/NoValidResultException.php index 237cadec5e..bf00b04ec2 100644 --- a/src/lib/Exception/NoValidResultException.php +++ b/src/lib/Exception/NoValidResultException.php @@ -16,12 +16,11 @@ class NoValidResultException extends Exception /** * @param string $message * @param int $code - * @param \Throwable|null $previous */ public function __construct( $message = 'No valid result from strategy', $code = 0, - Throwable $previous = null + ?Throwable $previous = null ) { parent::__construct($message, $code, $previous); } diff --git a/src/lib/Exception/ValidationFailedException.php b/src/lib/Exception/ValidationFailedException.php index d1ea55e8c4..a97adb6284 100644 --- a/src/lib/Exception/ValidationFailedException.php +++ b/src/lib/Exception/ValidationFailedException.php @@ -19,7 +19,7 @@ final class ValidationFailedException extends InvalidArgumentException public function __construct( string $argumentName, ConstraintViolationListInterface $errors, - Exception $previous = null + ?Exception $previous = null ) { parent::__construct($this->createMessage($argumentName, $errors), 0, $previous); diff --git a/src/lib/Exception/ValueMapperNotFoundException.php b/src/lib/Exception/ValueMapperNotFoundException.php index 7895e3281c..61fc7ce6c8 100644 --- a/src/lib/Exception/ValueMapperNotFoundException.php +++ b/src/lib/Exception/ValueMapperNotFoundException.php @@ -12,7 +12,7 @@ class ValueMapperNotFoundException extends InvalidArgumentException { - public function __construct($limitationType, $code = 0, Exception $previous = null) + public function __construct($limitationType, $code = 0, ?Exception $previous = null) { parent::__construct("No LimitationValueMapper found for '$limitationType'", $code, $previous); } diff --git a/src/lib/Form/Data/Asset/ImageAssetUploadData.php b/src/lib/Form/Data/Asset/ImageAssetUploadData.php index 99490feec8..45ed3cc32c 100644 --- a/src/lib/Form/Data/Asset/ImageAssetUploadData.php +++ b/src/lib/Form/Data/Asset/ImageAssetUploadData.php @@ -29,29 +29,17 @@ class ImageAssetUploadData */ private $languageCode; - /** - * @param \Symfony\Component\HttpFoundation\File\UploadedFile|null $file - * @param string|null $languageCode - */ - public function __construct(?UploadedFile $file = null, string $languageCode = null) + public function __construct(?UploadedFile $file = null, ?string $languageCode = null) { $this->file = $file; $this->languageCode = $languageCode; } - /** - * @return \Symfony\Component\HttpFoundation\File\UploadedFile|null - */ public function getFile(): ?UploadedFile { return $this->file; } - /** - * @param \Symfony\Component\HttpFoundation\File\UploadedFile $file|null - * - * @return \Ibexa\AdminUi\Form\Data\Asset\ImageAssetUploadData - */ public function setFile(?UploadedFile $file): self { $this->file = $file; @@ -59,19 +47,11 @@ public function setFile(?UploadedFile $file): self return $this; } - /** - * @return string|null - */ public function getLanguageCode(): ?string { return $this->languageCode; } - /** - * @param string|null $languageCode - * - * @return \Ibexa\AdminUi\Form\Data\Asset\ImageAssetUploadData - */ public function setLanguageCode(?string $languageCode): self { $this->languageCode = $languageCode; diff --git a/src/lib/Form/Data/Content/ContentVisibilityUpdateData.php b/src/lib/Form/Data/Content/ContentVisibilityUpdateData.php index 497e30a2eb..45ef21cdf8 100644 --- a/src/lib/Form/Data/Content/ContentVisibilityUpdateData.php +++ b/src/lib/Form/Data/Content/ContentVisibilityUpdateData.php @@ -24,24 +24,16 @@ class ContentVisibilityUpdateData */ private $location; - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo|null $contentInfo - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location|null $location - * @param bool|null $visible - */ public function __construct( - ContentInfo $contentInfo = null, - Location $location = null, - bool $visible = null + ?ContentInfo $contentInfo = null, + ?Location $location = null, + ?bool $visible = null ) { $this->contentInfo = $contentInfo; $this->visible = $visible; $this->location = $location; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo|null - */ public function getContentInfo(): ?ContentInfo { return $this->contentInfo; @@ -55,9 +47,6 @@ public function getVisible(): ?bool return $this->visible; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo - */ public function setContentInfo(ContentInfo $contentInfo): void { $this->contentInfo = $contentInfo; @@ -71,17 +60,11 @@ public function setVisible(bool $visible): void $this->visible = $visible; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Location|null - */ public function getLocation(): ?Location { return $this->location; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location|null $location - */ public function setLocation(?Location $location): void { $this->location = $location; diff --git a/src/lib/Form/Data/Content/Location/ContentMainLocationUpdateData.php b/src/lib/Form/Data/Content/Location/ContentMainLocationUpdateData.php index 74bf25f237..8ce110662d 100644 --- a/src/lib/Form/Data/Content/Location/ContentMainLocationUpdateData.php +++ b/src/lib/Form/Data/Content/Location/ContentMainLocationUpdateData.php @@ -33,45 +33,29 @@ class ContentMainLocationUpdateData */ public $location; - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo|null $contentInfo - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location|null $location - */ public function __construct( - ContentInfo $contentInfo = null, - Location $location = null + ?ContentInfo $contentInfo = null, + ?Location $location = null ) { $this->contentInfo = $contentInfo; $this->location = $location; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo|null - */ public function getContentInfo(): ?ContentInfo { return $this->contentInfo; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo|null $contentInfo - */ public function setContentInfo(?ContentInfo $contentInfo) { $this->contentInfo = $contentInfo; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Location|null - */ public function getLocation(): ?Location { return $this->location; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location $location - */ public function setLocation(Location $location) { $this->location = $location; diff --git a/src/lib/Form/Data/Content/Translation/TranslationAddData.php b/src/lib/Form/Data/Content/Translation/TranslationAddData.php index 76a92a6343..b9296991fd 100644 --- a/src/lib/Form/Data/Content/Translation/TranslationAddData.php +++ b/src/lib/Form/Data/Content/Translation/TranslationAddData.php @@ -33,34 +33,21 @@ class TranslationAddData */ protected $baseLanguage; - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location|null $location - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language|null $language - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language|null $baseLanguage - */ public function __construct( - Location $location = null, - Language $language = null, - Language $baseLanguage = null + ?Location $location = null, + ?Language $language = null, + ?Language $baseLanguage = null ) { $this->location = $location; $this->language = $language; $this->baseLanguage = $baseLanguage; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Location|null - */ public function getLocation(): ?Location { return $this->location; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location $location - * - * @return self - */ public function setLocation(Location $location): self { $this->location = $location; @@ -68,19 +55,11 @@ public function setLocation(Location $location): self return $this; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Language|null - */ public function getLanguage(): ?Language { return $this->language; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language $language - * - * @return self - */ public function setLanguage(Language $language): self { $this->language = $language; @@ -88,19 +67,11 @@ public function setLanguage(Language $language): self return $this; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Language|null - */ public function getBaseLanguage(): ?Language { return $this->baseLanguage; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language $baseLanguage - * - * @return self - */ public function setBaseLanguage(Language $baseLanguage): self { $this->baseLanguage = $baseLanguage; diff --git a/src/lib/Form/Data/ContentType/Translation/TranslationAddData.php b/src/lib/Form/Data/ContentType/Translation/TranslationAddData.php index 47193052cc..b222604a8f 100644 --- a/src/lib/Form/Data/ContentType/Translation/TranslationAddData.php +++ b/src/lib/Form/Data/ContentType/Translation/TranslationAddData.php @@ -41,17 +41,11 @@ class TranslationAddData */ private $baseLanguage; - /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType|null $contentType - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup|null $contentTypeGroup - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language|null $language - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language|null $baseLanguage - */ public function __construct( - ContentType $contentType = null, - ContentTypeGroup $contentTypeGroup = null, - Language $language = null, - Language $baseLanguage = null + ?ContentType $contentType = null, + ?ContentTypeGroup $contentTypeGroup = null, + ?Language $language = null, + ?Language $baseLanguage = null ) { $this->contentType = $contentType; $this->contentTypeGroup = $contentTypeGroup; @@ -59,19 +53,11 @@ public function __construct( $this->baseLanguage = $baseLanguage; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType|null - */ public function getContentType(): ?ContentType { return $this->contentType; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType|null $contentType - * - * @return self - */ public function setContentType(ContentType $contentType): self { $this->contentType = $contentType; @@ -79,19 +65,11 @@ public function setContentType(ContentType $contentType): self return $this; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup|null - */ public function getContentTypeGroup(): ?ContentTypeGroup { return $this->contentTypeGroup; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $contentTypeGroup - * - * @return self - */ public function setContentTypeGroup(ContentTypeGroup $contentTypeGroup): self { $this->contentTypeGroup = $contentTypeGroup; @@ -99,19 +77,11 @@ public function setContentTypeGroup(ContentTypeGroup $contentTypeGroup): self return $this; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Language|null - */ public function getLanguage(): ?Language { return $this->language; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language|null $language - * - * @return self - */ public function setLanguage(Language $language): self { $this->language = $language; @@ -119,19 +89,11 @@ public function setLanguage(Language $language): self return $this; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Language|null - */ public function getBaseLanguage(): ?Language { return $this->baseLanguage; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language|null $baseLanguage - * - * @return self - */ public function setBaseLanguage(Language $baseLanguage): self { $this->baseLanguage = $baseLanguage; diff --git a/src/lib/Form/Data/ContentType/Translation/TranslationRemoveData.php b/src/lib/Form/Data/ContentType/Translation/TranslationRemoveData.php index 083d28e1da..5783714d11 100644 --- a/src/lib/Form/Data/ContentType/Translation/TranslationRemoveData.php +++ b/src/lib/Form/Data/ContentType/Translation/TranslationRemoveData.php @@ -36,13 +36,11 @@ class TranslationRemoveData private $languageCodes; /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType|null $contentType - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup|null $contentTypeGroup * @param array $languageCodes */ public function __construct( - ContentType $contentType = null, - ContentTypeGroup $contentTypeGroup = null, + ?ContentType $contentType = null, + ?ContentTypeGroup $contentTypeGroup = null, array $languageCodes = [] ) { $this->contentType = $contentType; @@ -50,19 +48,11 @@ public function __construct( $this->languageCodes = $languageCodes; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType|null - */ public function getContentType(): ?ContentType { return $this->contentType; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType|null $contentType - * - * @return self - */ public function setContentType(ContentType $contentType): self { $this->contentType = $contentType; @@ -70,19 +60,11 @@ public function setContentType(ContentType $contentType): self return $this; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup|null - */ public function getContentTypeGroup(): ?ContentTypeGroup { return $this->contentTypeGroup; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $contentTypeGroup - * - * @return self - */ public function setContentTypeGroup(ContentTypeGroup $contentTypeGroup): self { $this->contentTypeGroup = $contentTypeGroup; diff --git a/src/lib/Form/Data/ContentTypeGroupData.php b/src/lib/Form/Data/ContentTypeGroupData.php index dee80fa1c0..3d04c96057 100644 --- a/src/lib/Form/Data/ContentTypeGroupData.php +++ b/src/lib/Form/Data/ContentTypeGroupData.php @@ -15,12 +15,7 @@ class ContentTypeGroupData /** @var string */ private $identifier; - /** - * ContentTypeGroupData constructor. - * - * @param string $identifier - */ - public function __construct(string $identifier = null) + public function __construct(?string $identifier = null) { $this->identifier = $identifier; } diff --git a/src/lib/Form/Data/Language/LanguageUpdateData.php b/src/lib/Form/Data/Language/LanguageUpdateData.php index 5e9a546fda..149e8823c0 100644 --- a/src/lib/Form/Data/Language/LanguageUpdateData.php +++ b/src/lib/Form/Data/Language/LanguageUpdateData.php @@ -25,59 +25,38 @@ class LanguageUpdateData /** @var bool */ private $enabled; - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language|null $language - */ - public function __construct(Language $language = null) + public function __construct(?Language $language = null) { $this->language = $language; $this->name = $language->name; $this->enabled = $language->enabled; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Language - */ - public function getLanguage(): Language + public function getLanguage(): ?Language { return $this->language; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language $language - */ public function setLanguage(Language $language) { $this->language = $language; } - /** - * @return string - */ public function getName(): ?string { return $this->name; } - /** - * @param string $name - */ public function setName(string $name) { $this->name = $name; } - /** - * @return bool - */ public function isEnabled(): bool { return $this->enabled; } - /** - * @param bool $enabled - */ public function setEnabled(bool $enabled) { $this->enabled = $enabled; diff --git a/src/lib/Form/Data/Location/AbstractLocationCopyData.php b/src/lib/Form/Data/Location/AbstractLocationCopyData.php index 69d96fbba2..ac43b288a2 100644 --- a/src/lib/Form/Data/Location/AbstractLocationCopyData.php +++ b/src/lib/Form/Data/Location/AbstractLocationCopyData.php @@ -18,43 +18,27 @@ abstract class AbstractLocationCopyData /** @var \Ibexa\Contracts\Core\Repository\Values\Content\Location|null */ protected $newParentLocation; - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location|null $location - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location|null $newParentLocation - */ - public function __construct(?Location $location = null, Location $newParentLocation = null) + public function __construct(?Location $location = null, ?Location $newParentLocation = null) { $this->location = $location; $this->newParentLocation = $newParentLocation; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Location||null - */ public function getLocation(): ?Location { return $this->location; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location||null $location - */ public function setLocation(?Location $location) { $this->location = $location; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Location||null - */ public function getNewParentLocation(): ?Location { return $this->newParentLocation; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location||null $newParentLocation - */ public function setNewParentLocation(?Location $newParentLocation) { $this->newParentLocation = $newParentLocation; diff --git a/src/lib/Form/Data/Location/LocationMoveData.php b/src/lib/Form/Data/Location/LocationMoveData.php index 9c7e7dfcdc..c04857744c 100644 --- a/src/lib/Form/Data/Location/LocationMoveData.php +++ b/src/lib/Form/Data/Location/LocationMoveData.php @@ -21,43 +21,27 @@ class LocationMoveData /** @var \Ibexa\Contracts\Core\Repository\Values\Content\Location|null */ protected $newParentLocation; - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location|null $location - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location|null $newParentLocation - */ - public function __construct(?Location $location = null, Location $newParentLocation = null) + public function __construct(?Location $location = null, ?Location $newParentLocation = null) { $this->location = $location; $this->newParentLocation = $newParentLocation; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Location|null - */ public function getLocation(): ?Location { return $this->location; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location|null $location - */ public function setLocation(?Location $location) { $this->location = $location; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Location|null - */ public function getNewParentLocation(): ?Location { return $this->newParentLocation; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location|null $newParentLocation - */ public function setNewParentLocation(?Location $newParentLocation) { $this->newParentLocation = $newParentLocation; diff --git a/src/lib/Form/Data/Location/LocationSwapData.php b/src/lib/Form/Data/Location/LocationSwapData.php index fdb44bf946..36e0855da7 100644 --- a/src/lib/Form/Data/Location/LocationSwapData.php +++ b/src/lib/Form/Data/Location/LocationSwapData.php @@ -21,43 +21,27 @@ class LocationSwapData /** @var \Ibexa\Contracts\Core\Repository\Values\Content\Location|null */ protected $newLocation; - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location|null $currentLocation - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location|null $newLocation - */ - public function __construct(?Location $currentLocation = null, Location $newLocation = null) + public function __construct(?Location $currentLocation = null, ?Location $newLocation = null) { $this->currentLocation = $currentLocation; $this->newLocation = $newLocation; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Location|null - */ public function getCurrentLocation(): ?Location { return $this->currentLocation; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location|null $currentLocation - */ public function setCurrentLocation(?Location $currentLocation) { $this->currentLocation = $currentLocation; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Location|null - */ public function getNewLocation(): ?Location { return $this->newLocation; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location|null $newLocation - */ public function setNewLocation(?Location $newLocation) { $this->newLocation = $newLocation; diff --git a/src/lib/Form/Data/ObjectState/ContentObjectStateUpdateData.php b/src/lib/Form/Data/ObjectState/ContentObjectStateUpdateData.php index 01eb8804f4..203257dc45 100644 --- a/src/lib/Form/Data/ObjectState/ContentObjectStateUpdateData.php +++ b/src/lib/Form/Data/ObjectState/ContentObjectStateUpdateData.php @@ -29,64 +29,41 @@ class ContentObjectStateUpdateData */ private $objectState; - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo|null $contentInfo - * @param \Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectStateGroup|null $objectStateGroup - * @param \Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectState|null $objectState - */ public function __construct( - ContentInfo $contentInfo = null, - ObjectStateGroup $objectStateGroup = null, - ObjectState $objectState = null + ?ContentInfo $contentInfo = null, + ?ObjectStateGroup $objectStateGroup = null, + ?ObjectState $objectState = null ) { $this->contentInfo = $contentInfo; $this->objectStateGroup = $objectStateGroup; $this->objectState = $objectState; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo - */ public function getContentInfo(): ContentInfo { return $this->contentInfo; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo - */ public function setContentInfo(ContentInfo $contentInfo) { $this->contentInfo = $contentInfo; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectStateGroup - */ public function getObjectStateGroup(): ObjectStateGroup { return $this->objectStateGroup; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectStateGroup $objectStateGroup - */ public function setObjectStateGroup(ObjectStateGroup $objectStateGroup) { $this->objectStateGroup = $objectStateGroup; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectState|null - */ public function getObjectState(): ?ObjectState { return $this->objectState; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectState $objectState - */ public function setObjectState(ObjectState $objectState) { $this->objectState = $objectState; diff --git a/src/lib/Form/Data/TrashItemData.php b/src/lib/Form/Data/TrashItemData.php index 608219d3b0..6c2f150740 100644 --- a/src/lib/Form/Data/TrashItemData.php +++ b/src/lib/Form/Data/TrashItemData.php @@ -33,7 +33,7 @@ class TrashItemData */ public function __construct( APITrashItem $location, - ContentType $contentType = null, + ?ContentType $contentType = null, array $ancestors = [], ?User $creator = null ) { @@ -43,33 +43,21 @@ public function __construct( $this->creator = $creator; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\Content\TrashItem - */ public function getLocation(): APITrashItem { return $this->location; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\TrashItem $location - */ public function setLocation(APITrashItem $location) { $this->location = $location; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType - */ - public function getContentType(): ContentType + public function getContentType(): ?ContentType { return $this->contentType; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType $contentType - */ public function setContentType(ContentType $contentType) { $this->contentType = $contentType; diff --git a/src/lib/Form/Factory/ContentTypeFormFactory.php b/src/lib/Form/Factory/ContentTypeFormFactory.php index 450485c75f..38068611fe 100644 --- a/src/lib/Form/Factory/ContentTypeFormFactory.php +++ b/src/lib/Form/Factory/ContentTypeFormFactory.php @@ -34,14 +34,8 @@ public function __construct( $this->formFactory = $formFactory; } - /** - * @param \Ibexa\AdminUi\Form\Data\ContentType\Translation\TranslationAddData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function addContentTypeTranslation( - TranslationAddData $data = null, + ?TranslationAddData $data = null, ?string $name = null ): FormInterface { $name = $name ?: 'add-translation'; @@ -49,14 +43,8 @@ public function addContentTypeTranslation( return $this->formFactory->createNamed($name, TranslationAddType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\ContentType\Translation\TranslationRemoveData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function removeContentTypeTranslation( - TranslationRemoveData $data = null, + ?TranslationRemoveData $data = null, ?string $name = null ): FormInterface { $name = $name ?: 'delete-translations'; @@ -65,14 +53,10 @@ public function removeContentTypeTranslation( } /** - * @param \Ibexa\AdminUi\Form\Data\ContentType\ContentTypeEditData|null $data - * @param string|null $name * @param array $options - * - * @return \Symfony\Component\Form\FormInterface */ public function contentTypeEdit( - ContentTypeEditData $data = null, + ?ContentTypeEditData $data = null, ?string $name = null, array $options = [] ): FormInterface { @@ -82,8 +66,6 @@ public function contentTypeEdit( } /** - * @param \Ibexa\AdminUi\Form\Data\ContentType\ContentTypeEditData - * @param string|null $name * @param array $options * * @return \Symfony\Component\Form\FormInterface diff --git a/src/lib/Form/Factory/FormFactory.php b/src/lib/Form/Factory/FormFactory.php index 9ba2df1596..04e03891d4 100644 --- a/src/lib/Form/Factory/FormFactory.php +++ b/src/lib/Form/Factory/FormFactory.php @@ -156,12 +156,8 @@ public function __construct( } /** - * @param \Ibexa\AdminUi\Form\Data\Content\Draft\ContentEditData|null $data - * @param string|null $name * @param array $options * - * @return \Symfony\Component\Form\FormInterface - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function contentEdit( @@ -185,11 +181,6 @@ public function contentEdit( } /** - * @param \Ibexa\AdminUi\Form\Data\Content\Draft\ContentCreateData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function createContent( @@ -203,15 +194,10 @@ public function createContent( } /** - * @param \Ibexa\AdminUi\Form\Data\ContentType\ContentTypesDeleteData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function deleteContentTypes( - ContentTypesDeleteData $data = null, + ?ContentTypesDeleteData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(ContentTypesDeleteType::class); @@ -219,12 +205,6 @@ public function deleteContentTypes( return $this->formFactory->createNamed($name, ContentTypesDeleteType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\ContentTypeGroup\ContentTypeGroupCreateData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function createContentTypeGroup( ?ContentTypeGroupCreateData $data = null, ?string $name = null @@ -238,46 +218,35 @@ public function createContentTypeGroup( ); } - /** - * @param \Ibexa\AdminUi\Form\Data\ContentTypeGroup\ContentTypeGroupUpdateData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function updateContentTypeGroup( - ContentTypeGroupUpdateData $data = null, + ?ContentTypeGroupUpdateData $data = null, ?string $name = null ): FormInterface { + if ($name === null && $data === null) { + throw new \InvalidArgumentException('Either $name or $data must be provided.'); + } $name = $name ?: sprintf('update-content-type-group-%d', $data->getContentTypeGroup()->id); return $this->formFactory->createNamed($name, ContentTypeGroupUpdateType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\ContentTypeGroup\ContentTypeGroupDeleteData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function deleteContentTypeGroup( - ContentTypeGroupDeleteData $data = null, + ?ContentTypeGroupDeleteData $data = null, ?string $name = null ): FormInterface { + if ($name === null && $data === null) { + throw new \InvalidArgumentException('Either $name or $data must be provided.'); + } $name = $name ?: sprintf('delete-content-type-group-%d', $data->getContentTypeGroup()->id); return $this->formFactory->createNamed($name, ContentTypeGroupDeleteType::class, $data); } /** - * @param \Ibexa\AdminUi\Form\Data\ContentTypeGroup\ContentTypeGroupsDeleteData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function deleteContentTypeGroups( - ContentTypeGroupsDeleteData $data = null, + ?ContentTypeGroupsDeleteData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(ContentTypeGroupsDeleteType::class); @@ -286,15 +255,10 @@ public function deleteContentTypeGroups( } /** - * @param \Ibexa\AdminUi\Form\Data\Content\Translation\TranslationAddData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function addTranslation( - TranslationAddData $data = null, + ?TranslationAddData $data = null, ?string $name = null ): FormInterface { $name = $name ?: sprintf('add-translation'); @@ -303,15 +267,10 @@ public function addTranslation( } /** - * @param \Ibexa\AdminUi\Form\Data\Content\Translation\TranslationDeleteData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function deleteTranslation( - TranslationDeleteData $data = null, + ?TranslationDeleteData $data = null, ?string $name = null ): FormInterface { $name = $name ?: sprintf('delete-translations'); @@ -320,15 +279,10 @@ public function deleteTranslation( } /** - * @param \Ibexa\AdminUi\Form\Data\Version\VersionRemoveData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function removeVersion( - VersionRemoveData $data = null, + ?VersionRemoveData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(VersionRemoveType::class); @@ -337,13 +291,10 @@ public function removeVersion( } /** - * @param \Ibexa\AdminUi\Form\Data\Content\Location\ContentLocationAddData|null $data - * @param string|null $name - * * @return \Symfony\Component\Form\FormInterface */ public function addLocation( - ContentLocationAddData $data = null, + ?ContentLocationAddData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(ContentLocationAddType::class); @@ -351,14 +302,8 @@ public function addLocation( return $this->formFactory->createNamed($name, ContentLocationAddType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\Content\Location\ContentLocationRemoveData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function removeLocation( - ContentLocationRemoveData $data = null, + ?ContentLocationRemoveData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(ContentLocationRemoveType::class); @@ -366,14 +311,8 @@ public function removeLocation( return $this->formFactory->createNamed($name, ContentLocationRemoveType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\Location\LocationSwapData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function swapLocation( - LocationSwapData $data = null, + ?LocationSwapData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(LocationSwapType::class); @@ -382,11 +321,6 @@ public function swapLocation( } /** - * @param \Ibexa\AdminUi\Form\Data\Content\Location\ContentMainLocationUpdateData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function updateContentMainLocation( @@ -403,14 +337,8 @@ public function updateContentMainLocation( ); } - /** - * @param \Ibexa\AdminUi\Form\Data\Location\LocationTrashData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function trashLocation( - LocationTrashData $data = null, + ?LocationTrashData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(LocationTrashType::class); @@ -419,14 +347,8 @@ public function trashLocation( return $this->formFactory->createNamed($name, LocationTrashType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\Location\LocationMoveData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function moveLocation( - LocationMoveData $data = null, + ?LocationMoveData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(LocationMoveType::class); @@ -434,14 +356,8 @@ public function moveLocation( return $this->formFactory->createNamed($name, LocationMoveType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\Location\LocationCopyData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function copyLocation( - LocationCopyData $data = null, + ?LocationCopyData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(LocationCopyType::class); @@ -450,15 +366,10 @@ public function copyLocation( } /** - * @param \Ibexa\AdminUi\Form\Data\Location\LocationUpdateVisibilityData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function updateVisibilityLocation( - LocationUpdateVisibilityData $data = null, + ?LocationUpdateVisibilityData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(LocationUpdateVisibilityData::class); @@ -479,14 +390,8 @@ public function updateVisibilityContent( return $this->formFactory->createNamed($name, ContentVisibilityUpdateType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\Location\LocationUpdateData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function updateLocation( - LocationUpdateData $data = null, + ?LocationUpdateData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(LocationUpdateType::class); @@ -494,14 +399,8 @@ public function updateLocation( return $this->formFactory->createNamed($name, LocationUpdateType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\Section\SectionContentAssignData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function assignContentSectionForm( - SectionContentAssignData $data = null, + ?SectionContentAssignData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(SectionContentAssignType::class); @@ -509,31 +408,23 @@ public function assignContentSectionForm( return $this->formFactory->createNamed($name, SectionContentAssignType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\Section\SectionDeleteData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function deleteSection( - SectionDeleteData $data = null, + ?SectionDeleteData $data = null, ?string $name = null ): FormInterface { + if ($name === null && $data === null) { + throw new \InvalidArgumentException('Either $name or $data must be provided.'); + } $name = $name ?: sprintf('delete-section-%d', $data->getSection()->id); return $this->formFactory->createNamed($name, SectionDeleteType::class, $data); } /** - * @param \Ibexa\AdminUi\Form\Data\Section\SectionsDeleteData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function deleteSections( - SectionsDeleteData $data = null, + ?SectionsDeleteData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(SectionsDeleteType::class); @@ -541,12 +432,6 @@ public function deleteSections( return $this->formFactory->createNamed($name, SectionsDeleteType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\Section\SectionCreateData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function createSection( ?SectionCreateData $data = null, ?string $name = null @@ -560,27 +445,18 @@ public function createSection( ); } - /** - * @param \Ibexa\AdminUi\Form\Data\Section\SectionUpdateData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function updateSection( - SectionUpdateData $data = null, + ?SectionUpdateData $data = null, ?string $name = null ): FormInterface { + if ($name === null && $data === null) { + throw new \InvalidArgumentException('Either $name or $data must be provided.'); + } $name = $name ?: sprintf('update-section-%d', $data->getSection()->id); return $this->formFactory->createNamed($name, SectionUpdateType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\Language\LanguageCreateData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function createLanguage( ?LanguageCreateData $data = null, ?string $name = null @@ -594,12 +470,6 @@ public function createLanguage( ); } - /** - * @param \Ibexa\AdminUi\Form\Data\Language\LanguageUpdateData $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function updateLanguage( LanguageUpdateData $data, ?string $name = null @@ -609,31 +479,26 @@ public function updateLanguage( return $this->formFactory->createNamed($name, LanguageUpdateType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\Language\LanguageDeleteData $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function deleteLanguage( LanguageDeleteData $data, ?string $name = null ): FormInterface { - $name = $name ?: sprintf('delete-language-%d', $data->getLanguage()->id); + if ($name === null) { + $language = $data->getLanguage(); + if ($language === null) { + throw new \InvalidArgumentException('Language is not provided in LanguageDeleteData.'); + } + $name = sprintf('delete-language-%d', $language->id); + } return $this->formFactory->createNamed($name, LanguageDeleteType::class, $data); } /** - * @param \Ibexa\AdminUi\Form\Data\Language\LanguagesDeleteData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function deleteLanguages( - LanguagesDeleteData $data = null, + ?LanguagesDeleteData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(LanguagesDeleteType::class); @@ -641,12 +506,6 @@ public function deleteLanguages( return $this->formFactory->createNamed($name, LanguagesDeleteType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\Role\RoleCreateData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function createRole( ?RoleCreateData $data = null, ?string $name = null @@ -656,12 +515,6 @@ public function createRole( return $this->formFactory->createNamed($name, RoleCreateType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\Role\RoleUpdateData $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function updateRole( RoleUpdateData $data, ?string $name = null @@ -671,12 +524,6 @@ public function updateRole( return $this->formFactory->createNamed($name, RoleUpdateType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\Role\RoleDeleteData $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function deleteRole( RoleDeleteData $data, ?string $name = null @@ -687,15 +534,10 @@ public function deleteRole( } /** - * @param \Ibexa\AdminUi\Form\Data\Role\RolesDeleteData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function deleteRoles( - RolesDeleteData $data = null, + ?RolesDeleteData $data = null, ?string $name = null ): FormInterface { $name = $name ?: sprintf('delete-roles'); @@ -703,12 +545,6 @@ public function deleteRoles( return $this->formFactory->createNamed($name, RolesDeleteType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\Role\RoleAssignmentCreateData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function createRoleAssignment( ?RoleAssignmentCreateData $data = null, ?string $name = null @@ -722,12 +558,6 @@ public function createRoleAssignment( ); } - /** - * @param \Ibexa\AdminUi\Form\Data\Role\RoleAssignmentDeleteData $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function deleteRoleAssignment( RoleAssignmentDeleteData $data, ?string $name = null @@ -744,16 +574,8 @@ public function deleteRoleAssignment( return $this->formFactory->createNamed($name, RoleAssignmentDeleteType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\Role\RoleAssignmentsDeleteData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - * - * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ public function deleteRoleAssignments( - RoleAssignmentsDeleteData $data = null, + ?RoleAssignmentsDeleteData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(RoleAssignmentsDeleteType::class); @@ -761,12 +583,6 @@ public function deleteRoleAssignments( return $this->formFactory->createNamed($name, RoleAssignmentsDeleteType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\Policy\PolicyCreateData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function createPolicy( ?PolicyCreateData $data = null, ?string $name = null @@ -776,12 +592,6 @@ public function createPolicy( return $this->formFactory->createNamed($name, PolicyCreateType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\Policy\PolicyCreateData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function createPolicyWithLimitation( ?PolicyCreateData $data = null, ?string $name = null @@ -791,12 +601,6 @@ public function createPolicyWithLimitation( return $this->formFactory->createNamed($name, PolicyCreateWithLimitationType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\Policy\PolicyUpdateData $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function updatePolicy( PolicyUpdateData $data, ?string $name = null @@ -806,12 +610,6 @@ public function updatePolicy( return $this->formFactory->createNamed($name, PolicyUpdateType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\Policy\PolicyDeleteData $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function deletePolicy( PolicyDeleteData $data, ?string $name = null @@ -822,15 +620,10 @@ public function deletePolicy( } /** - * @param \Ibexa\AdminUi\Form\Data\Policy\PoliciesDeleteData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function deletePolicies( - PoliciesDeleteData $data = null, + ?PoliciesDeleteData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(PoliciesDeleteType::class); @@ -839,14 +632,10 @@ public function deletePolicies( } /** - * @param \Ibexa\AdminUi\Form\Data\Search\SearchData|null $data - * @param string|null $name * @param array $options - * - * @return \Symfony\Component\Form\FormInterface */ public function createSearchForm( - SearchData $data = null, + ?SearchData $data = null, ?string $name = null, array $options = [] ): FormInterface { @@ -856,14 +645,10 @@ public function createSearchForm( } /** - * @param \Ibexa\AdminUi\Form\Data\URL\URLListData|null $data - * @param string|null $name * @param array $options - * - * @return \Symfony\Component\Form\FormInterface */ public function createUrlListForm( - URLListData $data = null, + ?URLListData $data = null, ?string $name = null, array $options = [] ): FormInterface { @@ -873,14 +658,10 @@ public function createUrlListForm( } /** - * @param \Ibexa\AdminUi\Form\Data\URL\URLUpdateData|null $data - * @param string|null $name * @param array $options - * - * @return \Symfony\Component\Form\FormInterface */ public function createUrlEditForm( - URLUpdateData $data = null, + ?URLUpdateData $data = null, ?string $name = null, array $options = [] ): FormInterface { @@ -889,14 +670,8 @@ public function createUrlEditForm( return $this->formFactory->createNamed($name, URLEditType::class, $data, $options); } - /** - * @param \Ibexa\AdminUi\Form\Data\User\UserDeleteData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function deleteUser( - UserDeleteData $data = null, + ?UserDeleteData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(UserDeleteType::class); @@ -904,14 +679,8 @@ public function deleteUser( return $this->formFactory->createNamed($name, UserDeleteType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\Content\CustomUrl\CustomUrlAddData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function addCustomUrl( - CustomUrlAddData $data = null, + ?CustomUrlAddData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(CustomUrlAddType::class); @@ -919,14 +688,8 @@ public function addCustomUrl( return $this->formFactory->createNamed($name, CustomUrlAddType::class, $data ?? new CustomUrlAddData()); } - /** - * @param \Ibexa\AdminUi\Form\Data\Content\CustomUrl\CustomUrlRemoveData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function removeCustomUrl( - CustomUrlRemoveData $data = null, + ?CustomUrlRemoveData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(CustomUrlRemoveType::class); @@ -934,12 +697,6 @@ public function removeCustomUrl( return $this->formFactory->createNamed($name, CustomUrlRemoveType::class, $data ?? new CustomUrlRemoveData()); } - /** - * @param \Ibexa\AdminUi\Form\Data\ObjectState\ObjectStateGroupCreateData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function createObjectStateGroup( ?ObjectStateGroupCreateData $data = null, ?string $name = null @@ -953,31 +710,23 @@ public function createObjectStateGroup( ); } - /** - * @param \Ibexa\AdminUi\Form\Data\ObjectState\ObjectStateGroupDeleteData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function deleteObjectStateGroup( - ObjectStateGroupDeleteData $data = null, + ?ObjectStateGroupDeleteData $data = null, ?string $name = null ): FormInterface { + if ($name === null && $data === null) { + throw new \InvalidArgumentException('Either $name or $data must be provided.'); + } $name = $name ?: sprintf('delete-object-state-group-%d', $data->getObjectStateGroup()->id); return $this->formFactory->createNamed($name, ObjectStateGroupDeleteType::class, $data); } /** - * @param \Ibexa\AdminUi\Form\Data\ObjectState\ObjectStateGroupsDeleteData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function deleteObjectStateGroups( - ObjectStateGroupsDeleteData $data = null, + ?ObjectStateGroupsDeleteData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(ObjectStateGroupsDeleteType::class); @@ -985,29 +734,20 @@ public function deleteObjectStateGroups( return $this->formFactory->createNamed($name, ObjectStateGroupsDeleteType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\ObjectState\ObjectStateGroupUpdateData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function updateObjectStateGroup( - ObjectStateGroupUpdateData $data = null, + ?ObjectStateGroupUpdateData $data = null, ?string $name = null ): FormInterface { + if ($name === null && $data === null) { + throw new \InvalidArgumentException('Either $name or $data must be provided.'); + } $name = $name ?: sprintf('update-object-state-group-%d', $data->getObjectStateGroup()->id); return $this->formFactory->createNamed($name, ObjectStateGroupUpdateType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\Location\LocationCopySubtreeData $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function copyLocationSubtree( - LocationCopySubtreeData $data = null, + ?LocationCopySubtreeData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(LocationCopySubtreeType::class); @@ -1015,14 +755,8 @@ public function copyLocationSubtree( return $this->formFactory->createNamed($name, LocationCopySubtreeType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\Bookmark\BookmarkRemoveData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function removeBookmark( - BookmarkRemoveData $data = null, + ?BookmarkRemoveData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(BookmarkRemoveType::class); @@ -1030,14 +764,8 @@ public function removeBookmark( return $this->formFactory->createNamed($name, BookmarkRemoveType::class, $data); } - /** - * @param \Ibexa\AdminUi\Form\Data\User\UserEditData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function editUser( - UserEditData $data = null, + ?UserEditData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(UserEditType::class); @@ -1049,14 +777,8 @@ public function editUser( return $this->formFactory->createNamed($name, UserEditType::class, $data, $options); } - /** - * @param \Ibexa\AdminUi\Form\Data\Content\Draft\ContentRemoveData|null $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - */ public function removeContentDraft( - ContentRemoveData $data = null, + ?ContentRemoveData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(ContentRemoveType::class); @@ -1065,12 +787,7 @@ public function removeContentDraft( } /** - * @param \Ibexa\AdminUi\Form\Data\URLWildcard\URLWildcardData|null $data - * @param string|null $name - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - * - * @return \Symfony\Component\Form\FormInterface */ public function createURLWildcard( ?URLWildcardData $data = null, @@ -1086,12 +803,7 @@ public function createURLWildcard( } /** - * @param \Ibexa\AdminUi\Form\Data\URLWildcard\URLWildcardUpdateData|null $data - * @param string|null $name - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - * - * @return \Symfony\Component\Form\FormInterface */ public function createURLWildcardUpdate( ?URLWildcardUpdateData $data = null, @@ -1107,12 +819,7 @@ public function createURLWildcardUpdate( } /** - * @param \Ibexa\AdminUi\Form\Data\URLWildcard\URLWildcardDeleteData|null $data - * @param string|null $name - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - * - * @return \Symfony\Component\Form\FormInterface */ public function deleteURLWildcard( ?URLWildcardDeleteData $data = null, diff --git a/src/lib/Form/Factory/TrashFormFactory.php b/src/lib/Form/Factory/TrashFormFactory.php index 0553596ee9..66e8de75be 100644 --- a/src/lib/Form/Factory/TrashFormFactory.php +++ b/src/lib/Form/Factory/TrashFormFactory.php @@ -43,7 +43,7 @@ public function restoreTrashItem( * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function deleteTrashItem( - TrashItemDeleteData $data = null, + ?TrashItemDeleteData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(TrashItemDeleteType::class); diff --git a/src/lib/Service/Role/RoleService.php b/src/lib/Service/Role/RoleService.php index 100c493fa2..43e8d042e4 100644 --- a/src/lib/Service/Role/RoleService.php +++ b/src/lib/Service/Role/RoleService.php @@ -201,7 +201,7 @@ public function assignRole(Role $role, RoleAssignmentData $data) } } - private function doAssignLimitation(Role $role, array $users = null, array $groups = null, RoleLimitation $limitation = null) + private function doAssignLimitation(Role $role, ?array $users = null, ?array $groups = null, ?RoleLimitation $limitation = null) { if (null !== $users) { foreach ($users as $user) { diff --git a/src/lib/Siteaccess/NonAdminSiteaccessResolver.php b/src/lib/Siteaccess/NonAdminSiteaccessResolver.php index 94eae3fa04..02ac99d1be 100644 --- a/src/lib/Siteaccess/NonAdminSiteaccessResolver.php +++ b/src/lib/Siteaccess/NonAdminSiteaccessResolver.php @@ -25,7 +25,6 @@ class NonAdminSiteaccessResolver implements SiteaccessResolverInterface private $siteAccessGroups; /** - * @param \Ibexa\AdminUi\Siteaccess\SiteaccessResolver $siteaccessResolver * @param string[] $siteAccessGroups */ public function __construct(SiteaccessResolver $siteaccessResolver, array $siteAccessGroups) @@ -36,8 +35,8 @@ public function __construct(SiteaccessResolver $siteaccessResolver, array $siteA public function getSiteaccessesForLocation( Location $location, - int $versionNo = null, - string $languageCode = null + ?int $versionNo = null, + ?string $languageCode = null ): array { return array_column( $this->getSiteAccessesListForLocation($location, $versionNo, $languageCode), diff --git a/src/lib/Siteaccess/SiteaccessResolver.php b/src/lib/Siteaccess/SiteaccessResolver.php index 6df66b2bf5..d03e9f6e1b 100644 --- a/src/lib/Siteaccess/SiteaccessResolver.php +++ b/src/lib/Siteaccess/SiteaccessResolver.php @@ -45,10 +45,6 @@ public function __construct( } /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location $location - * @param int|null $versionNo - * @param string|null $languageCode - * * @return array * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException @@ -56,8 +52,8 @@ public function __construct( */ public function getSiteaccessesForLocation( Location $location, - int $versionNo = null, - string $languageCode = null + ?int $versionNo = null, + ?string $languageCode = null ): array { @trigger_error( sprintf( diff --git a/src/lib/Siteaccess/SiteaccessResolverInterface.php b/src/lib/Siteaccess/SiteaccessResolverInterface.php index bdc209d031..137f39f410 100644 --- a/src/lib/Siteaccess/SiteaccessResolverInterface.php +++ b/src/lib/Siteaccess/SiteaccessResolverInterface.php @@ -16,10 +16,6 @@ interface SiteaccessResolverInterface /** * Accepts $location and returns all siteaccesses in which Content item can be previewed. * - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location $location - * @param int|null $versionNo - * @param string|null $languageCode - * * @return string[] * * @deprecated Deprecated since Ibexa DXP 4.5.0. @@ -27,8 +23,8 @@ interface SiteaccessResolverInterface */ public function getSiteaccessesForLocation( Location $location, - int $versionNo = null, - string $languageCode = null + ?int $versionNo = null, + ?string $languageCode = null ): array; /** diff --git a/src/lib/UI/Dataset/ContentDraftListDataset.php b/src/lib/UI/Dataset/ContentDraftListDataset.php index c67c88eaec..41b0d742c4 100644 --- a/src/lib/UI/Dataset/ContentDraftListDataset.php +++ b/src/lib/UI/Dataset/ContentDraftListDataset.php @@ -43,14 +43,7 @@ public function __construct( $this->valueFactory = $valueFactory; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\User\User|null $user - * @param int $offset - * @param int $limit - * - * @return \Ibexa\AdminUi\UI\Dataset\ContentDraftListDataset - */ - public function load(User $user = null, int $offset = 0, int $limit = 10): self + public function load(?User $user = null, int $offset = 0, int $limit = 10): self { $contentDraftListItems = $this->contentService->loadContentDraftList($user, $offset, $limit)->items; diff --git a/src/lib/UI/Dataset/ContentDraftsDataset.php b/src/lib/UI/Dataset/ContentDraftsDataset.php index 39ba715657..ef336496a4 100644 --- a/src/lib/UI/Dataset/ContentDraftsDataset.php +++ b/src/lib/UI/Dataset/ContentDraftsDataset.php @@ -49,12 +49,7 @@ public function __construct( $this->locationService = $locationService; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\User\User|null $user - * - * @return \Ibexa\AdminUi\UI\Dataset\ContentDraftsDataset - */ - public function load(User $user = null): self + public function load(?User $user = null): self { try { $contentDrafts = $this->contentService->loadContentDrafts($user); diff --git a/src/lib/View/Builder/ContentTranslateViewBuilder.php b/src/lib/View/Builder/ContentTranslateViewBuilder.php index 844bb9d830..d530795bd3 100644 --- a/src/lib/View/Builder/ContentTranslateViewBuilder.php +++ b/src/lib/View/Builder/ContentTranslateViewBuilder.php @@ -43,13 +43,6 @@ class ContentTranslateViewBuilder implements ViewBuilder /** @var \Ibexa\Core\MVC\Symfony\Locale\UserLanguagePreferenceProviderInterface */ private $languagePreferenceProvider; - /** - * @param \Ibexa\Contracts\Core\Repository\Repository $repository - * @param \Ibexa\Core\MVC\Symfony\View\Configurator $viewConfigurator - * @param \Ibexa\Core\MVC\Symfony\View\ParametersInjector $viewParametersInjector - * @param \Ibexa\ContentForms\Form\ActionDispatcher\ActionDispatcherInterface $contentActionDispatcher - * @param \Ibexa\Core\MVC\Symfony\Locale\UserLanguagePreferenceProviderInterface $languagePreferenceProvider - */ public function __construct( Repository $repository, Configurator $viewConfigurator, @@ -138,16 +131,14 @@ public function buildView(array $parameters) /** * Loads Content with id $contentId. * - * @param int $contentId * @param array $languages - * @param int|null $versionNo * * @return \Ibexa\Contracts\Core\Repository\Values\Content\Content * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException */ - private function loadContent(int $contentId, array $languages = [], int $versionNo = null): Content + private function loadContent(int $contentId, array $languages = [], ?int $versionNo = null): Content { return $this->repository->getContentService()->loadContent($contentId, $languages, $versionNo); } @@ -155,7 +146,6 @@ private function loadContent(int $contentId, array $languages = [], int $version /** * Loads a visible Location. * - * @param int $locationId * @param array|null $languages * * @return \Ibexa\Contracts\Core\Repository\Values\Content\Location @@ -163,7 +153,7 @@ private function loadContent(int $contentId, array $languages = [], int $version * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException */ - private function loadLocation(int $locationId, array $languages = null): Location + private function loadLocation(int $locationId, ?array $languages = null): Location { return $this->repository->getLocationService()->loadLocation($locationId, $languages); } @@ -171,10 +161,6 @@ private function loadLocation(int $locationId, array $languages = null): Locatio /** * Loads Language with code $languageCode. * - * @param string $languageCode - * - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Language - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException */ private function loadLanguage(string $languageCode): Language @@ -185,8 +171,6 @@ private function loadLanguage(string $languageCode): Language /** * @param array $parameters * - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Language|null - * * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException */ @@ -206,8 +190,6 @@ private function resolveFromLanguage(array $parameters): ?Language /** * @param array $parameters * - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Language - * * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException */ @@ -229,10 +211,6 @@ private function resolveToLanguage(array $parameters): Language /** * @param array $parameters - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location|null $location - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language|null $language - * - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Content * * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException @@ -262,9 +240,6 @@ private function resolveContent(array $parameters, ?Location $location, ?Languag /** * @param array $parameters - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language|null $language - * - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Location|null * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException diff --git a/tests/bundle/Templating/Twig/LimitationValueRenderingExtensionTest.php b/tests/bundle/Templating/Twig/LimitationValueRenderingExtensionTest.php index 4483609236..1f942a11e6 100644 --- a/tests/bundle/Templating/Twig/LimitationValueRenderingExtensionTest.php +++ b/tests/bundle/Templating/Twig/LimitationValueRenderingExtensionTest.php @@ -24,7 +24,7 @@ class LimitationValueRenderingExtensionTest extends FileSystemTwigIntegrationTestCase { - public function getExtensions(Environment $twig = null): array + public function getExtensions(?Environment $twig = null): array { $limitationBlockRenderer = new LimitationBlockRenderer( $this->createLimitationValueMapperRegistryMock(), diff --git a/tests/lib/EventListener/SetViewParametersListenerTest.php b/tests/lib/EventListener/SetViewParametersListenerTest.php index 9a6bb0023f..be26d52c27 100644 --- a/tests/lib/EventListener/SetViewParametersListenerTest.php +++ b/tests/lib/EventListener/SetViewParametersListenerTest.php @@ -136,7 +136,7 @@ public function testSetViewTemplateParameters(): void * * @return \Ibexa\Contracts\Core\Repository\Values\Content\Location */ - private function generateLocation(int $parentLocationId = null): API\Location + private function generateLocation(?int $parentLocationId = null): API\Location { return new Core\Location(['id' => 3, 'parentLocationId' => $parentLocationId]); } @@ -323,7 +323,7 @@ public function testSubscribedEvents(): void * * @return \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo */ - private function generateContentInfo(int $mainLocationId = null, bool $published = false): API\ContentInfo + private function generateContentInfo(?int $mainLocationId = null, bool $published = false): API\ContentInfo { return new API\ContentInfo([ 'mainLocationId' => $mainLocationId, diff --git a/tests/lib/Form/DataTransformer/UserTransformerTest.php b/tests/lib/Form/DataTransformer/UserTransformerTest.php index 5269454c02..594fac65c1 100644 --- a/tests/lib/Form/DataTransformer/UserTransformerTest.php +++ b/tests/lib/Form/DataTransformer/UserTransformerTest.php @@ -158,12 +158,7 @@ public function reverseTransformWithInvalidInputDataProvider(): array ]; } - /** - * @param int $id - * - * @return \Ibexa\Contracts\Core\Repository\Values\User\User - */ - private function generateUser(int $id = null): User + private function generateUser(?int $id = null): User { $contentInfo = new API\ContentInfo(['id' => $id]); $versionInfo = new Core\VersionInfo(['contentInfo' => $contentInfo]); diff --git a/tests/lib/Form/Processor/PreviewFormProcessorTest.php b/tests/lib/Form/Processor/PreviewFormProcessorTest.php index e49139b9a8..c7f17cbf00 100644 --- a/tests/lib/Form/Processor/PreviewFormProcessorTest.php +++ b/tests/lib/Form/Processor/PreviewFormProcessorTest.php @@ -61,10 +61,10 @@ protected function setUp(): void * @return \Ibexa\AdminUi\Form\Processor\PreviewFormProcessor */ private function createPreviewFormProcessor( - ContentService $contentService = null, - UrlGeneratorInterface $urlGenerator = null, - TranslatableNotificationHandlerInterface $notificationHandler = null, - LocationService $locationService = null + ?ContentService $contentService = null, + ?UrlGeneratorInterface $urlGenerator = null, + ?TranslatableNotificationHandlerInterface $notificationHandler = null, + ?LocationService $locationService = null ): PreviewFormProcessor { return new PreviewFormProcessor( $contentService ?? $this->contentService,