diff --git a/src/Codeception/Lib/Connector/Symfony.php b/src/Codeception/Lib/Connector/Symfony.php index 557a9434..dafcaa5a 100644 --- a/src/Codeception/Lib/Connector/Symfony.php +++ b/src/Codeception/Lib/Connector/Symfony.php @@ -38,7 +38,7 @@ class Symfony extends HttpKernelBrowser public function __construct(Kernel $kernel, array $services = [], bool $rebootable = true) { parent::__construct($kernel); - $this->followRedirects(true); + $this->followRedirects(); $this->rebootable = $rebootable; $this->persistentServices = $services; $this->container = $this->getContainer(); diff --git a/src/Codeception/Module/Symfony.php b/src/Codeception/Module/Symfony.php index 018f8710..abcd56e9 100644 --- a/src/Codeception/Module/Symfony.php +++ b/src/Codeception/Module/Symfony.php @@ -212,8 +212,6 @@ public function _initialize(): void /** * Initialize new client instance before each test - * - * @param TestInterface $test */ public function _before(TestInterface $test): void { @@ -223,8 +221,6 @@ public function _before(TestInterface $test): void /** * Update permanent services after each test - * - * @param TestInterface $test */ public function _after(TestInterface $test): void { @@ -370,13 +366,8 @@ protected function getProfile(): ?Profile /** * Grabs a Symfony Data Collector - * - * @param string $collector - * @param string $function - * @param string|null $message - * @return DataCollectorInterface */ - protected function grabCollector(string $collector, string $function, ?string $message = null): DataCollectorInterface + protected function grabCollector(string $collector, string $function, string $message = null): DataCollectorInterface { if (($profile = $this->getProfile()) === null) { $this->fail( diff --git a/src/Codeception/Module/Symfony/DoctrineAssertionsTrait.php b/src/Codeception/Module/Symfony/DoctrineAssertionsTrait.php index 2ea3606f..9aa4a054 100644 --- a/src/Codeception/Module/Symfony/DoctrineAssertionsTrait.php +++ b/src/Codeception/Module/Symfony/DoctrineAssertionsTrait.php @@ -27,7 +27,6 @@ trait DoctrineAssertionsTrait * * @param string $entityClass The entity class * @param array $criteria Optional query criteria - * @return int */ public function grabNumRecords(string $entityClass, array $criteria = []): int { @@ -55,11 +54,8 @@ public function grabNumRecords(string $entityClass, array $criteria = []): int * $I->grabRepository(UserRepository::class); * $I->grabRepository(UserRepositoryInterface::class); * ``` - * - * @param object|string $mixed - * @return \Doctrine\ORM\EntityRepository|null */ - public function grabRepository($mixed): ?EntityRepository + public function grabRepository(object|string $mixed): ?EntityRepository { $entityRepoClass = EntityRepository::class; $isNotARepo = function () use ($mixed): void { @@ -79,7 +75,7 @@ public function grabRepository($mixed): ?EntityRepository }; if (is_object($mixed)) { - $mixed = get_class($mixed); + $mixed = $mixed::class; } if (interface_exists($mixed)) { diff --git a/src/Codeception/Module/Symfony/EventsAssertionsTrait.php b/src/Codeception/Module/Symfony/EventsAssertionsTrait.php index 64eca663..f4b47b98 100644 --- a/src/Codeception/Module/Symfony/EventsAssertionsTrait.php +++ b/src/Codeception/Module/Symfony/EventsAssertionsTrait.php @@ -28,9 +28,9 @@ trait EventsAssertionsTrait * $I->dontSeeOrphanEvent(['App\MyEvent', 'App\MyOtherEvent']); * ``` * - * @param string|object|string[] $expected + * @param object|string|string[] $expected */ - public function dontSeeOrphanEvent($expected = null): void + public function dontSeeOrphanEvent(array|object|string $expected = null): void { $eventCollector = $this->grabEventCollector(__FUNCTION__); @@ -55,9 +55,9 @@ public function dontSeeOrphanEvent($expected = null): void * $I->dontSeeEventTriggered(['App\MyEvent', 'App\MyOtherEvent']); * ``` * - * @param string|object|string[] $expected + * @param object|string|string[] $expected */ - public function dontSeeEventTriggered($expected): void + public function dontSeeEventTriggered(array|object|string $expected): void { $eventCollector = $this->grabEventCollector(__FUNCTION__); @@ -82,9 +82,9 @@ public function dontSeeEventTriggered($expected): void * $I->seeOrphanEvent(['App\MyEvent', 'App\MyOtherEvent']); * ``` * - * @param string|object|string[] $expected + * @param object|string|string[] $expected */ - public function seeOrphanEvent($expected): void + public function seeOrphanEvent(array|object|string $expected): void { $eventCollector = $this->grabEventCollector(__FUNCTION__); @@ -105,9 +105,9 @@ public function seeOrphanEvent($expected): void * $I->seeEventTriggered(['App\MyEvent', 'App\MyOtherEvent']); * ``` * - * @param string|object|string[] $expected + * @param object|string|string[] $expected */ - public function seeEventTriggered($expected): void + public function seeEventTriggered(array|object|string $expected): void { $eventCollector = $this->grabEventCollector(__FUNCTION__); @@ -123,7 +123,7 @@ protected function assertEventNotTriggered(Data $data, array $expected): void $actual = $data->getValue(true); foreach ($expected as $expectedEvent) { - $expectedEvent = is_object($expectedEvent) ? get_class($expectedEvent) : $expectedEvent; + $expectedEvent = is_object($expectedEvent) ? $expectedEvent::class : $expectedEvent; $this->assertFalse( $this->eventWasTriggered($actual, (string)$expectedEvent), "The '{$expectedEvent}' event triggered" @@ -140,7 +140,7 @@ protected function assertEventTriggered(Data $data, array $expected): void $actual = $data->getValue(true); foreach ($expected as $expectedEvent) { - $expectedEvent = is_object($expectedEvent) ? get_class($expectedEvent) : $expectedEvent; + $expectedEvent = is_object($expectedEvent) ? $expectedEvent::class : $expectedEvent; $this->assertTrue( $this->eventWasTriggered($actual, (string)$expectedEvent), "The '{$expectedEvent}' event did not trigger" @@ -154,7 +154,7 @@ protected function eventWasTriggered(array $actual, string $expectedEvent): bool foreach ($actual as $actualEvent) { if (is_array($actualEvent)) { // Called Listeners - if (strpos($actualEvent['pretty'], $expectedEvent) === 0) { + if (str_starts_with($actualEvent['pretty'], $expectedEvent)) { $triggered = true; } } else { // Orphan Events diff --git a/src/Codeception/Module/Symfony/FormAssertionsTrait.php b/src/Codeception/Module/Symfony/FormAssertionsTrait.php index 3b923059..8261ea9f 100644 --- a/src/Codeception/Module/Symfony/FormAssertionsTrait.php +++ b/src/Codeception/Module/Symfony/FormAssertionsTrait.php @@ -46,7 +46,7 @@ public function dontSeeFormErrors(): void * @param string $field * @param string|null $message */ - public function seeFormErrorMessage(string $field, ?string $message = null): void + public function seeFormErrorMessage(string $field, string $message = null): void { $formCollector = $this->grabFormCollector(__FUNCTION__); diff --git a/src/Codeception/Module/Symfony/MailerAssertionsTrait.php b/src/Codeception/Module/Symfony/MailerAssertionsTrait.php index 9ead87ff..cb82484a 100644 --- a/src/Codeception/Module/Symfony/MailerAssertionsTrait.php +++ b/src/Codeception/Module/Symfony/MailerAssertionsTrait.php @@ -53,8 +53,6 @@ public function seeEmailIsSent(int $expectedCount = 1): void * $address = $email->getTo()[0]; * $I->assertSame('john_doe@example.com', $address->getAddress()); * ``` - * - * @return \Symfony\Component\Mime\Email|null */ public function grabLastSentEmail(): ?Email { diff --git a/src/Codeception/Module/Symfony/RouterAssertionsTrait.php b/src/Codeception/Module/Symfony/RouterAssertionsTrait.php index 4ca8032d..c023782f 100644 --- a/src/Codeception/Module/Symfony/RouterAssertionsTrait.php +++ b/src/Codeception/Module/Symfony/RouterAssertionsTrait.php @@ -37,7 +37,7 @@ public function amOnAction(string $action, array $params = []): void foreach ($routes as $route) { $controller = $route->getDefault('_controller'); - if (substr_compare($controller, $action, -strlen($action)) === 0) { + if (str_ends_with($controller, $action)) { $resource = $router->match($route->getPath()); $url = $router->generate( $resource['_route'], @@ -100,7 +100,7 @@ public function seeCurrentActionIs(string $action): void foreach ($routes as $route) { $controller = $route->getDefault('_controller'); - if (substr_compare($controller, $action, -strlen($action)) === 0) { + if (str_ends_with($controller, $action)) { $request = $this->getClient()->getRequest(); $currentActionFqcn = $request->attributes->get('_controller'); @@ -135,7 +135,7 @@ public function seeCurrentRouteIs(string $routeName, array $params = []): void $match = []; try { $match = $router->match($uri); - } catch (ResourceNotFoundException $e) { + } catch (ResourceNotFoundException) { $this->fail(sprintf('The "%s" url does not match with any route', $uri)); } @@ -167,7 +167,7 @@ public function seeInCurrentRoute(string $routeName): void $matchedRouteName = ''; try { $matchedRouteName = (string)$router->match($uri)['_route']; - } catch (ResourceNotFoundException $e) { + } catch (ResourceNotFoundException) { $this->fail(sprintf('The "%s" url does not match with any route', $uri)); } diff --git a/src/Codeception/Module/Symfony/SecurityAssertionsTrait.php b/src/Codeception/Module/Symfony/SecurityAssertionsTrait.php index a8ad24b6..a07e3ab3 100644 --- a/src/Codeception/Module/Symfony/SecurityAssertionsTrait.php +++ b/src/Codeception/Module/Symfony/SecurityAssertionsTrait.php @@ -183,10 +183,7 @@ protected function grabSecurityService(): Security return $this->grabService('security.helper'); } - /** - * @return UserPasswordHasherInterface|UserPasswordEncoderInterface - */ - protected function grabPasswordHasherService() + protected function grabPasswordHasherService(): UserPasswordHasherInterface|UserPasswordEncoderInterface { $hasher = $this->getService('security.password_hasher') ?: $this->getService('security.password_encoder'); diff --git a/src/Codeception/Module/Symfony/ServicesAssertionsTrait.php b/src/Codeception/Module/Symfony/ServicesAssertionsTrait.php index c21289c5..b53a72b8 100644 --- a/src/Codeception/Module/Symfony/ServicesAssertionsTrait.php +++ b/src/Codeception/Module/Symfony/ServicesAssertionsTrait.php @@ -21,7 +21,6 @@ trait ServicesAssertionsTrait * * @part services * @param string $serviceId - * @return object */ public function grabService(string $serviceId): object { @@ -37,7 +36,6 @@ public function grabService(string $serviceId): object * Get service $serviceName and add it to the lists of persistent services. * * @part services - * @param string $serviceName */ public function persistService(string $serviceName): void { @@ -53,7 +51,6 @@ public function persistService(string $serviceName): void * making that service persistent between tests. * * @part services - * @param string $serviceName */ public function persistPermanentService(string $serviceName): void { @@ -69,7 +66,6 @@ public function persistPermanentService(string $serviceName): void * Remove service $serviceName from the lists of persistent services. * * @part services - * @param string $serviceName */ public function unpersistService(string $serviceName): void { diff --git a/src/Codeception/Module/Symfony/SessionAssertionsTrait.php b/src/Codeception/Module/Symfony/SessionAssertionsTrait.php index e7ff9cbb..f6911303 100644 --- a/src/Codeception/Module/Symfony/SessionAssertionsTrait.php +++ b/src/Codeception/Module/Symfony/SessionAssertionsTrait.php @@ -75,10 +75,8 @@ public function amLoggedInAs(UserInterface $user, string $firewallName = 'main', * $I->dontSeeInSession('attribute', 'value'); * ``` * - * @param string $attribute - * @param mixed|null $value */ - public function dontSeeInSession(string $attribute, $value = null): void + public function dontSeeInSession(string $attribute, mixed $value = null): void { $session = $this->getCurrentSession(); @@ -160,11 +158,8 @@ public function logoutProgrammatically(): void * $I->seeInSession('attribute'); * $I->seeInSession('attribute', 'value'); * ``` - * - * @param string $attribute - * @param mixed|null $value */ - public function seeInSession(string $attribute, $value = null): void + public function seeInSession(string $attribute, mixed $value = null): void { $session = $this->getCurrentSession(); diff --git a/src/Codeception/Module/Symfony/TimeAssertionsTrait.php b/src/Codeception/Module/Symfony/TimeAssertionsTrait.php index ad3c1862..d48222eb 100644 --- a/src/Codeception/Module/Symfony/TimeAssertionsTrait.php +++ b/src/Codeception/Module/Symfony/TimeAssertionsTrait.php @@ -24,7 +24,7 @@ trait TimeAssertionsTrait * * @param int|float $expectedMilliseconds The expected time in milliseconds */ - public function seeRequestTimeIsLessThan($expectedMilliseconds): void + public function seeRequestTimeIsLessThan(int|float $expectedMilliseconds): void { $expectedMilliseconds = round($expectedMilliseconds, 2);