Skip to content

Commit 929ea30

Browse files
committed
Refactor duplicate check for package name, fix syntax violation
1 parent 9438724 commit 929ea30

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Indexer.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,21 @@ public function index(): Promise
149149
$cacheKey = null;
150150
$index = null;
151151
foreach (array_merge($this->composerLock->packages, $this->composerLock->{'packages-dev'}) as $package) {
152+
if ($package->name !== $packageName) {
153+
continue;
154+
}
152155
// Check if package can be cached.
153156
$packageVersion = ltrim($package->version, 'v');
154157
// If package is anchored to a version
155-
if ($package->name === $packageName && strpos($packageVersion, 'dev') === false) {
158+
if (strpos($packageVersion, 'dev') === false) {
156159
$packageKey = $packageName . ':' . $packageVersion;
157160
$cacheKey = self::CACHE_VERSION . ':' . $packageKey;
158161
// Check cache
159162
$index = yield $this->cache->get($cacheKey);
160163
break;
161164

162165
// If package is checked out
163-
} elseif ($package->name === $packageName && isset($package->source->reference)) {
166+
} else if (isset($package->source->reference)) {
164167
$packageKey = $packageName . ':' . $package->source->reference;
165168
$cacheKey = self::CACHE_VERSION . ':' . $packageKey;
166169
// Check cache

0 commit comments

Comments
 (0)