Browse Source

Merge pull request #17410 from cakephp/5.x-stan

Clean up PHPStan baseline.
ADmad 2 years ago
parent
commit
5baca240b0
2 changed files with 6 additions and 13 deletions
  1. 0 10
      phpstan-baseline.neon
  2. 6 3
      src/Validation/Validation.php

+ 0 - 10
phpstan-baseline.neon

@@ -131,16 +131,6 @@ parameters:
 			path: src/TestSuite/TestCase.php
 
 		-
-			message: "#^Offset 0 does not exist on array\\{\\}\\|array\\{0\\: int, 1\\: int, 2\\: int, 3\\: string, mime\\: string, channels\\?\\: int, bits\\?\\: int\\}\\.$#"
-			count: 1
-			path: src/Validation/Validation.php
-
-		-
-			message: "#^Offset 1 does not exist on array\\{\\}\\|array\\{0\\: int, 1\\: int, 2\\: int, 3\\: string, mime\\: string, channels\\?\\: int, bits\\?\\: int\\}\\.$#"
-			count: 1
-			path: src/Validation/Validation.php
-
-		-
 			message: "#^Unsafe usage of new static\\(\\)\\.$#"
 			count: 1
 			path: src/View/Form/ContextFactory.php

+ 6 - 3
src/Validation/Validation.php

@@ -1411,9 +1411,12 @@ class Validation
             return false;
         }
 
-        [$width, $height] = getimagesize($file) ?: [];
-        $validHeight = null;
-        $validWidth = null;
+        $width = $height = null;
+        $imageSize = getimagesize($file);
+        if ($imageSize) {
+            [$width, $height] = $imageSize;
+        }
+        $validWidth = $validHeight = null;
 
         if (isset($options['height'])) {
             $validHeight = self::comparison($height, $options['height'][0], $options['height'][1]);