Skip to content

Commit cf39c05

Browse files
committed
Address review comments
1 parent abc313c commit cf39c05

File tree

1 file changed

+21
-35
lines changed

1 file changed

+21
-35
lines changed

build/gen_stub.php

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,17 +2462,7 @@ function replaceClassSynopses(string $targetDirectory, array $classMap): array
24622462
continue;
24632463
}
24642464

2465-
$replacedXml = preg_replace(
2466-
[
2467-
"/&([A-Za-z0-9._{}%-]+?;)/",
2468-
"/<(\/)*xi:([A-Za-z]+?)/"
2469-
],
2470-
[
2471-
"REPLACED-ENTITY-$1",
2472-
"<$1XI$2",
2473-
],
2474-
$xml
2475-
);
2465+
$replacedXml = getReplacedClassSynopsisXml($xml);
24762466

24772467
$doc = new DOMDocument();
24782468
$doc->formatOutput = false;
@@ -2520,37 +2510,17 @@ function replaceClassSynopses(string $targetDirectory, array $classMap): array
25202510
// Check if there is any change - short circuit if there is not any.
25212511

25222512
$xml1 = $doc->saveXML($classSynopsis);
2523-
$xml1 = preg_replace(
2524-
[
2525-
"/&([A-Za-z0-9._{}%-]+?;)/",
2526-
"/<(\/)*xi:([A-Za-z]+?)/",
2527-
],
2528-
[
2529-
"REPLACED-ENTITY-$1",
2530-
"<$1XI$2",
2531-
],
2532-
$xml1
2533-
);
2513+
$xml1 = getReplacedClassSynopsisXml($xml1);
25342514
$docComparator->loadXML($xml1);
2535-
$xml1 = $docComparator->saveXML();
2515+
$xml11 = $docComparator->saveXML();
25362516

25372517
$classSynopsis->parentNode->replaceChild($newClassSynopsis, $classSynopsis);
25382518

25392519
$xml2 = $doc->saveXML($newClassSynopsis);
2540-
$xml2 = preg_replace(
2541-
[
2542-
"/&([A-Za-z0-9._{}%-]+?;)/",
2543-
"/<(\/)*xi:([A-Za-z]+?)/",
2544-
],
2545-
[
2546-
"REPLACED-ENTITY-$1",
2547-
"<$1XI$2",
2548-
],
2549-
$xml2
2550-
);
2520+
$xml2 = getReplacedClassSynopsisXml($xml2);
25512521

25522522
$docComparator->loadXML($xml2);
2553-
$xml2 = $docComparator->saveXML();
2523+
$xml22 = $docComparator->saveXML();
25542524

25552525
if ($xml1 === $xml2) {
25562526
continue;
@@ -2581,6 +2551,22 @@ function replaceClassSynopses(string $targetDirectory, array $classMap): array
25812551
return $classSynopses;
25822552
}
25832553

2554+
function getReplacedClassSynopsisXml(string $xml): string|array|null
2555+
{
2556+
$replacedXml = preg_replace(
2557+
[
2558+
"/&([A-Za-z0-9._{}%-]+?;)/",
2559+
"/<(\/)*xi:([A-Za-z]+?)/"
2560+
],
2561+
[
2562+
"REPLACED-ENTITY-$1",
2563+
"<$1XI$2",
2564+
],
2565+
$xml
2566+
);
2567+
return $replacedXml;
2568+
}
2569+
25842570
/**
25852571
* @param FuncInfo[] $funcMap
25862572
* @param FuncInfo[] $aliasMap

0 commit comments

Comments
 (0)