From b8c88aecf5265aa5e97f629a1c57fcf11d39d003 Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Thu, 3 Feb 2022 20:21:25 +0100 Subject: [PATCH] Improve typing --- classes/Config.php | 6 +++--- classes/Controller/FrontController.php | 2 +- classes/LocaleManager.php | 6 +++--- classes/Middleware/LocaleMiddleware.php | 2 +- classes/Stream/YoutubeChunkStream.php | 4 ++-- classes/UglyRouter.php | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/classes/Config.php b/classes/Config.php index da7a10a..b08b883 100644 --- a/classes/Config.php +++ b/classes/Config.php @@ -154,7 +154,7 @@ class Config /** * Config constructor. * - * @param mixed[] $options Options + * @param scalar[]|scalar[][]|null[] $options Options * @throws ConfigException */ public function __construct(array $options = []) @@ -222,7 +222,7 @@ class Config /** * Apply the provided options. * - * @param mixed[] $options Options + * @param scalar[]|scalar[][]|null[] $options Options * * @return void */ @@ -278,7 +278,7 @@ class Config /** * Manually set some options. * - * @param mixed[] $options Options (see `config/config.example.yml` for available options) + * @param scalar[]|scalar[][]|null[] $options Options (see `config/config.example.yml` for available options) * @return void * @throws ConfigException */ diff --git a/classes/Controller/FrontController.php b/classes/Controller/FrontController.php index c8c4b45..0bb6110 100644 --- a/classes/Controller/FrontController.php +++ b/classes/Controller/FrontController.php @@ -145,7 +145,7 @@ class FrontController extends BaseController * @return Response HTTP response * @throws AlltubeLibraryException */ - private function getInfoResponse(Request $request, Response $response) + private function getInfoResponse(Request $request, Response $response): Response { try { $this->video->getJson(); diff --git a/classes/LocaleManager.php b/classes/LocaleManager.php index 884579e..58b8944 100644 --- a/classes/LocaleManager.php +++ b/classes/LocaleManager.php @@ -135,14 +135,14 @@ class LocaleManager /** * Smarty "t" block. * - * @param mixed[] $params Block parameters + * @param string[]|string[][] $params Block parameters * @param string|null $text Block content * * @return string Translated string */ public function smartyTranslate(array $params, string $text = null): string { - if (isset($params['params'])) { + if (isset($params['params']) && is_array($params['params'])) { return $this->t($text, $params['params']); } else { return $this->t($text); @@ -154,7 +154,7 @@ class LocaleManager * * @param string|null $string $string String to translate * - * @param mixed[] $params + * @param string[] $params * @return string Translated string */ public function t(string $string = null, array $params = []): string diff --git a/classes/Middleware/LocaleMiddleware.php b/classes/Middleware/LocaleMiddleware.php index 418ee7d..bb0dfac 100644 --- a/classes/Middleware/LocaleMiddleware.php +++ b/classes/Middleware/LocaleMiddleware.php @@ -38,7 +38,7 @@ class LocaleMiddleware /** * Test if a locale can be used for the current user. * - * @param mixed[] $proposedLocale Locale array created by AcceptLanguage::parse() + * @param string[] $proposedLocale Locale array created by AcceptLanguage::parse() * * @return Locale|null Locale if chosen, nothing otherwise */ diff --git a/classes/Stream/YoutubeChunkStream.php b/classes/Stream/YoutubeChunkStream.php index bb95138..f66996f 100644 --- a/classes/Stream/YoutubeChunkStream.php +++ b/classes/Stream/YoutubeChunkStream.php @@ -156,9 +156,9 @@ class YoutubeChunkStream implements StreamInterface * * @param mixed $string The string that is to be written * - * @return mixed + * @return int */ - public function write($string) + public function write($string): int { return $this->response->getBody()->write($string); } diff --git a/classes/UglyRouter.php b/classes/UglyRouter.php index 51f080f..2f1661e 100644 --- a/classes/UglyRouter.php +++ b/classes/UglyRouter.php @@ -22,7 +22,7 @@ class UglyRouter extends Router * * @param ServerRequestInterface $request The current HTTP request object * - * @return mixed[] + * @return int[]|string[]|array[] * * @link https://github.com/nikic/FastRoute/blob/master/src/Dispatcher.php */