refactor(phpstan): Various code improvements

This commit is contained in:
Pierre Rudloff 2019-03-30 18:21:45 +01:00
parent 0ed788560c
commit 5835bd67a5
5 changed files with 19 additions and 21 deletions

View file

@ -16,7 +16,7 @@ class Config
/** /**
* Singleton instance. * Singleton instance.
* *
* @var Config * @var Config|null
*/ */
private static $instance; private static $instance;
@ -133,13 +133,11 @@ class Config
*/ */
public function __construct(array $options) public function __construct(array $options)
{ {
if (isset($options) && is_array($options)) {
foreach ($options as $option => $value) { foreach ($options as $option => $value) {
if (isset($this->$option) && isset($value)) { if (isset($this->$option) && isset($value)) {
$this->$option = $value; $this->$option = $value;
} }
} }
}
$this->getEnv(); $this->getEnv();
} }

View file

@ -24,7 +24,7 @@ class LocaleManager
/** /**
* Current locale. * Current locale.
* *
* @var Locale * @var Locale|null
*/ */
private $curLocale; private $curLocale;
@ -78,7 +78,7 @@ class LocaleManager
/** /**
* Get the current locale. * Get the current locale.
* *
* @return Locale * @return Locale|null
*/ */
public function getLocale() public function getLocale()
{ {

View file

@ -37,7 +37,7 @@ class LocaleMiddleware
* *
* @param array $proposedLocale Locale array created by AcceptLanguage::parse() * @param array $proposedLocale Locale array created by AcceptLanguage::parse()
* *
* @return string Locale name if chosen, nothing otherwise * @return Locale Locale if chosen, nothing otherwise
*/ */
public function testLocale(array $proposedLocale) public function testLocale(array $proposedLocale)
{ {
@ -65,7 +65,7 @@ class LocaleMiddleware
{ {
$headers = $request->getHeader('Accept-Language'); $headers = $request->getHeader('Accept-Language');
$curLocale = $this->localeManager->getLocale(); $curLocale = $this->localeManager->getLocale();
if (!isset($curLocale)) { if (is_null($curLocale)) {
if (isset($headers[0])) { if (isset($headers[0])) {
$this->localeManager->setLocale( $this->localeManager->setLocale(
AcceptLanguage::detect([$this, 'testLocale'], new Locale('en_US'), $headers[0]) AcceptLanguage::detect([$this, 'testLocale'], new Locale('en_US'), $headers[0])

View file

@ -186,7 +186,7 @@ class PlaylistArchiveStream extends TarArchive
public function stream_read($count) public function stream_read($count)
{ {
if (!$this->files[$this->curFile]['headersSent']) { if (!$this->files[$this->curFile]['headersSent']) {
$urls = $this->download->getUrl($this->files[$this->curFile]['url'], $this->format); $urls = $this->download->getURL($this->files[$this->curFile]['url'], $this->format);
$response = $this->client->request('GET', $urls[0], ['stream' => true]); $response = $this->client->request('GET', $urls[0], ['stream' => true]);
$contentLengthHeaders = $response->getHeader('Content-Length'); $contentLengthHeaders = $response->getHeader('Content-Length');

View file

@ -130,7 +130,7 @@ class VideoDownload
* @param string $format Format to use for the video * @param string $format Format to use for the video
* @param string $password Video password * @param string $password Video password
* *
* @return object Decoded JSON * @return stdClass Decoded JSON
* */ * */
public function getJSON($url, $format = null, $password = null) public function getJSON($url, $format = null, $password = null)
{ {
@ -214,7 +214,7 @@ class VideoDownload
/** /**
* Return arguments used to run rtmp for a specific video. * Return arguments used to run rtmp for a specific video.
* *
* @param object $video Video object returned by youtube-dl * @param stdClass $video Video object returned by youtube-dl
* *
* @return array Arguments * @return array Arguments
*/ */
@ -266,7 +266,7 @@ class VideoDownload
/** /**
* 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 object $video Video object returned by youtube-dl * @param stdClass $video Video object returned by youtube-dl
* @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
@ -484,7 +484,7 @@ class VideoDownload
/** /**
* Get a Tar stream containing every video in the playlist piped through the server. * Get a Tar stream containing every video in the playlist piped through the server.
* *
* @param object $video Video object returned by youtube-dl * @param stdClass $video Video object returned by youtube-dl
* @param string $format Requested format * @param string $format Requested format
* *
* @throws Exception If the popen stream was not created correctly * @throws Exception If the popen stream was not created correctly