Repository navigation
Language: (array) object cast — TYPE_CAST_ARRAY VM opcode (#3328) - #3346
Merged
Merged
Conversation
Add CastSupport::toArray() and wire OpCode::TYPE_CAST_ARRAY in the VM so (array) on objects exports instance properties and on arrays copies keys via HashTable::replaceCopy(). Matches Zend for public props and array copy semantics; protected/private mangling is follow-up. php-src: Zend/zend_operators.c (cast_object), convert_to_array 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
OpCode::TYPE_CAST_ARRAYin the VM vialib/VM/CastSupport.phpso(array)on objects exports instance property values and on arrays performs a keyed copy (HashTable::replaceCopy()).test/compliance/cases/language/cast_array_object.phpt(public properties + array copy isolation).Lane note: Lane C (
issue % 3 == 2) had no unclaimedimplementation-readylanguage issues without an open PR; this picks the lowest unclaimed language parity gap (#3328).php-src reference
Zend/zend_operators.c—cast_object, array cast /convert_to_arrayZend/zend_types.h—IS_ARRAYfrom objectVerification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter cast_array_object test/compliance/VMTest.php'Limits (follow-up)
TYPE_CAST_ARRAYstill throwsUnknown JIT opcodeif compiled natively (VM path only for now).\0Class\0name) not implemented; public + raw storage names only.Closes #3328
Made with Cursor