Fix: Prevent implicit float-to-int conversion in applyReplacements()#3
Open
Bebicek wants to merge 2 commits intoevosoftcz:bootstrap_5_lednice_lockfrom
Open
Fix: Prevent implicit float-to-int conversion in applyReplacements()#3Bebicek wants to merge 2 commits intoevosoftcz:bootstrap_5_lednice_lockfrom
Bebicek wants to merge 2 commits intoevosoftcz:bootstrap_5_lednice_lockfrom
Conversation
unid15
requested changes
Jul 7, 2025
src/Traits/TButtonRenderer.php
Outdated
| if ((is_scalar($value) || $value === null) && isset($this->replacements[$value])) { | ||
| $key = is_scalar($value) ? (string) $value : $value; | ||
|
|
||
| if ((is_scalar($value) || $value === null) && isset($this->replacements[$key])) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request addresses a deprecation warning in PHP 8.1+ related to the implicit conversion of float values to integers when used as array keys.
In the
applyReplacements()method, the value retrieved from a table row ($value) may be a float. When such a value is used directly as a key in the$this->replacementsarray, PHP implicitly casts it to an integer (e.g., 178.12 → 178), which can lead to precision loss and unintended behavior.The fix includes:
$valueis a float and, if so, explicitly casting it to a string to preserve precision.isset()and array access.