Skip to content

Commit 1bad7bd

Browse files
bug #34935 [FrameworkBundle][DependencyInjection] Skip removed ids in the lint container command and its associated pass (fancyweb)
This PR was merged into the 4.4 branch. Discussion ---------- [FrameworkBundle][DependencyInjection] Skip removed ids in the lint container command and its associated pass | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | symfony/symfony#34858 | License | MIT | Doc PR | - We remove the "removing" passes again and to avoid what symfony/symfony#34502 fixed, we skip validating the "live" container removed ids in the pass (the "live" container is supposed to have the same definitions than the "debug container" one). Logically, an errored service cannot pass the "live" container compilation without being removed. Consequently, it also skips the errored services that ended up being removed in the "live" container. Commits ------- a0f581ba9d [FrameworkBundle][DependencyInjection] Skip removed ids in the lint container command and its associated pass
2 parents ce0822d + 79a6314 commit 1bad7bd

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)