style(phpcs): Switch to PSR-12

https://www.php-fig.org/psr/psr-12/
This commit is contained in:
Pierre Rudloff 2019-10-03 21:24:12 +02:00
parent f063f2ead4
commit 44bf858c35
35 changed files with 101 additions and 67 deletions

View file

@ -1,4 +1,5 @@
<?php
/**
* Config class.
*/
@ -160,7 +161,7 @@ class Config
}
} elseif (!$this->stream) {
// Force HTTP if stream is not enabled.
$this->replaceGenericFormat($format, $format.'[protocol=https]/'.$format.'[protocol=http]');
$this->replaceGenericFormat($format, $format . '[protocol=https]/' . $format . '[protocol=http]');
}
}
}
@ -197,9 +198,9 @@ class Config
so they will go to the logs.
*/
if (!is_file($this->youtubedl)) {
throw new Exception("Can't find youtube-dl at ".$this->youtubedl);
throw new Exception("Can't find youtube-dl at " . $this->youtubedl);
} elseif (!Video::checkCommand([$this->python, '--version'])) {
throw new Exception("Can't find Python at ".$this->python);
throw new Exception("Can't find Python at " . $this->python);
}
}
@ -262,7 +263,7 @@ class Config
self::$instance = new self($options);
self::$instance->validateOptions();
} else {
throw new Exception("Can't find config file at ".$file);
throw new Exception("Can't find config file at " . $file);
}
}

View file

