You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pass statically known integer arguments to the existing Variant overload of php::fn::abs. The scalar overload cannot represent PHP's value-dependent int|float result and overflows for the minimum integer. The Variant overload already handles this edge and preserves integer results for ordinary integers.
Reuse the existing ordered argument lowering, with one occurrence of the argument expression. Float and arbitrary-precision dispatch remain unchanged. No PHP-X API change or dependency on an open PHP-X PR is required.
Also correct the existing static_prop_write.phpt expectation for the closure magic name introduced by the already-merged closure fix. The previous expectation was the enclosing method name; both PHP 8.4 and 8.5 CI produce the lexical closure name.
Evidence
Before: the expanded abs_edge.phpt reproduces the wrong negative result on the static integer path; the old fixture only covered PHP_INT_MIN through std::any, selecting the already-correct Variant overload.
After: the regression covers assigning the result to a variable, an int|float function return, ordinary integers, floating-point inputs and an argument with a counter proving it is evaluated exactly once.
Four related PHPTs pass: abs edge cases, strict builtin union handling, arbitrary-precision math dispatch and union returns.
Full PHPUnit with phpy loaded: 2,335 tests, 6,790 assertions, no failures; 67 existing warnings, 36 deprecations and one skip.
Follow-up: the corrected static-property fixture, closure magic-name fixture, and abs fixture pass locally. A broader 45-test static/related run passes 42 tests; the remaining three differ only by PHP 8.5 callable deprecation messages in the local environment and passed in the original CI run.
git diff --check passes. Local validation uses Linux ARM64 Docker / PHP 8.5.10 ZTS; PHP 8.4 and other platforms are left to CI.
Merge Danger
Door: two-way
Blast Radius: abs-codegen
Only statically known integer calls routed to php::fn::abs change overload. PHP-X's public scalar API and other math function dispatch are unchanged.
Thank you for investigating this edge case. We will not change the current implementation.
TypePHP intentionally compiles statically inferred integers as php::Int and keeps arithmetic on the native C++ integer path. These operations do not dynamically promote to floating point on overflow as Zend PHP does. abs(PHP_INT_MIN) therefore follows the same native integer semantics as other php::Int arithmetic.
Changing every normal abs(int) call to use Variant would add dynamic construction and result handling to a very common path for an extremely uncommon boundary case, while making abs() inconsistent with the rest of TypePHP's native integer operations.
Zend-compatible value-dependent behavior remains available for dynamic values, for example values explicitly converted through std::any().
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
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.
Summary
Pass statically known integer arguments to the existing Variant overload of
php::fn::abs. The scalar overload cannot represent PHP's value-dependentint|floatresult and overflows for the minimum integer. The Variant overload already handles this edge and preserves integer results for ordinary integers.Reuse the existing ordered argument lowering, with one occurrence of the argument expression. Float and arbitrary-precision dispatch remain unchanged. No PHP-X API change or dependency on an open PHP-X PR is required.
Also correct the existing
static_prop_write.phptexpectation for the closure magic name introduced by the already-merged closure fix. The previous expectation was the enclosing method name; both PHP 8.4 and 8.5 CI produce the lexical closure name.Evidence
abs_edge.phptreproduces the wrong negative result on the static integer path; the old fixture only covered PHP_INT_MIN throughstd::any, selecting the already-correct Variant overload.int|floatfunction return, ordinary integers, floating-point inputs and an argument with a counter proving it is evaluated exactly once.git diff --checkpasses. Local validation uses Linux ARM64 Docker / PHP 8.5.10 ZTS; PHP 8.4 and other platforms are left to CI.Merge Danger
Door: two-way
Blast Radius: abs-codegen
Only statically known integer calls routed to
php::fn::abschange overload. PHP-X's public scalar API and other math function dispatch are unchanged.