Skip to content

Commit

Permalink
Adjust code to meet coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed Feb 1, 2024
1 parent 3d4fa6e commit 955cb6c
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/AbstractEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class AbstractEntity
*/
public static function getShortClassname(): string
{
return (new ReflectionClass(get_called_class()))->getShortName();
return (new ReflectionClass(static::class))->getShortName();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/ColorTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function getLogicalSize(): int
*/
public function getByteSize(): int
{
if (! $this->hasColors()) {
if (!$this->hasColors()) {
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/CommentExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function getComments()
/**
* Get one comment by key
*
* @param int $key
* @param int $key
* @return mixed
*/
public function getComment(int $key): mixed
Expand Down
10 changes: 5 additions & 5 deletions src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public function setSize(int $width, int $height): self
/**
* Create new canvas
*
* @param int $width
* @param int $height
* @param int $width
* @param int $height
* @return self
*/
public static function canvas(int $width, int $height): self
Expand Down Expand Up @@ -153,9 +153,9 @@ protected function buildGraphicControlExtension(
/**
* Build table based image object from given source
*
* @param GifDataStream $source
* @param int $left
* @param int $top
* @param GifDataStream $source
* @param int $left
* @param int $top
* @return TableBasedImage
*/
protected function buildTableBasedImage(GifDataStream $source, int $left, int $top): TableBasedImage
Expand Down
2 changes: 1 addition & 1 deletion src/Decoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Decoder
/**
* Decode given input
*
* @param mixed $input
* @param mixed $input
* @return GifDataStream
*/
public static function decode(mixed $input): GifDataStream
Expand Down
8 changes: 4 additions & 4 deletions src/Decoders/AbstractDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function setHandle($handle): self
/**
* Read given number of bytes and move file pointer
*
* @param int $length
* @param int $length
* @return string
*/
protected function getNextBytes(int $length): string
Expand All @@ -49,7 +49,7 @@ protected function getNextBytes(int $length): string
/**
* Read given number of bytes and move pointer back to previous position
*
* @param int $length
* @param int $length
* @return string
*/
protected function viewNextBytes(int $length): string
Expand Down Expand Up @@ -81,7 +81,7 @@ protected function getRemainingBytes(): string
do {
$byte = fread($this->handle, 1);
$all .= $byte;
} while (! feof($this->handle));
} while (!feof($this->handle));

return $all;
}
Expand All @@ -99,7 +99,7 @@ protected function getNextByte(): string
/**
* Move file pointer on handle by given offset
*
* @param int $offset
* @param int $offset
* @return self
*/
protected function movePointer(int $offset): self
Expand Down
6 changes: 3 additions & 3 deletions src/Decoders/AbstractPackedBitDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected function decodePackedByte(string $byte): int
/**
* Determine if packed bit is set
*
* @param int $num from left to right, starting with 0
* @param int $num from left to right, starting with 0
* @return bool
*/
protected function hasPackedBit(string $byte, int $num): bool
Expand All @@ -30,8 +30,8 @@ protected function hasPackedBit(string $byte, int $num): bool
/**
* Get packed bits
*
* @param int $start
* @param int $length
* @param int $start
* @param int $length
* @return string
*/
protected function getPackedBits(string $byte, int $start = 0, int $length = 8): string
Expand Down
2 changes: 1 addition & 1 deletion src/Decoders/CommentExtensionDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function decodeComments(): array
/**
* Decode blocksize of following comment
*
* @param string $byte
* @param string $byte
* @return int
*/
protected function decodeBlocksize(string $byte): int
Expand Down
2 changes: 0 additions & 2 deletions src/Decoders/NetscapeApplicationExtensionDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace Intervention\Gif\Decoders;

use Intervention\Gif\Decoders\ApplicationExtensionDecoder;

class NetscapeApplicationExtensionDecoder extends ApplicationExtensionDecoder
{
}
2 changes: 1 addition & 1 deletion src/Encoders/PlainTextExtensionEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(PlainTextExtension $source)
*/
public function encode(): string
{
if (! $this->source->hasText()) {
if (!$this->source->hasText()) {
return '';
}

Expand Down
6 changes: 3 additions & 3 deletions src/Splitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function getDelays(): array
*
* @param GifDataStream $stream
*/
public function setStream(GifDataStream $stream): Splitter
public function setStream(GifDataStream $stream): self
{
$this->stream = $stream;

Expand All @@ -78,10 +78,10 @@ public function setStream(GifDataStream $stream): Splitter
/**
* Static constructor method
*
* @param GifDataStream $stream
* @param GifDataStream $stream
* @return Splitter
*/
public static function create(GifDataStream $stream): Splitter
public static function create(GifDataStream $stream): self
{
return new self($stream);
}
Expand Down
10 changes: 5 additions & 5 deletions src/Traits/CanDecode.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ trait CanDecode
/**
* Decode current instance
*
* @param resource $source
* @param null|int $length
* @param resource $source
* @param null|int $length
* @return mixed
*/
public static function decode($source, ?int $length = null): mixed
Expand All @@ -24,16 +24,16 @@ public static function decode($source, ?int $length = null): mixed
/**
* Get decoder for current instance
*
* @param resource $source
* @param null|int $length
* @param resource $source
* @param null|int $length
* @return AbstractDecoder
*/
protected static function getDecoder($source, ?int $length = null): AbstractDecoder
{
$classname = self::getDecoderClassname();

if (!class_exists($classname)) {
throw new DecoderException("Decoder for '" . get_called_class() . "' not found.");
throw new DecoderException("Decoder for '" . static::class . "' not found.");
}

return new $classname($source, $length);
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/CanEncode.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function getEncoder(): AbstractEncoder
$classname = $this->getEncoderClassname();

if (!class_exists($classname)) {
throw new EncoderException("Encoder for '" . get_class($this) . "' not found.");
throw new EncoderException("Encoder for '" . $this::class . "' not found.");
}

return new $classname($this);
Expand Down
6 changes: 3 additions & 3 deletions src/Traits/CanHandleFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private static function isFilePath($input): bool
/**
* Determine if given string contains null bytes
*
* @param string $string
* @param string $string
* @return bool
*/
private static function hasNullBytes($string): bool
Expand All @@ -30,7 +30,7 @@ private static function hasNullBytes($string): bool
/**
* Create file pointer from given gif image data
*
* @param string $data
* @param string $data
* @return resource
*/
private static function getHandleFromData($data)
Expand All @@ -45,7 +45,7 @@ private static function getHandleFromData($data)
/**
* Create file pounter from given file path
*
* @param string $path
* @param string $path
* @return resource
*/
private static function getHandleFromFilePath(string $path)
Expand Down

0 comments on commit 955cb6c

Please sign in to comment.