Stdlib: substr_compare(null $offset) DEP+coerce like Z_PARAM_LONG (#29504) - #29520
Merged
Conversation
…9504) Route $offset through shared soft-null int helpers (VmMath/JitChr) so null matches php-src deprecate+coerce instead of a hard TypeError. Co-authored-by: Cursor <cursoragent@cursor.com>
3 tasks
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.
Summary
substr_compare(..., null)$offsetnow emits Zend-shapedE_DEPRECATEDand coerces to0(php-srcext/standard/string.cZ_PARAM_LONG), instead of a hardTypeError.VmMath::parseChrCodepointForFrame; JIT/AOT usesJitChr::lowerZParamLongArg+ compile-time soft-null fold (same helpers assubstr_count#21657).SubstrCompareNullOffset{VM,JIT}Test; typeerror fixtures use non-numeric'x'so numeric-string coerce matches Zend.Closes #29504
php-src reference
ext/standard/string.c—PHP_FUNCTION(substr_compare)ext/standard/string.stub.php—int $offsetTest plan
php bin/vm.php test/repro/issue_29504_substr_compare_null_offset.php→WARN[8192]: … parameter #3 ($offset)…+-1php bin/jit.php test/repro/issue_29504_substr_compare_null_offset.php→ same./phpc build -o /tmp/sc29504 test/repro/issue_29504_substr_compare_null_offset_aot.php && /tmp/sc29504→ DEP +-1vendor/bin/phpunit --filter SubstrCompareNullOffset→ OK (2 tests)vendor/bin/phpunit test/compliance/SubstrCompareVMTest.php/SubstrCompareJITTest.php→ OKPillar probe:
user_release_ready: yes(inventory/spine/north-star5-fast green); gen-0 seed noted stale (unrelated).Made with Cursor