Skip to content

Commit 1c6cd99

Browse files
committed
[DI] Skip deprecated definitions in CheckTypeDeclarationsPass
1 parent 72a5b41 commit 1c6cd99

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

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

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)