Преглед изворни кода

handle PHP 8.2 deprecation

PHP 8.2 deprecates implicit conversion from float to int if it loses precision, hence the explicit conversion.

PHP 8.1 deprecates the (optional since PHP 8.0) 3rd parameter of imagefilledpolygon(), but 7.3 & 7.4 require it.
El RIDO пре 2 година
родитељ
комит
6bcef2fa24
1 измењених фајлова са 10 додато и 10 уклоњено
  1. 10 10
      lib/Vizhash16x16.php

+ 10 - 10
lib/Vizhash16x16.php

@@ -109,9 +109,9 @@ class Vizhash16x16
         for ($i = 0; $i < 7; ++$i) {
             $action = $this->getInt();
             $color  = imagecolorallocate($image, $r, $g, $b);
-            $r      = $r0      = ($r0 + $this->getInt() / 25) % 256;
-            $g      = $g0      = ($g0 + $this->getInt() / 25) % 256;
-            $b      = $b0      = ($b0 + $this->getInt() / 25) % 256;
+            $r      = $r0      = ((int) $r0 + $this->getInt() / 25) % 256;
+            $g      = $g0      = ((int) $g0 + $this->getInt() / 25) % 256;
+            $b      = $b0      = ((int) $b0 + $this->getInt() / 25) % 256;
             $this->drawshape($image, $action, $color);
         }
 
@@ -136,7 +136,7 @@ class Vizhash16x16
     {
         $v = $this->VALUES[$this->VALUES_INDEX];
         ++$this->VALUES_INDEX;
-        $this->VALUES_INDEX %= count($this->VALUES); // Warp around the array
+        $this->VALUES_INDEX %= count($this->VALUES); // Wrap around the array
         return $v;
     }
 
@@ -148,7 +148,7 @@ class Vizhash16x16
      */
     private function getX()
     {
-        return $this->width * $this->getInt() / 256;
+        return (int) $this->width * $this->getInt() / 256;
     }
 
     /**
@@ -159,7 +159,7 @@ class Vizhash16x16
      */
     private function getY()
     {
-        return $this->height * $this->getInt() / 256;
+        return (int) $this->height * $this->getInt() / 256;
     }
 
     /**
@@ -190,9 +190,9 @@ class Vizhash16x16
             ($color2[2] - $color1[2]) / $size,
         );
         for ($i = 0; $i < $size; ++$i) {
-            $r = $color1[0] + ($diffs[0] * $i);
-            $g = $color1[1] + ($diffs[1] * $i);
-            $b = $color1[2] + ($diffs[2] * $i);
+            $r = $color1[0] + ((int) $diffs[0] * $i);
+            $g = $color1[1] + ((int) $diffs[1] * $i);
+            $b = $color1[2] + ((int) $diffs[2] * $i);
             if ($direction == 'h') {
                 imageline($img, $i, 0, $i, $sizeinv, imagecolorallocate($img, $r, $g, $b));
             } else {
@@ -222,7 +222,7 @@ class Vizhash16x16
                 break;
             case 3:
                 $points = array($this->getX(), $this->getY(), $this->getX(), $this->getY(), $this->getX(), $this->getY(), $this->getX(), $this->getY());
-                imagefilledpolygon($image, $points, 4, $color);
+                version_compare(PHP_VERSION, '8.1', '<') ? imagefilledpolygon($image, $points, 4, $color) : imagefilledpolygon($image, $points, $color);
                 break;
             default:
                 $start = $this->getInt() * 360 / 256;