Skip to content

Commit f604e32

Browse files
authored
Merge pull request #1838 from doctrine/2.13.x-merge-up-into-2.14.x_m2wHm6n8
2 parents 50064cb + 2740ad8 commit f604e32

20 files changed

+75
-102
lines changed

.github/workflows/coding-standards.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ on:
1212
jobs:
1313
coding-standards:
1414
name: "Coding Standards"
15-
uses: "doctrine/.github/.github/workflows/coding-standards.yml@5.1.0"
15+
uses: "doctrine/.github/.github/workflows/coding-standards.yml@5.2.0"
1616
with:
1717
composer-options: "--prefer-dist --prefer-stable"

.github/workflows/composer-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ on:
1515
jobs:
1616
composer-lint:
1717
name: "Composer Lint"
18-
uses: "doctrine/.github/.github/workflows/composer-lint.yml@5.1.0"
18+
uses: "doctrine/.github/.github/workflows/composer-lint.yml@5.2.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@5.1.0"
20+
uses: "doctrine/.github/.github/workflows/documentation.yml@5.2.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@5.1.0"
11+
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@5.2.0"
1212
secrets:
1313
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
1414
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"symfony/console": "^5.4 || ^6.0 || ^7.0",
4040
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
4141
"symfony/deprecation-contracts": "^2.1 || ^3",
42-
"symfony/doctrine-bridge": "^5.4.19 || ^6.0.7 || ^7.0",
42+
"symfony/doctrine-bridge": "^5.4.46 || ^6.4.3 || ^7.0.3",
4343
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0",
4444
"symfony/polyfill-php80": "^1.15",
4545
"symfony/service-contracts": "^1.1.1 || ^2.0 || ^3"

docs/en/custom-id-generators.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ are provided: ``doctrine.ulid_generator`` to generate ULIDs, and
2323
2424
use Doctrine\ORM\Mapping as ORM;
2525
26-
/**
27-
* @ORM\Entity
28-
*/
26+
#[ORM\Entity]
2927
class User
3028
{
3129
#[ORM\Id]
@@ -38,5 +36,5 @@ are provided: ``doctrine.ulid_generator`` to generate ULIDs, and
3836
}
3937
4038
See also
41-
https://www.doctrine-project.org/projects/doctrine-orm/en/2.8/reference/annotations-reference.html#annref_customidgenerator
39+
https://www.doctrine-project.org/projects/doctrine-orm/en/3.3/reference/attributes-reference.html#attrref_customidgenerator
4240
for more info about custom ID generators.

psalm.xml.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
<referencedClass name="Doctrine\ORM\Mapping\Driver\YamlDriver"/>
4141
<referencedClass name="Doctrine\ORM\Mapping\Driver\SimplifiedYamlDriver"/>
4242
<referencedClass name="Doctrine\ORM\Mapping\Driver\AnnotationDriver"/>
43+
<referencedClass name="Doctrine\ORM\Mapping\Driver\PHPDriver"/>
44+
<referencedClass name="Doctrine\ORM\Mapping\Driver\StaticPHPDriver"/>
4345
<referencedClass name="Doctrine\ORM\ORMException"/>
4446
<!-- Dropped in DBAL 4 -->
4547
<referencedClass name="Doctrine\DBAL\Exception"/>

src/DependencyInjection/DoctrineExtension.php

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,21 @@
2222
use Doctrine\ORM\EntityManagerInterface;
2323
use Doctrine\ORM\Events;
2424
use Doctrine\ORM\Id\AbstractIdGenerator;
25+
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
26+
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
27+
use Doctrine\ORM\Mapping\Driver\PHPDriver as LegacyPHPDriver;
2528
use Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver;
29+
use Doctrine\ORM\Mapping\Driver\SimplifiedYamlDriver;
30+
use Doctrine\ORM\Mapping\Driver\StaticPHPDriver as LegacyStaticPHPDriver;
2631
use Doctrine\ORM\Proxy\Autoloader;
2732
use Doctrine\ORM\Proxy\ProxyFactory;
2833
use Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand;
2934
use Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand;
3035
use Doctrine\ORM\Tools\Export\ClassMetadataExporter;
3136
use Doctrine\ORM\UnitOfWork;
37+
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
38+
use Doctrine\Persistence\Mapping\Driver\PHPDriver;
39+
use Doctrine\Persistence\Mapping\Driver\StaticPHPDriver;
3240
use Doctrine\Persistence\Reflection\RuntimeReflectionProperty;
3341
use InvalidArgumentException;
3442
use LogicException;
@@ -1167,7 +1175,35 @@ public function getConfiguration(array $config, ContainerBuilder $container): Co
11671175

