Turns out PHP is a bit stricter on null types than I expected.

This commit is contained in:
flash 2018-02-11 16:07:54 +01:00
parent 0b4b835876
commit 421940829c
4 changed files with 8 additions and 7 deletions

View file

@ -64,12 +64,12 @@ class Application extends ApplicationBase
} }
} }
public function getSession(): Session public function getSession(): ?Session
{ {
return $this->session; return $this->session;
} }
public function setSession(Session $session): void public function setSession(?Session $session): void
{ {
$this->session = $session; $this->session = $session;
} }

View file

@ -171,15 +171,16 @@ class AuthController extends Controller
public function logout() public function logout()
{ {
$app = Application::getInstance(); $app = Application::getInstance();
$session = $app->getSession();
if ($app->session === null) { if ($session === null) {
echo "You aren't logged in."; echo "You aren't logged in.";
} else { } else {
echo "You've been logged out."; echo "You've been logged out.";
$this->setCookie('uid', '', -3600); $this->setCookie('uid', '', -3600);
$this->setCookie('sid', '', -3600); $this->setCookie('sid', '', -3600);
$app->session->delete(); $session->delete();
$app->session = null; $app->setSession(null);
} }
return '<meta http-equiv="refresh" content="1; url=/">'; return '<meta http-equiv="refresh" content="1; url=/">';

View file

@ -11,7 +11,7 @@ class Role extends Model
public static function createRole( public static function createRole(
string $name, string $name,
?int $hierarchy = null, ?int $hierarchy = null,
Colour $colour = null, ?Colour $colour = null,
?string $title = null, ?string $title = null,
?string $description = null, ?string $description = null,
bool $secret = false bool $secret = false

View file

@ -12,7 +12,7 @@ class Session extends Model
public static function createSession( public static function createSession(
User $user, User $user,
?string $userAgent = null, ?string $userAgent = null,
Carbon $expires = null, ?Carbon $expires = null,
?string $ipAddress = null ?string $ipAddress = null
): Session { ): Session {
$ipAddress = $ipAddress ?? IP::remote(); $ipAddress = $ipAddress ?? IP::remote();