mirror of
https://github.com/scummvm/scummvm-web.git
synced 2026-05-21 05:40:47 +00:00
WEB: Various small fixes
These are either cosmetic or spotted by PHPStan
This commit is contained in:
@@ -105,7 +105,7 @@ class Controller
|
||||
private function isRtl($localeName)
|
||||
{
|
||||
$rtl_chars_pattern = '/[\x{0590}-\x{05ff}\x{0600}-\x{06ff}]/u';
|
||||
return preg_match($rtl_chars_pattern, $localeName);
|
||||
return preg_match($rtl_chars_pattern, $localeName) === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,8 @@ use DateTime;
|
||||
*/
|
||||
class FileUtils
|
||||
{
|
||||
private const DOUBLE_EXTENSIONS = ['.bz2', '.gz', '.lz', '.xz', '.7z'];
|
||||
|
||||
/**
|
||||
* Returns whether or not the file exists and is readable
|
||||
*
|
||||
@@ -60,7 +62,7 @@ class FileUtils
|
||||
$extension = substr($path, (strrpos($path, '.')));
|
||||
|
||||
// For certain extensions, check for another extension (e.g. foo.tar.gz => tar.gz)
|
||||
if ($extension == '.bz2' || $extension == '.gz' || $extension == '.lz' || $extension == '.xz' || $extension == '.7z') {
|
||||
if (in_array($extension, self::DOUBLE_EXTENSIONS)) {
|
||||
$extension = substr($path, strrpos($path, '.', -(strlen($path) - strrpos($path, '.') + 1)));
|
||||
}
|
||||
return $extension;
|
||||
|
||||
@@ -14,7 +14,7 @@ abstract class BasicModel
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if (is_null(self::$cache)) {
|
||||
if (!isset(self::$cache)) {
|
||||
try {
|
||||
$driver = extension_loaded('redis') ? 'redis' : 'predis';
|
||||
$database = DEV_SERVER ? 7 : 8;
|
||||
|
||||
@@ -24,7 +24,7 @@ class GameDownloadsModel extends BasicModel
|
||||
foreach ($categories as $category) {
|
||||
$sections[$category] = new DownloadsSection([
|
||||
'anchor' => $category,
|
||||
'title' => $sectionsData[$category]['title'],
|
||||
'title' => $sectionsData[$category]['title'] ?? null,
|
||||
'notes' => $sectionsData[$category]['notes'] ?? null
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ class ScreenshotsModel extends BasicModel
|
||||
$combined[$subcategory] = $screenshot;
|
||||
}
|
||||
}
|
||||
\sort($combined, SORT_STRING);
|
||||
\ksort($combined, SORT_STRING);
|
||||
return $combined;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ abstract class BasicObject
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getName();
|
||||
return $this->getName() ?? '';
|
||||
}
|
||||
|
||||
/* Get the name. */
|
||||
|
||||
@@ -23,8 +23,8 @@ class File extends BasicObject
|
||||
$this->autoId = $data['auto_id'] ?? null;
|
||||
$this->category = $data['category'];
|
||||
$this->category_icon = $data['category_icon'];
|
||||
$this->notes = isset($data['notes']) ? $data['notes'] : '';
|
||||
$this->user_agent = isset($data["user_agent"]) ? $data["user_agent"] : "";
|
||||
$this->notes = $data['notes'] ?? '';
|
||||
$this->user_agent = $data['user_agent'] ?? '';
|
||||
$this->version = isset($data['version']) ? strtolower($data['version']) : null;
|
||||
|
||||
/* If it's not an array, we didn't get any attributes. */
|
||||
|
||||
@@ -39,7 +39,7 @@ class ArticlePage extends Controller
|
||||
/* Display the index page. */
|
||||
public function index($params)
|
||||
{
|
||||
if (!$params['article']) {
|
||||
if (empty($params['article'])) {
|
||||
throw new \ErrorException(self::ARTICLE_NAME_MISSING);
|
||||
}
|
||||
$filename = $params['article'] . '.markdown';
|
||||
|
||||
@@ -28,7 +28,7 @@ class SimplePage extends Controller
|
||||
throw new \ErrorException(\sprintf(self::FILE_NOT_FOUND, $templateFile));
|
||||
}
|
||||
if (array_key_exists($key, self::PAGE_MODELS)) {
|
||||
[$model, $data] = self::PAGE_MODELS[$key];
|
||||
list($model, $data) = self::PAGE_MODELS[$key];
|
||||
$this->model = new SimpleYamlModel($model, $data);
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ class SimplePage extends Controller
|
||||
/* Display the index page. */
|
||||
public function index($data = null)
|
||||
{
|
||||
if ($this->model) {
|
||||
if (isset($this->model)) {
|
||||
$data = $this->model->getAllData();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user