diff --git a/classes/Config.php b/classes/Config.php index 88fc0cc..c68d5b3 100644 --- a/classes/Config.php +++ b/classes/Config.php @@ -40,7 +40,7 @@ class Config /** * youtube-dl parameters. * - * @var array + * @var string[] */ public $params = ['--no-warnings', '--ignore-errors', '--flat-playlist', '--restrict-filenames', '--no-playlist']; @@ -61,7 +61,7 @@ class Config /** * List of formats available in advanced conversion mode. * - * @var array + * @var string[] */ public $convertAdvancedFormats = ['mp3', 'avi', 'flv', 'wav']; @@ -125,7 +125,7 @@ class Config /** * Generic formats supported by youtube-dl. * - * @var array + * @var string[] */ public $genericFormats = []; @@ -139,7 +139,8 @@ class Config /** * Config constructor. * - * @param array $options Options + * @param mixed[] $options Options + * @throws CaseConverterException */ private function __construct(array $options = []) { @@ -210,7 +211,7 @@ class Config /** * Apply the provided options. * - * @param array $options Options + * @param mixed[] $options Options * * @return void */ @@ -260,12 +261,13 @@ class Config * Set options from a YAML file. * * @param string $file Path to the YAML file + * @return void * @throws Exception */ public static function setFile($file) { if (is_file($file)) { - $options = Yaml::parse(file_get_contents($file)); + $options = Yaml::parse(strval(file_get_contents($file))); self::$instance = new self($options); self::$instance->validateOptions(); } else { @@ -276,8 +278,9 @@ class Config /** * Manually set some options. * - * @param array $options Options (see `config/config.example.yml` for available options) + * @param mixed[] $options Options (see `config/config.example.yml` for available options) * @param bool $update True to update an existing instance + * @return void * @throws Exception */ public static function setOptions(array $options, $update = true) diff --git a/classes/Locale.php b/classes/Locale.php index 2d27721..f8ebf2f 100644 --- a/classes/Locale.php +++ b/classes/Locale.php @@ -104,7 +104,7 @@ class Locale /** * Get country information from locale. * - * @return Country|array|null + * @return Country|Country[]|null */ public function getCountry() { diff --git a/classes/LocaleManager.php b/classes/LocaleManager.php index 12c14dd..813ea79 100644 --- a/classes/LocaleManager.php +++ b/classes/LocaleManager.php @@ -18,7 +18,7 @@ class LocaleManager /** * Supported locales. * - * @var array + * @var string[] */ private $supportedLocales = ['en_US', 'fr_FR', 'zh_CN', 'es_ES', 'pt_BR', 'de_DE', 'ar', 'pl_PL', 'tr_TR']; @@ -111,6 +111,7 @@ class LocaleManager * Set the current locale. * * @param Locale $locale Locale + * @return void */ public function setLocale(Locale $locale) { @@ -121,6 +122,7 @@ class LocaleManager /** * Unset the current locale. + * @return void */ public function unsetLocale() { @@ -132,8 +134,8 @@ class LocaleManager /** * Smarty "t" block. * - * @param array $params Block parameters - * @param string $text Block content + * @param mixed[] $params Block parameters + * @param string $text Block content * * @return string Translated string */ @@ -151,6 +153,7 @@ class LocaleManager * * @param string $string String to translate * + * @param mixed[] $params * @return string Translated string */ public function t($string, array $params = []) diff --git a/classes/LocaleMiddleware.php b/classes/LocaleMiddleware.php index 5d0aac5..b7395bd 100644 --- a/classes/LocaleMiddleware.php +++ b/classes/LocaleMiddleware.php @@ -36,7 +36,7 @@ class LocaleMiddleware /** * Test if a locale can be used for the current user. * - * @param array $proposedLocale Locale array created by AcceptLanguage::parse() + * @param mixed[] $proposedLocale Locale array created by AcceptLanguage::parse() * * @return Locale|null Locale if chosen, nothing otherwise */ @@ -59,9 +59,9 @@ class LocaleMiddleware /** * Main middleware function. * - * @param Request $request PSR request + * @param Request $request PSR request * @param Response $response PSR response - * @param callable $next Next middleware + * @param callable $next Next middleware * * @return Response */ diff --git a/classes/UglyRouter.php b/classes/UglyRouter.php index 89ec2bb..f03efe7 100644 --- a/classes/UglyRouter.php +++ b/classes/UglyRouter.php @@ -21,7 +21,7 @@ class UglyRouter extends Router * * @param ServerRequestInterface $request The current HTTP request object * - * @return array + * @return mixed[] * * @link https://github.com/nikic/FastRoute/blob/master/src/Dispatcher.php */ @@ -42,14 +42,14 @@ class UglyRouter extends Router /** * Build the path for a named route including the base path. * - * @param string $name Route name - * @param array $data Named argument replacement data - * @param array $queryParams Optional query string parameters - * - * @throws RuntimeException If named route does not exist - * @throws InvalidArgumentException If required data not provided + * @param string $name Route name + * @param string[] $data Named argument replacement data + * @param string[] $queryParams Optional query string parameters * * @return string + * @throws InvalidArgumentException If required data not provided + * + * @throws RuntimeException If named route does not exist */ public function pathFor($name, array $data = [], array $queryParams = []) { diff --git a/classes/Video.php b/classes/Video.php index cfea97d..8b67ae0 100644 --- a/classes/Video.php +++ b/classes/Video.php @@ -19,16 +19,16 @@ use Symfony\Component\Process\Process; * * Due to the way youtube-dl behaves, this class can also contain information about a playlist. * - * @property-read string $title Title - * @property-read string $protocol Network protocol (HTTP, RTMP, etc.) - * @property-read string $url File URL - * @property-read string $ext File extension - * @property-read string $extractor_key youtube-dl extractor class used - * @property-read array $entries List of videos (if the object contains information about a playlist) - * @property-read array $rtmp_conn + * @property-read string $title Title + * @property-read string $protocol Network protocol (HTTP, RTMP, etc.) + * @property-read string $url File URL + * @property-read string $ext File extension + * @property-read string $extractor_key youtube-dl extractor class used + * @property-read array $entries List of videos (if the object contains information about a playlist) + * @property-read array $rtmp_conn * @property-read string|null $_type Object type (usually "playlist" or null) - * @property-read stdClass $downloader_options - * @property-read stdClass $http_headers + * @property-read stdClass $downloader_options + * @property-read stdClass $http_headers */ class Video { @@ -70,7 +70,7 @@ class Video /** * URLs of the video files. * - * @var array + * @var string[] */ private $urls; @@ -84,11 +84,11 @@ class Video /** * VideoDownload constructor. * - * @param string $webpageUrl URL of the page containing the video + * @param string $webpageUrl URL of the page containing the video * @param string $requestedFormat Requested video format * (can be any format string accepted by youtube-dl, * including selectors like "[height<=720]") - * @param string $password Password + * @param string $password Password */ public function __construct($webpageUrl, $requestedFormat = 'best', $password = null) { @@ -105,7 +105,7 @@ class Video * * @param string[] $arguments Arguments * - * @return Process + * @return Process */ private static function getProcess(array $arguments) { @@ -137,13 +137,13 @@ class Video /** * Call youtube-dl. * - * @param array $arguments Arguments + * @param string[] $arguments Arguments * - * @throws PasswordException If the video is protected by a password and no password was specified + * @return string Result * @throws Exception If the password is wrong * @throws Exception If youtube-dl returns an error * - * @return string Result + * @throws PasswordException If the video is protected by a password and no password was specified */ private function callYoutubedl(array $arguments) { @@ -155,7 +155,7 @@ class Video $process->run(); if (!$process->isSuccessful()) { $errorOutput = trim($process->getErrorOutput()); - $exitCode = $process->getExitCode(); + $exitCode = intval($process->getExitCode()); if ($errorOutput == 'ERROR: This video is protected by a password, use the --video-password option') { throw new PasswordException($errorOutput, $exitCode); } elseif (substr($errorOutput, 0, 21) == 'ERROR: Wrong password') { @@ -294,7 +294,7 @@ class Video /** * Return arguments used to run rtmp for a specific video. * - * @return array Arguments + * @return string[] Arguments */ private function getRtmpArguments() { @@ -303,12 +303,12 @@ class Video if ($this->protocol == 'rtmp') { foreach ( [ - 'url' => '-rtmp_tcurl', - 'webpage_url' => '-rtmp_pageurl', - 'player_url' => '-rtmp_swfverify', - 'flash_version' => '-rtmp_flashver', - 'play_path' => '-rtmp_playpath', - 'app' => '-rtmp_app', + 'url' => '-rtmp_tcurl', + 'webpage_url' => '-rtmp_pageurl', + 'player_url' => '-rtmp_swfverify', + 'flash_version' => '-rtmp_flashver', + 'play_path' => '-rtmp_playpath', + 'app' => '-rtmp_app', ] as $property => $option ) { if (isset($this->{$property})) { @@ -331,7 +331,7 @@ class Video /** * Check if a command runs successfully. * - * @param array $command Command and arguments + * @param string[] $command Command and arguments * * @return bool False if the command returns an error, true otherwise */ @@ -346,15 +346,15 @@ class Video /** * Get a process that runs avconv in order to convert a video. * - * @param int $audioBitrate Audio bitrate of the converted file - * @param string $filetype Filetype of the converted file - * @param bool $audioOnly True to return an audio-only file - * @param string $from Start the conversion at this time - * @param string $to End the conversion at this time + * @param int $audioBitrate Audio bitrate of the converted file + * @param string $filetype Filetype of the converted file + * @param bool $audioOnly True to return an audio-only file + * @param string $from Start the conversion at this time + * @param string $to End the conversion at this time * + * @return Process Process * @throws Exception If avconv/ffmpeg is missing * - * @return Process Process */ private function getAvconvProcess( $audioBitrate, @@ -425,12 +425,12 @@ class Video * Get audio stream of converted video. * * @param string $from Start the conversion at this time - * @param string $to End the conversion at this time - * - * @throws Exception If your try to convert an M3U8 video - * @throws Exception If the popen stream was not created correctly + * @param string $to End the conversion at this time * * @return resource popen stream + * @throws Exception If the popen stream was not created correctly + * + * @throws Exception If your try to convert an M3U8 video */ public function getAudioStream($from = null, $to = null) { @@ -460,10 +460,10 @@ class Video /** * Get video stream from an M3U playlist. * - * @throws Exception If avconv/ffmpeg is missing + * @return resource popen stream * @throws Exception If the popen stream was not created correctly * - * @return resource popen stream + * @throws Exception If avconv/ffmpeg is missing */ public function getM3uStream() { @@ -502,9 +502,9 @@ class Video /** * Get an avconv stream to remux audio and video. * + * @return resource popen stream * @throws Exception If the popen stream was not created correctly * - * @return resource popen stream */ public function getRemuxStream() { @@ -539,9 +539,9 @@ class Video /** * Get video stream from an RTMP video. * + * @return resource popen stream * @throws Exception If the popen stream was not created correctly * - * @return resource popen stream */ public function getRtmpStream() { @@ -572,13 +572,13 @@ class Video /** * Get the stream of a converted video. * - * @param int $audioBitrate Audio bitrate of the converted file - * @param string $filetype Filetype of the converted file - * - * @throws Exception If your try to convert and M3U8 video - * @throws Exception If the popen stream was not created correctly + * @param int $audioBitrate Audio bitrate of the converted file + * @param string $filetype Filetype of the converted file * * @return resource popen stream + * @throws Exception If the popen stream was not created correctly + * + * @throws Exception If your try to convert and M3U8 video */ public function getConvertedStream($audioBitrate, $filetype) { @@ -612,7 +612,7 @@ class Video /** * Get a HTTP response containing the video. * - * @param array $headers HTTP headers of the request + * @param mixed[] $headers HTTP headers of the request * * @return ResponseInterface * @throws EmptyUrlException @@ -628,7 +628,7 @@ class Video $urls[0], [ 'stream' => true, - 'headers' => array_merge((array) $this->http_headers, $headers) + 'headers' => array_merge((array)$this->http_headers, $headers) ] ); } diff --git a/classes/ViewFactory.php b/classes/ViewFactory.php index 89e52ec..e5c0bb7 100644 --- a/classes/ViewFactory.php +++ b/classes/ViewFactory.php @@ -29,7 +29,7 @@ class ViewFactory public static function create(ContainerInterface $container, Request $request = null) { if (!isset($request)) { - $request = $container['request']; + $request = $container->get('request'); } $view = new Smarty(__DIR__ . '/../templates/'); @@ -37,9 +37,10 @@ class ViewFactory $request = $request->withUri($request->getUri()->withScheme('https')->withPort(443)); } - $localeManager = $container['locale']; + /** @var LocaleManager $localeManager */ + $localeManager = $container->get('locale'); - $smartyPlugins = new SmartyPlugins($container['router'], $request->getUri()->withUserInfo(null)); + $smartyPlugins = new SmartyPlugins($container->get('router'), $request->getUri()->withUserInfo(null)); $view->registerPlugin('function', 'path_for', [$smartyPlugins, 'pathFor']); $view->registerPlugin('function', 'base_url', [$smartyPlugins, 'baseUrl']); $view->registerPlugin('block', 't', [$localeManager, 'smartyTranslate']); diff --git a/classes/streams/PlaylistArchiveStream.php b/classes/streams/PlaylistArchiveStream.php index 8fe4878..9792cef 100644 --- a/classes/streams/PlaylistArchiveStream.php +++ b/classes/streams/PlaylistArchiveStream.php @@ -6,6 +6,8 @@ namespace Alltube\Stream; +use Alltube\Exception\EmptyUrlException; +use Alltube\Exception\PasswordException; use Alltube\Video; use Barracuda\ArchiveStream\ZipArchive; use Psr\Http\Message\StreamInterface; @@ -86,20 +88,21 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface * * @param string $string The string that is to be written * - * @return void + * @return int|false */ public function write($string) { - fwrite($this->buffer, $string); + return fwrite($this->buffer, $string); } /** * Get the size of the stream if known. * - * @return void + * @return int|null */ public function getSize() { + return null; } /** @@ -145,7 +148,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface /** * Returns the remaining contents in a string. * - * @return string + * @return string|false */ public function getContents() { @@ -196,7 +199,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface { $this->rewind(); - return $this->getContents(); + return strval($this->getContents()); } /** @@ -238,6 +241,8 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface * @param Video $video Video to stream * * @return void + * @throws PasswordException + * @throws EmptyUrlException */ protected function startVideoStream(Video $video) { @@ -248,7 +253,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface $this->init_file_stream_transfer( $video->getFilename(), - $contentLengthHeaders[0] + intval($contentLengthHeaders[0]) ); } diff --git a/classes/streams/YoutubeChunkStream.php b/classes/streams/YoutubeChunkStream.php index 91ee219..c99f422 100644 --- a/classes/streams/YoutubeChunkStream.php +++ b/classes/streams/YoutubeChunkStream.php @@ -41,7 +41,7 @@ class YoutubeChunkStream implements StreamInterface */ public function read($length) { - $size = $this->response->getHeader('Content-Length')[0]; + $size = intval($this->response->getHeader('Content-Length')[0]); if ($size - $this->tell() < $length) { // Don't try to read further than the end of the stream. $length = $size - $this->tell(); @@ -55,7 +55,7 @@ class YoutubeChunkStream implements StreamInterface */ public function __toString() { - return (string) $this->response->getBody(); + return (string)$this->response->getBody(); } /** diff --git a/classes/streams/YoutubeStream.php b/classes/streams/YoutubeStream.php index a3e9ac1..3995d11 100644 --- a/classes/streams/YoutubeStream.php +++ b/classes/streams/YoutubeStream.php @@ -6,6 +6,8 @@ namespace Alltube\Stream; +use Alltube\Exception\EmptyUrlException; +use Alltube\Exception\PasswordException; use Alltube\Video; use GuzzleHttp\Psr7\AppendStream; @@ -19,6 +21,8 @@ class YoutubeStream extends AppendStream * YoutubeStream constructor. * * @param Video $video Video to stream + * @throws EmptyUrlException + * @throws PasswordException */ public function __construct(Video $video) { @@ -31,7 +35,7 @@ class YoutubeStream extends AppendStream while ($rangeStart < $contentLenghtHeader[0]) { $rangeEnd = $rangeStart + $video->downloader_options->http_chunk_size; if ($rangeEnd >= $contentLenghtHeader[0]) { - $rangeEnd = $contentLenghtHeader[0] - 1; + $rangeEnd = intval($contentLenghtHeader[0]) - 1; } $response = $video->getHttpResponse(['Range' => 'bytes=' . $rangeStart . '-' . $rangeEnd]); $this->addStream(new YoutubeChunkStream($response)); diff --git a/composer.json b/composer.json index adcf9da..11b457a 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "heroku/heroku-buildpack-php": "^162.0", "php-mock/php-mock-mockery": "^1.3", "phpro/grumphp": "^0.17.0", - "phpstan/phpstan": "~0.9.2", + "phpstan/phpstan": "^0.12.25", "phpunit/phpunit": "^8.4", "roave/security-advisories": "dev-master", "smarty-gettext/smarty-gettext": "^1.6", diff --git a/composer.lock b/composer.lock index 12f6d4a..aa9c02a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d6b6d55bcc8f884443734ed9e2b3d94f", + "content-hash": "1b8bd0ca72e9fbff0c51280a0c2c3e91", "packages": [ { "name": "aura/session", @@ -3820,66 +3820,45 @@ }, { "name": "phpstan/phpstan", - "version": "0.9.2", + "version": "0.12.25", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "e59541bcc7cac9b35ca54db6365bf377baf4a488" + "reference": "9619551d68b2d4c0d681a8df73f3c847c798ee64" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e59541bcc7cac9b35ca54db6365bf377baf4a488", - "reference": "e59541bcc7cac9b35ca54db6365bf377baf4a488", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9619551d68b2d4c0d681a8df73f3c847c798ee64", + "reference": "9619551d68b2d4c0d681a8df73f3c847c798ee64", "shasum": "" }, "require": { - "jean85/pretty-package-versions": "^1.0.3", - "nette/bootstrap": "^2.4 || ^3.0", - "nette/di": "^2.4.7 || ^3.0", - "nette/robot-loader": "^3.0.1", - "nette/utils": "^2.4.5 || ^3.0", - "nikic/php-parser": "^3.1", - "php": "~7.0", - "phpstan/phpdoc-parser": "^0.2", - "symfony/console": "~3.2 || ~4.0", - "symfony/finder": "~3.2 || ~4.0" + "php": "^7.1" }, - "require-dev": { - "consistence/coding-standard": "2.2.1", - "ext-gd": "*", - "ext-intl": "*", - "ext-mysqli": "*", - "jakub-onderka/php-parallel-lint": "^0.9.2", - "phing/phing": "^2.16.0", - "phpstan/phpstan-php-parser": "^0.9", - "phpstan/phpstan-phpunit": "^0.9.3", - "phpstan/phpstan-strict-rules": "^0.9", - "phpunit/phpunit": "^6.5.4", - "slevomat/coding-standard": "4.0.0" + "conflict": { + "phpstan/phpstan-shim": "*" }, "bin": [ - "bin/phpstan" + "phpstan", + "phpstan.phar" ], "type": "library", "extra": { "branch-alias": { - "dev-master": "0.9-dev" + "dev-master": "0.12-dev" } }, "autoload": { - "psr-4": { - "PHPStan\\": [ - "src/", - "build/PHPStan" - ] - } + "files": [ + "bootstrap.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "description": "PHPStan - PHP Static Analysis Tool", - "time": "2018-01-28T13:22:19+00:00" + "time": "2020-05-10T20:36:16+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/controllers/FrontController.php b/controllers/FrontController.php index e5f4536..0277cbc 100644 --- a/controllers/FrontController.php +++ b/controllers/FrontController.php @@ -45,7 +45,7 @@ class FrontController extends BaseController /** * Display index page. * - * @param Request $request PSR-7 request + * @param Request $request PSR-7 request * @param Response $response PSR-7 response * * @return Response HTTP response @@ -57,15 +57,15 @@ class FrontController extends BaseController $response, 'index.tpl', [ - 'config' => $this->config, - 'class' => 'index', - 'description' => $this->localeManager->t( + 'config' => $this->config, + 'class' => 'index', + 'description' => $this->localeManager->t( 'Easily download videos from Youtube, Dailymotion, Vimeo and other websites.' ), - 'domain' => $uri->getScheme() . '://' . $uri->getAuthority(), - 'canonical' => $this->getCanonicalUrl($request), + 'domain' => $uri->getScheme() . '://' . $uri->getAuthority(), + 'canonical' => $this->getCanonicalUrl($request), 'supportedLocales' => $this->localeManager->getSupportedLocales(), - 'locale' => $this->localeManager->getLocale(), + 'locale' => $this->localeManager->getLocale(), ] ); @@ -75,9 +75,9 @@ class FrontController extends BaseController /** * Switch locale. * - * @param Request $request PSR-7 request + * @param Request $request PSR-7 request * @param Response $response PSR-7 response - * @param array $data Query parameters + * @param string[] $data Query parameters * * @return Response */ @@ -103,14 +103,14 @@ class FrontController extends BaseController $response, 'extractors.tpl', [ - 'config' => $this->config, - 'extractors' => Video::getExtractors(), - 'class' => 'extractors', - 'title' => $this->localeManager->t('Supported websites'), + 'config' => $this->config, + 'extractors' => Video::getExtractors(), + 'class' => 'extractors', + 'title' => $this->localeManager->t('Supported websites'), 'description' => $this->localeManager->t('List of all supported websites from which Alltube Download ' . 'can extract video or audio files'), 'canonical' => $this->getCanonicalUrl($request), - 'locale' => $this->localeManager->getLocale(), + 'locale' => $this->localeManager->getLocale(), ] ); @@ -120,7 +120,7 @@ class FrontController extends BaseController /** * Display a password prompt. * - * @param Request $request PSR-7 request + * @param Request $request PSR-7 request * @param Response $response PSR-7 response * * @return Response HTTP response @@ -131,14 +131,14 @@ class FrontController extends BaseController $response, 'password.tpl', [ - 'config' => $this->config, - 'class' => 'password', - 'title' => $this->localeManager->t('Password prompt'), + 'config' => $this->config, + 'class' => 'password', + 'title' => $this->localeManager->t('Password prompt'), 'description' => $this->localeManager->t( 'You need a password in order to download this video with Alltube Download' ), - 'canonical' => $this->getCanonicalUrl($request), - 'locale' => $this->localeManager->getLocale(), + 'canonical' => $this->getCanonicalUrl($request), + 'locale' => $this->localeManager->getLocale(), ] ); @@ -148,7 +148,7 @@ class FrontController extends BaseController /** * Return the video description page. * - * @param Request $request PSR-7 request + * @param Request $request PSR-7 request * @param Response $response PSR-7 response * * @return Response HTTP response @@ -185,13 +185,13 @@ class FrontController extends BaseController $response, $template, [ - 'video' => $this->video, - 'class' => 'info', - 'title' => $title, - 'description' => $description, - 'config' => $this->config, - 'canonical' => $this->getCanonicalUrl($request), - 'locale' => $this->localeManager->getLocale(), + 'video' => $this->video, + 'class' => 'info', + 'title' => $title, + 'description' => $description, + 'config' => $this->config, + 'canonical' => $this->getCanonicalUrl($request), + 'locale' => $this->localeManager->getLocale(), 'defaultFormat' => $this->defaultFormat, ] ); @@ -202,7 +202,7 @@ class FrontController extends BaseController /** * Dislay information about the video. * - * @param Request $request PSR-7 request + * @param Request $request PSR-7 request * @param Response $response PSR-7 response * * @return Response HTTP response @@ -231,9 +231,9 @@ class FrontController extends BaseController /** * Display an error page. * - * @param Request $request PSR-7 request - * @param Response $response PSR-7 response - * @param Throwable $error Error to display + * @param Request $request PSR-7 request + * @param Response $response PSR-7 response + * @param Throwable $error Error to display * * @return Response HTTP response */ @@ -256,12 +256,12 @@ class FrontController extends BaseController $response, 'error.tpl', [ - 'config' => $this->config, - 'error' => $message, - 'class' => 'video', - 'title' => $this->localeManager->t('Error'), + 'config' => $this->config, + 'error' => $message, + 'class' => 'video', + 'title' => $this->localeManager->t('Error'), 'canonical' => $this->getCanonicalUrl($request), - 'locale' => $this->localeManager->getLocale(), + 'locale' => $this->localeManager->getLocale(), ] ); diff --git a/index.php b/index.php index 6dd0a45..0b7772c 100644 --- a/index.php +++ b/index.php @@ -10,6 +10,7 @@ use Alltube\LocaleMiddleware; use Alltube\UglyRouter; use Alltube\ViewFactory; use Slim\App; +use Slim\Container; use Symfony\Component\Debug\Debug; if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/index.php') !== false) { @@ -23,6 +24,8 @@ if (is_file(__DIR__ . '/config/config.yml')) { // Create app. $app = new App(); + +/** @var Container $container */ $container = $app->getContainer(); // Load config. diff --git a/tests/ControllerTest.php b/tests/ControllerTest.php index cea9f59..bd9f737 100644 --- a/tests/ControllerTest.php +++ b/tests/ControllerTest.php @@ -6,6 +6,7 @@ namespace Alltube\Test; +use Alltube\Controller\BaseController; use Alltube\Controller\DownloadController; use Alltube\Controller\FrontController; use Alltube\LocaleManager; @@ -44,6 +45,7 @@ abstract class ControllerTest extends BaseTest /** * Controller instance used in tests. + * @var BaseController */ protected $controller; @@ -80,7 +82,7 @@ abstract class ControllerTest extends BaseTest * Run controller function with custom query parameters and return the result. * * @param string $request Controller function to call - * @param array $params Query parameters + * @param mixed[] $params Query parameters * * @return Response HTTP response */ @@ -96,7 +98,7 @@ abstract class ControllerTest extends BaseTest * Assert that calling controller function with these parameters returns a 200 HTTP response. * * @param string $request Controller function to call - * @param array $params Query parameters + * @param mixed[] $params Query parameters * * @return void */ @@ -109,7 +111,7 @@ abstract class ControllerTest extends BaseTest * Assert that calling controller function with these parameters returns an HTTP redirect. * * @param string $request Controller function to call - * @param array $params Query parameters + * @param mixed[] $params Query parameters * * @return void */ @@ -122,7 +124,7 @@ abstract class ControllerTest extends BaseTest * Assert that calling controller function with these parameters returns an HTTP 500 error. * * @param string $request Controller function to call - * @param array $params Query parameters + * @param mixed[] $params Query parameters * * @return void */ @@ -135,7 +137,7 @@ abstract class ControllerTest extends BaseTest * Assert that calling controller function with these parameters returns an HTTP 400 error. * * @param string $request Controller function to call - * @param array $params Query parameters + * @param mixed[] $params Query parameters * * @return void */ diff --git a/tests/FrontControllerTest.php b/tests/FrontControllerTest.php index f75a457..92e4824 100644 --- a/tests/FrontControllerTest.php +++ b/tests/FrontControllerTest.php @@ -17,6 +17,12 @@ use Slim\Http\Request; */ class FrontControllerTest extends ControllerTest { + /** + * Controller instance used in tests. + * @var FrontController + */ + protected $controller; + /** * Prepare tests. * @throws Exception diff --git a/tests/StreamTest.php b/tests/StreamTest.php index 7ffe235..bcd3887 100644 --- a/tests/StreamTest.php +++ b/tests/StreamTest.php @@ -6,6 +6,7 @@ namespace Alltube\Test; +use Psr\Http\Message\StreamInterface; use RuntimeException; /** @@ -15,6 +16,7 @@ abstract class StreamTest extends BaseTest { /** * Stream instance. + * @var StreamInterface */ protected $stream;