Skip to content

Commit 1a545f3

Browse files
committed
Fix problems
1 parent 2fbb71b commit 1a545f3

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

src/Utilities/TypeResolver.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,13 @@ public static function compare(string $a, string $b): bool
201201

202202
$a = static::getExtendedClasses($a);
203203
$b = static::getExtendedClasses($b);
204-
205-
if (count($a) !== count($b)) {
206-
return false;
207-
}
208-
204+
209205
$resultClassesComparison = [];
210206
$resultInterfacesComparison = [];
211207
for ($i = 0, $size = count($a); $i < $size; $i++) {
212208
[$aClasses, $aInterfaces] = $a[$i];
213209
[$bClasses, $bInterfaces] = $b[$i];
210+
214211
$resultClassesComparison[] = count(array_intersect($aClasses, $bClasses)) > 0;
215212
$resultInterfacesComparison[] = count(array_intersect($aInterfaces, $bInterfaces)) > 0;
216213
}
@@ -241,33 +238,32 @@ public static function getExtendedClasses($class): array
241238
}
242239
$classPath = Runtime::PHP_IMITATION_DIRECTORY . '\\' . implode('\\', $path);
243240

244-
if (isset($loadedExtendedRoots[$classPath])) {
245-
$extendedClasses = $loadedExtendedRoots[$classPath];
246-
continue;
247-
}
248-
249241
// Remove duplicated prefix
250242
$classPath = preg_replace(
251243
'/^(?:' . preg_quote(Runtime::PHP_IMITATION_DIRECTORY, '/') . ')+/',
252244
Runtime::PHP_IMITATION_DIRECTORY,
253245
$classPath
254246
);
255247

248+
if (isset($loadedExtendedRoots[$classPath])) {
249+
$result[] = $loadedExtendedRoots[$classPath];
250+
continue;
251+
}
252+
256253
$extendedClasses = array_values(class_parents($classPath, true));
257254
$interfaces = array_values(class_implements($classPath, true));
258-
$loadedExtendedRoots = $extendedClasses;
259255

260256
if (class_exists($classPath)) {
261257
$reflectionClass = new \ReflectionClass($classPath);
262258
preg_match_all('/\@parent\s+([^\r\n]+)/i', $reflectionClass->getDocComment(), $parents);
263259
$roots = array_merge($parents[1], [$classPath]);
264-
if (count($roots) > $extendedClasses) {
260+
if (count($roots) > count($extendedClasses)) {
265261
$extendedClasses = $roots;
266262
}
267263

268264
preg_match_all('/\@interface\s+([^\r\n]+)/i', $reflectionClass->getDocComment(), $interfaceRoots);
269265
$roots = $interfaceRoots[1];
270-
if (count($roots) > $interfaces) {
266+
if (count($roots) > count($interfaces)) {
271267
$interfaces = $roots;
272268
}
273269
}

0 commit comments

Comments
 (0)