11681176
protected function getMetadataDriverClass(string $driverType): string
11691177
{
1170-
return '%' . $this->getObjectManagerElementName('metadata.' . $driverType . '.class') . '%';
1178+
switch ($driverType) {
1179+
case 'driver_chain':
1180+
return MappingDriverChain::class;
1181+
1182+
case 'annotation':
1183+
if (! class_exists(AnnotationDriver::class)) {
1184+
throw new LogicException('The annotation driver is only available in doctrine/orm v2.');
1185+
}
1186+
1187+
return AnnotationDriver::class;
1188+
1189+
case 'xml':
1190+
return SimplifiedXmlDriver::class;
1191+
1192+
case 'yml':
1193+
return SimplifiedYamlDriver::class;
1194+
1195+
case 'php':
1196+
return class_exists(PHPDriver::class) ? PHPDriver::class : LegacyPHPDriver::class;
1197+
1198+
case 'staticphp':
1199+
return class_exists(StaticPHPDriver::class) ? StaticPHPDriver::class : LegacyStaticPHPDriver::class;
1200+
1201+
case 'attribute':
1202+
return AttributeDriver::class;
1203+
1204+
default:
1205+
throw new LogicException(sprintf('Unknown "%s" metadata driver type.', $driverType));
1206+
}
11711207
}
11721208

11731209
private function loadMessengerServices(ContainerBuilder $container): void

tests/CacheSchemaSubscriberTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public function testSchemaSubscriberWiring(string $adapterId, string $subscriber
4949
'kernel.container_class' => ContainerBuilder::class,
5050
'kernel.secret' => 'test',
5151
'env(base64:default::SYMFONY_DECRYPTION_SECRET)' => 'foo',
52+
'env(bool:default::SYMFONY_TRUST_X_SENDFILE_TYPE_HEADER)' => '',
53+
'env(default::SYMFONY_TRUSTED_HOSTS)' => '',
54+
'env(default::SYMFONY_TRUSTED_PROXIES)' => '',
55+
'env(default::SYMFONY_TRUSTED_HEADERS)' => '',
5256
'debug.file_link_format' => null,
5357
]));
5458

tests/DependencyInjection/AbstractDoctrineExtensionTest.php

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,11 @@
4040
use Symfony\Component\DependencyInjection\Reference;
4141
use Symfony\Component\DependencyInjection\ServiceLocator;
4242
use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
43-
use Symfony\Component\HttpKernel\Kernel;
4443
use Symfony\Component\Security\Core\User\UserInterface;
4544

4645
use function array_filter;
4746
use function array_intersect_key;
4847
use function array_keys;
49-
use function array_merge;
5048
use function array_values;
5149
use function assert;
5250
use function class_exists;
@@ -57,7 +55,6 @@
5755
use function sprintf;
5856
use function sys_get_temp_dir;
5957
use function uniqid;
60-
use function version_compare;
6158

6259
use const DIRECTORY_SEPARATOR;
6360

@@ -543,40 +540,30 @@ public function testSingleEntityManagerMultipleMappingBundleDefinitions(): void
543540
self::markTestSkipped('This test requires ORM');
544541
}
545542

546-
$container = $this->loadContainer('orm_single_em_bundle_mappings', ['YamlBundle', 'AnnotationsBundle', 'XmlBundle', 'AttributesBundle']);
543+
$container = $this->loadContainer('orm_single_em_bundle_mappings', ['YamlBundle', 'XmlBundle', 'AttributesBundle']);
547544

548545
$definition = $container->getDefinition('doctrine.orm.default_metadata_driver');
549546

