Skip to content

Commit f65b353

Browse files
authored
Merge pull request #542 from greg0ire/2.0.x
Merge 1.8.x up into 2.0.x
2 parents 492e9cb + 71f4570 commit f65b353

File tree

8 files changed

+33
-21
lines changed

8 files changed

+33
-21
lines changed

.github/workflows/coding-standards.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ on:
1111
jobs:
1212
coding-standards:
1313
name: "Coding Standards"
14-
uses: "doctrine/.github/.github/workflows/coding-standards.yml@7.2.2"
14+
uses: "doctrine/.github/.github/workflows/coding-standards.yml@7.3.0"

.github/workflows/documentation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ on:
1717
jobs:
1818
documentation:
1919
name: "Documentation"
20-
uses: "doctrine/.github/.github/workflows/documentation.yml@7.2.2"
20+
uses: "doctrine/.github/.github/workflows/documentation.yml@7.3.0"

.github/workflows/release-on-milestone-closed.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
release:
1010
name: "Git tag, release & create merge-up PR"
11-
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@7.2.2"
11+
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@7.3.0"
1212
secrets:
1313
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
1414
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}

.github/workflows/static-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ on:
1111
jobs:
1212
static-analysis:
1313
name: "Static Analysis"
14-
uses: "doctrine/.github/.github/workflows/phpstan.yml@7.2.2"
14+
uses: "doctrine/.github/.github/workflows/phpstan.yml@7.3.0"

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
},
2626
"require-dev": {
2727
"ext-sqlite3": "*",
28-
"doctrine/coding-standard": "^12",
28+
"doctrine/coding-standard": "^13",
2929
"doctrine/dbal": "^3.5 || ^4",
3030
"doctrine/mongodb-odm": "^1.3.0 || ^2.0.0",
3131
"doctrine/orm": "^2.14 || ^3",
3232
"fig/log-test": "^1",
33-
"phpstan/phpstan": "2.1.8",
33+
"phpstan/phpstan": "2.1.17",
3434
"phpunit/phpunit": "10.5.45",
3535
"symfony/cache": "^6.4 || ^7",
3636
"symfony/var-exporter": "^6.4 || ^7"

phpstan-baseline.neon

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -234,18 +234,6 @@ parameters:
234234
count: 1
235235
path: src/ReferenceRepository.php
236236

237-
-
238-
message: '#^Property Doctrine\\Common\\DataFixtures\\ReferenceRepository\:\:\$identitiesByClass \(array\<class\-string, array\<string, mixed\>\>\) does not accept array\<string, array\<string, mixed\>\>\.$#'
239-
identifier: assign.propertyType
240-
count: 1
241-
path: src/ReferenceRepository.php
242-
243-
-
244-
message: '#^Property Doctrine\\Common\\DataFixtures\\ReferenceRepository\:\:\$referencesByClass \(array\<class\-string, array\<string, object\>\>\) does not accept array\<string, array\<string, object\>\>\.$#'
245-
identifier: assign.propertyType
246-
count: 1
247-
path: src/ReferenceRepository.php
248-
249237
-
250238
message: '#^Unable to resolve the template type T in call to method Doctrine\\Persistence\\ObjectManager\:\:getClassMetadata\(\)$#'
251239
identifier: argument.templateType

src/ReferenceRepository.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
use function array_key_exists;
1414
use function array_keys;
15+
use function array_map;
1516
use function sprintf;
1617

1718
/**
@@ -25,7 +26,7 @@ class ReferenceRepository
2526
* List of named references to the fixture objects
2627
* gathered during fixure loading
2728
*
28-
* @phpstan-var array<class-string, array<string, object>>
29+
* @phpstan-var array<class-string, array<string|int, object>>
2930
*/
3031
private array $referencesByClass = [];
3132

@@ -192,7 +193,7 @@ public function getReferenceNames(object $reference): array
192193
return [];
193194
}
194195

195-
return array_keys($this->referencesByClass[$class], $reference, true);
196+
return array_map('strval', array_keys($this->referencesByClass[$class], $reference, true));
196197
}
197198

198199
/**
@@ -218,7 +219,7 @@ public function getIdentitiesByClass(): array
218219
/**
219220
* Get all stored references
220221
*
221-
* @phpstan-return array<class-string, array<string, object>>
222+
* @phpstan-return array<class-string, array<string|int, object>>
222223
*/
223224
public function getReferencesByClass(): array
224225
{
@@ -237,6 +238,8 @@ public function getManager(): ObjectManager
237238
* Get real class name of a reference that could be a proxy
238239
*
239240
* @param string $className Class name of reference object
241+
*
242+
* @return class-string
240243
*/
241244
protected function getRealClass(string $className): string
242245
{

tests/Common/DataFixtures/ReferenceRepositoryTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,4 +242,25 @@ public function testGetIdentifierWhenHasNotBeenManagedYetByUnitOfWork(): void
242242

243243
$this->assertEquals($identitiesExpected, $identities['entity']);
244244
}
245+
246+
public function testGivenAReferenceWithNameWithIntegerValueWhenGetReferenceNamesOfEntitiesThenReturnNamesInStringType(): void
247+
{
248+
$em = $this->getMockSqliteEntityManager();
249+
$referenceRepository = new ReferenceRepository($em);
250+
251+
$schemaTool = new SchemaTool($em);
252+
$schemaTool->dropSchema([]);
253+
$schemaTool->createSchema([$em->getClassMetadata(Role::class)]);
254+
255+
$role = new Role();
256+
$role->setName('role_name');
257+
$em->persist($role);
258+
$em->flush();
259+
260+
$name = (string) $role->getId();
261+
$referenceRepository->setReference($name, $role);
262+
$names = $referenceRepository->getReferenceNames($role);
263+
$this->assertCount(1, $names);
264+
$this->assertSame('1', $names[0]);
265+
}
245266
}

0 commit comments

Comments
 (0)