Skip to content

Commit 92a5bcd

Browse files
authored
Fix guard name implitic null issue (#56)
1 parent dfc426a commit 92a5bcd

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/Codeception/Module/Laravel/InteractsWithAuthentication.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ trait InteractsWithAuthentication
1818
* $I->amActingAs($user);
1919
* ```
2020
*/
21-
public function amActingAs(Authenticatable $user, string $guardName = null): void
21+
public function amActingAs(Authenticatable $user, ?string $guardName = null): void
2222
{
2323
if (property_exists($user, 'wasRecentlyCreated') && $user->wasRecentlyCreated) {
2424
$user->wasRecentlyCreated = false;
@@ -47,7 +47,7 @@ public function amActingAs(Authenticatable $user, string $guardName = null): voi
4747
* @param Authenticatable|array $user
4848
* @param string|null $guardName
4949
*/
50-
public function amLoggedAs($user, string $guardName = null): void
50+
public function amLoggedAs($user, ?string $guardName = null): void
5151
{
5252
if ($user instanceof Authenticatable) {
5353
$this->getAuth()->login($user);
@@ -69,7 +69,7 @@ public function amLoggedAs($user, string $guardName = null): void
6969
* $I->assertAuthenticatedAs($user);
7070
* ```
7171
*/
72-
public function assertAuthenticatedAs(Authenticatable $user, string $guardName = null): void
72+
public function assertAuthenticatedAs(Authenticatable $user, ?string $guardName = null): void
7373
{
7474
$expected = $this->getAuth()->guard($guardName)->user();
7575

@@ -97,7 +97,7 @@ public function assertAuthenticatedAs(Authenticatable $user, string $guardName =
9797
* ]);
9898
* ```
9999
*/
100-
public function assertCredentials(array $credentials, string $guardName = null): void
100+
public function assertCredentials(array $credentials, ?string $guardName = null): void
101101
{
102102
$this->assertTrue(
103103
$this->hasCredentials($credentials, $guardName), 'The given credentials are invalid.'
@@ -115,7 +115,7 @@ public function assertCredentials(array $credentials, string $guardName = null):
115115
* ]);
116116
* ```
117117
*/
118-
public function assertInvalidCredentials(array $credentials, string $guardName = null): void
118+
public function assertInvalidCredentials(array $credentials, ?string $guardName = null): void
119119
{
120120
$this->assertFalse(
121121
$this->hasCredentials($credentials, $guardName), 'The given credentials are valid.'
@@ -130,7 +130,7 @@ public function assertInvalidCredentials(array $credentials, string $guardName =
130130
* $I->dontSeeAuthentication();
131131
* ```
132132
*/
133-
public function dontSeeAuthentication(string $guardName = null): void
133+
public function dontSeeAuthentication(?string $guardName = null): void
134134
{
135135
$this->assertFalse($this->isAuthenticated($guardName), 'The user is authenticated');
136136
}
@@ -156,15 +156,15 @@ public function logout(): void
156156
* $I->seeAuthentication();
157157
* ```
158158
*/
159-
public function seeAuthentication(string $guardName = null): void
159+
public function seeAuthentication(?string $guardName = null): void
160160
{
161161
$this->assertTrue($this->isAuthenticated($guardName), 'The user is not authenticated');
162162
}
163163

164164
/**
165165
* Return true if the credentials are valid, false otherwise.
166166
*/
167-
protected function hasCredentials(array $credentials, string $guardName = null): bool
167+
protected function hasCredentials(array $credentials, ?string $guardName = null): bool
168168
{
169169
/** @var GuardHelpers $guard */
170170
$guard = $this->getAuth()->guard($guardName);

src/Codeception/Module/Laravel/InteractsWithConsole.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ trait InteractsWithConsole
2121
*
2222
* @return string|void
2323
*/
24-
public function callArtisan(string $command, array $parameters = [], OutputInterface $output = null)
24+
public function callArtisan(string $command, array $parameters = [], ?OutputInterface $output = null)
2525
{
2626
$console = $this->getConsoleKernel();
2727
if (!$output) {

src/Codeception/Module/Laravel/InteractsWithViews.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function dontSeeFormErrors(): void
4343
* $I->seeFormErrorMessage('username', 'Invalid Username');
4444
* ```
4545
*/
46-
public function seeFormErrorMessage(string $field, string $errorMessage = null): void
46+
public function seeFormErrorMessage(string $field, ?string $errorMessage = null): void
4747
{
4848
$viewErrorBag = $this->getViewErrorBag();
4949

0 commit comments

Comments
 (0)