550547
$this->assertDICDefinitionMethodCallAt(0, $definition, 'addDriver', [
551-
new Reference(version_compare(Kernel::VERSION, '7.0.0', '<') ? 'doctrine.orm.default_annotation_metadata_driver' : 'doctrine.orm.default_attribute_metadata_driver'),
552-
'Fixtures\Bundles\AnnotationsBundle\Entity',
553-
]);
554-
555-
$this->assertDICDefinitionMethodCallAt(1, $definition, 'addDriver', [
556548
new Reference('doctrine.orm.default_attribute_metadata_driver'),
557549
'Fixtures\Bundles\AttributesBundle\Entity',
558550
]);
559551

560-
$this->assertDICDefinitionMethodCallAt(2, $definition, 'addDriver', [
552+
$this->assertDICDefinitionMethodCallAt(1, $definition, 'addDriver', [
561553
new Reference('doctrine.orm.default_yml_metadata_driver'),
562554
'Fixtures\Bundles\YamlBundle\Entity',
563555
]);
564556

565-
$this->assertDICDefinitionMethodCallAt(3, $definition, 'addDriver', [
557+
$this->assertDICDefinitionMethodCallAt(2, $definition, 'addDriver', [
566558
new Reference('doctrine.orm.default_xml_metadata_driver'),
567559
'Fixtures\Bundles\XmlBundle',
568560
]);
569561

570562
$attrDef = $container->getDefinition('doctrine.orm.default_attribute_metadata_driver');
571563
$this->assertDICConstructorArguments($attrDef, [
572-
array_merge(
573-
! version_compare(Kernel::VERSION, '7.0.0', '<') ? [
574-
__DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'Bundles' . DIRECTORY_SEPARATOR . 'AnnotationsBundle' . DIRECTORY_SEPARATOR . 'Entity',
575-
] : [],
576-
[
577-
__DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'Bundles' . DIRECTORY_SEPARATOR . 'AttributesBundle' . DIRECTORY_SEPARATOR . 'Entity',
578-
],
579-
),
564+
[
565+
__DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'Bundles' . DIRECTORY_SEPARATOR . 'AttributesBundle' . DIRECTORY_SEPARATOR . 'Entity',
566+
],
580567
! class_exists(AnnotationDriver::class),
581568
]);
582569

@@ -600,21 +587,15 @@ public function testMultipleEntityManagersMappingBundleDefinitions(): void
600587
self::markTestSkipped('This test requires ORM');
601588
}
602589

603-
$container = $this->loadContainer('orm_multiple_em_bundle_mappings', ['YamlBundle', 'AnnotationsBundle', 'XmlBundle', 'AttributesBundle']);
590+
$container = $this->loadContainer('orm_multiple_em_bundle_mappings', ['YamlBundle', 'XmlBundle', 'AttributesBundle']);
604591

605592
$this->assertEquals(['em1' => 'doctrine.orm.em1_entity_manager', 'em2' => 'doctrine.orm.em2_entity_manager'], $container->getParameter('doctrine.entity_managers'), 'Set of the existing EntityManagers names is incorrect.');
606593
$this->assertEquals('%doctrine.entity_managers%', $container->getDefinition('doctrine')->getArgument(2), 'Set of the existing EntityManagers names is incorrect.');
607594

608-
$def1 = $container->getDefinition('doctrine.orm.em1_metadata_driver');
609-
$def2 = $container->getDefinition('doctrine.orm.em2_metadata_driver');
610-
$def1Id = version_compare(Kernel::VERSION, '7.0.0', '<') ? 'doctrine.orm.em1_annotation_metadata_driver' : 'doctrine.orm.em1_attribute_metadata_driver';
595+
$def1 = $container->getDefinition('doctrine.orm.em1_metadata_driver');
596+
$def2 = $container->getDefinition('doctrine.orm.em2_metadata_driver');
611597

612598
$this->assertDICDefinitionMethodCallAt(0, $def1, 'addDriver', [
613-
new Reference($def1Id),
614-
'Fixtures\Bundles\AnnotationsBundle\Entity',
615-
]);
616-
617-
$this->assertDICDefinitionMethodCallAt(1, $def1, 'addDriver', [
618599
new Reference('doctrine.orm.em1_attribute_metadata_driver'),
619600
'Fixtures\Bundles\AttributesBundle\Entity',
620601
]);
@@ -629,17 +610,6 @@ public function testMultipleEntityManagersMappingBundleDefinitions(): void
629610
'Fixtures\Bundles\XmlBundle',
630611
]);
631612

632-
if (version_compare(Kernel::VERSION, '7.0.0', '<')) {
633-
$annDef = $container->getDefinition($def1Id);
634-
$this->assertDICConstructorArguments($annDef, [
635-
new Reference('doctrine.orm.metadata.annotation_reader'),
636-
[
637-
__DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'Bundles' . DIRECTORY_SEPARATOR . 'AnnotationsBundle' . DIRECTORY_SEPARATOR . 'Entity',
638-
],
639-
! class_exists(AnnotationDriver::class),
640-
]);
641-
}
642-
643613
$ymlDef = $container->getDefinition('doctrine.orm.em2_yml_metadata_driver');
644614
$this->assertDICConstructorArguments($ymlDef, [
645615
[__DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'Bundles' . DIRECTORY_SEPARATOR . 'YamlBundle' . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'doctrine' => 'Fixtures\Bundles\YamlBundle\Entity'],
@@ -659,7 +629,7 @@ public function testSingleEntityManagerDefaultTableOptions(): void
659629
self::markTestSkipped('This test requires ORM');
660630
}
661631

662-
$container = $this->loadContainer('orm_single_em_default_table_options', ['YamlBundle', 'AnnotationsBundle', 'XmlBundle', 'AttributesBundle']);
632+
$container = $this->loadContainer('orm_single_em_default_table_options', ['YamlBundle', 'XmlBundle', 'AttributesBundle']);
663633

664634
$param = $container->getDefinition('doctrine.dbal.default_connection')->getArgument(0);
665635

tests/DependencyInjection/Compiler/IdGeneratorPassTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ public function testRepositoryServiceWiring(): void
8080
'kernel.secret' => 'test',
8181
'container.build_id' => uniqid(),
8282
'env(base64:default::SYMFONY_DECRYPTION_SECRET)' => 'foo',
83+
'env(bool:default::SYMFONY_TRUST_X_SENDFILE_TYPE_HEADER)' => '',
84+
'env(default::SYMFONY_TRUSTED_HOSTS)' => '',
85+
'env(default::SYMFONY_TRUSTED_PROXIES)' => '',
86+
'env(default::SYMFONY_TRUSTED_HEADERS)' => '',
8387
'debug.file_link_format' => null,
8488
]));
8589

