Skip to content

Commit 87c2578

Browse files
committed
Revert serializer and validator deprecations
1 parent b374b96 commit 87c2578

File tree

13 files changed

+45
-184
lines changed

13 files changed

+45
-184
lines changed

UPGRADE-7.4.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ Security
5757
* Deprecate `AbstractListener::__invoke`
5858
* Deprecate `LazyFirewallContext::__invoke()`
5959

60-
Serializer
61-
----------
62-
63-
* Deprecate XML configuration format, use YAML or attributes instead
64-
6560
Translation
6661
-----------
6762

@@ -191,4 +186,3 @@ Validator
191186
}
192187
}
193188
```
194-
* Deprecate XML configuration format, use YAML or attributes instead

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

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

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

14-
use Symfony\Component\Validator\Constraints as Assert;
15-
1614
class BaseUser
1715
{
1816
private $enabled;
1917

2018
public function __construct(
2119
private readonly int $id,
22-
23-
#[Assert\NotBlank(groups: ['Registration'])]
24-
#[Assert\Length(min: 2, max: 120, groups: ['Registration'])]
2520
private readonly string $username,
2621
) {
2722
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" ?>
2+
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping
5+
http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
6+
7+
<class name="Symfony\Bridge\Doctrine\Tests\Fixtures\BaseUser">
8+
<property name="username">
9+
<constraint name="NotBlank">
10+
<option name="groups">Registration</option>
11+
</constraint>
12+
<constraint name="Length">
13+
<option name="min">2</option>
14+
<option name="max">120</option>
15+
<option name="groups">Registration</option>
16+
</constraint>
17+
</property>
18+
</class>
19+
</constraint-mapping>

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

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

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

Lines changed: 11 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,9 @@ private function getArrayPool(string $file): PhpArrayAdapter
3939
}
4040

4141
/**
42-
* @dataProvider yamlLoaderProvider
42+
* @dataProvider loaderProvider
4343
*/
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)
44+
public function testWarmUp(array $loaders)
6545
{
6646
$file = sys_get_temp_dir().'/cache-serializer.php';
6747
@unlink($file);
@@ -74,35 +54,13 @@ public function testXmlWarmUp(array $loaders)
7454
$arrayPool = $this->getArrayPool($file);
7555

7656
$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-
9757
$this->assertTrue($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit());
9858
}
9959

10060
/**
101-
* @group legacy
102-
*
103-
* @dataProvider xmlLoaderProvider
61+
* @dataProvider loaderProvider
10462
*/
105-
public function testXmlWarmUpAbsoluteFilePath(array $loaders)
63+
public function testWarmUpAbsoluteFilePath(array $loaders)
10664
{
10765
$file = sys_get_temp_dir().'/0/cache-serializer.php';
10866
@unlink($file);
@@ -118,12 +76,13 @@ public function testXmlWarmUpAbsoluteFilePath(array $loaders)
11876
$arrayPool = $this->getArrayPool($file);
11977

12078
$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());
12180
}
12281

12382
/**
124-
* @dataProvider yamlLoaderProvider
83+
* @dataProvider loaderProvider
12584
*/
126-
public function testYamlWarmUpWithoutBuildDir(array $loaders)
85+
public function testWarmUpWithoutBuildDir(array $loaders)
12786
{
12887
$file = sys_get_temp_dir().'/cache-serializer.php';
12988
@unlink($file);
@@ -135,60 +94,25 @@ public function testYamlWarmUpWithoutBuildDir(array $loaders)
13594

13695
$arrayPool = $this->getArrayPool($file);
13796

138-
$this->assertFalse($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit());
139-
}
140-
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-
15897
$this->assertFalse($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Person')->isHit());
98+
$this->assertFalse($arrayPool->getItem('Symfony_Bundle_FrameworkBundle_Tests_Fixtures_Serialization_Author')->isHit());
15999
}
160100

161-
public static function yamlLoaderProvider(): array
162-
{
163-
return [
164-
[
165-
[
166-
new LoaderChain([
167-
new YamlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/author.yml'),
168-
]),
169-
],
170-
],
171-
[
172-
[
173-
new YamlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/author.yml'),
174-
],
175-
],
176-
];
177-
}
178-
179-
public static function xmlLoaderProvider(): array
101+
public static function loaderProvider(): array
180102
{
181103
return [
182104
[
183105
[
184106
new LoaderChain([
185107
new XmlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/person.xml'),
108+
new YamlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/author.yml'),
186109
]),
187110
],
188111
],
189112
[
190113
[
191114
new XmlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/person.xml'),
115+
new YamlFileLoader(__DIR__.'/../Fixtures/Serialization/Resources/author.yml'),
192116
],
193117
],
194118
];

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

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

40-
public function testYamlWarmUp()
41-
{
42-
$validatorBuilder = new ValidatorBuilder();
43-
$validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/author.yml');
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()
40+
public function testWarmUp()
6241
{
6342
$validatorBuilder = new ValidatorBuilder();
6443
$validatorBuilder->addXmlMapping(__DIR__.'/../Fixtures/Validation/Resources/person.xml');
44+
$validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/author.yml');
45+
$validatorBuilder->addMethodMapping('loadValidatorMetadata');
46+
$validatorBuilder->enableAttributeMapping();
6547

6648
$file = sys_get_temp_dir().'/cache-validator.php';
6749
@unlink($file);
@@ -74,36 +56,16 @@ public function testXmlWarmUp()
7456
$arrayPool = $this->getArrayPool($file);
7557

7658
$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-
9759
$this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author')->isHit());
9860
}
9961

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

10870
$file = sys_get_temp_dir().'/0/cache-validator.php';
10971
@unlink($file);
@@ -119,12 +81,16 @@ public function testXmlWarmUpAbsoluteFilePath()
11981
$arrayPool = $this->getArrayPool($file);
12082

12183
$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());
12285
}
12386

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

12995
$file = sys_get_temp_dir().'/cache-validator.php';
13096
@unlink($file);
@@ -136,28 +102,8 @@ public function testYamlWarmUpWithoutBuilDir()
136102

137103
$arrayPool = $this->getArrayPool($file);
138104

139-
$this->assertFalse($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author')->isHit());
140-
}
141-
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-
160105
$this->assertFalse($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Person')->isHit());
106+
$this->assertFalse($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author')->isHit());
161107
}
162108

163109
public function testWarmUpWithAnnotations()

src/Symfony/Component/Serializer/CHANGELOG.md

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

77
* Add `CDATA_WRAPPING_NAME_PATTERN` support to `XmlEncoder`
88
* Add support for `can*()` methods to `AttributeLoader`
9-
* Deprecate XML configuration format, use YAML or attributes instead
109

1110
7.3
1211
---

src/Symfony/Component/Serializer/Mapping/Loader/XmlFileLoader.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
* Loads XML mapping files.
2424
*
2525
* @author Kévin Dunglas <dunglas@gmail.com>
26-
*
27-
* @deprecated since Symfony 7.4, use another loader instead
2826
*/
2927
class XmlFileLoader extends FileLoader
3028
{
@@ -44,8 +42,6 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
4442
$attributesMetadata = $classMetadata->getAttributesMetadata();
4543

4644
if (isset($this->classes[$classMetadata->getName()])) {
47-
trigger_deprecation('symfony/serializer', '7.4', 'XML configuration format is deprecated, use YAML or attributes instead.');
48-
4945
$xml = $this->classes[$classMetadata->getName()];
5046

5147
foreach ($xml->attribute as $attribute) {

src/Symfony/Component/Serializer/Tests/Mapping/Loader/XmlFileLoaderTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131

3232
/**
3333
* @author Kévin Dunglas <dunglas@gmail.com>
34-
*
35-
* @group legacy
3634
*/
3735
class XmlFileLoaderTest extends TestCase
3836
{

src/Symfony/Component/Validator/CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ CHANGELOG
126126
}
127127
}
128128
```
129-
* Deprecate XML configuration format, use YAML or attributes instead
130129

131130
7.3
132131
---

0 commit comments

Comments
 (0)