diff options
| author | 2023-04-08 17:37:42 +0200 | |
|---|---|---|
| committer | 2023-04-08 17:37:42 +0200 | |
| commit | 743ca371bbd8c412c2cd4ded6a5a44544abc5a65 (patch) | |
| tree | 7b12b205c09ae335134d4c4ea2d8d9f04fc60e9d /app/Models/Themes.php | |
| parent | b2ee8a660f719ee3e523988bf536197d4bbe46a1 (diff) | |
PHPStan Level 6 for more files (#5275)
Contributes to https://github.com/FreshRSS/FreshRSS/issues/4112
Diffstat (limited to 'app/Models/Themes.php')
| -rw-r--r-- | app/Models/Themes.php | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/app/Models/Themes.php b/app/Models/Themes.php index 86125c5f5..ce63b24b2 100644 --- a/app/Models/Themes.php +++ b/app/Models/Themes.php @@ -1,18 +1,23 @@ <?php class FreshRSS_Themes extends Minz_Model { + /** @var string */ private static $themesUrl = '/themes/'; + /** @var string */ private static $defaultIconsUrl = '/themes/icons/'; + /** @var string */ public static $defaultTheme = 'Origine'; - public static function getList() { + /** @return array<string> */ + public static function getList(): array { return array_values(array_diff( scandir(PUBLIC_PATH . self::$themesUrl), array('..', '.') )); } - public static function get() { + /** @return array<string,array{'id':string,'name':string,'author':string,'description':string,'version':float|string,'files':array<string>,'theme-color'?:string|array{'dark'?:string,'light'?:string,'default'?:string}}> */ + public static function get(): array { $themes_list = self::getList(); $list = array(); foreach ($themes_list as $theme_dir) { @@ -24,7 +29,10 @@ class FreshRSS_Themes extends Minz_Model { return $list; } - public static function get_infos($theme_id) { + /** + * @return false|array{'id':string,'name':string,'author':string,'description':string,'version':float|string,'files':array<string>,'theme-color'?:string|array{'dark'?:string,'light'?:string,'default'?:string}} + */ + public static function get_infos(string $theme_id) { $theme_dir = PUBLIC_PATH . self::$themesUrl . $theme_id; if (is_dir($theme_dir)) { $json_filename = $theme_dir . '/metadata.json'; @@ -43,10 +51,15 @@ class FreshRSS_Themes extends Minz_Model { return false; } + /** @var string */ private static $themeIconsUrl; + /** @var array<string,int> */ private static $themeIcons; - public static function load($theme_id) { + /** + * @return false|array{'id':string,'name':string,'author':string,'description':string,'version':float|string,'files':array<string>,'theme-color'?:string|array{'dark'?:string,'light'?:string,'default'?:string}} + */ + public static function load(string $theme_id) { $infos = self::get_infos($theme_id); if (!$infos) { if ($theme_id !== self::$defaultTheme) { //Fall-back to default theme @@ -68,14 +81,14 @@ class FreshRSS_Themes extends Minz_Model { return $infos; } - public static function title($name) { + public static function title(string $name): string { static $titles = [ 'opml-dyn' => 'sub.category.dynamic_opml', ]; return $titles[$name] ?? ''; } - public static function alt($name) { + public static function alt(string $name): string { static $alts = array( 'add' => '➕', //✚ 'all' => '☰', @@ -119,7 +132,7 @@ class FreshRSS_Themes extends Minz_Model { 'view-reader' => '📜', 'warning' => '⚠️', //△ ); - return isset($name) ? $alts[$name] : ''; + return $alts[$name] ?? ''; } // TODO: Change for enum in PHP 8.1+ |
