Skip to content

Commit a6a0dae

Browse files
Merge branch '4.4' into 5.0
* 4.4: (21 commits) fix merge CS [FrameworkBundle][ContainerLintCommand] Improve messages when the kernel or the container is not supported [Serializer] Skip uninitialized (PHP 7.4) properties in PropertyNormalizer and ObjectNormalizer stop using deprecated Doctrine persistence classes [Cache] Fix wrong classname in deprecation message Fix regex lookahead syntax in ApplicationTest Fixed syntax in comment [SecurityBundle][FirewallMap] Remove unused property [Messenger][AMQP] Use delivery_mode=2 by default [FrameworkBundle][DependencyInjection] Skip removed ids in the lint container command and its associated pass [SECURITY] Revert "AbstractAuthenticationListener.php error instead info. Rebase of #28462" [FrameworkBundle][Secrets] Hook configured local dotenv file [DI] Improve performance of processDefinition fix redis multi host dsn not recognized fix constructor argument type declaration Fix invalid Windows path normalization [Validator][ConstraintValidator] Safe fail on invalid timezones [DoctrineBridge] Fixed submitting invalid ids when using queries with limit [FrameworkBundle] Add info & example to auto_mapping config ...
2 parents 0275231 + 4d98786 commit a6a0dae

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
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
}

Compiler/ResolveInstanceofConditionalsPass.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ private function processDefinition(ContainerBuilder $container, string $id, Defi
6363
$instanceofTags = [];
6464
$instanceofCalls = [];
6565
$instanceofBindings = [];
66+
$reflectionClass = null;
6667

6768
foreach ($conditionals as $interface => $instanceofDefs) {
68-
if ($interface !== $class && (!$container->getReflectionClass($class, false))) {
69+
if ($interface !== $class && !(null === $reflectionClass ? $reflectionClass = ($container->getReflectionClass($class, false) ?: false) : $reflectionClass)) {
6970
continue;
7071
}
7172

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)