Skip to content

Commit

Permalink
DISPLAY-1030: Applied rector LevelSetList::UP_TO_PHP_81
Browse files Browse the repository at this point in the history
  • Loading branch information
turegjorup committed Nov 23, 2023
1 parent 7c840ab commit 90646e4
Show file tree
Hide file tree
Showing 101 changed files with 292 additions and 376 deletions.
4 changes: 1 addition & 3 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@

require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

return function (array $context) {
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};
return fn (array $context) => new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
19 changes: 13 additions & 6 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
use Rector\Config\RectorConfig;
use Rector\Doctrine\Set\DoctrineSetList;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Symfony\Set\SymfonySetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/config',
__DIR__ . '/public',
__DIR__ . '/src',
__DIR__ . '/tests',
__DIR__.'/config',
__DIR__.'/public',
__DIR__.'/src',
__DIR__.'/tests',
]);

// register a single rule
Expand All @@ -21,7 +22,13 @@
// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_81,
DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
DoctrineSetList::DOCTRINE_DBAL_30,
// DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
// DoctrineSetList::DOCTRINE_DBAL_30,
// DoctrineSetList::DOCTRINE_ORM_214,
// DoctrineSetList::DOCTRINE_CODE_QUALITY,
// SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES,
// SymfonySetList::SYMFONY_63,
// SymfonySetList::SYMFONY_CODE_QUALITY,
// SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION,
]);
};
10 changes: 5 additions & 5 deletions src/Command/Feed/CreateFeedSourceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
class CreateFeedSourceCommand extends Command
{
public function __construct(
private EntityManagerInterface $entityManager,
private FeedService $feedService,
private FeedSourceRepository $feedSourceRepository,
private TenantRepository $tenantRepository
private readonly EntityManagerInterface $entityManager,
private readonly FeedService $feedService,
private readonly FeedSourceRepository $feedSourceRepository,
private readonly TenantRepository $tenantRepository
) {
parent::__construct();
}
Expand Down Expand Up @@ -135,7 +135,7 @@ final protected function execute(InputInterface $input, OutputInterface $output)
$feedSource->setSupportedFeedOutputType($feedType->getSupportedFeedOutputType());
$feedSource->setTenant($tenant);

$secretsString = implode(array_map(function ($key) use ($secrets) {
$secretsString = implode('', array_map(function ($key) use ($secrets) {
$value = $secrets[$key];

return " - $key: $value\n";
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Feed/GetFeedTypesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class GetFeedTypesCommand extends Command
{
public function __construct(
private FeedService $feedService
private readonly FeedService $feedService
) {
parent::__construct();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Feed/ListFeedSourceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class ListFeedSourceCommand extends Command
{
public function __construct(
private FeedSourceRepository $feedSourceRepository,
private readonly FeedSourceRepository $feedSourceRepository,
) {
parent::__construct();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Command/Feed/RemoveFeedSourceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
class RemoveFeedSourceCommand extends Command
{
public function __construct(
private EntityManagerInterface $entityManager,
private FeedSourceRepository $feedSourceRepository,
private FeedRepository $feedRepository
private readonly EntityManagerInterface $entityManager,
private readonly FeedSourceRepository $feedSourceRepository,
private readonly FeedRepository $feedRepository
) {
parent::__construct();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Command/LoadTemplateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
class LoadTemplateCommand extends Command
{
public function __construct(
private EntityManagerInterface $entityManager
private readonly EntityManagerInterface $entityManager
) {
parent::__construct();
}
Expand Down Expand Up @@ -75,7 +75,7 @@ final protected function execute(InputInterface $input, OutputInterface $output)

if (!$template) {
$template = new Template();
$metadata = $this->entityManager->getClassMetaData(get_class($template));
$metadata = $this->entityManager->getClassMetaData($template::class);
$metadata->setIdGenerator(new AssignedGenerator());

$ulid = Ulid::fromString($content->id);
Expand All @@ -97,7 +97,7 @@ final protected function execute(InputInterface $input, OutputInterface $output)
$io->success($successMessage);

return Command::SUCCESS;
} catch (\JsonException $exception) {
} catch (\JsonException) {
$io->error('Invalid json');

return Command::INVALID;
Expand Down
12 changes: 6 additions & 6 deletions src/Command/Screen/LoadScreenLayoutsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
class LoadScreenLayoutsCommand extends Command
{
public function __construct(
private EntityManagerInterface $entityManager,
private ScreenLayoutRepository $screenLayoutRepository,
private ScreenLayoutRegionsRepository $layoutRegionsRepository,
private readonly EntityManagerInterface $entityManager,
private readonly ScreenLayoutRepository $screenLayoutRepository,
private readonly ScreenLayoutRegionsRepository $layoutRegionsRepository,
) {
parent::__construct();
}
Expand Down Expand Up @@ -60,7 +60,7 @@ final protected function execute(InputInterface $input, OutputInterface $output)

if (!$screenLayout) {
$screenLayout = new ScreenLayout();
$metadata = $this->entityManager->getClassMetaData(get_class($screenLayout));
$metadata = $this->entityManager->getClassMetaData($screenLayout::class);
$metadata->setIdGenerator(new AssignedGenerator());

$ulid = Ulid::fromString($content->id);
Expand Down Expand Up @@ -97,7 +97,7 @@ final protected function execute(InputInterface $input, OutputInterface $output)
if (!$region) {
$region = new ScreenLayoutRegions();

$metadata = $this->entityManager->getClassMetaData(get_class($region));
$metadata = $this->entityManager->getClassMetaData($region::class);
$metadata->setIdGenerator(new AssignedGenerator());

$ulid = Ulid::fromString($localRegion->id);
Expand Down Expand Up @@ -143,7 +143,7 @@ final protected function execute(InputInterface $input, OutputInterface $output)
$io->success('Screen layout added.');

return Command::SUCCESS;
} catch (\JsonException $exception) {
} catch (\JsonException) {
$io->error('Invalid json');

return Command::INVALID;
Expand Down
8 changes: 4 additions & 4 deletions src/Command/Screen/RemoveScreenLayoutCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
class RemoveScreenLayoutCommand extends Command
{
public function __construct(
private EntityManagerInterface $entityManager,
private ScreenLayoutRepository $screenLayoutRepository,
private ScreenRepository $screenRepository
private readonly EntityManagerInterface $entityManager,
private readonly ScreenLayoutRepository $screenLayoutRepository,
private readonly ScreenRepository $screenRepository
) {
parent::__construct();
}
Expand Down Expand Up @@ -83,7 +83,7 @@ final protected function execute(InputInterface $input, OutputInterface $output)
$io->success('Screen layout removed');

return Command::SUCCESS;
} catch (\JsonException $exception) {
} catch (\JsonException) {
$io->error('Invalid json');

return Command::INVALID;
Expand Down
8 changes: 4 additions & 4 deletions src/Command/Tenant/AddTenantCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ class AddTenantCommand extends Command
private const DESCRIPTION_ARGUMENT = 'description';

public function __construct(
private EntityManagerInterface $entityManager,
private CommandInputValidator $validator,
private TenantRepository $tenants
private readonly EntityManagerInterface $entityManager,
private readonly CommandInputValidator $validator,
private readonly TenantRepository $tenants
) {
parent::__construct();
}
Expand Down Expand Up @@ -115,7 +115,7 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
if (null !== $tenantKey) {
$io->text(' > <info>Tenant Key</info>: '.$tenantKey);
} else {
$tenantKey = $io->ask('Tenant Key', null, [$this->validator, 'validateTenantKey']);
$tenantKey = $io->ask('Tenant Key', null, $this->validator->validateTenantKey(...));
$input->setArgument(self::TENANT_KEY_ARGUMENT, $tenantKey);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Command/Tenant/ConfigureTenantCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
class ConfigureTenantCommand extends Command
{
public function __construct(
private EntityManagerInterface $entityManager,
private TenantRepository $tenantRepository
private readonly EntityManagerInterface $entityManager,
private readonly TenantRepository $tenantRepository
) {
parent::__construct();
}
Expand Down
20 changes: 10 additions & 10 deletions src/Command/User/AddUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ class AddUserCommand extends Command
private const TENANT_KEYS_ARGUMENT = 'tenant-keys';

public function __construct(
private EntityManagerInterface $entityManager,
private UserPasswordHasherInterface $passwordHasher,
private CommandInputValidator $validator,
private UserRepository $users,
private TenantRepository $tenantRepository
private readonly EntityManagerInterface $entityManager,
private readonly UserPasswordHasherInterface $passwordHasher,
private readonly CommandInputValidator $validator,
private readonly UserRepository $users,
private readonly TenantRepository $tenantRepository
) {
parent::__construct();
}
Expand Down Expand Up @@ -132,7 +132,7 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
if (null !== $email) {
$io->text(' > <info>Email</info>: '.$email);
} else {
$email = $io->ask('Email', null, [$this->validator, 'validateEmail']);
$email = $io->ask('Email', null, $this->validator->validateEmail(...));
$input->setArgument(self::EMAIL_ARGUMENT, $email);
}

Expand All @@ -141,7 +141,7 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
if (null !== $password) {
$io->text(' > <info>Password</info>: '.u('*')->repeat(u($password)->length()));
} else {
$password = $io->askHidden('Password (your type will be hidden)', [$this->validator, 'validatePassword']);
$password = $io->askHidden('Password (your type will be hidden)', $this->validator->validatePassword(...));
$input->setArgument(self::PASSWORD_ARGUMENT, $password);
}

Expand All @@ -150,7 +150,7 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
if (null !== $fullName) {
$io->text(' > <info>Full Name</info>: '.$fullName);
} else {
$fullName = $io->ask('Full Name', null, [$this->validator, 'validateFullName']);
$fullName = $io->ask('Full Name', null, $this->validator->validateFullName(...));
$input->setArgument(self::FULL_NAME_ARGUMENT, $fullName);
}

Expand Down Expand Up @@ -228,14 +228,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$tenant = $this->tenantRepository->findOneBy(['tenantKey' => $tenantKey]);
$userRoleTenant = new UserRoleTenant();
$userRoleTenant->setTenant($tenant);
$userRoleTenant->setRoles(['ROLE_'.strtoupper($role)]);
$userRoleTenant->setRoles(['ROLE_'.strtoupper((string) $role)]);
$user->addUserRoleTenant($userRoleTenant);
}

$this->entityManager->persist($user);
$this->entityManager->flush();

$io->success(sprintf('%s was successfully created: %s', ucfirst($role), $user->getUserIdentifier()));
$io->success(sprintf('%s was successfully created: %s', ucfirst((string) $role), $user->getUserIdentifier()));

$event = $stopwatch->stop('add-user-command');
if ($output->isVerbose()) {
Expand Down
10 changes: 5 additions & 5 deletions src/Controller/AuthOidcController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
class AuthOidcController extends AbstractController
{
public function __construct(
private OpenIdConfigurationProviderManager $configurationProviderManager,
private AzureOidcAuthenticator $oidcAuthenticator,
private AuthenticationSuccessHandler $successHandler,
private AuthenticationFailureHandler $failureHandler
private readonly OpenIdConfigurationProviderManager $configurationProviderManager,
private readonly AzureOidcAuthenticator $oidcAuthenticator,
private readonly AuthenticationSuccessHandler $successHandler,
private readonly AuthenticationFailureHandler $failureHandler
) {}

#[Route('/v1/authentication/oidc/token', name: 'authentication_oidc_token', methods: ['GET'])]
Expand Down Expand Up @@ -83,7 +83,7 @@ public function getUrls(Request $request, SessionInterface $session): Response
];

return new JsonResponse($data);
} catch (InvalidProviderException $e) {
} catch (InvalidProviderException) {
throw $this->createNotFoundException('Unknown provider: '.$providerKey);
} catch (ItkOpenIdConnectException $e) {
throw new HttpException(500, $e->getMessage());
Expand Down
8 changes: 4 additions & 4 deletions src/Controller/AuthScreenBindController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
class AuthScreenBindController extends AbstractController
{
public function __construct(
private ScreenAuthenticator $authScreenService,
private ValidationUtils $validationUtils,
private ScreenRepository $screenRepository
private readonly ScreenAuthenticator $authScreenService,
private readonly ValidationUtils $validationUtils,
private readonly ScreenRepository $screenRepository
) {}

public function __invoke(Request $request, string $id): Response
Expand All @@ -42,7 +42,7 @@ public function __invoke(Request $request, string $id): Response

try {
$this->authScreenService->bindScreen($screen, $bindKey);
} catch (\Exception|InvalidArgumentException $exception) {
} catch (\Exception|InvalidArgumentException) {
return new JsonResponse('Key not accepted', Response::HTTP_BAD_REQUEST);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/AuthScreenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class AuthScreenController extends AbstractController
{
public function __construct(
private ScreenAuthenticator $authScreenService
private readonly ScreenAuthenticator $authScreenService
) {}

public function __invoke(Request $request): JsonResponse
Expand Down
6 changes: 3 additions & 3 deletions src/Controller/AuthScreenUnbindController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
class AuthScreenUnbindController extends AbstractController
{
public function __construct(
private ScreenAuthenticator $authScreenService,
private ValidationUtils $validationUtils,
private ScreenRepository $screenRepository
private readonly ScreenAuthenticator $authScreenService,
private readonly ValidationUtils $validationUtils,
private readonly ScreenRepository $screenRepository
) {}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Controller/FeedSourceConfigGetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
class FeedSourceConfigGetController extends AbstractController
{
public function __construct(
private FeedService $feedService,
private FeedSourceRepository $feedSourceRepository,
private ValidationUtils $validationUtils,
private readonly FeedService $feedService,
private readonly FeedSourceRepository $feedSourceRepository,
private readonly ValidationUtils $validationUtils,
) {}

public function __invoke(Request $request, string $id, string $name): JsonResponse
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/NotFoundAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#[AsController]
class NotFoundAction
{
public function __invoke()
public function __invoke(): never
{
throw new NotFoundHttpException();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/PlaylistScreenRegionDeleteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
class PlaylistScreenRegionDeleteController extends AbstractController
{
public function __construct(
private PlaylistScreenRegionRepository $playlistScreenRegionRepository,
private ValidationUtils $validationUtils
private readonly PlaylistScreenRegionRepository $playlistScreenRegionRepository,
private readonly ValidationUtils $validationUtils
) {}

public function __invoke(Request $request, string $id, string $regionId, string $playlistId): JsonResponse
Expand Down
Loading

0 comments on commit 90646e4

Please sign in to comment.