8000 Merge branch '4.4' into patch-6 · symfony/symfony@a2fe33d · GitHub
[go: up one dir, main page]

Skip to content

Commit a2fe33d

Browse files
authored
Merge branch '4.4' into patch-6
2 parents c0ad0d8 + a78fb18 commit a2fe33d

File tree

11 files changed

+194
-16
lines changed

11 files changed

+194
-16
lines changed

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,22 +132,28 @@
132132
{% endblock %}
133133

134134
{% block form_widget_simple -%}
135-
{% if type is not defined or type != 'hidden' %}
136-
{%- set attr = attr|merge({class: (attr.class|default('') ~ (type|default('') == 'file' ? ' custom-file-input' : ' form-control'))|trim}) -%}
137-
{% endif %}
135+
{%- if type is not defined or type != 'hidden' -%}
136+
{%- set className = ' form-control' -%}
137+
{%- if type|default('') == 'file' -%}
138+
{%- set className = ' custom-file-input' -%}
139+
{%- elseif type|default('') == 'range' -%}
140+
{%- set className = ' form-control-range' -%}
141+
{%- endif -%}
142+
{%- set attr = attr|merge({class: (attr.class|default('') ~ className)|trim}) -%}
143+
{%- endif -%}
138144
{%- if type is defined and (type == 'range' or type == 'color') %}
139145
{# Attribute "required" is not supported #}
140146
{%- set required = false -%}
141147
{% endif %}
142148
{{- parent() -}}
143149
{%- endblock form_widget_simple %}
144150

145-
{%- block widget_attributes -%}
146-
{%- if not valid %}
151+
{% block widget_attributes -%}
152+
{%- if not valid -%}
147153
{% set attr = attr|merge({class: (attr.class|default('') ~ ' is-invalid')|trim}) %}
148-
{% endif -%}
154+
{%- endif -%}
149155
{{ parent() }}
150-
{%- endblock widget_attributes -%}
156+
{%- endblock widget_attributes %}
151157

152158
{% block button_widget -%}
153159
{%- set attr = attr|merge({class: (attr.class|default('btn-secondary') ~ ' btn')|trim}) -%}

src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
2020
use Symfony\Component\Form\Extension\Core\Type\PercentType;
2121
use Symfony\Component\Form\Extension\Core\Type\RadioType;
22+
use Symfony\Component\Form\Extension\Core\Type\RangeType;
2223
use Symfony\Component\Form\Extension\Core\Type\TextType;
2324
use Symfony\Component\Form\FormError;
2425

@@ -1194,6 +1195,41 @@ public function testPercentCustomSymbol()
11941195
[contains(.., "‱")]
11951196
]
11961197
]
1198+
'
1199+
);
1200+
}
1201+
1202+
public function testRange()
1203+
{
1204+
$form = $this->factory->createNamed('name', RangeType::class, 42, ['attr' => ['min' => 5]]);
1205+
1206+
$this->assertWidgetMatchesXpath(
1207+
$form->createView(),
1208+
['attr' => ['class' => 'my&class']],
1209+
'/input
1210+
[@type="range"]
1211+
[@name="name"]
1212+
[@value="42"]
1213+
[@min="5"]
1214+
[@class="my&class form-control-range"]
1215+
'
1216+
);
1217+
}
1218+
1219+
public function testRangeWithMinMaxValues()
1220+
{
1221+
$form = $this->factory->createNamed('name', RangeType::class, 42, ['attr' => ['min' => 5, 'max' => 57]]);
1222+
1223+
$this->assertWidgetMatchesXpath(
1224+
$form->createView(),
1225+
['attr' => ['class' => 'my&class']],
1226+
'/input
1227+
[@type="range"]
1228+
[@name="name"]
1229+
[@value="42"]
1230+
[@min="5"]
1231+
[@max="57"]
1232+
[@class="my&class form-control-range"]
11971233
'
11981234
);
11991235
}

