diff --git a/config/packages/dev/monolog.php b/config/packages/dev/monolog.php index 2da2add..24be725 100644 --- a/config/packages/dev/monolog.php +++ b/config/packages/dev/monolog.php @@ -4,8 +4,7 @@ use Symfony\Config\MonologConfig; -return static function (MonologConfig $monolog): void -{ +return static function (MonologConfig $monolog): void { $monolog->handler('main', [ 'type' => 'stream', 'path' => '%kernel.logs_dir%/%kernel.environment%.log', diff --git a/config/packages/prod/monolog.php b/config/packages/prod/monolog.php index 702d978..c005524 100644 --- a/config/packages/prod/monolog.php +++ b/config/packages/prod/monolog.php @@ -4,22 +4,21 @@ use Symfony\Config\MonologConfig; -return static function (MonologConfig $monolog): void -{ +return static function (MonologConfig $monolog): void { $monolog->handler('main', [ 'type' => 'fingers_crossed', 'action_level' => 'error', 'handler' => 'nested', - 'buffer_size' => 50 + 'buffer_size' => 50, ])->excludedHttpCode()->code(404)->code(405); $monolog->handler('nested', [ 'type' => 'stream', 'path' => 'php://stderr', 'level' => 'debug', - 'formatter' => 'monolog.formatter.json' + 'formatter' => 'monolog.formatter.json', ]); $monolog->handler('console', [ 'type' => 'console', - 'process_psr_3_messages' => false + 'process_psr_3_messages' => false, ])->channels()->elements(['!event', '!doctrine']); }; diff --git a/config/packages/security.php b/config/packages/security.php index c21884a..aa67cb8 100644 --- a/config/packages/security.php +++ b/config/packages/security.php @@ -7,8 +7,7 @@ use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; use Symfony\Config\SecurityConfig; -return static function (SecurityConfig $security): void -{ +return static function (SecurityConfig $security): void { $security->enableAuthenticatorManager(true); $security->passwordHasher(PasswordAuthenticatedUserInterface::class, 'auto'); $userProvider = $security->provider('app_user_provider'); @@ -32,6 +31,6 @@ $mainFirewall->entryPoint('form_login'); $security->accessControl([ - 'path' => '^/dashboard', 'roles' => 'ROLE_USER' + 'path' => '^/dashboard', 'roles' => 'ROLE_USER', ]); }; diff --git a/config/packages/test/monolog.php b/config/packages/test/monolog.php index 0f91816..cc46109 100644 --- a/config/packages/test/monolog.php +++ b/config/packages/test/monolog.php @@ -4,8 +4,7 @@ use Symfony\Config\MonologConfig; -return static function (MonologConfig $monolog): void -{ +return static function (MonologConfig $monolog): void { $monolog->handler('main', [ 'type' => 'fingers_crossed', 'action_level' => 'error', @@ -14,6 +13,6 @@ $monolog->handler('nested', [ 'type' => 'stream', 'path' => '%kernel.logs_dir%/%kernel.environment%.log', - 'level' => 'debug' + 'level' => 'debug', ]); }; diff --git a/src/Command/ExampleCommand.php b/src/Command/ExampleCommand.php index ad0ec1a..79d6435 100644 --- a/src/Command/ExampleCommand.php +++ b/src/Command/ExampleCommand.php @@ -32,13 +32,10 @@ protected function configure(): void ); } - protected function initialize(InputInterface $input, OutputInterface $output): void + protected function execute(InputInterface $input, OutputInterface $output): int { $this->ioStream = new SymfonyStyle($input, $output); - } - protected function execute(InputInterface $input, OutputInterface $output): int - { $optionSomething = $input->getOption(self::OPTION_SOMETHING); if ($optionSomething) { $this->ioStream->text('Bye world!'); diff --git a/src/Controller/HttpClientController.php b/src/Controller/HttpClientController.php index bbeb75f..e4cdd37 100644 --- a/src/Controller/HttpClientController.php +++ b/src/Controller/HttpClientController.php @@ -12,11 +12,8 @@ final class HttpClientController extends AbstractController { - private HttpClientInterface $httpClient; - - public function __construct(HttpClientInterface $httpClient) + public function __construct(private readonly HttpClientInterface $httpClient) { - $this->httpClient = $httpClient; } public function routeUsingHttpClient(): Response @@ -65,9 +62,7 @@ public function routeMakingMultipleRequests(): Response public function internalEndpointPost(Request $request): Response { - $data = json_decode($request->getContent(), true); - - return $this->json(['received' => $data]); + return $this->json(['received' => $request->toArray()]); } public function routeShouldNotMakeSpecificRequest(): Response diff --git a/src/Controller/RegistrationController.php b/src/Controller/RegistrationController.php index 354937b..2187ff8 100644 --- a/src/Controller/RegistrationController.php +++ b/src/Controller/RegistrationController.php @@ -19,7 +19,7 @@ final class RegistrationController extends AbstractController public function __construct( private readonly Mailer $mailer, private readonly UserRepositoryInterface $userRepository, - private readonly EventDispatcherInterface $eventDispatcher + private readonly EventDispatcherInterface $eventDispatcher, ) { } diff --git a/src/Entity/User.php b/src/Entity/User.php index 2602684..3ea16ae 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -40,6 +40,7 @@ public static function create(string $email, string $password, array $roles = [] $user->email = $email; $user->password = $password; $user->roles = $roles; + return $user; } diff --git a/src/Repository/Model/UserRepositoryInterface.php b/src/Repository/Model/UserRepositoryInterface.php index ba5305d..d364eb2 100644 --- a/src/Repository/Model/UserRepositoryInterface.php +++ b/src/Repository/Model/UserRepositoryInterface.php @@ -9,4 +9,4 @@ interface UserRepositoryInterface public function save(User $user): void; public function getByEmail(string $email): ?User; -} \ No newline at end of file +} diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php index 233da67..49f22e6 100644 --- a/src/Repository/UserRepository.php +++ b/src/Repository/UserRepository.php @@ -27,6 +27,7 @@ public function getByEmail(string $email): ?User { /** @var User|null $user */ $user = $this->findOneBy(['email' => $email]); + return $user; } } diff --git a/src/Utils/Mailer.php b/src/Utils/Mailer.php index 6f97f4b..5412990 100644 --- a/src/Utils/Mailer.php +++ b/src/Utils/Mailer.php @@ -9,7 +9,7 @@ use Symfony\Component\Mailer\MailerInterface; use Symfony\Component\Mime\Address; -final class Mailer +final readonly class Mailer { public function __construct(private MailerInterface $mailer) { diff --git a/tests/Functional/DoctrineCest.php b/tests/Functional/DoctrineCest.php index 6f66550..bfe1e29 100644 --- a/tests/Functional/DoctrineCest.php +++ b/tests/Functional/DoctrineCest.php @@ -19,22 +19,22 @@ public function grabNumRecords(FunctionalTester $I) public function grabRepository(FunctionalTester $I) { - //With classes + // With classes $repository = $I->grabRepository(User::class); $I->assertInstanceOf(UserRepository::class, $repository); - //With Repository classes + // With Repository classes $repository = $I->grabRepository(UserRepository::class); $I->assertInstanceOf(UserRepository::class, $repository); - //With Entities + // With Entities $user = $I->grabEntityFromRepository(User::class, [ - 'email' => 'john_doe@gmail.com' + 'email' => 'john_doe@gmail.com', ]); $repository = $I->grabRepository($user); $I->assertInstanceOf(UserRepository::class, $repository); - //With Repository interfaces + // With Repository interfaces $repository = $I->grabRepository(UserRepositoryInterface::class); $I->assertInstanceOf(UserRepository::class, $repository); } @@ -43,5 +43,4 @@ public function seeNumRecords(FunctionalTester $I) { $I->seeNumRecords(1, User::class); } - } diff --git a/tests/Functional/EventsCest.php b/tests/Functional/EventsCest.php index c12a523..b3033a0 100644 --- a/tests/Functional/EventsCest.php +++ b/tests/Functional/EventsCest.php @@ -93,6 +93,7 @@ public function seeEvent(FunctionalTester $I) $I->seeEvent('non-existent-event'); } catch (ExpectationFailedException $ex) { $I->assertTrue(true, 'seeEvent assertion fails with non-existent events.'); + return; } $I->fail('seeEvent assertion did not fail as expected'); diff --git a/tests/Functional/ParameterCest.php b/tests/Functional/ParameterCest.php index bcb9801..98a0f93 100644 --- a/tests/Functional/ParameterCest.php +++ b/tests/Functional/ParameterCest.php @@ -10,7 +10,7 @@ final class ParameterCest { public function grabParameter(FunctionalTester $I) { - $locale = (string) $I->grabParameter('app.business_name'); - $I->assertSame('Codeception', $locale); + $businessName = (string) $I->grabParameter('app.business_name'); + $I->assertSame('Codeception', $businessName); } } diff --git a/tests/Functional/RouterCest.php b/tests/Functional/RouterCest.php index 0ae5bc3..85070e4 100644 --- a/tests/Functional/RouterCest.php +++ b/tests/Functional/RouterCest.php @@ -37,5 +37,4 @@ public function seeInCurrentRoute(FunctionalTester $I) $I->amOnPage('/'); $I->seeInCurrentRoute('index'); } - } diff --git a/tests/Functional/SecurityCest.php b/tests/Functional/SecurityCest.php index 4d1ddfe..beddba0 100644 --- a/tests/Functional/SecurityCest.php +++ b/tests/Functional/SecurityCest.php @@ -21,7 +21,7 @@ public function dontSeeRememberedAuthentication(FunctionalTester $I) $I->submitForm('form[name=login]', [ 'email' => 'john_doe@gmail.com', 'password' => '123456', - '_remember_me' => false + '_remember_me' => false, ]); $I->dontSeeRememberedAuthentication(); } @@ -29,7 +29,7 @@ public function dontSeeRememberedAuthentication(FunctionalTester $I) public function seeAuthentication(FunctionalTester $I) { $user = $I->grabEntityFromRepository(User::class, [ - 'email' => 'john_doe@gmail.com' + 'email' => 'john_doe@gmail.com', ]); $I->amLoggedInAs($user); $I->amOnPage('/dashboard'); @@ -43,7 +43,7 @@ public function seeRememberedAuthentication(FunctionalTester $I) $I->submitForm('form[name=login]', [ 'email' => 'john_doe@gmail.com', 'password' => '123456', - '_remember_me' => true + '_remember_me' => true, ]); $I->seeRememberedAuthentication(); } @@ -51,7 +51,7 @@ public function seeRememberedAuthentication(FunctionalTester $I) public function seeUserHasRole(FunctionalTester $I) { $user = $I->grabEntityFromRepository(User::class, [ - 'email' => 'john_doe@gmail.com' + 'email' => 'john_doe@gmail.com', ]); $I->amLoggedInAs($user); $I->amOnPage('/'); @@ -62,7 +62,7 @@ public function seeUserHasRole(FunctionalTester $I) public function seeUserHasRoles(FunctionalTester $I) { $user = $I->grabEntityFromRepository(User::class, [ - 'email' => 'john_doe@gmail.com' + 'email' => 'john_doe@gmail.com', ]); $I->amLoggedInAs($user); $I->amOnPage('/'); @@ -73,7 +73,7 @@ public function seeUserHasRoles(FunctionalTester $I) public function seeUserPasswordDoesNotNeedRehash(FunctionalTester $I) { $user = $I->grabEntityFromRepository(User::class, [ - 'email' => 'john_doe@gmail.com' + 'email' => 'john_doe@gmail.com', ]); $I->amLoggedInAs($user); $I->amOnPage('/dashboard'); diff --git a/tests/Functional/ServicesCest.php b/tests/Functional/ServicesCest.php index c7ee329..0f854b7 100644 --- a/tests/Functional/ServicesCest.php +++ b/tests/Functional/ServicesCest.php @@ -14,5 +14,4 @@ public function grabService(FunctionalTester $I) $security = $I->grabService('security.helper'); $I->assertInstanceOf(Security::class, $security); } - } diff --git a/tests/Functional/SessionCest.php b/tests/Functional/SessionCest.php index b29f751..77d5076 100644 --- a/tests/Functional/SessionCest.php +++ b/tests/Functional/SessionCest.php @@ -14,7 +14,7 @@ final class SessionCest public function amLoggedInAs(FunctionalTester $I) { $user = $I->grabEntityFromRepository(User::class, [ - 'email' => 'john_doe@gmail.com' + 'email' => 'john_doe@gmail.com', ]); $I->amLoggedInAs($user); $I->amOnPage('/dashboard'); @@ -28,7 +28,7 @@ public function amLoggedInAs(FunctionalTester $I) public function amLoggedInWithToken(FunctionalTester $I) { $user = $I->grabEntityFromRepository(User::class, [ - 'email' => 'john_doe@gmail.com' + 'email' => 'john_doe@gmail.com', ]); $token = new PostAuthenticationToken($user, 'main', $user->getRoles()); $I->amLoggedInWithToken($token); @@ -49,7 +49,7 @@ public function dontSeeInSession(FunctionalTester $I) public function goToLogoutPath(FunctionalTester $I) { $user = $I->grabEntityFromRepository(User::class, [ - 'email' => 'john_doe@gmail.com' + 'email' => 'john_doe@gmail.com', ]); $I->amLoggedInAs($user); $I->amOnPage('/dashboard'); @@ -63,7 +63,7 @@ public function goToLogoutPath(FunctionalTester $I) public function logoutProgrammatically(FunctionalTester $I) { $user = $I->grabEntityFromRepository(User::class, [ - 'email' => 'john_doe@gmail.com' + 'email' => 'john_doe@gmail.com', ]); $I->amLoggedInAs($user); $I->amOnPage('/dashboard'); @@ -78,7 +78,7 @@ public function logoutProgrammatically(FunctionalTester $I) public function seeInSession(FunctionalTester $I) { $user = $I->grabEntityFromRepository(User::class, [ - 'email' => 'john_doe@gmail.com' + 'email' => 'john_doe@gmail.com', ]); $I->amLoggedInAs($user); $I->amOnPage('/'); @@ -89,7 +89,7 @@ public function seeInSession(FunctionalTester $I) public function seeSessionHasValues(FunctionalTester $I) { $user = $I->grabEntityFromRepository(User::class, [ - 'email' => 'john_doe@gmail.com' + 'email' => 'john_doe@gmail.com', ]); $I->amLoggedInAs($user); $I->amOnPage('/'); diff --git a/tests/Functional/TimeCest.php b/tests/Functional/TimeCest.php index 1f3e444..005c2c6 100644 --- a/tests/Functional/TimeCest.php +++ b/tests/Functional/TimeCest.php @@ -14,4 +14,4 @@ public function seeRequestElapsedTimeLessThan(FunctionalTester $I) $I->seeInCurrentUrl('register'); $I->seeRequestTimeIsLessThan(400); } -} \ No newline at end of file +} diff --git a/tests/Functional/TwigCest.php b/tests/Functional/TwigCest.php index e674da2..713c60a 100644 --- a/tests/Functional/TwigCest.php +++ b/tests/Functional/TwigCest.php @@ -26,4 +26,4 @@ public function seeRenderedTemplate(FunctionalTester $I) $I->seeRenderedTemplate('layout.html.twig'); $I->seeRenderedTemplate('security/login.html.twig'); } -} \ No newline at end of file +}