Skip to content

Commit dd616ab

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

File tree

5 files changed

+151
-164
lines changed

5 files changed

+151
-164
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: 4 additions & 8 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-
64-
$key = strtolower((string) $row['normalized_name']);
65-
$versions[$key] = $row;
60+
$key = strtolower($row['normalized_name']);
61+
$versions[$key] = $row['id'];
6662
}
6763

6864
return $versions;

0 commit comments

Comments
 (0)