Stdlib: implement class_constants() — interface/enum constant maps (#7309)#7326
Merged
Conversation
Add VM handler backed by class metadata, JIT/AOT lowering via compile-time class constant tables, and compliance tests matching php-src enum case objects. 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
class_constants(string $class): arrayinext/standard/class_constants_.phpwith VM helpers inVmReflection::fetchClassEntryForClassConstants()/classConstantsArray().ext/standard/Module.php; JIT/AOT lowering inext/standard/JitClassConstants.phpvia compile-time class constant tables (Object_::classConstFetch()), returning enum case objects not backing scalars (php-src-strict,Zend/zend_constants.c).ext/standard/basic_functions.c—PHP_FUNCTION(class_constants); behavior aligned withReflectionClass::getConstants()on PHP 8.2 reference.Closes #7309
Verification
Results (2026-06-07 harness):
ClassConstantsBuiltinTest: OK (3 tests)VMTest --filter class_constants: OK (3 tests)JITTest --filter class_constants: OK (3 tests)array('X'=>1)+ enum case map with\E::Aobjectsbin/compile.php -lon AOT fixture body: exit 0AOT link note:
bin/compile.php -ocurrently segfaults (exit 139) for all AOT fixtures on this harness host, including pre-existingclass_parents_get_class_vars— not introduced by this PR. AOT fixture +-lgate added for when link is restored.PHP-in-PHP
No new C runtime symbols; behavior lives in
ext/standard/+lib/JIT/Builtin/Type/Object_.phpdisplay-name helper only.Made with Cursor