tests/DependencyInjection/DoctrineExtensionTest.php

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
use Symfony\Component\DependencyInjection\Reference;
5151
use Symfony\Component\Messenger\Bridge\Doctrine\Transport\DoctrineTransportFactory;
5252
use Symfony\Component\Messenger\MessageBusInterface;
53-
use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader;
5453

5554
use function array_values;
5655
use function class_exists;
@@ -823,39 +822,6 @@ public function testXmlBundleMappingDetection(): void
823822
]);
824823
}
825824

826-
public function testAnnotationsBundleMappingDetection(): void
827-
{
828-
if (! interface_exists(EntityManagerInterface::class)) {
829-
self::markTestSkipped('This test requires ORM');
830-
}
831-
832-
$container = $this->getContainer(['AnnotationsBundle']);
833-
$extension = new DoctrineExtension();
834-
835-
$config = BundleConfigurationBuilder::createBuilder()
836-
->addBaseConnection()
837-
->addEntityManager([
838-
'default_entity_manager' => 'default',
839-
'entity_managers' => [
840-
'default' => [
841-
'mappings' => [
842-
'AnnotationsBundle' => [],
843-
],
844-
],
845-
],
846-
])
847-
->build();
848-
$extension->load([$config], $container);
849-
850-
$definition = $container->getDefinition('doctrine.orm.default_metadata_driver');
851-
$this->assertDICDefinitionMethodCallOnce($definition, 'addDriver', [
852-
new Reference(class_exists(AnnotationLoader::class)
853-
? 'doctrine.orm.default_annotation_metadata_driver'
854-
: 'doctrine.orm.default_attribute_metadata_driver'),
855-
'Fixtures\Bundles\AnnotationsBundle\Entity',
856-
]);
857-
}
858-
859825
/** @requires PHP 8 */
860826
public function testAttributesBundleMappingDetection(): void
861827
{
@@ -898,7 +864,7 @@ public function testOrmMergeConfigs(): void
898864
self::markTestSkipped('This test requires ORM');
899865
}
900866

