Skip validation of services that make the CI fail

This commit is contained in:
Nicolas Grekas 2019-11-06 17:48:56 +01:00
parent a1155ea6e2
commit 403fdf4a59
3 changed files with 12 additions and 4 deletions

View File

@ -18,6 +18,7 @@ use Symfony\Component\DependencyInjection\Compiler\CheckTypeDeclarationsPass;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class TestBundle extends Bundle
@ -29,6 +30,12 @@ class TestBundle extends Bundle
/** @var $extension DependencyInjection\TestExtension */
$extension = $container->getExtension('test');
if (!$container->getParameterBag() instanceof FrozenParameterBag) {
$container->setParameter('container.build_hash', 'test_bundle');
$container->setParameter('container.build_time', time());
$container->setParameter('container.build_id', 'test_bundle');
}
$extension->setCustomConfig(new CustomConfig());
$container->addCompilerPass(new AnnotationReaderPass(), PassConfig::TYPE_AFTER_REMOVING);
@ -42,6 +49,6 @@ class TestBundle extends Bundle
}
});
$container->addCompilerPass(new CheckTypeDeclarationsPass(true), PassConfig::TYPE_AFTER_REMOVING, -100);
$container->addCompilerPass(new CheckTypeDeclarationsPass(true, ['http_client', '.debug.http_client']), PassConfig::TYPE_AFTER_REMOVING, -100);
}
}

View File

@ -12,5 +12,4 @@
return [
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\TestBundle(),
];

View File

@ -37,14 +37,16 @@ final class CheckTypeDeclarationsPass extends AbstractRecursivePass
private const SCALAR_TYPES = ['int', 'float', 'bool', 'string'];
private $autoload;
private $ignoredServices;
/**
* @param bool $autoload Whether services who's class in not loaded should be checked or not.
* Defaults to false to save loading code during compilation.
*/
public function __construct(bool $autoload = false)
public function __construct(bool $autoload = false, array $ignoredServices = [])
{
$this->autoload = $autoload;
$this->ignoredServices = array_flip($ignoredServices);
}
/**
@ -52,7 +54,7 @@ final class CheckTypeDeclarationsPass extends AbstractRecursivePass
*/
protected function processValue($value, $isRoot = false)
{
if (!$value instanceof Definition) {
if (!$value instanceof Definition || isset($this->ignoredServices[$this->currentId])) {
return parent::processValue($value, $isRoot);
}