Skip to content

Commit c47d5fd

Browse files
committed
Deprecate XML configuration format
1 parent 693311f commit c47d5fd

File tree

36 files changed

+536
-139
lines changed

36 files changed

+536
-139
lines changed

UPGRADE-7.4.md

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

2424
* Add argument `$target` to `ContainerBuilder::registerAliasForArgument()`
2525
* Deprecate registering a service without a class when its id is a non-existing FQCN
26+
* Deprecate XML configuration format, use YAML or PHP instead
2627

2728
DoctrineBridge
2829
--------------
@@ -44,13 +45,23 @@ HttpFoundation
4445

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

48+
Routing
49+
-------
50+
51+
* Deprecate XML configuration format, use YAML, PHP or attributes instead
52+
4753
Security
4854
--------
4955

5056
* Deprecate callable firewall listeners, extend `AbstractListener` or implement `FirewallListenerInterface` instead
5157
* Deprecate `AbstractListener::__invoke`
5258
* Deprecate `LazyFirewallContext::__invoke()`
5359

60+
Serializer
61+
----------
62+
63+
* Deprecate XML configuration format, use YAML or attributes instead
64+
5465
Translation
5566
-----------
5667

@@ -180,3 +191,4 @@ Validator
180191
}
181192
}
182193
```
194+
* 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: 87 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,29 @@ private function getArrayPool(string $file): PhpArrayAdapter
3939
}
4040

4141
/**
42-
* @dataProvider loaderProvider
42+
* @dataProvider yamlLoaderProvider
4343
*/
44-
public function testWarmUp(array $loaders)
44+
public function testYamlWarmUp(array $loaders)
45+
{
46+
$file = sys_get_temp_dir().'/cache-serializer.php';
47+
@unlink($file);
48+
49+
$warmer = new SerializerCacheWarmer($loaders, $file);
50+
$warmer->warmUp(\dirname($file), \dirname($file));
51+
52+
$this->assertFileExists($file);
53+
54+
$arrayPool = new PhpArrayAdapter($file, new NullAdapter());
55+
56+
$this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit());
57+
}
58+
59+
/**
60+
* @group legacy
61+
*
62+
* @dataProvider xmlLoaderProvider
63+
*/
64+
public function testXmlWarmUp(array $loaders)
4565
{
4666
$file = sys_get_temp_dir().'/cache-serializer.php';
4767
@unlink($file);
@@ -54,13 +74,35 @@ public function testWarmUp(array $loaders)
5474
$arrayPool = $this->getArrayPool($file);
5575

5676
$this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Person')->isHit());
77+
}
78+
79+
/**
80+
* @dataProvider yamlLoaderProvider
81+
*/
82+
public function testYamlWarmUpAbsoluteFilePath(array $loaders)
83+
{
84+
$file = sys_get_temp_dir().'/0/cache-serializer.php';
85+
@unlink($file);
86+
87+
$cacheDir = sys_get_temp_dir().'/1';
88+
89+
$warmer = new SerializerCacheWarmer($loaders, $file);
90+
$warmer->warmUp($cacheDir, $cacheDir);
91+
92+
$this->assertFileExists($file);
93+
$this->assertFileDoesNotExist($cacheDir.'/cache-serializer.php');
94+
95+
$arrayPool = new PhpArrayAdapter($file, new NullAdapter());
96+
5797
$this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit());
5898
}
5999

60100
/**
61-
* @dataProvider loaderProvider
101+
* @group legacy
102+
*
103+
* @dataProvider xmlLoaderProvider
62104
*/
63-
public function testWarmUpAbsoluteFilePath(array $loaders)
105+
public function testXmlWarmUpAbsoluteFilePath(array $loaders)
64106
{
65107
$file = sys_get_temp_dir().'/0/cache-serializer.php';
66108
@unlink($file);
@@ -76,13 +118,12 @@ public function testWarmUpAbsoluteFilePath(array $loaders)
76118
$arrayPool = $this->getArrayPool($file);
77119

78120
$this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Person')->isHit());
79-
$this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit());
80121
}
81122

82123
/**
83-
* @dataProvider loaderProvider
124+
* @dataProvider yamlLoaderProvider
84125
*/
85-
public function testWarmUpWithoutBuildDir(array $loaders)
126+
public function testYamlWarmUpWithoutBuildDir(array $loaders)
86127
{
87128
$file = sys_get_temp_dir().'/cache-serializer.php';
88129
@unlink($file);
@@ -94,30 +135,65 @@ public function testWarmUpWithoutBuildDir(array $loaders)
94135

95136
$arrayPool = $this->getArrayPool($file);
96137

97-
$this->assertFalse($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Person')->isHit());
98138
$this->assertFalse($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit());
99139
}
100140

101-
public static function loaderProvider(): array
141+
/**
142+
* @group legacy
143+
*
144+
* @dataProvider xmlLoaderProvider
145+
*/
146+
public function testXmlWarmUpWithoutBuildDir(array $loaders)
147+
{
148+
$file = sys_get_temp_dir().'/cache-serializer.php';
149+
@unlink($file);
150+
151+
$warmer = new SerializerCacheWarmer($loaders, $file);
152+
$warmer->warmUp(\dirname($file));
153+
154+
$this->assertFileDoesNotExist($file);
155+
156+
$arrayPool = new PhpArrayAdapter($file, new NullAdapter());
157+
158+
$this->assertFalse($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Person')->isHit());
159+
}
160+
161+
public static function yamlLoaderProvider(): array
102162
{
103163
return [
104164
[
105165
[
106166
new LoaderChain([
107-
new XmlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/person.xml'),
108167
new YamlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/author.yml'),
109168
]),
110169
],
111170
],
112171
[
113172
[
114-
new XmlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/person.xml'),
115173
new YamlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/author.yml'),
116174
],
117175
],
118176
];
119177
}
120178

179+
public static function xmlLoaderProvider(): array
180+
{
181+
return [
182+
[
183+
[
184+
new LoaderChain([
185+
new XmlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/person.xml'),
186+
]),
187+
],
188+
],
189+
[
190+
[
191+
new XmlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/person.xml'),
192+
],
193+
],
194+
];
195+
}
196+
121197
public function testWarmUpWithoutLoader()
122198
{
123199
$file = sys_get_temp_dir().'/cache-serializer-without-loader.php';

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

Lines changed: 68 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,31 @@ private function getArrayPool(string $file): PhpArrayAdapter
3737
return $this->arrayPool = new PhpArrayAdapter($file, new NullAdapter());
3838
}
3939

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

4866
$file = sys_get_temp_dir().'/cache-validator.php';
4967
@unlink($file);
@@ -56,16 +74,36 @@ public function testWarmUp()
5674
$arrayPool = $this->getArrayPool($file);
5775

5876
$this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person')->isHit());
77+
}
78+
79+
public function testYamlWarmUpAbsoluteFilePath()
80+
{
81+
$validatorBuilder = new ValidatorBuilder();
82+
$validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/author.yml');
83+
84+
$file = sys_get_temp_dir().'/0/cache-validator.php';
85+
@unlink($file);
86+
87+
$cacheDir = sys_get_temp_dir().'/1';
88+
89+
$warmer = new ValidatorCacheWarmer($validatorBuilder, $file);
90+
$warmer->warmUp($cacheDir, $cacheDir);
91+
92+
$this->assertFileExists($file);
93+
$this->assertFileDoesNotExist($cacheDir.'/cache-validator.php');
94+
95+
$arrayPool = new PhpArrayAdapter($file, new NullAdapter());
96+
5997
$this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author')->isHit());
6098
}
6199

62-
public function testWarmUpAbsoluteFilePath()
100+
/**
101+
* @group legacy
102+
*/
103+
public function testXmlWarmUpAbsoluteFilePath()
63104
{
64105
$validatorBuilder = new ValidatorBuilder();
65106
$validatorBuilder->addXmlMapping(__DIR__.'/../Fixtures/Validation/Resources/person.xml');
66-
$validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/author.yml');
67-
$validatorBuilder->addMethodMapping('loadValidatorMetadata');
68-
$validatorBuilder->enableAttributeMapping();
69107

70108
$file = sys_get_temp_dir().'/0/cache-validator.php';
71109
@unlink($file);
@@ -81,16 +119,12 @@ public function testWarmUpAbsoluteFilePath()
81119
$arrayPool = $this->getArrayPool($file);
82120

83121
$this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person')->isHit());
84-
$this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author')->isHit());
85122
}
86123

87-
public function testWarmUpWithoutBuilDir()
124+
public function testYamlWarmUpWithoutBuilDir()
88125
{
89126
$validatorBuilder = new ValidatorBuilder();
90-
$validatorBuilder->addXmlMapping(__DIR__.'/../Fixtures/Validation/Resources/person.xml');
91127
$validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/author.yml');
92-
$validatorBuilder->addMethodMapping('loadValidatorMetadata');
93-
$validatorBuilder->enableAttributeMapping();
94128

95129
$file = sys_get_temp_dir().'/cache-validator.php';
96130
@unlink($file);
@@ -102,10 +136,30 @@ public function testWarmUpWithoutBuilDir()
102136

103137
$arrayPool = $this->getArrayPool($file);
104138

105-
$this->assertFalse($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person')->isHit());
106139
$this->assertFalse($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author')->isHit());
107140
}
108141

142+
/**
143+
* @group legacy
144+
*/
145+
public function testXmlWarmUpWithoutBuilDir()
146+
{
147+
$validatorBuilder = new ValidatorBuilder();
148+
$validatorBuilder->addXmlMapping(__DIR__.'/../Fixtures/Validation/Resources/person.xml');
149+
150+
$file = sys_get_temp_dir().'/cache-validator.php';
151+
@unlink($file);
152+
153+
$warmer = new ValidatorCacheWarmer($validatorBuilder, $file);
154+
$warmer->warmUp(\dirname($file));
155+
156+
$this->assertFileDoesNotExist($file);
157+
158+
$arrayPool = new PhpArrayAdapter($file, new NullAdapter());
159+
160+
$this->assertFalse($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person')->isHit());
161+
}
162+
109163
public function testWarmUpWithAnnotations()
110164
{
111165
$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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy