Skip to content

Commit 64401fd

Browse files
committed
Small logic improvement
1 parent b6d86c6 commit 64401fd

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

src/Psalm/Internal/Provider/ClassLikeStorageProvider.php

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,24 @@ public function addMore(array $more): void
104104
foreach ($more as $k => $storage) {
105105
if (isset(self::$storage[$k])) {
106106
$duplicate_storage = self::$storage[$k];
107-
IssueBuffer::maybeAdd(
108-
new DuplicateClass(
109-
'Class ' . $k . ' has already been defined'
110-
. ($duplicate_storage->location
111-
? ' in ' . $duplicate_storage->location->file_path
112-
: ''),
113-
$duplicate_storage->location,
114-
),
115-
);
116-
117-
//$storage->file_storage->has_visitor_issues = true;
118-
119-
$duplicate_storage->has_visitor_issues = true;
107+
$duplicate_location = $duplicate_storage->location ?? $duplicate_storage->stmt_location;
108+
$location = $storage->location ?? $storage->stmt_location;
109+
if ($duplicate_location !== null
110+
&& $location !== null
111+
&& $duplicate_location->getHash() !== $location->getHash()
112+
) {
113+
IssueBuffer::maybeAdd(
114+
new DuplicateClass(
115+
'Class ' . $k . ' has already been defined'
116+
. ' in ' . $location->file_path,
117+
$location,
118+
),
119+
);
120+
121+
//$storage->file_storage->has_visitor_issues = true;
122+
123+
$duplicate_storage->has_visitor_issues = true;
124+
}
120125
continue;
121126
}
122127
self::$new_storage[$k] = $storage;

0 commit comments

Comments
 (0)