diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 9522877c..e265e543 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,17 +1,5 @@ parameters: ignoreErrors: - - - message: '#^Method Ibexa\\Bundle\\User\\Command\\AuditUserDatabaseCommand\:\:isUniqueEmailRequired\(\) has parameter \$userFieldDefinitions with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Command/AuditUserDatabaseCommand.php - - - - message: '#^Method Ibexa\\Bundle\\User\\Controller\\DefaultProfileImageController\:\:getInitialsColors\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Controller/DefaultProfileImageController.php - - message: '#^Cannot call method getAPIUser\(\) on Symfony\\Component\\Security\\Core\\User\\UserInterface\|null\.$#' identifier: method.nonObject @@ -24,18 +12,6 @@ parameters: count: 1 path: src/bundle/Controller/PasswordChangeController.php - - - message: '#^Method Ibexa\\Bundle\\User\\Controller\\PasswordChangeController\:\:__construct\(\) has parameter \$siteAccessGroups with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Controller/PasswordChangeController.php - - - - message: '#^Property Ibexa\\Bundle\\User\\Controller\\PasswordChangeController\:\:\$siteAccessGroups type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Controller/PasswordChangeController.php - - message: '#^Parameter \#1 \$user of method Ibexa\\Bundle\\User\\Controller\\PasswordResetController\:\:sendResetPasswordMessage\(\) expects Ibexa\\Contracts\\Core\\Repository\\Values\\User\\User, Ibexa\\Contracts\\Core\\Repository\\Values\\User\\User\|false given\.$#' identifier: argument.type @@ -84,96 +60,12 @@ parameters: count: 1 path: src/bundle/Controller/UserSettingsController.php - - - message: '#^PHPDoc tag @throws has invalid value \(\\Ibexa\\Core\\Base\\Exceptions\\InvalidArgumentException;\)\: Unexpected token ";", expected TOKEN_HORIZONTAL_WS at offset 337 on line 6$#' - identifier: phpDoc.parseError - count: 1 - path: src/bundle/DependencyInjection/Compiler/UserSetting/FormMapperPass.php - - - - message: '#^Method Ibexa\\Bundle\\User\\DependencyInjection\\Configuration\\Parser\\ChangePassword\:\:mapConfig\(\) has parameter \$scopeSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/ChangePassword.php - - - - message: '#^Method Ibexa\\Bundle\\User\\DependencyInjection\\Configuration\\Parser\\ForgotPassword\:\:mapConfig\(\) has parameter \$scopeSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/ForgotPassword.php - - - - message: '#^Method Ibexa\\Bundle\\User\\DependencyInjection\\Configuration\\Parser\\Pagination\:\:mapConfig\(\) has parameter \$scopeSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/Pagination.php - - - - message: '#^Method Ibexa\\Bundle\\User\\DependencyInjection\\Configuration\\Parser\\ResetPassword\:\:mapConfig\(\) has parameter \$scopeSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/ResetPassword.php - - - - message: '#^Method Ibexa\\Bundle\\User\\DependencyInjection\\Configuration\\Parser\\Security\:\:mapConfig\(\) has parameter \$scopeSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/Security.php - - - - message: '#^Method Ibexa\\Bundle\\User\\DependencyInjection\\Configuration\\Parser\\UserInvitation\:\:mapConfig\(\) has parameter \$scopeSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/UserInvitation.php - - - - message: '#^Method Ibexa\\Bundle\\User\\DependencyInjection\\Configuration\\Parser\\UserPreferences\:\:mapConfig\(\) has parameter \$scopeSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/UserPreferences.php - - - - message: '#^Method Ibexa\\Bundle\\User\\DependencyInjection\\Configuration\\Parser\\UserRegistration\:\:mapConfig\(\) has parameter \$scopeSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/UserRegistration.php - - - - message: '#^Method Ibexa\\Contracts\\User\\Invitation\\Persistence\\Gateway\:\:getInvitation\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/contracts/Invitation/Persistence/Gateway.php - - message: '#^Method Ibexa\\Contracts\\User\\Invitation\\Persistence\\Gateway\:\:getInvitationByEmail\(\) has no return type specified\.$#' identifier: missingType.return count: 1 path: src/contracts/Invitation/Persistence/Gateway.php - - - message: '#^Method Ibexa\\Contracts\\User\\Invitation\\Persistence\\Invitation\:\:__construct\(\) has parameter \$limitationValue with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/Invitation/Persistence/Invitation.php - - - - message: '#^Method Ibexa\\Contracts\\User\\Invitation\\Persistence\\Invitation\:\:getLimitationValue\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/Invitation/Persistence/Invitation.php - - - - message: '#^Property Ibexa\\Contracts\\User\\Invitation\\Persistence\\Invitation\:\:\$limitationValue type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/Invitation/Persistence/Invitation.php - - - - message: '#^Method Ibexa\\Contracts\\User\\Invitation\\Persistence\\Mapper\:\:extractInvitationFromRow\(\) has parameter \$row with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/Invitation/Persistence/Mapper.php - - message: '#^Method Ibexa\\Contracts\\User\\Notification\\UserInvitation\:\:asEmailMessage\(\) never returns null so it can be removed from the return type\.$#' identifier: return.unusedType @@ -198,90 +90,12 @@ parameters: count: 1 path: src/contracts/UserSetting/FormMapperInterface.php - - - message: '#^Method Ibexa\\User\\ConfigResolver\\ConfigurableSudoRepositoryLoader\:\:__construct\(\) has parameter \$params with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ConfigResolver/ConfigurableSudoRepositoryLoader.php - - - - message: '#^Method Ibexa\\User\\ConfigResolver\\ConfigurableSudoRepositoryLoader\:\:configureOptions\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/lib/ConfigResolver/ConfigurableSudoRepositoryLoader.php - - - - message: '#^Method Ibexa\\User\\ConfigResolver\\ConfigurableSudoRepositoryLoader\:\:getParam\(\) has parameter \$name with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: src/lib/ConfigResolver/ConfigurableSudoRepositoryLoader.php - - - - message: '#^Method Ibexa\\User\\ConfigResolver\\ConfigurableSudoRepositoryLoader\:\:setParam\(\) has parameter \$name with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: src/lib/ConfigResolver/ConfigurableSudoRepositoryLoader.php - - - - message: '#^Method Ibexa\\User\\ConfigResolver\\ConfigurableSudoRepositoryLoader\:\:setParam\(\) has parameter \$value with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: src/lib/ConfigResolver/ConfigurableSudoRepositoryLoader.php - - - - message: '#^Property Ibexa\\User\\ConfigResolver\\ConfigurableSudoRepositoryLoader\:\:\$params type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ConfigResolver/ConfigurableSudoRepositoryLoader.php - - - - message: '#^Method Ibexa\\User\\ExceptionHandler\\ActionResultHandler\:\:error\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ExceptionHandler/ActionResultHandler.php - - - - message: '#^Method Ibexa\\User\\ExceptionHandler\\ActionResultHandler\:\:success\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ExceptionHandler/ActionResultHandler.php - - - - message: '#^Method Ibexa\\User\\ExceptionHandler\\NullActionResultHandler\:\:error\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ExceptionHandler/NullActionResultHandler.php - - - - message: '#^Method Ibexa\\User\\ExceptionHandler\\NullActionResultHandler\:\:success\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ExceptionHandler/NullActionResultHandler.php - - message: '#^Method Ibexa\\User\\Form\\BaseSubmitHandler\:\:handle\(\) 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/Form/BaseSubmitHandler.php - - - message: '#^Method Ibexa\\User\\Form\\ChoiceList\\Loader\\UserGroupsChoiceLoader\:\:loadChoices\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Form/ChoiceList/Loader/UserGroupsChoiceLoader.php - - - - message: '#^Method Ibexa\\User\\Form\\Data\\UserInvitationData\:\:__construct\(\) has parameter \$limitationValue with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Form/Data/UserInvitationData.php - - - - message: '#^Method Ibexa\\User\\Form\\Data\\UserInvitationData\:\:__construct\(\) has parameter \$sections with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Form/Data/UserInvitationData.php - - message: '#^Method Ibexa\\User\\Form\\Data\\UserInvitationData\:\:getLimitationValue\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -312,66 +126,12 @@ parameters: count: 1 path: src/lib/Form/Data/UserInvitationData.php - - - message: '#^Property Ibexa\\User\\Form\\Data\\UserInvitationData\:\:\$email \(string\) does not accept string\|null\.$#' - identifier: assign.propertyType - count: 1 - path: src/lib/Form/Data/UserInvitationData.php - - - - message: '#^Property Ibexa\\User\\Form\\Data\\UserInvitationData\:\:\$limitationValue type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Form/Data/UserInvitationData.php - - - - message: '#^Method Ibexa\\User\\Form\\Data\\UserSettingUpdateData\:\:__construct\(\) has parameter \$values with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Form/Data/UserSettingUpdateData.php - - - - message: '#^Method Ibexa\\User\\Form\\Data\\UserSettingUpdateData\:\:getValues\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Form/Data/UserSettingUpdateData.php - - - - message: '#^Method Ibexa\\User\\Form\\Data\\UserSettingUpdateData\:\:setValues\(\) has parameter \$values with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Form/Data/UserSettingUpdateData.php - - message: '#^Method Ibexa\\User\\ConfigResolver\\RegistrationContentTypeLoader\:\:loadContentType\(\) invoked with 1 parameter, 0 required\.$#' identifier: arguments.count count: 1 path: src/lib/Form/DataMapper/UserRegisterMapper.php - - - message: '#^Method Ibexa\\User\\Form\\DataMapper\\UserRegisterMapper\:\:setParam\(\) has parameter \$name with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: src/lib/Form/DataMapper/UserRegisterMapper.php - - - - message: '#^Method Ibexa\\User\\Form\\DataMapper\\UserRegisterMapper\:\:setParam\(\) has parameter \$value with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: src/lib/Form/DataMapper/UserRegisterMapper.php - - - - message: '#^PHPDoc tag @var for property Ibexa\\User\\Form\\DataMapper\\UserRegisterMapper\:\:\$parentGroupLoader with type Ibexa\\User\\ConfigResolver\\RegistrationContentTypeLoader is not subtype of native type Ibexa\\User\\ConfigResolver\\RegistrationGroupLoader\.$#' - identifier: property.phpDocType - count: 1 - path: src/lib/Form/DataMapper/UserRegisterMapper.php - - - - message: '#^Property Ibexa\\User\\Form\\DataMapper\\UserRegisterMapper\:\:\$params type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Form/DataMapper/UserRegisterMapper.php - - message: '#^Cannot call method getDateFormat\(\) on Ibexa\\User\\UserSetting\\Setting\\Value\\DateTimeFormat\|null\.$#' identifier: method.nonObject @@ -390,12 +150,6 @@ parameters: count: 1 path: src/lib/Form/DataTransformer/DateTimeFormatTransformer.php - - - message: '#^Method Ibexa\\User\\Form\\DataTransformer\\DateTimeFormatTransformer\:\:transform\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Form/DataTransformer/DateTimeFormatTransformer.php - - message: '#^Class Ibexa\\User\\Form\\DataTransformer\\InvitationTransformer implements generic interface Symfony\\Component\\Form\\DataTransformerInterface but does not specify its types\: T, R$#' identifier: missingType.generics @@ -468,72 +222,30 @@ parameters: count: 1 path: src/lib/Form/Type/Invitation/InvitationType.php - - - message: '#^Method Ibexa\\User\\Form\\Type\\Invitation\\InvitationType\:\:getParent\(\) never returns null so it can be removed from the return type\.$#' - identifier: return.unusedType - count: 1 - path: src/lib/Form/Type/Invitation/InvitationType.php - - message: '#^Class Ibexa\\User\\Form\\Type\\Invitation\\RoleChoiceType extends generic class Symfony\\Component\\Form\\AbstractType but does not specify its types\: TData$#' identifier: missingType.generics count: 1 path: src/lib/Form/Type/Invitation/RoleChoiceType.php - - - message: '#^Method Ibexa\\User\\Form\\Type\\Invitation\\RoleChoiceType\:\:getParent\(\) never returns null so it can be removed from the return type\.$#' - identifier: return.unusedType - count: 1 - path: src/lib/Form/Type/Invitation/RoleChoiceType.php - - - - message: '#^Method Ibexa\\User\\Form\\Type\\Invitation\\RoleChoiceType\:\:loadFilteredRoles\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Form/Type/Invitation/RoleChoiceType.php - - message: '#^Class Ibexa\\User\\Form\\Type\\Invitation\\SectionsChoiceType extends generic class Symfony\\Component\\Form\\AbstractType but does not specify its types\: TData$#' identifier: missingType.generics count: 1 path: src/lib/Form/Type/Invitation/SectionsChoiceType.php - - - message: '#^Method Ibexa\\User\\Form\\Type\\Invitation\\SectionsChoiceType\:\:getParent\(\) never returns null so it can be removed from the return type\.$#' - identifier: return.unusedType - count: 1 - path: src/lib/Form/Type/Invitation/SectionsChoiceType.php - - message: '#^Class Ibexa\\User\\Form\\Type\\Invitation\\SiteAccessChoiceType extends generic class Symfony\\Component\\Form\\AbstractType but does not specify its types\: TData$#' identifier: missingType.generics count: 1 path: src/lib/Form/Type/Invitation/SiteAccessChoiceType.php - - - message: '#^Method Ibexa\\User\\Form\\Type\\Invitation\\SiteAccessChoiceType\:\:getParent\(\) never returns null so it can be removed from the return type\.$#' - identifier: return.unusedType - count: 1 - path: src/lib/Form/Type/Invitation/SiteAccessChoiceType.php - - message: '#^Class Ibexa\\User\\Form\\Type\\Invitation\\UserGroupChoiceType extends generic class Symfony\\Component\\Form\\AbstractType but does not specify its types\: TData$#' identifier: missingType.generics count: 1 path: src/lib/Form/Type/Invitation/UserGroupChoiceType.php - - - message: '#^Method Ibexa\\User\\Form\\Type\\Invitation\\UserGroupChoiceType\:\:getParent\(\) never returns null so it can be removed from the return type\.$#' - identifier: return.unusedType - count: 1 - path: src/lib/Form/Type/Invitation/UserGroupChoiceType.php - - - - message: '#^Method Ibexa\\User\\Form\\Type\\Invitation\\UserGroupChoiceType\:\:loadFilteredGroups\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Form/Type/Invitation/UserGroupChoiceType.php - - message: '#^Class Ibexa\\User\\Form\\Type\\Invitation\\UserInvitationType extends generic class Symfony\\Component\\Form\\AbstractType but does not specify its types\: TData$#' identifier: missingType.generics @@ -600,12 +312,6 @@ parameters: count: 1 path: src/lib/Invitation/DomainMapper.php - - - message: '#^Parameter \#2 \$values of method Ibexa\\User\\Invitation\\DomainMapper\:\:mapRoleLimitation\(\) expects array, array\|null given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Invitation/DomainMapper.php - - message: '#^Parameter \#1 \$length of function random_bytes expects int\<1, max\>, int given\.$#' identifier: argument.type @@ -630,24 +336,12 @@ parameters: count: 1 path: src/lib/Invitation/InvitationService.php - - - message: '#^Method Ibexa\\User\\Invitation\\Persistence\\DoctrineGateway\:\:getInvitation\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/lib/Invitation/Persistence/DoctrineGateway.php - - message: '#^Parameter \#1 \$select of method Doctrine\\DBAL\\Query\\QueryBuilder\:\:select\(\) expects array\\|string\|null, int given\.$#' identifier: argument.type count: 1 path: src/lib/Invitation/Persistence/DoctrineGateway.php - - - message: '#^Method Ibexa\\User\\Invitation\\Persistence\\Mapper\:\:extractInvitationFromRow\(\) has parameter \$row with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Invitation/Persistence/Mapper.php - - message: '#^Method Ibexa\\User\\Pagination\\Pagerfanta\\UserSettingsAdapter\:\:getNbResults\(\) should return int\<0, max\> but returns int\.$#' identifier: return.type @@ -660,30 +354,6 @@ parameters: count: 1 path: src/lib/Pagination/Pagerfanta/UserSettingsAdapter.php - - - message: '#^Method Ibexa\\User\\Strategy\\DefaultThumbnailStrategy\:\:__construct\(\) has parameter \$initialsFieldDefIdentifiers with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Strategy/DefaultThumbnailStrategy.php - - - - message: '#^Method Ibexa\\User\\Strategy\\DefaultThumbnailStrategy\:\:getInitials\(\) has parameter \$fields with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Strategy/DefaultThumbnailStrategy.php - - - - message: '#^Method Ibexa\\User\\Strategy\\DefaultThumbnailStrategy\:\:getThumbnail\(\) has parameter \$fields with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Strategy/DefaultThumbnailStrategy.php - - - - message: '#^Property Ibexa\\User\\Templating\\Twig\\DateTimeExtension\:\:\$dateTimeFormatSerializer is never read, only written\.$#' - identifier: property.onlyWritten - count: 1 - path: src/lib/Templating/Twig/DateTimeExtension.php - - message: '#^Cannot call method getDateFormat\(\) on Ibexa\\User\\UserSetting\\Setting\\Value\\DateTimeFormat\|null\.$#' identifier: method.nonObject @@ -708,36 +378,6 @@ parameters: count: 1 path: src/lib/UserSetting/DateTimeFormat/ShortTimeFormatterFactory.php - - - message: '#^Method Ibexa\\User\\UserSetting\\Group\\AbstractGroup\:\:__construct\(\) has parameter \$values with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/UserSetting/Group/AbstractGroup.php - - - - message: '#^Method Ibexa\\User\\UserSetting\\Group\\BrowsingGroup\:\:__construct\(\) has parameter \$values with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/UserSetting/Group/BrowsingGroup.php - - - - message: '#^Method Ibexa\\User\\UserSetting\\Group\\CustomGroup\:\:__construct\(\) has parameter \$values with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/UserSetting/Group/CustomGroup.php - - - - message: '#^Method Ibexa\\User\\UserSetting\\Group\\EditContentGroup\:\:__construct\(\) has parameter \$values with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/UserSetting/Group/EditContentGroup.php - - - - message: '#^Method Ibexa\\User\\UserSetting\\Group\\LocationGroup\:\:__construct\(\) has parameter \$values with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/UserSetting/Group/LocationGroup.php - - message: '#^Cannot call method getDateFormat\(\) on Ibexa\\User\\UserSetting\\Setting\\Value\\DateTimeFormat\|null\.$#' identifier: method.nonObject @@ -750,18 +390,6 @@ parameters: count: 1 path: src/lib/UserSetting/Setting/AbstractDateTimeFormat.php - - - message: '#^PHPDoc tag @var for property Ibexa\\User\\UserSetting\\Setting\\AbstractDateTimeFormat\:\:\$formatter with type Ibexa\\User\\UserSetting\\DateTimeFormat\\Formatter\|null is not subtype of native type Ibexa\\User\\UserSetting\\DateTimeFormat\\FormatterInterface\.$#' - identifier: property.phpDocType - count: 1 - path: src/lib/UserSetting/Setting/AbstractDateTimeFormat.php - - - - message: '#^Property Ibexa\\User\\UserSetting\\Setting\\AbstractDateTimeFormat\:\:\$formatter \(Ibexa\\User\\UserSetting\\DateTimeFormat\\Formatter\) does not accept Ibexa\\User\\UserSetting\\DateTimeFormat\\FormatterInterface\.$#' - identifier: assign.propertyType - count: 1 - path: src/lib/UserSetting/Setting/AbstractDateTimeFormat.php - - message: '#^Method Ibexa\\User\\UserSetting\\Setting\\CharacterCounter\:\:mapFieldForm\(\) has parameter \$formBuilder with generic interface Symfony\\Component\\Form\\FormBuilderInterface but does not specify its types\: TData$#' identifier: missingType.generics @@ -864,84 +492,12 @@ parameters: count: 1 path: src/lib/UserSetting/UserSettingArrayAccessor.php - - - message: '#^Method Ibexa\\User\\UserSetting\\UserSettingGroup\:\:__construct\(\) has parameter \$settings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/UserSetting/UserSettingGroup.php - - - - message: '#^Method Ibexa\\User\\UserSetting\\UserSettingGroup\:\:getSettings\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/UserSetting/UserSettingGroup.php - - - - message: '#^Method Ibexa\\User\\UserSetting\\UserSettingService\:\:createUserSettingsGroup\(\) has parameter \$userPreferences with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/UserSetting/UserSettingService.php - - - - message: '#^Method Ibexa\\User\\UserSetting\\UserSettingService\:\:loadGroupedUserSettings\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/UserSetting/UserSettingService.php - - - - message: '#^Method Ibexa\\User\\UserSetting\\UserSettingService\:\:loadUserSettings\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/UserSetting/UserSettingService.php - - message: '#^Class Ibexa\\User\\UserSetting\\ValueDefinitionGroupRegistryEntry implements generic interface IteratorAggregate but does not specify its types\: TKey, TValue$#' identifier: missingType.generics count: 1 path: src/lib/UserSetting/ValueDefinitionGroupRegistryEntry.php - - - message: '#^Method Ibexa\\User\\UserSetting\\ValueDefinitionGroupRegistryEntry\:\:__construct\(\) has parameter \$valueDefinitions with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/UserSetting/ValueDefinitionGroupRegistryEntry.php - - - - message: '#^Method Ibexa\\User\\UserSetting\\ValueDefinitionGroupRegistryEntry\:\:getValueDefinitions\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/UserSetting/ValueDefinitionGroupRegistryEntry.php - - - - message: '#^Property Ibexa\\User\\UserSetting\\ValueDefinitionGroupRegistryEntry\:\:\$valueDefinitions type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/UserSetting/ValueDefinitionGroupRegistryEntry.php - - - - message: '#^Method Ibexa\\User\\UserSetting\\ValueDefinitionRegistry\:\:__construct\(\) has parameter \$valueDefinitions with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/UserSetting/ValueDefinitionRegistry.php - - - - message: '#^Method Ibexa\\User\\UserSetting\\ValueDefinitionRegistry\:\:getValueDefinitionGroups\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/UserSetting/ValueDefinitionRegistry.php - - - - message: '#^PHPDoc tag @param references unknown parameter\: \$priority$#' - identifier: parameter.notFound - count: 1 - path: src/lib/UserSetting/ValueDefinitionRegistry.php - - - - message: '#^Property Ibexa\\User\\UserSetting\\ValueDefinitionRegistry\:\:\$groupedDefinitions \(array\\) does not accept array\\.$#' - identifier: assign.propertyType - count: 1 - path: src/lib/UserSetting/ValueDefinitionRegistry.php - - message: '#^Access to an undefined property Symfony\\Component\\Validator\\Constraint\:\:\$message\.$#' identifier: property.notFound @@ -954,12 +510,6 @@ parameters: count: 1 path: src/lib/Validator/Constraints/Password.php - - - message: '#^Property Ibexa\\User\\Validator\\Constraints\\UserPassword\:\:\$message has no type specified\.$#' - identifier: missingType.property - count: 1 - path: src/lib/Validator/Constraints/UserPassword.php - - message: '#^Access to an undefined property Symfony\\Component\\Validator\\Constraint\:\:\$message\.$#' identifier: property.notFound @@ -978,12 +528,6 @@ parameters: count: 1 path: src/lib/Validator/Constraints/UserPasswordValidator.php - - - message: '#^Strict comparison using \=\=\= between null and string will always evaluate to false\.$#' - identifier: identical.alwaysFalse - count: 1 - path: src/lib/Validator/Constraints/UserPasswordValidator.php - - message: '#^Method Ibexa\\User\\View\\UserSettings\\UpdateView\:\:getInternalParameters\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -996,18 +540,6 @@ parameters: count: 1 path: src/lib/View/UserSettings/UpdateViewBuilder.php - - - message: '#^Method Ibexa\\User\\View\\UserSettings\\UpdateViewProvider\:\:buildUpdateSettingView\(\) has parameter \$viewConfig with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/View/UserSettings/UpdateViewProvider.php - - - - message: '#^Method Ibexa\\User\\View\\UserSettings\\UpdateViewProvider\:\:getView\(\) should return Ibexa\\Core\\MVC\\Symfony\\View\\View but returns null\.$#' - identifier: return.type - count: 1 - path: src/lib/View/UserSettings/UpdateViewProvider.php - - message: '#^Parameter \#1 \$kernel of class Symfony\\Bundle\\FrameworkBundle\\Console\\Application constructor expects Symfony\\Component\\HttpKernel\\KernelInterface, Symfony\\Component\\HttpKernel\\KernelInterface\|null given\.$#' identifier: argument.type @@ -1038,60 +570,6 @@ parameters: count: 1 path: tests/integration/Invitation/InvitationServiceTest.php - - - message: '#^Method Ibexa\\Tests\\User\\Form\\Type\\ChoiceList\\Loader\\AvailableLocaleChoiceLoaderTest\:\:providerForGetChoiceList\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/lib/Form/Type/ChoiceList/Loader/AvailableLocaleChoiceLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\User\\Form\\Type\\ChoiceList\\Loader\\AvailableLocaleChoiceLoaderTest\:\:testGetChoiceList\(\) has parameter \$additionalTranslations with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/lib/Form/Type/ChoiceList/Loader/AvailableLocaleChoiceLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\User\\Form\\Type\\ChoiceList\\Loader\\AvailableLocaleChoiceLoaderTest\:\:testGetChoiceList\(\) has parameter \$availableTranslations with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/lib/Form/Type/ChoiceList/Loader/AvailableLocaleChoiceLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\User\\Form\\Type\\ChoiceList\\Loader\\AvailableLocaleChoiceLoaderTest\:\:testGetChoiceList\(\) has parameter \$expectedLocales with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/lib/Form/Type/ChoiceList/Loader/AvailableLocaleChoiceLoaderTest.php - - - - message: '#^Method Ibexa\\Tests\\User\\Invitation\\InvitationServiceTest\:\:invitationProvider\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/lib/Invitation/InvitationServiceTest.php - - - - message: '#^Method Ibexa\\Tests\\User\\Permission\\UserPermissionsLimitationTypeTest\:\:providerForTestAcceptValue\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/lib/Permission/UserPermissionsLimitationTypeTest.php - - - - message: '#^Method Ibexa\\Tests\\User\\Permission\\UserPermissionsLimitationTypeTest\:\:providerForTestAcceptValueException\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/lib/Permission/UserPermissionsLimitationTypeTest.php - - - - message: '#^Method Ibexa\\Tests\\User\\Permission\\UserPermissionsLimitationTypeTest\:\:providerForTestEvaluate\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/lib/Permission/UserPermissionsLimitationTypeTest.php - - - - message: '#^Method Ibexa\\Tests\\User\\Permission\\UserPermissionsLimitationTypeTest\:\:providerForTestValidateError\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/lib/Permission/UserPermissionsLimitationTypeTest.php - - message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\User\\\\PasswordValidationContext'' and Ibexa\\Contracts\\Core\\Repository\\Values\\User\\PasswordValidationContext will always evaluate to true\.$#' identifier: method.alreadyNarrowedType @@ -1103,21 +581,3 @@ parameters: identifier: staticMethod.alreadyNarrowedType count: 1 path: tests/lib/Validator/Constraint/PasswordValidatorTest.php - - - - message: '#^Method Ibexa\\Tests\\User\\Validator\\Constraint\\PasswordValidatorTest\:\:dataProviderForValidateNotSupportedValueType\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/lib/Validator/Constraint/PasswordValidatorTest.php - - - - message: '#^Method Ibexa\\Tests\\User\\Validator\\Constraint\\UserPasswordValidatorTest\:\:emptyDataProvider\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/lib/Validator/Constraint/UserPasswordValidatorTest.php - - - - message: '#^Parameter \#1 \$password of method Ibexa\\User\\Validator\\Constraints\\UserPasswordValidator\:\:validate\(\) expects string, string\|null given\.$#' - identifier: argument.type - count: 1 - path: tests/lib/Validator/Constraint/UserPasswordValidatorTest.php diff --git a/src/bundle/Command/AuditUserDatabaseCommand.php b/src/bundle/Command/AuditUserDatabaseCommand.php index 670fad62..58c93c08 100644 --- a/src/bundle/Command/AuditUserDatabaseCommand.php +++ b/src/bundle/Command/AuditUserDatabaseCommand.php @@ -19,26 +19,17 @@ final class AuditUserDatabaseCommand extends Command { - private ContentTypeService $contentTypeService; - - private UserService $userService; - - private Connection $connection; - public function __construct( - ContentTypeService $contentTypeService, - UserService $userService, - Connection $connection + private readonly ContentTypeService $contentTypeService, + private readonly UserService $userService, + private readonly Connection $connection ) { parent::__construct('ibexa:user:audit-database'); - - $this->contentTypeService = $contentTypeService; - $this->userService = $userService; - $this->connection = $connection; } /** * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException + * @throws \Doctrine\DBAL\Exception */ public function execute( InputInterface $input, @@ -96,7 +87,7 @@ public function execute( foreach ($logins as $record) { $login = $record['login']; - if (!preg_match(sprintf('/%s/', $pattern), $login)) { + if (!preg_match(sprintf('/%s/', $pattern), (string) $login)) { $output->writeln(sprintf(' - Login %s does not match', $login)); } } @@ -109,7 +100,7 @@ public function execute( } /** - * @return \Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition[] + * @return list<\Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition> */ private function getUserFieldDefinitions(): array { @@ -130,6 +121,9 @@ private function getUserFieldDefinitions(): array return $userFieldDefinitions; } + /** + * @param list<\Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition> $userFieldDefinitions + */ private function isUniqueEmailRequired(array $userFieldDefinitions): bool { foreach ($userFieldDefinitions as $userFieldDefinition) { diff --git a/src/bundle/Command/UpdateUserCommand.php b/src/bundle/Command/UpdateUserCommand.php index 533b70a9..e1e723d9 100644 --- a/src/bundle/Command/UpdateUserCommand.php +++ b/src/bundle/Command/UpdateUserCommand.php @@ -111,9 +111,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $userUpdateStruct->enabled = $this->resolveEnabledFlag($enable, $disable); $this->repository->sudo( - function () use ($user, $userUpdateStruct): User { - return $this->userService->updateUser($user, $userUpdateStruct); - } + fn (): User => $this->userService->updateUser($user, $userUpdateStruct) ); $io->success(sprintf( diff --git a/src/bundle/Controller/DefaultProfileImageController.php b/src/bundle/Controller/DefaultProfileImageController.php index d508efec..4a2835b1 100644 --- a/src/bundle/Controller/DefaultProfileImageController.php +++ b/src/bundle/Controller/DefaultProfileImageController.php @@ -14,12 +14,9 @@ final class DefaultProfileImageController extends Controller { - private ConfigResolverInterface $configResolver; - public function __construct( - ConfigResolverInterface $configResolver + private readonly ConfigResolverInterface $configResolver ) { - $this->configResolver = $configResolver; } public function initialsAction(Request $request): Response @@ -38,6 +35,9 @@ public function initialsAction(Request $request): Response ], $response); } + /** + * @return array{text: string, background: string} + */ private function getInitialsColors(string $initials): array { $colors = $this->configResolver->getParameter('user.default_profile_image.colors'); diff --git a/src/bundle/Controller/PasswordChangeController.php b/src/bundle/Controller/PasswordChangeController.php index 8e2a54c5..b24853c1 100644 --- a/src/bundle/Controller/PasswordChangeController.php +++ b/src/bundle/Controller/PasswordChangeController.php @@ -26,35 +26,19 @@ final class PasswordChangeController extends Controller implements RestrictedCon { use AuthenticatedRememberedCheckTrait; - private ActionResultHandler $actionResultHandler; - - private UserService $userService; - - private FormFactory $formFactory; - - private TokenStorageInterface $tokenStorage; - - private array $siteAccessGroups; - + /** + * @param array> $siteAccessGroups + */ public function __construct( - ActionResultHandler $actionResultHandler, - UserService $userService, - FormFactory $formFactory, - TokenStorageInterface $tokenStorage, - array $siteAccessGroups + private ActionResultHandler $actionResultHandler, + private UserService $userService, + private FormFactory $formFactory, + private TokenStorageInterface $tokenStorage, + private array $siteAccessGroups ) { - $this->actionResultHandler = $actionResultHandler; - $this->userService = $userService; - $this->formFactory = $formFactory; - $this->tokenStorage = $tokenStorage; - $this->siteAccessGroups = $siteAccessGroups; } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Ibexa\User\View\ChangePassword\FormView|\Ibexa\User\View\ChangePassword\SuccessView|\Symfony\Component\HttpFoundation\RedirectResponse - * * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentType */ public function userPasswordChangeAction(Request $request): RedirectResponse|SuccessView|FormView diff --git a/src/bundle/Controller/PasswordResetController.php b/src/bundle/Controller/PasswordResetController.php index 4bc95c77..c55ca6ff 100644 --- a/src/bundle/Controller/PasswordResetController.php +++ b/src/bundle/Controller/PasswordResetController.php @@ -39,42 +39,20 @@ class PasswordResetController extends Controller { - private FormFactory $formFactory; - - private UserService $userService; - - private Environment $twig; - - private ActionResultHandler $actionResultHandler; - - private PermissionResolver $permissionResolver; - - private ConfigResolverInterface $configResolver; - - private NotificationServiceInterface $notificationService; - public function __construct( - FormFactory $formFactory, - UserService $userService, - Environment $twig, - ActionResultHandler $actionResultHandler, - PermissionResolver $permissionResolver, - ConfigResolverInterface $configResolver, - NotificationServiceInterface $notificationService + private readonly FormFactory $formFactory, + private readonly UserService $userService, + private readonly Environment $twig, + private readonly ActionResultHandler $actionResultHandler, + private readonly PermissionResolver $permissionResolver, + private readonly ConfigResolverInterface $configResolver, + private readonly NotificationServiceInterface $notificationService ) { - $this->formFactory = $formFactory; - $this->userService = $userService; - $this->twig = $twig; - $this->actionResultHandler = $actionResultHandler; - $this->permissionResolver = $permissionResolver; - $this->configResolver = $configResolver; - $this->notificationService = $notificationService; } /** - * @return \Ibexa\User\View\ForgotPassword\FormView|\Ibexa\User\View\ForgotPassword\SuccessView|\Symfony\Component\HttpFoundation\RedirectResponse - * * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentType + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ public function userForgotPasswordAction(Request $request, ?string $reason = null): RedirectResponse|SuccessView|FormView { @@ -108,11 +86,8 @@ public function userForgotPasswordAction(Request $request, ?string $reason = nul } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Ibexa\User\View\ForgotPassword\LoginView|\Ibexa\User\View\ForgotPassword\SuccessView - * * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentType + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ public function userForgotPasswordLoginAction(Request $request): SuccessView|LoginView { @@ -125,7 +100,7 @@ public function userForgotPasswordLoginAction(Request $request): SuccessView|Log try { $user = $this->userService->loadUserByLogin($data->getLogin()); - } catch (NotFoundException $e) { + } catch (NotFoundException) { $user = null; } @@ -145,11 +120,6 @@ public function userForgotPasswordLoginAction(Request $request): SuccessView|Log } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param string $hashKey - * - * @return \Ibexa\User\View\ResetPassword\FormView|\Ibexa\User\View\ResetPassword\InvalidLinkView|\Ibexa\User\View\ResetPassword\SuccessView - * * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentType */ public function userResetPasswordAction(Request $request, string $hashKey): InvalidLinkView|UserResetPasswordSuccessView|UserResetPasswordFormView @@ -210,10 +180,6 @@ public function userResetPasswordAction(Request $request, string $hashKey): Inva } /** - * @param \Ibexa\Contracts\Core\Repository\Values\User\User $user - * - * @return string - * * @throws \Exception */ private function updateUserToken(User $user): string diff --git a/src/bundle/Controller/UserInvitationController.php b/src/bundle/Controller/UserInvitationController.php index 396ed267..29a060bb 100644 --- a/src/bundle/Controller/UserInvitationController.php +++ b/src/bundle/Controller/UserInvitationController.php @@ -26,26 +26,21 @@ final class UserInvitationController extends Controller implements RestrictedCon { use AuthenticatedRememberedCheckTrait; - private InvitationService $invitationService; - - private InvitationSender $mailSender; - - private FormFactoryInterface $formFactory; - - private ActionResultHandler $actionResultHandler; - public function __construct( - InvitationService $invitationService, - InvitationSender $mailSender, - FormFactoryInterface $formFactory, - ActionResultHandler $actionResultHandler + private InvitationService $invitationService, + private InvitationSender $mailSender, + private FormFactoryInterface $formFactory, + private ActionResultHandler $actionResultHandler ) { - $this->invitationService = $invitationService; - $this->mailSender = $mailSender; - $this->formFactory = $formFactory; - $this->actionResultHandler = $actionResultHandler; } + /** + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException + * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentType + * @throws \JsonException + */ public function inviteUser(Request $request): FormView { $form = $this->formFactory->create(UserInvitationType::class); @@ -73,14 +68,14 @@ public function inviteUser(Request $request): FormView ['%email%' => $data->getEmail()], 'ibexa_user_invitation' ); - } catch (InvitationAlreadyExistsException $e) { + } catch (InvitationAlreadyExistsException) { $this->actionResultHandler->error( /** @Desc("Invitation for '%email%' already exists.") */ 'user_invitation.send.invitation_exist', ['%email%' => $data->getEmail()], 'ibexa_user_invitation' ); - } catch (UserAlreadyExistsException $e) { + } catch (UserAlreadyExistsException) { $this->actionResultHandler->error( /** @Desc("User with '%email%' already exists.") */ 'user_invitation.send.user_exist', diff --git a/src/bundle/Controller/UserRegisterController.php b/src/bundle/Controller/UserRegisterController.php index c698fcdb..7e29d0bb 100644 --- a/src/bundle/Controller/UserRegisterController.php +++ b/src/bundle/Controller/UserRegisterController.php @@ -16,34 +16,22 @@ use Ibexa\User\View\Register\ConfirmView; use Ibexa\User\View\Register\FormView; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; class UserRegisterController extends Controller { - private UserRegisterMapper $userRegisterMapper; - - private ActionDispatcherInterface $userActionDispatcher; - - private InvitationService $invitationService; - public function __construct( - UserRegisterMapper $userRegisterMapper, - ActionDispatcherInterface $userActionDispatcher, - InvitationService $invitationService + private readonly UserRegisterMapper $userRegisterMapper, + private readonly ActionDispatcherInterface $userActionDispatcher, + private readonly InvitationService $invitationService ) { - $this->userRegisterMapper = $userRegisterMapper; - $this->userActionDispatcher = $userActionDispatcher; - $this->invitationService = $invitationService; } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Ibexa\User\View\Register\FormView|\Symfony\Component\HttpFoundation\Response|null - * * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentType */ - public function registerAction(Request $request) + public function registerAction(Request $request): Response|FormView { if (!$this->isGranted(new Attribute('user', 'register'))) { throw new UnauthorizedHttpException('You are not allowed to register a new account'); @@ -70,20 +58,12 @@ public function registerAction(Request $request) return new FormView(null, ['form' => $form->createView()]); } - /** - * @return \Ibexa\User\View\Register\ConfirmView - * - * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentType - */ public function registerConfirmAction(): ConfirmView { return new ConfirmView(); } - /** - * @return \Ibexa\User\View\Register\FormView|\Symfony\Component\HttpFoundation\Response - */ - public function registerFromInvitationAction(Request $request) + public function registerFromInvitationAction(Request $request): Response|FormView { $invitation = $this->invitationService->getInvitation($request->get('inviteHash')); diff --git a/src/bundle/Controller/UserSettingsController.php b/src/bundle/Controller/UserSettingsController.php index d4907746..64835434 100644 --- a/src/bundle/Controller/UserSettingsController.php +++ b/src/bundle/Controller/UserSettingsController.php @@ -30,39 +30,19 @@ final class UserSettingsController extends Controller implements RestrictedContr { use AuthenticatedRememberedCheckTrait; - private FormFactory $formFactory; - - private SubmitHandler $submitHandler; - - private UserSettingService $userSettingService; - - private ValueDefinitionRegistry $valueDefinitionRegistry; - - private ActionResultHandler $actionResultHandler; - - private PermissionResolver $permissionResolver; - public function __construct( - FormFactory $formFactory, - SubmitHandler $submitHandler, - UserSettingService $userSettingService, - ValueDefinitionRegistry $valueDefinitionRegistry, - ActionResultHandler $actionResultHandler, - PermissionResolver $permissionResolver + private readonly FormFactory $formFactory, + private readonly SubmitHandler $submitHandler, + private readonly UserSettingService $userSettingService, + private readonly ValueDefinitionRegistry $valueDefinitionRegistry, + private readonly ActionResultHandler $actionResultHandler, + private readonly PermissionResolver $permissionResolver ) { - $this->formFactory = $formFactory; - $this->submitHandler = $submitHandler; - $this->userSettingService = $userSettingService; - $this->valueDefinitionRegistry = $valueDefinitionRegistry; - $this->actionResultHandler = $actionResultHandler; - $this->permissionResolver = $permissionResolver; } /** - * @param int $page - * - * @return \Ibexa\User\View\UserSettings\ListView - * + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentType */ public function listAction(int $page = 1): ListView diff --git a/src/bundle/DependencyInjection/Compiler/UserSetting/FormMapperPass.php b/src/bundle/DependencyInjection/Compiler/UserSetting/FormMapperPass.php index ff4ab20b..8bc29440 100644 --- a/src/bundle/DependencyInjection/Compiler/UserSetting/FormMapperPass.php +++ b/src/bundle/DependencyInjection/Compiler/UserSetting/FormMapperPass.php @@ -16,14 +16,12 @@ class FormMapperPass implements CompilerPassInterface { - public const TAG_NAME = 'ibexa.user.setting.mapper.form'; + public const string TAG_NAME = 'ibexa.user.setting.mapper.form'; /** - * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container - * * @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException * @throws \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException - * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentException; + * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentException */ public function process(ContainerBuilder $container): void { diff --git a/src/bundle/DependencyInjection/Compiler/UserSetting/ValueDefinitionPass.php b/src/bundle/DependencyInjection/Compiler/UserSetting/ValueDefinitionPass.php index cf932231..19db1ee7 100644 --- a/src/bundle/DependencyInjection/Compiler/UserSetting/ValueDefinitionPass.php +++ b/src/bundle/DependencyInjection/Compiler/UserSetting/ValueDefinitionPass.php @@ -19,12 +19,10 @@ class ValueDefinitionPass implements CompilerPassInterface { use PriorityTaggedServiceTrait; - public const TAG_NAME = 'ibexa.user.setting.value'; - public const GROUP_TAG_NAME = 'ibexa.user.setting.group'; + public const string TAG_NAME = 'ibexa.user.setting.value'; + public const string GROUP_TAG_NAME = 'ibexa.user.setting.group'; /** - * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container - * * @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException * @throws \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentException diff --git a/src/bundle/DependencyInjection/Configuration/Parser/ChangePassword.php b/src/bundle/DependencyInjection/Configuration/Parser/ChangePassword.php index 8de76450..df63d2af 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/ChangePassword.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/ChangePassword.php @@ -40,6 +40,10 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void ->end(); } + /** + * @param array $scopeSettings + * @param string $currentScope + */ public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void { if (empty($scopeSettings['user_change_password'])) { diff --git a/src/bundle/DependencyInjection/Configuration/Parser/ForgotPassword.php b/src/bundle/DependencyInjection/Configuration/Parser/ForgotPassword.php index ebf7446a..c52ad463 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/ForgotPassword.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/ForgotPassword.php @@ -60,6 +60,10 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void ; } + /** + * @param array $scopeSettings + * @param string $currentScope + */ public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void { if (!empty($scopeSettings['user_forgot_password'])) { diff --git a/src/bundle/DependencyInjection/Configuration/Parser/Pagination.php b/src/bundle/DependencyInjection/Configuration/Parser/Pagination.php index 91560fa1..2b3caedd 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/Pagination.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/Pagination.php @@ -38,7 +38,8 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void } /** - * {@inheritdoc} + * @param array $scopeSettings + * @param string $currentScope */ public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void { diff --git a/src/bundle/DependencyInjection/Configuration/Parser/ResetPassword.php b/src/bundle/DependencyInjection/Configuration/Parser/ResetPassword.php index c4648821..9d7b864e 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/ResetPassword.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/ResetPassword.php @@ -39,6 +39,10 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void ; } + /** + * @param array $scopeSettings + * @param string $currentScope + */ public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void { if (empty($scopeSettings['user_reset_password'])) { diff --git a/src/bundle/DependencyInjection/Configuration/Parser/Security.php b/src/bundle/DependencyInjection/Configuration/Parser/Security.php index b13f71a9..9af05f70 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/Security.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/Security.php @@ -37,7 +37,8 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void } /** - * {@inheritdoc} + * @param array $scopeSettings + * @param string $currentScope */ public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void { diff --git a/src/bundle/DependencyInjection/Configuration/Parser/UserInvitation.php b/src/bundle/DependencyInjection/Configuration/Parser/UserInvitation.php index aa59c652..10418fba 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/UserInvitation.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/UserInvitation.php @@ -55,6 +55,10 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void ->end(); } + /** + * @param array $scopeSettings + * @param string $currentScope + */ public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void { if (empty($scopeSettings['user_invitation'])) { diff --git a/src/bundle/DependencyInjection/Configuration/Parser/UserPreferences.php b/src/bundle/DependencyInjection/Configuration/Parser/UserPreferences.php index 7bd512b6..d8fd1993 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/UserPreferences.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/UserPreferences.php @@ -44,9 +44,6 @@ */ class UserPreferences extends AbstractParser { - /** - * {@inheritdoc} - */ public function addSemanticConfig(NodeBuilder $nodeBuilder): void { $nodeBuilder @@ -107,7 +104,8 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void } /** - * {@inheritdoc} + * @param array $scopeSettings + * @param string $currentScope */ public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void { diff --git a/src/bundle/DependencyInjection/Configuration/Parser/UserRegistration.php b/src/bundle/DependencyInjection/Configuration/Parser/UserRegistration.php index 92055f13..2df60ab6 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/UserRegistration.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/UserRegistration.php @@ -57,6 +57,10 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void ->end(); } + /** + * @param array $scopeSettings + * @param string $currentScope + */ public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void { if (empty($scopeSettings['user_registration'])) { diff --git a/src/bundle/DependencyInjection/Configuration/Parser/UserSettingsUpdateView.php b/src/bundle/DependencyInjection/Configuration/Parser/UserSettingsUpdateView.php index 8393cd5a..488a648d 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/UserSettingsUpdateView.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/UserSettingsUpdateView.php @@ -12,6 +12,6 @@ class UserSettingsUpdateView extends View { - public const NODE_KEY = 'user_settings_update_view'; - public const INFO = 'Template selection settings when displaying a user setting update form'; + public const string NODE_KEY = 'user_settings_update_view'; + public const string INFO = 'Template selection settings when displaying a user setting update form'; } diff --git a/src/bundle/DependencyInjection/IbexaUserExtension.php b/src/bundle/DependencyInjection/IbexaUserExtension.php index 8e543553..0e9b058d 100644 --- a/src/bundle/DependencyInjection/IbexaUserExtension.php +++ b/src/bundle/DependencyInjection/IbexaUserExtension.php @@ -39,9 +39,6 @@ public function prepend(ContainerBuilder $container): void $this->prependJMSTranslation($container); } - /** - * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container - */ public function prependJMSTranslation(ContainerBuilder $container): void { $container->prependExtensionConfig('jms_translation', [ diff --git a/src/bundle/IbexaUserBundle.php b/src/bundle/IbexaUserBundle.php index 4e92ddd2..4b93c8b7 100644 --- a/src/bundle/IbexaUserBundle.php +++ b/src/bundle/IbexaUserBundle.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\Bundle\User; diff --git a/src/bundle/Security/Authentication/DefaultAuthenticationFailureHandler.php b/src/bundle/Security/Authentication/DefaultAuthenticationFailureHandler.php index ee0b03be..c34b7439 100644 --- a/src/bundle/Security/Authentication/DefaultAuthenticationFailureHandler.php +++ b/src/bundle/Security/Authentication/DefaultAuthenticationFailureHandler.php @@ -16,6 +16,7 @@ final class DefaultAuthenticationFailureHandler extends HttpDefaultAuthenticationFailureHandler { + #[\Override] public function onAuthenticationFailure(Request $request, AuthenticationException $exception): Response { if ($exception instanceof PasswordInUnsupportedFormatException) { diff --git a/src/bundle/Twig/UserExtension.php b/src/bundle/Twig/UserExtension.php index f463f6eb..666bbd55 100644 --- a/src/bundle/Twig/UserExtension.php +++ b/src/bundle/Twig/UserExtension.php @@ -14,6 +14,7 @@ final class UserExtension extends AbstractExtension { + #[\Override] public function getFunctions(): array { return [ diff --git a/src/bundle/Twig/UserRuntime.php b/src/bundle/Twig/UserRuntime.php index ed6e007b..9c010208 100644 --- a/src/bundle/Twig/UserRuntime.php +++ b/src/bundle/Twig/UserRuntime.php @@ -13,18 +13,12 @@ use Ibexa\Contracts\Core\Repository\Values\User\User; use Twig\Extension\RuntimeExtensionInterface; -final class UserRuntime implements RuntimeExtensionInterface +final readonly class UserRuntime implements RuntimeExtensionInterface { - private PermissionResolver $permissionResolver; - - private UserService $userService; - public function __construct( - PermissionResolver $permissionResolver, - UserService $userService + private PermissionResolver $permissionResolver, + private UserService $userService ) { - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; } public function getCurrentUser(): User diff --git a/src/bundle/Type/UserForgotPasswordReason.php b/src/bundle/Type/UserForgotPasswordReason.php index 8fe45336..59605872 100644 --- a/src/bundle/Type/UserForgotPasswordReason.php +++ b/src/bundle/Type/UserForgotPasswordReason.php @@ -10,5 +10,5 @@ class UserForgotPasswordReason { - public const MIGRATION = 'migration'; + public const string MIGRATION = 'migration'; } diff --git a/src/contracts/Invitation/Invitation.php b/src/contracts/Invitation/Invitation.php index ffa46509..145e1527 100644 --- a/src/contracts/Invitation/Invitation.php +++ b/src/contracts/Invitation/Invitation.php @@ -16,42 +16,17 @@ final class Invitation extends ValueObject { - private string $email; - - private string $hash; - - private DateTimeInterface $createdAt; - - private string $siteAccessIdentifier; - - private bool $used; - - private ?Role $role; - - private ?UserGroup $userGroup; - - private ?RoleLimitation $limitation; - public function __construct( - string $email, - string $hash, - DateTimeInterface $createdAt, - string $siteAccessIdentifier, - bool $used, - ?Role $role = null, - ?UserGroup $userGroup = null, - ?RoleLimitation $limitation = null + private readonly string $email, + private readonly string $hash, + private readonly DateTimeInterface $createdAt, + private readonly string $siteAccessIdentifier, + private readonly bool $used, + private readonly ?Role $role = null, + private readonly ?UserGroup $userGroup = null, + private readonly ?RoleLimitation $limitation = null ) { parent::__construct(); - - $this->email = $email; - $this->hash = $hash; - $this->createdAt = $createdAt; - $this->siteAccessIdentifier = $siteAccessIdentifier; - $this->used = $used; - $this->role = $role; - $this->userGroup = $userGroup; - $this->limitation = $limitation; } public function getEmail(): string diff --git a/src/contracts/Invitation/InvitationCreateStruct.php b/src/contracts/Invitation/InvitationCreateStruct.php index 082ae360..65e6e535 100644 --- a/src/contracts/Invitation/InvitationCreateStruct.php +++ b/src/contracts/Invitation/InvitationCreateStruct.php @@ -15,30 +15,14 @@ final class InvitationCreateStruct extends ValueObject { - private string $email; - - private string $siteAccessIdentifier; - - private ?UserGroup $userGroup; - - private ?Role $role; - - private ?RoleLimitation $roleLimitation; - public function __construct( - string $email, - string $siteAccessIdentifier, - ?UserGroup $userGroup = null, - ?Role $role = null, - ?RoleLimitation $roleLimitation = null + private readonly string $email, + private readonly string $siteAccessIdentifier, + private readonly ?UserGroup $userGroup = null, + private readonly ?Role $role = null, + private readonly ?RoleLimitation $roleLimitation = null ) { parent::__construct(); - - $this->email = $email; - $this->siteAccessIdentifier = $siteAccessIdentifier; - $this->userGroup = $userGroup; - $this->role = $role; - $this->roleLimitation = $roleLimitation; } public function getEmail(): string diff --git a/src/contracts/Invitation/Persistence/Gateway.php b/src/contracts/Invitation/Persistence/Gateway.php index 16b1294a..c60d3eec 100644 --- a/src/contracts/Invitation/Persistence/Gateway.php +++ b/src/contracts/Invitation/Persistence/Gateway.php @@ -38,7 +38,10 @@ public function addInvitation( ?string $limitationValue = null ): array; - public function getInvitation(string $hash); + /** + * @return array + */ + public function getInvitation(string $hash): array; public function invitationExistsForEmail(string $email): bool; diff --git a/src/contracts/Invitation/Persistence/Invitation.php b/src/contracts/Invitation/Persistence/Invitation.php index 192a7f5d..0859b146 100644 --- a/src/contracts/Invitation/Persistence/Invitation.php +++ b/src/contracts/Invitation/Persistence/Invitation.php @@ -12,46 +12,21 @@ final class Invitation extends ValueObject { - private string $email; - - private string $hash; - - private string $siteAccessIdentifier; - - private int $createdAtTimestamp; - - private bool $isUsed; - - private ?int $roleId; - - private ?int $groupId; - - private ?string $limitation; - - private ?array $limitationValue; - + /** + * @param array|null $limitationValue + */ public function __construct( - string $email, - string $hash, - string $siteAccessIdentifier, - int $createdAtTimestamp, - bool $isUsed, - ?int $roleId = null, - ?int $groupId = null, - ?string $limitation = null, - ?array $limitationValue = null + private readonly string $email, + private readonly string $hash, + private readonly string $siteAccessIdentifier, + private readonly int $createdAtTimestamp, + private readonly bool $isUsed, + private readonly ?int $roleId = null, + private readonly ?int $groupId = null, + private readonly ?string $limitation = null, + private readonly ?array $limitationValue = null ) { parent::__construct(); - - $this->email = $email; - $this->hash = $hash; - $this->siteAccessIdentifier = $siteAccessIdentifier; - $this->createdAtTimestamp = $createdAtTimestamp; - $this->isUsed = $isUsed; - $this->roleId = $roleId; - $this->groupId = $groupId; - $this->limitation = $limitation; - $this->limitationValue = $limitationValue; } public function getEmail(): string @@ -94,6 +69,9 @@ public function getLimitation(): ?string return $this->limitation; } + /** + * @return array|null + */ public function getLimitationValue(): ?array { return $this->limitationValue; diff --git a/src/contracts/Invitation/Persistence/InvitationUpdateStruct.php b/src/contracts/Invitation/Persistence/InvitationUpdateStruct.php index 5da83f1a..81ec93a0 100644 --- a/src/contracts/Invitation/Persistence/InvitationUpdateStruct.php +++ b/src/contracts/Invitation/Persistence/InvitationUpdateStruct.php @@ -12,22 +12,12 @@ final class InvitationUpdateStruct extends ValueObject { - private ?int $createdAt; - - private ?bool $isUsed; - - private ?string $hash; - public function __construct( - ?int $createdAt = null, - ?bool $isUsed = null, - ?string $hash = null + private ?int $createdAt = null, + private ?bool $isUsed = null, + private ?string $hash = null ) { parent::__construct(); - - $this->createdAt = $createdAt; - $this->isUsed = $isUsed; - $this->hash = $hash; } public function getCreatedAt(): ?int diff --git a/src/contracts/Invitation/Persistence/Mapper.php b/src/contracts/Invitation/Persistence/Mapper.php index ad9d8f6d..e547525a 100644 --- a/src/contracts/Invitation/Persistence/Mapper.php +++ b/src/contracts/Invitation/Persistence/Mapper.php @@ -10,5 +10,8 @@ interface Mapper { + /** + * @param array $row + */ public function extractInvitationFromRow(array $row): Invitation; } diff --git a/src/contracts/Invitation/Query/InvitationFilter.php b/src/contracts/Invitation/Query/InvitationFilter.php index 73228a32..e0efc194 100644 --- a/src/contracts/Invitation/Query/InvitationFilter.php +++ b/src/contracts/Invitation/Query/InvitationFilter.php @@ -13,20 +13,11 @@ final class InvitationFilter { - private ?Role $role; - - private ?UserGroup $userGroup; - - private ?bool $isUsed; - public function __construct( - ?Role $role = null, - ?UserGroup $userGroup = null, - ?bool $isUsed = null + private ?Role $role = null, + private ?UserGroup $userGroup = null, + private ?bool $isUsed = null ) { - $this->role = $role; - $this->userGroup = $userGroup; - $this->isUsed = $isUsed; } public function setRole(?Role $role): void diff --git a/src/contracts/Notification/UserPasswordReset.php b/src/contracts/Notification/UserPasswordReset.php index 9a3f13b2..f997e8c6 100644 --- a/src/contracts/Notification/UserPasswordReset.php +++ b/src/contracts/Notification/UserPasswordReset.php @@ -19,29 +19,16 @@ final class UserPasswordReset extends Notification implements EmailNotificationInterface, UserAwareNotificationInterface { - private User $user; - - private string $token; - - private ConfigResolverInterface $configResolver; - - private Environment $twig; - public function __construct( - User $user, - string $token, - ConfigResolverInterface $configResolver, - Environment $twig + private readonly User $user, + private readonly string $token, + private readonly ConfigResolverInterface $configResolver, + private readonly Environment $twig ) { parent::__construct(); - - $this->user = $user; - $this->token = $token; - $this->configResolver = $configResolver; - $this->twig = $twig; } - public function asEmailMessage(EmailRecipientInterface $recipient, string $transport = null): ?EmailMessage + public function asEmailMessage(EmailRecipientInterface $recipient, ?string $transport = null): ?EmailMessage { $templatePath = $this->configResolver->getParameter('user_forgot_password.templates.mail'); $template = $this->twig->load($templatePath); diff --git a/src/contracts/Notification/UserRegister.php b/src/contracts/Notification/UserRegister.php index fbdb5a52..3c868f1d 100644 --- a/src/contracts/Notification/UserRegister.php +++ b/src/contracts/Notification/UserRegister.php @@ -16,13 +16,10 @@ final class UserRegister extends Notification implements EmailNotificationInterface, UserAwareNotificationInterface { - private User $user; - - public function __construct(User $user) - { + public function __construct( + private readonly User $user + ) { parent::__construct(); - - $this->user = $user; } public function asEmailMessage(EmailRecipientInterface $recipient, string $transport = null): ?EmailMessage diff --git a/src/lib/Behat/Context/UserSettingsContext.php b/src/lib/Behat/Context/UserSettingsContext.php index f670db82..25bf7e10 100644 --- a/src/lib/Behat/Context/UserSettingsContext.php +++ b/src/lib/Behat/Context/UserSettingsContext.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\User\Behat\Context; @@ -14,17 +15,11 @@ class UserSettingsContext implements Context { - private UserSettingService $userSettingService; - - private PermissionResolver $permissionResolver; - - private UserService $userService; - - public function __construct(UserSettingService $userSettingService, PermissionResolver $permissionResolver, UserService $userService) - { - $this->userSettingService = $userSettingService; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; + public function __construct( + private readonly UserSettingService $userSettingService, + private readonly PermissionResolver $permissionResolver, + private readonly UserService $userService + ) { } /** diff --git a/src/lib/Behat/Context/UserSetupContext.php b/src/lib/Behat/Context/UserSetupContext.php index 05bccbd3..f61b52d0 100644 --- a/src/lib/Behat/Context/UserSetupContext.php +++ b/src/lib/Behat/Context/UserSetupContext.php @@ -15,13 +15,11 @@ class UserSetupContext implements Context { - private const UNSUPPORTED_USER_HASH = 5; + private const int UNSUPPORTED_USER_HASH = 5; - private Connection $connection; - - public function __construct(Connection $connection) - { - $this->connection = $connection; + public function __construct( + private readonly Connection $connection + ) { } /** diff --git a/src/lib/ConfigResolver/ConfigurableRegistrationContentTypeLoader.php b/src/lib/ConfigResolver/ConfigurableRegistrationContentTypeLoader.php index cfebe23d..a6e357d7 100644 --- a/src/lib/ConfigResolver/ConfigurableRegistrationContentTypeLoader.php +++ b/src/lib/ConfigResolver/ConfigurableRegistrationContentTypeLoader.php @@ -16,25 +16,16 @@ /** * Loads the registration content type from a configured, injected content type identifier. */ -class ConfigurableRegistrationContentTypeLoader implements RegistrationContentTypeLoader +readonly class ConfigurableRegistrationContentTypeLoader implements RegistrationContentTypeLoader { - private ConfigResolverInterface $configResolver; - - private Repository $repository; - - private ContentTypeService $contentTypeService; - public function __construct( - ConfigResolverInterface $configResolver, - Repository $repository, - ContentTypeService $contentTypeService + private ConfigResolverInterface $configResolver, + private Repository $repository, + private ContentTypeService $contentTypeService ) { - $this->configResolver = $configResolver; - $this->repository = $repository; - $this->contentTypeService = $contentTypeService; } - public function loadContentType(?string $siteAccessIdentifier = null) + public function loadContentType(?string $siteAccessIdentifier = null): ContentType { return $this->repository->sudo( fn (): ContentType => $this->contentTypeService->loadContentTypeByIdentifier( diff --git a/src/lib/ConfigResolver/ConfigurableRegistrationGroupLoader.php b/src/lib/ConfigResolver/ConfigurableRegistrationGroupLoader.php index 253c9186..30da5354 100644 --- a/src/lib/ConfigResolver/ConfigurableRegistrationGroupLoader.php +++ b/src/lib/ConfigResolver/ConfigurableRegistrationGroupLoader.php @@ -15,26 +15,20 @@ /** * Loads the registration user group from a configured, injected group ID. */ -class ConfigurableRegistrationGroupLoader implements RegistrationGroupLoader +readonly class ConfigurableRegistrationGroupLoader implements RegistrationGroupLoader { - private ConfigResolverInterface $configResolver; - - private Repository $repository; - - public function __construct(ConfigResolverInterface $configResolver, Repository $repository) - { - $this->configResolver = $configResolver; - $this->repository = $repository; + public function __construct( + private ConfigResolverInterface $configResolver, + private Repository $repository + ) { } - public function loadGroup() + public function loadGroup(): UserGroup { - return $this->repository->sudo(function (Repository $repository): UserGroup { - return $repository - ->getUserService() - ->loadUserGroupByRemoteId( - $this->configResolver->getParameter('user_registration.group_remote_id') - ); - }); + return $this->repository->sudo(fn (Repository $repository): UserGroup => $repository + ->getUserService() + ->loadUserGroupByRemoteId( + $this->configResolver->getParameter('user_registration.group_remote_id') + )); } } diff --git a/src/lib/ConfigResolver/ConfigurableSudoRepositoryLoader.php b/src/lib/ConfigResolver/ConfigurableSudoRepositoryLoader.php index 75b1d968..0397b292 100644 --- a/src/lib/ConfigResolver/ConfigurableSudoRepositoryLoader.php +++ b/src/lib/ConfigResolver/ConfigurableSudoRepositoryLoader.php @@ -26,40 +26,23 @@ */ abstract class ConfigurableSudoRepositoryLoader { - private Repository $repository; - - /** @var array */ - private $params; - /** - * @param \Ibexa\Contracts\Core\Repository\Repository $repository - * @param array $params + * @param array $params */ - public function __construct(Repository $repository, $params = []) - { - $this->repository = $repository; - $this->params = $params; + public function __construct( + private readonly Repository $repository, + private array $params = [] + ) { } - /** - * @param $name - * @param $value - * - * @return $this - */ - public function setParam($name, $value) + public function setParam(string $name, mixed $value): self { $this->params[$name] = $value; return $this; } - /** - * @param $name - * - * @return mixed - */ - protected function getParam($name) + protected function getParam(string $name): mixed { if (!isset($this->params[$name])) { throw new OutOfBoundsException("There is no param '$name'"); @@ -68,22 +51,12 @@ protected function getParam($name) return $this->params[$name]; } - /** - * @return \Ibexa\Contracts\Core\Repository\Repository - */ - protected function getRepository() + protected function getRepository(): Repository { return $this->repository; } - /** - * @param \Closure $callback - * - * @return mixed - * - * @throws \Exception - */ - protected function sudo(Closure $callback) + protected function sudo(Closure $callback): mixed { $resolver = new OptionsResolver(); $this->configureOptions($resolver); @@ -92,8 +65,5 @@ protected function sudo(Closure $callback) return $this->repository->sudo($callback); } - /** - * @param \Symfony\Component\OptionsResolver\OptionsResolver $optionsResolver - */ - abstract protected function configureOptions(OptionsResolver $optionsResolver); + abstract protected function configureOptions(OptionsResolver $optionsResolver): void; } diff --git a/src/lib/ConfigResolver/RegistrationContentTypeLoader.php b/src/lib/ConfigResolver/RegistrationContentTypeLoader.php index c50098de..d20a63b8 100644 --- a/src/lib/ConfigResolver/RegistrationContentTypeLoader.php +++ b/src/lib/ConfigResolver/RegistrationContentTypeLoader.php @@ -8,6 +8,8 @@ namespace Ibexa\User\ConfigResolver; +use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType; + /** * Loads the content type used by user registration. */ @@ -15,8 +17,6 @@ interface RegistrationContentTypeLoader { /** * Gets the content type used by user registration. - * - * @return \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType */ - public function loadContentType(); + public function loadContentType(): ContentType; } diff --git a/src/lib/ConfigResolver/RegistrationGroupLoader.php b/src/lib/ConfigResolver/RegistrationGroupLoader.php index 86125e02..151c15a9 100644 --- a/src/lib/ConfigResolver/RegistrationGroupLoader.php +++ b/src/lib/ConfigResolver/RegistrationGroupLoader.php @@ -8,6 +8,8 @@ namespace Ibexa\User\ConfigResolver; +use Ibexa\Contracts\Core\Repository\Values\User\UserGroup; + /** * Used to load a user group during registration. */ @@ -15,8 +17,6 @@ interface RegistrationGroupLoader { /** * Loads a parent group. - * - * @return \Ibexa\Contracts\Core\Repository\Values\User\UserGroup */ - public function loadGroup(); + public function loadGroup(): UserGroup; } diff --git a/src/lib/EventListener/BuildSchemaSubscriber.php b/src/lib/EventListener/BuildSchemaSubscriber.php index 70605fbc..389d2ac3 100644 --- a/src/lib/EventListener/BuildSchemaSubscriber.php +++ b/src/lib/EventListener/BuildSchemaSubscriber.php @@ -12,13 +12,11 @@ use Ibexa\Contracts\DoctrineSchema\SchemaBuilderEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -final class BuildSchemaSubscriber implements EventSubscriberInterface +final readonly class BuildSchemaSubscriber implements EventSubscriberInterface { - private string $schemaFilePath; - - public function __construct(string $schemaFilePath) - { - $this->schemaFilePath = $schemaFilePath; + public function __construct( + private string $schemaFilePath + ) { } public static function getSubscribedEvents(): array diff --git a/src/lib/EventListener/PerformAccessCheckSubscriber.php b/src/lib/EventListener/PerformAccessCheckSubscriber.php index 28b8ae6e..e3c0cf49 100644 --- a/src/lib/EventListener/PerformAccessCheckSubscriber.php +++ b/src/lib/EventListener/PerformAccessCheckSubscriber.php @@ -13,14 +13,14 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\ControllerEvent; -final class PerformAccessCheckSubscriber implements EventSubscriberInterface +final readonly class PerformAccessCheckSubscriber implements EventSubscriberInterface { /** * @param iterable $controllers */ public function __construct( #[AutowireIterator('controller.service_arguments')] - private readonly iterable $controllers + private iterable $controllers ) { } diff --git a/src/lib/EventListener/ViewTemplatesListener.php b/src/lib/EventListener/ViewTemplatesListener.php index 214ef288..4d0bb167 100644 --- a/src/lib/EventListener/ViewTemplatesListener.php +++ b/src/lib/EventListener/ViewTemplatesListener.php @@ -17,11 +17,9 @@ class ViewTemplatesListener implements EventSubscriberInterface { - private ConfigResolverInterface $configResolver; - - public function __construct(ConfigResolverInterface $configResolver) - { - $this->configResolver = $configResolver; + public function __construct( + private readonly ConfigResolverInterface $configResolver + ) { } public static function getSubscribedEvents(): array diff --git a/src/lib/ExceptionHandler/ActionResultHandler.php b/src/lib/ExceptionHandler/ActionResultHandler.php index fc7618c0..14c831f2 100644 --- a/src/lib/ExceptionHandler/ActionResultHandler.php +++ b/src/lib/ExceptionHandler/ActionResultHandler.php @@ -13,7 +13,13 @@ */ interface ActionResultHandler { + /** + * @param array $parameters + */ public function error(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; } diff --git a/src/lib/Form/ChoiceList/Loader/AvailableLocaleChoiceLoader.php b/src/lib/Form/ChoiceList/Loader/AvailableLocaleChoiceLoader.php index 79585d39..23babc0e 100644 --- a/src/lib/Form/ChoiceList/Loader/AvailableLocaleChoiceLoader.php +++ b/src/lib/Form/ChoiceList/Loader/AvailableLocaleChoiceLoader.php @@ -25,24 +25,14 @@ class AvailableLocaleChoiceLoader implements ChoiceLoaderInterface */ private const array EXCLUDED_TRANSLATIONS = ['ach-UG']; - private ValidatorInterface $validator; - - private ConfigResolverInterface $configResolver; - - /** @var string[] */ - private array $availableTranslations; - /** * @param string[] $availableTranslations */ public function __construct( - ValidatorInterface $validator, - ConfigResolverInterface $configResolver, - array $availableTranslations + private readonly ValidatorInterface $validator, + private readonly ConfigResolverInterface $configResolver, + private readonly array $availableTranslations ) { - $this->validator = $validator; - $this->availableTranslations = $availableTranslations; - $this->configResolver = $configResolver; } /** diff --git a/src/lib/Form/ChoiceList/Loader/UserGroupsChoiceLoader.php b/src/lib/Form/ChoiceList/Loader/UserGroupsChoiceLoader.php index f2281793..6deba3db 100644 --- a/src/lib/Form/ChoiceList/Loader/UserGroupsChoiceLoader.php +++ b/src/lib/Form/ChoiceList/Loader/UserGroupsChoiceLoader.php @@ -20,23 +20,17 @@ final class UserGroupsChoiceLoader extends AbstractChoiceLoader { - private Repository $repository; - - private SearchService $searchService; - - private UserService $userService; - public function __construct( - Repository $repository, - SearchService $searchService, - UserService $userService + private readonly Repository $repository, + private readonly SearchService $searchService, + private readonly UserService $userService ) { - $this->repository = $repository; - $this->searchService = $searchService; - $this->userService = $userService; } - protected function loadChoices(): array + /** + * @return iterable<\Ibexa\Contracts\Core\Repository\Values\User\UserGroup> + */ + protected function loadChoices(): iterable { return $this->repository->sudo(function () { $query = new Query(); diff --git a/src/lib/Form/Data/UserInvitationData.php b/src/lib/Form/Data/UserInvitationData.php index b9b39322..fb0becc4 100644 --- a/src/lib/Form/Data/UserInvitationData.php +++ b/src/lib/Form/Data/UserInvitationData.php @@ -16,48 +16,24 @@ final class UserInvitationData { - #[Assert\NotBlank] - #[Assert\Email] - private string $email; - - private ?Role $role; - - #[Assert\NotBlank] - private ?SiteAccess $siteaccess; - - private ?UserGroup $userGroup; - - /** @var \Ibexa\Contracts\Core\Persistence\Content\Section[]|null */ - private ?array $sections; - - private ?string $locationPath; - - private ?RoleLimitation $roleLimitation; - - private ?string $limitationType; - - private ?array $limitationValue; - + /** + * @param array|null $sections + * @param array|null $limitationValue + */ public function __construct( - string $email = null, - SiteAccess $siteaccess = null, - ?Role $role = null, - ?UserGroup $userGroup = null, - ?array $sections = null, - ?string $locationId = null, - ?RoleLimitation $roleLimitation = null, - ?string $limitationType = null, - ?array $limitationValue = null + #[Assert\NotBlank] + #[Assert\Email] + private string $email, + #[Assert\NotBlank] + private ?SiteAccess $siteaccess = null, + private ?Role $role = null, + private ?UserGroup $userGroup = null, + private ?array $sections = null, + private ?string $locationPath = null, + private ?RoleLimitation $roleLimitation = null, + private ?string $limitationType = null, + private ?array $limitationValue = null ) { - $this->email = $email; - $this->role = $role; - $this->siteaccess = $siteaccess; - $this->userGroup = $userGroup; - $this->sections = $sections; - $this->locationPath = $locationId; - $this->limitationType = $limitationType; - $this->limitationValue = $limitationValue; - $this->roleLimitation = $roleLimitation; } public function getLimitationType(): ?string diff --git a/src/lib/Form/Data/UserPasswordChangeData.php b/src/lib/Form/Data/UserPasswordChangeData.php index 12b5714b..809874b4 100644 --- a/src/lib/Form/Data/UserPasswordChangeData.php +++ b/src/lib/Form/Data/UserPasswordChangeData.php @@ -13,52 +13,32 @@ class UserPasswordChangeData { - /** - * @UserAssert\UserPassword() - */ - #[Assert\NotBlank] - private ?string $oldPassword; - - #[Assert\NotBlank] - private ?string $newPassword; - - /** - * @param string|null $oldPassword - * @param string|null $newPassword - */ - public function __construct(?string $oldPassword = null, ?string $newPassword = null) - { - $this->oldPassword = $oldPassword; - $this->newPassword = $newPassword; + public function __construct( + /** + * @UserAssert\UserPassword() + */ + #[Assert\NotBlank] + private ?string $oldPassword = null, + #[Assert\NotBlank] + private ?string $newPassword = null + ) { } - /** - * @param string|null $oldPassword - */ public function setOldPassword(?string $oldPassword): void { $this->oldPassword = $oldPassword; } - /** - * @param string|null $newPassword - */ public function setNewPassword(?string $newPassword): void { $this->newPassword = $newPassword; } - /** - * @return string|null - */ public function getOldPassword(): ?string { return $this->oldPassword; } - /** - * @return string|null - */ public function getNewPassword(): ?string { return $this->newPassword; diff --git a/src/lib/Form/Data/UserPasswordForgotData.php b/src/lib/Form/Data/UserPasswordForgotData.php index ae6731f2..2cea7647 100644 --- a/src/lib/Form/Data/UserPasswordForgotData.php +++ b/src/lib/Form/Data/UserPasswordForgotData.php @@ -12,28 +12,17 @@ class UserPasswordForgotData { - #[Assert\NotBlank] - private ?string $email; - - /** - * @param string|null $email - */ - public function __construct(?string $email = null) - { - $this->email = $email; + public function __construct( + #[Assert\NotBlank] + private ?string $email = null + ) { } - /** - * @param string|null $email - */ public function setEmail(?string $email): void { $this->email = $email; } - /** - * @return string|null - */ public function getEmail(): ?string { return $this->email; diff --git a/src/lib/Form/Data/UserPasswordForgotWithLoginData.php b/src/lib/Form/Data/UserPasswordForgotWithLoginData.php index 12f941ee..24053666 100644 --- a/src/lib/Form/Data/UserPasswordForgotWithLoginData.php +++ b/src/lib/Form/Data/UserPasswordForgotWithLoginData.php @@ -12,28 +12,17 @@ class UserPasswordForgotWithLoginData { - #[Assert\NotBlank] - private ?string $login; - - /** - * @param string|null $login - */ - public function __construct(?string $login = null) - { - $this->login = $login; + public function __construct( + #[Assert\NotBlank] + private ?string $login = null + ) { } - /** - * @param string|null $login - */ public function setLogin(?string $login): void { $this->login = $login; } - /** - * @return string|null - */ public function getLogin(): ?string { return $this->login; diff --git a/src/lib/Form/Data/UserPasswordResetData.php b/src/lib/Form/Data/UserPasswordResetData.php index 13d8a38b..115ee66c 100644 --- a/src/lib/Form/Data/UserPasswordResetData.php +++ b/src/lib/Form/Data/UserPasswordResetData.php @@ -13,50 +13,31 @@ class UserPasswordResetData { - #[Assert\NotBlank] - private ?string $newPassword; - - /** - * @deprecated ContentType should be passed as option to FormType. - */ - private ?ContentType $contentType; - - /** - * @param string|null $newPassword - */ - public function __construct(?string $newPassword = null, ?ContentType $contentType = null) - { - $this->newPassword = $newPassword; - $this->contentType = $contentType; + public function __construct( + #[Assert\NotBlank] + private ?string $newPassword = null, + /** + * @deprecated ContentType should be passed as option to FormType. + */ + private ?ContentType $contentType = null + ) { } - /** - * @param string|null $newPassword - */ public function setNewPassword(?string $newPassword): void { $this->newPassword = $newPassword; } - /** - * @return string|null - */ public function getNewPassword(): ?string { return $this->newPassword; } - /** - * @return \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType - */ public function getContentType(): ?ContentType { return $this->contentType; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType $contentType - */ public function setContentType(ContentType $contentType): void { $this->contentType = $contentType; diff --git a/src/lib/Form/Data/UserSettingUpdateData.php b/src/lib/Form/Data/UserSettingUpdateData.php index 1609db73..a2e21a83 100644 --- a/src/lib/Form/Data/UserSettingUpdateData.php +++ b/src/lib/Form/Data/UserSettingUpdateData.php @@ -12,18 +12,14 @@ class UserSettingUpdateData { - #[Assert\NotBlank] - private string $identifier; - /** - * @var array + * @param array> $values */ - private array $values; - - public function __construct(string $identifier, array $values) - { - $this->identifier = $identifier; - $this->values = $values; + public function __construct( + #[Assert\NotBlank] + private string $identifier, + private array $values + ) { } public function getIdentifier(): string @@ -36,11 +32,17 @@ public function setIdentifier(string $identifier): void $this->identifier = $identifier; } + /** + * @return array> + */ public function getValues(): array { return $this->values; } + /** + * @param array> $values + */ public function setValues(array $values): void { $this->values = $values; diff --git a/src/lib/Form/DataMapper/UserRegisterMapper.php b/src/lib/Form/DataMapper/UserRegisterMapper.php index bf08e1d7..8ce3c12f 100644 --- a/src/lib/Form/DataMapper/UserRegisterMapper.php +++ b/src/lib/Form/DataMapper/UserRegisterMapper.php @@ -20,38 +20,20 @@ */ class UserRegisterMapper { - private RegistrationContentTypeLoader $contentTypeLoader; + /** @var array */ + private array $params; - /** @var \Ibexa\User\ConfigResolver\RegistrationContentTypeLoader */ - private RegistrationGroupLoader $parentGroupLoader; - - /** @var array */ - private $params; - - /** - * @param \Ibexa\User\ConfigResolver\RegistrationContentTypeLoader $contentTypeLoader - * @param \Ibexa\User\ConfigResolver\RegistrationGroupLoader $registrationGroupLoader - */ public function __construct( - RegistrationContentTypeLoader $contentTypeLoader, - RegistrationGroupLoader $registrationGroupLoader + private readonly RegistrationContentTypeLoader $contentTypeLoader, + private readonly RegistrationGroupLoader $parentGroupLoader ) { - $this->contentTypeLoader = $contentTypeLoader; - $this->parentGroupLoader = $registrationGroupLoader; } - /** - * @param $name - * @param $value - */ - public function setParam($name, $value): void + public function setParam(string $name, mixed $value): void { $this->params[$name] = $value; } - /** - * @return \Ibexa\User\Form\Data\UserRegisterData - */ public function mapToFormData(): UserRegisterData { $resolver = new OptionsResolver(); diff --git a/src/lib/Form/DataTransformer/DateTimeFormatTransformer.php b/src/lib/Form/DataTransformer/DateTimeFormatTransformer.php index eaa85ec6..62fb311f 100644 --- a/src/lib/Form/DataTransformer/DateTimeFormatTransformer.php +++ b/src/lib/Form/DataTransformer/DateTimeFormatTransformer.php @@ -15,20 +15,15 @@ class DateTimeFormatTransformer implements DataTransformerInterface { - private DateTimeFormatSerializer $serializer; - - /** - * @param \Ibexa\User\UserSetting\Setting\DateTimeFormatSerializer $serializer - */ - public function __construct(DateTimeFormatSerializer $serializer) - { - $this->serializer = $serializer; + public function __construct( + private readonly DateTimeFormatSerializer $serializer + ) { } /** - * {@inheritdoc} + * @return array{date_format: ?string, time_format: ?string}|null */ - public function transform($value): ?array + public function transform(mixed $value): ?array { if (null === $value) { return null; @@ -48,10 +43,7 @@ public function transform($value): ?array ]; } - /** - * {@inheritdoc} - */ - public function reverseTransform($value): ?string + public function reverseTransform(mixed $value): ?string { if (empty($value)) { return null; diff --git a/src/lib/Form/DataTransformer/InvitationTransformer.php b/src/lib/Form/DataTransformer/InvitationTransformer.php index f65697fb..6607134e 100644 --- a/src/lib/Form/DataTransformer/InvitationTransformer.php +++ b/src/lib/Form/DataTransformer/InvitationTransformer.php @@ -14,16 +14,14 @@ use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\Exception\TransformationFailedException; -class InvitationTransformer implements DataTransformerInterface +readonly class InvitationTransformer implements DataTransformerInterface { - private InvitationService $invitationService; - - public function __construct(InvitationService $invitationService) - { - $this->invitationService = $invitationService; + public function __construct( + private InvitationService $invitationService + ) { } - public function transform($value): ?string + public function transform(mixed $value): ?string { if (null === $value) { return null; @@ -36,7 +34,7 @@ public function transform($value): ?string return $value->getHash(); } - public function reverseTransform($value): ?Invitation + public function reverseTransform(mixed $value): ?Invitation { if (empty($value)) { return null; diff --git a/src/lib/Form/Factory/FormFactory.php b/src/lib/Form/Factory/FormFactory.php index 216d3e5e..414933bd 100644 --- a/src/lib/Form/Factory/FormFactory.php +++ b/src/lib/Form/Factory/FormFactory.php @@ -27,18 +27,10 @@ class FormFactory { - protected FormFactoryInterface $formFactory; - - protected UrlGeneratorInterface $urlGenerator; - - /** - * @param \Symfony\Component\Form\FormFactoryInterface $formFactory - * @param \Symfony\Component\Routing\Generator\UrlGeneratorInterface $urlGenerator - */ - public function __construct(FormFactoryInterface $formFactory, UrlGeneratorInterface $urlGenerator) - { - $this->formFactory = $formFactory; - $this->urlGenerator = $urlGenerator; + public function __construct( + protected FormFactoryInterface $formFactory, + protected UrlGeneratorInterface $urlGenerator + ) { } public function changeUserPassword( @@ -61,11 +53,6 @@ public function changeUserPassword( } /** - * @param \Ibexa\User\Form\Data\UserPasswordForgotData $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function forgotUserPassword( @@ -78,11 +65,6 @@ public function forgotUserPassword( } /** - * @param \Ibexa\User\Form\Data\UserPasswordForgotWithLoginData $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function forgotUserPasswordWithLogin( @@ -95,11 +77,6 @@ public function forgotUserPasswordWithLogin( } /** - * @param \Ibexa\User\Form\Data\UserPasswordResetData $data - * @param string|null $name - * - * @return \Symfony\Component\Form\FormInterface - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function resetUserPassword( diff --git a/src/lib/Form/Processor/UserRegisterFormProcessor.php b/src/lib/Form/Processor/UserRegisterFormProcessor.php index c3d1fddb..8cde4ccc 100644 --- a/src/lib/Form/Processor/UserRegisterFormProcessor.php +++ b/src/lib/Form/Processor/UserRegisterFormProcessor.php @@ -22,35 +22,19 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Component\Routing\RouterInterface; /** * Listens for and processes User register events. */ -class UserRegisterFormProcessor implements EventSubscriberInterface +readonly class UserRegisterFormProcessor implements EventSubscriberInterface { - private UserService $userService; - - private UrlGeneratorInterface $urlGenerator; - - private Repository $repository; - - private RoleService $roleService; - - private NotificationServiceInterface $notificationService; - public function __construct( - Repository $repository, - UserService $userService, - RouterInterface $router, - RoleService $roleService, - NotificationServiceInterface $notificationService + private Repository $repository, + private UserService $userService, + private UrlGeneratorInterface $urlGenerator, + private RoleService $roleService, + private NotificationServiceInterface $notificationService ) { - $this->userService = $userService; - $this->urlGenerator = $router; - $this->repository = $repository; - $this->roleService = $roleService; - $this->notificationService = $notificationService; } public static function getSubscribedEvents(): array @@ -61,8 +45,6 @@ public static function getSubscribedEvents(): array } /** - * @param \Ibexa\ContentForms\Event\FormActionEvent $event - * * @throws \Exception */ public function processRegister(FormActionEvent $event): void diff --git a/src/lib/Form/Type/Invitation/InvitationType.php b/src/lib/Form/Type/Invitation/InvitationType.php index 57b3df4f..afe73cb8 100644 --- a/src/lib/Form/Type/Invitation/InvitationType.php +++ b/src/lib/Form/Type/Invitation/InvitationType.php @@ -15,11 +15,9 @@ final class InvitationType extends AbstractType { - private InvitationService $invitationService; - - public function __construct(InvitationService $invitationService) - { - $this->invitationService = $invitationService; + public function __construct( + private readonly InvitationService $invitationService + ) { } public function buildForm(FormBuilderInterface $builder, array $options): void @@ -27,7 +25,8 @@ public function buildForm(FormBuilderInterface $builder, array $options): void $builder->addViewTransformer(new InvitationTransformer($this->invitationService)); } - public function getParent(): ?string + #[\Override] + public function getParent(): string { return HiddenType::class; } diff --git a/src/lib/Form/Type/Invitation/RoleChoiceType.php b/src/lib/Form/Type/Invitation/RoleChoiceType.php index 04dd95ab..342b4284 100644 --- a/src/lib/Form/Type/Invitation/RoleChoiceType.php +++ b/src/lib/Form/Type/Invitation/RoleChoiceType.php @@ -10,6 +10,7 @@ use Ibexa\Contracts\Core\Repository\PermissionResolver; use Ibexa\Contracts\Core\Repository\RoleService; +use Ibexa\Contracts\Core\Repository\Values\User\Role; use Ibexa\Core\Repository\Repository; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader; @@ -18,45 +19,37 @@ final class RoleChoiceType extends AbstractType { - private RoleService $roleService; - - private Repository $repository; - - private PermissionResolver $permissionResolver; - public function __construct( - RoleService $roleService, - Repository $repository, - PermissionResolver $permissionResolver + private readonly RoleService $roleService, + private readonly Repository $repository, + private readonly PermissionResolver $permissionResolver ) { - $this->roleService = $roleService; - $this->repository = $repository; - $this->permissionResolver = $permissionResolver; } public function configureOptions(OptionsResolver $resolver): void { $resolver ->setDefaults([ - 'choice_loader' => new CallbackChoiceLoader([$this, 'loadFilteredRoles']), + 'choice_loader' => new CallbackChoiceLoader($this->loadFilteredRoles(...)), 'choice_label' => 'identifier', 'choice_name' => 'id', 'choice_value' => 'id', ]); } + /** + * @return array + */ public function loadFilteredRoles(): array { return array_filter( $this->repository->sudo(fn (): iterable => $this->roleService->loadRoles()), - fn ($role): bool => $this->permissionResolver->canUser('user', 'invite', $role) + fn (Role $role): bool => $this->permissionResolver->canUser('user', 'invite', $role) ); } - /** - * {@inheritdoc} - */ - public function getParent(): ?string + #[\Override] + public function getParent(): string { return ChoiceType::class; } diff --git a/src/lib/Form/Type/Invitation/SectionsChoiceType.php b/src/lib/Form/Type/Invitation/SectionsChoiceType.php index 6da434d2..77fec6fb 100644 --- a/src/lib/Form/Type/Invitation/SectionsChoiceType.php +++ b/src/lib/Form/Type/Invitation/SectionsChoiceType.php @@ -17,16 +17,10 @@ final class SectionsChoiceType extends AbstractType { - private SectionService $sectionService; - - private Repository $repository; - public function __construct( - Repository $repository, - SectionService $sectionService + private readonly Repository $repository, + private readonly SectionService $sectionService ) { - $this->sectionService = $sectionService; - $this->repository = $repository; } public function configureOptions(OptionsResolver $resolver): void @@ -42,10 +36,8 @@ public function configureOptions(OptionsResolver $resolver): void ]); } - /** - * {@inheritdoc} - */ - public function getParent(): ?string + #[\Override] + public function getParent(): string { return ChoiceType::class; } diff --git a/src/lib/Form/Type/Invitation/SiteAccessChoiceType.php b/src/lib/Form/Type/Invitation/SiteAccessChoiceType.php index 6448a98e..e62e8abb 100644 --- a/src/lib/Form/Type/Invitation/SiteAccessChoiceType.php +++ b/src/lib/Form/Type/Invitation/SiteAccessChoiceType.php @@ -15,11 +15,9 @@ final class SiteAccessChoiceType extends AbstractType { - private SiteAccessServiceInterface $siteAccessService; - - public function __construct(SiteAccessServiceInterface $siteAccessService) - { - $this->siteAccessService = $siteAccessService; + public function __construct( + private readonly SiteAccessServiceInterface $siteAccessService + ) { } public function configureOptions(OptionsResolver $resolver): void @@ -33,10 +31,8 @@ public function configureOptions(OptionsResolver $resolver): void ]); } - /** - * {@inheritdoc} - */ - public function getParent(): ?string + #[\Override] + public function getParent(): string { return ChoiceType::class; } diff --git a/src/lib/Form/Type/Invitation/UserGroupChoiceType.php b/src/lib/Form/Type/Invitation/UserGroupChoiceType.php index 2f4c78b7..ee6c71fe 100644 --- a/src/lib/Form/Type/Invitation/UserGroupChoiceType.php +++ b/src/lib/Form/Type/Invitation/UserGroupChoiceType.php @@ -12,6 +12,7 @@ use Ibexa\Contracts\Core\Repository\Repository; use Ibexa\Contracts\Core\Repository\SearchService; use Ibexa\Contracts\Core\Repository\UserService; +use Ibexa\Contracts\Core\Repository\Values\User\UserGroup; use Ibexa\User\Form\ChoiceList\Loader\UserGroupsChoiceLoader; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader; @@ -20,45 +21,37 @@ final class UserGroupChoiceType extends AbstractType { - private UserService $userService; - - private SearchService $searchService; - - private Repository $repository; - - private PermissionResolver $permissionResolver; - public function __construct( - Repository $repository, - UserService $userService, - SearchService $searchService, - PermissionResolver $permissionResolver + private readonly Repository $repository, + private readonly UserService $userService, + private readonly SearchService $searchService, + private readonly PermissionResolver $permissionResolver ) { - $this->userService = $userService; - $this->searchService = $searchService; - $this->repository = $repository; - $this->permissionResolver = $permissionResolver; } public function configureOptions(OptionsResolver $resolver): void { $resolver ->setDefaults([ - 'choice_loader' => new CallbackChoiceLoader([$this, 'loadFilteredGroups']), + 'choice_loader' => new CallbackChoiceLoader($this->loadFilteredGroups(...)), 'choice_label' => 'name', 'choice_name' => 'id', 'choice_value' => 'id', ]); } - /** - * {@inheritdoc} - */ - public function getParent(): ?string + #[\Override] + public function getParent(): string { return ChoiceType::class; } + /** + * @return array + * + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException + */ public function loadFilteredGroups(): array { return array_filter( @@ -67,7 +60,7 @@ public function loadFilteredGroups(): array $this->searchService, $this->userService ))->loadChoiceList()->getChoices(), - fn ($group): bool => $this->permissionResolver->canUser('user', 'invite', $group) + fn (UserGroup $group): bool => $this->permissionResolver->canUser('user', 'invite', $group) ); } } diff --git a/src/lib/Form/Type/Invitation/UserInvitationType.php b/src/lib/Form/Type/Invitation/UserInvitationType.php index 84177a88..e35ac124 100644 --- a/src/lib/Form/Type/Invitation/UserInvitationType.php +++ b/src/lib/Form/Type/Invitation/UserInvitationType.php @@ -19,9 +19,9 @@ final class UserInvitationType extends AbstractType { - public const LIMITATION_TYPE_NONE = 'none'; - public const LIMITATION_TYPE_SECTION = 'section'; - public const LIMITATION_TYPE_LOCATION = 'location'; + public const string LIMITATION_TYPE_NONE = 'none'; + public const string LIMITATION_TYPE_SECTION = 'section'; + public const string LIMITATION_TYPE_LOCATION = 'location'; public function buildForm(FormBuilderInterface $builder, array $options): void { diff --git a/src/lib/Form/Type/UserRegisterType.php b/src/lib/Form/Type/UserRegisterType.php index 5d1bd888..338b3631 100644 --- a/src/lib/Form/Type/UserRegisterType.php +++ b/src/lib/Form/Type/UserRegisterType.php @@ -26,11 +26,9 @@ */ class UserRegisterType extends AbstractType { - private ConfigResolverInterface $configResolver; - - public function __construct(ConfigResolverInterface $configResolver) - { - $this->configResolver = $configResolver; + public function __construct( + private readonly ConfigResolverInterface $configResolver + ) { } public function getName(): string @@ -38,12 +36,14 @@ public function getName(): string return $this->getBlockPrefix(); } + #[\Override] public function getBlockPrefix(): string { return 'ezplatform_content_forms_user_register'; } - public function getParent(): ?string + #[\Override] + public function getParent(): string { return BaseContentType::class; } diff --git a/src/lib/Form/Type/UserSettingUpdateType.php b/src/lib/Form/Type/UserSettingUpdateType.php index 096f8f3d..8af5fa4e 100644 --- a/src/lib/Form/Type/UserSettingUpdateType.php +++ b/src/lib/Form/Type/UserSettingUpdateType.php @@ -20,27 +20,15 @@ class UserSettingUpdateType extends AbstractType { - public const BTN_UPDATE_AND_EDIT = 'update_and_edit'; + public const string BTN_UPDATE_AND_EDIT = 'update_and_edit'; - protected FormMapperRegistry $formMapperRegistry; - - protected ValueDefinitionRegistry $valueDefinitionRegistry; - - /** - * @param \Ibexa\User\UserSetting\FormMapperRegistry $formMapperRegistry - * @param \Ibexa\User\UserSetting\ValueDefinitionRegistry $valueDefinitionRegistry - */ public function __construct( - FormMapperRegistry $formMapperRegistry, - ValueDefinitionRegistry $valueDefinitionRegistry + protected FormMapperRegistry $formMapperRegistry, + protected ValueDefinitionRegistry $valueDefinitionRegistry ) { - $this->formMapperRegistry = $formMapperRegistry; - $this->valueDefinitionRegistry = $valueDefinitionRegistry; } /** - * {@inheritdoc} - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ public function buildForm(FormBuilderInterface $builder, array $options): void @@ -71,9 +59,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void $builder->add(self::BTN_UPDATE_AND_EDIT, SubmitType::class); } - /** - * {@inheritdoc} - */ public function configureOptions(OptionsResolver $resolver): void { $resolver diff --git a/src/lib/Form/Type/UserSettings/DateTimeFormatType.php b/src/lib/Form/Type/UserSettings/DateTimeFormatType.php index 126d80e2..bf149c24 100644 --- a/src/lib/Form/Type/UserSettings/DateTimeFormatType.php +++ b/src/lib/Form/Type/UserSettings/DateTimeFormatType.php @@ -16,9 +16,6 @@ class DateTimeFormatType extends AbstractType { - /** - * {@inheritdoc} - */ public function buildForm(FormBuilderInterface $builder, array $options): void { $builder->add('date_format', ChoiceType::class, [ @@ -36,9 +33,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ]); } - /** - * {@inheritdoc} - */ public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ diff --git a/src/lib/Form/Type/UserSettings/FullDateTimeFormatType.php b/src/lib/Form/Type/UserSettings/FullDateTimeFormatType.php index db8f3e53..770cf4ef 100644 --- a/src/lib/Form/Type/UserSettings/FullDateTimeFormatType.php +++ b/src/lib/Form/Type/UserSettings/FullDateTimeFormatType.php @@ -14,16 +14,11 @@ class FullDateTimeFormatType extends AbstractType { - private ConfigResolverInterface $configResolver; - - public function __construct(ConfigResolverInterface $configResolver) - { - $this->configResolver = $configResolver; + public function __construct( + private readonly ConfigResolverInterface $configResolver + ) { } - /** - * {@inheritdoc} - */ public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ @@ -32,9 +27,7 @@ public function configureOptions(OptionsResolver $resolver): void ]); } - /** - * {@inheritdoc} - */ + #[\Override] public function getParent(): string { return DateTimeFormatType::class; diff --git a/src/lib/Form/Type/UserSettings/ShortDateTimeFormatType.php b/src/lib/Form/Type/UserSettings/ShortDateTimeFormatType.php index 6294c8e8..f27c55c8 100644 --- a/src/lib/Form/Type/UserSettings/ShortDateTimeFormatType.php +++ b/src/lib/Form/Type/UserSettings/ShortDateTimeFormatType.php @@ -14,16 +14,11 @@ class ShortDateTimeFormatType extends AbstractType { - private ConfigResolverInterface $configResolver; - - public function __construct(ConfigResolverInterface $configResolver) - { - $this->configResolver = $configResolver; + public function __construct( + private readonly ConfigResolverInterface $configResolver + ) { } - /** - * {@inheritdoc} - */ public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ @@ -32,9 +27,7 @@ public function configureOptions(OptionsResolver $resolver): void ]); } - /** - * {@inheritdoc} - */ + #[\Override] public function getParent(): string { return DateTimeFormatType::class; diff --git a/src/lib/Form/UserFormEvents.php b/src/lib/Form/UserFormEvents.php index 6113dee7..57b1d7b8 100644 --- a/src/lib/Form/UserFormEvents.php +++ b/src/lib/Form/UserFormEvents.php @@ -13,5 +13,5 @@ final class UserFormEvents /** * Triggered when registering an user. */ - public const USER_REGISTER = 'user.edit.register'; + public const string USER_REGISTER = 'user.edit.register'; } diff --git a/src/lib/Invitation/DomainMapper.php b/src/lib/Invitation/DomainMapper.php index 16bbf759..7f2a092a 100644 --- a/src/lib/Invitation/DomainMapper.php +++ b/src/lib/Invitation/DomainMapper.php @@ -21,26 +21,14 @@ use Ibexa\Contracts\User\Invitation\Persistence\Invitation as PersistenceInvitation; use Ibexa\Core\Repository\Permission\LimitationService; -final class DomainMapper implements DomainMapperInterface +final readonly class DomainMapper implements DomainMapperInterface { - private UserService $userService; - - private RoleService $roleService; - - private Repository $repository; - - private LimitationService $limitationService; - public function __construct( - Repository $repository, - UserService $userService, - RoleService $roleService, - LimitationService $limitationService + private Repository $repository, + private UserService $userService, + private RoleService $roleService, + private LimitationService $limitationService ) { - $this->userService = $userService; - $this->roleService = $roleService; - $this->repository = $repository; - $this->limitationService = $limitationService; } public function buildDomainObject(PersistenceInvitation $invitation): Invitation @@ -49,7 +37,7 @@ public function buildDomainObject(PersistenceInvitation $invitation): Invitation $role = $invitation->getRoleId() !== null ? $this->loadRole($invitation->getRoleId()) : null; $roleLimitation = null; - if ($invitation->getLimitation()) { + if ($invitation->getLimitation() !== null && is_array($invitation->getLimitationValue())) { $roleLimitation = $this->mapRoleLimitation( $invitation->getLimitation(), $invitation->getLimitationValue() @@ -88,7 +76,7 @@ private function mapRoleLimitation(string $type, array $values): RoleLimitation sprintf( 'Given limitation must be of: %s class, %s given', RoleLimitation::class, - get_class($limitation) + $limitation::class ) ); } diff --git a/src/lib/Invitation/InvitationHashGenerator.php b/src/lib/Invitation/InvitationHashGenerator.php index f9f3985f..f916b9b7 100644 --- a/src/lib/Invitation/InvitationHashGenerator.php +++ b/src/lib/Invitation/InvitationHashGenerator.php @@ -10,16 +10,14 @@ use Ibexa\Contracts\Core\HashGenerator; -final class InvitationHashGenerator implements HashGenerator +final readonly class InvitationHashGenerator implements HashGenerator { - private int $length; - - public function __construct(int $length = 16) - { - $this->length = $length; + public function __construct( + private int $length = 16 + ) { } - public function generate() + public function generate(): string { return bin2hex(random_bytes($this->length)); } diff --git a/src/lib/Invitation/InvitationService.php b/src/lib/Invitation/InvitationService.php index b6c222a7..f3065af2 100644 --- a/src/lib/Invitation/InvitationService.php +++ b/src/lib/Invitation/InvitationService.php @@ -28,42 +28,18 @@ use Ibexa\Core\MVC\Symfony\SiteAccess\SiteAccessServiceInterface; use Ibexa\User\Invitation\Persistence\Handler; -final class InvitationService implements InvitationServiceInterface +final readonly class InvitationService implements InvitationServiceInterface { - private Handler $handler; - - private HashGenerator $hashGenerator; - - private SiteaccessServiceInterface $siteAccessService; - - private PermissionResolver $permissionResolver; - - private UserService $userService; - - private TransactionHandler $transactionHandler; - - private ConfigResolverInterface $configResolver; - - private DomainMapper $domainMapper; - public function __construct( - PermissionResolver $permissionResolver, - Handler $handler, - HashGenerator $hashGenerator, - UserService $userService, - SiteAccessServiceInterface $siteAccessService, - TransactionHandler $transactionHandler, - ConfigResolverInterface $configResolver, - DomainMapper $domainMapper + private PermissionResolver $permissionResolver, + private Handler $handler, + private HashGenerator $hashGenerator, + private UserService $userService, + private SiteaccessServiceInterface $siteAccessService, + private TransactionHandler $transactionHandler, + private ConfigResolverInterface $configResolver, + private DomainMapper $domainMapper ) { - $this->handler = $handler; - $this->hashGenerator = $hashGenerator; - $this->siteAccessService = $siteAccessService; - $this->permissionResolver = $permissionResolver; - $this->userService = $userService; - $this->transactionHandler = $transactionHandler; - $this->configResolver = $configResolver; - $this->domainMapper = $domainMapper; } /** @@ -102,7 +78,7 @@ public function createInvitation( if ($this->userService->loadUserByEmail($createStruct->getEmail())) { throw new UserAlreadyExistsException(); } - } catch (NotFoundException $exception) { + } catch (NotFoundException) { } $roleLimitation = $createStruct->getRoleLimitation(); diff --git a/src/lib/Invitation/MailSender.php b/src/lib/Invitation/MailSender.php index e61beca5..2cd09f35 100644 --- a/src/lib/Invitation/MailSender.php +++ b/src/lib/Invitation/MailSender.php @@ -18,22 +18,13 @@ use Symfony\Component\Notifier\Recipient\Recipient; use Twig\Environment; -final class MailSender implements InvitationSender +final readonly class MailSender implements InvitationSender { - private Environment $twig; - - private ConfigResolverInterface $configResolver; - - private NotificationServiceInterface $notificationService; - public function __construct( - Environment $twig, - ConfigResolverInterface $configResolver, - NotificationServiceInterface $notificationService + private Environment $twig, + private ConfigResolverInterface $configResolver, + private NotificationServiceInterface $notificationService ) { - $this->twig = $twig; - $this->configResolver = $configResolver; - $this->notificationService = $notificationService; } public function sendInvitation(Invitation $invitation): void diff --git a/src/lib/Invitation/Persistence/DoctrineGateway.php b/src/lib/Invitation/Persistence/DoctrineGateway.php index 704ca33e..cbf76cb9 100644 --- a/src/lib/Invitation/Persistence/DoctrineGateway.php +++ b/src/lib/Invitation/Persistence/DoctrineGateway.php @@ -20,18 +20,16 @@ * * @phpstan-import-type TInvitationData from \Ibexa\Contracts\User\Invitation\Persistence\Gateway */ -final class DoctrineGateway implements Gateway +final readonly class DoctrineGateway implements Gateway { private const string TABLE_USER_INVITATIONS = 'ibexa_user_invitation'; private const string TABLE_USER_INVITATIONS_ASSIGNMENTS = 'ibexa_user_invitation_assignment'; private const string TABLE_USER_INVITATIONS_SEQ = 'ibexa_user_invitation_id_seq'; - private Connection $connection; - - public function __construct(Connection $connection) - { - $this->connection = $connection; + public function __construct( + private Connection $connection + ) { } public function addInvitation( @@ -78,7 +76,7 @@ public function addInvitation( public function getInvitation( string $hash - ) { + ): array { $query = $this->getSelectQuery(); $query->where( $query->expr()->eq( @@ -89,6 +87,7 @@ public function getInvitation( $statement = $query->executeQuery(); + /** @var array */ return $statement->fetchAssociative(); } @@ -114,7 +113,7 @@ public function invitationExistsForEmail( /** * @phpstan-return TInvitationData */ - public function getInvitationByEmail(string $email) + public function getInvitationByEmail(string $email): array { $query = $this->getSelectQuery(); $query->where( diff --git a/src/lib/Invitation/Persistence/Handler.php b/src/lib/Invitation/Persistence/Handler.php index c59ddef8..f2c49812 100644 --- a/src/lib/Invitation/Persistence/Handler.php +++ b/src/lib/Invitation/Persistence/Handler.php @@ -18,16 +18,10 @@ class Handler implements HandlerInterface { - private Gateway $gateway; - - private Mapper $mapper; - public function __construct( - Gateway $gateway, - Mapper $mapper + private readonly Gateway $gateway, + private readonly Mapper $mapper ) { - $this->gateway = $gateway; - $this->mapper = $mapper; } public function createInvitation( diff --git a/src/lib/Pagination/Pagerfanta/UserSettingsAdapter.php b/src/lib/Pagination/Pagerfanta/UserSettingsAdapter.php index 9f350542..628e3dc3 100644 --- a/src/lib/Pagination/Pagerfanta/UserSettingsAdapter.php +++ b/src/lib/Pagination/Pagerfanta/UserSettingsAdapter.php @@ -14,34 +14,22 @@ /** * @phpstan-implements \Pagerfanta\Adapter\AdapterInterface<\Ibexa\User\UserSetting\UserSetting> */ -class UserSettingsAdapter implements AdapterInterface +readonly class UserSettingsAdapter implements AdapterInterface { - private UserSettingService $userSettingService; - - /** - * @param \Ibexa\User\UserSetting\UserSettingService $userSettingService - */ - public function __construct(UserSettingService $userSettingService) - { - $this->userSettingService = $userSettingService; + public function __construct( + private UserSettingService $userSettingService + ) { } - /** - * {@inheritdoc} - * - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException - */ public function getNbResults(): int { return $this->userSettingService->countUserSettings(); } /** - * {@inheritdoc} - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException */ - public function getSlice($offset, $length): array + public function getSlice(int $offset, int $length): array { return $this->userSettingService->loadUserSettings($offset, $length); } diff --git a/src/lib/Permission/UserPermissionsLimitation.php b/src/lib/Permission/UserPermissionsLimitation.php index 2a6d9ee1..7f46d3ed 100644 --- a/src/lib/Permission/UserPermissionsLimitation.php +++ b/src/lib/Permission/UserPermissionsLimitation.php @@ -14,7 +14,7 @@ final class UserPermissionsLimitation extends Limitation implements TranslationContainerInterface { - public const IDENTIFIER = 'UserPermissions'; + public const string IDENTIFIER = 'UserPermissions'; public function getIdentifier(): string { diff --git a/src/lib/Permission/UserPermissionsLimitationHandler.php b/src/lib/Permission/UserPermissionsLimitationHandler.php index 44457104..7d2edc67 100644 --- a/src/lib/Permission/UserPermissionsLimitationHandler.php +++ b/src/lib/Permission/UserPermissionsLimitationHandler.php @@ -12,8 +12,8 @@ class UserPermissionsLimitationHandler extends LimitationHandler { - public const USER_GROUP_PREFIX = 'UserGroup_'; - public const ROLE_PREFIX = 'Role_'; + public const string USER_GROUP_PREFIX = 'UserGroup_'; + public const string ROLE_PREFIX = 'Role_'; public function toLegacy(Policy $policy): void { @@ -42,11 +42,11 @@ public function toSPI(Policy $policy): void 'user_groups' => [], ]; foreach ($policy->limitations[UserPermissionsLimitation::IDENTIFIER] as $value) { - if (strpos($value, self::ROLE_PREFIX) === 0) { - $values['roles'][] = (int) substr($value, strlen(self::ROLE_PREFIX)); + if (str_starts_with((string) $value, self::ROLE_PREFIX)) { + $values['roles'][] = (int) substr((string) $value, strlen(self::ROLE_PREFIX)); } - if (strpos($value, self::USER_GROUP_PREFIX) === 0) { - $values['user_groups'][] = (int) substr($value, strlen(self::USER_GROUP_PREFIX)); + if (str_starts_with((string) $value, self::USER_GROUP_PREFIX)) { + $values['user_groups'][] = (int) substr((string) $value, strlen(self::USER_GROUP_PREFIX)); } } $policy->limitations[UserPermissionsLimitation::IDENTIFIER] = $values; diff --git a/src/lib/Permission/UserPermissionsLimitationType.php b/src/lib/Permission/UserPermissionsLimitationType.php index 8c1f7b3c..cd0c1393 100644 --- a/src/lib/Permission/UserPermissionsLimitationType.php +++ b/src/lib/Permission/UserPermissionsLimitationType.php @@ -29,8 +29,6 @@ class UserPermissionsLimitationType extends AbstractPersistenceLimitationType im * Makes sure LimitationValue object and ->limitationValues is of correct type. * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException If the value does not match the expected type/structure - * - * @param \Ibexa\Contracts\Core\Repository\Values\User\Limitation $limitationValue */ public function acceptValue(APILimitationValue $limitationValue): void { @@ -78,8 +76,6 @@ public function acceptValue(APILimitationValue $limitationValue): void * * Make sure {@link acceptValue()} is checked first! * - * @param \Ibexa\Contracts\Core\Repository\Values\User\Limitation $limitationValue - * * @return \Ibexa\Contracts\Core\FieldType\ValidationError[] */ public function validate(APILimitationValue $limitationValue): array @@ -90,7 +86,7 @@ public function validate(APILimitationValue $limitationValue): array foreach ($limitationValue->limitationValues['roles'] as $key => $id) { try { $this->persistence->userHandler()->loadRole($id); - } catch (NotFoundException $e) { + } catch (NotFoundException) { $validationErrors[] = new ValidationError( "limitationValues[%key%] => '%value%' does not exist in the backend", null, @@ -107,7 +103,7 @@ public function validate(APILimitationValue $limitationValue): array foreach ($limitationValue->limitationValues['user_groups'] as $key => $id) { try { $this->persistence->contentHandler()->loadContentInfo($id); - } catch (NotFoundException $e) { + } catch (NotFoundException) { $validationErrors[] = new ValidationError( "limitationValues[%key%] => '%value%' does not exist in the backend", null, @@ -126,9 +122,7 @@ public function validate(APILimitationValue $limitationValue): array /** * Create the Limitation Value. * - * @param mixed[] $limitationValues - * - * @return \Ibexa\Contracts\Core\Repository\Values\User\Limitation + * @param array $limitationValues */ public function buildValue(array $limitationValues): APILimitationValue { @@ -143,12 +137,8 @@ public function buildValue(array $limitationValues): APILimitationValue * @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException If value of the LimitationValue is unsupported * Example if OwnerLimitationValue->limitationValues[0] is not one of: [ 1 ] * - * @param \Ibexa\Contracts\Core\Repository\Values\User\Limitation $value - * @param \Ibexa\Contracts\Core\Repository\Values\User\UserReference $currentUser * @param \Ibexa\Contracts\Core\Repository\Values\ValueObject $object * @param \Ibexa\Contracts\Core\Repository\Values\ValueObject[]|null $targets The context of the $object, like Location of Content, if null none where provided by caller - * - * @return bool */ public function evaluate(APILimitationValue $value, APIUserReference $currentUser, object $object, array $targets = null): ?bool { @@ -177,11 +167,6 @@ public function evaluate(APILimitationValue $value, APIUserReference $currentUse /** * Returns Criterion for use in find() query. - * - * @param \Ibexa\Contracts\Core\Repository\Values\User\Limitation $value - * @param \Ibexa\Contracts\Core\Repository\Values\User\UserReference $currentUser - * - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface */ public function getCriterion(APILimitationValue $value, APIUserReference $currentUser): CriterionInterface { diff --git a/src/lib/Strategy/DefaultThumbnailStrategy.php b/src/lib/Strategy/DefaultThumbnailStrategy.php index c2b61c55..7ceb2b1e 100644 --- a/src/lib/Strategy/DefaultThumbnailStrategy.php +++ b/src/lib/Strategy/DefaultThumbnailStrategy.php @@ -14,24 +14,23 @@ use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -final class DefaultThumbnailStrategy implements ThumbnailStrategy +final readonly class DefaultThumbnailStrategy implements ThumbnailStrategy { - private const THUMBNAIL_MIME_TYPE = 'image/svg+xml'; - private const USER_TYPE_IDENTIFIER = 'ibexa_user'; - - private UrlGeneratorInterface $urlGenerator; - - /** @var string[] */ - private array $initialsFieldDefIdentifiers; + private const string THUMBNAIL_MIME_TYPE = 'image/svg+xml'; + private const string USER_TYPE_IDENTIFIER = 'ibexa_user'; + /** + * @param list $initialsFieldDefIdentifiers + */ public function __construct( - UrlGeneratorInterface $urlGenerator, - array $initialsFieldDefIdentifiers + private UrlGeneratorInterface $urlGenerator, + private array $initialsFieldDefIdentifiers ) { - $this->urlGenerator = $urlGenerator; - $this->initialsFieldDefIdentifiers = $initialsFieldDefIdentifiers; } + /** + * @param list<\Ibexa\Contracts\Core\Repository\Values\Content\Field> $fields + */ public function getThumbnail( ContentType $contentType, array $fields, @@ -51,6 +50,9 @@ public function getThumbnail( ]); } + /** + * @param list<\Ibexa\Contracts\Core\Repository\Values\Content\Field> $fields + */ private function getInitials(array $fields): string { $initials = ''; diff --git a/src/lib/Templating/Twig/DateTimeExtension.php b/src/lib/Templating/Twig/DateTimeExtension.php index 6a06c28c..e76b1ee5 100644 --- a/src/lib/Templating/Twig/DateTimeExtension.php +++ b/src/lib/Templating/Twig/DateTimeExtension.php @@ -11,109 +11,57 @@ use DateTimeImmutable; use DateTimeInterface; use Ibexa\User\UserSetting\DateTimeFormat\FormatterInterface; -use Ibexa\User\UserSetting\Setting\DateTimeFormatSerializer; use RuntimeException; use Twig\Extension\AbstractExtension; use Twig\TwigFilter; class DateTimeExtension extends AbstractExtension { - private DateTimeFormatSerializer $dateTimeFormatSerializer; - - private FormatterInterface $shortDateTimeFormatter; - - private FormatterInterface $shortDateFormatter; - - private FormatterInterface $shortTimeFormatter; - - private FormatterInterface $fullDateTimeFormatter; - - private FormatterInterface $fullDateFormatter; - - private FormatterInterface $fullTimeFormatter; - - /** - * @param \Ibexa\User\UserSetting\Setting\DateTimeFormatSerializer $dateTimeFormatSerializer - * @param \Ibexa\User\UserSetting\DateTimeFormat\FormatterInterface $shortDateTimeFormatter - * @param \Ibexa\User\UserSetting\DateTimeFormat\FormatterInterface $shortDateFormatter - * @param \Ibexa\User\UserSetting\DateTimeFormat\FormatterInterface $shortTimeFormatter - * @param \Ibexa\User\UserSetting\DateTimeFormat\FormatterInterface $fullDateTimeFormatter - * @param \Ibexa\User\UserSetting\DateTimeFormat\FormatterInterface $fullDateFormatter - * @param \Ibexa\User\UserSetting\DateTimeFormat\FormatterInterface $fullTimeFormatter - */ public function __construct( - DateTimeFormatSerializer $dateTimeFormatSerializer, - FormatterInterface $shortDateTimeFormatter, - FormatterInterface $shortDateFormatter, - FormatterInterface $shortTimeFormatter, - FormatterInterface $fullDateTimeFormatter, - FormatterInterface $fullDateFormatter, - FormatterInterface $fullTimeFormatter + private readonly FormatterInterface $shortDateTimeFormatter, + private readonly FormatterInterface $shortDateFormatter, + private readonly FormatterInterface $shortTimeFormatter, + private readonly FormatterInterface $fullDateTimeFormatter, + private readonly FormatterInterface $fullDateFormatter, + private readonly FormatterInterface $fullTimeFormatter ) { - $this->dateTimeFormatSerializer = $dateTimeFormatSerializer; - $this->shortDateTimeFormatter = $shortDateTimeFormatter; - $this->shortDateFormatter = $shortDateFormatter; - $this->shortTimeFormatter = $shortTimeFormatter; - $this->fullDateTimeFormatter = $fullDateTimeFormatter; - $this->fullDateFormatter = $fullDateFormatter; - $this->fullTimeFormatter = $fullTimeFormatter; } - /** - * {@inheritdoc} - */ + #[\Override] public function getFilters(): array { return [ new TwigFilter( 'ibexa_short_datetime', - function ($date, $timezone = null): string { - return $this->format($this->shortDateTimeFormatter, $date, $timezone); - } + fn ($date, $timezone = null): string => $this->format($this->shortDateTimeFormatter, $date, $timezone) ), new TwigFilter( 'ibexa_short_date', - function ($date, $timezone = null): string { - return $this->format($this->shortDateFormatter, $date, $timezone); - } + fn ($date, $timezone = null): string => $this->format($this->shortDateFormatter, $date, $timezone) ), new TwigFilter( 'ibexa_short_time', - function ($date, $timezone = null): string { - return $this->format($this->shortTimeFormatter, $date, $timezone); - } + fn ($date, $timezone = null): string => $this->format($this->shortTimeFormatter, $date, $timezone) ), new TwigFilter( 'ibexa_full_datetime', - function ($date, $timezone = null): string { - return $this->format($this->fullDateTimeFormatter, $date, $timezone); - } + fn ($date, $timezone = null): string => $this->format($this->fullDateTimeFormatter, $date, $timezone) ), new TwigFilter( 'ibexa_full_date', - function ($date, $timezone = null): string { - return $this->format($this->fullDateFormatter, $date, $timezone); - } + fn ($date, $timezone = null): string => $this->format($this->fullDateFormatter, $date, $timezone) ), new TwigFilter( 'ibexa_full_time', - function ($date, $timezone = null): string { - return $this->format($this->fullTimeFormatter, $date, $timezone); - } + fn ($date, $timezone = null): string => $this->format($this->fullTimeFormatter, $date, $timezone) ), ]; } /** - * @param \Ibexa\User\UserSetting\DateTimeFormat\FormatterInterface $formatter - * @param mixed|null $date - * @param string|null $timezone - * - * @return string - * * @throws \Exception */ - public function format(FormatterInterface $formatter, $date = null, string $timezone = null): string + public function format(FormatterInterface $formatter, mixed $date = null, ?string $timezone = null): string { if ($date === null) { $date = new DateTimeImmutable(); diff --git a/src/lib/Templating/Twig/InvitationExtension.php b/src/lib/Templating/Twig/InvitationExtension.php index ebc7c716..8a98670d 100644 --- a/src/lib/Templating/Twig/InvitationExtension.php +++ b/src/lib/Templating/Twig/InvitationExtension.php @@ -15,17 +15,12 @@ class InvitationExtension extends AbstractExtension { - private InvitationService $invitationService; - public function __construct( - InvitationService $invitationService + private readonly InvitationService $invitationService ) { - $this->invitationService = $invitationService; } - /** - * {@inheritdoc} - */ + #[\Override] public function getFunctions(): array { return [ diff --git a/src/lib/UserSetting/DateTimeFormat/AbstractDateTimeFormatterFactory.php b/src/lib/UserSetting/DateTimeFormat/AbstractDateTimeFormatterFactory.php index fb46d160..313c2e54 100644 --- a/src/lib/UserSetting/DateTimeFormat/AbstractDateTimeFormatterFactory.php +++ b/src/lib/UserSetting/DateTimeFormat/AbstractDateTimeFormatterFactory.php @@ -12,24 +12,13 @@ abstract class AbstractDateTimeFormatterFactory implements DateTimeFormatterFactoryInterface { - protected UserSettingService $userSettingService; - - /** - * @param \Ibexa\User\UserSetting\UserSettingService $userSettingService - */ - public function __construct(UserSettingService $userSettingService) - { - $this->userSettingService = $userSettingService; + public function __construct( + protected UserSettingService $userSettingService + ) { } - /** - * @return string - */ abstract protected function getFormat(): string; - /** - * {@inheritdoc} - */ public function getFormatter(): FormatterInterface { $language = $this->userSettingService->getUserSetting('language')->value; diff --git a/src/lib/UserSetting/DateTimeFormat/DateTimeFormatterFactoryInterface.php b/src/lib/UserSetting/DateTimeFormat/DateTimeFormatterFactoryInterface.php index bac998bf..3b1a1226 100644 --- a/src/lib/UserSetting/DateTimeFormat/DateTimeFormatterFactoryInterface.php +++ b/src/lib/UserSetting/DateTimeFormat/DateTimeFormatterFactoryInterface.php @@ -10,8 +10,5 @@ interface DateTimeFormatterFactoryInterface { - /** - * @return \Ibexa\User\UserSetting\DateTimeFormat\FormatterInterface - */ public function getFormatter(): FormatterInterface; } diff --git a/src/lib/UserSetting/DateTimeFormat/Formatter.php b/src/lib/UserSetting/DateTimeFormat/Formatter.php index 68604e01..6964050a 100644 --- a/src/lib/UserSetting/DateTimeFormat/Formatter.php +++ b/src/lib/UserSetting/DateTimeFormat/Formatter.php @@ -12,7 +12,7 @@ use IntlDateFormatter; use LogicException; -class Formatter implements FormatterInterface +readonly class Formatter implements FormatterInterface { private IntlDateFormatter $formatter; @@ -28,7 +28,7 @@ public function __construct(string $locale, string $timezone, string $format) ); } - public function format(DateTimeInterface $datetime, string $timezone = null): string + public function format(DateTimeInterface $datetime, ?string $timezone = null): string { if ($timezone) { $currentTimezone = $this->formatter->getTimeZone(); diff --git a/src/lib/UserSetting/DateTimeFormat/FormatterInterface.php b/src/lib/UserSetting/DateTimeFormat/FormatterInterface.php index 5b86b821..d8cef69c 100644 --- a/src/lib/UserSetting/DateTimeFormat/FormatterInterface.php +++ b/src/lib/UserSetting/DateTimeFormat/FormatterInterface.php @@ -12,11 +12,5 @@ interface FormatterInterface { - /** - * @param \DateTimeInterface $datetime - * @param string|null $timezone - * - * @return string - */ - public function format(DateTimeInterface $datetime, string $timezone = null): string; + public function format(DateTimeInterface $datetime, ?string $timezone = null): string; } diff --git a/src/lib/UserSetting/DateTimeFormat/FullDateFormatterFactory.php b/src/lib/UserSetting/DateTimeFormat/FullDateFormatterFactory.php index f00dd66b..6fdb5905 100644 --- a/src/lib/UserSetting/DateTimeFormat/FullDateFormatterFactory.php +++ b/src/lib/UserSetting/DateTimeFormat/FullDateFormatterFactory.php @@ -13,23 +13,13 @@ class FullDateFormatterFactory extends AbstractDateTimeFormatterFactory implements DateTimeFormatterFactoryInterface { - private DateTimeFormatSerializer $dateTimeFormatSerializer; - - /** - * @param \Ibexa\User\UserSetting\UserSettingService $userSettingService - * @param \Ibexa\User\UserSetting\Setting\DateTimeFormatSerializer $dateTimeFormatSerializer - */ public function __construct( UserSettingService $userSettingService, - DateTimeFormatSerializer $dateTimeFormatSerializer + private readonly DateTimeFormatSerializer $dateTimeFormatSerializer ) { parent::__construct($userSettingService); - $this->dateTimeFormatSerializer = $dateTimeFormatSerializer; } - /** - * {@inheritdoc} - */ protected function getFormat(): string { return (string)$this->dateTimeFormatSerializer->deserialize( diff --git a/src/lib/UserSetting/DateTimeFormat/FullDateTimeFormatterFactory.php b/src/lib/UserSetting/DateTimeFormat/FullDateTimeFormatterFactory.php index 9632ce77..4d652607 100644 --- a/src/lib/UserSetting/DateTimeFormat/FullDateTimeFormatterFactory.php +++ b/src/lib/UserSetting/DateTimeFormat/FullDateTimeFormatterFactory.php @@ -13,23 +13,13 @@ class FullDateTimeFormatterFactory extends AbstractDateTimeFormatterFactory implements DateTimeFormatterFactoryInterface { - private DateTimeFormatSerializer $dateTimeFormatSerializer; - - /** - * @param \Ibexa\User\UserSetting\UserSettingService $userSettingService - * @param \Ibexa\User\UserSetting\Setting\DateTimeFormatSerializer $dateTimeFormatSerializer - */ public function __construct( UserSettingService $userSettingService, - DateTimeFormatSerializer $dateTimeFormatSerializer + private readonly DateTimeFormatSerializer $dateTimeFormatSerializer ) { parent::__construct($userSettingService); - $this->dateTimeFormatSerializer = $dateTimeFormatSerializer; } - /** - * {@inheritdoc} - */ protected function getFormat(): string { return (string)$this->dateTimeFormatSerializer->deserialize( diff --git a/src/lib/UserSetting/DateTimeFormat/FullTimeFormatterFactory.php b/src/lib/UserSetting/DateTimeFormat/FullTimeFormatterFactory.php index 09e1909d..fab3ef22 100644 --- a/src/lib/UserSetting/DateTimeFormat/FullTimeFormatterFactory.php +++ b/src/lib/UserSetting/DateTimeFormat/FullTimeFormatterFactory.php @@ -13,23 +13,13 @@ class FullTimeFormatterFactory extends AbstractDateTimeFormatterFactory implements DateTimeFormatterFactoryInterface { - private DateTimeFormatSerializer $dateTimeFormatSerializer; - - /** - * @param \Ibexa\User\UserSetting\UserSettingService $userSettingService - * @param \Ibexa\User\UserSetting\Setting\DateTimeFormatSerializer $dateTimeFormatSerializer - */ public function __construct( UserSettingService $userSettingService, - DateTimeFormatSerializer $dateTimeFormatSerializer + private readonly DateTimeFormatSerializer $dateTimeFormatSerializer ) { parent::__construct($userSettingService); - $this->dateTimeFormatSerializer = $dateTimeFormatSerializer; } - /** - * {@inheritdoc} - */ protected function getFormat(): string { return (string)$this->dateTimeFormatSerializer->deserialize( diff --git a/src/lib/UserSetting/DateTimeFormat/ShortDateFormatterFactory.php b/src/lib/UserSetting/DateTimeFormat/ShortDateFormatterFactory.php index 9f95242a..2886b0df 100644 --- a/src/lib/UserSetting/DateTimeFormat/ShortDateFormatterFactory.php +++ b/src/lib/UserSetting/DateTimeFormat/ShortDateFormatterFactory.php @@ -13,23 +13,13 @@ class ShortDateFormatterFactory extends AbstractDateTimeFormatterFactory implements DateTimeFormatterFactoryInterface { - private DateTimeFormatSerializer $dateTimeFormatSerializer; - - /** - * @param \Ibexa\User\UserSetting\UserSettingService $userSettingService - * @param \Ibexa\User\UserSetting\Setting\DateTimeFormatSerializer $dateTimeFormatSerializer - */ public function __construct( UserSettingService $userSettingService, - DateTimeFormatSerializer $dateTimeFormatSerializer + private readonly DateTimeFormatSerializer $dateTimeFormatSerializer ) { parent::__construct($userSettingService); - $this->dateTimeFormatSerializer = $dateTimeFormatSerializer; } - /** - * {@inheritdoc} - */ protected function getFormat(): string { return (string)$this->dateTimeFormatSerializer->deserialize( diff --git a/src/lib/UserSetting/DateTimeFormat/ShortDateTimeFormatterFactory.php b/src/lib/UserSetting/DateTimeFormat/ShortDateTimeFormatterFactory.php index 672255d6..5d5a04ea 100644 --- a/src/lib/UserSetting/DateTimeFormat/ShortDateTimeFormatterFactory.php +++ b/src/lib/UserSetting/DateTimeFormat/ShortDateTimeFormatterFactory.php @@ -13,23 +13,13 @@ class ShortDateTimeFormatterFactory extends AbstractDateTimeFormatterFactory implements DateTimeFormatterFactoryInterface { - private DateTimeFormatSerializer $dateTimeFormatSerializer; - - /** - * @param \Ibexa\User\UserSetting\UserSettingService $userSettingService - * @param \Ibexa\User\UserSetting\Setting\DateTimeFormatSerializer $dateTimeFormatSerializer - */ public function __construct( UserSettingService $userSettingService, - DateTimeFormatSerializer $dateTimeFormatSerializer + private readonly DateTimeFormatSerializer $dateTimeFormatSerializer ) { parent::__construct($userSettingService); - $this->dateTimeFormatSerializer = $dateTimeFormatSerializer; } - /** - * {@inheritdoc} - */ protected function getFormat(): string { return (string)$this->dateTimeFormatSerializer->deserialize( diff --git a/src/lib/UserSetting/DateTimeFormat/ShortTimeFormatterFactory.php b/src/lib/UserSetting/DateTimeFormat/ShortTimeFormatterFactory.php index f71fe9d5..b283b934 100644 --- a/src/lib/UserSetting/DateTimeFormat/ShortTimeFormatterFactory.php +++ b/src/lib/UserSetting/DateTimeFormat/ShortTimeFormatterFactory.php @@ -13,23 +13,13 @@ class ShortTimeFormatterFactory extends AbstractDateTimeFormatterFactory implements DateTimeFormatterFactoryInterface { - private DateTimeFormatSerializer $dateTimeFormatSerializer; - - /** - * @param \Ibexa\User\UserSetting\UserSettingService $userSettingService - * @param \Ibexa\User\UserSetting\Setting\DateTimeFormatSerializer $dateTimeFormatSerializer - */ public function __construct( UserSettingService $userSettingService, - DateTimeFormatSerializer $dateTimeFormatSerializer + private readonly DateTimeFormatSerializer $dateTimeFormatSerializer ) { parent::__construct($userSettingService); - $this->dateTimeFormatSerializer = $dateTimeFormatSerializer; } - /** - * {@inheritdoc} - */ protected function getFormat(): string { return (string)$this->dateTimeFormatSerializer->deserialize( diff --git a/src/lib/UserSetting/FormMapperRegistry.php b/src/lib/UserSetting/FormMapperRegistry.php index 2ade0956..efd0620e 100644 --- a/src/lib/UserSetting/FormMapperRegistry.php +++ b/src/lib/UserSetting/FormMapperRegistry.php @@ -16,21 +16,14 @@ */ class FormMapperRegistry { - /** @var \Ibexa\Contracts\User\UserSetting\FormMapperInterface[] */ - protected $formMappers; - /** - * @param \Ibexa\Contracts\User\UserSetting\FormMapperInterface[] $formMappers + * @param array $formMappers */ - public function __construct(array $formMappers = []) - { - $this->formMappers = $formMappers; + public function __construct( + protected array $formMappers = [] + ) { } - /** - * @param string $identifier - * @param \Ibexa\Contracts\User\UserSetting\FormMapperInterface $formMapper - */ public function addFormMapper( string $identifier, FormMapperInterface $formMapper @@ -39,10 +32,6 @@ public function addFormMapper( } /** - * @param string $identifier - * - * @return \Ibexa\Contracts\User\UserSetting\FormMapperInterface - * * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentException */ public function getFormMapper(string $identifier): FormMapperInterface @@ -58,7 +47,7 @@ public function getFormMapper(string $identifier): FormMapperInterface } /** - * @return \Ibexa\Contracts\User\UserSetting\FormMapperInterface[] + * @return array */ public function getFormMappers(): array { diff --git a/src/lib/UserSetting/Group/AbstractGroup.php b/src/lib/UserSetting/Group/AbstractGroup.php index 6150273e..df1b5531 100644 --- a/src/lib/UserSetting/Group/AbstractGroup.php +++ b/src/lib/UserSetting/Group/AbstractGroup.php @@ -13,12 +13,12 @@ abstract class AbstractGroup implements ValueDefinitionGroupInterface { - /** @var array */ - protected array $values; - - public function __construct(array $values = []) - { - $this->values = $values; + /** + * @param array $values + */ + public function __construct( + protected array $values = [] + ) { } public function addValueDefinition(string $identifier, ValueDefinitionInterface $valueDefinition): void diff --git a/src/lib/UserSetting/Group/BrowsingGroup.php b/src/lib/UserSetting/Group/BrowsingGroup.php index 4a04dcac..3addd8de 100644 --- a/src/lib/UserSetting/Group/BrowsingGroup.php +++ b/src/lib/UserSetting/Group/BrowsingGroup.php @@ -8,18 +8,17 @@ namespace Ibexa\User\UserSetting\Group; -use JMS\TranslationBundle\Annotation\Desc; use Symfony\Contracts\Translation\TranslatorInterface; final class BrowsingGroup extends AbstractGroup { - private TranslatorInterface $translator; - + /** + * @param array $values + */ public function __construct( - TranslatorInterface $translator, + private readonly TranslatorInterface $translator, array $values = [] ) { - $this->translator = $translator; parent::__construct($values); } diff --git a/src/lib/UserSetting/Group/CustomGroup.php b/src/lib/UserSetting/Group/CustomGroup.php index 649fe9e4..1e06cc92 100644 --- a/src/lib/UserSetting/Group/CustomGroup.php +++ b/src/lib/UserSetting/Group/CustomGroup.php @@ -13,15 +13,15 @@ final class CustomGroup extends AbstractGroup { - public const CUSTOM_GROUP_IDENTIFIER = 'custom'; - - private TranslatorInterface $translator; + public const string CUSTOM_GROUP_IDENTIFIER = 'custom'; + /** + * @param array $values + */ public function __construct( - TranslatorInterface $translator, + private readonly TranslatorInterface $translator, array $values = [] ) { - $this->translator = $translator; parent::__construct($values); } diff --git a/src/lib/UserSetting/Group/EditContentGroup.php b/src/lib/UserSetting/Group/EditContentGroup.php index 2637f64c..93b00401 100644 --- a/src/lib/UserSetting/Group/EditContentGroup.php +++ b/src/lib/UserSetting/Group/EditContentGroup.php @@ -13,13 +13,13 @@ final class EditContentGroup extends AbstractGroup { - private TranslatorInterface $translator; - + /** + * @param array $values + */ public function __construct( - TranslatorInterface $translator, + private readonly TranslatorInterface $translator, array $values = [] ) { - $this->translator = $translator; parent::__construct($values); } diff --git a/src/lib/UserSetting/Group/LocationGroup.php b/src/lib/UserSetting/Group/LocationGroup.php index b30c7da8..e65bbedb 100644 --- a/src/lib/UserSetting/Group/LocationGroup.php +++ b/src/lib/UserSetting/Group/LocationGroup.php @@ -13,13 +13,13 @@ final class LocationGroup extends AbstractGroup { - private TranslatorInterface $translator; - + /** + * @param array $values + */ public function __construct( - TranslatorInterface $translator, + private readonly TranslatorInterface $translator, array $values = [] ) { - $this->translator = $translator; parent::__construct($values); } diff --git a/src/lib/UserSetting/Setting/AbstractDateTimeFormat.php b/src/lib/UserSetting/Setting/AbstractDateTimeFormat.php index 6b471c61..1c9ce50f 100644 --- a/src/lib/UserSetting/Setting/AbstractDateTimeFormat.php +++ b/src/lib/UserSetting/Setting/AbstractDateTimeFormat.php @@ -15,40 +15,22 @@ abstract class AbstractDateTimeFormat implements ValueDefinitionInterface, FormMapperInterface { - protected DateTimeFormatSerializer $serializer; - - /** @var \Ibexa\User\UserSetting\DateTimeFormat\Formatter|null */ - protected FormatterInterface $formatter; - - /** - * @param \Ibexa\User\UserSetting\Setting\DateTimeFormatSerializer $serializer - * @param \Ibexa\User\UserSetting\DateTimeFormat\FormatterInterface $formatter - */ - public function __construct(DateTimeFormatSerializer $serializer, FormatterInterface $formatter) - { - $this->serializer = $serializer; - $this->formatter = $formatter; + public function __construct( + protected DateTimeFormatSerializer $serializer, + protected FormatterInterface $formatter + ) { } - /** - * {@inheritdoc} - */ public function getName(): string { return $this->getTranslatedName(); } - /** - * {@inheritdoc} - */ public function getDescription(): string { return $this->getTranslatedDescription(); } - /** - * {@inheritdoc} - */ public function getDisplayValue(string $storageValue): string { $dateTimeFormat = $this->serializer->deserialize($storageValue); @@ -81,13 +63,7 @@ abstract protected function getAllowedTimeFormats(): array; */ abstract protected function getAllowedDateFormats(): array; - /** - * @return string - */ abstract protected function getTranslatedName(): string; - /** - * @return string - */ abstract protected function getTranslatedDescription(): string; } diff --git a/src/lib/UserSetting/Setting/CharacterCounter.php b/src/lib/UserSetting/Setting/CharacterCounter.php index 30059df6..d57e81c0 100644 --- a/src/lib/UserSetting/Setting/CharacterCounter.php +++ b/src/lib/UserSetting/Setting/CharacterCounter.php @@ -18,64 +18,41 @@ class CharacterCounter implements ValueDefinitionInterface, FormMapperInterface { - public const ENABLED_OPTION = 'enabled'; - public const DISABLED_OPTION = 'disabled'; + public const string ENABLED_OPTION = 'enabled'; + public const string DISABLED_OPTION = 'disabled'; - private TranslatorInterface $translator; - - /** - * @param \Symfony\Contracts\Translation\TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; + public function __construct( + private readonly TranslatorInterface $translator + ) { } - /** - * {@inheritdoc} - */ public function getName(): string { return $this->getTranslatedName(); } - /** - * {@inheritdoc} - */ public function getDescription(): string { return $this->getTranslatedDescription(); } - /** - * {@inheritdoc} - */ public function getDisplayValue(string $storageValue): string { - switch ($storageValue) { - case self::ENABLED_OPTION: - return $this->getTranslatedOptionEnabled(); - case self::DISABLED_OPTION: - return $this->getTranslatedOptionDisabled(); - default: - throw new InvalidArgumentException( - '$storageValue', - sprintf('There is no \'%s\' option', $storageValue) - ); - } + return match ($storageValue) { + self::ENABLED_OPTION => $this->getTranslatedOptionEnabled(), + self::DISABLED_OPTION => $this->getTranslatedOptionDisabled(), + default => throw new InvalidArgumentException( + '$storageValue', + sprintf('There is no \'%s\' option', $storageValue) + ), + }; } - /** - * {@inheritdoc} - */ public function getDefaultValue(): string { return 'enabled'; } - /** - * {@inheritdoc} - */ public function mapFieldForm(FormBuilderInterface $formBuilder, ValueDefinitionInterface $value): FormBuilderInterface { $choices = [ @@ -95,9 +72,6 @@ public function mapFieldForm(FormBuilderInterface $formBuilder, ValueDefinitionI ); } - /** - * @return string - */ private function getTranslatedName(): string { return $this->translator->trans( @@ -108,9 +82,6 @@ private function getTranslatedName(): string ); } - /** - * @return string - */ private function getTranslatedDescription(): string { return $this->translator->trans( @@ -121,9 +92,6 @@ private function getTranslatedDescription(): string ); } - /** - * @return string - */ private function getTranslatedOptionEnabled(): string { return $this->translator->trans( @@ -134,9 +102,6 @@ private function getTranslatedOptionEnabled(): string ); } - /** - * @return string - */ private function getTranslatedOptionDisabled(): string { return $this->translator->trans( diff --git a/src/lib/UserSetting/Setting/FullDateTimeFormat.php b/src/lib/UserSetting/Setting/FullDateTimeFormat.php index 9347cf1a..c6426df9 100644 --- a/src/lib/UserSetting/Setting/FullDateTimeFormat.php +++ b/src/lib/UserSetting/Setting/FullDateTimeFormat.php @@ -20,31 +20,15 @@ class FullDateTimeFormat extends AbstractDateTimeFormat { - private TranslatorInterface $translator; - - private ConfigResolverInterface $configResolver; - - /** - * @param \Ibexa\User\UserSetting\Setting\DateTimeFormatSerializer $serializer - * @param \Symfony\Contracts\Translation\TranslatorInterface $translator - * @param \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface $configResolver - * @param \Ibexa\User\UserSetting\DateTimeFormat\FormatterInterface $formatter - */ public function __construct( DateTimeFormatSerializer $serializer, - TranslatorInterface $translator, - ConfigResolverInterface $configResolver, + private readonly TranslatorInterface $translator, + private readonly ConfigResolverInterface $configResolver, FormatterInterface $formatter ) { parent::__construct($serializer, $formatter); - - $this->translator = $translator; - $this->configResolver = $configResolver; } - /** - * {@inheritdoc} - */ public function getDefaultValue(): string { $format = $this->configResolver->getParameter('user_preferences.full_datetime_format'); @@ -54,9 +38,6 @@ public function getDefaultValue(): string ); } - /** - * {@inheritdoc} - */ public function mapFieldForm( FormBuilderInterface $formBuilder, ValueDefinitionInterface $value @@ -74,9 +55,6 @@ public function mapFieldForm( return $form; } - /** - * {@inheritdoc} - */ protected function getTranslatedName(): string { return $this->translator->trans( @@ -87,9 +65,6 @@ protected function getTranslatedName(): string ); } - /** - * {@inheritdoc} - */ protected function getTranslatedDescription(): string { return $this->translator->trans( diff --git a/src/lib/UserSetting/Setting/Language.php b/src/lib/UserSetting/Setting/Language.php index aeb6a41c..f5c7020e 100644 --- a/src/lib/UserSetting/Setting/Language.php +++ b/src/lib/UserSetting/Setting/Language.php @@ -19,54 +19,28 @@ class Language implements ValueDefinitionInterface, FormMapperInterface { - private TranslatorInterface $translator; - - private UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider; - - private AvailableLocaleChoiceLoader $availableLocaleChoiceLoader; - - /** - * @param \Symfony\Contracts\Translation\TranslatorInterface $translator - * @param \Ibexa\Core\MVC\Symfony\Locale\UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider - * @param \Ibexa\User\Form\ChoiceList\Loader\AvailableLocaleChoiceLoader $availableLocaleChoiceLoader - */ public function __construct( - TranslatorInterface $translator, - UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider, - AvailableLocaleChoiceLoader $availableLocaleChoiceLoader + private readonly TranslatorInterface $translator, + private readonly UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider, + private readonly AvailableLocaleChoiceLoader $availableLocaleChoiceLoader ) { - $this->translator = $translator; - $this->userLanguagePreferenceProvider = $userLanguagePreferenceProvider; - $this->availableLocaleChoiceLoader = $availableLocaleChoiceLoader; } - /** - * {@inheritdoc} - */ public function getName(): string { return $this->getTranslatedName(); } - /** - * {@inheritdoc} - */ public function getDescription(): string { return $this->getTranslatedDescription(); } - /** - * {@inheritdoc} - */ public function getDisplayValue(string $storageValue): string { return $storageValue; } - /** - * {@inheritdoc} - */ public function getDefaultValue(): string { $defaultLocale = ''; @@ -81,9 +55,6 @@ public function getDefaultValue(): string return $defaultLocale; } - /** - * {@inheritdoc} - */ public function mapFieldForm(FormBuilderInterface $formBuilder, ValueDefinitionInterface $value): FormBuilderInterface { return $formBuilder->create( @@ -97,9 +68,6 @@ public function mapFieldForm(FormBuilderInterface $formBuilder, ValueDefinitionI ); } - /** - * @return string - */ private function getTranslatedName(): string { return $this->translator->trans( @@ -110,9 +78,6 @@ private function getTranslatedName(): string ); } - /** - * @return string - */ private function getTranslatedDescription(): string { return $this->translator->trans( diff --git a/src/lib/UserSetting/Setting/ShortDateTimeFormat.php b/src/lib/UserSetting/Setting/ShortDateTimeFormat.php index 98a71de7..4e11a7ae 100644 --- a/src/lib/UserSetting/Setting/ShortDateTimeFormat.php +++ b/src/lib/UserSetting/Setting/ShortDateTimeFormat.php @@ -20,30 +20,15 @@ class ShortDateTimeFormat extends AbstractDateTimeFormat { - private TranslatorInterface $translator; - - private ConfigResolverInterface $configResolver; - - /** - * @param \Ibexa\User\UserSetting\Setting\DateTimeFormatSerializer $serializer - * @param \Symfony\Contracts\Translation\TranslatorInterface $translator - * @param \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface $configResolver - * @param \Ibexa\User\UserSetting\DateTimeFormat\FormatterInterface $formatter - */ public function __construct( DateTimeFormatSerializer $serializer, - TranslatorInterface $translator, - ConfigResolverInterface $configResolver, + private readonly TranslatorInterface $translator, + private readonly ConfigResolverInterface $configResolver, FormatterInterface $formatter ) { parent::__construct($serializer, $formatter); - $this->translator = $translator; - $this->configResolver = $configResolver; } - /** - * {@inheritdoc} - */ public function getDefaultValue(): string { $format = $this->configResolver->getParameter('user_preferences.short_datetime_format'); @@ -53,9 +38,6 @@ public function getDefaultValue(): string ); } - /** - * {@inheritdoc} - */ public function mapFieldForm( FormBuilderInterface $formBuilder, ValueDefinitionInterface $value @@ -73,9 +55,6 @@ public function mapFieldForm( return $valueForm; } - /** - * {@inheritdoc} - */ protected function getTranslatedName(): string { return $this->translator->trans( @@ -86,9 +65,6 @@ protected function getTranslatedName(): string ); } - /** - * {@inheritdoc} - */ protected function getTranslatedDescription(): string { return $this->translator->trans( diff --git a/src/lib/UserSetting/Setting/SubitemsLimit.php b/src/lib/UserSetting/Setting/SubitemsLimit.php index 3a448225..6ba414d4 100644 --- a/src/lib/UserSetting/Setting/SubitemsLimit.php +++ b/src/lib/UserSetting/Setting/SubitemsLimit.php @@ -18,51 +18,32 @@ class SubitemsLimit implements ValueDefinitionInterface, FormMapperInterface { - private TranslatorInterface $translator; - - private ConfigResolverInterface $configResolver; - - public function __construct(TranslatorInterface $translator, ConfigResolverInterface $configResolver) - { - $this->translator = $translator; - $this->configResolver = $configResolver; + public function __construct( + private readonly TranslatorInterface $translator, + private readonly ConfigResolverInterface $configResolver + ) { } - /** - * {@inheritdoc} - */ public function getName(): string { return $this->getTranslatedName(); } - /** - * {@inheritdoc} - */ public function getDescription(): string { return $this->getTranslatedDescription(); } - /** - * {@inheritdoc} - */ public function getDisplayValue(string $storageValue): string { return $storageValue; } - /** - * {@inheritdoc} - */ public function getDefaultValue(): string { return (string)$this->configResolver->getParameter('subitems_module.limit'); } - /** - * {@inheritdoc} - */ public function mapFieldForm(FormBuilderInterface $formBuilder, ValueDefinitionInterface $value): FormBuilderInterface { return $formBuilder->create( @@ -76,9 +57,6 @@ public function mapFieldForm(FormBuilderInterface $formBuilder, ValueDefinitionI ); } - /** - * @return string - */ private function getTranslatedName(): string { return $this->translator->trans( @@ -89,9 +67,6 @@ private function getTranslatedName(): string ); } - /** - * @return string - */ private function getTranslatedDescription(): string { return $this->translator->trans( diff --git a/src/lib/UserSetting/Setting/Timezone.php b/src/lib/UserSetting/Setting/Timezone.php index e32a38d8..ec6ffa58 100644 --- a/src/lib/UserSetting/Setting/Timezone.php +++ b/src/lib/UserSetting/Setting/Timezone.php @@ -17,51 +17,31 @@ class Timezone implements ValueDefinitionInterface, FormMapperInterface { - private TranslatorInterface $translator; - - /** - * @param \Symfony\Contracts\Translation\TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; + public function __construct( + private readonly TranslatorInterface $translator + ) { } - /** - * {@inheritdoc} - */ public function getName(): string { return $this->getTranslatedName(); } - /** - * {@inheritdoc} - */ public function getDescription(): string { return $this->getTranslatedDescription(); } - /** - * {@inheritdoc} - */ public function getDisplayValue(string $storageValue): string { return $storageValue; } - /** - * {@inheritdoc} - */ public function getDefaultValue(): string { return date_default_timezone_get(); } - /** - * {@inheritdoc} - */ public function mapFieldForm(FormBuilderInterface $formBuilder, ValueDefinitionInterface $value): FormBuilderInterface { return $formBuilder->create( @@ -75,9 +55,6 @@ public function mapFieldForm(FormBuilderInterface $formBuilder, ValueDefinitionI ); } - /** - * @return string - */ private function getTranslatedName(): string { return $this->translator->trans( @@ -88,9 +65,6 @@ private function getTranslatedName(): string ); } - /** - * @return string - */ private function getTranslatedDescription(): string { return $this->translator->trans( diff --git a/src/lib/UserSetting/Setting/Value/DateTimeFormat.php b/src/lib/UserSetting/Setting/Value/DateTimeFormat.php index b9d1d1d1..4be4baeb 100644 --- a/src/lib/UserSetting/Setting/Value/DateTimeFormat.php +++ b/src/lib/UserSetting/Setting/Value/DateTimeFormat.php @@ -8,25 +8,14 @@ namespace Ibexa\User\UserSetting\Setting\Value; -final class DateTimeFormat +final class DateTimeFormat implements \Stringable { - private ?string $dateFormat; - - private ?string $timeFormat; - - /** - * @param string|null $dateFormat - * @param string|null $timeFormat - */ - public function __construct(?string $dateFormat = null, ?string $timeFormat = null) - { - $this->dateFormat = $dateFormat; - $this->timeFormat = $timeFormat; + public function __construct( + private ?string $dateFormat = null, + private ?string $timeFormat = null + ) { } - /** - * @return string|null - */ public function getDateFormat(): ?string { return $this->dateFormat; @@ -37,9 +26,6 @@ public function setDateFormat(?string $dateFormat): void $this->dateFormat = $dateFormat; } - /** - * @return string|null - */ public function getTimeFormat(): ?string { return $this->timeFormat; @@ -50,9 +36,6 @@ public function setTimeFormat(?string $timeFormat): void $this->timeFormat = $timeFormat; } - /** - * @return string - */ public function __toString(): string { $parts = []; diff --git a/src/lib/UserSetting/UserSetting.php b/src/lib/UserSetting/UserSetting.php index 5f3a0923..e86a4e29 100644 --- a/src/lib/UserSetting/UserSetting.php +++ b/src/lib/UserSetting/UserSetting.php @@ -18,17 +18,13 @@ */ class UserSetting extends ValueObject { - /** @var string */ - protected $identifier; + protected string $identifier; - /** @var string */ - protected $name; + protected string $name; - /** @var string */ - protected $description; + protected string $description; - /** @var string */ - protected $value; + protected string $value; public function getIdentifier(): string { diff --git a/src/lib/UserSetting/UserSettingArrayAccessor.php b/src/lib/UserSetting/UserSettingArrayAccessor.php index a09a41e1..2e77ecec 100644 --- a/src/lib/UserSetting/UserSettingArrayAccessor.php +++ b/src/lib/UserSetting/UserSettingArrayAccessor.php @@ -16,46 +16,29 @@ */ class UserSettingArrayAccessor implements ArrayAccess { - protected UserSettingService $userSettingService; - - /** - * @param \Ibexa\User\UserSetting\UserSettingService $userSettingService - */ - public function __construct(UserSettingService $userSettingService) - { - $this->userSettingService = $userSettingService; + public function __construct( + protected UserSettingService $userSettingService + ) { } - /** - * {@inheritdoc} - */ - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { // @todo refactor once UserSettingService supports this natively return null !== $this->userSettingService->getUserSetting($offset); } - /** - * {@inheritdoc} - */ - public function offsetGet($offset): string + public function offsetGet(mixed $offset): string { return $this->userSettingService->getUserSetting($offset)->value; } - /** - * {@inheritdoc} - */ - public function offsetSet($offset, $value): void + public function offsetSet(mixed $offset, mixed $value): void { $this->userSettingService->setUserSetting($offset, $value); } - /** - * {@inheritdoc} - */ - public function offsetUnset($offset): void + public function offsetUnset(mixed $offset): void { // UserSettingService doesn't provide this feature diff --git a/src/lib/UserSetting/UserSettingGroup.php b/src/lib/UserSetting/UserSettingGroup.php index 4ad67289..07914a7c 100644 --- a/src/lib/UserSetting/UserSettingGroup.php +++ b/src/lib/UserSetting/UserSettingGroup.php @@ -18,9 +18,12 @@ class UserSettingGroup extends ValueObject protected string $description; - /** @var array */ + /** @var list<\Ibexa\User\UserSetting\UserSetting> */ protected array $settings; + /** + * @param list<\Ibexa\User\UserSetting\UserSetting> $settings + */ public function __construct(string $identifier, string $name = '', string $description = '', array $settings = []) { parent::__construct([ @@ -46,6 +49,9 @@ public function getDescription(): string return $this->description; } + /** + * @return list<\Ibexa\User\UserSetting\UserSetting> + */ public function getSettings(): array { return $this->settings; diff --git a/src/lib/UserSetting/UserSettingService.php b/src/lib/UserSetting/UserSettingService.php index d8ada179..9f67b0f6 100644 --- a/src/lib/UserSetting/UserSettingService.php +++ b/src/lib/UserSetting/UserSettingService.php @@ -19,28 +19,15 @@ */ class UserSettingService { - protected UserPreferenceService $userPreferenceService; - - protected ValueDefinitionRegistry $valueRegistry; - - /** - * @param \Ibexa\Contracts\Core\Repository\UserPreferenceService $userPreferenceService - * @param \Ibexa\User\UserSetting\ValueDefinitionRegistry $valueRegistry - */ public function __construct( - UserPreferenceService $userPreferenceService, - ValueDefinitionRegistry $valueRegistry + protected UserPreferenceService $userPreferenceService, + protected ValueDefinitionRegistry $valueRegistry ) { - $this->userPreferenceService = $userPreferenceService; - $this->valueRegistry = $valueRegistry; } /** - * @param string $identifier - * @param string $value - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException - * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentException + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ public function setUserSetting(string $identifier, string $value): void { @@ -52,10 +39,6 @@ public function setUserSetting(string $identifier, string $value): void } /** - * @param string $identifier - * - * @return \Ibexa\User\UserSetting\UserSetting - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException */ @@ -68,6 +51,10 @@ public function getUserSetting(string $identifier): UserSetting return $this->createUserSetting($identifier, $valueDefinition, $userPreferenceValue); } + /** + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException + */ public function getUserSettingGroup(string $identifier): UserSettingGroup { $group = $this->valueRegistry->getValueDefinitionGroup($identifier); @@ -81,10 +68,7 @@ public function getUserSettingGroup(string $identifier): UserSettingGroup } /** - * @param int $offset - * @param int $limit - * - * @return array + * @return list<\Ibexa\User\UserSetting\UserSetting> * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException */ @@ -107,6 +91,11 @@ public function loadUserSettings(int $offset = 0, int $limit = 25): array return $userSettings; } + /** + * @return array + * + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException + */ public function loadGroupedUserSettings(): array { $groups = $this->valueRegistry->getValueDefinitionGroups(); @@ -123,14 +112,14 @@ public function loadGroupedUserSettings(): array return $settings; } - /** - * @return int - */ public function countUserSettings(): int { return $this->valueRegistry->countValueDefinitions(); } + /** + * @param array $userPreferences + */ private function createUserSettingsGroup( string $groupId, ValueDefinitionGroupInterface $group, @@ -149,13 +138,6 @@ private function createUserSettingsGroup( ); } - /** - * @param string $identifier - * @param \Ibexa\Contracts\User\UserSetting\ValueDefinitionInterface $value - * @param string $userPreferenceValue - * - * @return \Ibexa\User\UserSetting\UserSetting - */ private function createUserSetting( string $identifier, ValueDefinitionInterface $value, @@ -170,11 +152,6 @@ private function createUserSetting( } /** - * @param string $identifier - * @param \Ibexa\Contracts\User\UserSetting\ValueDefinitionInterface $value - * - * @return string - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException */ private function getUserSettingValue(string $identifier, ValueDefinitionInterface $value): string @@ -182,7 +159,7 @@ private function getUserSettingValue(string $identifier, ValueDefinitionInterfac try { $userPreference = $this->userPreferenceService->getUserPreference($identifier); $userPreferenceValue = $userPreference->value; - } catch (NotFoundException $e) { + } catch (NotFoundException) { $userPreferenceValue = $value->getDefaultValue(); } diff --git a/src/lib/UserSetting/ValueDefinitionGroupRegistryEntry.php b/src/lib/UserSetting/ValueDefinitionGroupRegistryEntry.php index 46978afe..46bf2b6e 100644 --- a/src/lib/UserSetting/ValueDefinitionGroupRegistryEntry.php +++ b/src/lib/UserSetting/ValueDefinitionGroupRegistryEntry.php @@ -19,14 +19,13 @@ */ final class ValueDefinitionGroupRegistryEntry implements IteratorAggregate { - private ValueDefinitionGroupInterface $definition; - - private array $valueDefinitions; - - public function __construct(ValueDefinitionGroupInterface $definition, array $valueDefinitions = []) - { - $this->definition = $definition; - $this->valueDefinitions = $valueDefinitions; + /** + * @param array $valueDefinitions + */ + public function __construct( + private readonly ValueDefinitionGroupInterface $definition, + private array $valueDefinitions = [] + ) { } public function addToValueDefinitions(string $identifier, ValueDefinitionInterface $valueDefinition): void @@ -34,6 +33,9 @@ public function addToValueDefinitions(string $identifier, ValueDefinitionInterfa $this->valueDefinitions[$identifier] = $valueDefinition; } + /** + * @return array + */ public function getValueDefinitions(): array { return $this->valueDefinitions; diff --git a/src/lib/UserSetting/ValueDefinitionRegistry.php b/src/lib/UserSetting/ValueDefinitionRegistry.php index a43c04a7..923a8585 100644 --- a/src/lib/UserSetting/ValueDefinitionRegistry.php +++ b/src/lib/UserSetting/ValueDefinitionRegistry.php @@ -11,33 +11,30 @@ use Ibexa\Contracts\User\UserSetting\ValueDefinitionGroupInterface; use Ibexa\Contracts\User\UserSetting\ValueDefinitionInterface; use Ibexa\Core\Base\Exceptions\InvalidArgumentException; -use Ibexa\User\UserSetting\Group\CustomGroup; /** * @internal */ class ValueDefinitionRegistry { - /** @var \Ibexa\Contracts\User\UserSetting\ValueDefinitionInterface[] */ + /** @var array */ protected array $valueDefinitions; - /** @var \Ibexa\Contracts\User\UserSetting\ValueDefinitionGroupInterface[] */ - protected $groupedDefinitions; + /** @var array */ + protected array $groupedDefinitions; - public function __construct(array $valueDefinitions = []) - { + /** + * @param array $valueDefinitions + */ + public function __construct( + array $valueDefinitions = [] + ) { $this->valueDefinitions = []; foreach ($valueDefinitions as $identifier => $valueDefinition) { $this->valueDefinitions[$identifier] = $valueDefinition; } - $this->groupedDefinitions[CustomGroup::CUSTOM_GROUP_IDENTIFIER] = $valueDefinitions; } - /** - * @param string $identifier - * @param \Ibexa\Contracts\User\UserSetting\ValueDefinitionInterface $valueDefinition - * @param int $priority - */ public function addValueDefinition( string $identifier, ValueDefinitionInterface $valueDefinition, @@ -60,16 +57,15 @@ public function addValueDefinitionGroup( $this->groupedDefinitions[$groupIdentifier] = $valueDefinition; } + /** + * @return array + */ public function getValueDefinitionGroups(): array { return $this->groupedDefinitions; } /** - * @param string $identifier - * - * @return \Ibexa\Contracts\User\UserSetting\ValueDefinitionInterface - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ public function getValueDefinition(string $identifier): ValueDefinitionInterface @@ -84,6 +80,9 @@ public function getValueDefinition(string $identifier): ValueDefinitionInterface return $this->valueDefinitions[$identifier]; } + /** + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException + */ public function getValueDefinitionGroup(string $identifier): ValueDefinitionGroupInterface { if (!isset($this->groupedDefinitions[$identifier])) { @@ -96,11 +95,6 @@ public function getValueDefinitionGroup(string $identifier): ValueDefinitionGrou return $this->groupedDefinitions[$identifier]; } - /** - * @param string $identifier - * - * @return bool - */ public function hasValueDefinition(string $identifier): bool { return isset($this->valueDefinitions[$identifier]); @@ -114,9 +108,6 @@ public function getValueDefinitions(): array return $this->valueDefinitions; } - /** - * @return int - */ public function countValueDefinitions(): int { return count($this->valueDefinitions); diff --git a/src/lib/UserSetting/ValueDefinitionRegistryEntry.php b/src/lib/UserSetting/ValueDefinitionRegistryEntry.php index 395cab30..307200dc 100644 --- a/src/lib/UserSetting/ValueDefinitionRegistryEntry.php +++ b/src/lib/UserSetting/ValueDefinitionRegistryEntry.php @@ -13,33 +13,19 @@ /** * @internal */ -final class ValueDefinitionRegistryEntry +final readonly class ValueDefinitionRegistryEntry { - private ValueDefinitionInterface $definition; - - private int $priority; - - /** - * @param \Ibexa\Contracts\User\UserSetting\ValueDefinitionInterface $definition - * @param int $priority - */ - public function __construct(ValueDefinitionInterface $definition, int $priority = 0) - { - $this->definition = $definition; - $this->priority = $priority; + public function __construct( + private ValueDefinitionInterface $definition, + private int $priority = 0 + ) { } - /** - * @return \Ibexa\Contracts\User\UserSetting\ValueDefinitionInterface - */ public function getDefinition(): ValueDefinitionInterface { return $this->definition; } - /** - * @return int - */ public function getPriority(): int { return $this->priority; diff --git a/src/lib/Validator/Constraints/EmailInvitationValidator.php b/src/lib/Validator/Constraints/EmailInvitationValidator.php index d3041e79..01026de6 100644 --- a/src/lib/Validator/Constraints/EmailInvitationValidator.php +++ b/src/lib/Validator/Constraints/EmailInvitationValidator.php @@ -15,25 +15,25 @@ class EmailInvitationValidator extends ConstraintValidator { - private UserService $userService; - - public function __construct(UserService $userService) - { - $this->userService = $userService; + public function __construct( + private readonly UserService $userService + ) { } /** * Checks if the passed value is valid. * - * @param string $email The value that should be validated + * @param mixed $email The value that should be validated * @param \Symfony\Component\Validator\Constraint $constraint The constraint for the validation */ - public function validate($email, Constraint $constraint): void + public function validate(mixed $email, Constraint $constraint): void { + assert(is_string($email)); + try { $this->userService->loadUserByEmail($email); $this->context->addViolation($constraint->message, ['%email%' => $email]); - } catch (NotFoundException $exception) { + } catch (NotFoundException) { // Do nothing } } diff --git a/src/lib/Validator/Constraints/Password.php b/src/lib/Validator/Constraints/Password.php index 73ae2793..c20956f7 100644 --- a/src/lib/Validator/Constraints/Password.php +++ b/src/lib/Validator/Constraints/Password.php @@ -23,9 +23,7 @@ class Password extends Constraint public ?User $user = null; - /** - * {@inheritdoc} - */ + #[\Override] public function getTargets(): array { return [self::CLASS_CONSTRAINT, self::PROPERTY_CONSTRAINT]; diff --git a/src/lib/Validator/Constraints/PasswordValidator.php b/src/lib/Validator/Constraints/PasswordValidator.php index ab75281e..6b76c4b8 100644 --- a/src/lib/Validator/Constraints/PasswordValidator.php +++ b/src/lib/Validator/Constraints/PasswordValidator.php @@ -16,11 +16,9 @@ class PasswordValidator extends ConstraintValidator { - private UserService $userService; - - public function __construct(UserService $userService) - { - $this->userService = $userService; + public function __construct( + private readonly UserService $userService + ) { } /** diff --git a/src/lib/Validator/Constraints/UserPassword.php b/src/lib/Validator/Constraints/UserPassword.php index db91ddda..f0d78239 100644 --- a/src/lib/Validator/Constraints/UserPassword.php +++ b/src/lib/Validator/Constraints/UserPassword.php @@ -17,7 +17,7 @@ */ class UserPassword extends Constraint implements TranslationContainerInterface { - public $message = 'ezplatform.change_user_password.not_match'; + public string $message = 'ezplatform.change_user_password.not_match'; /** * @return \JMS\TranslationBundle\Model\Message[] diff --git a/src/lib/Validator/Constraints/UserPasswordValidator.php b/src/lib/Validator/Constraints/UserPasswordValidator.php index b090f6ce..d135a547 100644 --- a/src/lib/Validator/Constraints/UserPasswordValidator.php +++ b/src/lib/Validator/Constraints/UserPasswordValidator.php @@ -20,27 +20,16 @@ */ class UserPasswordValidator extends ConstraintValidator { - private UserService $userService; - - private TokenStorageInterface $tokenStorage; - - /** - * @param \Ibexa\Contracts\Core\Repository\UserService $userService - * @param \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface $tokenStorage - */ - public function __construct(UserService $userService, TokenStorageInterface $tokenStorage) - { - $this->userService = $userService; - $this->tokenStorage = $tokenStorage; + public function __construct( + private readonly UserService $userService, + private readonly TokenStorageInterface $tokenStorage + ) { } /** * Checks if the passed password exists for logged user. - * - * @param string $password The password that should be validated - * @param \Symfony\Component\Validator\Constraint|\Ibexa\User\Validator\Constraints\UserPassword $constraint The constraint for the validation */ - public function validate($password, Constraint $constraint): void + public function validate(mixed $password, Constraint $constraint): void { if (null === $password || '' === $password) { $this->context->addViolation($constraint->message); @@ -48,6 +37,8 @@ public function validate($password, Constraint $constraint): void return; } + assert(is_string($password)); + $user = $this->tokenStorage->getToken()->getUser()->getAPIUser(); if (!$user instanceof User) { diff --git a/src/lib/View/UserSettings/Matcher/Identifier.php b/src/lib/View/UserSettings/Matcher/Identifier.php index 7fc0f178..7b790357 100644 --- a/src/lib/View/UserSettings/Matcher/Identifier.php +++ b/src/lib/View/UserSettings/Matcher/Identifier.php @@ -20,17 +20,11 @@ class Identifier implements ViewMatcherInterface /** @var string[] */ private array $identifiers = []; - /** - * {@inheritdoc} - */ - public function setMatchingConfig($matchingConfig): void + public function setMatchingConfig(mixed $matchingConfig): void { $this->identifiers = (array)$matchingConfig; } - /** - * {@inheritdoc} - */ public function match(View $view): bool { if (!$view instanceof UpdateView || $view->getUserSettingGroup() === null) { diff --git a/src/lib/View/UserSettings/UpdateView.php b/src/lib/View/UserSettings/UpdateView.php index 28d78bbd..d7548c0c 100644 --- a/src/lib/View/UserSettings/UpdateView.php +++ b/src/lib/View/UserSettings/UpdateView.php @@ -22,7 +22,7 @@ class UpdateView extends BaseView * @param array $parameters */ public function __construct( - $templateIdentifier = null, + ?string $templateIdentifier = null, array $parameters = [], string $viewType = 'full' ) { @@ -31,17 +31,11 @@ public function __construct( parent::__construct($templateIdentifier, $parameters, $viewType); } - /** - * @return \Ibexa\User\UserSetting\UserSetting|null - */ public function getUserSetting(): ?UserSetting { return $this->userSetting; } - /** - * @param \Ibexa\User\UserSetting\UserSetting|null $userSetting - */ public function setUserSetting(?UserSetting $userSetting): void { $this->userSetting = $userSetting; @@ -57,9 +51,7 @@ public function setUserSettingGroup(?UserSettingGroup $userSettingGroup): void $this->userSettingGroup = $userSettingGroup; } - /** - * {@inheritdoc} - */ + #[\Override] protected function getInternalParameters(): array { return [ diff --git a/src/lib/View/UserSettings/UpdateViewBuilder.php b/src/lib/View/UserSettings/UpdateViewBuilder.php index 3deb238f..7280cbf1 100644 --- a/src/lib/View/UserSettings/UpdateViewBuilder.php +++ b/src/lib/View/UserSettings/UpdateViewBuilder.php @@ -15,38 +15,18 @@ class UpdateViewBuilder implements ViewBuilder { - private UserSettingService $userSettingService; - - private Configurator $viewConfigurator; - - private ParametersInjector $viewParametersInjector; - - /** - * @param \Ibexa\User\UserSetting\UserSettingService $userSettingService - * @param \Ibexa\Core\MVC\Symfony\View\Configurator $viewConfigurator - * @param \Ibexa\Core\MVC\Symfony\View\ParametersInjector $viewParametersInjector - */ public function __construct( - UserSettingService $userSettingService, - Configurator $viewConfigurator, - ParametersInjector $viewParametersInjector + private readonly UserSettingService $userSettingService, + private readonly Configurator $viewConfigurator, + private readonly ParametersInjector $viewParametersInjector ) { - $this->userSettingService = $userSettingService; - $this->viewConfigurator = $viewConfigurator; - $this->viewParametersInjector = $viewParametersInjector; } - /** - * {@inheritdoc} - */ - public function matches($argument): bool + public function matches(mixed $argument): bool { return 'Ibexa\Bundle\User\Controller\UserSettingsController::updateAction' === $argument; } - /** - * {@inheritdoc} - */ public function buildView(array $parameters): UpdateView { $view = new UpdateView(); diff --git a/src/lib/View/UserSettings/UpdateViewProvider.php b/src/lib/View/UserSettings/UpdateViewProvider.php index 32e33558..1421fd24 100644 --- a/src/lib/View/UserSettings/UpdateViewProvider.php +++ b/src/lib/View/UserSettings/UpdateViewProvider.php @@ -15,20 +15,12 @@ class UpdateViewProvider implements ViewProvider { - protected MatcherFactoryInterface $matcherFactory; - - /** - * @param \Ibexa\Core\MVC\Symfony\Matcher\MatcherFactoryInterface $matcherFactory - */ - public function __construct(MatcherFactoryInterface $matcherFactory) - { - $this->matcherFactory = $matcherFactory; + public function __construct( + protected MatcherFactoryInterface $matcherFactory + ) { } - /** - * {@inheritdoc} - */ - public function getView(View $view) + public function getView(View $view): ?UpdateView { if (($configHash = $this->matcherFactory->match($view)) === null) { return null; @@ -38,9 +30,7 @@ public function getView(View $view) } /** - * @param array $viewConfig - * - * @return \Ibexa\User\View\UserSettings\UpdateView + * @param array $viewConfig * * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentType */ diff --git a/tests/bundle/DependencyInjection/Configuration/Parser/ChangePasswordTest.php b/tests/bundle/DependencyInjection/Configuration/Parser/ChangePasswordTest.php index d30682a8..ac8d9c82 100644 --- a/tests/bundle/DependencyInjection/Configuration/Parser/ChangePasswordTest.php +++ b/tests/bundle/DependencyInjection/Configuration/Parser/ChangePasswordTest.php @@ -25,6 +25,7 @@ protected function getContainerExtensions(): array ]; } + #[\Override] protected function getMinimalConfiguration(): array { return [ diff --git a/tests/bundle/DependencyInjection/Configuration/Parser/ForgotPasswordTest.php b/tests/bundle/DependencyInjection/Configuration/Parser/ForgotPasswordTest.php index fa6fd257..b86ef3a8 100644 --- a/tests/bundle/DependencyInjection/Configuration/Parser/ForgotPasswordTest.php +++ b/tests/bundle/DependencyInjection/Configuration/Parser/ForgotPasswordTest.php @@ -25,6 +25,7 @@ protected function getContainerExtensions(): array ]; } + #[\Override] protected function getMinimalConfiguration(): array { return [ diff --git a/tests/bundle/DependencyInjection/Configuration/Parser/ResetPasswordTest.php b/tests/bundle/DependencyInjection/Configuration/Parser/ResetPasswordTest.php index 41673548..12bdc5b9 100644 --- a/tests/bundle/DependencyInjection/Configuration/Parser/ResetPasswordTest.php +++ b/tests/bundle/DependencyInjection/Configuration/Parser/ResetPasswordTest.php @@ -25,6 +25,7 @@ protected function getContainerExtensions(): array ]; } + #[\Override] protected function getMinimalConfiguration(): array { return [ diff --git a/tests/integration/IbexaTestKernel.php b/tests/integration/IbexaTestKernel.php index ebdd6845..f61c034f 100644 --- a/tests/integration/IbexaTestKernel.php +++ b/tests/integration/IbexaTestKernel.php @@ -20,6 +20,7 @@ final class IbexaTestKernel extends BaseIbexaTestKernel { + #[\Override] public function getSchemaFiles(): iterable { yield from parent::getSchemaFiles(); @@ -29,6 +30,7 @@ public function getSchemaFiles(): iterable ]; } + #[\Override] public function registerBundles(): iterable { yield from parent::registerBundles(); @@ -39,6 +41,7 @@ public function registerBundles(): iterable ]; } + #[\Override] protected static function getExposedServicesByClass(): iterable { yield from parent::getExposedServicesByClass(); @@ -46,6 +49,7 @@ protected static function getExposedServicesByClass(): iterable yield InvitationService::class; } + #[\Override] public function registerContainerConfiguration(LoaderInterface $loader): void { parent::registerContainerConfiguration($loader); @@ -53,7 +57,7 @@ public function registerContainerConfiguration(LoaderInterface $loader): void $loader->load(static function (ContainerBuilder $container): void { $container->setParameter('locale_fallback', 'en'); - self::createSyntheticService($container, UserDispatcher::class); + self::createSyntheticService($container); $container->loadFromExtension('framework', [ 'router' => [ @@ -68,12 +72,10 @@ public function registerContainerConfiguration(LoaderInterface $loader): void * Additionally, those services can be replaced with mock implementations at runtime, allowing integration testing. * * You can set them up in KernelTestCase by calling `self::getContainer()->set($id, $this->createMock($class));` - * - * @phpstan-param class-string $class */ - private static function createSyntheticService(ContainerBuilder $container, string $class, ?string $id = null): void + private static function createSyntheticService(ContainerBuilder $container): void { - $id = $id ?? $class; + $id = UserDispatcher::class; if ($container->has($id)) { throw new LogicException(sprintf( 'Expected test kernel to not contain "%s" service. A real service should not be overwritten by a mock', @@ -81,7 +83,7 @@ private static function createSyntheticService(ContainerBuilder $container, stri )); } - $definition = new Definition($class); + $definition = new Definition(UserDispatcher::class); $definition->setSynthetic(true); $container->setDefinition($id, $definition); } diff --git a/tests/integration/Invitation/InvitationServiceTest.php b/tests/integration/Invitation/InvitationServiceTest.php index fb23fdb3..fb33f604 100644 --- a/tests/integration/Invitation/InvitationServiceTest.php +++ b/tests/integration/Invitation/InvitationServiceTest.php @@ -149,7 +149,7 @@ public function testMarkInvitationAsUsed(): void public function testRefreshInvitation(): void { ClockMock::register(Handler::class); - ClockMock::register(__CLASS__); + ClockMock::register(self::class); ClockMock::withClockMock(true); diff --git a/tests/lib/EventListener/PerformAccessCheckSubscriberTest.php b/tests/lib/EventListener/PerformAccessCheckSubscriberTest.php index f669de26..dc8160c1 100644 --- a/tests/lib/EventListener/PerformAccessCheckSubscriberTest.php +++ b/tests/lib/EventListener/PerformAccessCheckSubscriberTest.php @@ -10,6 +10,7 @@ use Ibexa\Tests\User\Stub\RestrictedControllerStub; use Ibexa\User\EventListener\PerformAccessCheckSubscriber; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Event\ControllerEvent; @@ -19,7 +20,7 @@ final class PerformAccessCheckSubscriberTest extends TestCase { private PerformAccessCheckSubscriber $subscriber; - private HttpKernelInterface $kernel; + private HttpKernelInterface&MockObject $kernel; private Request $request; diff --git a/tests/lib/Form/Type/ChoiceList/Loader/AvailableLocaleChoiceLoaderTest.php b/tests/lib/Form/Type/ChoiceList/Loader/AvailableLocaleChoiceLoaderTest.php index 40918499..dbcba446 100644 --- a/tests/lib/Form/Type/ChoiceList/Loader/AvailableLocaleChoiceLoaderTest.php +++ b/tests/lib/Form/Type/ChoiceList/Loader/AvailableLocaleChoiceLoaderTest.php @@ -34,11 +34,11 @@ protected function setUp(): void } /** - * @dataProvider providerForGetChoiceList + * @param array $availableTranslations + * @param array $additionalTranslations + * @param array $expectedLocales * - * @param array $availableTranslations - * @param array $additionalTranslations - * @param array $expectedLocales + * @dataProvider providerForGetChoiceList */ public function testGetChoiceList( array $availableTranslations, @@ -47,9 +47,7 @@ public function testGetChoiceList( ): void { $this->validator ->method('validate') - ->willReturnCallback(function ($locale): ConstraintViolationList { - return $locale === 'foo_BAR' ? new ConstraintViolationList([$this->constraintViolation]) : new ConstraintViolationList(); - }); + ->willReturnCallback(fn ($locale): ConstraintViolationList => $locale === 'foo_BAR' ? new ConstraintViolationList([$this->constraintViolation]) : new ConstraintViolationList()); $this->configResolver ->method('getParameter') @@ -65,6 +63,13 @@ public function testGetChoiceList( self::assertSame($expectedLocales, $availableLocaleChoiceLoader->getChoiceList()); } + /** + * @return array, + * 1: array, + * 2: array + * }> + */ public function providerForGetChoiceList(): array { return [ diff --git a/tests/lib/Invitation/InvitationServiceTest.php b/tests/lib/Invitation/InvitationServiceTest.php index ac10008e..3f9a1745 100644 --- a/tests/lib/Invitation/InvitationServiceTest.php +++ b/tests/lib/Invitation/InvitationServiceTest.php @@ -76,6 +76,13 @@ public function testIsValid( ); } + /** + * @return array + */ public function invitationProvider(): array { return [ diff --git a/tests/lib/Permission/UserPermissionsLimitationTypeTest.php b/tests/lib/Permission/UserPermissionsLimitationTypeTest.php index d8022e05..1059eb45 100644 --- a/tests/lib/Permission/UserPermissionsLimitationTypeTest.php +++ b/tests/lib/Permission/UserPermissionsLimitationTypeTest.php @@ -33,6 +33,11 @@ public function testAcceptValue(UserPermissionsLimitation $limitation): void (new UserPermissionsLimitationType($this->getPersistenceMock()))->acceptValue($limitation); } + /** + * @return array + */ public function providerForTestAcceptValue(): array { return [ @@ -78,6 +83,11 @@ public function testAcceptValueException(UserPermissionsLimitation $limitation): (new UserPermissionsLimitationType($this->getPersistenceMock()))->acceptValue($limitation); } + /** + * @return array + */ public function providerForTestAcceptValueException(): array { return [ @@ -178,10 +188,16 @@ public function testValidateError(UserPermissionsLimitation $limitation, int $er self::assertCount($errorCount, $validationErrors); } + /** + * @return array + */ public function providerForTestValidateError(): array { return [ - [ + 'roles_limitation_only' => [ new UserPermissionsLimitation([ 'limitationValues' => [ 'roles' => [4, 8], @@ -190,7 +206,7 @@ public function providerForTestValidateError(): array ]), 1, ], - [ + 'user_groups_limitation_only' => [ new UserPermissionsLimitation([ 'limitationValues' => [ 'roles' => null, @@ -199,7 +215,7 @@ public function providerForTestValidateError(): array ]), 1, ], - [ + 'both_limitations' => [ new UserPermissionsLimitation( [ 'limitationValues' => [ @@ -230,6 +246,13 @@ public function testEvaluate( self::assertEquals($expected, $value); } + /** + * @return array + */ public function providerForTestEvaluate(): array { return [ diff --git a/tests/lib/UserSetting/Setting/LanguageTest.php b/tests/lib/UserSetting/Setting/LanguageTest.php index 0a39aa10..243b5ea8 100644 --- a/tests/lib/UserSetting/Setting/LanguageTest.php +++ b/tests/lib/UserSetting/Setting/LanguageTest.php @@ -11,16 +11,15 @@ use Ibexa\Core\MVC\Symfony\Locale\UserLanguagePreferenceProviderInterface; use Ibexa\User\Form\ChoiceList\Loader\AvailableLocaleChoiceLoader; use Ibexa\User\UserSetting\Setting\Language; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Contracts\Translation\TranslatorInterface; final class LanguageTest extends TestCase { - /** @var \Ibexa\Core\MVC\Symfony\Locale\UserLanguagePreferenceProviderInterface&\PHPUnit\Framework\MockObject\MockObject */ - private UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider; + private UserLanguagePreferenceProviderInterface&MockObject $userLanguagePreferenceProvider; - /** @var \Ibexa\User\Form\ChoiceList\Loader\AvailableLocaleChoiceLoader&\PHPUnit\Framework\MockObject\MockObject */ - private AvailableLocaleChoiceLoader $availableLocaleChoiceLoader; + private AvailableLocaleChoiceLoader&MockObject $availableLocaleChoiceLoader; protected function setUp(): void { diff --git a/tests/lib/UserSetting/UserSettingServiceTest.php b/tests/lib/UserSetting/UserSettingServiceTest.php index 76c61f62..a2070fff 100644 --- a/tests/lib/UserSetting/UserSettingServiceTest.php +++ b/tests/lib/UserSetting/UserSettingServiceTest.php @@ -68,12 +68,6 @@ public function testLoadUserSettings(): void self::assertEquals($expected, $settings); } - /** - * @param string $name - * @param string $description - * - * @return \Ibexa\Contracts\User\UserSetting\ValueDefinitionInterface - */ private function getValueDefinition(string $name = 'name', string $description = 'description'): ValueDefinitionInterface { $valueDefinition = $this->createMock(ValueDefinitionInterface::class); diff --git a/tests/lib/Validator/Constraint/PasswordValidatorTest.php b/tests/lib/Validator/Constraint/PasswordValidatorTest.php index 51f69ab7..d2e611c1 100644 --- a/tests/lib/Validator/Constraint/PasswordValidatorTest.php +++ b/tests/lib/Validator/Constraint/PasswordValidatorTest.php @@ -40,7 +40,7 @@ protected function setUp(): void /** * @dataProvider dataProviderForValidateNotSupportedValueType */ - public function testValidateShouldBeSkipped(mixed $value): void + public function testValidateShouldBeSkipped(\stdClass|string|null $value): void { $this->userService ->expects(self::never()) @@ -140,6 +140,9 @@ public function testInvalid(): void ])); } + /** + * @return array + */ public function dataProviderForValidateNotSupportedValueType(): array { return [ diff --git a/tests/lib/Validator/Constraint/UserPasswordValidatorTest.php b/tests/lib/Validator/Constraint/UserPasswordValidatorTest.php index 2a0dda0e..3b9d377f 100644 --- a/tests/lib/Validator/Constraint/UserPasswordValidatorTest.php +++ b/tests/lib/Validator/Constraint/UserPasswordValidatorTest.php @@ -41,8 +41,6 @@ protected function setUp(): void /** * @dataProvider emptyDataProvider - * - * @param string|null $value */ public function testEmptyValueType(?string $value): void { @@ -59,6 +57,9 @@ public function testEmptyValueType(?string $value): void $this->validator->validate($value, new UserPassword()); } + /** + * @return array + */ public function emptyDataProvider(): array { return [