Skip to content

gen_stub: fix namespaced types in union/intersection type list#21717

Open
GromNaN wants to merge 1 commit intophp:masterfrom
GromNaN:fix-gen-stub-union-intersection-types
Open

gen_stub: fix namespaced types in union/intersection type list#21717
GromNaN wants to merge 1 commit intophp:masterfrom
GromNaN:fix-gen-stub-union-intersection-types

Conversation

@GromNaN
Copy link
Copy Markdown
Member

@GromNaN GromNaN commented Apr 10, 2026

Fix a bug in build/gen_stub.php: when generating a type list for union/intersection types, the zend_string* variable was declared with toVarEscapedName() but referenced with toEscapedName(), producing an invalid C identifier for namespaced class names.

@GromNaN
Copy link
Copy Markdown
Member Author

GromNaN commented Apr 16, 2026

Should I add update ext/zend_test/test.stub.php to test this fix?

@TimWolla
Copy link
Copy Markdown
Member

Should I add update ext/zend_test/test.stub.php to test this fix?

Yes, please do. Perhaps adjusting one of the existing functions is sufficient.

@TimWolla
Copy link
Copy Markdown
Member

Also, two unrelated changes should go into two PRs. Particularly if one is a good and one is a feature.

@GromNaN GromNaN force-pushed the fix-gen-stub-union-intersection-types branch from b7300b4 to b8b7060 Compare April 17, 2026 07:59
@GromNaN GromNaN changed the title gen_stub: fix union/intersection types with namespaced classes and support use statements gen_stub: fix invalid C variable name for namespaced types in union/intersection type list Apr 17, 2026
@GromNaN GromNaN force-pushed the fix-gen-stub-union-intersection-types branch from b8b7060 to 9ca590d Compare April 17, 2026 08:19
@GromNaN GromNaN changed the title gen_stub: fix invalid C variable name for namespaced types in union/intersection type list gen_stub: fix namespaced types in union/intersection type list Apr 17, 2026
@GromNaN
Copy link
Copy Markdown
Member Author

GromNaN commented Apr 17, 2026

Thanks for the feedback. I extracted the use statement fix into #21784 and added tests.

…ntersection type list

When generating a union or intersection type list with multiple class
types, the variable holding each zend_string* was declared using
toVarEscapedName() (backslashes replaced by underscores), but the
subsequent ZEND_TYPE_INIT_CLASS() reference used toEscapedName()
(backslashes escaped as \\), producing an invalid C identifier.
@GromNaN GromNaN force-pushed the fix-gen-stub-union-intersection-types branch from 9ca590d to d51401d Compare April 17, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants