Skip to content

Commit 8079ea7

Browse files
committed
rename tag attribute name to type_name due to Yaml limitation
1 parent 3107b1a commit 8079ea7

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/DependencyInjection/Compiler/RegisterDbalTypePass.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ final class RegisterDbalTypePass implements CompilerPassInterface
2929
public static function autoconfigureFromAttribute(ChildDefinition $definition, AsDatabaseType $type, ReflectionClass $reflector): void
3030
{
3131
$attributes = [
32-
'name' => $type->name ?? $reflector->name,
32+
'type_name' => $type->name ?? $reflector->name,
3333
];
3434

3535
// Determine if the version of symfony/dependency-injection is >= 7.3
@@ -58,14 +58,14 @@ public function process(ContainerBuilder $container): void
5858
throw new InvalidArgumentException(sprintf('The "%s" class must extends "%s".', $class, Type::class));
5959
}
6060

61-
$types[$tag['name'] ?? $class] = ['class' => $class];
61+
$types[$tag['type_name'] ?? $class] = ['class' => $class];
6262
}
6363
}
6464

6565
$container->setParameter('doctrine.dbal.connection_factory.types', $types);
6666
}
6767

68-
/** @return array<string, array<array{name?: string}>> */
68+
/** @return array<string, array<array{type_name?: string}>> */
6969
private function findTaggedResourceIds(ContainerBuilder $container): array
7070
{
7171
// Determine if the version of symfony/dependency-injection is >= 7.3

tests/DependencyInjection/Compiler/RegisterDbalTypePassTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function testTaggedTypeAreAdded(): void
2323
$container->setParameter('doctrine.dbal.connection_factory.types', []);
2424

2525
$container->register(BarType::class)
26-
->addTag('doctrine.dbal.type', ['name' => 'bar'])
26+
->addTag('doctrine.dbal.type', ['type_name' => 'bar'])
2727
->addTag('container.excluded');
2828

2929
$container->compile();
@@ -55,7 +55,7 @@ public function testTypeMustBeASubclassOfTheDbalBaseType(): void
5555
$container->setParameter('doctrine.dbal.connection_factory.types', []);
5656

5757
$container->register(NotASubClassOfDbalBaseType::class)
58-
->addTag('doctrine.dbal.type', ['name' => 'invalid_type'])
58+
->addTag('doctrine.dbal.type', ['type_name' => 'invalid_type'])
5959
->addTag('container.excluded');
6060

6161
$this->expectException(InvalidArgumentException::class);

tests/DependencyInjection/DoctrineExtensionTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ public static function cacheConfigurationProvider(): array
953953

954954
/** @param class-string $typeClassname */
955955
#[DataProvider('provideDatabaseTypeAttribute')]
956-
public function testAsDatabaseTypeAttribute(string $typeClassname, string $expectedName): void
956+
public function testAsDatabaseTypeAttribute(string $typeClassname, string $expectedTypeName): void
957957
{
958958
$container = $this->getContainer();
959959
$extension = new DoctrineExtension();
@@ -977,7 +977,7 @@ public function testAsDatabaseTypeAttribute(string $typeClassname, string $expec
977977

978978
$attributes[AsDatabaseType::class]($definition, $attribute, $reflector);
979979

980-
$expected = ['name' => $expectedName];
980+
$expected = ['type_name' => $expectedTypeName];
981981
$this->assertSame([$expected], $definition->getTag('doctrine.dbal.type'));
982982
$this->assertSame([['source' => 'by tag "doctrine.dbal.type"']], $definition->getTag('container.excluded'));
983983
}
@@ -986,8 +986,8 @@ public function testAsDatabaseTypeAttribute(string $typeClassname, string $expec
986986
public static function provideDatabaseTypeAttribute(): array
987987
{
988988
return [
989-
'with name' => [DbalType::class, 'dbal_type'],
990-
'without name' => [DbalTypeNoName::class, DbalTypeNoName::class],
989+
'with type name' => [DbalType::class, 'dbal_type'],
990+
'without type name' => [DbalTypeNoName::class, DbalTypeNoName::class],
991991
];
992992
}
993993

0 commit comments

Comments
 (0)