Skip to content

Commit d6b6816

Browse files
Make it really work on real apps
1 parent 2c7bf8c commit d6b6816

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CHANGELOG
44
4.4.0
55
-----
66

7-
* Added `lint:container` to check that services wiring matches type declarations
7+
* Added `lint:container` command to check that services wiring matches type declarations
88
* Added `MailerAssertionsTrait`
99
* Deprecated support for `templating` engine in `TemplateController`, use Twig instead
1010
* Deprecated the `$parser` argument of `ControllerResolver::__construct()` and `DelegatingLoader::__construct()`

Command/ContainerLintCommand.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\Config\FileLocator;
1616
use Symfony\Component\Console\Command\Command;
1717
use Symfony\Component\Console\Input\InputInterface;
18-
use Symfony\Component\Console\Input\InputOption;
1918
use Symfony\Component\Console\Output\OutputInterface;
2019
use Symfony\Component\DependencyInjection\Compiler\CheckTypeDeclarationsPass;
2120
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
@@ -39,7 +38,6 @@ protected function configure()
3938
$this
4039
->setDescription('Ensures that arguments injected into services match type declarations')
4140
->setHelp('This command parses service definitions and ensures that injected values match the type declarations of each services\' class.')
42-
->addOption('ignore-unused-services', 'o', InputOption::VALUE_NONE, 'Ignore unused services')
4341
;
4442
}
4543

@@ -50,13 +48,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5048
{
5149
$container = $this->getContainerBuilder();
5250

51+
$container->setParameter('container.build_hash', 'lint_container');
52+
$container->setParameter('container.build_time', time());
5353
$container->setParameter('container.build_id', 'lint_container');
5454

55-
$container->addCompilerPass(
56-
new CheckTypeDeclarationsPass(true),
57-
$input->getOption('ignore-unused-services') ? PassConfig::TYPE_AFTER_REMOVING : PassConfig::TYPE_OPTIMIZE,
58-
-5
59-
);
55+
$container->addCompilerPass(new CheckTypeDeclarationsPass(true), PassConfig::TYPE_AFTER_REMOVING, -100);
6056

6157
$container->compile();
6258

Resources/config/validator.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</service>
1818
<service id="Symfony\Component\Validator\Validator\ValidatorInterface" alias="validator" />
1919

20-
<service id="validator.builder" class="Symfony\Component\Validator\ValidatorBuilderInterface">
20+
<service id="validator.builder" class="Symfony\Component\Validator\ValidatorBuilder">
2121
<factory class="Symfony\Component\Validator\Validation" method="createValidatorBuilder" />
2222
<call method="setConstraintValidatorFactory">
2323
<argument type="service" id="validator.validator_factory" />

Tests/Functional/Bundle/TestBundle/TestBundle.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection\AnnotationReaderPass;
1515
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection\Config\CustomConfig;
1616
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection\TranslationDebugPass;
17+
use Symfony\Component\DependencyInjection\Compiler\CheckTypeDeclarationsPass;
18+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1719
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
1820
use Symfony\Component\DependencyInjection\ContainerBuilder;
1921
use Symfony\Component\HttpKernel\Bundle\Bundle;
@@ -31,5 +33,15 @@ public function build(ContainerBuilder $container)
3133

3234
$container->addCompilerPass(new AnnotationReaderPass(), PassConfig::TYPE_AFTER_REMOVING);
3335
$container->addCompilerPass(new TranslationDebugPass());
36+
37+
$container->addCompilerPass(new class() implements CompilerPassInterface {
38+
public function process(ContainerBuilder $container)
39+
{
40+
$container->removeDefinition('twig.controller.exception');
41+
$container->removeDefinition('twig.controller.preview_error');
42+
}
43+
});
44+
45+
$container->addCompilerPass(new CheckTypeDeclarationsPass(true), PassConfig::TYPE_AFTER_REMOVING, -100);
3446
}
3547
}

0 commit comments

Comments
 (0)