diff --git a/.github/workflows/browser-tests.yaml b/.github/workflows/browser-tests.yaml index 63ca8502..687cff07 100644 --- a/.github/workflows/browser-tests.yaml +++ b/.github/workflows/browser-tests.yaml @@ -16,6 +16,9 @@ jobs: test-suite: '--profile=browser --suite=password' secrets: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + AUTOMATION_CLIENT_ID: ${{ secrets.AUTOMATION_CLIENT_ID }} + AUTOMATION_CLIENT_INSTALLATION: ${{ secrets.AUTOMATION_CLIENT_INSTALLATION }} + AUTOMATION_CLIENT_SECRET: ${{ secrets.AUTOMATION_CLIENT_SECRET }} login-providers: name: "User login providers tests" uses: ibexa/gh-workflows/.github/workflows/browser-tests.yml@main @@ -25,3 +28,6 @@ jobs: test-setup-phase-1: '--mode=standard --profile=setup --suite=login-methods' secrets: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + AUTOMATION_CLIENT_ID: ${{ secrets.AUTOMATION_CLIENT_ID }} + AUTOMATION_CLIENT_INSTALLATION: ${{ secrets.AUTOMATION_CLIENT_INSTALLATION }} + AUTOMATION_CLIENT_SECRET: ${{ secrets.AUTOMATION_CLIENT_SECRET }} diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 6545c8aa..3176e5e5 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -66,6 +66,12 @@ parameters: count: 1 path: src/bundle/Controller/PasswordResetController.php + - + message: '#^Parameter \#1 \$email of class Ibexa\\Contracts\\User\\Invitation\\InvitationCreateStruct constructor expects string, string\|null given\.$#' + identifier: argument.type + count: 1 + path: src/bundle/Controller/UserInvitationController.php + - message: '#^Call to an undefined method Symfony\\Component\\Form\\FormInterface\\:\:getClickedButton\(\)\.$#' identifier: method.notFound @@ -420,12 +426,6 @@ 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 @@ -588,12 +588,6 @@ parameters: count: 1 path: src/lib/Form/DataTransformer/LimitationValueTransformer.php - - - message: '#^Cannot call method getContentType\(\) on Ibexa\\User\\Form\\Data\\UserPasswordResetData\|null\.$#' - identifier: method.nonObject - count: 1 - path: src/lib/Form/Factory/FormFactory.php - - message: '#^Method Ibexa\\User\\Form\\Factory\\FormFactory\:\:changeUserPassword\(\) return type with generic interface Symfony\\Component\\Form\\FormInterface does not specify its types\: TData$#' identifier: missingType.generics diff --git a/src/contracts/Notification/UserPasswordReset.php b/src/contracts/Notification/UserPasswordReset.php index a4c50e43..9bfea639 100644 --- a/src/contracts/Notification/UserPasswordReset.php +++ b/src/contracts/Notification/UserPasswordReset.php @@ -33,12 +33,12 @@ public function __construct( $this->token = $token; } - public function asEmailMessage(EmailRecipientInterface $recipient, string $transport = null): ?EmailMessage + public function asEmailMessage(EmailRecipientInterface $recipient, ?string $transport = null): ?EmailMessage { return null; } - public function asSmsMessage(SmsRecipientInterface $recipient, string $transport = null): ?SmsMessage + public function asSmsMessage(SmsRecipientInterface $recipient, ?string $transport = null): ?SmsMessage { return null; } diff --git a/src/contracts/Notification/UserRegister.php b/src/contracts/Notification/UserRegister.php index 2f07fb5b..b096db96 100644 --- a/src/contracts/Notification/UserRegister.php +++ b/src/contracts/Notification/UserRegister.php @@ -28,12 +28,12 @@ public function __construct(User $user) $this->user = $user; } - public function asEmailMessage(EmailRecipientInterface $recipient, string $transport = null): ?EmailMessage + public function asEmailMessage(EmailRecipientInterface $recipient, ?string $transport = null): ?EmailMessage { return null; } - public function asSmsMessage(SmsRecipientInterface $recipient, string $transport = null): ?SmsMessage + public function asSmsMessage(SmsRecipientInterface $recipient, ?string $transport = null): ?SmsMessage { return null; } diff --git a/src/lib/EventListener/ViewTemplatesListener.php b/src/lib/EventListener/ViewTemplatesListener.php index 49df3bf2..4199c865 100644 --- a/src/lib/EventListener/ViewTemplatesListener.php +++ b/src/lib/EventListener/ViewTemplatesListener.php @@ -68,7 +68,7 @@ public function setViewTemplates(PreContentViewEvent $event): void } /** - * @return string[] + * @return array */ private function getTemplatesMap(): array { diff --git a/src/lib/Form/Data/UserInvitationData.php b/src/lib/Form/Data/UserInvitationData.php index 8f52141b..07b874e5 100644 --- a/src/lib/Form/Data/UserInvitationData.php +++ b/src/lib/Form/Data/UserInvitationData.php @@ -21,7 +21,7 @@ final class UserInvitationData * * @Assert\Email() */ - private string $email; + private ?string $email; private ?Role $role; @@ -44,8 +44,8 @@ final class UserInvitationData private ?array $limitationValue; public function __construct( - string $email = null, - SiteAccess $siteaccess = null, + ?string $email = null, + ?SiteAccess $siteaccess = null, ?Role $role = null, ?UserGroup $userGroup = null, ?array $sections = null, @@ -85,7 +85,7 @@ public function setLimitationValue(?array $limitationValue): void $this->limitationValue = $limitationValue; } - public function getEmail(): string + public function getEmail(): ?string { return $this->email; } diff --git a/src/lib/Form/Factory/FormFactory.php b/src/lib/Form/Factory/FormFactory.php index 94827388..a6f845d9 100644 --- a/src/lib/Form/Factory/FormFactory.php +++ b/src/lib/Form/Factory/FormFactory.php @@ -20,6 +20,7 @@ use Ibexa\User\Form\Type\UserPasswordForgotWithLoginType; use Ibexa\User\Form\Type\UserPasswordResetType; use Ibexa\User\Form\Type\UserSettingUpdateType; +use InvalidArgumentException; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\Util\StringUtil; @@ -45,7 +46,7 @@ public function __construct(FormFactoryInterface $formFactory, UrlGeneratorInter public function changeUserPassword( ContentType $contentType, - UserPasswordChangeData $data = null, + ?UserPasswordChangeData $data = null, ?string $name = null, ?User $user = null ): FormInterface { @@ -71,7 +72,7 @@ public function changeUserPassword( * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function forgotUserPassword( - UserPasswordForgotData $data = null, + ?UserPasswordForgotData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(UserPasswordForgotType::class); @@ -88,7 +89,7 @@ public function forgotUserPassword( * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function forgotUserPasswordWithLogin( - UserPasswordForgotWithLoginData $data = null, + ?UserPasswordForgotWithLoginData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(UserPasswordForgotWithLoginType::class); @@ -97,21 +98,19 @@ 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( - UserPasswordResetData $data = null, + ?UserPasswordResetData $data = null, ?string $name = null, ?ContentType $contentType = null, ?User $user = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(UserPasswordResetType::class); + if (null === $data) { + throw new InvalidArgumentException('UserPasswordResetData is required for resetting user password'); + } $userContentType = $contentType ?? $data->getContentType(); return $this->formFactory->createNamed( @@ -127,7 +126,7 @@ public function resetUserPassword( public function updateUserSetting( string $userSettingIdentifier, - UserSettingUpdateData $data = null, + ?UserSettingUpdateData $data = null, ?string $name = null ): FormInterface { $name = $name ?: StringUtil::fqcnToBlockPrefix(UserSettingUpdateType::class); diff --git a/src/lib/Permission/UserPermissionsLimitationType.php b/src/lib/Permission/UserPermissionsLimitationType.php index 45f07b47..d85492b4 100644 --- a/src/lib/Permission/UserPermissionsLimitationType.php +++ b/src/lib/Permission/UserPermissionsLimitationType.php @@ -148,7 +148,7 @@ public function buildValue(array $limitationValues) * * @return bool */ - public function evaluate(APILimitationValue $value, APIUserReference $currentUser, ValueObject $object, array $targets = null) + public function evaluate(APILimitationValue $value, APIUserReference $currentUser, ValueObject $object, ?array $targets = null) { if (!$value instanceof UserPermissionsLimitation) { throw new InvalidArgumentException('$value', 'Must be of type: APISiteAccessLimitation'); diff --git a/src/lib/Templating/Twig/DateTimeExtension.php b/src/lib/Templating/Twig/DateTimeExtension.php index 08ee75aa..64757f29 100644 --- a/src/lib/Templating/Twig/DateTimeExtension.php +++ b/src/lib/Templating/Twig/DateTimeExtension.php @@ -178,7 +178,7 @@ function ($date, $timezone = null) { * * @throws \Exception */ - public function format(FormatterInterface $formatter, $date = null, string $timezone = null): string + public function format(FormatterInterface $formatter, $date = null, ?string $timezone = null): string { if ($date === null) { $date = new DateTimeImmutable(); diff --git a/src/lib/UserSetting/DateTimeFormat/Formatter.php b/src/lib/UserSetting/DateTimeFormat/Formatter.php index 0995b1b3..7ce906d5 100644 --- a/src/lib/UserSetting/DateTimeFormat/Formatter.php +++ b/src/lib/UserSetting/DateTimeFormat/Formatter.php @@ -36,7 +36,7 @@ public function __construct(string $locale, string $timezone, string $format) /** * {@inheritdoc} */ - 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 25e5e8e9..837071c0 100644 --- a/src/lib/UserSetting/DateTimeFormat/FormatterInterface.php +++ b/src/lib/UserSetting/DateTimeFormat/FormatterInterface.php @@ -18,7 +18,7 @@ interface FormatterInterface * * @return string */ - public function format(DateTimeInterface $datetime, string $timezone = null): string; + public function format(DateTimeInterface $datetime, ?string $timezone = null): string; } class_alias(FormatterInterface::class, 'EzSystems\EzPlatformUser\UserSetting\DateTimeFormat\FormatterInterface');