8000 tweaks thanks to Fab · symfony/symfony@d95d406 · GitHub
[go: up one dir, main page]

Skip to content

Commit d95d406

Browse files
committed
tweaks thanks to Fab
1 parent a283b00 commit d95d406

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

src/Symfony/Component/AssetMapper/ImportMap/ImportMapVersionChecker.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,19 @@ public function checkVersions(): array
8080
foreach ($dependencies as $dependencyName) {
8181
$dependencyVersionConstraint = $packageDependencies[$dependencyName] ?? null;
8282

83-
if (null === $dependencyVersionConstraint) {
84-
// odd that this would happen
85-
continue;
86-
}
87-
8883
$dependencyPackageName = $this->extractPackageNameFromImport($dependencyName);
8984
if (!$entries->has($dependencyPackageName)) {
9085
$problems[] = new PackageVersionProblem($packageName, $dependencyName, $dependencyVersionConstraint, null);
9186

9287
continue;
9388
}
9489

90+
if (null === $dependencyVersionConstraint) {
91+
// local file imports this, but the package doesn't have it as a dependency
92+
// odd, but not technically a problem
93+
continue;
94+
}
95+
9596
if (!$this->isVersionSatisfied($dependencyVersionConstraint, $entries->get($dependencyName)->version)) {
9697
$problems[] = new PackageVersionProblem($packageName, $dependencyName, $dependencyVersionConstraint, $entries->get($dependencyName)->version);
9798
}
@@ -112,11 +113,7 @@ public function checkVersions(): array
112113

113114
private function isVersionSatisfied(string $versionConstraint, ?string $version): bool
114115
{
115-
if (null === $version) {
116-
return false;
117-
}
118-
119-
return Semver::satisfies($version, $versionConstraint);
116+
return $version ? Semver::satisfies($version, $versionConstraint) : false;
120117
}
121118

122119
private function extractPackageNameFromImport(string $importName): string

src/Symfony/Component/AssetMapper/ImportMap/PackageVersionProblem.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
final class PackageVersionProblem
1515
{
1616
public function __construct(
17-
public string $packageName,
18-
public string $dependencyPackageName,
19-
public string $requiredVersionConstraint,
20-
public ?string $installedVersion
17+
public readonly string $packageName,
18+
public readonly string $dependencyPackageName,
19+
public readonly string $requiredVersionConstraint,
20+
public readonly ?string $installedVersion
2121
) {
2222
}
2323
}

0 commit comments

Comments
 (0)
0