Skip to content

Commit 8a8494b

Browse files
committed
Be more deterministic
1 parent cecb23e commit 8a8494b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

extractor/extract.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9999
$stubPath = $file->getRealPath();
100100
[$tmpClasses, $tmpFunctions] = $this->extractStub($stubPath, $file->getRelativePathname(), $isUpdate, $updateFrom, $updateTo);
101101
foreach ($tmpClasses as $className => $fileName) {
102+
if (array_key_exists($className, $addClasses)) {
103+
throw new \Exception('Duplicate class ' . $className);
104+
}
102105
$addClasses[$className] = $fileName;
103106
}
104107
foreach ($tmpFunctions as $functionName => $fileName) {
108+
if (array_key_exists($functionName, $addFunctions)) {
109+
continue;
110+
}
105111
$addFunctions[$functionName] = $fileName;
106112
}
107113
}
@@ -731,6 +737,8 @@ private function findPhpDocReturn(PhpDocNode $node): ?ReturnTagValueNode
731737
*/
732738
private function dumpMap(array $classes, array $functions, ?string $updateTo, array $addClasses, array $addFunctions): void
733739
{
740+
ksort($classes);
741+
ksort($functions);
734742
$template = <<<'PHP'
735743
<?php declare(strict_types = 1);
736744
@@ -778,6 +786,9 @@ public function __construct(int $phpVersionId)
778786
// UPDATE BELONGS HERE
779787
PHP;
780788

789+
ksort($addClasses);
790+
ksort($addFunctions);
791+
781792
$parts = explode('.', $updateTo);
782793
$phpVersion = (int) $parts[0] * 10000 + (int) ($parts[1] ?? 0) * 100 + (int) ($parts[2] ?? 0);
783794
$updateString = sprintf(

0 commit comments

Comments
 (0)