Skip to content

Commit 9b77251

Browse files
authored
Declare nullable parameter types explicitly for PHP 8.4 compatibility (#197)
1 parent df4c02c commit 9b77251

7 files changed

+18
-18
lines changed

src/Codeception/Module/Symfony.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ protected function getProfile(): ?Profile
335335
/**
336336
* Grabs a Symfony Data Collector
337337
*/
338-
protected function grabCollector(string $collector, string $function, string $message = null): DataCollectorInterface
338+
protected function grabCollector(string $collector, string $function, ?string $message = null): DataCollectorInterface
339339
{
340340
$profile = $this->getProfile();
341341
if ($profile === null) {

src/Codeception/Module/Symfony/BrowserAssertionsTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function rebootClientKernel(): void
4343
*
4444
* @param string|null $url
4545
*/
46-
public function seePageIsAvailable(string $url = null): void
46+
public function seePageIsAvailable(?string $url = null): void
4747
{
4848
if ($url !== null) {
4949
$this->amOnPage($url);

src/Codeception/Module/Symfony/EventsAssertionsTrait.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ trait EventsAssertionsTrait
2323
*
2424
* @param string|string[]|null $expected
2525
*/
26-
public function dontSeeEvent(array|string $expected = null): void
26+
public function dontSeeEvent(array|string|null $expected = null): void
2727
{
2828
$actualEvents = [...array_column($this->getCalledListeners(), 'event')];
2929
$actual = [$this->getOrphanedEvents(), $actualEvents];
@@ -87,7 +87,7 @@ public function dontSeeEventTriggered(array|object|string $expected): void
8787
*
8888
* @param string|string[] $expected
8989
*/
90-
public function dontSeeOrphanEvent(array|string $expected = null): void
90+
public function dontSeeOrphanEvent(array|string|null $expected = null): void
9191
{
9292
$actual = [$this->getOrphanedEvents()];
9393
$this->assertEventTriggered(false, $expected, $actual);

src/Codeception/Module/Symfony/FormAssertionsTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function dontSeeFormErrors(): void
4545
*
4646
* @param string|null $message
4747
*/
48-
public function seeFormErrorMessage(string $field, string $message = null): void
48+
public function seeFormErrorMessage(string $field, ?string $message = null): void
4949
{
5050
$formCollector = $this->grabFormCollector(__FUNCTION__);
5151

src/Codeception/Module/Symfony/MimeAssertionsTrait.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ trait MimeAssertionsTrait
2020
* $I->assertEmailAddressContains('To', '[email protected]');
2121
* ```
2222
*/
23-
public function assertEmailAddressContains(string $headerName, string $expectedValue, Email $email = null): void
23+
public function assertEmailAddressContains(string $headerName, string $expectedValue, ?Email $email = null): void
2424
{
2525
$email = $this->verifyEmailObject($email, __FUNCTION__);
2626
$this->assertThat($email, new MimeConstraint\EmailAddressContains($headerName, $expectedValue));
@@ -35,7 +35,7 @@ public function assertEmailAddressContains(string $headerName, string $expectedV
3535
* $I->assertEmailAttachmentCount(1);
3636
* ```
3737
*/
38-
public function assertEmailAttachmentCount(int $count, Email $email = null): void
38+
public function assertEmailAttachmentCount(int $count, ?Email $email = null): void
3939
{
4040
$email = $this->verifyEmailObject($email, __FUNCTION__);
4141
$this->assertThat($email, new MimeConstraint\EmailAttachmentCount($count));
@@ -50,7 +50,7 @@ public function assertEmailAttachmentCount(int $count, Email $email = null): voi
5050
* $I->assertEmailHasHeader('Bcc');
5151
* ```
5252
*/
53-
public function assertEmailHasHeader(string $headerName, Email $email = null): void
53+
public function assertEmailHasHeader(string $headerName, ?Email $email = null): void
5454
{
5555
$email = $this->verifyEmailObject($email, __FUNCTION__);
5656
$this->assertThat($email, new MimeConstraint\EmailHasHeader($headerName));
@@ -66,7 +66,7 @@ public function assertEmailHasHeader(string $headerName, Email $email = null): v
6666
* $I->assertEmailHeaderNotSame('To', '[email protected]');
6767
* ```
6868
*/
69-
public function assertEmailHeaderNotSame(string $headerName, string $expectedValue, Email $email = null): void
69+
public function assertEmailHeaderNotSame(string $headerName, string $expectedValue, ?Email $email = null): void
7070
{
7171
$email = $this->verifyEmailObject($email, __FUNCTION__);
7272
$this->assertThat($email, new LogicalNot(new MimeConstraint\EmailHeaderSame($headerName, $expectedValue)));
@@ -82,7 +82,7 @@ public function assertEmailHeaderNotSame(string $headerName, string $expectedVal
8282
* $I->assertEmailHeaderSame('To', '[email protected]');
8383
* ```
8484
*/
85-
public function assertEmailHeaderSame(string $headerName, string $expectedValue, Email $email = null): void
85+
public function assertEmailHeaderSame(string $headerName, string $expectedValue, ?Email $email = null): void
8686
{
8787
$email = $this->verifyEmailObject($email, __FUNCTION__);
8888
$this->assertThat($email, new MimeConstraint\EmailHeaderSame($headerName, $expectedValue));
@@ -97,7 +97,7 @@ public function assertEmailHeaderSame(string $headerName, string $expectedValue,
9797
* $I->assertEmailHtmlBodyContains('Successful registration');
9898
* ```
9999
*/
100-
public function assertEmailHtmlBodyContains(string $text, Email $email = null): void
100+
public function assertEmailHtmlBodyContains(string $text, ?Email $email = null): void
101101
{
102102
$email = $this->verifyEmailObject($email, __FUNCTION__);
103103
$this->assertThat($email, new MimeConstraint\EmailHtmlBodyContains($text));
@@ -112,7 +112,7 @@ public function assertEmailHtmlBodyContains(string $text, Email $email = null):
112112
* $I->assertEmailHtmlBodyNotContains('userpassword');
113113
* ```
114114
*/
115-
public function assertEmailHtmlBodyNotContains(string $text, Email $email = null): void
115+
public function assertEmailHtmlBodyNotContains(string $text, ?Email $email = null): void
116116
{
117117
$email = $this->verifyEmailObject($email, __FUNCTION__);
118118
$this->assertThat($email, new LogicalNot(new MimeConstraint\EmailHtmlBodyContains($text)));
@@ -127,7 +127,7 @@ public function assertEmailHtmlBodyNotContains(string $text, Email $email = null
127127
* $I->assertEmailNotHasHeader('Bcc');
128128
* ```
129129
*/
130-
public function assertEmailNotHasHeader(string $headerName, Email $email = null): void
130+
public function assertEmailNotHasHeader(string $headerName, ?Email $email = null): void
131131
{
132132
$email = $this->verifyEmailObject($email, __FUNCTION__);
133133
$this->assertThat($email, new LogicalNot(new MimeConstraint\EmailHasHeader($headerName)));
@@ -142,7 +142,7 @@ public function assertEmailNotHasHeader(string $headerName, Email $email = null)
142142
* $I->assertEmailTextBodyContains('Example text body');
143143
* ```
144144
*/
145-
public function assertEmailTextBodyContains(string $text, Email $email = null): void
145+
public function assertEmailTextBodyContains(string $text, ?Email $email = null): void
146146
{
147147
$email = $this->verifyEmailObject($email, __FUNCTION__);
148148
$this->assertThat($email, new MimeConstraint\EmailTextBodyContains($text));
@@ -157,7 +157,7 @@ public function assertEmailTextBodyContains(string $text, Email $email = null):
157157
* $I->assertEmailTextBodyNotContains('My secret text body');
158158
* ```
159159
*/
160-
public function assertEmailTextBodyNotContains(string $text, Email $email = null): void
160+
public function assertEmailTextBodyNotContains(string $text, ?Email $email = null): void
161161
{
162162
$email = $this->verifyEmailObject($email, __FUNCTION__);
163163
$this->assertThat($email, new LogicalNot(new MimeConstraint\EmailTextBodyContains($text)));

src/Codeception/Module/Symfony/SecurityAssertionsTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public function seeUserHasRoles(array $roles): void
163163
*
164164
* @param UserInterface|null $user
165165
*/
166-
public function seeUserPasswordDoesNotNeedRehash(UserInterface $user = null): void
166+
public function seeUserPasswordDoesNotNeedRehash(?UserInterface $user = null): void
167167
{
168168
if ($user === null) {
169169
$security = $this->grabSecurityService();

src/Codeception/Module/Symfony/SessionAssertionsTrait.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ trait SessionAssertionsTrait
3535
* $I->amLoggedInAs($user);
3636
* ```
3737
*/
38-
public function amLoggedInAs(UserInterface $user, string $firewallName = 'main', string $firewallContext = null): void
38+
public function amLoggedInAs(UserInterface $user, string $firewallName = 'main', ?string $firewallContext = null): void
3939
{
4040
$token = $this->createAuthenticationToken($user, $firewallName);
4141
$this->loginWithToken($token, $firewallName, $firewallContext);
4242
}
4343

44-
public function amLoggedInWithToken(TokenInterface $token, string $firewallName = 'main', string $firewallContext = null): void
44+
public function amLoggedInWithToken(TokenInterface $token, string $firewallName = 'main', ?string $firewallContext = null): void
4545
{
4646
$this->loginWithToken($token, $firewallName, $firewallContext);
4747
}

0 commit comments

Comments
 (0)