Stdlib: sort() unit enum arrays preserve stable order (#16905)#16906
Merged
Conversation
Unit enum cases are incomparable under SORT_REGULAR — return 0 from compareEnumCasesForSort() so insertion order matches Zend (php-src array.c). Refresh bootstrap-inventory.md for GetDefinedExcludeDisabledJit.php spine path. Verification: php bin/vm.php test/compliance/cases/stdlib/sort_enum_cases.phpt vendor/bin/phpunit --filter SortEnumCasesBuiltinTest php script/bootstrap-inventory.php --check 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
sort()on unit enum case arrays now preserves stable insertion order when cases are incomparable — matches Zend/php-srcarray.cbehavior (Stdlib: sort() on unit enum arrays reorders cases — must preserve stable order (ext/standard/array.c) #16905).EnumCaseSupport::compareEnumCasesForSort()returns0for distinct unit-enum cases (backed enums unchanged: object-handle order).sort_enum_cases.phptEXPECT to match Zend output (unitB,A;EOrderC,A,B).docs/bootstrap-inventory.md(GetDefinedExcludeDisabledJit.phpon vm.php spine path).php-src reference
ext/standard/array.c—php_array_sortenum zval compareZend/zend_enum.c— unit enum case handlesVerification
Output:
Closes #16905
Made with Cursor