src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ private static function formatFileSize(string $path): string
116116
} else {
117117
$size = 0;
118118
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS | \RecursiveDirectoryIterator::FOLLOW_SYMLINKS)) as $file) {
119-
$size += $file->getSize();
119+
if ($file->isReadable()) {
120+
$size += $file->getSize();
121+
}
120122
}
121123
}
122124

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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\Tests\Command\AboutCommand;
13+
14+
use Symfony\Bundle\FrameworkBundle\Command\AboutCommand;
15+
use Symfony\Bundle\FrameworkBundle\Console\Application;
16+
use Symfony\Bundle\FrameworkBundle\Tests\Command\AboutCommand\Fixture\TestAppKernel;
17+
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
18+
use Symfony\Component\Console\Tester\CommandTester;
19+
use Symfony\Component\Filesystem\Exception\IOException;
20+
use Symfony\Component\Filesystem\Filesystem;
21+
22+
class AboutCommandTest extends TestCase
23+
{
24+
/** @var Filesystem */
25+
private $fs;
26+
27+
protected function setUp(): void
28+
{
29+
$this->fs = new Filesystem();
30+
}
31+
32+
public function testAboutWithReadableFiles()
33+
{
34+
$kernel = new TestAppKernel('test', true);
35+
$this->fs->mkdir($kernel->getProjectDir());
36+
37+
$this->fs->dumpFile($kernel->getCacheDir().'/readable_file', 'The file content.');
38+
$this->fs->chmod($kernel->getCacheDir().'/readable_file', 0777);
39+
40+
$tester = $this->createCommandTester($kernel);
41+
$ret = $tester->execute([]);
42+
43+
$this->assertSame(0, $ret);
44+
$this->assertStringContainsString('Cache directory', $tester->getDisplay());
45+
$this->assertStringContainsString('Log directory', $tester->getDisplay());
46+
47+
$this->fs->chmod($kernel->getCacheDir().'/readable_file', 0777);
48+
49+
try {
50+
$this->fs->remove($kernel->getProjectDir());
51+
} catch (IOException $e) {
52+
}
53+
}
54+
55+
public function testAboutWithUnreadableFiles()
56+
{
57+
$kernel = new TestAppKernel('test', true);
58+
$this->fs->mkdir($kernel->getProjectDir());
59+
60+
// skip test on Windows; PHP can't easily set file as unreadable on Windows
61+
if ('\\' === \DIRECTORY_SEPARATOR) {
62+
$this->markTestSkipped('This test cannot run on Windows.');
63+
}
64+
65+
$this->fs->dumpFile($kernel->getCacheDir().'/unreadable_file', 'The file content.');
66+
$this->fs->chmod($kernel->getCacheDir().'/unreadable_file', 0222);
67+
68+
$tester = $this->createCommandTester($kernel);
69+
$ret = $tester->execute([]);
70+
71+
$this->assertSame(0, $ret);
72+
$this->assertStringContainsString('Cache directory', $tester->getDisplay());
73+
$this->assertStringContainsString('Log directory', $tester->getDisplay());
74+
75+
$this->fs->chmod($kernel->getCacheDir().'/unreadable_file', 0777);
76+
77+
try {
78+
$this->fs->remove($kernel->getProjectDir());
79+
} catch (IOException $e) {
80+
}
81+
}
82+
83+
private function createCommandTester(TestAppKernel $kernel): CommandTester
84+
{
85+
$application = new Application($kernel);
86+
$application->add(new AboutCommand());
87+
88+
return new CommandTester($application->find('about'));
89+
}
90+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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\Tests\Command\AboutCommand\Fixture;
13+
14+
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
15+
use Symfony\Component\Config\Loader\LoaderInterface;
16+
use Symfony\Component\DependencyInjection\ContainerBuilder;
17+
use Symfony\Component\HttpKernel\Kernel;
18+
19+
class TestAppKernel extends Kernel
20+
{
21+
public function registerBundles(): iterable
22+
{
23+
return [
24+
new FrameworkBundle(),
25+
];
26+
}
27+
28+
public function getProjectDir(): string
29+
{
30+
return __DIR__.'/test';
31+
}
32+
33+
public function registerContainerConfiguration(LoaderInterface $loader)
34+
{
35+
}
36+
37+
protected function build(ContainerBuilder $container)
38+
{
39+
}
40+
}

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,7 @@ protected function createContainerFromFile($file, $data = [], $resetCompilerPass
17231723
$container->getCompilerPassConfig()->setAfterRemovingPasses([]);
17241724
}
17251725
$container->getCompilerPassConfig()->setBeforeOptimizationPasses([new LoggerPass()]);
1726-
$container->getCompilerPassConfig()->setBeforeRemovingPasses([new AddConstraintValidatorsPass(), new TranslatorPass('translator.default', 'translation.reader')]);
1726+
$container->getCompilerPassConfig()->setBeforeRemovingPasses([new AddConstraintValidatorsPass(), new TranslatorPass()]);
17271727
$container->getCompilerPassConfig()->setAfterRemovingPasses([new AddAnnotationsCachedReaderPass()]);
17281728

17291729
if (!$compile) {

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
.sf-toolbar-block > a:hover {
101101
display: block;
102102
text-decoration: none;
103+
background-color: transparent;
103104
color: inherit;
104105
}
105106

@@ -238,6 +239,7 @@ div.sf-toolbar .sf-toolbar-block a:hover {
238239
padding: 0 10px;
239240
}
240241
.sf-toolbar-block-request .sf-toolbar-info-piece a {
242+
background-color: transparent;
241243
text-decoration: none;
242244
}
243245
.sf-toolbar-block-request .sf-toolbar-info-piece a:hover {

src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@ public function testOverwriteWithSectionOutput()
343343
);
344344
}
345345

346-
// ensure that ANSI characters are excluded when calculating line length
347346
public function testOverwriteWithAnsiSectionOutput()
348347
{
349348
// output has 43 visible characters plus 2 invisible ANSI characters
@@ -360,7 +359,7 @@ public function testOverwriteWithAnsiSectionOutput()
360359
$bar->advance();
361360

362361
rewind($output->getStream());
363-
$this->assertEquals(
362+
$this->assertSame(
364363
" \033[44;37m 0/50\033[0m [>---------------------------] 0%".\PHP_EOL.
365364
"\x1b[1A\x1b[0J"." \033[44;37m 1/50\033[0m [>---------------------------] 2%".\PHP_EOL.
366365
"\x1b[1A\x1b[0J"." \033[44;37m 2/50\033[0m [=>--------------------------] 4%".\PHP_EOL,

src/Symfony/Component/Translation/Tests/DependencyInjection/TranslationPassTest.php renamed to src/Symfony/Component/Translation/Tests/DependencyInjection/TranslatorPassTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use Symfony\Component\DependencyInjection\Reference;
1919
use Symfony\Component\Translation\DependencyInjection\TranslatorPass;
2020

21-
class TranslationPassTest extends TestCase
21+
class TranslatorPassTest extends TestCase
2222
{
2323
public function testValidCollector()
2424
{
@@ -35,7 +35,7 @@ public function testValidCollector()
3535
$container->setDefinition('translation.reader', $reader);
3636
$container->setDefinition('translation.xliff_loader', $loader);
3737

38-
$pass = new TranslatorPass('translator.default', 'translation.reader');
38+
$pass = new TranslatorPass();
3939
$pass->process($container);
4040

4141
$expectedReader = (new Definition())
@@ -72,7 +72,7 @@ public function testValidCommandsViewPathsArgument()
7272
;
7373
$container->setParameter('twig.default_path', 'templates');
7474

75-
$pass = new TranslatorPass('translator.default');
75+
$pass = new TranslatorPass();
7676
$pass->process($container);
7777

7878
$expectedViewPaths = ['other/templates', 'tpl'];
@@ -113,7 +113,7 @@ public function testCommandsViewPathsArgumentsAreIgnoredWithOldServiceDefinition
113113
;
114114
$container->setParameter('twig.default_path', 'templates');
115115

116-
$pass = new TranslatorPass('translator.default');
116+
$pass = new TranslatorPass();
117117
$pass->process($container);
118118

119119
$this->assertSame('templates', $debugCommand->getArgument(4));

src/Symfony/Contracts/Service/ServiceSubscriberInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ interface ServiceSubscriberInterface
4747
* * ['?Psr\Log\LoggerInterface'] is a shortcut for
4848
* * ['Psr\Log\LoggerInterface' => '?Psr\Log\LoggerInterface']
4949
*
50-
* @return array The required service types, optionally keyed by service names
50+
* @return string[] The required service types, optionally keyed by service names
5151
*/
5252
public static function getSubscribedServices();
5353
}

src/Symfony/Contracts/Service/ServiceSubscriberTrait.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ trait ServiceSubscriberTrait
2424
/** @var ContainerInterface */
2525
protected $container;
2626

27+
/**
28+
* {@inheritdoc}
29+
*/
2730
public static function getSubscribedServices(): array
2831
{
2932
static $services;

0 commit comments

Comments
 (0)
0