diff --git a/UPGRADE-7.1.md b/UPGRADE-7.1.md index fca6dbb4a8547..8cbff1f03be81 100644 --- a/UPGRADE-7.1.md +++ b/UPGRADE-7.1.md @@ -37,6 +37,11 @@ PropertyInfo * Deprecate `PropertyTypeExtractorInterface::getTypes()`, use `PropertyTypeExtractorInterface::getType()` instead +HttpKernel +---------- + + * Deprecate `Extension::addAnnotatedClassesToCompile()` and related code infrastructure + SecurityBundle -------------- diff --git a/src/Symfony/Component/HttpKernel/CHANGELOG.md b/src/Symfony/Component/HttpKernel/CHANGELOG.md index f639e2ada7517..2e79d13b66d95 100644 --- a/src/Symfony/Component/HttpKernel/CHANGELOG.md +++ b/src/Symfony/Component/HttpKernel/CHANGELOG.md @@ -9,6 +9,7 @@ CHANGELOG * Add `$validationFailedStatusCode` argument to `#[MapQueryParameter]` that allows setting a custom HTTP status code when validation fails * Add `NearMissValueResolverException` to let value resolvers report when an argument could be under their watch but failed to be resolved * Add `$type` argument to `#[MapRequestPayload]` that allows mapping a list of items + * Deprecate `Extension::addAnnotatedClassesToCompile()` and related code infrastructure 7.0 --- diff --git a/src/Symfony/Component/HttpKernel/DependencyInjection/AddAnnotatedClassesToCachePass.php b/src/Symfony/Component/HttpKernel/DependencyInjection/AddAnnotatedClassesToCachePass.php index 1fa529947725b..c8ed6b8e41b33 100644 --- a/src/Symfony/Component/HttpKernel/DependencyInjection/AddAnnotatedClassesToCachePass.php +++ b/src/Symfony/Component/HttpKernel/DependencyInjection/AddAnnotatedClassesToCachePass.php @@ -17,10 +17,14 @@ use Symfony\Component\ErrorHandler\DebugClassLoader; use Symfony\Component\HttpKernel\Kernel; +trigger_deprecation('symfony/http-kernel', '7.1', 'The "%s" class is deprecated since Symfony 7.1 and will be removed in 8.0.', AddAnnotatedClassesToCachePass::class); + /** * Sets the classes to compile in the cache for the container. * * @author Fabien Potencier + * + * @deprecated since Symfony 7.1, to be removed in 8.0 */ class AddAnnotatedClassesToCachePass implements CompilerPassInterface { diff --git a/src/Symfony/Component/HttpKernel/DependencyInjection/Extension.php b/src/Symfony/Component/HttpKernel/DependencyInjection/Extension.php index a70edad6875cc..87b81a8c5e689 100644 --- a/src/Symfony/Component/HttpKernel/DependencyInjection/Extension.php +++ b/src/Symfony/Component/HttpKernel/DependencyInjection/Extension.php @@ -17,6 +17,8 @@ * Allow adding classes to the class cache. * * @author Fabien Potencier + * + * @internal since Symfony 7.1, to be deprecated in 8.1; use Symfony\Component\DependencyInjection\Extension\Extension instead */ abstract class Extension extends BaseExtension { @@ -26,9 +28,13 @@ abstract class Extension extends BaseExtension * Gets the annotated classes to cache. * * @return string[] + * + * @deprecated since Symfony 7.1, to be removed in 8.0 */ public function getAnnotatedClassesToCompile(): array { + trigger_deprecation('symfony/http-kernel', '7.1', 'The "%s()" method is deprecated since Symfony 7.1 and will be removed in 8.0.', __METHOD__); + return $this->annotatedClasses; } @@ -36,9 +42,13 @@ public function getAnnotatedClassesToCompile(): array * Adds annotated classes to the class cache. * * @param string[] $annotatedClasses An array of class patterns + * + * @deprecated since Symfony 7.1, to be removed in 8.0 */ public function addAnnotatedClassesToCompile(array $annotatedClasses): void { + trigger_deprecation('symfony/http-kernel', '7.1', 'The "%s()" method is deprecated since Symfony 7.1 and will be removed in 8.0.', __METHOD__); + $this->annotatedClasses = array_merge($this->annotatedClasses, $annotatedClasses); } } diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 6323a84aec9ad..6816457cbee87 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -37,7 +37,6 @@ use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface; use Symfony\Component\HttpKernel\Config\FileLocator; -use Symfony\Component\HttpKernel\DependencyInjection\AddAnnotatedClassesToCachePass; use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; // Help opcache.preload discover always-needed symbols @@ -278,9 +277,13 @@ public function getContainer(): ContainerInterface /** * @internal + * + * @deprecated since Symfony 7.1, to be removed in 8.0 */ public function setAnnotatedClassCache(array $annotatedClasses): void { + trigger_deprecation('symfony/http-kernel', '7.1', 'The "%s()" method is deprecated since Symfony 7.1 and will be removed in 8.0.', __METHOD__); + file_put_contents(($this->warmupDir ?: $this->getBuildDir()).'/annotations.map', sprintf('prepareContainer($container); $this->registerContainerConfiguration($this->getContainerLoader($container)); - $container->addCompilerPass(new AddAnnotatedClassesToCachePass($this)); - return $container; } diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/AddAnnotatedClassesToCachePassTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/AddAnnotatedClassesToCachePassTest.php index ad8904902a426..387a5108ec324 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/AddAnnotatedClassesToCachePassTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/AddAnnotatedClassesToCachePassTest.php @@ -14,6 +14,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpKernel\DependencyInjection\AddAnnotatedClassesToCachePass; +/** + * @group legacy + */ class AddAnnotatedClassesToCachePassTest extends TestCase { public function testExpandClasses() diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php index ac2264f3b224a..35be55db7f3ac 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php @@ -13,8 +13,8 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; use Symfony\Component\HttpKernel\Tests\Fixtures\AcmeFooBundle\AcmeFooBundle; diff --git a/src/Symfony/Component/HttpKernel/composer.json b/src/Symfony/Component/HttpKernel/composer.json index 62d5f3eec7a56..1a06898eac44f 100644 --- a/src/Symfony/Component/HttpKernel/composer.json +++ b/src/Symfony/Component/HttpKernel/composer.json @@ -17,6 +17,7 @@ ], "require": { "php": ">=8.2", + "symfony/deprecation-contracts": "^2.5|^3", "symfony/error-handler": "^6.4|^7.0", "symfony/event-dispatcher": "^6.4|^7.0", "symfony/http-foundation": "^6.4|^7.0",