Skip to content

Commit

Permalink
Catch missing classlike exceptions during scanning
Browse files Browse the repository at this point in the history
This may resolve vimeo#10706, although I'm not exactly convinced it's the
best way.
  • Loading branch information
weirdan committed Feb 19, 2024
1 parent 5f2e9d1 commit 6ead530
Showing 1 changed file with 30 additions and 26 deletions.
56 changes: 30 additions & 26 deletions src/Psalm/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -888,33 +888,37 @@ private static function intersectAtomicTypes(
}

if (null === $intersection_atomic) {
if (AtomicTypeComparator::isContainedBy(
$codebase,
$type_2_atomic,
$type_1_atomic,
$allow_interface_equality,
$allow_float_int_equality,
)) {
$intersection_atomic = $type_2_atomic;
$wider_type = $type_1_atomic;
$intersection_performed = true;
} elseif (AtomicTypeComparator::isContainedBy(
$codebase,
$type_1_atomic,
$type_2_atomic,
$allow_interface_equality,
$allow_float_int_equality,
)) {
$intersection_atomic = $type_1_atomic;
$wider_type = $type_2_atomic;
$intersection_performed = true;
}
try {
if (AtomicTypeComparator::isContainedBy(
$codebase,
$type_2_atomic,
$type_1_atomic,
$allow_interface_equality,
$allow_float_int_equality,
)) {
$intersection_atomic = $type_2_atomic;
$wider_type = $type_1_atomic;
$intersection_performed = true;
} elseif (AtomicTypeComparator::isContainedBy(
$codebase,
$type_1_atomic,
$type_2_atomic,
$allow_interface_equality,
$allow_float_int_equality,
)) {
$intersection_atomic = $type_1_atomic;
$wider_type = $type_2_atomic;
$intersection_performed = true;
}

if ($intersection_atomic
&& !self::hasIntersection($type_1_atomic)
&& !self::hasIntersection($type_2_atomic)
) {
return $intersection_atomic;
if ($intersection_atomic
&& !self::hasIntersection($type_1_atomic)
&& !self::hasIntersection($type_2_atomic)
) {
return $intersection_atomic;
}
} catch (InvalidArgumentException $e) {
// Ignore non-existing classes during initial scan
}
}

Expand Down

0 comments on commit 6ead530

Please sign in to comment.