Skip to content

Commit 4048afd

Browse files
committed
Implement metadata refactoring in PackageMetadataResolver
Signed-off-by: Tim Goudriaan <tim@codedmonkey.com>
1 parent fe47669 commit 4048afd

File tree

6 files changed

+155
-166
lines changed

6 files changed

+155
-166
lines changed

phpstan.dist.neon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ parameters:
1111
- tests/bootstrap.php
1212
ignoreErrors:
1313
- '#^Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition\:\:children\(\)\.$#'
14-
- '#CodedMonkey\\Dirigent\\Doctrine\\Entity\\AbstractVersionLink given\.#'
15-
- '#^PHPDoc tag @var with type CodedMonkey\\Dirigent\\Doctrine\\Entity\\AbstractVersionLink is not subtype of native type#'
14+
- '#CodedMonkey\\Dirigent\\Doctrine\\Entity\\AbstractMetadataLink given\.#'
15+
- '#^PHPDoc tag @var with type CodedMonkey\\Dirigent\\Doctrine\\Entity\\AbstractMetadataLink is not subtype of native type#'
1616
- '#^Property CodedMonkey\\Dirigent\\Doctrine\\Entity\\[a-zA-Z]+\:\:\$id \(int\|null\) is never assigned int so it can be removed from the property type\.$#'
1717
-
1818
message: '#^Class CodedMonkey\\Dirigent\\Doctrine\\Entity\\TrackedEntity has an uninitialized readonly property \$createdAt\. Assign it in the constructor\.$#'

src/Doctrine/Repository/VersionRepository.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,19 @@ public function findOneByNormalizedVersionName(Package $package, string $name):
4646
}
4747

4848
/**
49-
* @return array<string, array{id: int, name: string, normalized_name: string, source: ?array}>
49+
* @return array<string, int>
5050
*/
5151
public function getVersionMetadataForUpdate(Package $package): array
5252
{
5353
$rows = $this->getEntityManager()->getConnection()->fetchAllAssociative(
54-
'SELECT id, name, normalized_name, source FROM version v WHERE v.package_id = :id',
54+
'SELECT id, normalized_name FROM version v WHERE v.package_id = :id',
5555
['id' => $package->getId()],
5656
);
5757

5858
$versions = [];
5959
foreach ($rows as $row) {
60-
if ($row['source']) {
61-
$row['source'] = json_decode((string) $row['source'], true);
62-
}
63-
6460
$key = strtolower((string) $row['normalized_name']);
65-
$versions[$key] = $row;
61+
$versions[$key] = $row['id'];
6662
}
6763

6864
return $versions;

src/Package/PackageDistributionResolver.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ public function resolve(Version $version, string $reference, string $type): bool
4141
return true;
4242
}
4343

44-
if ($reference !== $version->getDistReference() || $type !== $version->getDistType()) {
44+
$metadata = $version->getCurrentMetadata();
45+
46+
if ($reference !== $metadata->getDistReference() || $type !== $metadata->getDistType()) {
4547
return false;
4648
}
4749

48-
$distUrl = $version->getDistUrl();
50+
$distUrl = $metadata->getDistUrl();
4951
$path = $this->path($packageName, $versionName, $reference, $type);
5052

5153
$this->filesystem->mkdir(dirname($path));

0 commit comments

Comments
 (0)