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

@ -23,7 +23,7 @@ module.exports = function (grunt) {
}, },
phpcs: { phpcs: {
options: { options: {
standard: 'PSR2', standard: 'PSR12',
bin: 'vendor/bin/phpcs' bin: 'vendor/bin/phpcs'
}, },
php: { php: {

View File

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

View File

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

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* LocaleManager class. * LocaleManager class.
*/ */
@ -61,7 +62,8 @@ class LocaleManager
$process->run(); $process->run();
$installedLocales = explode(PHP_EOL, trim($process->getOutput())); $installedLocales = explode(PHP_EOL, trim($process->getOutput()));
foreach ($this->supportedLocales as $supportedLocale) { foreach ($this->supportedLocales as $supportedLocale) {
if (in_array($supportedLocale, $installedLocales) if (
in_array($supportedLocale, $installedLocales)
|| in_array($supportedLocale . '.utf8', $installedLocales) || in_array($supportedLocale . '.utf8', $installedLocales)
) { ) {
$return[] = new Locale($supportedLocale); $return[] = new Locale($supportedLocale);

View File

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

View File

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

View File

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

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* VideoDownload class. * VideoDownload class.
*/ */
@ -281,14 +282,16 @@ class Video
$arguments = []; $arguments = [];
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})) {
$arguments[] = $option; $arguments[] = $option;
$arguments[] = $this->{$property}; $arguments[] = $this->{$property};

View File

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

View File

@ -20,7 +20,7 @@
}, },
"require-dev": { "require-dev": {
"symfony/var-dumper": "~3.4.1", "symfony/var-dumper": "~3.4.1",
"squizlabs/php_codesniffer": "~3.4.0", "squizlabs/php_codesniffer": "^3.5",
"phpunit/phpunit": "~6.5.2", "phpunit/phpunit": "~6.5.2",
"ffmpeg/ffmpeg": "^4.1", "ffmpeg/ffmpeg": "^4.1",
"rg3/youtube-dl": "^2019.09", "rg3/youtube-dl": "^2019.09",

12
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": "33493e464172695368aaecf1f8e4e563", "content-hash": "07b922cb69b4f4dbd5e537656d559c8d",
"packages": [ "packages": [
{ {
"name": "aura/session", "name": "aura/session",
@ -3831,16 +3831,16 @@
}, },
{ {
"name": "squizlabs/php_codesniffer", "name": "squizlabs/php_codesniffer",
"version": "3.4.2", "version": "3.5.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8" "reference": "0afebf16a2e7f1e434920fa976253576151effe9"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8", "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/0afebf16a2e7f1e434920fa976253576151effe9",
"reference": "b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8", "reference": "0afebf16a2e7f1e434920fa976253576151effe9",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3878,7 +3878,7 @@
"phpcs", "phpcs",
"standards" "standards"
], ],
"time": "2019-04-10T23:49:02+00:00" "time": "2019-09-26T23:12:26+00:00"
}, },
{ {
"name": "symfony/console", "name": "symfony/console",

View File

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

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* DownloadController class. * DownloadController class.
*/ */
@ -49,7 +50,8 @@ class DownloadController extends BaseController
return $this->getDownloadResponse($request, $response); return $this->getDownloadResponse($request, $response);
} catch (PasswordException $e) { } catch (PasswordException $e) {
return $response->withRedirect( return $response->withRedirect(
$this->container->get('router')->pathFor('info').'?'.http_build_query($request->getQueryParams()) $this->container->get('router')->pathFor('info') .
'?' . http_build_query($request->getQueryParams())
); );
} catch (Exception $e) { } catch (Exception $e) {
$response->getBody()->write($e->getMessage()); $response->getBody()->write($e->getMessage());

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* FrontController class. * FrontController class.
*/ */
@ -171,7 +172,8 @@ class FrontController extends BaseController
$description = _('Download video from ') . $this->video->extractor_key; $description = _('Download video from ') . $this->video->extractor_key;
if (isset($this->video->title)) { if (isset($this->video->title)) {
$title = $this->video->title; $title = $this->video->title;
$description = _('Download').' "'.$this->video->title.'" '._('from').' '.$this->video->extractor_key; $description = _('Download') . ' "' . $this->video->title . '" ' .
_('from') . ' ' . $this->video->extractor_key;
} }
$this->view->render( $this->view->render(
$response, $response,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,20 +1,18 @@
<?php <?php
/** /**
* File used to bootstrap tests. * File used to bootstrap tests.
*/ */
use phpmock\mockery\PHPMockery; use phpmock\mockery\PHPMockery;
/** // Composer autoload.
* Composer autoload.
*/
require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../vendor/autoload.php';
ini_set('session.use_cookies', 0); ini_set('session.use_cookies', 0);
session_cache_limiter(''); session_cache_limiter('');
session_start(); session_start();
/* // See https://bugs.php.net/bug.php?id=68541
* @see https://bugs.php.net/bug.php?id=68541
*/
PHPMockery::define('Alltube', 'popen'); PHPMockery::define('Alltube', 'popen');
PHPMockery::define('Alltube', 'fopen'); PHPMockery::define('Alltube', 'fopen');