Skip to content

Stdlib: get_defined_constants(true) extension groups (#17416)#17421

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-17416-get-defined-constants-groups
Jul 8, 2026
Merged

Stdlib: get_defined_constants(true) extension groups (#17416)#17421
PurHur merged 1 commit into
masterfrom
agent/issue-17416-get-defined-constants-groups

Conversation

@PurHur

@PurHur PurHur commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add ExtensionConstantGroups registry so get_defined_constants(true) buckets VM-defined extension constants by extension name (calendar, hash, dom, filter, standard, etc.) instead of lumping them into user.
  • Extract stdlib bootstrap constant maps into StdlibModuleConstants (single source for Module::init() and categorization).
  • Add compliance guard for calendar / CAL_GREGORIAN; sync spine (+4 units).

php-src reference

  • Zend/zend_builtin_functions.cget_defined_constants() categorized buckets

PHP implementation

  • ext/standard/ExtensionConstantGroups.php — extension name → registered constant map
  • ext/standard/VmConstants.phpbuildCategorized() iterates registry
  • ext/standard/StdlibModuleConstants.php — stdlib/date/zlib/json bootstrap maps

Verification

./script/docker-exec.sh -- bash -lc \
  'echo "zend:"; php -r '\''$c=get_defined_constants(true); var_dump(defined("CAL_GREGORIAN")); var_dump(isset($c["calendar"]["CAL_GREGORIAN"]));'\''; \
   echo "vm:"; php bin/vm.php -r '\''$c=get_defined_constants(true); var_dump(defined("CAL_GREGORIAN")); var_dump(isset($c["calendar"]["CAL_GREGORIAN"]));'\'''
# zend: bool(true) bool(true)
# vm:  bool(true) bool(true)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter "GetDefinedConstants|filter_defined_constants"'
# OK (13 tests, 20 assertions)

php script/check-selfhost-spine-coverage-sync.php
# OK (spine covers all 4278 inventory files)

Closes #17416

Made with Cursor

…#17416)

Extension constants registered via defineConstant() were lumped into the
user bucket; Zend groups them by extension (calendar, hash, dom, etc.).
Add ExtensionConstantGroups registry and route buildCategorized() through
it so VM/JIT/AOT match php-src buckets including calendar/CAL_GREGORIAN.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur PurHur merged commit 8d274ae into master Jul 8, 2026
1 check failed
@PurHur PurHur deleted the agent/issue-17416-get-defined-constants-groups branch July 8, 2026 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stdlib/VM parity: get_defined_constants(true) missing extension groups (e.g. calendar)

1 participant