Add return types

This commit is contained in:
Pierre Rudloff 2020-12-17 22:43:05 +01:00
parent f2785bca03
commit 05311ac7b6
21 changed files with 84 additions and 78 deletions

View file

@ -113,7 +113,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
*
* @return int|null
*/
public function getSize()
public function getSize(): ?int
{
return null;
}
@ -123,7 +123,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
*
* @return bool
*/
public function isSeekable()
public function isSeekable(): bool
{
return true;
}
@ -143,7 +143,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
*
* @return bool
*/
public function isWritable()
public function isWritable(): bool
{
return true;
}
@ -153,7 +153,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
*
* @return bool
*/
public function isReadable()
public function isReadable(): bool
{
return true;
}
@ -173,7 +173,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
*
* @param string|null $key string $key Specific metadata to retrieve.
*
* @return array|mixed|null
* @return mixed|null
*/
public function getMetadata($key = null)
{
@ -208,7 +208,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
*
* @return string
*/
public function __toString()
public function __toString(): string
{
$this->rewind();
@ -243,7 +243,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
*
* @return bool
*/
public function eof()
public function eof(): bool
{
return $this->isComplete && feof($this->buffer);
}
@ -272,12 +272,12 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
/**
* Read data from the stream.
*
* @param mixed $count Number of bytes to read
* @param mixed $length Number of bytes to read
*
* @return string|false
* @throws AlltubeLibraryException
*/
public function read($count)
public function read($length)
{
// If the archive is complete, we only read the remaining buffer.
if (!$this->isComplete) {
@ -297,7 +297,7 @@ class PlaylistArchiveStream extends ZipArchive implements StreamInterface
}
} else {
// Continue streaming the current video.
$this->stream_file_part($this->curVideoStream->read($count));
$this->stream_file_part($this->curVideoStream->read($length));
}
} else {
// 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);
}
/**

View file

@ -39,7 +39,7 @@ class YoutubeChunkStream implements StreamInterface
*
* @return string
*/
public function read($length)
public function read($length): string
{
$size = intval($this->response->getHeader('Content-Length')[0]);
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.
*/
public function __toString()
public function __toString(): string
{
return (string)$this->response->getBody();
}
@ -83,7 +83,7 @@ class YoutubeChunkStream implements StreamInterface
*
* @return int|null
*/
public function getSize()
public function getSize(): ?int
{
return $this->response->getBody()->getSize();
}
@ -93,7 +93,7 @@ class YoutubeChunkStream implements StreamInterface
*
* @return int
*/
public function tell()
public function tell(): int
{
return $this->response->getBody()->tell();
}
@ -103,7 +103,7 @@ class YoutubeChunkStream implements StreamInterface
*
* @return bool
*/
public function eof()
public function eof(): bool
{
return $this->response->getBody()->eof();
}
@ -113,7 +113,7 @@ class YoutubeChunkStream implements StreamInterface
*
* @return bool
*/
public function isSeekable()
public function isSeekable(): bool
{
return $this->response->getBody()->isSeekable();
}
@ -146,7 +146,7 @@ class YoutubeChunkStream implements StreamInterface
*
* @return bool
*/
public function isWritable()
public function isWritable(): bool
{
return $this->response->getBody()->isWritable();
}
@ -168,7 +168,7 @@ class YoutubeChunkStream implements StreamInterface
*
* @return bool
*/
public function isReadable()
public function isReadable(): bool
{
return $this->response->getBody()->isReadable();
}
@ -178,7 +178,7 @@ class YoutubeChunkStream implements StreamInterface
*
* @return string
*/
public function getContents()
public function getContents(): string
{
return $this->response->getBody()->getContents();
}
@ -188,7 +188,7 @@ class YoutubeChunkStream implements StreamInterface
*
* @param string|null $key Specific metadata to retrieve.
*
* @return array|mixed|null
* @return mixed|null
*/
public function getMetadata($key = null)
{