mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
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).
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user