Skip to content

gen_stub: fix union/intersection types with namespaced classes and support use statements#21717

Open
GromNaN wants to merge 2 commits intophp:masterfrom
GromNaN:fix-gen-stub-union-intersection-types
Open

gen_stub: fix union/intersection types with namespaced classes and support use statements#21717
GromNaN wants to merge 2 commits intophp:masterfrom
GromNaN:fix-gen-stub-union-intersection-types

Conversation

@GromNaN
Copy link
Copy Markdown
Member

@GromNaN GromNaN commented Apr 10, 2026

Two fixes for build/gen_stub.php:

Fix 1: When generating a type list for union/intersection types with multiple class names, the zend_string* variable was declared with toVarEscapedName() (backslashes to underscores) but referenced with toEscapedName() (backslashes to \\), producing an invalid C identifier.

Fix 2: use and use group statements in stub files caused an "Unexpected node Stmt_Use" exception. Since NameResolver already resolves names to fully qualified form before parsing, these nodes can simply be skipped.

GromNaN added 2 commits April 10, 2026 23:06
…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.
Stmt\Use_ and Stmt\GroupUse nodes were not handled in handleStatements(),
causing an "Unexpected node" exception when use statements appeared in
stub files. Since NameResolver resolves all names to their fully qualified
form before handleStatements() runs, these nodes can simply be skipped.
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.

1 participant