Skip to content

Commit

Permalink
Use an assertion to clear up phpstan's confusion about nulls
Browse files Browse the repository at this point in the history
  • Loading branch information
bakert committed Oct 8, 2024
1 parent 7160ffc commit 1e3ac98
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
1 change: 1 addition & 0 deletions gatherling/Auth/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public static function login(?string $username, ?string $password): LoginResult
if ($errors) {
return new LoginResult(false, $errors);
}
assert(is_string($username) && is_string($password));
$auth = Player::checkPassword($username, $password);
// The $admin check allows an admin to su into any user without a password.
$admin = Player::isLoggedIn() && Player::getSessionPlayer()->isSuper();
Expand Down
15 changes: 0 additions & 15 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,6 @@ parameters:
count: 1
path: gatherling/Auth/Login.php

-
message: "#^Parameter \\#1 \\$string of function strlen expects string, string\\|null given\\.$#"
count: 1
path: gatherling/Auth/Login.php

-
message: "#^Parameter \\#1 \\$username of static method Gatherling\\\\Models\\\\Player\\:\\:checkPassword\\(\\) expects string, string\\|null given\\.$#"
count: 1
path: gatherling/Auth/Login.php

-
message: "#^Parameter \\#2 \\$password of static method Gatherling\\\\Models\\\\Player\\:\\:checkPassword\\(\\) expects string, string\\|null given\\.$#"
count: 1
path: gatherling/Auth/Login.php

-
message: "#^Cannot access property \\$discord_handle on Gatherling\\\\Models\\\\Player\\|null\\.$#"
count: 1
Expand Down

0 comments on commit 1e3ac98

Please sign in to comment.