Skip to content

Commit 0e10266

Browse files
committed
Type cast (int) where PHP8.x was complaining
PHP's gotten stricter about type juggling and complained that converting from `float` to `int` causes imprecisions and that if one does it, it should be explicit. Not rigorously tested but seems to have fixed the Warnings in my usage.
1 parent 361b8a8 commit 0e10266

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/MischiefCollective/ColorJizz/ColorJizz.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function distance(ColorJizz $destinationColor)
110110
$a_dimension_pow = pow(($a->a_dimension - $b->a_dimension), 2);
111111
$b_dimension_pow = pow(($a->b_dimension - $b->b_dimension), 2);
112112

113-
return sqrt($lightness_pow + $a_dimension_pow + $b_dimension_pow);
113+
return (int)sqrt($lightness_pow + $a_dimension_pow + $b_dimension_pow);
114114
}
115115

116116
/**

src/MischiefCollective/ColorJizz/Formats/CMY.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static function create($cyan, $magenta, $yellow)
6767
*/
6868
public function getCyan()
6969
{
70-
return $this->cyan;
70+
return (int)$this->cyan;
7171
}
7272

7373

@@ -78,7 +78,7 @@ public function getCyan()
7878
*/
7979
public function getMagenta()
8080
{
81-
return $this->magenta;
81+
return (int)$this->magenta;
8282
}
8383

8484

@@ -89,7 +89,7 @@ public function getMagenta()
8989
*/
9090
public function getYellow()
9191
{
92-
return $this->yellow;
92+
return (int)$this->yellow;
9393
}
9494

9595

src/MischiefCollective/ColorJizz/Formats/CMYK.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public static function create($cyan, $magenta, $yellow, $key)
7474
*/
7575
public function getCyan()
7676
{
77-
return $this->cyan;
77+
return (int)$this->cyan;
7878
}
7979

8080

@@ -85,7 +85,7 @@ public function getCyan()
8585
*/
8686
public function getMagenta()
8787
{
88-
return $this->magenta;
88+
return (int)$this->magenta;
8989
}
9090

9191

@@ -96,7 +96,7 @@ public function getMagenta()
9696
*/
9797
public function getYellow()
9898
{
99-
return $this->yellow;
99+
return (int)$this->yellow;
100100
}
101101

102102

@@ -107,7 +107,7 @@ public function getYellow()
107107
*/
108108
public function getKey()
109109
{
110-
return $this->key;
110+
return (int)$this->key;
111111
}
112112

113113
/**

src/MischiefCollective/ColorJizz/Formats/RGB.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function __construct($red, $green, $blue)
7272
*/
7373
public function getRed()
7474
{
75-
return (0.5 + $this->red) | 0;
75+
return (int)(0.5 + $this->red) | 0;
7676
}
7777

7878
/**
@@ -82,7 +82,7 @@ public function getRed()
8282
*/
8383
public function getGreen()
8484
{
85-
return (0.5 + $this->green) | 0;
85+
return (int)(0.5 + $this->green) | 0;
8686
}
8787

8888
/**
@@ -92,7 +92,7 @@ public function getGreen()
9292
*/
9393
public function getBlue()
9494
{
95-
return (0.5 + $this->blue) | 0;
95+
return (int)(0.5 + $this->blue) | 0;
9696
}
9797

9898
/**

0 commit comments

Comments
 (0)