Skip to content

Commit

Permalink
Less_Functions: Fix "Implicit conversion from float to int" on PHP 8.…
Browse files Browse the repository at this point in the history
…1 warning

This could happen when using the `hsv()` Less function.

Closes #119.

Bug: T383085
Change-Id: Icaeaff167a574f3d335d984c02c4bbe2cdb150f7
  • Loading branch information
peterpp authored and Krinkle committed Jan 6, 2025
1 parent 2573465 commit afdef14
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Less/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function hsv( $h, $s, $v ) {
* @param float $a
*/
public function hsva( $h, $s, $v, $a ) {
$h = ( ( self::_number( $h ) % 360 ) / 360 ) * 360;
$h = ( ( (int)self::_number( $h ) % 360 ) / 360 ) * 360;
$s = self::_number( $s );
$v = self::_number( $v );
$a = self::_number( $a );
Expand Down
3 changes: 3 additions & 0 deletions test/Fixtures/less.php/css/T383085-float-precision.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
div {
color: #efffde;
}
6 changes: 6 additions & 0 deletions test/Fixtures/less.php/less/T383085-float-precision.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@a: #EEFFDE;
@b: hsv(hsvhue(@a), hsvsaturation(@a), hsvvalue(@a));

div {
color: @b;
}

0 comments on commit afdef14

Please sign in to comment.