diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 0cded9dcf5..8d260672a6 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1446,120 +1446,12 @@ parameters: count: 1 path: src/contracts/Component/Renderer/RendererInterface.php - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\Event\\FormActionEvent\:\:__construct\(\) has parameter \$form with generic interface Symfony\\Component\\Form\\FormInterface but does not specify its types\: TData$#' - identifier: missingType.generics - count: 1 - path: src/contracts/Event/FormActionEvent.php - - - - message: '#^Property Ibexa\\Contracts\\AdminUi\\Event\\FormActionEvent\:\:\$response \(Symfony\\Component\\HttpFoundation\\Response\|null\) is never assigned null so it can be removed from the property type\.$#' - identifier: property.unusedType - count: 1 - path: src/contracts/Event/FormActionEvent.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\Form\\ActionDispatcher\\ActionDispatcherInterface\:\:dispatchFormAction\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/contracts/Form/ActionDispatcher/ActionDispatcherInterface.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\Form\\ActionDispatcher\\ActionDispatcherInterface\:\:dispatchFormAction\(\) has parameter \$form with generic interface Symfony\\Component\\Form\\FormInterface but does not specify its types\: TData$#' - identifier: missingType.generics - count: 1 - path: src/contracts/Form/ActionDispatcher/ActionDispatcherInterface.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\Form\\ActionDispatcher\\ActionDispatcherInterface\:\:dispatchFormAction\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/Form/ActionDispatcher/ActionDispatcherInterface.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\Form\\Data\\FormMapper\\FormDataMapperInterface\:\:mapToFormData\(\) has parameter \$params with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/Form/Data/FormMapper/FormDataMapperInterface.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\Menu\\AbstractBuilder\:\:build\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/Menu/AbstractBuilder.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\Menu\\AbstractBuilder\:\:createConfigureMenuEvent\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/Menu/AbstractBuilder.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\Menu\\AbstractBuilder\:\:createMenuItem\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/Menu/AbstractBuilder.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\Menu\\AbstractBuilder\:\:createStructure\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/Menu/AbstractBuilder.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\Notification\\TranslatableNotificationHandlerInterface\:\:error\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/Notification/TranslatableNotificationHandlerInterface.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\Notification\\TranslatableNotificationHandlerInterface\:\:info\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/Notification/TranslatableNotificationHandlerInterface.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\Notification\\TranslatableNotificationHandlerInterface\:\:success\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/Notification/TranslatableNotificationHandlerInterface.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\Notification\\TranslatableNotificationHandlerInterface\:\:warning\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/Notification/TranslatableNotificationHandlerInterface.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\Permission\\PermissionCheckerInterface\:\:canCreateInLocation\(\) has parameter \$hasAccess with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/Permission/PermissionCheckerInterface.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\Permission\\PermissionCheckerInterface\:\:getRestrictions\(\) has parameter \$hasAccess with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/Permission/PermissionCheckerInterface.php - - message: '#^Method Ibexa\\Contracts\\AdminUi\\Permission\\PermissionCheckerInterface\:\:getRestrictions\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 path: src/contracts/Permission/PermissionCheckerInterface.php - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\UI\\Action\\FormUiActionMapperInterface\:\:map\(\) has parameter \$form with generic interface Symfony\\Component\\Form\\FormInterface but does not specify its types\: TData$#' - identifier: missingType.generics - count: 1 - path: src/contracts/UI/Action/FormUiActionMapperInterface.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\UI\\Action\\FormUiActionMapperInterface\:\:supports\(\) has parameter \$form with generic interface Symfony\\Component\\Form\\FormInterface but does not specify its types\: TData$#' - identifier: missingType.generics - count: 1 - path: src/contracts/UI/Action/FormUiActionMapperInterface.php - - message: '#^Method Ibexa\\Contracts\\AdminUi\\UI\\Action\\UiActionEventInterface\:\:getForm\(\) return type with generic interface Symfony\\Component\\Form\\FormInterface does not specify its types\: TData$#' identifier: missingType.generics @@ -1572,60 +1464,6 @@ parameters: count: 1 path: src/contracts/UI/Action/UiActionEventInterface.php - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\UniversalDiscovery\\Provider\:\:getBreadcrumbLocations\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/UniversalDiscovery/Provider.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\UniversalDiscovery\\Provider\:\:getColumns\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/UniversalDiscovery/Provider.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\UniversalDiscovery\\Provider\:\:getLocationData\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/UniversalDiscovery/Provider.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\UniversalDiscovery\\Provider\:\:getLocationGridViewData\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/UniversalDiscovery/Provider.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\UniversalDiscovery\\Provider\:\:getLocationPermissionRestrictions\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/UniversalDiscovery/Provider.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\UniversalDiscovery\\Provider\:\:getLocations\(\) has parameter \$locationIds with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/UniversalDiscovery/Provider.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\UniversalDiscovery\\Provider\:\:getLocations\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/UniversalDiscovery/Provider.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\UniversalDiscovery\\Provider\:\:getSubitemContents\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/UniversalDiscovery/Provider.php - - - - message: '#^Method Ibexa\\Contracts\\AdminUi\\UniversalDiscovery\\Provider\:\:getSubitemLocations\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/UniversalDiscovery/Provider.php - - message: '#^Method Ibexa\\AdminUi\\Behat\\BrowserContext\\ContentTypeContext\:\:thereAContentTypeOnContentTypesList\(\) has parameter \$contentTypeName with no type specified\.$#' identifier: missingType.parameter @@ -6966,12 +6804,6 @@ parameters: count: 1 path: src/lib/Limitation/Templating/LimitationBlockRendererInterface.php - - - message: '#^Method Ibexa\\AdminUi\\Menu\\Admin\\ContentType\\AbstractContentTypeRightSidebarBuilder\:\:createStructure\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Menu/Admin/ContentType/AbstractContentTypeRightSidebarBuilder.php - - message: '#^Method Ibexa\\AdminUi\\Menu\\Admin\\ContentType\\ContentTypeGroupCreateRightSidebarBuilder\:\:createStructure\(\) has parameter \$options with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -7092,12 +6924,6 @@ parameters: count: 1 path: src/lib/Menu/Admin/Role/RoleAssignmentCreateRightSidebarBuilder.php - - - message: '#^Method Ibexa\\AdminUi\\Menu\\Admin\\Role\\RoleCopyRightSidebarBuilder\:\:createStructure\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Menu/Admin/Role/RoleCopyRightSidebarBuilder.php - - message: '#^Method Ibexa\\AdminUi\\Menu\\Admin\\Role\\RoleCreateRightSidebarBuilder\:\:createStructure\(\) has parameter \$options with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -7266,24 +7092,12 @@ parameters: count: 1 path: src/lib/Menu/TrashRightSidebarBuilder.php - - - message: '#^Method Ibexa\\AdminUi\\Menu\\URLEditRightSidebarBuilder\:\:createStructure\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Menu/URLEditRightSidebarBuilder.php - - message: '#^Property Ibexa\\AdminUi\\Menu\\URLEditRightSidebarBuilder\:\:\$translator is never read, only written\.$#' identifier: property.onlyWritten count: 1 path: src/lib/Menu/URLEditRightSidebarBuilder.php - - - message: '#^Method Ibexa\\AdminUi\\Menu\\URLWildcardEditRightSidebarBuilder\:\:createStructure\(\) has parameter \$options with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Menu/URLWildcardEditRightSidebarBuilder.php - - message: '#^Property Ibexa\\AdminUi\\Menu\\URLWildcardEditRightSidebarBuilder\:\:\$translator is never read, only written\.$#' identifier: property.onlyWritten @@ -7338,18 +7152,6 @@ parameters: count: 1 path: src/lib/Notification/FlashBagNotificationHandler.php - - - message: '#^Method Ibexa\\AdminUi\\Notification\\TranslatableNotificationHandler\:\:info\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Notification/TranslatableNotificationHandler.php - - - - message: '#^Method Ibexa\\AdminUi\\Notification\\TranslatableNotificationHandler\:\:warning\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Notification/TranslatableNotificationHandler.php - - message: '#^Cannot access offset mixed on iterable\\.$#' identifier: offsetAccess.nonOffsetAccessible @@ -7428,12 +7230,6 @@ parameters: count: 1 path: src/lib/Permission/PermissionChecker.php - - - message: '#^Method Ibexa\\AdminUi\\Permission\\PermissionChecker\:\:getRestrictions\(\) has parameter \$hasAccess with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Permission/PermissionChecker.php - - message: '#^Method Ibexa\\AdminUi\\Permission\\PermissionChecker\:\:getRestrictions\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -8166,18 +7962,6 @@ parameters: count: 1 path: src/lib/Translation/Extractor/SortingTranslationExtractor.php - - - message: '#^Method Ibexa\\AdminUi\\UI\\Action\\FormUiActionMapper\:\:map\(\) has parameter \$form with generic interface Symfony\\Component\\Form\\FormInterface but does not specify its types\: TData$#' - identifier: missingType.generics - count: 1 - path: src/lib/UI/Action/FormUiActionMapper.php - - - - message: '#^Method Ibexa\\AdminUi\\UI\\Action\\FormUiActionMapper\:\:supports\(\) has parameter \$form with generic interface Symfony\\Component\\Form\\FormInterface but does not specify its types\: TData$#' - identifier: missingType.generics - count: 1 - path: src/lib/UI/Action/FormUiActionMapper.php - - message: '#^Parameter \#1 \$fqcn of static method Symfony\\Component\\Form\\Util\\StringUtil\:\:fqcnToBlockPrefix\(\) expects string, class\-string\|false given\.$#' identifier: argument.type @@ -8899,91 +8683,67 @@ parameters: path: src/lib/UniversalDiscovery/UniversalDiscoveryProvider.php - - message: '#^Method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:getBreadcrumbLocations\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/UniversalDiscovery/UniversalDiscoveryProvider.php - - - - message: '#^Method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:getColumns\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/UniversalDiscovery/UniversalDiscoveryProvider.php - - - - message: '#^Method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:getLocationData\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/UniversalDiscovery/UniversalDiscoveryProvider.php - - - - message: '#^Method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:getLocationGridViewData\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/UniversalDiscovery/UniversalDiscoveryProvider.php - - - - message: '#^Method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:getLocationPermissionRestrictions\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:getLocations\(\) should return array\, restrictedLanguageCodes\: array\\}, edit\: array\{hasAccess\: bool, restrictedContentTypeIds\: array\, restrictedLanguageCodes\: array\\}\}\}\> but returns list\\}\>\.$#' + identifier: return.type count: 1 path: src/lib/UniversalDiscovery/UniversalDiscoveryProvider.php - - message: '#^Method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:getLocations\(\) has parameter \$locationIds with no value type specified in iterable type array\.$#' + message: '#^Method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:getRelativeLocationPath\(\) has parameter \$locationPath with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 path: src/lib/UniversalDiscovery/UniversalDiscoveryProvider.php - - message: '#^Method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:getLocations\(\) return type has no value type specified in iterable type array\.$#' + message: '#^Method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:getRelativeLocationPath\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 path: src/lib/UniversalDiscovery/UniversalDiscoveryProvider.php - - message: '#^Method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:getRelativeLocationPath\(\) has parameter \$locationPath with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:getSortClause\(\) should return Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\SortClause but returns object\.$#' + identifier: return.type count: 1 path: src/lib/UniversalDiscovery/UniversalDiscoveryProvider.php - - message: '#^Method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:getRelativeLocationPath\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:getSubitemContents\(\) should return array\ but returns list\\.$#' + identifier: return.type count: 1 path: src/lib/UniversalDiscovery/UniversalDiscoveryProvider.php - - message: '#^Method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:getSortClause\(\) should return Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\SortClause but returns object\.$#' + message: '#^Method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:getSubitemLocations\(\) should return array\ but returns array\\|list\\|null\>\.$#' identifier: return.type count: 1 path: src/lib/UniversalDiscovery/UniversalDiscoveryProvider.php - - message: '#^Method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:getSubitemContents\(\) return type has no value type specified in iterable type array\.$#' + message: '#^Method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:moveSelectedLocationOnTop\(\) has parameter \$locations with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 path: src/lib/UniversalDiscovery/UniversalDiscoveryProvider.php - - message: '#^Method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:getSubitemLocations\(\) return type has no value type specified in iterable type array\.$#' + message: '#^Method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:moveSelectedLocationOnTop\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 path: src/lib/UniversalDiscovery/UniversalDiscoveryProvider.php - - message: '#^Method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:moveSelectedLocationOnTop\(\) has parameter \$locations with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#1 \$query of method Ibexa\\Contracts\\Core\\Repository\\SearchService\:\:findLocations\(\) expects Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\LocationQuery, Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query given\.$#' + identifier: argument.type count: 1 path: src/lib/UniversalDiscovery/UniversalDiscoveryProvider.php - - message: '#^Method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:moveSelectedLocationOnTop\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#1 \$value of class Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Criterion\\LocationId constructor expects array\\|int, list\ given\.$#' + identifier: argument.type count: 1 path: src/lib/UniversalDiscovery/UniversalDiscoveryProvider.php - - message: '#^Parameter \#1 \$query of method Ibexa\\Contracts\\Core\\Repository\\SearchService\:\:findLocations\(\) expects Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\LocationQuery, Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query given\.$#' + message: '#^Parameter \#2 \$locations of method Ibexa\\AdminUi\\UniversalDiscovery\\UniversalDiscoveryProvider\:\:moveSelectedLocationOnTop\(\) expects array, Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location given\.$#' identifier: argument.type count: 1 path: src/lib/UniversalDiscovery/UniversalDiscoveryProvider.php diff --git a/src/bundle/Controller/UniversalDiscoveryController.php b/src/bundle/Controller/UniversalDiscoveryController.php index 6521eca632..ead23be1d6 100644 --- a/src/bundle/Controller/UniversalDiscoveryController.php +++ b/src/bundle/Controller/UniversalDiscoveryController.php @@ -16,14 +16,11 @@ use Ibexa\Rest\Server\Controller; use Symfony\Component\HttpFoundation\Request; -class UniversalDiscoveryController extends Controller +final class UniversalDiscoveryController extends Controller { - private Provider $provider; - public function __construct( - Provider $provider + private readonly Provider $provider ) { - $this->provider = $provider; } public function locationsAction(Request $request): LocationListData diff --git a/src/contracts/Controller/Controller.php b/src/contracts/Controller/Controller.php index ea2231c748..a6f98d254c 100644 --- a/src/contracts/Controller/Controller.php +++ b/src/contracts/Controller/Controller.php @@ -21,8 +21,8 @@ abstract class Controller extends AbstractController implements RestrictedContro public function redirectToLocation(Location $location, string $uriFragment = ''): RedirectResponse { return $this->redirectToRoute('ibexa.content.view', [ - 'contentId' => $location->contentId, - 'locationId' => $location->id, + 'contentId' => $location->getContentId(), + 'locationId' => $location->getId(), '_fragment' => $uriFragment, ]); } diff --git a/src/contracts/Event/AutosaveEvents.php b/src/contracts/Event/AutosaveEvents.php index f91362a7a9..82e10040fa 100644 --- a/src/contracts/Event/AutosaveEvents.php +++ b/src/contracts/Event/AutosaveEvents.php @@ -10,6 +10,5 @@ final class AutosaveEvents { - /** @var string */ - public const CONTENT_AUTOSAVE = 'content.edit.autosave'; + public const string CONTENT_AUTOSAVE = 'content.edit.autosave'; } diff --git a/src/contracts/Event/ContentEditEvent.php b/src/contracts/Event/ContentEditEvent.php index caa636629b..5f1f45db07 100644 --- a/src/contracts/Event/ContentEditEvent.php +++ b/src/contracts/Event/ContentEditEvent.php @@ -20,20 +20,11 @@ final class ContentEditEvent extends Event { private ?Response $response = null; - private Content $content; - - private VersionInfo $versionInfo; - - private string $languageCode; - public function __construct( - Content $content, - VersionInfo $versionInfo, - string $languageCode + private readonly Content $content, + private readonly VersionInfo $versionInfo, + private readonly string $languageCode ) { - $this->content = $content; - $this->versionInfo = $versionInfo; - $this->languageCode = $languageCode; } public function getContent(): Content diff --git a/src/contracts/Event/ContentOnTheFlyEvents.php b/src/contracts/Event/ContentOnTheFlyEvents.php index b6f6686949..da38d500d7 100644 --- a/src/contracts/Event/ContentOnTheFlyEvents.php +++ b/src/contracts/Event/ContentOnTheFlyEvents.php @@ -8,17 +8,13 @@ namespace Ibexa\Contracts\AdminUi\Event; -final class ContentOnTheFlyEvents +final readonly class ContentOnTheFlyEvents { - /** @var string */ - public const CONTENT_CREATE = 'ibexa.content_on_the_fly.create'; + public const string CONTENT_CREATE = 'ibexa.content_on_the_fly.create'; - /** @var string */ - public const CONTENT_CREATE_PUBLISH = 'ibexa.content_on_the_fly.create.publish'; + public const string CONTENT_CREATE_PUBLISH = 'ibexa.content_on_the_fly.create.publish'; - /** @var string */ - public const CONTENT_EDIT = 'ibexa.content_on_the_fly.edit'; + public const string CONTENT_EDIT = 'ibexa.content_on_the_fly.edit'; - /** @var string */ - public const CONTENT_EDIT_PUBLISH = 'ibexa.content_on_the_fly.edit.publish'; + public const string CONTENT_EDIT_PUBLISH = 'ibexa.content_on_the_fly.edit.publish'; } diff --git a/src/contracts/Event/ContentProxyCreateEvent.php b/src/contracts/Event/ContentProxyCreateEvent.php index 17da1a33cf..06857c642b 100644 --- a/src/contracts/Event/ContentProxyCreateEvent.php +++ b/src/contracts/Event/ContentProxyCreateEvent.php @@ -18,28 +18,19 @@ */ class ContentProxyCreateEvent extends Event { - public const OPTION_CONTENT_DRAFT = 'contentDraft'; - public const OPTION_IS_ON_THE_FLY = 'isOnTheFly'; + public const string OPTION_CONTENT_DRAFT = 'contentDraft'; + public const string OPTION_IS_ON_THE_FLY = 'isOnTheFly'; private ?Response $response = null; - private ContentType $contentType; - - private string $languageCode; - - private int $parentLocationId; - private Options $options; public function __construct( - ContentType $contentType, - string $languageCode, - int $parentLocationId, + private readonly ContentType $contentType, + private readonly string $languageCode, + private readonly int $parentLocationId, ?Options $options = null ) { - $this->contentType = $contentType; - $this->languageCode = $languageCode; - $this->parentLocationId = $parentLocationId; $this->options = $options ?? new Options(); } diff --git a/src/contracts/Event/ContentProxyTranslateEvent.php b/src/contracts/Event/ContentProxyTranslateEvent.php index 8fe5aa0009..6ec3e536b5 100644 --- a/src/contracts/Event/ContentProxyTranslateEvent.php +++ b/src/contracts/Event/ContentProxyTranslateEvent.php @@ -19,28 +19,16 @@ class ContentProxyTranslateEvent extends Event { private ?Response $response = null; - private int $contentId; - - private ?string $fromLanguageCode; - - private string $toLanguageCode; - private Options $options; - private ?int $locationId; - public function __construct( - int $contentId, - ?string $fromLanguageCode, - string $toLanguageCode, + private readonly int $contentId, + private readonly ?string $fromLanguageCode, + private readonly string $toLanguageCode, ?Options $options = null, - ?int $locationId = null + private readonly ?int $locationId = null ) { - $this->contentId = $contentId; - $this->fromLanguageCode = $fromLanguageCode; - $this->toLanguageCode = $toLanguageCode; $this->options = $options ?? new Options(); - $this->locationId = $locationId; } public function getContentId(): int diff --git a/src/contracts/Event/FieldDefinitionMappingEvent.php b/src/contracts/Event/FieldDefinitionMappingEvent.php index a4f86951c8..4298b9a8c6 100644 --- a/src/contracts/Event/FieldDefinitionMappingEvent.php +++ b/src/contracts/Event/FieldDefinitionMappingEvent.php @@ -13,27 +13,18 @@ use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition; use Symfony\Contracts\EventDispatcher\Event; -class FieldDefinitionMappingEvent extends Event +final class FieldDefinitionMappingEvent extends Event { /** * Triggered when contentTypeData is created from contentTypeDraft. */ - public const NAME = 'field_definition.mapping'; - - private FieldDefinitionData $fieldDefinitionData; - - private ?Language $baseLanguage; - - private ?Language $targetLanguage; + public const string NAME = 'field_definition.mapping'; public function __construct( - FieldDefinitionData $fieldDefinitionData, - ?Language $baseLanguage, - ?Language $targetLanguage + private FieldDefinitionData $fieldDefinitionData, + private readonly ?Language $baseLanguage, + private readonly ?Language $targetLanguage ) { - $this->baseLanguage = $baseLanguage; - $this->targetLanguage = $targetLanguage; - $this->fieldDefinitionData = $fieldDefinitionData; } public function getFieldDefinition(): FieldDefinition diff --git a/src/contracts/Event/FocusModeChangedEvent.php b/src/contracts/Event/FocusModeChangedEvent.php index f7c32b5283..2a272dd260 100644 --- a/src/contracts/Event/FocusModeChangedEvent.php +++ b/src/contracts/Event/FocusModeChangedEvent.php @@ -12,11 +12,8 @@ final class FocusModeChangedEvent extends Event { - private bool $enabled; - - public function __construct(bool $enabled) + public function __construct(private readonly bool $enabled) { - $this->enabled = $enabled; } public function isEnabled(): bool diff --git a/src/contracts/Event/FormActionEvent.php b/src/contracts/Event/FormActionEvent.php index c7ef0a295e..98101c52e6 100644 --- a/src/contracts/Event/FormActionEvent.php +++ b/src/contracts/Event/FormActionEvent.php @@ -12,47 +12,26 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Response; -class FormActionEvent extends FormEvent +final class FormActionEvent extends FormEvent { - /** - * Name of the button used to submit the form. - */ - private ?string $clickedButton; - - /** - * Hash of options. - * - * @var array - */ - private array $options; - /** * Response to return after form post-processing. Typically, a RedirectResponse. */ - private ?Response $response; - - /** - * Additional payload populated for event listeners next in priority. - * - * @var array - */ - private array $payloads; + private ?Response $response = null; /** + * @param \Symfony\Component\Form\FormInterface $form * @param array $options - * @param array $payloads + * @param array $payloads additional payloads populated for event listeners next in priority */ public function __construct( FormInterface $form, mixed $data, - ?string $clickedButton, - array $options = [], - array $payloads = [] + private readonly ?string $clickedButton, + private readonly array $options = [], + private array $payloads = [] ) { parent::__construct($form, $data); - $this->clickedButton = $clickedButton; - $this->options = $options; - $this->payloads = $payloads; } public function getClickedButton(): ?string diff --git a/src/contracts/Event/FormEvents.php b/src/contracts/Event/FormEvents.php index 86559d34a2..309cf60c09 100644 --- a/src/contracts/Event/FormEvents.php +++ b/src/contracts/Event/FormEvents.php @@ -4,38 +4,39 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Contracts\AdminUi\Event; -final class FormEvents +final readonly class FormEvents { /** * Base name for ContentType update processing events. */ - public const CONTENT_TYPE_UPDATE = 'contentType.update'; + public const string CONTENT_TYPE_UPDATE = 'contentType.update'; /** * Triggered when adding a FieldDefinition to the ContentTypeDraft. */ - public const CONTENT_TYPE_ADD_FIELD_DEFINITION = 'contentType.update.addFieldDefinition'; + public const string CONTENT_TYPE_ADD_FIELD_DEFINITION = 'contentType.update.addFieldDefinition'; /** * Triggered when removing a FieldDefinition from the ContentTypeDraft. */ - public const CONTENT_TYPE_REMOVE_FIELD_DEFINITION = 'contentType.update.removeFieldDefinition'; + public const string CONTENT_TYPE_REMOVE_FIELD_DEFINITION = 'contentType.update.removeFieldDefinition'; /** * Triggered when saving the draft + publishing the ContentType. */ - public const CONTENT_TYPE_PUBLISH = 'contentType.update.publishContentType'; + public const string CONTENT_TYPE_PUBLISH = 'contentType.update.publishContentType'; /** * Triggered when saving the draft + publishing the ContentType and starting edition on new draft. */ - public const CONTENT_TYPE_PUBLISH_AND_EDIT = 'contentType.update.publishAndEditContentType'; + public const string CONTENT_TYPE_PUBLISH_AND_EDIT = 'contentType.update.publishAndEditContentType'; /** * Triggered when removing the draft (e.g. "cancel" action). */ - public const CONTENT_TYPE_REMOVE_DRAFT = 'contentType.update.removeDraft'; + public const string CONTENT_TYPE_REMOVE_DRAFT = 'contentType.update.removeDraft'; } diff --git a/src/contracts/Event/UserOnTheFlyEvents.php b/src/contracts/Event/UserOnTheFlyEvents.php index f0961c910c..3711ca75ac 100644 --- a/src/contracts/Event/UserOnTheFlyEvents.php +++ b/src/contracts/Event/UserOnTheFlyEvents.php @@ -8,17 +8,13 @@ namespace Ibexa\Contracts\AdminUi\Event; -final class UserOnTheFlyEvents +final readonly class UserOnTheFlyEvents { - /** @var string */ - public const USER_CREATE = 'ibexa.user_on_the_fly.create'; + public const string USER_CREATE = 'ibexa.user_on_the_fly.create'; - /** @var string */ - public const USER_CREATE_PUBLISH = 'ibexa.user_on_the_fly.create.create'; + public const string USER_CREATE_PUBLISH = 'ibexa.user_on_the_fly.create.create'; - /** @var string */ - public const USER_EDIT = 'ibexa.user_on_the_fly.edit'; + public const string USER_EDIT = 'ibexa.user_on_the_fly.edit'; - /** @var string */ - public const USER_EDIT_PUBLISH = 'ibexa.user_on_the_fly.edit.update'; + public const string USER_EDIT_PUBLISH = 'ibexa.user_on_the_fly.edit.update'; } diff --git a/src/contracts/Form/ActionDispatcher/ActionDispatcherInterface.php b/src/contracts/Form/ActionDispatcher/ActionDispatcherInterface.php index 9a9f20a123..4fc52fdf7f 100644 --- a/src/contracts/Form/ActionDispatcher/ActionDispatcherInterface.php +++ b/src/contracts/Form/ActionDispatcher/ActionDispatcherInterface.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\ValueObject; use Symfony\Component\Form\FormInterface; +use Symfony\Component\HttpFoundation\Response; /** * Form action dispatchers can be used to abstract actions when a complex form is submitted. @@ -22,18 +23,18 @@ interface ActionDispatcherInterface /** * Dispatches the action of a given form. * - * @param \Symfony\Component\Form\FormInterface $form the form that has been submitted + * @param \Symfony\Component\Form\FormInterface $form the form that has been submitted * @param \Ibexa\Contracts\Core\Repository\Values\ValueObject $data Underlying data for the form. Most likely a create or update struct. - * @param string|null $actionName The form action itself. Typically the form clicked button name, + * @param string|null $actionName The form action itself. Typically, the form clicked button name, * or null if the default action is used (e.g. when pressing enter). - * @param array $options arbitrary hash of options + * @param array $options arbitrary hash of options */ - public function dispatchFormAction(FormInterface $form, ValueObject $data, $actionName = null, array $options = []); + public function dispatchFormAction( + FormInterface $form, + ValueObject $data, + ?string $actionName = null, + array $options = [] + ): void; - /** - * Returns the generated response, if any. Typically a RedirectResponse. - * - * @return \Symfony\Component\HttpFoundation\Response|null - */ - public function getResponse(); + public function getResponse(): ?Response; } diff --git a/src/contracts/Form/Data/FormMapper/FormDataMapperInterface.php b/src/contracts/Form/Data/FormMapper/FormDataMapperInterface.php index 7102a92f65..eca92fecbe 100644 --- a/src/contracts/Form/Data/FormMapper/FormDataMapperInterface.php +++ b/src/contracts/Form/Data/FormMapper/FormDataMapperInterface.php @@ -16,12 +16,9 @@ interface FormDataMapperInterface { /** - * Maps a ValueObject from Ibexa content repository to a data usable as underlying form data (e.g. create/update struct). + * Maps a ValueObject from content repository to a data usable as underlying form data (e.g. create/update struct). * - * @param \Ibexa\Contracts\Core\Repository\Values\ValueObject $repositoryValueObject - * @param array $params - * - * @return mixed + * @param array $params */ - public function mapToFormData(ValueObject $repositoryValueObject, array $params = []); + public function mapToFormData(ValueObject $repositoryValueObject, array $params = []): mixed; } diff --git a/src/contracts/Form/DataMapper/DataMapperInterface.php b/src/contracts/Form/DataMapper/DataMapperInterface.php index d1fd00352e..d4e5b65d76 100644 --- a/src/contracts/Form/DataMapper/DataMapperInterface.php +++ b/src/contracts/Form/DataMapper/DataMapperInterface.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Contracts\AdminUi\Form\DataMapper; @@ -14,21 +15,7 @@ */ interface DataMapperInterface { - /** - * Maps Struct object to Data object. - * - * @param \Ibexa\Contracts\Core\Repository\Values\ValueObject $value - * - * @return mixed - */ - public function map(ValueObject $value); + public function map(ValueObject $value): mixed; - /** - * Maps Data object to Struct object. - * - * @param mixed $data - * - * @return mixed - */ - public function reverseMap($data); + public function reverseMap(mixed $data): mixed; } diff --git a/src/contracts/Menu/AbstractActionBuilder.php b/src/contracts/Menu/AbstractActionBuilder.php index 426352569c..4334292463 100644 --- a/src/contracts/Menu/AbstractActionBuilder.php +++ b/src/contracts/Menu/AbstractActionBuilder.php @@ -19,34 +19,21 @@ abstract class AbstractActionBuilder extends AbstractBuilder { - protected const TRANSLATION_DOMAIN = 'ibexa_action_menu'; - protected const IBEXA_BTN_CONTENT_DRAFT_EDIT_CLASS = 'ibexa-btn--content-draft-edit'; + protected const string TRANSLATION_DOMAIN = 'ibexa_action_menu'; + protected const string IBEXA_BTN_CONTENT_DRAFT_EDIT_CLASS = 'ibexa-btn--content-draft-edit'; - private const ICON_EDIT = 'edit'; - private const ORDER_NUMBER = 200; - - protected TranslatorInterface $translator; - - protected UrlGeneratorInterface $urlGenerator; - - private ContentService $contentService; - - private UserService $userService; + private const string ICON_EDIT = 'edit'; + private const int ORDER_NUMBER = 200; public function __construct( MenuItemFactoryInterface $menuItemFactory, EventDispatcherInterface $eventDispatcher, - ContentService $contentService, - TranslatorInterface $translator, - UrlGeneratorInterface $urlGenerator, - UserService $userService + private readonly ContentService $contentService, + protected readonly TranslatorInterface $translator, + protected readonly UrlGeneratorInterface $urlGenerator, + private readonly UserService $userService ) { parent::__construct($menuItemFactory, $eventDispatcher); - - $this->contentService = $contentService; - $this->translator = $translator; - $this->urlGenerator = $urlGenerator; - $this->userService = $userService; } /** diff --git a/src/contracts/Menu/AbstractBuilder.php b/src/contracts/Menu/AbstractBuilder.php index 29afa7dbb3..743af401e4 100644 --- a/src/contracts/Menu/AbstractBuilder.php +++ b/src/contracts/Menu/AbstractBuilder.php @@ -18,44 +18,27 @@ */ abstract class AbstractBuilder { - protected MenuItemFactoryInterface $factory; - - protected EventDispatcherInterface $eventDispatcher; - - /** - * @param \Ibexa\Contracts\AdminUi\Menu\MenuItemFactoryInterface $factory - * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher - */ - public function __construct(MenuItemFactoryInterface $factory, EventDispatcherInterface $eventDispatcher) - { - $this->factory = $factory; - $this->eventDispatcher = $eventDispatcher; + public function __construct( + protected readonly MenuItemFactoryInterface $factory, + protected readonly EventDispatcherInterface $eventDispatcher + ) { } /** - * @param string $id - * @param array $options - * - * @return \Knp\Menu\ItemInterface + * @param array $options */ protected function createMenuItem(string $id, array $options = []): ItemInterface { return $this->factory->createItem($id, $options); } - /** - * @param string $name - * @param \Symfony\Contracts\EventDispatcher\Event $event - */ protected function dispatchMenuEvent(string $name, Event $event): void { $this->eventDispatcher->dispatch($event, $name); } /** - * @param \Knp\Menu\ItemInterface $menu - * - * @return \Ibexa\AdminUi\Menu\Event\ConfigureMenuEvent + * @param array $options */ protected function createConfigureMenuEvent(ItemInterface $menu, array $options = []): ConfigureMenuEvent { @@ -63,9 +46,7 @@ protected function createConfigureMenuEvent(ItemInterface $menu, array $options } /** - * @param array $options - * - * @return \Knp\Menu\ItemInterface + * @param array $options */ public function build(array $options): ItemInterface { @@ -78,5 +59,8 @@ public function build(array $options): ItemInterface abstract protected function getConfigureEventName(): string; + /** + * @param array $options + */ abstract protected function createStructure(array $options): ItemInterface; } diff --git a/src/contracts/Menu/AbstractFormContextMenuBuilder.php b/src/contracts/Menu/AbstractFormContextMenuBuilder.php index 7e3a1229a8..6eeff761ad 100644 --- a/src/contracts/Menu/AbstractFormContextMenuBuilder.php +++ b/src/contracts/Menu/AbstractFormContextMenuBuilder.php @@ -14,16 +14,12 @@ abstract class AbstractFormContextMenuBuilder extends AbstractBuilder { - private string $formName; - public function __construct( MenuItemFactoryInterface $factory, EventDispatcherInterface $eventDispatcher, - string $formName + private readonly string $formName ) { parent::__construct($factory, $eventDispatcher); - - $this->formName = $formName; } /** diff --git a/src/contracts/Menu/MenuItemFactoryInterface.php b/src/contracts/Menu/MenuItemFactoryInterface.php index fc18c9ea4f..3eba705e67 100644 --- a/src/contracts/Menu/MenuItemFactoryInterface.php +++ b/src/contracts/Menu/MenuItemFactoryInterface.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Contracts\AdminUi\Menu; @@ -16,8 +17,6 @@ interface MenuItemFactoryInterface extends FactoryInterface * Creates Location menu item only when user has content/read permission. * * @param array $options - * - * @return \Knp\Menu\ItemInterface|null */ public function createLocationMenuItem(string $name, int $locationId, array $options = []): ?ItemInterface; } diff --git a/src/contracts/Notification/NotificationHandlerInterface.php b/src/contracts/Notification/NotificationHandlerInterface.php index d367a27b1e..a308299931 100644 --- a/src/contracts/Notification/NotificationHandlerInterface.php +++ b/src/contracts/Notification/NotificationHandlerInterface.php @@ -10,23 +10,11 @@ interface NotificationHandlerInterface { - /** - * @param string $message - */ public function info(string $message): void; - /** - * @param string $message - */ public function success(string $message): void; - /** - * @param string $message - */ public function warning(string $message): void; - /** - * @param string $message - */ public function error(string $message): void; } diff --git a/src/contracts/Notification/TranslatableNotificationHandlerInterface.php b/src/contracts/Notification/TranslatableNotificationHandlerInterface.php index 727ff585ba..e06c5ba154 100644 --- a/src/contracts/Notification/TranslatableNotificationHandlerInterface.php +++ b/src/contracts/Notification/TranslatableNotificationHandlerInterface.php @@ -13,11 +13,23 @@ */ interface TranslatableNotificationHandlerInterface { + /** + * @param array $parameters + */ public function info(string $message, array $parameters = [], ?string $domain = null, ?string $locale = null): void; + /** + * @param array $parameters + */ public function success(string $message, array $parameters = [], ?string $domain = null, ?string $locale = null): void; + /** + * @param array $parameters + */ public function warning(string $message, array $parameters = [], ?string $domain = null, ?string $locale = null): void; + /** + * @param array $parameters + */ public function error(string $message, array $parameters = [], ?string $domain = null, ?string $locale = null): void; } diff --git a/src/contracts/Permission/PermissionCheckerInterface.php b/src/contracts/Permission/PermissionCheckerInterface.php index 5f29c81607..110c35cc31 100644 --- a/src/contracts/Permission/PermissionCheckerInterface.php +++ b/src/contracts/Permission/PermissionCheckerInterface.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Contracts\AdminUi\Permission; @@ -11,10 +12,13 @@ interface PermissionCheckerInterface { + /** + * @param array $hasAccess + */ public function getRestrictions(array $hasAccess, string $class): array; /** - * @param array|bool $hasAccess + * @param array|bool $hasAccess */ - public function canCreateInLocation(Location $location, $hasAccess): bool; + public function canCreateInLocation(Location $location, array|bool $hasAccess): bool; } diff --git a/src/contracts/REST/ApplicationConfigRestGeneratorInterface.php b/src/contracts/REST/ApplicationConfigRestGeneratorInterface.php index eedeb7dca9..e6da263f17 100644 --- a/src/contracts/REST/ApplicationConfigRestGeneratorInterface.php +++ b/src/contracts/REST/ApplicationConfigRestGeneratorInterface.php @@ -17,8 +17,5 @@ public function supportsNamespace(string $namespace): bool; public function supportsParameter(string $parameterName): bool; - /** - * @param mixed $parameter - */ - public function generate($parameter, Generator $generator, Visitor $visitor): void; + public function generate(mixed $parameter, Generator $generator, Visitor $visitor): void; } diff --git a/src/contracts/REST/ApplicationConfigRestResolverInterface.php b/src/contracts/REST/ApplicationConfigRestResolverInterface.php index ea96af5cc5..325e0789a7 100644 --- a/src/contracts/REST/ApplicationConfigRestResolverInterface.php +++ b/src/contracts/REST/ApplicationConfigRestResolverInterface.php @@ -15,9 +15,7 @@ public function supportsNamespace(string $namespace): bool; public function supportsParameter(string $parameterName): bool; /** - * @param array $config - * - * @return mixed + * @param array $config */ - public function resolve(array $config); + public function resolve(array $config): mixed; } diff --git a/src/contracts/Tab/AbstractControllerBasedTab.php b/src/contracts/Tab/AbstractControllerBasedTab.php index 88be767440..ca776715f3 100644 --- a/src/contracts/Tab/AbstractControllerBasedTab.php +++ b/src/contracts/Tab/AbstractControllerBasedTab.php @@ -18,16 +18,12 @@ */ abstract class AbstractControllerBasedTab extends AbstractTab { - protected HttpKernelRuntime $httpKernelRuntime; - public function __construct( Environment $twig, TranslatorInterface $translator, - HttpKernelRuntime $httpKernelRuntime + protected readonly HttpKernelRuntime $httpKernelRuntime ) { parent::__construct($twig, $translator); - - $this->httpKernelRuntime = $httpKernelRuntime; } public function renderView(array $parameters): string diff --git a/src/contracts/Tab/AbstractEventDispatchingTab.php b/src/contracts/Tab/AbstractEventDispatchingTab.php index ac8a9cdda9..30dee6bf32 100644 --- a/src/contracts/Tab/AbstractEventDispatchingTab.php +++ b/src/contracts/Tab/AbstractEventDispatchingTab.php @@ -21,16 +21,12 @@ */ abstract class AbstractEventDispatchingTab extends AbstractTab { - protected EventDispatcherInterface $eventDispatcher; - public function __construct( Environment $twig, TranslatorInterface $translator, - EventDispatcherInterface $eventDispatcher + protected readonly EventDispatcherInterface $eventDispatcher ) { parent::__construct($twig, $translator); - - $this->eventDispatcher = $eventDispatcher; } public function renderView(array $parameters): string diff --git a/src/contracts/Tab/AbstractRouteBasedTab.php b/src/contracts/Tab/AbstractRouteBasedTab.php index d4009b344e..5fad2d0b66 100644 --- a/src/contracts/Tab/AbstractRouteBasedTab.php +++ b/src/contracts/Tab/AbstractRouteBasedTab.php @@ -18,20 +18,13 @@ */ abstract class AbstractRouteBasedTab extends AbstractTab { - protected UrlGeneratorInterface $urlGenerator; - - private HttpKernelRuntime $httpKernelRuntime; - public function __construct( Environment $twig, TranslatorInterface $translator, - UrlGeneratorInterface $urlGenerator, - HttpKernelRuntime $httpKernelRuntime + protected readonly UrlGeneratorInterface $urlGenerator, + private readonly HttpKernelRuntime $httpKernelRuntime ) { parent::__construct($twig, $translator); - - $this->urlGenerator = $urlGenerator; - $this->httpKernelRuntime = $httpKernelRuntime; } public function renderView(array $parameters): string diff --git a/src/contracts/Tab/AbstractTab.php b/src/contracts/Tab/AbstractTab.php index e538fd61b1..62d1665daf 100644 --- a/src/contracts/Tab/AbstractTab.php +++ b/src/contracts/Tab/AbstractTab.php @@ -17,13 +17,9 @@ */ abstract class AbstractTab implements TabInterface { - protected Environment $twig; - - protected TranslatorInterface $translator; - - public function __construct(Environment $twig, TranslatorInterface $translator) - { - $this->twig = $twig; - $this->translator = $translator; + public function __construct( + protected Environment $twig, + protected TranslatorInterface $translator + ) { } } diff --git a/src/contracts/Tab/OrderedTabInterface.php b/src/contracts/Tab/OrderedTabInterface.php index 83d7709819..899a1ab555 100644 --- a/src/contracts/Tab/OrderedTabInterface.php +++ b/src/contracts/Tab/OrderedTabInterface.php @@ -15,8 +15,5 @@ */ interface OrderedTabInterface { - /** - * Get the order of this tab. - */ public function getOrder(): int; } diff --git a/src/contracts/Tab/TabInterface.php b/src/contracts/Tab/TabInterface.php index 1762e33e6b..bd45052eaf 100644 --- a/src/contracts/Tab/TabInterface.php +++ b/src/contracts/Tab/TabInterface.php @@ -14,19 +14,11 @@ */ interface TabInterface { - /** - * Returns identifier of the tab. - */ public function getIdentifier(): string; - /** - * Returns name of the tab which is displayed as a tab's title in the UI. - */ public function getName(): string; /** - * Returns HTML body of the tab. - * * @param array $parameters */ public function renderView(array $parameters): string; diff --git a/src/contracts/UI/Action/EventDispatcherInterface.php b/src/contracts/UI/Action/EventDispatcherInterface.php index 0604bfa26f..38021e8422 100644 --- a/src/contracts/UI/Action/EventDispatcherInterface.php +++ b/src/contracts/UI/Action/EventDispatcherInterface.php @@ -10,10 +10,7 @@ interface EventDispatcherInterface { - public const EVENT_NAME_PREFIX = 'ezplatform.admin_ui.action'; + public const string EVENT_NAME_PREFIX = 'ibexa.admin_ui.action'; - /** - * @param \Ibexa\Contracts\AdminUi\UI\Action\UiActionEventInterface $event - */ public function dispatch(UiActionEventInterface $event): void; } diff --git a/src/contracts/UI/Action/FormUiActionMapperInterface.php b/src/contracts/UI/Action/FormUiActionMapperInterface.php index ec578eaa4c..a1c7b33bae 100644 --- a/src/contracts/UI/Action/FormUiActionMapperInterface.php +++ b/src/contracts/UI/Action/FormUiActionMapperInterface.php @@ -14,20 +14,12 @@ interface FormUiActionMapperInterface { /** - * Maps $form object to UiActionEvent object. - * - * @param \Symfony\Component\Form\FormInterface $form - * - * @return \Ibexa\AdminUi\UI\Action\UiActionEvent + * @param \Symfony\Component\Form\FormInterface $form */ public function map(FormInterface $form): UiActionEvent; /** - * Returns true if FormUiActionMapper is able to create Event from the $form;. - * - * @param \Symfony\Component\Form\FormInterface $form - * - * @return bool + * @param \Symfony\Component\Form\FormInterface $form */ public function supports(FormInterface $form): bool; } diff --git a/src/contracts/UI/Action/UiActionEventInterface.php b/src/contracts/UI/Action/UiActionEventInterface.php index 93f197f876..9a3d56bdee 100644 --- a/src/contracts/UI/Action/UiActionEventInterface.php +++ b/src/contracts/UI/Action/UiActionEventInterface.php @@ -13,46 +13,22 @@ interface UiActionEventInterface { - public const TYPE_SUCCESS = 'success'; - public const TYPE_FAILURE = 'failure'; + public const string TYPE_SUCCESS = 'success'; + public const string TYPE_FAILURE = 'failure'; - /** - * @return string - */ public function getName(): string; - /** - * @param string $name - */ public function setName(string $name): void; - /** - * @return string - */ public function getType(): string; - /** - * @param string $type - */ public function setType(string $type): void; - /** - * @return \Symfony\Component\Form\FormInterface - */ public function getForm(): FormInterface; - /** - * @param \Symfony\Component\Form\FormInterface $form - */ public function setForm(FormInterface $form): void; - /** - * @return \Symfony\Component\HttpFoundation\Response|null - */ public function getResponse(): ?Response; - /** - * @param \Symfony\Component\HttpFoundation\Response|null $response - */ public function setResponse(?Response $response): void; } diff --git a/src/contracts/UI/Config/ProviderInterface.php b/src/contracts/UI/Config/ProviderInterface.php index 60037aa575..7292eaa236 100644 --- a/src/contracts/UI/Config/ProviderInterface.php +++ b/src/contracts/UI/Config/ProviderInterface.php @@ -14,7 +14,7 @@ interface ProviderInterface { /** - * @return mixed Anything that is serializable via json_encode() + * @return mixed anything that is serializable via json_encode() */ - public function getConfig(); + public function getConfig(): mixed; } diff --git a/src/contracts/UniversalDiscovery/Provider.php b/src/contracts/UniversalDiscovery/Provider.php index 1ef6ef901c..64f7cf80aa 100644 --- a/src/contracts/UniversalDiscovery/Provider.php +++ b/src/contracts/UniversalDiscovery/Provider.php @@ -13,11 +13,14 @@ interface Provider { - public const ROOT_LOCATION_ID = 1; + public const int ROOT_LOCATION_ID = 1; - public const SORT_CLAUSE_DATE_PUBLISHED = 'DatePublished'; - public const SORT_CLAUSE_CONTENT_NAME = 'ContentName'; + public const string SORT_CLAUSE_DATE_PUBLISHED = 'DatePublished'; + public const string SORT_CLAUSE_CONTENT_NAME = 'ContentName'; + /** + * @return array + */ public function getColumns( int $locationId, int $limit, @@ -26,13 +29,22 @@ public function getColumns( int $rootLocationId = self::ROOT_LOCATION_ID ): array; + /** + * @return \Ibexa\Contracts\Core\Repository\Values\Content\Location[] + */ public function getBreadcrumbLocations( int $locationId, int $rootLocationId = self::ROOT_LOCATION_ID ): array; + /** + * @return array + */ public function getLocationPermissionRestrictions(Location $location): array; + /** + * @return \Ibexa\Contracts\Core\Repository\Values\Content\Content[] + */ public function getSubitemContents( int $locationId, int $offset, @@ -40,6 +52,9 @@ public function getSubitemContents( Query\SortClause $sortClause ): array; + /** + * @return \Ibexa\Contracts\Core\Repository\Values\Content\Location[] + */ public function getSubitemLocations( int $locationId, int $offset, @@ -47,6 +62,9 @@ public function getSubitemLocations( Query\SortClause $sortClause ): array; + /** + * @return array + */ public function getLocationData( int $locationId, int $offset, @@ -54,6 +72,9 @@ public function getLocationData( Query\SortClause $sortClause ): array; + /** + * @return array + */ public function getLocationGridViewData( int $locationId, int $offset, @@ -61,6 +82,25 @@ public function getLocationGridViewData( Query\SortClause $sortClause ): array; + /** + * @param list $locationIds + * + * @return array, + * restrictedLanguageCodes: array + * }, + * edit: array{ + * hasAccess: bool, + * restrictedContentTypeIds: array, + * restrictedLanguageCodes: array + * } + * } + * }> + */ public function getLocations(array $locationIds): array; public function getSortClause(string $sortClauseName, string $sortOrder): Query\SortClause; diff --git a/src/lib/REST/Generator/ProfilePictureFieldConfigRestGenerator.php b/src/lib/REST/Generator/ProfilePictureFieldConfigRestGenerator.php index c969589e53..ded46d85d9 100644 --- a/src/lib/REST/Generator/ProfilePictureFieldConfigRestGenerator.php +++ b/src/lib/REST/Generator/ProfilePictureFieldConfigRestGenerator.php @@ -13,10 +13,10 @@ use Ibexa\Contracts\Rest\Output\Generator; use Ibexa\Contracts\Rest\Output\Visitor; -final class ProfilePictureFieldConfigRestGenerator implements ApplicationConfigRestGeneratorInterface +final readonly class ProfilePictureFieldConfigRestGenerator implements ApplicationConfigRestGeneratorInterface { - private const NAMESPACE = 'user'; - private const PARAMETER = 'profile_picture_field'; + private const string NAMESPACE = 'user'; + private const string PARAMETER = 'profile_picture_field'; public function supportsNamespace(string $namespace): bool { @@ -28,7 +28,7 @@ public function supportsParameter(string $parameterName): bool return self::PARAMETER === $parameterName; } - public function generate($parameter, Generator $generator, Visitor $visitor): void + public function generate(mixed $parameter, Generator $generator, Visitor $visitor): void { if ($parameter instanceof Field) { $generator->startHashElement(self::PARAMETER); diff --git a/src/lib/REST/Generator/UserConfigRestGenerator.php b/src/lib/REST/Generator/UserConfigRestGenerator.php index fa7012755c..e9d9eab27e 100644 --- a/src/lib/REST/Generator/UserConfigRestGenerator.php +++ b/src/lib/REST/Generator/UserConfigRestGenerator.php @@ -13,10 +13,10 @@ use Ibexa\Contracts\Rest\Output\Generator; use Ibexa\Contracts\Rest\Output\Visitor; -final class UserConfigRestGenerator implements ApplicationConfigRestGeneratorInterface +final readonly class UserConfigRestGenerator implements ApplicationConfigRestGeneratorInterface { - private const NAMESPACE = 'user'; - private const PARAMETER = 'user'; + private const string NAMESPACE = 'user'; + private const string PARAMETER = 'user'; public function supportsNamespace(string $namespace): bool { @@ -28,7 +28,7 @@ public function supportsParameter(string $parameterName): bool return self::PARAMETER === $parameterName; } - public function generate($parameter, Generator $generator, Visitor $visitor): void + public function generate(mixed $parameter, Generator $generator, Visitor $visitor): void { if ($parameter instanceof User) { $generator->startHashElement(self::PARAMETER); diff --git a/src/lib/UI/Config/Provider/ScopeParameterBasedValue.php b/src/lib/UI/Config/Provider/ScopeParameterBasedValue.php index 1fe2ab326b..34dcc994d4 100644 --- a/src/lib/UI/Config/Provider/ScopeParameterBasedValue.php +++ b/src/lib/UI/Config/Provider/ScopeParameterBasedValue.php @@ -11,35 +11,22 @@ use Ibexa\Contracts\AdminUi\UI\Config\ProviderInterface; use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface; -class ScopeParameterBasedValue implements ProviderInterface +readonly class ScopeParameterBasedValue implements ProviderInterface { - protected ConfigResolverInterface $configResolver; - - protected string $parameterName; - - protected ?string $namespace; - - protected ?string $scope; - public function __construct( - ConfigResolverInterface $configResolver, - string $parameterName, - ?string $namespace = null, - ?string $scope = null + protected ConfigResolverInterface $configResolver, + protected string $parameterName, + protected ?string $namespace = null, + protected ?string $scope = null ) { - $this->configResolver = $configResolver; - $this->parameterName = $parameterName; - $this->namespace = $namespace; - $this->scope = $scope; } - /** - * {@inheritdoc} - * - * @return mixed - */ - public function getConfig() + public function getConfig(): mixed { - return $this->configResolver->getParameter($this->parameterName, $this->namespace, $this->scope); + return $this->configResolver->getParameter( + $this->parameterName, + $this->namespace, + $this->scope + ); } } diff --git a/src/lib/UI/Config/Provider/UserContentTypes.php b/src/lib/UI/Config/Provider/UserContentTypes.php index aa6f9be7ca..c96a78b1ff 100644 --- a/src/lib/UI/Config/Provider/UserContentTypes.php +++ b/src/lib/UI/Config/Provider/UserContentTypes.php @@ -11,23 +11,16 @@ use Ibexa\Contracts\AdminUi\UI\Config\ProviderInterface; use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface; -class UserContentTypes implements ProviderInterface +final readonly class UserContentTypes implements ProviderInterface { - private ConfigResolverInterface $configResolver; - - /** - * @param \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface $configResolver - */ - public function __construct(ConfigResolverInterface $configResolver) + public function __construct(private ConfigResolverInterface $configResolver) { - $this->configResolver = $configResolver; } - /** - * @return mixed Anything that is serializable via json_encode() - */ - public function getConfig() + public function getConfig(): mixed { - return $this->configResolver->getParameter('user_content_type_identifier'); + return $this->configResolver->getParameter( + 'user_content_type_identifier' + ); } } diff --git a/src/lib/UI/Config/Provider/Value.php b/src/lib/UI/Config/Provider/Value.php index 1ad1f6355f..b3be6ba022 100644 --- a/src/lib/UI/Config/Provider/Value.php +++ b/src/lib/UI/Config/Provider/Value.php @@ -14,25 +14,13 @@ * Simple value provider that passes on the value it is given in the constructor. * Can be used for container config. */ -class Value implements ProviderInterface +readonly class Value implements ProviderInterface { - /** @var mixed */ - protected $config; - - /** - * @param mixed $value - */ - public function __construct($value) + public function __construct(protected mixed $config) { - $this->config = $value; } - /** - * {@inheritdoc} - * - * @return mixed - */ - public function getConfig() + public function getConfig(): mixed { return $this->config; } diff --git a/tests/lib/Tab/TabRegistryTest.php b/tests/lib/Tab/TabRegistryTest.php index de1374ab3c..e45ed2eec2 100644 --- a/tests/lib/Tab/TabRegistryTest.php +++ b/tests/lib/Tab/TabRegistryTest.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Tests\AdminUi\Tab; @@ -15,7 +16,7 @@ use Symfony\Contracts\Translation\TranslatorInterface; use Twig\Environment; -class TabRegistryTest extends TestCase +final class TabRegistryTest extends TestCase { private string $groupName; @@ -28,7 +29,9 @@ protected function setUp(): void public function testGetTabsByGroupNameWhenGroupDoesNotExist(): void { $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage(sprintf('Could not find the requested group named "%s". Did you tag the service?', $this->groupName)); + $this->expectExceptionMessage( + sprintf('Could not find the requested group named "%s". Did you tag the service?', $this->groupName) + ); $tabRegistry = new TabRegistry(); $tabRegistry->getTabsByGroupName($this->groupName); @@ -68,7 +71,9 @@ public function testGetTabFromGroup(): void public function testGetTabFromGroupWhenGroupDoesNotExist(): void { $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage(sprintf('Could not find the requested group named "%s". Did you tag the service?', $this->groupName)); + $this->expectExceptionMessage( + sprintf('Could not find the requested group named "%s". Did you tag the service?', $this->groupName) + ); $tabRegistry = new TabRegistry(); $tabRegistry->getTabFromGroup('tab1', $this->groupName); @@ -79,7 +84,13 @@ public function testGetTabFromGroupWhenTabDoesNotExist(): void $tabName = 'tab1'; $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage(sprintf('Could not find the requested tab "%s" from group "%s". Did you tag the service?', $tabName, $this->groupName)); + $this->expectExceptionMessage( + sprintf( + 'Could not find the requested tab "%s" from group "%s". Did you tag the service?', + $tabName, + $this->groupName + ) + ); $tabs = []; $tabRegistry = new TabRegistry(); @@ -149,16 +160,12 @@ private function createTabGroup(string $name = 'lorem', array $tabs = []): TabGr private function createTab(string $name, Environment $twig, TranslatorInterface $translator): TabInterface { return new class($name, $twig, $translator) extends AbstractTab { - protected string $name; - - protected Environment $twig; - - protected TranslatorInterface $translator; - - public function __construct(string $name, Environment $twig, TranslatorInterface $translator) - { + public function __construct( + protected readonly string $name, + Environment $twig, + TranslatorInterface $translator + ) { parent::__construct($twig, $translator); - $this->name = $name; } public function getIdentifier(): string