Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
540 changes: 0 additions & 540 deletions phpstan-baseline.neon

Large diffs are not rendered by default.

24 changes: 9 additions & 15 deletions src/bundle/Command/AuditUserDatabaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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));
}
}
Expand All @@ -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
{
Expand All @@ -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) {
Expand Down
4 changes: 1 addition & 3 deletions src/bundle/Command/UpdateUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions src/bundle/Controller/DefaultProfileImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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');
Expand Down
32 changes: 8 additions & 24 deletions src/bundle/Controller/PasswordChangeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, list<string>> $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
Expand Down
54 changes: 10 additions & 44 deletions src/bundle/Controller/PasswordResetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand All @@ -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;
}

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
31 changes: 13 additions & 18 deletions src/bundle/Controller/UserInvitationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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',
Expand Down
32 changes: 6 additions & 26 deletions src/bundle/Controller/UserRegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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'));

Expand Down
36 changes: 8 additions & 28 deletions src/bundle/Controller/UserSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Loading