diff --git a/src/Symfony/Component/Config/CHANGELOG.md b/src/Symfony/Component/Config/CHANGELOG.md index e38639e4d1ae8..a610bd5601d93 100644 --- a/src/Symfony/Component/Config/CHANGELOG.md +++ b/src/Symfony/Component/Config/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +7.3 +--- + + * Deprecate XmlUtils::parse(), XmlUtils::loadFile(), XmlUtils::convertDomElementToArray() + 7.2 --- diff --git a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php index 2bc31e3bba421..77091c95af551 100644 --- a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php +++ b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php @@ -17,6 +17,9 @@ class XmlUtilsTest extends TestCase { + /** + * @group legacy + */ public function testLoadFile() { $fixtures = __DIR__.'/../Fixtures/Util/'; @@ -90,6 +93,9 @@ public function testLoadFile() $this->assertSame([], libxml_get_errors()); } + /** + * @group legacy + */ public function testParseWithInvalidValidatorCallable() { $fixtures = __DIR__.'/../Fixtures/Util/'; @@ -103,6 +109,9 @@ public function testParseWithInvalidValidatorCallable() XmlUtils::parse(file_get_contents($fixtures.'valid.xml'), [$mock, 'validate']); } + /** + * @group legacy + */ public function testLoadFileWithInternalErrorsEnabled() { $internalErrors = libxml_use_internal_errors(true); @@ -117,6 +126,8 @@ public function testLoadFileWithInternalErrorsEnabled() /** * @dataProvider getDataForConvertDomToArray + * + * @group legacy */ public function testConvertDomToArray($expected, string $xml, bool $root = false, bool $checkPrefix = true) { @@ -191,6 +202,9 @@ public static function getDataForPhpize(): array ]; } + /** + * @group legacy + */ public function testLoadEmptyXmlFile() { $file = __DIR__.'/../Fixtures/foo.xml'; @@ -202,13 +216,16 @@ public function testLoadEmptyXmlFile() } // test for issue https://github.com/symfony/symfony/issues/9731 + /** + * @group legacy + */ public function testLoadWrongEmptyXMLWithErrorHandler() { $errorReporting = error_reporting(-1); set_error_handler(function ($errno, $errstr) { throw new \Exception($errstr, $errno); - }); + }, \E_ERROR); $file = __DIR__.'/../Fixtures/foo.xml'; try { diff --git a/src/Symfony/Component/Config/Util/XmlUtils.php b/src/Symfony/Component/Config/Util/XmlUtils.php index 02ebe7dbe28cd..951dfacee0bd9 100644 --- a/src/Symfony/Component/Config/Util/XmlUtils.php +++ b/src/Symfony/Component/Config/Util/XmlUtils.php @@ -153,9 +153,13 @@ public static function loadFile(string $file, string|callable|null $schemaOrCall * * @param \DOMElement $element A \DOMElement instance * @param bool $checkPrefix Check prefix in an element or an attribute name + * + * @deprecated since Symfony 7.3 */ public static function convertDomElementToArray(\DOMElement $element, bool $checkPrefix = true): mixed { + trigger_deprecation('symfony/config', '7.3', \sprintf('The "%s" method is deprecated.', __METHOD__)); + $prefix = $element->prefix; $empty = true; $config = []; diff --git a/src/Symfony/Component/DependencyInjection/CHANGELOG.md b/src/Symfony/Component/DependencyInjection/CHANGELOG.md index 4287747ec4309..32e2a4538fab5 100644 --- a/src/Symfony/Component/DependencyInjection/CHANGELOG.md +++ b/src/Symfony/Component/DependencyInjection/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +7.3 +--- + + * Deprecate XmlDumper and XmlFileLoader + 7.2 --- diff --git a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php index 7c38455b5876c..efa38f55e0df0 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php @@ -17,6 +17,7 @@ use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument; use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Exception\RuntimeException; @@ -29,11 +30,21 @@ * * @author Fabien Potencier * @author Martin Hasoň + * + * @deprecated since Symfony 7.3 */ class XmlDumper extends Dumper { private \DOMDocument $document; + public function __construct( + protected ContainerBuilder $container, + ) { + trigger_deprecation('symfony/dependency-injection', '7.3', \sprintf('The "%s" class is deprecated.', __CLASS__)); + + parent::__construct($container); + } + /** * Dumps the service container as an XML string. */ diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index f596980663f15..c523183278c8f 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection\Loader; +use Symfony\Component\Config\FileLocatorInterface; use Symfony\Component\Config\Util\XmlUtils; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Argument\AbstractArgument; @@ -34,6 +35,8 @@ * XmlFileLoader loads XML files service definitions. * * @author Fabien Potencier + * + * @deprecated since Symfony 7.3 */ class XmlFileLoader extends FileLoader { @@ -41,6 +44,17 @@ class XmlFileLoader extends FileLoader protected bool $autoRegisterAliasesForSinglyImplementedInterfaces = false; + public function __construct( + protected ContainerBuilder $container, + FileLocatorInterface $locator, + ?string $env = null, + protected bool $prepend = false, + ) { + trigger_deprecation('symfony/dependency-injection', '7.3', \sprintf('The "%s" class is deprecated.', __CLASS__)); + + parent::__construct($container, $locator, $env, $prepend); + } + public function load(mixed $resource, ?string $type = null): mixed { $path = $this->locator->locate($resource); diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index a4a93f63a415f..19c325c19c99a 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -340,7 +340,7 @@ private function isUsingShortSyntax(array $service): bool private function parseDefinition(string $id, array|string|null $service, string $file, array $defaults, bool $return = false, bool $trackBindings = true): Definition|Alias|null { if (preg_match('/^_[a-zA-Z0-9_]*$/', $id)) { - throw new InvalidArgumentException(\sprintf('Service names that start with an underscore are reserved. Rename the "%s" service or define it in XML instead.', $id)); + throw new InvalidArgumentException(\sprintf('Service names that start with an underscore are reserved. Rename the "%s" service.', $id)); } if (\is_string($service) && str_starts_with($service, '@')) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php index f6aafdec910c5..29fb431ac21cc 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AutowirePassTest.php @@ -29,7 +29,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Exception\AutowiringFailedException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; -use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Tests\Fixtures\BarInterface; use Symfony\Component\DependencyInjection\Tests\Fixtures\CaseSensitiveClass; @@ -992,8 +992,8 @@ public function testExceptionWhenAliasDoesNotExist() public function testInlineServicesAreNotCandidates() { $container = new ContainerBuilder(); - $loader = new XmlFileLoader($container, new FileLocator(realpath(__DIR__.'/../Fixtures/xml'))); - $loader->load('services_inline_not_candidate.xml'); + $loader = new YamlFileLoader($container, new FileLocator(realpath(__DIR__.'/../Fixtures/yaml'))); + $loader->load('services_inline_not_candidate.yml'); $pass = new AutowirePass(); $pass->process($container); diff --git a/src/Symfony/Component/DependencyInjection/Tests/CrossCheckTest.php b/src/Symfony/Component/DependencyInjection/Tests/CrossCheckTest.php index db17da4082f56..4b39b73ccc3ab 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/CrossCheckTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/CrossCheckTest.php @@ -32,6 +32,10 @@ public static function setUpBeforeClass(): void */ public function testCrossCheck($fixture, $type) { + if ('xml' === $type) { + $this->markTestSkipped('XmlFileLoader is deprecated.'); + } + $loaderClass = 'Symfony\\Component\\DependencyInjection\\Loader\\'.ucfirst($type).'FileLoader'; $dumperClass = 'Symfony\\Component\\DependencyInjection\\Dumper\\'.ucfirst($type).'Dumper'; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php index 548e5a18b27ec..f43bab49d150c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php @@ -30,6 +30,9 @@ use Symfony\Component\DependencyInjection\Tests\Fixtures\FooUnitEnum; use Symfony\Component\DependencyInjection\Tests\Fixtures\FooWithAbstractArgument; +/** + * @group legacy + */ class XmlDumperTest extends TestCase { protected static string $fixturesPath; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_inline_not_candidate.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_inline_not_candidate.xml deleted file mode 100644 index e6857813c6a67..0000000000000 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_inline_not_candidate.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_inline_not_candidate.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_inline_not_candidate.yml new file mode 100644 index 0000000000000..b47d56c563061 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_inline_not_candidate.yml @@ -0,0 +1,11 @@ + +services: + foo: + class: stdClass + arguments: + - !service + class: Symfony\Component\DependencyInjection\Tests\Compiler\D + + autowired: + class: Symfony\Component\DependencyInjection\Tests\Compiler\E + autowire: true diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php index f962fa1062bb5..c64bc67be0841 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -50,6 +50,9 @@ use Symfony\Component\DependencyInjection\Tests\Fixtures\RemoteCallerSocket; use Symfony\Component\ExpressionLanguage\Expression; +/** + * @group legacy + */ class XmlFileLoaderTest extends TestCase { use ExpectUserDeprecationMessageTrait; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index 8da59796ee1f6..e3c6fde1ec6b6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -121,7 +121,7 @@ public function testLoadImports() $container = new ContainerBuilder(); $resolver = new LoaderResolver([ new IniFileLoader($container, new FileLocator(self::$fixturesPath.'/ini')), - new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')), + // deprecated new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')), new PhpFileLoader($container, new FileLocator(self::$fixturesPath.'/php')), $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')), ]); @@ -381,8 +381,8 @@ public function testSupports() $this->assertTrue($loader->supports('foo.yml'), '->supports() returns true if the resource is loadable'); $this->assertTrue($loader->supports('foo.yaml'), '->supports() returns true if the resource is loadable'); $this->assertFalse($loader->supports('foo.foo'), '->supports() returns false if the resource is not loadable'); - $this->assertTrue($loader->supports('with_wrong_ext.xml', 'yml'), '->supports() returns true if the resource with forced type is loadable'); - $this->assertTrue($loader->supports('with_wrong_ext.xml', 'yaml'), '->supports() returns true if the resource with forced type is loadable'); + // $this->assertTrue($loader->supports('with_wrong_ext.xml', 'yml'), '->supports() returns true if the resource with forced type is loadable'); + // $this->assertTrue($loader->supports('with_wrong_ext.xml', 'yaml'), '->supports() returns true if the resource with forced type is loadable'); } public function testNonArrayTagsThrowsException() @@ -767,7 +767,7 @@ public function testInvalidTagsWithDefaults() public function testUnderscoreServiceId() { $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('Service names that start with an underscore are reserved. Rename the "_foo" service or define it in XML instead.'); + $this->expectExceptionMessage('Service names that start with an underscore are reserved. Rename the "_foo" service.'); $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); $loader->load('services_underscore.yml'); diff --git a/src/Symfony/Component/Routing/CHANGELOG.md b/src/Symfony/Component/Routing/CHANGELOG.md index 7c4614059fe3d..59e6c3b094ec6 100644 --- a/src/Symfony/Component/Routing/CHANGELOG.md +++ b/src/Symfony/Component/Routing/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +7.3 +--- + + * Deprecate XmlFileLoader + 7.2 --- diff --git a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php index 4a80b2965bdd9..f5013adcf8b9d 100644 --- a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php @@ -41,7 +41,7 @@ public function __construct( protected FileLocatorInterface $locator, ?string $env = null, ) { - trigger_deprecation('symfony/routing', '7.3', 'The "%s" class is deprecated.', __CLASS__); + trigger_deprecation('symfony/routing', '7.3', \sprintf('The "%s" class is deprecated.', __CLASS__)); parent::__construct($locator, $env); } diff --git a/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd b/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd index 1b24dfdc89695..c3e0682fa5a6c 100644 --- a/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd +++ b/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd @@ -12,6 +12,8 @@ This scheme defines the elements and attributes that can be used to define routes. A route maps an HTTP request to a set of configuration variables. + + This schema is deprecated since Symfony 7.3. ]]> diff --git a/src/Symfony/Component/Serializer/CHANGELOG.md b/src/Symfony/Component/Serializer/CHANGELOG.md index 4c36d5885a6dd..914250118836a 100644 --- a/src/Symfony/Component/Serializer/CHANGELOG.md +++ b/src/Symfony/Component/Serializer/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +7.3 +--- + + * Deprecate XmlFileLoader + 7.2 --- diff --git a/src/Symfony/Component/Serializer/Mapping/Loader/XmlFileLoader.php b/src/Symfony/Component/Serializer/Mapping/Loader/XmlFileLoader.php index 44ba89df18072..ff128a68636a9 100644 --- a/src/Symfony/Component/Serializer/Mapping/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/Serializer/Mapping/Loader/XmlFileLoader.php @@ -23,6 +23,8 @@ * Loads XML mapping files. * * @author Kévin Dunglas + * + * @deprecated since Symfony 7.3 */ class XmlFileLoader extends FileLoader { @@ -33,6 +35,14 @@ class XmlFileLoader extends FileLoader */ private ?array $classes = null; + public function __construct( + protected string $file, + ) { + trigger_deprecation('symfony/serializer', '7.3', \sprintf('The "%s" class is deprecated.', __CLASS__)); + + parent::__construct($file); + } + public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool { if (!$this->classes ??= $this->getClassesFromXml()) { diff --git a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/XmlFileLoaderTest.php index c0298129efa59..d65b27566f661 100644 --- a/src/Symfony/Component/Serializer/Tests/Mapping/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Mapping/Loader/XmlFileLoaderTest.php @@ -31,6 +31,8 @@ /** * @author Kévin Dunglas + * + * @group legacy */ class XmlFileLoaderTest extends TestCase { diff --git a/src/Symfony/Component/Validator/CHANGELOG.md b/src/Symfony/Component/Validator/CHANGELOG.md index 6b5be184c0101..bd116357a65e3 100644 --- a/src/Symfony/Component/Validator/CHANGELOG.md +++ b/src/Symfony/Component/Validator/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +7.3 +--- + + * Deprecate XmlFileLoader and XmlFilesLoader + 7.2 --- diff --git a/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php b/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php index 83a14b2e8c75e..0258591cfea51 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php @@ -20,6 +20,8 @@ * Loads validation metadata from an XML file. * * @author Bernhard Schussek + * + * @deprecated since Symfony 7.3 */ class XmlFileLoader extends FileLoader { @@ -30,9 +32,12 @@ class XmlFileLoader extends FileLoader */ protected array $classes; - public function __construct(string $file) - { - $this->file = $file; + public function __construct( + protected string $file, + ) { + trigger_deprecation('symfony/validator', '7.3', \sprintf('The "%s" class is deprecated.', __CLASS__)); + + parent::__construct($file); } public function loadClassMetadata(ClassMetadata $metadata): bool diff --git a/src/Symfony/Component/Validator/Mapping/Loader/XmlFilesLoader.php b/src/Symfony/Component/Validator/Mapping/Loader/XmlFilesLoader.php index aab15762da41f..cdd3b65cb8f4a 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/XmlFilesLoader.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/XmlFilesLoader.php @@ -18,9 +18,18 @@ * @author Bernhard Schussek * * @see FilesLoader + * + * @deprecated since Symfony 7.3 */ class XmlFilesLoader extends FilesLoader { + public function __construct(array $paths) + { + trigger_deprecation('symfony/validator', '7.3', \sprintf('The "%s" class is deprecated.', __CLASS__)); + + parent::__construct($paths); + } + public function getFileLoaderInstance(string $file): LoaderInterface { return new XmlFileLoader($file); diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php index 2385dc888b276..5e2e26c512c4c 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php @@ -35,6 +35,9 @@ use Symfony\Component\Validator\Tests\Mapping\Loader\Fixtures\ConstraintWithNamedArguments; use Symfony\Component\Validator\Tests\Mapping\Loader\Fixtures\ConstraintWithoutValueWithNamedArguments; +/** + * @group legacy + */ class XmlFileLoaderTest extends TestCase { public function testLoadClassMetadataReturnsTrueIfSuccessful()