bug #39861 [DependencyInjection] Skip deprecated definitions in CheckTypeDeclarationsPass (chalasr)
This PR was merged into the 4.4 branch.
Discussion
----------
[DependencyInjection] Skip deprecated definitions in CheckTypeDeclarationsPass
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
When a definition uses a deprecated class , `CheckTypeDeclarationsPass` (with `$autoload = true`) will autoload the class, which triggers a deprecation notice. That breaks the CI in #39802 because the compiler pass is registered inside the SecurityBundle test suite.
I propose to stop checking deprecated definitions. Makes sense?
Commits
-------
531c81a06e
[DI] Skip deprecated definitions in CheckTypeDeclarationsPass
This commit is contained in:
commit
5ba237a8ec
@ -84,7 +84,7 @@ final class CheckTypeDeclarationsPass extends AbstractRecursivePass
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (!$value instanceof Definition || $value->hasErrors()) {
|
||||
if (!$value instanceof Definition || $value->hasErrors() || $value->isDeprecated()) {
|
||||
return parent::processValue($value, $isRoot);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPa
|
||||
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\BarMethodCall;
|
||||
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\BarOptionalArgument;
|
||||
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\BarOptionalArgumentNotNull;
|
||||
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Deprecated;
|
||||
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Foo;
|
||||
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\FooObject;
|
||||
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\UnionConstructor;
|
||||
@ -723,6 +724,19 @@ class CheckTypeDeclarationsPassTest extends TestCase
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function testProcessSkipsDeprecatedDefinitions()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container
|
||||
->register('foobar', Deprecated::class)
|
||||
->setDeprecated(true)
|
||||
;
|
||||
|
||||
(new CheckTypeDeclarationsPass(true))->process($container);
|
||||
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function testProcessHandleClosureForCallable()
|
||||
{
|
||||
$closureDefinition = new Definition(\Closure::class);
|
||||
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass;
|
||||
|
||||
trigger_deprecation('foo/bar', '1.2.3', 'Deprecated class.');
|
||||
|
||||
class Deprecated
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user