Skip to content

Commit

Permalink
Merge pull request #10043 from nicelocal/fix_intersection_scanning
Browse files Browse the repository at this point in the history
Fix scanning of intersection types
  • Loading branch information
orklah authored Jul 29, 2023
2 parents 73ebe22 + 068bfbf commit 7e4a6f5
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions src/Psalm/Internal/Codebase/ClassLikes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2347,15 +2347,31 @@ public function addThreadData(array $thread_data): void
$existing_classes,
] = $thread_data;

$this->existing_classlikes_lc = array_merge($existing_classlikes_lc, $this->existing_classlikes_lc);
$this->existing_classes_lc = array_merge($existing_classes_lc, $this->existing_classes_lc);
$this->existing_traits_lc = array_merge($existing_traits_lc, $this->existing_traits_lc);
$this->existing_traits = array_merge($existing_traits, $this->existing_traits);
$this->existing_enums_lc = array_merge($existing_enums_lc, $this->existing_enums_lc);
$this->existing_enums = array_merge($existing_enums, $this->existing_enums);
$this->existing_interfaces_lc = array_merge($existing_interfaces_lc, $this->existing_interfaces_lc);
$this->existing_interfaces = array_merge($existing_interfaces, $this->existing_interfaces);
$this->existing_classes = array_merge($existing_classes, $this->existing_classes);
$this->existing_classlikes_lc = self::mergeThreadData($existing_classlikes_lc, $this->existing_classlikes_lc);
$this->existing_classes_lc = self::mergeThreadData($existing_classes_lc, $this->existing_classes_lc);
$this->existing_traits_lc = self::mergeThreadData($existing_traits_lc, $this->existing_traits_lc);
$this->existing_traits = self::mergeThreadData($existing_traits, $this->existing_traits);
$this->existing_enums_lc = self::mergeThreadData($existing_enums_lc, $this->existing_enums_lc);
$this->existing_enums = self::mergeThreadData($existing_enums, $this->existing_enums);
$this->existing_interfaces_lc = self::mergeThreadData($existing_interfaces_lc, $this->existing_interfaces_lc);
$this->existing_interfaces = self::mergeThreadData($existing_interfaces, $this->existing_interfaces);
$this->existing_classes = self::mergeThreadData($existing_classes, $this->existing_classes);
}

/**
* @template T as string|lowercase-string
* @param array<T, bool> $old
* @param array<T, bool> $new
* @return array<T, bool>
*/
private static function mergeThreadData(array $old, array $new): array
{
foreach ($new as $name => $value) {
if (!isset($old[$name]) || (!$old[$name] && $value)) {
$old[$name] = $value;
}
}
return $old;
}

public function getStorageFor(string $fq_class_name): ?ClassLikeStorage
Expand Down

0 comments on commit 7e4a6f5

Please sign in to comment.