Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ef95928

Browse files
nicolas-grekasfabpot
authored andcommitted
[HttpKernel] Deprecate AddAnnotatedClassesToCachePass and related code infrastructure
1 parent 7bedfa0 commit ef95928

File tree

8 files changed

+33
-4
lines changed

8 files changed

+33
-4
lines changed

UPGRADE-7.1.md

+5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ PropertyInfo
3737

3838
* Deprecate `PropertyTypeExtractorInterface::getTypes()`, use `PropertyTypeExtractorInterface::getType()` instead
3939

40+
HttpKernel
41+
----------
42+
43+
* Deprecate `Extension::addAnnotatedClassesToCompile()` and related code infrastructure
44+
4045
SecurityBundle
4146
--------------
4247

src/Symfony/Component/HttpKernel/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CHANGELOG
99
* Add `$validationFailedStatusCode` argument to `#[MapQueryParameter]` that allows setting a custom HTTP status code when validation fails
1010
* Add `NearMissValueResolverException` to let value resolvers report when an argument could be under their watch but failed to be resolved
1111
* Add `$type` argument to `#[MapRequestPayload]` that allows mapping a list of items
12+
* Deprecate `Extension::addAnnotatedClassesToCompile()` and related code infrastructure
1213

1314
7.0
1415
---

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

+4
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 <[email protected]>
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

+10
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 <[email protected]>
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 Symfony 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

+8-3
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
@@ -278,9 +277,13 @@ public function getContainer(): ContainerInterface
278277

279278
/**
280279
* @internal
280+
*
281+
* @deprecated since Symfony 7.1, to be removed in 8.0
281282
*/
282283
public function setAnnotatedClassCache(array $annotatedClasses): void
283284
{
285+
trigger_deprecation('symfony/http-kernel', '7.1', 'The "%s()" method is deprecated since Symfony 7.1 and will be removed in 8.0.', __METHOD__);
286+
284287
file_put_contents(($this->warmupDir ?: $this->getBuildDir()).'/annotations.map', sprintf('<?php return %s;', var_export($annotatedClasses, true)));
285288
}
286289

@@ -314,9 +317,13 @@ public function getCharset(): string
314317
* Gets the patterns defining the classes to parse and cache for annotations.
315318
*
316319
* @return string[]
320+
*
321+
* @deprecated since Symfony 7.1, to be removed in 8.0
317322
*/
318323
public function getAnnotatedClassesToCompile(): array
319324
{
325+
trigger_deprecation('symfony/http-kernel', '7.1', 'The "%s()" method is deprecated since Symfony 7.1 and will be removed in 8.0.', __METHOD__);
326+
320327
return [];
321328
}
322329

@@ -591,8 +598,6 @@ protected function buildContainer(): ContainerBuilder
591598
$this->prepareContainer($container);
592599
$this->registerContainerConfiguration($this->getContainerLoader($container));
593600

594-
$container->addCompilerPass(new AddAnnotatedClassesToCachePass($this));
595-
596601
return $container;
597602
}
598603

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

+3
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

+1-1
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

+1
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)