901-
$container = $this->getContainer(['XmlBundle', 'AnnotationsBundle', 'AttributesBundle']);
867+
$container = $this->getContainer(['XmlBundle', 'AttributesBundle']);
902868
$extension = new DoctrineExtension();
903869

904870
$config1 = BundleConfigurationBuilder::createBuilder()
@@ -908,10 +874,7 @@ public function testOrmMergeConfigs(): void
908874
'default_entity_manager' => 'default',
909875
'entity_managers' => [
910876
'default' => [
911-
'mappings' => [
912-
'AnnotationsBundle' => [],
913-
'AttributesBundle' => ['type' => 'attribute'],
914-
],
877+
'mappings' => ['AttributesBundle' => ['type' => 'attribute']],
915878
],
916879
],
917880
])
@@ -934,16 +897,10 @@ public function testOrmMergeConfigs(): void
934897

935898
$definition = $container->getDefinition('doctrine.orm.default_metadata_driver');
936899
$this->assertDICDefinitionMethodCallAt(0, $definition, 'addDriver', [
937-
new Reference(class_exists(AnnotationLoader::class)
938-
? 'doctrine.orm.default_annotation_metadata_driver'
939-
: 'doctrine.orm.default_attribute_metadata_driver'),
940-
'Fixtures\Bundles\AnnotationsBundle\Entity',
941-
]);
942-
$this->assertDICDefinitionMethodCallAt(1, $definition, 'addDriver', [
943900
new Reference('doctrine.orm.default_attribute_metadata_driver'),
944901
'Fixtures\Bundles\AttributesBundle\Entity',
945902
]);
946-
$this->assertDICDefinitionMethodCallAt(2, $definition, 'addDriver', [
903+
$this->assertDICDefinitionMethodCallAt(1, $definition, 'addDriver', [
947904
new Reference('doctrine.orm.default_xml_metadata_driver'),
948905
'Fixtures\Bundles\XmlBundle\Entity',
949906
]);

tests/DependencyInjection/Fixtures/config/xml/orm_multiple_em_bundle_mappings.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
<orm default-entity-manager="em2">
1515
<entity-manager name="em1">
16-
<mapping name="AnnotationsBundle" />
1716
<mapping name="AttributesBundle" type="attribute" />
1817
</entity-manager>
1918
<entity-manager name="em2" validate-xml-mapping="true">

tests/DependencyInjection/Fixtures/config/xml/orm_single_em_bundle_mappings.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
</dbal>
1313

1414
<orm validate-xml-mapping="true">
15-
<mapping name="AnnotationsBundle" />
1615
<mapping name="AttributesBundle" type="attribute" />
1716
<mapping name="YamlBundle" dir="Resources/config/doctrine" alias="yml" />
1817
<mapping name="manual" type="xml" prefix="Fixtures\Bundles\XmlBundle"

tests/DependencyInjection/Fixtures/config/xml/orm_single_em_default_table_options.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
</dbal>
1717

1818
<orm>
19-
<mapping name="AnnotationsBundle" />
2019
<mapping name="AttributesBundle" type="attribute" />
2120
<mapping name="YamlBundle" dir="Resources/config/doctrine" alias="yml" />
2221
<mapping name="manual" type="xml" prefix="Fixtures\Bundles\XmlBundle"

tests/DependencyInjection/Fixtures/config/yml/orm_multiple_em_bundle_mappings.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ doctrine:
1010
entity_managers:
1111
em1:
1212
mappings:
13-
AnnotationsBundle: ~
1413
AttributesBundle:
1514
type: attribute
1615
em2:

tests/DependencyInjection/Fixtures/config/yml/orm_single_em_bundle_mappings.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ doctrine:
88
orm:
99
validate_xml_mapping: true
1010
mappings:
11-
AnnotationsBundle: ~
1211
AttributesBundle:
1312
type: attribute
1413
YamlBundle:

0 commit comments

Comments
 (0)