4040 * @internal
4141 */
4242#[CoversClass(EntityToIdentifierTransformer::class)]
43- class EntityToIdentifierTransformerTest extends TestCase
43+ final class EntityToIdentifierTransformerTest extends TestCase
4444{
4545 private City $ entity ;
4646 /** @var class-string<City|AbstractPerson|Employee> */
@@ -52,8 +52,6 @@ class EntityToIdentifierTransformerTest extends TestCase
5252 private ObjectManager $ entityManager ;
5353 /** @var ObjectRepository<City>&MockObject */
5454 private ObjectRepository $ repository ;
55- /** @var ClassMetadata&MockObject */
56- private ClassMetadata $ metadata ;
5755
5856 protected function setUp (): void
5957 {
@@ -66,13 +64,13 @@ protected function setUp(): void
6664
6765 $ this ->entityManager = $ this ->createMock (ObjectManager::class);
6866 $ this ->repository = $ this ->createMock (ObjectRepository::class);
69- $ this -> metadata = $ this ->createMock (ClassMetadata::class);
67+ $ metadata = $ this ->createMock (ClassMetadata::class);
7068
7169 $ this ->entityManager ->method ('getRepository ' )->willReturn ($ this ->repository );
72- $ this ->entityManager ->method ('getClassMetadata ' )->willReturn ($ this -> metadata );
70+ $ this ->entityManager ->method ('getClassMetadata ' )->willReturn ($ metadata );
7371
74- $ this -> metadata ->method ('getName ' )->willReturnCallback ($ this ->getClassName (...));
75- $ this -> metadata ->method ('getIdentifierValues ' )->willReturnCallback ($ this ->getIdentifier (...));
72+ $ metadata ->method ('getName ' )->willReturnCallback ($ this ->getClassName (...));
73+ $ metadata ->method ('getIdentifierValues ' )->willReturnCallback ($ this ->getIdentifier (...));
7674 }
7775
7876 public function getClassName (): string
@@ -100,7 +98,7 @@ public function testTransform(): void
10098 public function testTransformAlias (): void
10199 {
102100 /** @var class-string<City> $className */
103- $ className = 'AppBundle:City ' ;
101+ $ className = 'AppBundle:City ' ; // @phpstan-ignore varTag.nativeType
104102
105103 $ transformer = new EntityToIdentifierTransformer ($ this ->entityManager , $ className );
106104
@@ -222,31 +220,27 @@ public function testReverseTransformEntityNotFound(): void
222220 }
223221
224222 /**
225- * @return array <string, array{mixed}>
223+ * @return \Iterator <string, array{mixed}>
226224 */
227- public static function providerNoObject (): array
225+ public static function providerNoObject (): \ Iterator
228226 {
229- return [
230- 'bool ' => [true ],
231- 'int ' => [1 ],
232- 'float ' => [1.2 ],
233- 'string ' => ['foo ' ],
234- 'array ' => [['foo ' , 'bar ' ]],
235- 'resource ' => [tmpfile ()],
236- 'callable ' => [function () {}],
237- ];
227+ yield 'bool ' => [true ];
228+ yield 'int ' => [1 ];
229+ yield 'float ' => [1.2 ];
230+ yield 'string ' => ['foo ' ];
231+ yield 'array ' => [['foo ' , 'bar ' ]];
232+ yield 'resource ' => [tmpfile ()];
233+ yield 'callable ' => [function (): void {}];
238234 }
239235
240236 /**
241- * @return array <string, array{mixed}>
237+ * @return \Iterator <string, array{mixed}>
242238 */
243- public static function providerNoScalar (): array
244- {
245- return [
246- 'array ' => [['foo ' , 'bar ' ]],
247- 'object ' => [new \stdClass ()],
248- 'resource ' => [tmpfile ()],
249- 'callable ' => [function () {}],
250- ];
239+ public static function providerNoScalar (): \Iterator
240+ {
241+ yield 'array ' => [['foo ' , 'bar ' ]];
242+ yield 'object ' => [new \stdClass ()];
243+ yield 'resource ' => [tmpfile ()];
244+ yield 'callable ' => [function (): void {}];
251245 }
252246}
0 commit comments