From 8d15fbdda298c4f34574f91eec5ceab7f17c309c Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Sun, 27 Sep 2020 15:53:53 +0200 Subject: [PATCH] Lint --- classes/Config.php | 4 ++-- classes/Controller/BaseController.php | 2 +- classes/Controller/FrontController.php | 2 +- classes/Locale.php | 2 +- classes/LocaleManager.php | 14 +++++++++----- classes/Stream/PlaylistArchiveStream.php | 10 +++++----- classes/Stream/YoutubeChunkStream.php | 8 ++++---- classes/UglyRouter.php | 2 +- classes/ViewFactory.php | 2 +- 9 files changed, 25 insertions(+), 21 deletions(-) diff --git a/classes/Config.php b/classes/Config.php index a37497e..c2fd010 100644 --- a/classes/Config.php +++ b/classes/Config.php @@ -185,7 +185,7 @@ class Config * * @return string */ - public static function addHttpToFormat($format) + public static function addHttpToFormat(string $format) { $newFormat = []; foreach (explode('/', $format) as $subformat) { @@ -279,7 +279,7 @@ class Config * @return void * @throws ConfigException */ - public static function setFile($file) + public static function setFile(string $file) { if (is_file($file)) { $options = Yaml::parse(strval(file_get_contents($file))); diff --git a/classes/Controller/BaseController.php b/classes/Controller/BaseController.php index a152f11..0a3bced 100644 --- a/classes/Controller/BaseController.php +++ b/classes/Controller/BaseController.php @@ -144,7 +144,7 @@ abstract class BaseController * * @return Response HTTP response */ - protected function displayError(Request $request, Response $response, $message) + protected function displayError(Request $request, Response $response, string $message) { $controller = new FrontController($this->container); diff --git a/classes/Controller/FrontController.php b/classes/Controller/FrontController.php index b292e3b..5f06568 100644 --- a/classes/Controller/FrontController.php +++ b/classes/Controller/FrontController.php @@ -242,7 +242,7 @@ class FrontController extends BaseController * * @return Response HTTP response */ - protected function displayError(Request $request, Response $response, $message) + protected function displayError(Request $request, Response $response, string $message) { $this->view->render( $response, diff --git a/classes/Locale.php b/classes/Locale.php index f8ebf2f..9e81180 100644 --- a/classes/Locale.php +++ b/classes/Locale.php @@ -34,7 +34,7 @@ class Locale * * @param string $locale ISO 15897 code */ - public function __construct($locale) + public function __construct(string $locale) { $parse = AcceptLanguage::parse($locale); $this->language = $parse[1]['language']; diff --git a/classes/LocaleManager.php b/classes/LocaleManager.php index 861ddf2..b008d8a 100644 --- a/classes/LocaleManager.php +++ b/classes/LocaleManager.php @@ -142,11 +142,11 @@ class LocaleManager * Smarty "t" block. * * @param mixed[] $params Block parameters - * @param string $text Block content + * @param string|null $text Block content * * @return string Translated string */ - public function smartyTranslate(array $params, $text) + public function smartyTranslate(array $params, string $text = null) { if (isset($params['params'])) { return $this->t($text, $params['params']); @@ -158,14 +158,18 @@ class LocaleManager /** * Translate a string. * - * @param string $string String to translate + * @param string|null $string $string String to translate * * @param mixed[] $params * @return string Translated string */ - public function t($string, array $params = []) + public function t(string $string = null, array $params = []) { - return $this->translator->trans($string, $params); + if (isset($string)) { + return $this->translator->trans($string, $params); + } + + return ''; } /** diff --git a/classes/Stream/PlaylistArchiveStream.php b/classes/Stream/PlaylistArchiveStream.php index d55e554..1bf08ff 100644 --- a/classes/Stream/PlaylistArchiveStream.php +++ b/classes/Stream/PlaylistArchiveStream.php @@ -79,7 +79,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface /** * Add data to the archive. * - * @param string $data Data + * @param mixed $data Data * * @return void */ @@ -99,7 +99,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface /** * Write data to the stream. * - * @param string $string The string that is to be written + * @param mixed $string The string that is to be written * * @return int|false */ @@ -171,7 +171,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface /** * Get stream metadata as an associative array or retrieve a specific key. * - * @param string $key string $key Specific metadata to retrieve. + * @param string|null $key string $key Specific metadata to retrieve. * * @return array|mixed|null */ @@ -228,7 +228,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface /** * Seek to a position in the stream. * - * @param int $offset Offset + * @param mixed $offset Offset * @param int $whence Specifies how the cursor position will be calculated * * @return void @@ -272,7 +272,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface /** * Read data from the stream. * - * @param int $count Number of bytes to read + * @param mixed $count Number of bytes to read * * @return string|false * @throws AlltubeLibraryException diff --git a/classes/Stream/YoutubeChunkStream.php b/classes/Stream/YoutubeChunkStream.php index c99f422..bf64c0a 100644 --- a/classes/Stream/YoutubeChunkStream.php +++ b/classes/Stream/YoutubeChunkStream.php @@ -35,7 +35,7 @@ class YoutubeChunkStream implements StreamInterface /** * Read data from the stream. * - * @param int $length Read up to $length bytes from the object and return + * @param mixed $length Read up to $length bytes from the object and return * * @return string */ @@ -121,7 +121,7 @@ class YoutubeChunkStream implements StreamInterface /** * Seek to a position in the stream. * - * @param int $offset Stream offset + * @param mixed $offset Stream offset * @param int $whence Specifies how the cursor position will be calculated * * @return void @@ -154,7 +154,7 @@ class YoutubeChunkStream implements StreamInterface /** * Write data to the stream. * - * @param string $string The string that is to be written + * @param mixed $string The string that is to be written * * @return mixed */ @@ -186,7 +186,7 @@ class YoutubeChunkStream implements StreamInterface /** * Get stream metadata as an associative array or retrieve a specific key. * - * @param string $key Specific metadata to retrieve. + * @param string|null $key Specific metadata to retrieve. * * @return array|mixed|null */ diff --git a/classes/UglyRouter.php b/classes/UglyRouter.php index a5b1020..235ece0 100644 --- a/classes/UglyRouter.php +++ b/classes/UglyRouter.php @@ -42,7 +42,7 @@ class UglyRouter extends Router /** * Build the path for a named route including the base path. * - * @param string $name Route name + * @param mixed $name Route name * @param string[] $data Named argument replacement data * @param string[] $queryParams Optional query string parameters * diff --git a/classes/ViewFactory.php b/classes/ViewFactory.php index e5c0bb7..b082798 100644 --- a/classes/ViewFactory.php +++ b/classes/ViewFactory.php @@ -21,7 +21,7 @@ class ViewFactory * Create Smarty view object. * * @param ContainerInterface $container Slim dependency container - * @param Request $request PSR-7 request + * @param Request|null $request PSR-7 request * * @return Smarty * @throws SmartyException