Skip to content

Commit

Permalink
increase phpstan level + fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nielsvanpach committed Dec 1, 2023
1 parent eacba4b commit e013c5b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ includes:
- phpstan-baseline.neon

parameters:
level: 6
level: 9
paths:
- src/

Expand Down
4 changes: 2 additions & 2 deletions src/Drivers/Concerns/CalculatesFocalCropCoordinates.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/** @mixin \Spatie\Image\Drivers\ImageDriver */
trait CalculatesFocalCropCoordinates
{
/** @return array<int> */
protected function calculateFocalCropCoordinates(int $width, int $height, int $cropCenterX, int $cropCenterY): array
/** @return array<int, int|null> */
protected function calculateFocalCropCoordinates(int $width, int $height, ?int $cropCenterX, ?int $cropCenterY): array
{
$width = min($width, $this->getWidth());
$height = min($height, $this->getHeight());
Expand Down
3 changes: 2 additions & 1 deletion src/Drivers/Gd/GdDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ protected function modify(

$transparentColorValue = imagecolortransparent($this->image);

if ($transparentColorValue != -1) {
if ($transparentColorValue !== -1) {
$rgba = imagecolorsforindex($newImage, $transparentColorValue);

Check failure on line 219 in src/Drivers/Gd/GdDriver.php

View workflow job for this annotation

GitHub Actions / phpstan

Parameter #1 $image of function imagecolorsforindex expects GdImage, GdImage|false given.

$transparentColor = imagecolorallocatealpha(
Expand Down Expand Up @@ -656,6 +656,7 @@ public function border(int $width, BorderType $type, string $color = '000000'):
return $this;
}

/** @param int<-1, 100> $quality */
public function quality(int $quality): self
{
$this->ensureNumberBetween($quality, -1, 100, 'quality');
Expand Down
5 changes: 3 additions & 2 deletions src/Size.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
class Size
{
public function __construct(
public int|float $width,
public int|float $height,
public int $width,
public int $height,
public Point $pivot = new Point()
) {
}
Expand Down Expand Up @@ -42,6 +42,7 @@ public function resize(
->resizeWidth($desiredWidth, $constraints)
->resizeHeight($desiredHeight, $constraints);

// @todo desiredWidth and desiredHeight can still be null here, which will cause an error
return $dominantHeightSize->fitsInto(new Size($desiredWidth, $desiredHeight))
? $dominantHeightSize
: $dominantWidthSize;
Expand Down

0 comments on commit e013c5b

Please sign in to comment.