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

View file

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

View file

@ -37,7 +37,7 @@ class LocaleMiddleware
*
* @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)
{
@ -65,7 +65,7 @@ class LocaleMiddleware
{
$headers = $request->getHeader('Accept-Language');
$curLocale = $this->localeManager->getLocale();
if (!isset($curLocale)) {
if (is_null($curLocale)) {
if (isset($headers[0])) {
$this->localeManager->setLocale(
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)
{
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]);
$contentLengthHeaders = $response->getHeader('Content-Length');

View file

@ -130,7 +130,7 @@ class VideoDownload
* @param string $format Format to use for the video
* @param string $password Video password
*
* @return object Decoded JSON
* @return stdClass Decoded JSON
* */
public function getJSON($url, $format = null, $password = null)
{
@ -214,7 +214,7 @@ class VideoDownload
/**
* 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
*/
@ -266,12 +266,12 @@ class VideoDownload
/**
* Get a process that runs avconv in order to convert a video.
*
* @param object $video Video object returned by youtube-dl
* @param int $audioBitrate Audio bitrate of the converted file
* @param string $filetype Filetype of the converted file
* @param bool $audioOnly True to return an audio-only file
* @param string $from Start the conversion at this time
* @param string $to End the conversion at this time
* @param stdClass $video Video object returned by youtube-dl
* @param int $audioBitrate Audio bitrate of the converted file
* @param string $filetype Filetype of the converted file
* @param bool $audioOnly True to return an audio-only file
* @param string $from Start the conversion at this time
* @param string $to End the conversion at this time
*
* @throws Exception If avconv/ffmpeg is missing
*
@ -484,8 +484,8 @@ class VideoDownload
/**
* Get a Tar stream containing every video in the playlist piped through the server.
*
* @param object $video Video object returned by youtube-dl
* @param string $format Requested format
* @param stdClass $video Video object returned by youtube-dl
* @param string $format Requested format
*
* @throws Exception If the popen stream was not created correctly
*