fix(stdlib): str_shuffle() TypeError for non-string operands (#4551) - #7543
Merged
Merged
Conversation
Use VmString::coerceStringBuiltinArg and JitStringBuiltinArg so array/object operands match php-src ext/standard/string.c instead of silently accepting non-strings or throwing LogicException. Co-authored-by: Cursor <cursoragent@cursor.com>
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
str_shuffle()throughVmString::coerceStringBuiltinArg()(VM) andJitStringBuiltinArg::lower()(JIT/AOT) so non-string argument Php stdlib specs implementation #1 raisesTypeErrorwith Zend-like messages, matching php/php-srcext/standard/string.cPHP_FUNCTION(str_shuffle).[]andLogicExceptionfor wrong types.Closes #4551
php-src reference
ext/standard/string.c—PHP_FUNCTION(str_shuffle)(Z_PARAM_STR)Implementation
ext/standard/str_shuffle.phptest/compliance/cases/stdlib/str_shuffle_type_error*.phpttest/fixtures/aot/cases/str_shuffle_type_error.phptVerification
Output:
Note: Full AOT link (
bin/compile.php -o) and MCJIT execute for type_error PHPTs share pre-existing LLVM verify failures on this harness (same ascrc32_type_error/ucfirst_type_error); AOT lint (-l) and VM paths are green.Made with Cursor