phpstan update

Better typying
This commit is contained in:
Pierre Rudloff 2020-05-13 22:28:05 +02:00
parent 74db3b9ad0
commit 6adc1df213
17 changed files with 166 additions and 158 deletions

View file

@ -40,7 +40,7 @@ class Config
/** /**
* youtube-dl parameters. * youtube-dl parameters.
* *
* @var array * @var string[]
*/ */
public $params = ['--no-warnings', '--ignore-errors', '--flat-playlist', '--restrict-filenames', '--no-playlist']; 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. * List of formats available in advanced conversion mode.
* *
* @var array * @var string[]
*/ */
public $convertAdvancedFormats = ['mp3', 'avi', 'flv', 'wav']; public $convertAdvancedFormats = ['mp3', 'avi', 'flv', 'wav'];
@ -125,7 +125,7 @@ class Config
/** /**
* Generic formats supported by youtube-dl. * Generic formats supported by youtube-dl.
* *
* @var array * @var string[]
*/ */
public $genericFormats = []; public $genericFormats = [];
@ -139,7 +139,8 @@ class Config
/** /**
* Config constructor. * Config constructor.
* *
* @param array $options Options * @param mixed[] $options Options
* @throws CaseConverterException
*/ */
private function __construct(array $options = []) private function __construct(array $options = [])
{ {
@ -210,7 +211,7 @@ class Config
/** /**
* Apply the provided options. * Apply the provided options.
* *
* @param array $options Options * @param mixed[] $options Options
* *
* @return void * @return void
*/ */
@ -260,12 +261,13 @@ class Config
* Set options from a YAML file. * Set options from a YAML file.
* *
* @param string $file Path to the YAML file * @param string $file Path to the YAML file
* @return void
* @throws Exception * @throws Exception
*/ */
public static function setFile($file) public static function setFile($file)
{ {
if (is_file($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 = new self($options);
self::$instance->validateOptions(); self::$instance->validateOptions();
} else { } else {
@ -276,8 +278,9 @@ class Config
/** /**
* Manually set some options. * 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 * @param bool $update True to update an existing instance
* @return void
* @throws Exception * @throws Exception
*/ */
public static function setOptions(array $options, $update = true) public static function setOptions(array $options, $update = true)

View file

@ -104,7 +104,7 @@ class Locale
/** /**
* Get country information from locale. * Get country information from locale.
* *
* @return Country|array|null * @return Country|Country[]|null
*/ */
public function getCountry() public function getCountry()
{ {

View file

@ -18,7 +18,7 @@ class LocaleManager
/** /**
* Supported locales. * 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']; 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. * Set the current locale.
* *
* @param Locale $locale Locale * @param Locale $locale Locale
* @return void
*/ */
public function setLocale(Locale $locale) public function setLocale(Locale $locale)
{ {
@ -121,6 +122,7 @@ class LocaleManager
/** /**
* Unset the current locale. * Unset the current locale.
* @return void
*/ */
public function unsetLocale() public function unsetLocale()
{ {
@ -132,8 +134,8 @@ class LocaleManager
/** /**
* Smarty "t" block. * Smarty "t" block.
* *
* @param array $params Block parameters * @param mixed[] $params Block parameters
* @param string $text Block content * @param string $text Block content
* *
* @return string Translated string * @return string Translated string
*/ */
@ -151,6 +153,7 @@ class LocaleManager
* *
* @param string $string String to translate * @param string $string String to translate
* *
* @param mixed[] $params
* @return string Translated string * @return string Translated string
*/ */
public function t($string, array $params = []) public function t($string, array $params = [])

View file

@ -36,7 +36,7 @@ class LocaleMiddleware
/** /**
* Test if a locale can be used for the current user. * 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 * @return Locale|null Locale if chosen, nothing otherwise
*/ */
@ -59,9 +59,9 @@ class LocaleMiddleware
/** /**
* Main middleware function. * Main middleware function.
* *
* @param Request $request PSR request * @param Request $request PSR request
* @param Response $response PSR response * @param Response $response PSR response
* @param callable $next Next middleware * @param callable $next Next middleware
* *
* @return Response * @return Response
*/ */

View file

@ -21,7 +21,7 @@ class UglyRouter extends Router
* *
* @param ServerRequestInterface $request The current HTTP request object * @param ServerRequestInterface $request The current HTTP request object
* *
* @return array * @return mixed[]
* *
* @link https://github.com/nikic/FastRoute/blob/master/src/Dispatcher.php * @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. * Build the path for a named route including the base path.
* *
* @param string $name Route name * @param string $name Route name
* @param array $data Named argument replacement data * @param string[] $data Named argument replacement data
* @param array $queryParams Optional query string parameters * @param string[] $queryParams Optional query string parameters
*
* @throws RuntimeException If named route does not exist
* @throws InvalidArgumentException If required data not provided
* *
* @return string * @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 = []) public function pathFor($name, array $data = [], array $queryParams = [])
{ {

View file

@ -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. * Due to the way youtube-dl behaves, this class can also contain information about a playlist.
* *
* @property-read string $title Title * @property-read string $title Title
* @property-read string $protocol Network protocol (HTTP, RTMP, etc.) * @property-read string $protocol Network protocol (HTTP, RTMP, etc.)
* @property-read string $url File URL * @property-read string $url File URL
* @property-read string $ext File extension * @property-read string $ext File extension
* @property-read string $extractor_key youtube-dl extractor class used * @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 $entries List of videos (if the object contains information about a playlist)
* @property-read array $rtmp_conn * @property-read array $rtmp_conn
* @property-read string|null $_type Object type (usually "playlist" or null) * @property-read string|null $_type Object type (usually "playlist" or null)
* @property-read stdClass $downloader_options * @property-read stdClass $downloader_options
* @property-read stdClass $http_headers * @property-read stdClass $http_headers
*/ */
class Video class Video
{ {
@ -70,7 +70,7 @@ class Video
/** /**
* URLs of the video files. * URLs of the video files.
* *
* @var array * @var string[]
*/ */
private $urls; private $urls;
@ -84,11 +84,11 @@ class Video
/** /**
* VideoDownload constructor. * 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 * @param string $requestedFormat Requested video format
* (can be any format string accepted by youtube-dl, * (can be any format string accepted by youtube-dl,
* including selectors like "[height<=720]") * including selectors like "[height<=720]")
* @param string $password Password * @param string $password Password
*/ */
public function __construct($webpageUrl, $requestedFormat = 'best', $password = null) public function __construct($webpageUrl, $requestedFormat = 'best', $password = null)
{ {
@ -105,7 +105,7 @@ class Video
* *
* @param string[] $arguments Arguments * @param string[] $arguments Arguments
* *
* @return Process * @return Process<string>
*/ */
private static function getProcess(array $arguments) private static function getProcess(array $arguments)
{ {
@ -137,13 +137,13 @@ class Video
/** /**
* Call youtube-dl. * 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 the password is wrong
* @throws Exception If youtube-dl returns an error * @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) private function callYoutubedl(array $arguments)
{ {
@ -155,7 +155,7 @@ class Video
$process->run(); $process->run();
if (!$process->isSuccessful()) { if (!$process->isSuccessful()) {
$errorOutput = trim($process->getErrorOutput()); $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') { if ($errorOutput == 'ERROR: This video is protected by a password, use the --video-password option') {
throw new PasswordException($errorOutput, $exitCode); throw new PasswordException($errorOutput, $exitCode);
} elseif (substr($errorOutput, 0, 21) == 'ERROR: Wrong password') { } 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 arguments used to run rtmp for a specific video.
* *
* @return array Arguments * @return string[] Arguments
*/ */
private function getRtmpArguments() private function getRtmpArguments()
{ {
@ -303,12 +303,12 @@ class Video
if ($this->protocol == 'rtmp') { if ($this->protocol == 'rtmp') {
foreach ( foreach (
[ [
'url' => '-rtmp_tcurl', 'url' => '-rtmp_tcurl',
'webpage_url' => '-rtmp_pageurl', 'webpage_url' => '-rtmp_pageurl',
'player_url' => '-rtmp_swfverify', 'player_url' => '-rtmp_swfverify',
'flash_version' => '-rtmp_flashver', 'flash_version' => '-rtmp_flashver',
'play_path' => '-rtmp_playpath', 'play_path' => '-rtmp_playpath',
'app' => '-rtmp_app', 'app' => '-rtmp_app',
] as $property => $option ] as $property => $option
) { ) {
if (isset($this->{$property})) { if (isset($this->{$property})) {
@ -331,7 +331,7 @@ class Video
/** /**
* Check if a command runs successfully. * 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 * @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. * Get a process that runs avconv in order to convert a video.
* *
* @param int $audioBitrate Audio bitrate of the converted file * @param int $audioBitrate Audio bitrate of the converted file
* @param string $filetype Filetype of the converted file * @param string $filetype Filetype of the converted file
* @param bool $audioOnly True to return an audio-only file * @param bool $audioOnly True to return an audio-only file
* @param string $from Start the conversion at this time * @param string $from Start the conversion at this time
* @param string $to End the conversion at this time * @param string $to End the conversion at this time
* *
* @return Process<string> Process
* @throws Exception If avconv/ffmpeg is missing * @throws Exception If avconv/ffmpeg is missing
* *
* @return Process Process
*/ */
private function getAvconvProcess( private function getAvconvProcess(
$audioBitrate, $audioBitrate,
@ -425,12 +425,12 @@ class Video
* Get audio stream of converted video. * Get audio stream of converted video.
* *
* @param string $from Start the conversion at this time * @param string $from Start the conversion at this time
* @param string $to End 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
* *
* @return resource popen stream * @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) public function getAudioStream($from = null, $to = null)
{ {
@ -460,10 +460,10 @@ class Video
/** /**
* Get video stream from an M3U playlist. * 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 * @throws Exception If the popen stream was not created correctly
* *
* @return resource popen stream * @throws Exception If avconv/ffmpeg is missing
*/ */
public function getM3uStream() public function getM3uStream()
{ {
@ -502,9 +502,9 @@ class Video
/** /**
* Get an avconv stream to remux audio and video. * Get an avconv stream to remux audio and video.
* *
* @return resource popen stream
* @throws Exception If the popen stream was not created correctly * @throws Exception If the popen stream was not created correctly
* *
* @return resource popen stream
*/ */
public function getRemuxStream() public function getRemuxStream()
{ {
@ -539,9 +539,9 @@ class Video
/** /**
* Get video stream from an RTMP video. * Get video stream from an RTMP video.
* *
* @return resource popen stream
* @throws Exception If the popen stream was not created correctly * @throws Exception If the popen stream was not created correctly
* *
* @return resource popen stream
*/ */
public function getRtmpStream() public function getRtmpStream()
{ {
@ -572,13 +572,13 @@ class Video
/** /**
* Get the stream of a converted video. * Get the stream of a converted video.
* *
* @param int $audioBitrate Audio bitrate of the converted file * @param int $audioBitrate Audio bitrate of the converted file
* @param string $filetype Filetype 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
* *
* @return resource popen stream * @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) public function getConvertedStream($audioBitrate, $filetype)
{ {
@ -612,7 +612,7 @@ class Video
/** /**
* Get a HTTP response containing the 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 * @return ResponseInterface
* @throws EmptyUrlException * @throws EmptyUrlException
@ -628,7 +628,7 @@ class Video
$urls[0], $urls[0],
[ [
'stream' => true, 'stream' => true,
'headers' => array_merge((array) $this->http_headers, $headers) 'headers' => array_merge((array)$this->http_headers, $headers)
] ]
); );
} }

View file

@ -29,7 +29,7 @@ class ViewFactory
public static function create(ContainerInterface $container, Request $request = null) public static function create(ContainerInterface $container, Request $request = null)
{ {
if (!isset($request)) { if (!isset($request)) {
$request = $container['request']; $request = $container->get('request');
} }
$view = new Smarty(__DIR__ . '/../templates/'); $view = new Smarty(__DIR__ . '/../templates/');
@ -37,9 +37,10 @@ class ViewFactory
$request = $request->withUri($request->getUri()->withScheme('https')->withPort(443)); $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', 'path_for', [$smartyPlugins, 'pathFor']);
$view->registerPlugin('function', 'base_url', [$smartyPlugins, 'baseUrl']); $view->registerPlugin('function', 'base_url', [$smartyPlugins, 'baseUrl']);
$view->registerPlugin('block', 't', [$localeManager, 'smartyTranslate']); $view->registerPlugin('block', 't', [$localeManager, 'smartyTranslate']);

View file

@ -6,6 +6,8 @@
namespace Alltube\Stream; namespace Alltube\Stream;
use Alltube\Exception\EmptyUrlException;
use Alltube\Exception\PasswordException;
use Alltube\Video; use Alltube\Video;
use Barracuda\ArchiveStream\ZipArchive; use Barracuda\ArchiveStream\ZipArchive;
use Psr\Http\Message\StreamInterface; 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 * @param string $string The string that is to be written
* *
* @return void * @return int|false
*/ */
public function write($string) public function write($string)
{ {
fwrite($this->buffer, $string); return fwrite($this->buffer, $string);
} }
/** /**
* Get the size of the stream if known. * Get the size of the stream if known.
* *
* @return void * @return int|null
*/ */
public function getSize() public function getSize()
{ {
return null;
} }
/** /**
@ -145,7 +148,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
/** /**
* Returns the remaining contents in a string. * Returns the remaining contents in a string.
* *
* @return string * @return string|false
*/ */
public function getContents() public function getContents()
{ {
@ -196,7 +199,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
{ {
$this->rewind(); $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 * @param Video $video Video to stream
* *
* @return void * @return void
* @throws PasswordException
* @throws EmptyUrlException
*/ */
protected function startVideoStream(Video $video) protected function startVideoStream(Video $video)
{ {
@ -248,7 +253,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
$this->init_file_stream_transfer( $this->init_file_stream_transfer(
$video->getFilename(), $video->getFilename(),
$contentLengthHeaders[0] intval($contentLengthHeaders[0])
); );
} }

View file

@ -41,7 +41,7 @@ class YoutubeChunkStream implements StreamInterface
*/ */
public function read($length) public function read($length)
{ {
$size = $this->response->getHeader('Content-Length')[0]; $size = intval($this->response->getHeader('Content-Length')[0]);
if ($size - $this->tell() < $length) { if ($size - $this->tell() < $length) {
// Don't try to read further than the end of the stream. // Don't try to read further than the end of the stream.
$length = $size - $this->tell(); $length = $size - $this->tell();
@ -55,7 +55,7 @@ class YoutubeChunkStream implements StreamInterface
*/ */
public function __toString() public function __toString()
{ {
return (string) $this->response->getBody(); return (string)$this->response->getBody();
} }
/** /**

View file

@ -6,6 +6,8 @@
namespace Alltube\Stream; namespace Alltube\Stream;
use Alltube\Exception\EmptyUrlException;
use Alltube\Exception\PasswordException;
use Alltube\Video; use Alltube\Video;
use GuzzleHttp\Psr7\AppendStream; use GuzzleHttp\Psr7\AppendStream;
@ -19,6 +21,8 @@ class YoutubeStream extends AppendStream
* YoutubeStream constructor. * YoutubeStream constructor.
* *
* @param Video $video Video to stream * @param Video $video Video to stream
* @throws EmptyUrlException
* @throws PasswordException
*/ */
public function __construct(Video $video) public function __construct(Video $video)
{ {
@ -31,7 +35,7 @@ class YoutubeStream extends AppendStream
while ($rangeStart < $contentLenghtHeader[0]) { while ($rangeStart < $contentLenghtHeader[0]) {
$rangeEnd = $rangeStart + $video->downloader_options->http_chunk_size; $rangeEnd = $rangeStart + $video->downloader_options->http_chunk_size;
if ($rangeEnd >= $contentLenghtHeader[0]) { if ($rangeEnd >= $contentLenghtHeader[0]) {
$rangeEnd = $contentLenghtHeader[0] - 1; $rangeEnd = intval($contentLenghtHeader[0]) - 1;
} }
$response = $video->getHttpResponse(['Range' => 'bytes=' . $rangeStart . '-' . $rangeEnd]); $response = $video->getHttpResponse(['Range' => 'bytes=' . $rangeStart . '-' . $rangeEnd]);
$this->addStream(new YoutubeChunkStream($response)); $this->addStream(new YoutubeChunkStream($response));

View file

@ -27,7 +27,7 @@
"heroku/heroku-buildpack-php": "^162.0", "heroku/heroku-buildpack-php": "^162.0",
"php-mock/php-mock-mockery": "^1.3", "php-mock/php-mock-mockery": "^1.3",
"phpro/grumphp": "^0.17.0", "phpro/grumphp": "^0.17.0",
"phpstan/phpstan": "~0.9.2", "phpstan/phpstan": "^0.12.25",
"phpunit/phpunit": "^8.4", "phpunit/phpunit": "^8.4",
"roave/security-advisories": "dev-master", "roave/security-advisories": "dev-master",
"smarty-gettext/smarty-gettext": "^1.6", "smarty-gettext/smarty-gettext": "^1.6",

51
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "d6b6d55bcc8f884443734ed9e2b3d94f", "content-hash": "1b8bd0ca72e9fbff0c51280a0c2c3e91",
"packages": [ "packages": [
{ {
"name": "aura/session", "name": "aura/session",
@ -3820,66 +3820,45 @@
}, },
{ {
"name": "phpstan/phpstan", "name": "phpstan/phpstan",
"version": "0.9.2", "version": "0.12.25",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan.git", "url": "https://github.com/phpstan/phpstan.git",
"reference": "e59541bcc7cac9b35ca54db6365bf377baf4a488" "reference": "9619551d68b2d4c0d681a8df73f3c847c798ee64"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/e59541bcc7cac9b35ca54db6365bf377baf4a488", "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9619551d68b2d4c0d681a8df73f3c847c798ee64",
"reference": "e59541bcc7cac9b35ca54db6365bf377baf4a488", "reference": "9619551d68b2d4c0d681a8df73f3c847c798ee64",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"jean85/pretty-package-versions": "^1.0.3", "php": "^7.1"
"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"
}, },
"require-dev": { "conflict": {
"consistence/coding-standard": "2.2.1", "phpstan/phpstan-shim": "*"
"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"
}, },
"bin": [ "bin": [
"bin/phpstan" "phpstan",
"phpstan.phar"
], ],
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "0.9-dev" "dev-master": "0.12-dev"
} }
}, },
"autoload": { "autoload": {
"psr-4": { "files": [
"PHPStan\\": [ "bootstrap.php"
"src/", ]
"build/PHPStan"
]
}
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
"MIT" "MIT"
], ],
"description": "PHPStan - PHP Static Analysis Tool", "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", "name": "phpunit/php-code-coverage",

View file

@ -45,7 +45,7 @@ class FrontController extends BaseController
/** /**
* Display index page. * Display index page.
* *
* @param Request $request PSR-7 request * @param Request $request PSR-7 request
* @param Response $response PSR-7 response * @param Response $response PSR-7 response
* *
* @return Response HTTP response * @return Response HTTP response
@ -57,15 +57,15 @@ class FrontController extends BaseController
$response, $response,
'index.tpl', 'index.tpl',
[ [
'config' => $this->config, 'config' => $this->config,
'class' => 'index', 'class' => 'index',
'description' => $this->localeManager->t( 'description' => $this->localeManager->t(
'Easily download videos from Youtube, Dailymotion, Vimeo and other websites.' 'Easily download videos from Youtube, Dailymotion, Vimeo and other websites.'
), ),
'domain' => $uri->getScheme() . '://' . $uri->getAuthority(), 'domain' => $uri->getScheme() . '://' . $uri->getAuthority(),
'canonical' => $this->getCanonicalUrl($request), 'canonical' => $this->getCanonicalUrl($request),
'supportedLocales' => $this->localeManager->getSupportedLocales(), 'supportedLocales' => $this->localeManager->getSupportedLocales(),
'locale' => $this->localeManager->getLocale(), 'locale' => $this->localeManager->getLocale(),
] ]
); );
@ -75,9 +75,9 @@ class FrontController extends BaseController
/** /**
* Switch locale. * Switch locale.
* *
* @param Request $request PSR-7 request * @param Request $request PSR-7 request
* @param Response $response PSR-7 response * @param Response $response PSR-7 response
* @param array $data Query parameters * @param string[] $data Query parameters
* *
* @return Response * @return Response
*/ */
@ -103,14 +103,14 @@ class FrontController extends BaseController
$response, $response,
'extractors.tpl', 'extractors.tpl',
[ [
'config' => $this->config, 'config' => $this->config,
'extractors' => Video::getExtractors(), 'extractors' => Video::getExtractors(),
'class' => 'extractors', 'class' => 'extractors',
'title' => $this->localeManager->t('Supported websites'), 'title' => $this->localeManager->t('Supported websites'),
'description' => $this->localeManager->t('List of all supported websites from which Alltube Download ' . 'description' => $this->localeManager->t('List of all supported websites from which Alltube Download ' .
'can extract video or audio files'), 'can extract video or audio files'),
'canonical' => $this->getCanonicalUrl($request), 'canonical' => $this->getCanonicalUrl($request),
'locale' => $this->localeManager->getLocale(), 'locale' => $this->localeManager->getLocale(),
] ]
); );
@ -120,7 +120,7 @@ class FrontController extends BaseController
/** /**
* Display a password prompt. * Display a password prompt.
* *
* @param Request $request PSR-7 request * @param Request $request PSR-7 request
* @param Response $response PSR-7 response * @param Response $response PSR-7 response
* *
* @return Response HTTP response * @return Response HTTP response
@ -131,14 +131,14 @@ class FrontController extends BaseController
$response, $response,
'password.tpl', 'password.tpl',
[ [
'config' => $this->config, 'config' => $this->config,
'class' => 'password', 'class' => 'password',
'title' => $this->localeManager->t('Password prompt'), 'title' => $this->localeManager->t('Password prompt'),
'description' => $this->localeManager->t( 'description' => $this->localeManager->t(
'You need a password in order to download this video with Alltube Download' 'You need a password in order to download this video with Alltube Download'
), ),
'canonical' => $this->getCanonicalUrl($request), 'canonical' => $this->getCanonicalUrl($request),
'locale' => $this->localeManager->getLocale(), 'locale' => $this->localeManager->getLocale(),
] ]
); );
@ -148,7 +148,7 @@ class FrontController extends BaseController
/** /**
* Return the video description page. * Return the video description page.
* *
* @param Request $request PSR-7 request * @param Request $request PSR-7 request
* @param Response $response PSR-7 response * @param Response $response PSR-7 response
* *
* @return Response HTTP response * @return Response HTTP response
@ -185,13 +185,13 @@ class FrontController extends BaseController
$response, $response,
$template, $template,
[ [
'video' => $this->video, 'video' => $this->video,
'class' => 'info', 'class' => 'info',
'title' => $title, 'title' => $title,
'description' => $description, 'description' => $description,
'config' => $this->config, 'config' => $this->config,
'canonical' => $this->getCanonicalUrl($request), 'canonical' => $this->getCanonicalUrl($request),
'locale' => $this->localeManager->getLocale(), 'locale' => $this->localeManager->getLocale(),
'defaultFormat' => $this->defaultFormat, 'defaultFormat' => $this->defaultFormat,
] ]
); );
@ -202,7 +202,7 @@ class FrontController extends BaseController
/** /**
* Dislay information about the video. * Dislay information about the video.
* *
* @param Request $request PSR-7 request * @param Request $request PSR-7 request
* @param Response $response PSR-7 response * @param Response $response PSR-7 response
* *
* @return Response HTTP response * @return Response HTTP response
@ -231,9 +231,9 @@ class FrontController extends BaseController
/** /**
* Display an error page. * Display an error page.
* *
* @param Request $request PSR-7 request * @param Request $request PSR-7 request
* @param Response $response PSR-7 response * @param Response $response PSR-7 response
* @param Throwable $error Error to display * @param Throwable $error Error to display
* *
* @return Response HTTP response * @return Response HTTP response
*/ */
@ -256,12 +256,12 @@ class FrontController extends BaseController
$response, $response,
'error.tpl', 'error.tpl',
[ [
'config' => $this->config, 'config' => $this->config,
'error' => $message, 'error' => $message,
'class' => 'video', 'class' => 'video',
'title' => $this->localeManager->t('Error'), 'title' => $this->localeManager->t('Error'),
'canonical' => $this->getCanonicalUrl($request), 'canonical' => $this->getCanonicalUrl($request),
'locale' => $this->localeManager->getLocale(), 'locale' => $this->localeManager->getLocale(),
] ]
); );

View file

@ -10,6 +10,7 @@ use Alltube\LocaleMiddleware;
use Alltube\UglyRouter; use Alltube\UglyRouter;
use Alltube\ViewFactory; use Alltube\ViewFactory;
use Slim\App; use Slim\App;
use Slim\Container;
use Symfony\Component\Debug\Debug; use Symfony\Component\Debug\Debug;
if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/index.php') !== false) { 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. // Create app.
$app = new App(); $app = new App();
/** @var Container $container */
$container = $app->getContainer(); $container = $app->getContainer();
// Load config. // Load config.

View file

@ -6,6 +6,7 @@
namespace Alltube\Test; namespace Alltube\Test;
use Alltube\Controller\BaseController;
use Alltube\Controller\DownloadController; use Alltube\Controller\DownloadController;
use Alltube\Controller\FrontController; use Alltube\Controller\FrontController;
use Alltube\LocaleManager; use Alltube\LocaleManager;
@ -44,6 +45,7 @@ abstract class ControllerTest extends BaseTest
/** /**
* Controller instance used in tests. * Controller instance used in tests.
* @var BaseController
*/ */
protected $controller; protected $controller;
@ -80,7 +82,7 @@ abstract class ControllerTest extends BaseTest
* Run controller function with custom query parameters and return the result. * Run controller function with custom query parameters and return the result.
* *
* @param string $request Controller function to call * @param string $request Controller function to call
* @param array $params Query parameters * @param mixed[] $params Query parameters
* *
* @return Response HTTP response * @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. * Assert that calling controller function with these parameters returns a 200 HTTP response.
* *
* @param string $request Controller function to call * @param string $request Controller function to call
* @param array $params Query parameters * @param mixed[] $params Query parameters
* *
* @return void * @return void
*/ */
@ -109,7 +111,7 @@ abstract class ControllerTest extends BaseTest
* Assert that calling controller function with these parameters returns an HTTP redirect. * Assert that calling controller function with these parameters returns an HTTP redirect.
* *
* @param string $request Controller function to call * @param string $request Controller function to call
* @param array $params Query parameters * @param mixed[] $params Query parameters
* *
* @return void * @return void
*/ */
@ -122,7 +124,7 @@ abstract class ControllerTest extends BaseTest
* Assert that calling controller function with these parameters returns an HTTP 500 error. * Assert that calling controller function with these parameters returns an HTTP 500 error.
* *
* @param string $request Controller function to call * @param string $request Controller function to call
* @param array $params Query parameters * @param mixed[] $params Query parameters
* *
* @return void * @return void
*/ */
@ -135,7 +137,7 @@ abstract class ControllerTest extends BaseTest
* Assert that calling controller function with these parameters returns an HTTP 400 error. * Assert that calling controller function with these parameters returns an HTTP 400 error.
* *
* @param string $request Controller function to call * @param string $request Controller function to call
* @param array $params Query parameters * @param mixed[] $params Query parameters
* *
* @return void * @return void
*/ */

View file

@ -17,6 +17,12 @@ use Slim\Http\Request;
*/ */
class FrontControllerTest extends ControllerTest class FrontControllerTest extends ControllerTest
{ {
/**
* Controller instance used in tests.
* @var FrontController
*/
protected $controller;
/** /**
* Prepare tests. * Prepare tests.
* @throws Exception * @throws Exception

View file

@ -6,6 +6,7 @@
namespace Alltube\Test; namespace Alltube\Test;
use Psr\Http\Message\StreamInterface;
use RuntimeException; use RuntimeException;
/** /**
@ -15,6 +16,7 @@ abstract class StreamTest extends BaseTest
{ {
/** /**
* Stream instance. * Stream instance.
* @var StreamInterface
*/ */
protected $stream; protected $stream;