Skip to content

Commit 6637c2f

Browse files
authored
PhpCsFixer issues (#29)
1 parent fcef9bd commit 6637c2f

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/Image.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ final class Image
5757
private ?string $orient;
5858
private ?string $mime;
5959

60-
public function __construct(\GdImage|string $filename = null, bool $strict = false)
60+
public function __construct(\GdImage|string|null $filename = null, bool $strict = false)
6161
{
6262
Helper::checkGD();
6363

@@ -227,7 +227,7 @@ public function loadString(?string $imageString, bool $strict = false): self
227227
* Load image resource.
228228
* @param null|\GdImage|string $imageRes Image GD Resource
229229
*/
230-
public function loadResource(\GdImage|string $imageRes = null): self
230+
public function loadResource(\GdImage|string|null $imageRes = null): self
231231
{
232232
if (!$imageRes instanceof \GdImage) {
233233
throw new Exception('Image is not GD resource!');
@@ -280,7 +280,7 @@ public function isSquare(): bool
280280
* @param null|array|string $color Hex color string, array(red, green, blue) or array(red, green, blue, alpha).
281281
* Where red, green, blue - integers 0-255, alpha - integer 0-127
282282
*/
283-
public function create(int $width, ?int $height = null, array|string $color = null): self
283+
public function create(int $width, ?int $height = null, array|string|null $color = null): self
284284
{
285285
$this->cleanup();
286286

@@ -810,13 +810,14 @@ private function renderImageByFormat(
810810
* Get metadata of image or base64 string.
811811
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
812812
*/
813-
private function loadMeta(\GdImage|string $image = null, bool $strict = false): self
813+
private function loadMeta(\GdImage|string|null $image = null, bool $strict = false): self
814814
{
815815
// Gather meta data
816816
if ($image === null && $this->filename !== null && $this->filename !== '') {
817817
$imageInfo = \getimagesize($this->filename);
818818
if ($imageInfo !== false) {
819-
$this->image = $this->imageCreate((string)($imageInfo['mime'] ?? ''));
819+
// @phan-suppress-next-line PhanPartialTypeMismatchArgument
820+
$this->image = $this->imageCreate($imageInfo['mime']);
820821
}
821822
} elseif ($image instanceof \GdImage) {
822823
$this->image = $image;
@@ -854,9 +855,9 @@ private function loadMeta(\GdImage|string $image = null, bool $strict = false):
854855

855856
// Set internal state
856857
if (isset($imageInfo) && \is_array($imageInfo)) {
857-
$this->mime = $imageInfo['mime'] ?? null;
858-
$this->width = (int)($imageInfo['0'] ?? 0);
859-
$this->height = (int)($imageInfo['1'] ?? 0);
858+
$this->mime = $imageInfo['mime'];
859+
$this->width = $imageInfo['0'];
860+
$this->height = $imageInfo['1'];
860861
}
861862
$this->exif = $this->getExif();
862863
$this->orient = $this->getOrientation();

0 commit comments

Comments
 (0)