@ -1,4 +1,5 @@
<?php
/**
* Locale class.
*/
@ -67,7 +68,7 @@ class Locale
*/
public function getIso15897()
{
return $this->language.'_'.$this->region;
return $this->language . '_' . $this->region;
}
/**
@ -77,7 +78,7 @@ class Locale
*/
public function getBcp47()
{
return $this->language.'-'.$this->region;
return $this->language . '-' . $this->region;
}
/**

View file

@ -1,4 +1,5 @@
<?php
/**
* LocaleManager class.
*/
@ -45,7 +46,7 @@ class LocaleManager
if (isset($cookieLocale)) {
$this->setLocale(new Locale($cookieLocale));
}
bindtextdomain('Alltube', __DIR__.'/../i18n/');
bindtextdomain('Alltube', __DIR__ . '/../i18n/');
textdomain('Alltube');
}
@ -61,8 +62,9 @@ class LocaleManager
$process->run();
$installedLocales = explode(PHP_EOL, trim($process->getOutput()));
foreach ($this->supportedLocales as $supportedLocale) {
if (in_array($supportedLocale, $installedLocales)
|| in_array($supportedLocale.'.utf8', $installedLocales)
if (
in_array($supportedLocale, $installedLocales)
|| in_array($supportedLocale . '.utf8', $installedLocales)
) {
$return[] = new Locale($supportedLocale);
}
@ -88,8 +90,8 @@ class LocaleManager
*/
public function setLocale(Locale $locale)
{
putenv('LANG='.$locale);
setlocale(LC_ALL, [$locale.'.utf8', $locale]);
putenv('LANG=' . $locale);
setlocale(LC_ALL, [$locale . '.utf8', $locale]);
$this->curLocale = $locale;
$this->sessionSegment->set('locale', $locale);
}

View file

@ -1,4 +1,5 @@
<?php
/**
* LocaleMiddleware class.
*/
@ -43,11 +44,12 @@ class LocaleMiddleware
{
foreach ($this->localeManager->getSupportedLocales() as $locale) {
$parsedLocale = AcceptLanguage::parse($locale);
if (isset($proposedLocale['language'])
if (
isset($proposedLocale['language'])
&& $parsedLocale[1]['language'] == $proposedLocale['language']
&& $parsedLocale[1]['region'] == $proposedLocale['region']
) {
return new Locale($proposedLocale['language'].'_'.$proposedLocale['region']);
return new Locale($proposedLocale['language'] . '_' . $proposedLocale['region']);
}
}
}

View file

@ -1,4 +1,5 @@
<?php
/**
* SessionManager class.
*/

View file

@ -1,4 +1,5 @@
<?php
/**
* UglyRouter class.
*/
@ -55,7 +56,7 @@ class UglyRouter extends Router
$url = str_replace('/', '/?page=', $this->relativePathFor($name, $data, $queryParams));
if ($this->basePath) {
$url = $this->basePath.$url;
$url = $this->basePath . $url;
}
return $url;

View file

@ -1,4 +1,5 @@
<?php
/**
* VideoDownload class.
*/
@ -135,7 +136,7 @@ class Video
$process = self::getProcess($arguments);
//This is needed by the openload extractor because it runs PhantomJS
$process->setEnv(['PATH'=>$config->phantomjsDir]);
$process->setEnv(['PATH' => $config->phantomjsDir]);
$process->inheritEnvironmentVariables();
$process->run();
if (!$process->isSuccessful()) {
@ -162,7 +163,7 @@ class Video
*/
private function getProp($prop = 'dump-json')
{
$arguments = ['--'.$prop];
$arguments = ['--' . $prop];
if (isset($this->webpageUrl)) {
$arguments[] = $this->webpageUrl;
@ -265,7 +266,7 @@ class Video
pathinfo(
$this->getFilename(),
PATHINFO_FILENAME
).'.'.$extension,
) . '.' . $extension,
ENT_COMPAT,
'ISO-8859-1'
);
@ -281,14 +282,16 @@ class Video
$arguments = [];
if ($this->protocol == 'rtmp') {
foreach ([
foreach (
[
'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) {
] as $property => $option
) {
if (isset($this->{$property})) {
$arguments[] = $option;
$arguments[] = $this->{$property};
@ -342,7 +345,7 @@ class Video
$to = null
) {
if (!$this->checkCommand([$this->config->avconv, '-version'])) {
throw new Exception(_('Can\'t find avconv or ffmpeg at ').$this->config->avconv.'.');
throw new Exception(_('Can\'t find avconv or ffmpeg at ') . $this->config->avconv . '.');
}
$durationRegex = '/(\d+:)?(\d+:)?(\d+)/';
@ -355,14 +358,14 @@ class Video
if (!empty($from)) {
if (!preg_match($durationRegex, $from)) {
throw new Exception(_('Invalid start time: ').$from.'.');
throw new Exception(_('Invalid start time: ') . $from . '.');
}
$afterArguments[] = '-ss';
$afterArguments[] = $from;
}
if (!empty($to)) {
if (!preg_match($durationRegex, $to)) {
throw new Exception(_('Invalid end time: ').$to.'.');
throw new Exception(_('Invalid end time: ') . $to . '.');
}
$afterArguments[] = '-to';
$afterArguments[] = $to;
@ -379,7 +382,7 @@ class Video
[
'-i', $urls[0],
'-f', $filetype,
'-b:a', $audioBitrate.'k',
'-b:a', $audioBitrate . 'k',
],
$afterArguments,
[
@ -441,7 +444,7 @@ class Video
public function getM3uStream()
{
if (!$this->checkCommand([$this->config->avconv, '-version'])) {
throw new Exception(_('Can\'t find avconv or ffmpeg at ').$this->config->avconv.'.');
throw new Exception(_('Can\'t find avconv or ffmpeg at ') . $this->config->avconv . '.');
}
$urls = $this->getUrl();

View file

@ -1,4 +1,5 @@
<?php
/**
* ViewFactory class.
*/
@ -29,7 +30,7 @@ class ViewFactory
$request = $container['request'];
}
$view = new Smarty(__DIR__.'/../templates/');
$view = new Smarty(__DIR__ . '/../templates/');
if (in_array('https', $request->getHeader('X-Forwarded-Proto'))) {
$request = $request->withUri($request->getUri()->withScheme('https')->withPort(443));
}