From 69322603869ed0c6dbdbd80247b71c31b01e661c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Fri, 20 Mar 2026 23:30:01 +0100 Subject: [PATCH] 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). --- build/gen_stub.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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; }