Commit 69322603869 for php.net
commit 69322603869ed0c6dbdbd80247b71c31b01e661c
Author: Máté Kocsis <kocsismate@woohoolabs.com>
Date: Fri Mar 20 23:30:01 2026 +0100
Fix replacement of class signatures when a packagesynopsis element is present
So far, the gen_stub.php --replace-classsynopses subcommand didn't take the packagesynopsis element into account, causing some bugs: the wrong element was tried to be replaced (classynopsis instead of packagesynopsis) with the wrong content (the classname without the namespace: e.g. \Exception instead of \FFI\Exception).
diff --git a/build/gen_stub.php b/build/gen_stub.php
index 75f4b12f957..396541272c3 100755
--- a/build/gen_stub.php
+++ b/build/gen_stub.php
@@ -5776,6 +5776,19 @@ function replaceClassSynopses(
continue;
}
$className = $child->textContent;
+
+ if ($classSynopsis->parentElement->nodeName === "packagesynopsis" &&
+ $classSynopsis->parentElement->firstElementChild->nodeName === "package"
+ ) {
+ $package = $classSynopsis->parentElement->firstElementChild;
+ $namespace = $package->textContent;
+
+ $className = $namespace . "\\" . $className;
+ $elementToReplace = $classSynopsis->parentElement;
+ } else {
+ $elementToReplace = $classSynopsis;
+ }
+
if (!isset($classMap[$className])) {
continue;
}
@@ -5791,7 +5804,7 @@ function replaceClassSynopses(
// Check if there is any change - short circuit if there is not any.
- if (replaceAndCompareXmls($doc, $classSynopsis, $newClassSynopsis)) {
+ if (replaceAndCompareXmls($doc, $elementToReplace, $newClassSynopsis)) {
continue;
}