consolidation / robo

Modern task runner for PHP
http://robo.li
Other
2.66k stars 305 forks source link

Implicit conversion from float to int loses precision #1094

Closed Sweetchuck closed 2 years ago

Sweetchuck commented 2 years ago

Steps to reproduce

Need a task which runs 5-10 minutes. The error message can't be reproducible all the time.

Expected behavior

To see the duration time at the end of the output.

Actual behavior

ERROR: Implicit conversion from float 105.24845504760742 to int loses precision in /.../vendor/consolidation/robo/src/Common/TimeKeeper.php:72

System Configuration

I have seen this error message in different docker containers (openSUSE Tumbleweed, Fedora 36, Ubuntu 21.10) PHP 8.0, 8.1

php -i | grep prec

precision => 14 => 14 serialize_precision => -1 => -1

Maybe this one is related: https://php.watch/versions/8.1/deprecate-implicit-conversion-incompatible-float-string

Sweetchuck commented 2 years ago

Related to #1071

Sweetchuck commented 2 years ago

I started to work on the fix, and cover the modifications with unit tests, but there are other problems as well. For example: TimeKeeper::formatDuration(3600) returns 00:00;

kurtjunker commented 2 years ago

Hi @Sweetchuck,

Is it possible that this fix can be merged to a new minor Version like 3.0.8? I think that this change can also be used in the previous PHP Versions.

Sweetchuck commented 2 years ago

@kurtjunker This fix is already merged into 3.x, and works with PHP 7.1 - 8.1.