Skip to content

Commit c95122c

Browse files
authored
Merge pull request #2102 from doctrine/3.1.x
Merge 3.1.x up into 4.0.x
2 parents 112091b + a5eebe3 commit c95122c

File tree

9 files changed

+54
-22
lines changed

9 files changed

+54
-22
lines changed

UPGRADE-3.1.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
UPGRADE FROM 3.0 to 3.1
2+
=======================
3+
4+
Configuration
5+
-------------
6+
7+
The `doctrine.orm.entity_managers.some_em.enable_native_lazy_objects`
8+
configuration option is deprecated and will be removed in DoctrineBundle 4.0,
9+
as native lazy objects are now always enabled.

composer.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434
"doctrine/deprecations": "^1.0",
3535
"doctrine/persistence": "^4",
3636
"doctrine/sql-formatter": "^1.0.1",
37-
"symfony/cache": "^6.4 || ^7.0",
38-
"symfony/config": "^6.4 || ^7.0",
39-
"symfony/console": "^6.4 || ^7.0",
40-
"symfony/dependency-injection": "^6.4 || ^7.0",
41-
"symfony/doctrine-bridge": "^6.4.3 || ^7.0.3",
42-
"symfony/framework-bundle": "^6.4 || ^7.0",
37+
"symfony/cache": "^6.4 || ^7.0 || ^8.0",
38+
"symfony/config": "^6.4 || ^7.0 || ^8.0",
39+
"symfony/console": "^6.4 || ^7.0 || ^8.0",
40+
"symfony/dependency-injection": "^6.4 || ^7.0 || ^8.0",
41+
"symfony/doctrine-bridge": "^6.4.3 || ^7.0.3 || ^8.0",
42+
"symfony/framework-bundle": "^6.4 || ^7.0 || ^8.0",
4343
"symfony/service-contracts": "^3"
4444
},
4545
"require-dev": {
@@ -50,18 +50,18 @@
5050
"phpstan/phpstan-strict-rules": "^2",
5151
"phpunit/phpunit": "^12.3.10",
5252
"psr/log": "^3.0",
53-
"symfony/doctrine-messenger": "^6.4 || ^7.0",
54-
"symfony/expression-language": "^6.4 || ^7.0",
55-
"symfony/messenger": "^6.4 || ^7.0",
56-
"symfony/property-info": "^6.4 || ^7.0",
57-
"symfony/security-bundle": "^6.4 || ^7.0",
58-
"symfony/stopwatch": "^6.4 || ^7.0",
59-
"symfony/string": "^6.4 || ^7.0",
60-
"symfony/twig-bridge": "^6.4 || ^7.0",
61-
"symfony/validator": "^6.4 || ^7.0",
62-
"symfony/var-exporter": "^6.4.1 || ^7.0.1",
63-
"symfony/web-profiler-bundle": "^6.4 || ^7.0",
64-
"symfony/yaml": "^6.4 || ^7.0",
53+
"symfony/doctrine-messenger": "^6.4 || ^7.0 || ^8.0",
54+
"symfony/expression-language": "^6.4 || ^7.0 || ^8.0",
55+
"symfony/messenger": "^6.4 || ^7.0 || ^8.0",
56+
"symfony/property-info": "^6.4 || ^7.0 || ^8.0",
57+
"symfony/security-bundle": "^6.4 || ^7.0 || ^8.0",
58+
"symfony/stopwatch": "^6.4 || ^7.0 || ^8.0",
59+
"symfony/string": "^6.4 || ^7.0 || ^8.0",
60+
"symfony/twig-bridge": "^6.4 || ^7.0 || ^8.0",
61+
"symfony/validator": "^6.4 || ^7.0 || ^8.0",
62+
"symfony/var-exporter": "^6.4.1 || ^7.0.1 || ^8.0",
63+
"symfony/web-profiler-bundle": "^6.4 || ^7.0 || ^8.0",
64+
"symfony/yaml": "^6.4 || ^7.0 || ^8.0",
6565
"twig/twig": "^3.21.1"
6666
},
6767
"conflict": {

src/DependencyInjection/Configuration.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,11 @@ private function addOrmSection(ArrayNodeDefinition $node): void
410410
->ifTrue(static fn ($v) => $v === false)
411411
->thenInvalid('The setting "enable_native_lazy_objects" can no longer be disabled and should not be set')
412412
->end()
413-
->info('no-op, will be deprecated and removed in the future')
413+
->setDeprecated(
414+
'doctrine/doctrine-bundle',
415+
'3.1',
416+
'The "%node%" option is deprecated and will be removed in DoctrineBundle 4.0, as native lazy objects are now always enabled.',
417+
)
414418
->end()
415419
->arrayNode('controller_resolver')
416420
->canBeDisabled()

src/DependencyInjection/DoctrineExtension.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,8 @@ private function validateAutoMapping(array $managerConfigs): string|null
414414

415415
/**
416416
* {@inheritDoc}
417-
*
418-
* @return void
419417
*/
420-
public function load(array $configs, ContainerBuilder $container)
418+
public function load(array $configs, ContainerBuilder $container): void
421419
{
422420
$configuration = $this->getConfiguration($configs, $container);
423421
$config = $this->processConfigurationPrependingDefaults($configuration, $configs);

tests/DependencyInjection/AbstractDoctrineExtensionTestCase.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use PDO;
2727
use PHPUnit\Framework\Attributes\DataProvider;
2828
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
29+
use PHPUnit\Framework\Attributes\RequiresMethod;
2930
use PHPUnit\Framework\TestCase;
3031
use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterEventListenersAndSubscribersPass;
3132
use Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestHydrator;
@@ -40,6 +41,7 @@
4041
use Symfony\Component\DependencyInjection\Reference;
4142
use Symfony\Component\DependencyInjection\ServiceLocator;
4243
use Symfony\Component\Security\Core\User\UserInterface;
44+
use Symfony\Component\VarExporter\ProxyHelper;
4345

4446
use function array_filter;
4547
use function array_keys;
@@ -1184,6 +1186,7 @@ public function testDisableSchemaValidation(): void
11841186
$this->assertFalse($collectorDefinition->getArguments()[1]);
11851187
}
11861188

1189+
#[RequiresMethod(ProxyHelper::class, 'generateLazyGhost')]
11871190
public function testNativeLazyObjectsWithoutConfig(): void
11881191
{
11891192
if (! interface_exists(EntityManagerInterface::class)) {
@@ -1208,6 +1211,7 @@ public function testNativeLazyObjectsWithConfigTrue(): void
12081211
$this->assertTrue($entityManager->getConfiguration()->isNativeLazyObjectsEnabled());
12091212
}
12101213

1214+
#[RequiresMethod(ProxyHelper::class, 'generateLazyGhost')]
12111215
public function testNativeLazyObjectsWithConfigFalse(): void
12121216
{
12131217
if (! interface_exists(EntityManagerInterface::class)) {

tests/DependencyInjection/DoctrineExtensionTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,7 @@ public function testEntityAttributeExcludesFromContainer(string $class): void
973973
/** @phpstan-ignore function.alreadyNarrowedType */
974974
$attributes = method_exists($container, 'getAttributeAutoconfigurators')
975975
? array_map(static fn (array $arr) => $arr[0], $container->getAttributeAutoconfigurators())
976+
/** @phpstan-ignore method.notFound */
976977
: $container->getAutoconfiguredAttributes();
977978
$this->assertInstanceOf(Closure::class, $attributes[$class]);
978979

@@ -1002,6 +1003,7 @@ public function testAsEntityListenerAttribute(): void
10021003
/** @phpstan-ignore function.alreadyNarrowedType */
10031004
$attributes = method_exists($container, 'getAttributeAutoconfigurators')
10041005
? array_map(static fn (array $arr) => $arr[0], $container->getAttributeAutoconfigurators())
1006+
/** @phpstan-ignore method.notFound */
10051007
: $container->getAutoconfiguredAttributes();
10061008
$this->assertInstanceOf(Closure::class, $attributes[AsEntityListener::class]);
10071009

@@ -1041,6 +1043,7 @@ public function testAsDoctrineListenerAttribute(): void
10411043
/** @phpstan-ignore function.alreadyNarrowedType */
10421044
$attributes = method_exists($container, 'getAttributeAutoconfigurators')
10431045
? array_map(static fn (array $arr) => $arr[0], $container->getAttributeAutoconfigurators())
1046+
/** @phpstan-ignore method.notFound */
10441047
: $container->getAutoconfiguredAttributes();
10451048
$this->assertInstanceOf(Closure::class, $attributes[AsDoctrineListener::class]);
10461049

tests/DependencyInjection/Fixtures/DbalTestKernel.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use function md5;
1717
use function mt_rand;
1818
use function sys_get_temp_dir;
19+
use function version_compare;
1920

2021
class DbalTestKernel extends Kernel
2122
{
@@ -45,6 +46,13 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
4546
'http_method_override' => false,
4647
]);
4748

49+
/** @phpstan-ignore if.alwaysFalse */
50+
if (version_compare(Kernel::VERSION, '7.0.0', '<')) {
51+
$container->loadFromExtension('framework', [
52+
'annotations' => ['enabled' => true],
53+
]);
54+
}
55+
4856
$container->loadFromExtension('doctrine', [
4957
'dbal' => $this->dbalConfig,
5058
]);

tests/DependencyInjection/XmlDoctrineExtensionTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,23 @@
55
namespace Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection;
66

77
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
8+
use PHPUnit\Framework\Attributes\RequiresMethod;
89
use Symfony\Component\Config\FileLocator;
910
use Symfony\Component\DependencyInjection\ContainerBuilder;
1011
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
12+
use Symfony\Component\Validator\Mapping\Loader\XmlFileLoader as LoaderXmlFileLoader;
1113

1214
#[IgnoreDeprecations]
15+
#[RequiresMethod(LoaderXmlFileLoader::class, 'loadFile')]
1316
class XmlDoctrineExtensionTest extends AbstractDoctrineExtensionTestCase
1417
{
1518
protected function loadFromFile(
1619
ContainerBuilder $container,
1720
string $file,
1821
): void {
22+
/** @phpstan-ignore class.notFound */
1923
$loadXml = new XmlFileLoader($container, new FileLocator(__DIR__ . '/Fixtures/config/xml'));
24+
/** @phpstan-ignore class.notFound */
2025
$loadXml->import($file . '.{xml}');
2126
}
2227
}

tests/Polyfill/SymfonyApp.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function addCommand(callable|Command $command): Command|null
2929
*/
3030
public function add(Command $command): Command
3131
{
32+
/** @phpstan-ignore staticMethod.notFound */
3233
return parent::add($command);
3334
}
3435
}

0 commit comments

Comments
 (0)