phpstan & refactoring

This commit is contained in:
Milos Stojanovic
2019-06-14 13:07:01 +02:00
parent f6185c92ab
commit fa319eda36
8 changed files with 20 additions and 7 deletions

View File

@@ -101,7 +101,7 @@ class Database implements Service, AuthInterface
], 'WHERE username = ?', $username);
}
return $this->find($user->getUsername());
return $this->find($user->getUsername()) ?: $user;
}
public function add(User $user, $password): User
@@ -119,7 +119,7 @@ class Database implements Service, AuthInterface
'password' => $this->hashPassword($password),
]);
return $this->find($user->getUsername());
return $this->find($user->getUsername()) ?: $user;
}
public function delete(User $user)

View File

@@ -96,7 +96,7 @@ class JsonFile implements Service, AuthInterface
$this->saveUsers($all_users);
return $this->find($user->getUsername());
return $this->find($user->getUsername()) ?: $user;
}
}
@@ -122,7 +122,7 @@ class JsonFile implements Service, AuthInterface
$this->saveUsers($all_users);
return $this->find($user->getUsername());
return $this->find($user->getUsername()) ?: $user;
}
public function delete(User $user)

View File

@@ -55,7 +55,11 @@ class SessionStorage implements Service, SessionStorageInterface
public function invalidate()
{
if ($this->getSession() !== null || ! $this->getSession()->isStarted()) {
if ($this->getSession() === null) {
return;
}
if (! $this->getSession()->isStarted()) {
$this->getSession()->start();
}

View File

@@ -282,6 +282,6 @@ class Filesystem implements Service
$tmp = explode($this->separator, trim($path, $this->separator));
return array_pop($tmp);
return (string) array_pop($tmp);
}
}