Skip to content

[DependencyInjection][Routing][Serializer][Validator] Deprecate XML configuration format #60568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 7.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions UPGRADE-7.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ DependencyInjection
-------------------

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

FrameworkBundle
---------------
Expand All @@ -33,9 +34,24 @@ HttpFoundation

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

Routing
-------

* Deprecate XML configuration format, use YAML, PHP or attributes instead

Security
--------

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

Serializer
----------

* Deprecate XML configuration format, use YAML or attributes instead

Validator
---------

* Deprecate XML configuration format, use YAML or attributes instead
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderParentEntity;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Bridge\Doctrine\Validator\DoctrineLoader;
use Symfony\Bridge\PhpUnit\ExpectUserDeprecationMessageTrait;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Mapping\AutoMappingStrategy;
use Symfony\Component\Validator\Mapping\CascadingStrategy;
Expand All @@ -36,6 +37,8 @@
*/
class DoctrineLoaderTest extends TestCase
{
use ExpectUserDeprecationMessageTrait;

public function testLoadClassMetadata()
{
$validator = Validation::createValidatorBuilder()
Expand Down Expand Up @@ -155,8 +158,13 @@ public function testExtractEnum()
$this->assertCount(0, $enumStringMetadata); // asserts the length constraint is not added to an enum
}

/**
* @group legacy
*/
public function testFieldMappingsConfiguration()
{
$this->expectUserDeprecationMessage('Since symfony/validator 7.4: XML configuration format is deprecated, use YAML or attributes instead.');

$validator = Validation::createValidatorBuilder()
->enableAttributeMapping()
->addXmlMappings([__DIR__.'/../Resources/validator/BaseUser.xml'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer;

use Symfony\Bridge\PhpUnit\ExpectUserDeprecationMessageTrait;
use Symfony\Bundle\FrameworkBundle\CacheWarmer\SerializerCacheWarmer;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
use Symfony\Component\Cache\Adapter\NullAdapter;
Expand All @@ -21,11 +22,17 @@

class SerializerCacheWarmerTest extends TestCase
{
use ExpectUserDeprecationMessageTrait;

/**
* @group legacy
*
* @dataProvider loaderProvider
*/
public function testWarmUp(array $loaders)
{
$this->expectUserDeprecationMessage('Since symfony/serializer 7.4: XML configuration format is deprecated, use YAML or attributes instead.');

$file = sys_get_temp_dir().'/cache-serializer.php';
@unlink($file);

Expand All @@ -41,10 +48,14 @@ public function testWarmUp(array $loaders)
}

/**
* @group legacy
*
* @dataProvider loaderProvider
*/
public function testWarmUpAbsoluteFilePath(array $loaders)
{
$this->expectUserDeprecationMessage('Since symfony/serializer 7.4: XML configuration format is deprecated, use YAML or attributes instead.');

$file = sys_get_temp_dir().'/0/cache-serializer.php';
@unlink($file);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer;

use Symfony\Bridge\PhpUnit\ExpectUserDeprecationMessageTrait;
use Symfony\Bundle\FrameworkBundle\CacheWarmer\ValidatorCacheWarmer;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
use Symfony\Component\Cache\Adapter\NullAdapter;
Expand All @@ -20,8 +21,15 @@

class ValidatorCacheWarmerTest extends TestCase
{
use ExpectUserDeprecationMessageTrait;

/**
* @group legacy
*/
public function testWarmUp()
{
$this->expectUserDeprecationMessage('Since symfony/validator 7.4: XML configuration format is deprecated, use YAML or attributes instead.');

$validatorBuilder = new ValidatorBuilder();
$validatorBuilder->addXmlMapping(__DIR__.'/../Fixtures/Validation/Resources/person.xml');
$validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/author.yml');
Expand All @@ -42,8 +50,13 @@ public function testWarmUp()
$this->assertTrue($arrayPool->getItem('Symfony.Bundle.FrameworkBundle.Tests.Fixtures.Validation.Author')->isHit());
}

/**
* @group legacy
*/
public function testWarmUpAbsoluteFilePath()
{
$this->expectUserDeprecationMessage('Since symfony/validator 7.4: XML configuration format is deprecated, use YAML or attributes instead.');

$validatorBuilder = new ValidatorBuilder();
$validatorBuilder->addXmlMapping(__DIR__.'/../Fixtures/Validation/Resources/person.xml');
$validatorBuilder->addYamlMapping(__DIR__.'/../Fixtures/Validation/Resources/author.yml');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

/**
* @group legacy
*/
class XmlFrameworkExtensionTest extends FrameworkExtensionTestCase
{
protected function loadFromFile(ContainerBuilder $container, $file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

/**
* @group legacy
*/
class XmlCompleteConfigurationTest extends CompleteConfigurationTestCase
{
public function testFirewallPatterns()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

/**
* @group legacy
*/
class XmlCustomAuthenticatorTest extends TestCase
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

/**
* @group legacy
*/
class XmlCustomProviderTest extends TestCase
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;

class FirewallEntryPointExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
services:
firewall_entry_point.entry_point.stub:
class: Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle\Security\EntryPointStub
Loading
Loading