Add return types

This commit is contained in:
Pierre Rudloff 2020-12-17 22:45:50 +01:00
parent ec18e416a2
commit f670629d49

View file

@ -115,7 +115,7 @@ class Downloader
* @param string|null $password Password
* @return Video
*/
public function getVideo(string $webpageUrl, $requestedFormat = 'best/bestvideo', string $password = null)
public function getVideo(string $webpageUrl, $requestedFormat = 'best/bestvideo', string $password = null): Video
{
return new Video($this, $webpageUrl, $requestedFormat, $password);
}
@ -127,7 +127,7 @@ class Downloader
*
* @return Process<string>
*/
private function getProcess(array $arguments)
private function getProcess(array $arguments): Process
{
return new Process(
array_merge(
@ -145,7 +145,7 @@ class Downloader
*
* @return bool False if the command returns an error, true otherwise
*/
public static function checkCommand(array $command)
public static function checkCommand(array $command): bool
{
$process = new Process($command);
$process->run();
@ -178,7 +178,7 @@ class Downloader
$audioOnly = true,
string $from = null,
string $to = null
) {
): Process {
if (!$this->checkCommand([$this->avconv, '-version'])) {
throw new AvconvException($this->avconv);
}
@ -246,7 +246,7 @@ class Downloader
* @throws YoutubedlException If youtube-dl returns an error
* @throws PasswordException If the video is protected by a password and no password was specified
*/
public function callYoutubedl(array $arguments)
public function callYoutubedl(array $arguments): string
{
$process = $this->getProcess($arguments);
//This is needed by the openload extractor because it runs PhantomJS
@ -468,7 +468,7 @@ class Downloader
*
* @throws AlltubeLibraryException
*/
public function getExtractors()
public function getExtractors(): array
{
return explode("\n", trim($this->callYoutubedl(['--list-extractors'])));
}
@ -484,7 +484,7 @@ class Downloader
* @throws AlltubeLibraryException
* @link https://github.com/guzzle/guzzle/issues/2640
*/
public function getHttpResponse(Video $video, array $headers = [])
public function getHttpResponse(Video $video, array $headers = []): ResponseInterface
{
// IDN conversion breaks with Google hosts like https://r3---sn-25glene6.googlevideo.com/.
$client = new Client(['idn_conversion' => false]);