cakephp / debug_kit

Debug Toolbar for CakePHP applications.
http://cakephp.org
Other
852 stars 573 forks source link

Fix for deprecation warning in SimpleGraphHelper::bar() #981

Closed jharder closed 10 months ago

jharder commented 10 months ago

When using DebugKit, on the Timer tab the bar graphs all display an error message:

Deprecated (8192): Implicit conversion from float 126.51705741882324 to int loses precision [in /var/cake/vendor/cakephp/debug_kit/src/View/Helper/SimpleGraphHelper.php, line 55]

The bar() function currently uses these parameters like this: $value: $graphValue = $value / $max * $width;

$offset: $graphOffset = $offset / $max * $width;

Both new $graph* values are then provided to round(), which handles conversion to int. The raw values are then only used in displaying the message. From what I can tell, this function can handle float as well as int values, and this fix updates the type hint to allow the actual consumers of the function to use it as they have historically.

Added a new test to cover the explicit case. All test cases pass.