Commit fa5ab4fcc1c for php.net

commit fa5ab4fcc1c304d45ca188ee7938af85f6e97387
Author: Jérôme Tamarelle <jerome@tamarelle.net>
Date:   Fri Apr 17 23:45:34 2026 +0200

    gen_stub: support use statements in stub files (#21784)

    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.

diff --git a/build/gen_stub.php b/build/gen_stub.php
index c189abd0347..eca1ab3e8c1 100755
--- a/build/gen_stub.php
+++ b/build/gen_stub.php
@@ -4261,6 +4261,11 @@ private function handleStatements(array $stmts, PrettyPrinterAbstract $prettyPri
                 continue;
             }

+            if ($stmt instanceof Stmt\Use_ || $stmt instanceof Stmt\GroupUse) {
+                // use statements are resolved by NameResolver before this point
+                continue;
+            }
+
             if ($stmt instanceof Stmt\Const_) {
                 foreach ($stmt->consts as $const) {
                     $this->constInfos[] = parseConstLike(
diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php
index f4844eb0681..c9d367d5553 100644
--- a/ext/zend_test/test.stub.php
+++ b/ext/zend_test/test.stub.php
@@ -380,6 +380,10 @@ public function method(): ?NotUnlikelyCompileError {}

 namespace ZendTestNS2 {

+    use ZendTestNS\Foo as FooAlias;
+    use ZendTestNS\UnlikelyCompileError;
+    use ZendTestNS\{NotUnlikelyCompileError};
+
     /** @var string */
     const ZEND_CONSTANT_A = "namespaced";

@@ -387,6 +391,9 @@ class Foo {
         public ZendSubNS\Foo $foo;
         public ZendSubNS\Foo&\ZendTestNS\Bar $intersectionProp;
         public ZendSubNS\Foo|\ZendTestNS\Bar $unionProp;
+        public FooAlias $fooAlias;
+        public UnlikelyCompileError $unlProp;
+        public NotUnlikelyCompileError $notUnlProp;

         public function method(): void {}
     }
diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h
index d2bdbd72db4..a4da05df2ff 100644
Binary files a/ext/zend_test/test_arginfo.h and b/ext/zend_test/test_arginfo.h differ
diff --git a/ext/zend_test/test_decl.h b/ext/zend_test/test_decl.h
index 816e03919a1..bc2ebaa93c3 100644
Binary files a/ext/zend_test/test_decl.h and b/ext/zend_test/test_decl.h differ
diff --git a/ext/zend_test/test_legacy_arginfo.h b/ext/zend_test/test_legacy_arginfo.h
index b4a07503ad0..b446a0f9a29 100644
Binary files a/ext/zend_test/test_legacy_arginfo.h and b/ext/zend_test/test_legacy_arginfo.h differ
diff --git a/ext/zend_test/tests/gen_stub_test_01.phpt b/ext/zend_test/tests/gen_stub_test_01.phpt
index 3126eb61631..0cda0651bee 100644
--- a/ext/zend_test/tests/gen_stub_test_01.phpt
+++ b/ext/zend_test/tests/gen_stub_test_01.phpt
@@ -22,6 +22,12 @@
   uninitialized(ZendTestNS2\ZendSubNS\Foo&ZendTestNS\Bar)
   ["unionProp"]=>
   uninitialized(ZendTestNS2\ZendSubNS\Foo|ZendTestNS\Bar)
+  ["fooAlias"]=>
+  uninitialized(ZendTestNS\Foo)
+  ["unlProp"]=>
+  uninitialized(ZendTestNS\UnlikelyCompileError)
+  ["notUnlProp"]=>
+  uninitialized(ZendTestNS\NotUnlikelyCompileError)
 }
 object(ZendTestNS2\Foo)#%d (%d) {
   ["foo"]=>
@@ -31,6 +37,12 @@
   uninitialized(ZendTestNS2\ZendSubNS\Foo&ZendTestNS\Bar)
   ["unionProp"]=>
   uninitialized(ZendTestNS2\ZendSubNS\Foo|ZendTestNS\Bar)
+  ["fooAlias"]=>
+  uninitialized(ZendTestNS\Foo)
+  ["unlProp"]=>
+  uninitialized(ZendTestNS\UnlikelyCompileError)
+  ["notUnlProp"]=>
+  uninitialized(ZendTestNS\NotUnlikelyCompileError)
 }
 object(ZendTestNS\UnlikelyCompileError)#%d (%d) {
 }