Skip to content

gen_stub: support use statements in stub files#21784

Open
GromNaN wants to merge 1 commit intophp:masterfrom
GromNaN:fix-gen-stub-use-statements
Open

gen_stub: support use statements in stub files#21784
GromNaN wants to merge 1 commit intophp:masterfrom
GromNaN:fix-gen-stub-use-statements

Conversation

@GromNaN
Copy link
Copy Markdown
Member

@GromNaN GromNaN commented Apr 17, 2026

Fix a bug in build/gen_stub.php: use and use group statements in stub files caused an "Unexpected node Stmt_Use" exception. Since NameResolver already resolves names to their fully qualified form before handleStatements() runs, these nodes can be skipped.

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.
@GromNaN GromNaN force-pushed the fix-gen-stub-use-statements branch from 7296cf9 to 7a158af Compare April 17, 2026 08:54
Copy link
Copy Markdown
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems harmless. But @kocsismate should merge as he's codeowner.

Copy link
Copy Markdown
Member

@TimWolla TimWolla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept LGTM.

Comment thread build/gen_stub.php
Comment on lines +4390 to +4393
if ($stmt instanceof Stmt\Use_ || $stmt instanceof Stmt\GroupUse) {
// use statements are resolved by NameResolver before this point
continue;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would expect this to be placed right below the Namespace_ handler.

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.

3 participants