Fix for deprecation warning in SimpleGraphHelper::bar() #981
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.