Add type hints from DocBlocks
This commit is contained in:
@@ -11,7 +11,7 @@ class AnimatedGifService
|
||||
* @param integer $dataSize GIF blob size.
|
||||
* @return boolean GIF file/blob is animated.
|
||||
*/
|
||||
public static function isAnimatedGif(string $filenameOrBlob, int $dataSize = 0)
|
||||
public static function isAnimatedGif(string $filenameOrBlob, int $dataSize = 0): bool
|
||||
{
|
||||
$regex = '#\x00\x21\xF9\x04.{4}\x00(\x2C|\x21)#s';
|
||||
$count = 0;
|
||||
@@ -44,7 +44,7 @@ class AnimatedGifService
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function extract(string $filenameOrBlob, int $dataSize = 0, $originalFrames = false)
|
||||
public function extract(string $filenameOrBlob, int $dataSize = 0, bool $originalFrames = false): array
|
||||
{
|
||||
if (self::isAnimatedGif($filenameOrBlob) === false) {
|
||||
return [];
|
||||
@@ -198,7 +198,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @param string $filename GIF filename path
|
||||
*/
|
||||
private function parseFramesInfo($filename)
|
||||
private function parseFramesInfo(string $filename)
|
||||
{
|
||||
$this->openFile($filename);
|
||||
$this->parseGifHeader();
|
||||
@@ -278,7 +278,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @param integer $type
|
||||
*/
|
||||
private function parseGraphicsExtension($type)
|
||||
private function parseGraphicsExtension(int $type)
|
||||
{
|
||||
$startdata = $this->readByte(2);
|
||||
|
||||
@@ -306,7 +306,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @param integer $type
|
||||
*/
|
||||
private function getFrameString($type)
|
||||
private function getFrameString(int $type)
|
||||
{
|
||||
if ($this->checkByte(0x2c)) {
|
||||
$start = $this->pointer;
|
||||
@@ -407,7 +407,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getImageDataByte($type, $start, $length)
|
||||
private function getImageDataByte(string $type, int $start, int $length): string
|
||||
{
|
||||
if ($type == "ext") {
|
||||
return substr($this->frameSources[$this->frameNumber]["graphicsextension"], $start, $length);
|
||||
@@ -427,7 +427,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
private function getImageDataBit($type, $byteIndex, $bitStart, $bitLength)
|
||||
private function getImageDataBit(string $type, int $byteIndex, int $bitStart, int $bitLength): number
|
||||
{
|
||||
if ($type == "ext") {
|
||||
return $this->readBits(ord(substr($this->frameSources[$this->frameNumber]["graphicsextension"], $byteIndex, 1)), $bitStart, $bitLength);
|
||||
@@ -444,7 +444,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
private function dualByteVal($s)
|
||||
private function dualByteVal(string $s): int
|
||||
{
|
||||
$i = (ord($s[1]) * 256 + ord($s[0]));
|
||||
|
||||
@@ -456,7 +456,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @param integer $firstLength
|
||||
*/
|
||||
private function readDataStream($firstLength)
|
||||
private function readDataStream(int $firstLength)
|
||||
{
|
||||
$this->pointerForward($firstLength);
|
||||
$length = $this->readByteInt();
|
||||
@@ -474,7 +474,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @param string $filename
|
||||
*/
|
||||
private function openFile($filename)
|
||||
private function openFile(string $filename)
|
||||
{
|
||||
$this->handle = fopen($filename, "rb");
|
||||
$this->pointer = 0;
|
||||
@@ -500,7 +500,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function readByte($byteCount)
|
||||
private function readByte(int $byteCount): string
|
||||
{
|
||||
$data = fread($this->handle, $byteCount);
|
||||
$this->pointer += $byteCount;
|
||||
@@ -513,7 +513,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
private function readByteInt()
|
||||
private function readByteInt(): int
|
||||
{
|
||||
$data = fread($this->handle, 1);
|
||||
$this->pointer++;
|
||||
@@ -530,7 +530,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
private function readBits($byte, $start, $length)
|
||||
private function readBits(string $byte, int $start, int $length): number
|
||||
{
|
||||
$bin = str_pad(decbin($byte), 8, "0", STR_PAD_LEFT);
|
||||
$data = substr($bin, $start, $length);
|
||||
@@ -543,7 +543,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @param integer $length
|
||||
*/
|
||||
private function pointerRewind($length)
|
||||
private function pointerRewind(int $length)
|
||||
{
|
||||
$this->pointer -= $length;
|
||||
fseek($this->handle, $this->pointer);
|
||||
@@ -554,7 +554,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @param integer $length
|
||||
*/
|
||||
private function pointerForward($length)
|
||||
private function pointerForward(int $length)
|
||||
{
|
||||
$this->pointer += $length;
|
||||
fseek($this->handle, $this->pointer);
|
||||
@@ -568,7 +568,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function dataPart($start, $length)
|
||||
private function dataPart(int $start, int $length): string
|
||||
{
|
||||
fseek($this->handle, $start);
|
||||
$data = fread($this->handle, $length);
|
||||
@@ -584,7 +584,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private function checkByte($byte)
|
||||
private function checkByte(int $byte): bool
|
||||
{
|
||||
if (fgetc($this->handle) == chr($byte)) {
|
||||
fseek($this->handle, $this->pointer);
|
||||
@@ -601,7 +601,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private function checkEOF()
|
||||
private function checkEOF(): bool
|
||||
{
|
||||
if (fgetc($this->handle) === false) {
|
||||
return true;
|
||||
@@ -631,7 +631,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getTotalDuration()
|
||||
public function getTotalDuration(): int
|
||||
{
|
||||
return $this->totalDuration;
|
||||
}
|
||||
@@ -641,7 +641,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getFrameNumber()
|
||||
public function getFrameNumber(): int
|
||||
{
|
||||
return $this->frameNumber;
|
||||
}
|
||||
@@ -651,7 +651,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFrames()
|
||||
public function getFrames(): array
|
||||
{
|
||||
return $this->frames;
|
||||
}
|
||||
@@ -661,7 +661,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFramePositions()
|
||||
public function getFramePositions(): array
|
||||
{
|
||||
return $this->framePositions;
|
||||
}
|
||||
@@ -671,7 +671,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFrameDimensions()
|
||||
public function getFrameDimensions(): array
|
||||
{
|
||||
return $this->frameDimensions;
|
||||
}
|
||||
@@ -681,7 +681,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFrameImages()
|
||||
public function getFrameImages(): array
|
||||
{
|
||||
return $this->frameImages;
|
||||
}
|
||||
@@ -691,7 +691,7 @@ class GifFrameExtractor
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFrameDurations()
|
||||
public function getFrameDurations(): array
|
||||
{
|
||||
return $this->frameDurations;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user