Proposal: Distinguish between float and int in print_r() output. #6611
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.
Benefits:
print_r() previously make it look as if a value was an int when it really was a
float. When using print_r() to inspect the value of an array, TypeErrors or differences in behavior can be unintuitive
if you think the value is really an integer when it's actually a float.
This change should save time debugging in the long run for users unfamiliar with this behavior.
(https://www.php.net/print_r has no mention of floats in the summary or user-submitted comments)
print_r() output now shows a difference between 0.0 and 0,
which is useful for generating diffs between expected and actual values in test failures asserting values are
===
, etc.Cons:
print_r and dumping float values.
If this is merged, tests would need to normalize print_r output
to pass in both 8.0 and 8.1 (or switch to var_dump(), etc.)
TODO: Fix remaining test failures