Skip to content

Commit 25e957f

Browse files
Merge branch '4.4'
* 4.4: (39 commits) [Console] Fix #33915, Detect dimensions using mode CON if vt100 is supported [PhpUnitBridge] Also search for composer.phar in git root folder [HttpKernel][DataCollectorInterface] Ease compatibility Add tests to ensure defaultLocale is properly passed to the URL generator [DependencyInjection] Fix broken references in tests [VarDumper] display the method we're in when dumping stack traces [HttpClient] Retry safe requests when then fail before the body arrives [Console] Rename some methods related to redraw frequency Avoid using of kernel after shutdown Simplify PHP CS Fixer configuration [PropertyInfo] Fixed type extraction for nullable collections of non-nullable elements [FrameworkBundle] [HttpKernel] fixed correct EOL and EOM month Fix CS [Serializer] Fix property name usage for denormalization Name test accordingly to the tested class Fix MockFileSessionStorageTest::sessionDir being used after it's unset [Security] Fix SwitchUserToken wrongly deauthenticated Supporting Bootstrap 4 custom switches Add new Form WeekType bumped Symfony version to 4.3.7 ...
2 parents 3468318 + 41dc9ca commit 25e957f

File tree

7 files changed

+107
-1
lines changed

7 files changed

+107
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ CHANGELOG
2424
4.4.0
2525
-----
2626

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

Command/AboutCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private static function formatFileSize(string $path): string
125125

126126
private static function isExpired(string $date): bool
127127
{
128-
$date = \DateTime::createFromFormat('m/Y', $date);
128+
$date = \DateTime::createFromFormat('d/m/Y', '01/'.$date);
129129

130130
return false !== $date && new \DateTime() > $date->modify('last day of this month 23:59:59');
131131
}

Command/ContainerLintCommand.php

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\Command;
13+
14+
use Symfony\Component\Config\ConfigCache;
15+
use Symfony\Component\Config\FileLocator;
16+
use Symfony\Component\Console\Command\Command;
17+
use Symfony\Component\Console\Input\InputInterface;
18+
use Symfony\Component\Console\Output\OutputInterface;
19+
use Symfony\Component\DependencyInjection\Compiler\CheckTypeDeclarationsPass;
20+
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
21+
use Symfony\Component\DependencyInjection\ContainerBuilder;
22+
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
23+
24+
final class ContainerLintCommand extends Command
25+
{
26+
protected static $defaultName = 'lint:container';
27+
28+
/**
29+
* @var ContainerBuilder
30+
*/
31+
private $containerBuilder;
32+
33+
/**
34+
* {@inheritdoc}
35+
*/
36+
protected function configure()
37+
{
38+
$this
39+
->setDescription('Ensures that arguments injected into services match type declarations')
40+
->setHelp('This command parses service definitions and ensures that injected values match the type declarations of each services\' class.')
41+
;
42+
}
43+
44+
/**
45+
* {@inheritdoc}
46+
*/
47+
protected function execute(InputInterface $input, OutputInterface $output): int
48+
{
49+
$container = $this->getContainerBuilder();
50+
51+
$container->setParameter('container.build_hash', 'lint_container');
52+
$container->setParameter('container.build_time', time());
53+
$container->setParameter('container.build_id', 'lint_container');
54+
55+
$container->addCompilerPass(new CheckTypeDeclarationsPass(true), PassConfig::TYPE_AFTER_REMOVING, -100);
56+
57+
$container->compile();
58+
59+
return 0;
60+
}
61+
62+
private function getContainerBuilder(): ContainerBuilder
63+
{
64+
if ($this->containerBuilder) {
65+
return $this->containerBuilder;
66+
}
67+
68+
$kernel = $this->getApplication()->getKernel();
69+
70+
if (!$kernel->isDebug() || !(new ConfigCache($kernel->getContainer()->getParameter('debug.container.dump'), true))->isFresh()) {
71+
$buildContainer = \Closure::bind(function () { return $this->buildContainer(); }, $kernel, \get_class($kernel));
72+
$container = $buildContainer();
73+
$container->getCompilerPassConfig()->setRemovingPasses([]);
74+
} else {
75+
(new XmlFileLoader($container = new ContainerBuilder(), new FileLocator()))->load($kernel->getContainer()->getParameter('debug.container.dump'));
76+
}
77+
78+
return $this->containerBuilder = $container;
79+
}
80+
}

Resources/config/console.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@
7070
<tag name="console.command" command="debug:container" />
7171
</service>
7272

73+
<service id="console.command.container_lint" class="Symfony\Bundle\FrameworkBundle\Command\ContainerLintCommand">
74+
<tag name="console.command" command="lint:container" />
75+
</service>
76+
7377
<service id="console.command.debug_autowiring" class="Symfony\Bundle\FrameworkBundle\Command\DebugAutowiringCommand">
7478
<argument>null</argument>
7579
<argument type="service" id="debug.file_link_formatter" on-invalid="null"/>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php if ($widget == 'single_text'): ?>
2+
<?php echo $view['form']->block($form, 'form_widget_simple'); ?>
3+
<?php else: ?>
4+
<?php $vars = $widget == 'text' ? ['attr' => ['size' => 1]] : [] ?>
5+
<div <?php echo $view['form']->block($form, 'widget_container_attributes') ?>>
6+
<?php
7+
// There should be no spaces between the colons and the widgets, that's why
8+
// this block is written in a single PHP tag
9+
echo $view['form']->widget($form['year'], $vars);
10+
echo '-';
11+
echo $view['form']->widget($form['week'], $vars);
12+
?>
13+
</div>
14+
<?php endif ?>

Test/KernelTestCase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ abstract class KernelTestCase extends TestCase
4242
protected function tearDown(): void
4343
{
4444
static::ensureKernelShutdown();
45+
static::$kernel = null;
4546
}
4647

4748
/**

Tests/Functional/Bundle/TestBundle/TestBundle.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection\AnnotationReaderPass;
1515
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection\Config\CustomConfig;
16+
use Symfony\Component\DependencyInjection\Compiler\CheckTypeDeclarationsPass;
1617
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
1718
use Symfony\Component\DependencyInjection\ContainerBuilder;
1819
use Symfony\Component\HttpKernel\Bundle\Bundle;
@@ -23,11 +24,16 @@ public function build(ContainerBuilder $container)
2324
{
2425
parent::build($container);
2526

27+
$container->setParameter('container.build_hash', 'test_bundle');
28+
$container->setParameter('container.build_time', time());
29+
$container->setParameter('container.build_id', 'test_bundle');
30+
2631
/** @var $extension DependencyInjection\TestExtension */
2732
$extension = $container->getExtension('test');
2833

2934
$extension->setCustomConfig(new CustomConfig());
3035

3136
$container->addCompilerPass(new AnnotationReaderPass(), PassConfig::TYPE_AFTER_REMOVING);
37+
$container->addCompilerPass(new CheckTypeDeclarationsPass(true), PassConfig::TYPE_AFTER_REMOVING, -100);
3238
}
3339
}

0 commit comments

Comments
 (0)