Skip to content

Commit 79a6314

Browse files
fancywebnicolas-grekas
authored andcommitted
[FrameworkBundle][DependencyInjection] Skip removed ids in the lint container command and its associated pass
1 parent ef56b33 commit 79a6314

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

Compiler/CheckTypeDeclarationsPass.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,30 @@ final class CheckTypeDeclarationsPass extends AbstractRecursivePass
4242
private const SCALAR_TYPES = ['int', 'float', 'bool', 'string'];
4343

4444
private $autoload;
45+
private $skippedIds;
4546

4647
private $expressionLanguage;
4748

4849
/**
49-
* @param bool $autoload Whether services who's class in not loaded should be checked or not.
50-
* Defaults to false to save loading code during compilation.
50+
* @param bool $autoload Whether services who's class in not loaded should be checked or not.
51+
* Defaults to false to save loading code during compilation.
52+
* @param array $skippedIds An array indexed by the service ids to skip
5153
*/
52-
public function __construct(bool $autoload = false)
54+
public function __construct(bool $autoload = false, array $skippedIds = [])
5355
{
5456
$this->autoload = $autoload;
57+
$this->skippedIds = $skippedIds;
5558
}
5659

5760
/**
5861
* {@inheritdoc}
5962
*/
6063
protected function processValue($value, $isRoot = false)
6164
{
65+
if (isset($this->skippedIds[$this->currentId])) {
66+
return $value;
67+
}
68+
6269
if (!$value instanceof Definition || $value->hasErrors()) {
6370
return parent::processValue($value, $isRoot);
6471
}

Tests/Compiler/CheckTypeDeclarationsPassTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,4 +669,16 @@ public function testProcessHandleNotFoundEnvPlaceholder()
669669

670670
$this->addToAssertionCount(1);
671671
}
672+
673+
public function testProcessSkipSkippedIds()
674+
{
675+
$container = new ContainerBuilder();
676+
$container
677+
->register('foobar', BarMethodCall::class)
678+
->addMethodCall('setArray', ['a string']);
679+
680+
(new CheckTypeDeclarationsPass(true, ['foobar' => true]))->process($container);
681+
682+
$this->addToAssertionCount(1);
683+
}
672684
}

0 commit comments

Comments
 (0)