8000 bug #39861 [DependencyInjection] Skip deprecated definitions in Check… · symfony/symfony@5ba237a · GitHub
[go: up one dir, main page]

Skip to content

Commit 5ba237a

Browse files
committed
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 ------- 531c81a [DI] Skip deprecated definitions in CheckTypeDeclarationsPass
2 parents 833a9e0 + 531c81a commit 5ba237a

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected function processValue($value, $isRoot = false)
8484
return $value;
8585
}
8686

87-
if (!$value instanceof Definition || $value->hasErrors()) {
87+
if (!$value instanceof Definition || $value->hasErrors() || $value->isDeprecated()) {
8888
return parent::processValue($value, $isRoot);
8989
}
9090

src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckTypeDeclarationsPassTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\BarMethodCall;
2525
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\BarOptionalArgument;
2626
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\BarOptionalArgumentNotNull;
27+
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Deprecated;
2728
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\Foo;
2829
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\FooObject;
2930
use Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass\UnionConstructor;
@@ -723,6 +724,19 @@ public function testProcessSkipSkippedIds()
723724
$this->addToAssertionCount(1);
724725
}
725726

727+
public function testProcessSkipsDeprecatedDefinitions()
728+
{
729+
$container = new ContainerBuilder();
730+
$container
731+
->register('foobar', Deprecated::class)
732+
->setDeprecated(true)
733+
;
734+
735+
(new CheckTypeDeclarationsPass(true))->process($container);
736+
737+
$this->addToAssertionCount(1);
738+
}
739+
726740
public function testProcessHandleClosureForCallable()
727741
{
728742
$closureDefinition = new Definition(\Closure::class);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\CheckTypeDeclarationsPass;
4+
5+
trigger_deprecation('foo/bar', '1.2.3', 'Deprecated class.');
6+
7+
class Deprecated
8+
{
9+
}

0 commit comments

Comments
 (0)
0