Add return types
This commit is contained in:
parent
f2785bca03
commit
05311ac7b6
21 changed files with 84 additions and 78 deletions
|
@ -187,7 +187,7 @@ class Config
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function addHttpToFormat(string $format)
|
public static function addHttpToFormat(string $format): string
|
||||||
{
|
{
|
||||||
$newFormat = [];
|
$newFormat = [];
|
||||||
foreach (explode('/', $format) as $subformat) {
|
foreach (explode('/', $format) as $subformat) {
|
||||||
|
@ -266,7 +266,7 @@ class Config
|
||||||
* @return Config
|
* @return Config
|
||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
*/
|
*/
|
||||||
public static function fromFile(string $file)
|
public static function fromFile(string $file): Config
|
||||||
{
|
{
|
||||||
if (is_file($file)) {
|
if (is_file($file)) {
|
||||||
return new self(Yaml::parse(strval(file_get_contents($file))));
|
return new self(Yaml::parse(strval(file_get_contents($file))));
|
||||||
|
@ -293,7 +293,7 @@ class Config
|
||||||
*
|
*
|
||||||
* @return Downloader
|
* @return Downloader
|
||||||
*/
|
*/
|
||||||
public function getDownloader()
|
public function getDownloader(): Downloader
|
||||||
{
|
{
|
||||||
return new Downloader(
|
return new Downloader(
|
||||||
$this->youtubedl,
|
$this->youtubedl,
|
||||||
|
@ -308,7 +308,7 @@ class Config
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getAppVersion()
|
public function getAppVersion(): string
|
||||||
{
|
{
|
||||||
$version = PrettyVersions::getRootPackageVersion();
|
$version = PrettyVersions::getRootPackageVersion();
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ abstract class BaseController
|
||||||
*
|
*
|
||||||
* @return string format
|
* @return string format
|
||||||
*/
|
*/
|
||||||
protected function getFormat(Request $request)
|
protected function getFormat(Request $request): string
|
||||||
{
|
{
|
||||||
$format = $request->getQueryParam('format');
|
$format = $request->getQueryParam('format');
|
||||||
if (!isset($format)) {
|
if (!isset($format)) {
|
||||||
|
@ -126,9 +126,9 @@ abstract class BaseController
|
||||||
*
|
*
|
||||||
* @param Request $request PSR-7 request
|
* @param Request $request PSR-7 request
|
||||||
*
|
*
|
||||||
* @return string Password
|
* @return string|null Password
|
||||||
*/
|
*/
|
||||||
protected function getPassword(Request $request)
|
protected function getPassword(Request $request): ?string
|
||||||
{
|
{
|
||||||
$url = $request->getQueryParam('url');
|
$url = $request->getQueryParam('url');
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ abstract class BaseController
|
||||||
*
|
*
|
||||||
* @return Response HTTP response
|
* @return Response HTTP response
|
||||||
*/
|
*/
|
||||||
protected function displayError(Request $request, Response $response, string $message)
|
protected function displayError(Request $request, Response $response, string $message): Response
|
||||||
{
|
{
|
||||||
$controller = new FrontController($this->container);
|
$controller = new FrontController($this->container);
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ class DownloadController extends BaseController
|
||||||
* @return Response HTTP response
|
* @return Response HTTP response
|
||||||
* @throws AlltubeLibraryException
|
* @throws AlltubeLibraryException
|
||||||
*/
|
*/
|
||||||
public function download(Request $request, Response $response)
|
public function download(Request $request, Response $response): Response
|
||||||
{
|
{
|
||||||
$url = $request->getQueryParam('url');
|
$url = $request->getQueryParam('url');
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ class DownloadController extends BaseController
|
||||||
* @return Response HTTP response
|
* @return Response HTTP response
|
||||||
* @throws AlltubeLibraryException
|
* @throws AlltubeLibraryException
|
||||||
*/
|
*/
|
||||||
private function getConvertedAudioResponse(Request $request, Response $response)
|
private function getConvertedAudioResponse(Request $request, Response $response): Response
|
||||||
{
|
{
|
||||||
$from = null;
|
$from = null;
|
||||||
$to = null;
|
$to = null;
|
||||||
|
@ -135,7 +135,7 @@ class DownloadController extends BaseController
|
||||||
* @throws PasswordException
|
* @throws PasswordException
|
||||||
* @throws WrongPasswordException
|
* @throws WrongPasswordException
|
||||||
*/
|
*/
|
||||||
private function getAudioResponse(Request $request, Response $response)
|
private function getAudioResponse(Request $request, Response $response): Response
|
||||||
{
|
{
|
||||||
if (!empty($request->getQueryParam('from')) || !empty($request->getQueryParam('to'))) {
|
if (!empty($request->getQueryParam('from')) || !empty($request->getQueryParam('to'))) {
|
||||||
// Force convert when we need to seek.
|
// Force convert when we need to seek.
|
||||||
|
@ -174,7 +174,7 @@ class DownloadController extends BaseController
|
||||||
* @return Response HTTP response
|
* @return Response HTTP response
|
||||||
* @throws AlltubeLibraryException
|
* @throws AlltubeLibraryException
|
||||||
*/
|
*/
|
||||||
private function getStream(Request $request, Response $response)
|
private function getStream(Request $request, Response $response): Response
|
||||||
{
|
{
|
||||||
if (isset($this->video->entries)) {
|
if (isset($this->video->entries)) {
|
||||||
if ($this->config->convert && $request->getQueryParam('audio')) {
|
if ($this->config->convert && $request->getQueryParam('audio')) {
|
||||||
|
@ -240,7 +240,7 @@ class DownloadController extends BaseController
|
||||||
* @return Response HTTP response
|
* @return Response HTTP response
|
||||||
* @throws AlltubeLibraryException
|
* @throws AlltubeLibraryException
|
||||||
*/
|
*/
|
||||||
private function getRemuxStream(Request $request, Response $response)
|
private function getRemuxStream(Request $request, Response $response): Response
|
||||||
{
|
{
|
||||||
if (!$this->config->remux) {
|
if (!$this->config->remux) {
|
||||||
throw new RemuxException('You need to enable remux mode to merge two formats.');
|
throw new RemuxException('You need to enable remux mode to merge two formats.');
|
||||||
|
@ -267,7 +267,7 @@ class DownloadController extends BaseController
|
||||||
* @return Response HTTP response
|
* @return Response HTTP response
|
||||||
* @throws AlltubeLibraryException
|
* @throws AlltubeLibraryException
|
||||||
*/
|
*/
|
||||||
private function getDownloadResponse(Request $request, Response $response)
|
private function getDownloadResponse(Request $request, Response $response): Response
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$videoUrls = $this->video->getUrl();
|
$videoUrls = $this->video->getUrl();
|
||||||
|
@ -306,7 +306,7 @@ class DownloadController extends BaseController
|
||||||
* @throws YoutubedlException
|
* @throws YoutubedlException
|
||||||
* @throws PopenStreamException
|
* @throws PopenStreamException
|
||||||
*/
|
*/
|
||||||
private function getConvertedResponse(Request $request, Response $response)
|
private function getConvertedResponse(Request $request, Response $response): Response
|
||||||
{
|
{
|
||||||
$response = $response->withHeader(
|
$response = $response->withHeader(
|
||||||
'Content-Disposition',
|
'Content-Disposition',
|
||||||
|
|
|
@ -52,7 +52,7 @@ class FrontController extends BaseController
|
||||||
*
|
*
|
||||||
* @return Response HTTP response
|
* @return Response HTTP response
|
||||||
*/
|
*/
|
||||||
public function index(Request $request, Response $response)
|
public function index(Request $request, Response $response): Response
|
||||||
{
|
{
|
||||||
$this->view->render(
|
$this->view->render(
|
||||||
$response,
|
$response,
|
||||||
|
@ -78,7 +78,7 @@ class FrontController extends BaseController
|
||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function locale(Request $request, Response $response, array $data)
|
public function locale(Request $request, Response $response, array $data): Response
|
||||||
{
|
{
|
||||||
$this->localeManager->setLocale(new Locale($data['locale']));
|
$this->localeManager->setLocale(new Locale($data['locale']));
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ class FrontController extends BaseController
|
||||||
* @return Response HTTP response
|
* @return Response HTTP response
|
||||||
* @throws AlltubeLibraryException
|
* @throws AlltubeLibraryException
|
||||||
*/
|
*/
|
||||||
public function extractors(Request $request, Response $response)
|
public function extractors(Request $request, Response $response): Response
|
||||||
{
|
{
|
||||||
$this->view->render(
|
$this->view->render(
|
||||||
$response,
|
$response,
|
||||||
|
@ -119,7 +119,7 @@ class FrontController extends BaseController
|
||||||
*
|
*
|
||||||
* @return Response HTTP response
|
* @return Response HTTP response
|
||||||
*/
|
*/
|
||||||
public function password(Request $request, Response $response)
|
public function password(Request $request, Response $response): Response
|
||||||
{
|
{
|
||||||
$this->view->render(
|
$this->view->render(
|
||||||
$response,
|
$response,
|
||||||
|
@ -199,7 +199,7 @@ class FrontController extends BaseController
|
||||||
* @return Response HTTP response
|
* @return Response HTTP response
|
||||||
* @throws AlltubeLibraryException
|
* @throws AlltubeLibraryException
|
||||||
*/
|
*/
|
||||||
public function info(Request $request, Response $response)
|
public function info(Request $request, Response $response): Response
|
||||||
{
|
{
|
||||||
$url = $request->getQueryParam('url') ?: $request->getQueryParam('v');
|
$url = $request->getQueryParam('url') ?: $request->getQueryParam('v');
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ class FrontController extends BaseController
|
||||||
*
|
*
|
||||||
* @return Response HTTP response
|
* @return Response HTTP response
|
||||||
*/
|
*/
|
||||||
protected function displayError(Request $request, Response $response, string $message)
|
protected function displayError(Request $request, Response $response, string $message): Response
|
||||||
{
|
{
|
||||||
$this->view->render(
|
$this->view->render(
|
||||||
$response,
|
$response,
|
||||||
|
@ -248,7 +248,7 @@ class FrontController extends BaseController
|
||||||
* @param Response $response
|
* @param Response $response
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function notFound(Request $request, Response $response)
|
public function notFound(Request $request, Response $response): Response
|
||||||
{
|
{
|
||||||
return $this->displayError($request, $response, $this->localeManager->t('Page not found'))
|
return $this->displayError($request, $response, $this->localeManager->t('Page not found'))
|
||||||
->withStatus(StatusCode::HTTP_NOT_FOUND);
|
->withStatus(StatusCode::HTTP_NOT_FOUND);
|
||||||
|
@ -259,7 +259,7 @@ class FrontController extends BaseController
|
||||||
* @param Response $response
|
* @param Response $response
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function notAllowed(Request $request, Response $response)
|
public function notAllowed(Request $request, Response $response): Response
|
||||||
{
|
{
|
||||||
return $this->displayError($request, $response, $this->localeManager->t('Method not allowed'))
|
return $this->displayError($request, $response, $this->localeManager->t('Method not allowed'))
|
||||||
->withStatus(StatusCode::HTTP_METHOD_NOT_ALLOWED);
|
->withStatus(StatusCode::HTTP_METHOD_NOT_ALLOWED);
|
||||||
|
@ -274,7 +274,7 @@ class FrontController extends BaseController
|
||||||
*
|
*
|
||||||
* @return Response HTTP response
|
* @return Response HTTP response
|
||||||
*/
|
*/
|
||||||
public function error(Request $request, Response $response, Throwable $error)
|
public function error(Request $request, Response $response, Throwable $error): Response
|
||||||
{
|
{
|
||||||
$this->logger->error($error);
|
$this->logger->error($error);
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ class JsonController extends BaseController
|
||||||
* @return Response HTTP response
|
* @return Response HTTP response
|
||||||
* @throws AlltubeLibraryException
|
* @throws AlltubeLibraryException
|
||||||
*/
|
*/
|
||||||
public function json(Request $request, Response $response)
|
public function json(Request $request, Response $response): Response
|
||||||
{
|
{
|
||||||
$url = $request->getQueryParam('url');
|
$url = $request->getQueryParam('url');
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class ConfigFactory
|
||||||
* @return Config
|
* @return Config
|
||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
*/
|
*/
|
||||||
public static function create(Container $container)
|
public static function create(Container $container): Config
|
||||||
{
|
{
|
||||||
$configPath = __DIR__ . '/../../config/config.yml';
|
$configPath = __DIR__ . '/../../config/config.yml';
|
||||||
if (is_file($configPath)) {
|
if (is_file($configPath)) {
|
||||||
|
|
|
@ -15,10 +15,10 @@ class LocaleManagerFactory
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Container $container
|
* @param Container $container
|
||||||
* @return LocaleManager|null
|
* @return LocaleManager
|
||||||
* @throws DependencyException
|
* @throws DependencyException
|
||||||
*/
|
*/
|
||||||
public static function create(Container $container)
|
public static function create(Container $container): LocaleManager
|
||||||
{
|
{
|
||||||
if (!class_exists('Locale')) {
|
if (!class_exists('Locale')) {
|
||||||
throw new DependencyException('You need to install the intl extension for PHP.');
|
throw new DependencyException('You need to install the intl extension for PHP.');
|
||||||
|
|
|
@ -18,7 +18,7 @@ class LoggerFactory
|
||||||
* @param Container $container
|
* @param Container $container
|
||||||
* @return Logger
|
* @return Logger
|
||||||
*/
|
*/
|
||||||
public static function create(Container $container)
|
public static function create(Container $container): Logger
|
||||||
{
|
{
|
||||||
$config = $container->get('config');
|
$config = $container->get('config');
|
||||||
if ($config->debug) {
|
if ($config->debug) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ class SessionFactory
|
||||||
* @param Container $container
|
* @param Container $container
|
||||||
* @return Session
|
* @return Session
|
||||||
*/
|
*/
|
||||||
public static function create(Container $container)
|
public static function create(Container $container): Session
|
||||||
{
|
{
|
||||||
$session_factory = new \Aura\Session\SessionFactory();
|
$session_factory = new \Aura\Session\SessionFactory();
|
||||||
$session = $session_factory->newInstance($_COOKIE);
|
$session = $session_factory->newInstance($_COOKIE);
|
||||||
|
|
|
@ -26,7 +26,7 @@ class ViewFactory
|
||||||
*
|
*
|
||||||
* @return string URL
|
* @return string URL
|
||||||
*/
|
*/
|
||||||
private static function getCanonicalUrl(Request $request)
|
private static function getCanonicalUrl(Request $request): string
|
||||||
{
|
{
|
||||||
/** @var Uri $uri */
|
/** @var Uri $uri */
|
||||||
$uri = $request->getUri();
|
$uri = $request->getUri();
|
||||||
|
@ -45,7 +45,7 @@ class ViewFactory
|
||||||
* @return Smarty
|
* @return Smarty
|
||||||
* @throws SmartyException
|
* @throws SmartyException
|
||||||
*/
|
*/
|
||||||
public static function create(ContainerInterface $container, Request $request = null)
|
public static function create(ContainerInterface $container, Request $request = null): Smarty
|
||||||
{
|
{
|
||||||
if (!isset($request)) {
|
if (!isset($request)) {
|
||||||
$request = $container->get('request');
|
$request = $container->get('request');
|
||||||
|
|
|
@ -48,7 +48,7 @@ class Locale
|
||||||
*
|
*
|
||||||
* @return string ISO 15897 code
|
* @return string ISO 15897 code
|
||||||
*/
|
*/
|
||||||
public function __toString()
|
public function __toString(): string
|
||||||
{
|
{
|
||||||
return $this->getIso15897();
|
return $this->getIso15897();
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ class Locale
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getFullName()
|
public function getFullName(): string
|
||||||
{
|
{
|
||||||
return PHPLocale::getDisplayName($this->getIso15897(), $this->getIso15897());
|
return PHPLocale::getDisplayName($this->getIso15897(), $this->getIso15897());
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ class Locale
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getIso15897()
|
public function getIso15897(): string
|
||||||
{
|
{
|
||||||
if (isset($this->region)) {
|
if (isset($this->region)) {
|
||||||
return $this->language . '_' . $this->region;
|
return $this->language . '_' . $this->region;
|
||||||
|
@ -82,7 +82,7 @@ class Locale
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getBcp47()
|
public function getBcp47(): string
|
||||||
{
|
{
|
||||||
if (isset($this->region)) {
|
if (isset($this->region)) {
|
||||||
return $this->language . '-' . $this->region;
|
return $this->language . '-' . $this->region;
|
||||||
|
@ -96,7 +96,7 @@ class Locale
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getIso3166()
|
public function getIso3166(): string
|
||||||
{
|
{
|
||||||
return strtolower($this->region);
|
return strtolower($this->region);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ class LocaleManager
|
||||||
*
|
*
|
||||||
* @return Locale[]
|
* @return Locale[]
|
||||||
*/
|
*/
|
||||||
public function getSupportedLocales()
|
public function getSupportedLocales(): array
|
||||||
{
|
{
|
||||||
$return = [
|
$return = [
|
||||||
new Locale('en_US')
|
new Locale('en_US')
|
||||||
|
@ -103,7 +103,7 @@ class LocaleManager
|
||||||
*
|
*
|
||||||
* @return Locale|null
|
* @return Locale|null
|
||||||
*/
|
*/
|
||||||
public function getLocale()
|
public function getLocale(): ?Locale
|
||||||
{
|
{
|
||||||
return $this->curLocale;
|
return $this->curLocale;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ class LocaleManager
|
||||||
*
|
*
|
||||||
* @return string Translated string
|
* @return string Translated string
|
||||||
*/
|
*/
|
||||||
public function smartyTranslate(array $params, string $text = null)
|
public function smartyTranslate(array $params, string $text = null): string
|
||||||
{
|
{
|
||||||
if (isset($params['params'])) {
|
if (isset($params['params'])) {
|
||||||
return $this->t($text, $params['params']);
|
return $this->t($text, $params['params']);
|
||||||
|
@ -157,7 +157,7 @@ class LocaleManager
|
||||||
* @param mixed[] $params
|
* @param mixed[] $params
|
||||||
* @return string Translated string
|
* @return string Translated string
|
||||||
*/
|
*/
|
||||||
public function t(string $string = null, array $params = [])
|
public function t(string $string = null, array $params = []): string
|
||||||
{
|
{
|
||||||
if (isset($string)) {
|
if (isset($string)) {
|
||||||
return $this->translator->trans($string, $params);
|
return $this->translator->trans($string, $params);
|
||||||
|
|
|
@ -34,7 +34,7 @@ class CspMiddleware
|
||||||
* @param Response $response
|
* @param Response $response
|
||||||
* @return MessageInterface
|
* @return MessageInterface
|
||||||
*/
|
*/
|
||||||
public function applyHeader(Response $response)
|
public function applyHeader(Response $response): MessageInterface
|
||||||
{
|
{
|
||||||
$csp = new CSPBuilder();
|
$csp = new CSPBuilder();
|
||||||
$csp->addDirective('default-src', [])
|
$csp->addDirective('default-src', [])
|
||||||
|
|
|
@ -42,7 +42,7 @@ class LocaleMiddleware
|
||||||
*
|
*
|
||||||
* @return Locale|null Locale if chosen, nothing otherwise
|
* @return Locale|null Locale if chosen, nothing otherwise
|
||||||
*/
|
*/
|
||||||
public function testLocale(array $proposedLocale)
|
public function testLocale(array $proposedLocale): ?Locale
|
||||||
{
|
{
|
||||||
foreach ($this->localeManager->getSupportedLocales() as $locale) {
|
foreach ($this->localeManager->getSupportedLocales() as $locale) {
|
||||||
$parsedLocale = AcceptLanguage::parse($locale);
|
$parsedLocale = AcceptLanguage::parse($locale);
|
||||||
|
@ -67,7 +67,7 @@ class LocaleMiddleware
|
||||||
*
|
*
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function __invoke(Request $request, Response $response, callable $next)
|
public function __invoke(Request $request, Response $response, callable $next): Response
|
||||||
{
|
{
|
||||||
$headers = $request->getHeader('Accept-Language');
|
$headers = $request->getHeader('Accept-Language');
|
||||||
$curLocale = $this->localeManager->getLocale();
|
$curLocale = $this->localeManager->getLocale();
|
||||||
|
|
|
@ -113,7 +113,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
|
||||||
*
|
*
|
||||||
* @return int|null
|
* @return int|null
|
||||||
*/
|
*/
|
||||||
public function getSize()
|
public function getSize(): ?int
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isSeekable()
|
public function isSeekable(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isWritable()
|
public function isWritable(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isReadable()
|
public function isReadable(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
|
||||||
*
|
*
|
||||||
* @param string|null $key string $key Specific metadata to retrieve.
|
* @param string|null $key string $key Specific metadata to retrieve.
|
||||||
*
|
*
|
||||||
* @return array|mixed|null
|
* @return mixed|null
|
||||||
*/
|
*/
|
||||||
public function getMetadata($key = null)
|
public function getMetadata($key = null)
|
||||||
{
|
{
|
||||||
|
@ -208,7 +208,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function __toString()
|
public function __toString(): string
|
||||||
{
|
{
|
||||||
$this->rewind();
|
$this->rewind();
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function eof()
|
public function eof(): bool
|
||||||
{
|
{
|
||||||
return $this->isComplete && feof($this->buffer);
|
return $this->isComplete && feof($this->buffer);
|
||||||
}
|
}
|
||||||
|
@ -272,12 +272,12 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
|
||||||
/**
|
/**
|
||||||
* Read data from the stream.
|
* Read data from the stream.
|
||||||
*
|
*
|
||||||
* @param mixed $count Number of bytes to read
|
* @param mixed $length Number of bytes to read
|
||||||
*
|
*
|
||||||
* @return string|false
|
* @return string|false
|
||||||
* @throws AlltubeLibraryException
|
* @throws AlltubeLibraryException
|
||||||
*/
|
*/
|
||||||
public function read($count)
|
public function read($length)
|
||||||
{
|
{
|
||||||
// If the archive is complete, we only read the remaining buffer.
|
// If the archive is complete, we only read the remaining buffer.
|
||||||
if (!$this->isComplete) {
|
if (!$this->isComplete) {
|
||||||
|
@ -297,7 +297,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Continue streaming the current video.
|
// Continue streaming the current video.
|
||||||
$this->stream_file_part($this->curVideoStream->read($count));
|
$this->stream_file_part($this->curVideoStream->read($length));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Start streaming the first video.
|
// Start streaming the first video.
|
||||||
|
@ -305,7 +305,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fread($this->buffer, $count);
|
return fread($this->buffer, $length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -39,7 +39,7 @@ class YoutubeChunkStream implements StreamInterface
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function read($length)
|
public function read($length): string
|
||||||
{
|
{
|
||||||
$size = intval($this->response->getHeader('Content-Length')[0]);
|
$size = intval($this->response->getHeader('Content-Length')[0]);
|
||||||
if ($size - $this->tell() < $length) {
|
if ($size - $this->tell() < $length) {
|
||||||
|
@ -53,7 +53,7 @@ class YoutubeChunkStream implements StreamInterface
|
||||||
/**
|
/**
|
||||||
* Reads all data from the stream into a string, from the beginning to end.
|
* Reads all data from the stream into a string, from the beginning to end.
|
||||||
*/
|
*/
|
||||||
public function __toString()
|
public function __toString(): string
|
||||||
{
|
{
|
||||||
return (string)$this->response->getBody();
|
return (string)$this->response->getBody();
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ class YoutubeChunkStream implements StreamInterface
|
||||||
*
|
*
|
||||||
* @return int|null
|
* @return int|null
|
||||||
*/
|
*/
|
||||||
public function getSize()
|
public function getSize(): ?int
|
||||||
{
|
{
|
||||||
return $this->response->getBody()->getSize();
|
return $this->response->getBody()->getSize();
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ class YoutubeChunkStream implements StreamInterface
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function tell()
|
public function tell(): int
|
||||||
{
|
{
|
||||||
return $this->response->getBody()->tell();
|
return $this->response->getBody()->tell();
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ class YoutubeChunkStream implements StreamInterface
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function eof()
|
public function eof(): bool
|
||||||
{
|
{
|
||||||
return $this->response->getBody()->eof();
|
return $this->response->getBody()->eof();
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ class YoutubeChunkStream implements StreamInterface
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isSeekable()
|
public function isSeekable(): bool
|
||||||
{
|
{
|
||||||
return $this->response->getBody()->isSeekable();
|
return $this->response->getBody()->isSeekable();
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ class YoutubeChunkStream implements StreamInterface
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isWritable()
|
public function isWritable(): bool
|
||||||
{
|
{
|
||||||
return $this->response->getBody()->isWritable();
|
return $this->response->getBody()->isWritable();
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ class YoutubeChunkStream implements StreamInterface
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isReadable()
|
public function isReadable(): bool
|
||||||
{
|
{
|
||||||
return $this->response->getBody()->isReadable();
|
return $this->response->getBody()->isReadable();
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ class YoutubeChunkStream implements StreamInterface
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getContents()
|
public function getContents(): string
|
||||||
{
|
{
|
||||||
return $this->response->getBody()->getContents();
|
return $this->response->getBody()->getContents();
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ class YoutubeChunkStream implements StreamInterface
|
||||||
*
|
*
|
||||||
* @param string|null $key Specific metadata to retrieve.
|
* @param string|null $key Specific metadata to retrieve.
|
||||||
*
|
*
|
||||||
* @return array|mixed|null
|
* @return mixed|null
|
||||||
*/
|
*/
|
||||||
public function getMetadata($key = null)
|
public function getMetadata($key = null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,7 +26,7 @@ class UglyRouter extends Router
|
||||||
*
|
*
|
||||||
* @link https://github.com/nikic/FastRoute/blob/master/src/Dispatcher.php
|
* @link https://github.com/nikic/FastRoute/blob/master/src/Dispatcher.php
|
||||||
*/
|
*/
|
||||||
public function dispatch(ServerRequestInterface $request)
|
public function dispatch(ServerRequestInterface $request): array
|
||||||
{
|
{
|
||||||
$params = $request->getQueryParams();
|
$params = $request->getQueryParams();
|
||||||
$uri = new Uri('', '');
|
$uri = new Uri('', '');
|
||||||
|
@ -53,7 +53,7 @@ class UglyRouter extends Router
|
||||||
* @throws InvalidArgumentException If required data not provided
|
* @throws InvalidArgumentException If required data not provided
|
||||||
* @throws RuntimeException If named route does not exist
|
* @throws RuntimeException If named route does not exist
|
||||||
*/
|
*/
|
||||||
public function pathFor($name, array $data = [], array $queryParams = [])
|
public function pathFor($name, array $data = [], array $queryParams = []): string
|
||||||
{
|
{
|
||||||
$queryParams['page'] = $name;
|
$queryParams['page'] = $name;
|
||||||
$url = Uri::createFromString($this->relativePathFor($name, $data, $queryParams))->withPath('');
|
$url = Uri::createFromString($this->relativePathFor($name, $data, $queryParams))->withPath('');
|
||||||
|
|
|
@ -18,7 +18,7 @@ abstract class BaseTest extends TestCase
|
||||||
*
|
*
|
||||||
* @return string Path to file
|
* @return string Path to file
|
||||||
*/
|
*/
|
||||||
protected function getConfigFile()
|
protected function getConfigFile(): string
|
||||||
{
|
{
|
||||||
return __DIR__ . '/../config/config_test.yml';
|
return __DIR__ . '/../config/config_test.yml';
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ abstract class ControllerTest extends ContainerTest
|
||||||
*
|
*
|
||||||
* @return Response HTTP response
|
* @return Response HTTP response
|
||||||
*/
|
*/
|
||||||
protected function getRequestResult(string $request, array $params)
|
protected function getRequestResult(string $request, array $params): Response
|
||||||
{
|
{
|
||||||
return $this->controller->$request(
|
return $this->controller->$request(
|
||||||
$this->container->get('request')->withQueryParams($params),
|
$this->container->get('request')->withQueryParams($params),
|
||||||
|
|
|
@ -85,26 +85,32 @@ class LocaleMiddlewareTest extends ContainerTest
|
||||||
* Check that the request contains an Accept-Language header.
|
* Check that the request contains an Accept-Language header.
|
||||||
*
|
*
|
||||||
* @param Request $request PSR-7 request
|
* @param Request $request PSR-7 request
|
||||||
|
* @param Response $response
|
||||||
*
|
*
|
||||||
* @return void
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function assertHeader(Request $request)
|
public function assertHeader(Request $request, Response $response): Response
|
||||||
{
|
{
|
||||||
$header = $request->getHeader('Accept-Language');
|
$header = $request->getHeader('Accept-Language');
|
||||||
$this->assertEquals('foo-BAR', $header[0]);
|
$this->assertEquals('foo-BAR', $header[0]);
|
||||||
|
|
||||||
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that the request contains no Accept-Language header.
|
* Check that the request contains no Accept-Language header.
|
||||||
*
|
*
|
||||||
* @param Request $request PSR-7 request
|
* @param Request $request PSR-7 request
|
||||||
|
* @param Response $response
|
||||||
*
|
*
|
||||||
* @return void
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function assertNoHeader(Request $request)
|
public function assertNoHeader(Request $request, Response $response): Response
|
||||||
{
|
{
|
||||||
$header = $request->getHeader('Accept-Language');
|
$header = $request->getHeader('Accept-Language');
|
||||||
$this->assertEmpty($header);
|
$this->assertEmpty($header);
|
||||||
|
|
||||||
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -157,7 +157,7 @@ class VideoTest extends ContainerTest
|
||||||
*
|
*
|
||||||
* @return array[]
|
* @return array[]
|
||||||
*/
|
*/
|
||||||
public function urlProvider()
|
public function urlProvider(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
|
@ -193,7 +193,7 @@ class VideoTest extends ContainerTest
|
||||||
*
|
*
|
||||||
* @return array[]
|
* @return array[]
|
||||||
*/
|
*/
|
||||||
public function remuxUrlProvider()
|
public function remuxUrlProvider(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
|
@ -210,7 +210,7 @@ class VideoTest extends ContainerTest
|
||||||
*
|
*
|
||||||
* @return array[]
|
* @return array[]
|
||||||
*/
|
*/
|
||||||
public function m3uUrlProvider()
|
public function m3uUrlProvider(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
|
@ -227,7 +227,7 @@ class VideoTest extends ContainerTest
|
||||||
*
|
*
|
||||||
* @return array[]
|
* @return array[]
|
||||||
*/
|
*/
|
||||||
public function rtmpUrlProvider()
|
public function rtmpUrlProvider(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
|
@ -244,7 +244,7 @@ class VideoTest extends ContainerTest
|
||||||
*
|
*
|
||||||
* @return array[]
|
* @return array[]
|
||||||
*/
|
*/
|
||||||
public function errorUrlProvider()
|
public function errorUrlProvider(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
['http://example.com/video'],
|
['http://example.com/video'],
|
||||||
|
|
Loading…
Reference in a new issue