Skip to content

Commit

Permalink
Declare nullable parameter types explicitly for PHP 8.4 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
W0rma committed Jul 26, 2024
1 parent df4c02c commit f23199b
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/Codeception/Module/Symfony.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ protected function getProfile(): ?Profile
/**
* Grabs a Symfony Data Collector
*/
protected function grabCollector(string $collector, string $function, string $message = null): DataCollectorInterface
protected function grabCollector(string $collector, string $function, ?string $message = null): DataCollectorInterface
{
$profile = $this->getProfile();
if ($profile === null) {
Expand Down
2 changes: 1 addition & 1 deletion src/Codeception/Module/Symfony/BrowserAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function rebootClientKernel(): void
*
* @param string|null $url
*/
public function seePageIsAvailable(string $url = null): void
public function seePageIsAvailable(?string $url = null): void
{
if ($url !== null) {
$this->amOnPage($url);
Expand Down
4 changes: 2 additions & 2 deletions src/Codeception/Module/Symfony/EventsAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ trait EventsAssertionsTrait
*
* @param string|string[]|null $expected
*/
public function dontSeeEvent(array|string $expected = null): void
public function dontSeeEvent(array|string|null $expected = null): void
{
$actualEvents = [...array_column($this->getCalledListeners(), 'event')];
$actual = [$this->getOrphanedEvents(), $actualEvents];
Expand Down Expand Up @@ -87,7 +87,7 @@ public function dontSeeEventTriggered(array|object|string $expected): void
*
* @param string|string[] $expected
*/
public function dontSeeOrphanEvent(array|string $expected = null): void
public function dontSeeOrphanEvent(array|string|null $expected = null): void
{
$actual = [$this->getOrphanedEvents()];
$this->assertEventTriggered(false, $expected, $actual);
Expand Down
2 changes: 1 addition & 1 deletion src/Codeception/Module/Symfony/FormAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function dontSeeFormErrors(): void
*
* @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__);

Expand Down
20 changes: 10 additions & 10 deletions src/Codeception/Module/Symfony/MimeAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ trait MimeAssertionsTrait
* $I->assertEmailAddressContains('To', '[email protected]');
* ```
*/
public function assertEmailAddressContains(string $headerName, string $expectedValue, Email $email = null): void
public function assertEmailAddressContains(string $headerName, string $expectedValue, ?Email $email = null): void
{
$email = $this->verifyEmailObject($email, __FUNCTION__);
$this->assertThat($email, new MimeConstraint\EmailAddressContains($headerName, $expectedValue));
Expand All @@ -35,7 +35,7 @@ public function assertEmailAddressContains(string $headerName, string $expectedV
* $I->assertEmailAttachmentCount(1);
* ```
*/
public function assertEmailAttachmentCount(int $count, Email $email = null): void
public function assertEmailAttachmentCount(int $count, ?Email $email = null): void
{
$email = $this->verifyEmailObject($email, __FUNCTION__);
$this->assertThat($email, new MimeConstraint\EmailAttachmentCount($count));
Expand All @@ -50,7 +50,7 @@ public function assertEmailAttachmentCount(int $count, Email $email = null): voi
* $I->assertEmailHasHeader('Bcc');
* ```
*/
public function assertEmailHasHeader(string $headerName, Email $email = null): void
public function assertEmailHasHeader(string $headerName, ?Email $email = null): void
{
$email = $this->verifyEmailObject($email, __FUNCTION__);
$this->assertThat($email, new MimeConstraint\EmailHasHeader($headerName));
Expand All @@ -66,7 +66,7 @@ public function assertEmailHasHeader(string $headerName, Email $email = null): v
* $I->assertEmailHeaderNotSame('To', '[email protected]');
* ```
*/
public function assertEmailHeaderNotSame(string $headerName, string $expectedValue, Email $email = null): void
public function assertEmailHeaderNotSame(string $headerName, string $expectedValue, ?Email $email = null): void
{
$email = $this->verifyEmailObject($email, __FUNCTION__);
$this->assertThat($email, new LogicalNot(new MimeConstraint\EmailHeaderSame($headerName, $expectedValue)));
Expand All @@ -82,7 +82,7 @@ public function assertEmailHeaderNotSame(string $headerName, string $expectedVal
* $I->assertEmailHeaderSame('To', '[email protected]');
* ```
*/
public function assertEmailHeaderSame(string $headerName, string $expectedValue, Email $email = null): void
public function assertEmailHeaderSame(string $headerName, string $expectedValue, ?Email $email = null): void
{
$email = $this->verifyEmailObject($email, __FUNCTION__);
$this->assertThat($email, new MimeConstraint\EmailHeaderSame($headerName, $expectedValue));
Expand All @@ -97,7 +97,7 @@ public function assertEmailHeaderSame(string $headerName, string $expectedValue,
* $I->assertEmailHtmlBodyContains('Successful registration');
* ```
*/
public function assertEmailHtmlBodyContains(string $text, Email $email = null): void
public function assertEmailHtmlBodyContains(string $text, ?Email $email = null): void
{
$email = $this->verifyEmailObject($email, __FUNCTION__);
$this->assertThat($email, new MimeConstraint\EmailHtmlBodyContains($text));
Expand All @@ -112,7 +112,7 @@ public function assertEmailHtmlBodyContains(string $text, Email $email = null):
* $I->assertEmailHtmlBodyNotContains('userpassword');
* ```
*/
public function assertEmailHtmlBodyNotContains(string $text, Email $email = null): void
public function assertEmailHtmlBodyNotContains(string $text, ?Email $email = null): void
{
$email = $this->verifyEmailObject($email, __FUNCTION__);
$this->assertThat($email, new LogicalNot(new MimeConstraint\EmailHtmlBodyContains($text)));
Expand All @@ -127,7 +127,7 @@ public function assertEmailHtmlBodyNotContains(string $text, Email $email = null
* $I->assertEmailNotHasHeader('Bcc');
* ```
*/
public function assertEmailNotHasHeader(string $headerName, Email $email = null): void
public function assertEmailNotHasHeader(string $headerName, ?Email $email = null): void
{
$email = $this->verifyEmailObject($email, __FUNCTION__);
$this->assertThat($email, new LogicalNot(new MimeConstraint\EmailHasHeader($headerName)));
Expand All @@ -142,7 +142,7 @@ public function assertEmailNotHasHeader(string $headerName, Email $email = null)
* $I->assertEmailTextBodyContains('Example text body');
* ```
*/
public function assertEmailTextBodyContains(string $text, Email $email = null): void
public function assertEmailTextBodyContains(string $text, ?Email $email = null): void
{
$email = $this->verifyEmailObject($email, __FUNCTION__);
$this->assertThat($email, new MimeConstraint\EmailTextBodyContains($text));
Expand All @@ -157,7 +157,7 @@ public function assertEmailTextBodyContains(string $text, Email $email = null):
* $I->assertEmailTextBodyNotContains('My secret text body');
* ```
*/
public function assertEmailTextBodyNotContains(string $text, Email $email = null): void
public function assertEmailTextBodyNotContains(string $text, ?Email $email = null): void
{
$email = $this->verifyEmailObject($email, __FUNCTION__);
$this->assertThat($email, new LogicalNot(new MimeConstraint\EmailTextBodyContains($text)));
Expand Down
2 changes: 1 addition & 1 deletion src/Codeception/Module/Symfony/SecurityAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function seeUserHasRoles(array $roles): void
*
* @param UserInterface|null $user
*/
public function seeUserPasswordDoesNotNeedRehash(UserInterface $user = null): void
public function seeUserPasswordDoesNotNeedRehash(?UserInterface $user = null): void
{
if ($user === null) {
$security = $this->grabSecurityService();
Expand Down
4 changes: 2 additions & 2 deletions src/Codeception/Module/Symfony/SessionAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ trait SessionAssertionsTrait
* $I->amLoggedInAs($user);
* ```
*/
public function amLoggedInAs(UserInterface $user, string $firewallName = 'main', string $firewallContext = null): void
public function amLoggedInAs(UserInterface $user, string $firewallName = 'main', ?string $firewallContext = null): void
{
$token = $this->createAuthenticationToken($user, $firewallName);
$this->loginWithToken($token, $firewallName, $firewallContext);
}

public function amLoggedInWithToken(TokenInterface $token, string $firewallName = 'main', string $firewallContext = null): void
public function amLoggedInWithToken(TokenInterface $token, string $firewallName = 'main', ?string $firewallContext = null): void
{
$this->loginWithToken($token, $firewallName, $firewallContext);
}
Expand Down

0 comments on commit f23199b

Please sign in to comment.