Skip to content

Fix float to int deprecation in "is odd by" / "is even by" operators - #1210

Open
h-marumoto wants to merge 1 commit into
smarty-php:masterfrom
h-marumoto:fix_1208
Open

h-marumoto wants to merge 1 commit into
smarty-php:masterfrom
h-marumoto:fix_1208

Conversation

@h-marumoto

Copy link
Copy Markdown
Contributor

Fixes #1208

Hi!

is [not] odd by / is [not] even by compile to (1 & $a / $b).
When the division has a remainder, the bitwise AND triggers "Implicit conversion from float to int loses precision" on PHP 8.1+.
The division result is now cast to int explicitly ((1 & (int)($a / $b))), which matches the implicit truncation PHP was already doing, so template output is unchanged.

Thank you!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecation warning in demo app, Smarty 5.8.4, PHP 8.4

1 participant