8000 [HttpKernel] Deprecate `AddAnnotatedClassesToCachePass` and related c… · symfony/symfony@599867d · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 599867d

Browse files
[HttpKernel] Deprecate AddAnnotatedClassesToCachePass and related code infrastructure
1 parent 749ad6e commit 599867d

File tree

8 files changed

+33
-4
lines changed

8 files changed

+33
-4
lines changed

UPGRADE-7.1.md

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

1212
* Mark classes `ConfigBuilderCacheWarmer`, `Router`, `SerializerCacheWarmer`, `TranslationsCacheWarmer`, `Translator` and `ValidatorCacheWarmer` as `final`
1313

14+
HttpKernel
15+
----------
16+
17+
* Deprecate `Extension::addAnnotatedClassesToCompile()` and related code infrastructure
18+
1419
Messenger
1520
---------
1621

src/Symfony/Component/HttpKernel/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CHANGELOG
77
* Add method `isKernelTerminating()` to `ExceptionEvent` that allows to check if an exception was thrown while the kernel is being terminated
88
* Add `HttpException::fromStatusCode()`
99
* Add `$validationFailedStatusCode` argument to `#[MapQueryParameter]` that allows setting a custom HTTP status code when validation fails
10+
* Deprecate `Extension::addAnnotatedClassesToCompile()` and related code infrastructure
1011

1112
7.0
1213
---

src/Symfony/Component/HttpKernel/DependencyInjection/AddAnnotatedClassesToCachePass.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@
1717
use Symfony\Component\ErrorHandler\DebugClassLoader;
1818
use Symfony\Component\HttpKernel\Kernel;
1919

20+
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);
21+
2022
/**
2123
* Sets the classes to compile in the cache for the container.
2224
*
2325
* @author Fabien Potencier <fabien@symfony.com>
26+
*
27+
* @deprecated since Symfony 7.1, to be removed in 8.0
2428
*/
2529
class AddAnnotatedClassesToCachePass implements CompilerPassInterface
2630
{

src/Symfony/Component/HttpKernel/DependencyInjection/Extension.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* Allow adding classes to the class cache.
1818
*
1919
* @author Fabien Potencier <fabien@symfony.com>
20+
*
21+
* @internal since Symfony 7.1, to be deprecated in 8.1; use Symfony\Component\DependencyInjection\Extension\Extension instead
2022
*/
2123
abstract class Extension extends BaseExtension
2224
{
@@ -26,19 +28,27 @@ abstract class Extension extends BaseExtension
2628
* Gets the annotated classes to cache.
2729
*
2830
* @return string[]
31+
*
32+
* @deprecated since S 8000 ymfony 7.1, to be removed in 8.0
2933
*/
3034
public function getAnnotatedClassesToCompile(): array
3135
{
36+
trigger_deprecation('symfony/http-kernel', '7.1', 'The "%s()" method is deprecated since Symfony 7.1 and will be removed in 8.0.', __METHOD__);
37+
3238
return $this->annotatedClasses;
3339
}
3440

3541
/**
3642
* Adds annotated classes to the class cache.
3743
*
3844
* @param string[] $annotatedClasses An array of class patterns
45+
*
46+
* @deprecated since Symfony 7.1, to be removed in 8.0
3947
*/
4048
public function addAnnotatedClassesToCompile(array $annotatedClasses): void
4149
{
50+
trigger_deprecation('symfony/http-kernel', '7.1', 'The "%s()" method is deprecated since Symfony 7.1 and will be removed in 8.0.', __METHOD__);
51+
4252
$this->annotatedClasses = array_merge($this->annotatedClasses, $annotatedClasses);
4353
}
4454
}

src/Symfony/Component/HttpKernel/Kernel.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
3838
use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;
3939
use Symfony\Component\HttpKernel\Config\FileLocator;
40-
use Symfony\Component\HttpKernel\DependencyInjection\AddAnnotatedClassesToCachePass;
4140
use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass;
4241

4342
// Help opcache.preload discover always-needed symbols
@@ -280,9 +279,13 @@ public function getContainer(): ContainerInterface
280279

281280
/**
282281
* @internal
282+
*
283+
* @deprecated since Symfony 7.1, to be removed in 8.0
283284
*/
284285
public function setAnnotatedClassCache(array $annotatedClasses): void
285286
{
287+
trigger_deprecation('symfony/http-kernel', '7.1', 'The "%s()" method is deprecated since Symfony 7.1 and will be removed in 8.0.', __METHOD__);
288+
286289
file_put_contents(($this->warmupDir ?: $this->getBuildDir()).'/annotations.map', sprintf('<?php return %s;', var_export($annotatedClasses, true)));
287290
}
288291

@@ -316,9 +319,13 @@ public function getCharset(): string
316319
* Gets the patterns defining the classes to parse and cache for annotations.
317320
*
318321
* @return string[]
322+
*
323+
* @deprecated since Symfony 7.1, to be removed in 8.0
319324
*/
320325
public function getAnnotatedClassesToCompile(): array
321326
{
327+
trigger_deprecation('symfony/http-kernel', '7.1', 'The "%s()" method is deprecated since Symfony 7.1 and will be removed in 8.0.', __METHOD__);
328+
322329
return [];
323330
}
324331

@@ -593,8 +600,6 @@ protected function buildContainer(): ContainerBuilder
593600
$this->prepareContainer($container);
594601
$this->registerContainerConfiguration($this->getContainerLoader($container));
595602

596-
$container->addCompilerPass(new AddAnnotatedClassesToCachePass($this));
597-
598603
return $container;
599604
}
600605

src/Symfony/Component/HttpKernel/Tests/DependencyInjection/AddAnnotatedClassesToCachePassTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\HttpKernel\DependencyInjection\AddAnnotatedClassesToCachePass;
1616

17+
/**
18+
* @group legacy
19+
*/
1720
class AddAnnotatedClassesToCachePassTest extends TestCase
1821
{
1922
public function testExpandClasses()

src/Symfony/Component/HttpKernel/Tests/DependencyInjection/MergeExtensionConfigurationPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
use Symfony\Component\DependencyInjection\Extension\Extension;
1617
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
17-
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
1818
use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass;
1919
use Symfony\Component\HttpKernel\Tests\Fixtures\AcmeFooBundle\AcmeFooBundle;
2020

src/Symfony/Component/HttpKernel/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
],
1818
"require": {
1919
"php": ">=8.2",
20+
"symfony/deprecation-contracts": "^2.5|^3",
2021
"symfony/error-handler": "^6.4|^7.0",
2122
"symfony/event-dispatcher": "^6.4|^7.0",
2223
"symfony/http-foundation": "^6.4|^7.0",

0 commit comments

Comments
 (0)
0