From cbc8ed0845525aff8d8b0381d72f2f2657f94b1b Mon Sep 17 00:00:00 2001 From: oleibman <10341515+oleibman@users.noreply.github.com> Date: Sat, 2 Jul 2022 01:16:11 -0700 Subject: [PATCH] Changes for Phpstan 1.8.0 (#2920) Dependabot pushed changes. As usual for Phpstan, some changes to code are required. --- phpstan-baseline.neon | 5 ----- src/PhpSpreadsheet/Helper/Dimension.php | 2 ++ src/PhpSpreadsheet/Worksheet/MemoryDrawing.php | 8 ++++---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 858502fd..14160edf 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1250,11 +1250,6 @@ parameters: count: 2 path: src/PhpSpreadsheet/DefinedName.php - - - message: "#^Cannot use array destructuring on array\\|null\\.$#" - count: 1 - path: src/PhpSpreadsheet/Helper/Dimension.php - - message: "#^Cannot call method setBold\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Font\\|null\\.$#" count: 1 diff --git a/src/PhpSpreadsheet/Helper/Dimension.php b/src/PhpSpreadsheet/Helper/Dimension.php index 4e3e6680..425c9a61 100644 --- a/src/PhpSpreadsheet/Helper/Dimension.php +++ b/src/PhpSpreadsheet/Helper/Dimension.php @@ -57,8 +57,10 @@ class Dimension public function __construct(string $dimension) { + // @phpstan-ignore-next-line [$size, $unit] = sscanf($dimension, '%[1234567890.]%s'); $unit = strtolower(trim($unit ?? '')); + $size = (float) $size; // If a UoM is specified, then convert the size to pixels for internal storage if (isset(self::ABSOLUTE_UNITS[$unit])) { diff --git a/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php b/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php index e65541dc..b2d1aa69 100644 --- a/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php +++ b/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php @@ -86,8 +86,8 @@ class MemoryDrawing extends BaseDrawing return; } - $width = imagesx($this->imageResource); - $height = imagesy($this->imageResource); + $width = (int) imagesx($this->imageResource); + $height = (int) imagesy($this->imageResource); if (imageistruecolor($this->imageResource)) { $clone = imagecreatetruecolor($width, $height); @@ -150,8 +150,8 @@ class MemoryDrawing extends BaseDrawing if ($this->imageResource !== null) { // Get width/height - $this->width = imagesx($this->imageResource); - $this->height = imagesy($this->imageResource); + $this->width = (int) imagesx($this->imageResource); + $this->height = (int) imagesy($this->imageResource); } return $this;