Skip to content

Commit e913275

Browse files
committed
Deprecate XML configuration format
1 parent 2478de5 commit e913275

File tree

36 files changed

+538
-137
lines changed

36 files changed

+538
-137
lines changed

UPGRADE-7.4.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ DependencyInjection
2222
-------------------
2323

2424
* Add argument `$target` to `ContainerBuilder::registerAliasForArgument()`
25+
* Deprecate XML configuration format, use YAML or PHP instead
2526

2627
FrameworkBundle
2728
---------------
@@ -38,13 +39,23 @@ HttpFoundation
3839

3940
* Deprecate using `Request::sendHeaders()` after headers have already been sent; use a `StreamedResponse` instead
4041

42+
Routing
43+
-------
44+
45+
* Deprecate XML configuration format, use YAML, PHP or attributes instead
46+
4147
Security
4248
--------
4349

4450
* Deprecate callable firewall listeners, extend `AbstractListener` or implement `FirewallListenerInterface` instead
4551
* Deprecate `AbstractListener::__invoke`
4652
* Deprecate `LazyFirewallContext::__invoke()`
4753

54+
Serializer
55+
----------
56+
57+
* Deprecate XML configuration format, use YAML or attributes instead
58+
4859
Validator
4960
---------
5061

@@ -171,3 +182,4 @@ Validator
171182
}
172183
}
173184
```
185+
* Deprecate XML configuration format, use YAML or attributes instead

src/Symfony/Bridge/Doctrine/Tests/Fixtures/BaseUser.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Tests\Fixtures;
1313

14+
use Symfony\Component\Validator\Constraints as Assert;
15+
1416
class BaseUser
1517
{
1618
private $enabled;
1719

1820
public function __construct(
1921
private readonly int $id,
22+
23+
#[Assert\NotBlank(groups: ['Registration'])]
24+
#[Assert\Length(min: 2, max: 120, groups: ['Registration'])]
2025
private readonly string $username,
2126
) {
2227
}

src/Symfony/Bridge/Doctrine/Tests/Resources/validator/BaseUser.xml

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/Symfony/Bridge/Doctrine/Tests/Validator/DoctrineLoaderTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ public function testFieldMappingsConfiguration()
159159
{
160160
$validator = Validation::createValidatorBuilder()
161161
->enableAttributeMapping()
162-
->addXmlMappings([__DIR__.'/../Resources/validator/BaseUser.xml'])
163162
->addLoader(
164163
new DoctrineLoader(
165164
DoctrineTestHelper::createTestEntityManager(

src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/SerializerCacheWarmerTest.php

Lines changed: 86 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,29 @@
2222
class SerializerCacheWarmerTest extends TestCase
2323
{
2424
/**
25-
* @dataProvider loaderProvider
25+
* @dataProvider yamlLoaderProvider
2626
*/
27-
public function testWarmUp(array $loaders)
27+
public function testYamlWarmUp(array $loaders)
28+
{
29+
$file = sys_get_temp_dir().'/cache-serializer.php';
30+
@unlink($file);
31+
32+
$warmer = new SerializerCacheWarmer($loaders, $file);
33+
$warmer->warmUp(\dirname($file), \dirname($file));
34+
35+
$this->assertFileExists($file);
36+
37+
$arrayPool = new PhpArrayAdapter($file, new NullAdapter());
38+
39+
$this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit());
40+
}
41+
42+
/**
43+
* @group legacy
44+
*
45+
* @dataProvider xmlLoaderProvider
46+
*/
47+
public function testXmlWarmUp(array $loaders)
2848
{
2949
$file = sys_get_temp_dir().'/cache-serializer.php';
3050
@unlink($file);
@@ -37,13 +57,35 @@ public function testWarmUp(array $loaders)
3757
$arrayPool = new PhpArrayAdapter($file, new NullAdapter());
3858

3959
$this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Person')->isHit());
60+
}
61+
62+
/**
63+
* @dataProvider yamlLoaderProvider
64+
*/
65+
public function testYamlWarmUpAbsoluteFilePath(array $loaders)
66+
{
67+
$file = sys_get_temp_dir().'/0/cache-serializer.php';
68+
@unlink($file);
69+
70+
$cacheDir = sys_get_temp_dir().'/1';
71+
72+
$warmer = new SerializerCacheWarmer($loaders, $file);
73+
$warmer->warmUp($cacheDir, $cacheDir);
74+
75+
$this->assertFileExists($file);
76+
$this->assertFileDoesNotExist($cacheDir.'/cache-serializer.php');
77+
78+
$arrayPool = new PhpArrayAdapter($file, new NullAdapter());
79+
4080
$this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit());
4181
}
4282

4383
/**
44-
* @dataProvider loaderProvider
84+
* @group legacy
85+
*
86+
* @dataProvider xmlLoaderProvider
4587
*/
46-
public function testWarmUpAbsoluteFilePath(array $loaders)
88+
public function testXmlWarmUpAbsoluteFilePath(array $loaders)
4789
{
4890
$file = sys_get_temp_dir().'/0/cache-serializer.php';
4991
@unlink($file);
@@ -59,13 +101,32 @@ public function testWarmUpAbsoluteFilePath(array $loaders)
59101
$arrayPool = new PhpArrayAdapter($file, new NullAdapter());
60102

61103
$this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Person')->isHit());
104+
}
105+
106+
/**
107+
* @dataProvider yamlLoaderProvider
108+
*/
109+
public function testYamlWarmUpWithoutBuildDir(array $loaders)
110+
{
111+
$file = sys_get_temp_dir().'/cache-serializer.php';
112+
@unlink($file);
113+
114+
$warmer = new SerializerCacheWarmer($loaders, $file);
115+
$warmer->warmUp(\dirname($file));
116+
117+
$this->assertFileDoesNotExist($file);
118+
119+
$arrayPool = new PhpArrayAdapter($file, new NullAdapter());
120+
62121
$this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit());
63122
}
64123

65124
/**
66-
* @dataProvider loaderProvider
125+
* @group legacy
126+
*
127+
* @dataProvider xmlLoaderProvider
67128
*/
68-
public function testWarmUpWithoutBuildDir(array $loaders)
129+
public function testXmlWarmUpWithoutBuildDir(array $loaders)
69130
{
70131
$file = sys_get_temp_dir().'/cache-serializer.php';
71132
@unlink($file);
@@ -78,29 +139,44 @@ public function testWarmUpWithoutBuildDir(array $loaders)
78139
$arrayPool = new PhpArrayAdapter($file, new NullAdapter());
79140

80141
$this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Person')->isHit());
81-
$this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit());
82142
}
83143

84-
public static function loaderProvider(): array
144+
public static function yamlLoaderProvider(): array
85145
{
86146
return [
87147
[
88148
[
89149
new LoaderChain([
90-
new XmlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/person.xml'),
91150
new YamlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/author.yml'),
92151
]),
93152
],
94153
],
95154
[
96155
[
97-
new XmlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/person.xml'),
98156
new YamlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/author.yml'),
99157
],
100158
],
101159
];
102160
}
103161

162+
public static function xmlLoaderProvider(): array
163+
{
164+
return [
165+
[
166+
[
167+
new LoaderChain([
168+
new XmlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/person.xml'),
169+
]),
170+
],
171+
],
172+
[
173+
[
174+
new XmlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/person.xml'),
175+
],
176+
],
177+
];
178+
}
179+
104180
public function testWarmUpWithoutLoader()
105181
{
106182
$file = sys_get_temp_dir().'/cache-serializer-without-loader.php';

src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/ValidatorCacheWarmerTest.php

Lines changed: 67 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@
2020

2121
class ValidatorCacheWarmerTest extends TestCase
2222
{
23-
public function testWarmUp()
23+
public function testYamlWarmUp()
2424
{
2525
$validatorBuilder = new ValidatorBuilder();
26-
$validatorBuilder->addXmlMapping(__DIR__.'/../Fixtures/Validation/Resources/person.xml');
2726
$validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/author.yml');
28-
$validatorBuilder->addMethodMapping('loadValidatorMetadata');
29-
$validatorBuilder->enableAttributeMapping();
3027

3128
$file = sys_get_temp_dir().'/cache-validator.php';
3229
@unlink($file);
@@ -38,17 +35,34 @@ public function testWarmUp()
3835

3936
$arrayPool = new PhpArrayAdapter($file, new NullAdapter());
4037

41-
$this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person')->isHit());
4238
$this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author')->isHit());
4339
}
4440

45-
public function testWarmUpAbsoluteFilePath()
41+
/**
42+
* @group legacy
43+
*/
44+
public function testXmlWarmUp()
4645
{
4746
$validatorBuilder = new ValidatorBuilder();
4847
$validatorBuilder->addXmlMapping(__DIR__.'/../Fixtures/Validation/Resources/person.xml');
48+
49+
$file = sys_get_temp_dir().'/cache-validator.php';
50+
@unlink($file);
51+
52+
$warmer = new ValidatorCacheWarmer($validatorBuilder, $file);
53+
$warmer->warmUp(\dirname($file), \dirname($file));
54+
55+
$this->assertFileExists($file);
56+
57+
$arrayPool = new PhpArrayAdapter($file, new NullAdapter());
58+
59+
$this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person')->isHit());
60+
}
61+
62+
public function testYamlWarmUpAbsoluteFilePath()
63+
{
64+
$validatorBuilder = new ValidatorBuilder();
4965
$validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/author.yml');
50-
$validatorBuilder->addMethodMapping('loadValidatorMetadata');
51-
$validatorBuilder->enableAttributeMapping();
5266

5367
$file = sys_get_temp_dir().'/0/cache-validator.php';
5468
@unlink($file);
@@ -63,17 +77,37 @@ public function testWarmUpAbsoluteFilePath()
6377

6478
$arrayPool = new PhpArrayAdapter($file, new NullAdapter());
6579

66-
$this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person')->isHit());
6780
$this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author')->isHit());
6881
}
6982

70-
public function testWarmUpWithoutBuilDir()
83+
/**
84+
* @group legacy
85+
*/
86+
public function testXmlWarmUpAbsoluteFilePath()
7187
{
7288
$validatorBuilder = new ValidatorBuilder();
7389
$validatorBuilder->addXmlMapping(__DIR__.'/../Fixtures/Validation/Resources/person.xml');
90+
91+
$file = sys_get_temp_dir().'/0/cache-validator.php';
92+
@unlink($file);
93+
94+
$cacheDir = sys_get_temp_dir().'/1';
95+
96+
$warmer = new ValidatorCacheWarmer($validatorBuilder, $file);
97+
$warmer->warmUp($cacheDir, $cacheDir);
98+
99+
$this->assertFileExists($file);
100+
$this->assertFileDoesNotExist($cacheDir.'/cache-validator.php');
101+
102+
$arrayPool = new PhpArrayAdapter($file, new NullAdapter());
103+
104+
$this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person')->isHit());
105+
}
106+
107+
public function testYamlWarmUpWithoutBuilDir()
108+
{
109+
$validatorBuilder = new ValidatorBuilder();
74110
$validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/author.yml');
75-
$validatorBuilder->addMethodMapping('loadValidatorMetadata');
76-
$validatorBuilder->enableAttributeMapping();
77111

78112
$file = sys_get_temp_dir().'/cache-validator.php';
79113
@unlink($file);
@@ -85,10 +119,30 @@ public function testWarmUpWithoutBuilDir()
85119

86120
$arrayPool = new PhpArrayAdapter($file, new NullAdapter());
87121

88-
$this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person')->isHit());
89122
$this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author')->isHit());
90123
}
91124

125+
/**
126+
* @group legacy
127+
*/
128+
public function testXmlWarmUpWithoutBuilDir()
129+
{
130+
$validatorBuilder = new ValidatorBuilder();
131+
$validatorBuilder->addXmlMapping(__DIR__.'/../Fixtures/Validation/Resources/person.xml');
132+
133+
$file = sys_get_temp_dir().'/cache-validator.php';
134+
@unlink($file);
135+
136+
$warmer = new ValidatorCacheWarmer($validatorBuilder, $file);
137+
$warmer->warmUp(\dirname($file));
138+
139+
$this->assertFileDoesNotExist($file);
140+
141+
$arrayPool = new PhpArrayAdapter($file, new NullAdapter());
142+
143+
$this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person')->isHit());
144+
}
145+
92146
public function testWarmUpWithAnnotations()
93147
{
94148
$validatorBuilder = new ValidatorBuilder();

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/XmlFrameworkExtensionTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
1616
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
1717

18+
/**
19+
* @group legacy
20+
*/
1821
class XmlFrameworkExtensionTest extends FrameworkExtensionTestCase
1922
{
2023
protected function loadFromFile(ContainerBuilder $container, $file)

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/XmlCompleteConfigurationTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
1616
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
1717

18+
/**
19+
* @group legacy
20+
*/
1821
class XmlCompleteConfigurationTest extends CompleteConfigurationTestCase
1922
{
2023
public function testFirewallPatterns()

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/XmlCustomAuthenticatorTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
use Symfony\Component\DependencyInjection\ContainerBuilder;
1919
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
2020

21+
/**
22+
* @group legacy
23+
*/
2124
class XmlCustomAuthenticatorTest extends TestCase
2225
{
2326
/**

0 commit comments

Comments
 (0)