Skip to content

Language: ReflectionType::__toString DNF parens and ?T for T|null (#23065)#23090

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-23065-reflection-type-tostring
Jul 25, 2026
Merged

Language: ReflectionType::__toString DNF parens and ?T for T|null (#23065)#23090
PurHur merged 1 commit into
masterfrom
agent/issue-23065-reflection-type-tostring

Conversation

@PurHur

@PurHur PurHur commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • Match php-src zend_type_to_string / ReflectionType::__toString for DNF unions (parentheses around intersection groups) and single-named |null?T.
  • PHP-in-PHP in lib/VM/ReflectionTypeSupport.php — no new runtime/*.c.
  • Compliance .phpt + repro; JIT umbrella skip (MCJIT lacks ReflectionFunction::getParameters).

Closes #23065

php-src reference

  • ext/reflection/php_reflection.c — ReflectionType stringification
  • Zend type pretty-print (zend_type_to_string) for DNF parens / ?T

PHP implementation

  • lib/VM/ReflectionTypeSupport.phpcfgTypeString DNF parens; buildTypeObject stores cfgTypeStringForDump for unions

Test plan

  • php bin/vm.php test/repro/issue_23065_reflection_type_tostring.php
  • Zend host PHP vs VM diff match
  • ./script/phpunit.sh --filter 'ReflectionTypesTest|reflection_type_tostring_dnf_null' → OK (5 tests)

Verification

$ php bin/vm.php test/repro/issue_23065_reflection_type_tostring.php
(Traversable&Countable)|array
?int
?int

$ ./script/phpunit.sh --filter 'ReflectionTypesTest|reflection_type_tostring_dnf_null'
OK (5 tests, 5 assertions)

Trust snapshot (#10533)

Made with Cursor

…3065)

Match php-src zend_type_to_string: wrap intersection groups in unions and
normalize single-named |null unions to ?T for ReflectionType string casts.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit b680673 into master Jul 25, 2026
@PurHur
PurHur deleted the agent/issue-23065-reflection-type-tostring branch July 25, 2026 17:53
PurHur added a commit that referenced this pull request Jul 25, 2026
) (#23096)

Pillar 1: 4f-m drifted again (95e2817e… vs live 92251643…) after Reflection
private(set)/DNF merges; inventory construct flags also went stale. Stamp with
BOOTSTRAP_GEN0_ALLOW_UNVERIFIED_STAMP=1; regenerate docs/bootstrap-inventory.md.
Honest verified-fresh rebuild remains #22717.

Co-authored-by: PurHur <PurHur@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Regression: Reflection DNF/(int\|null) type strings diverge from Zend (ext/reflection/php_reflection.c)

1 participant