Skip to content

Commit 61fea5a

Browse files
committed
Merge branch '2.8' into 3.1
* 2.8: [TwigBridge] fix tests Tag the FormFieldRegistry as being internal [Form] Fix Date\TimeType marked as invalid on request with single_text and zero seconds [Validator] Added missing swedish translation [TranslationDebug] workaround for getFallbackLocales. [Translation] fixed nested fallback catalogue using multiple locales. fixed phpdoc [Command] Fixed method comments as phpDoc syntax Added single quotes for upgrade guides.
2 parents c4989c5 + 2cf474e commit 61fea5a

File tree

17 files changed

+120
-21
lines changed

17 files changed

+120
-21
lines changed

UPGRADE-3.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1902,5 +1902,5 @@ UPGRADE FROM 2.x to 3.0
19021902
After:
19031903

19041904
```php
1905-
$request->query->get('foo')[bar];
1905+
$request->query->get('foo')['bar'];
19061906
```

src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,12 @@ public function testOneVar()
8080
}
8181

8282
EOTXT;
83-
$expected = preg_replace('/%(.*?)%/', '(isset($context["$1"]) ? $context["$1"] : null)', $expected);
83+
84+
if (PHP_VERSION_ID >= 70000) {
85+
$expected = preg_replace('/%(.*?)%/', '($context["$1"] ?? null)', $expected);
86+
} else {
87+
$expected = preg_replace('/%(.*?)%/', '(isset($context["$1"]) ? $context["$1"] : null)', $expected);
88+
}
8489

8590
$this->assertSame($expected, $compiler->compile($node)->getSource());
8691
}
@@ -106,7 +111,12 @@ public function testMultiVars()
106111
}
107112

108113
EOTXT;
109-
$expected = preg_replace('/%(.*?)%/', '(isset($context["$1"]) ? $context["$1"] : null)', $expected);
114+
115+
if (PHP_VERSION_ID >= 70000) {
116+
$expected = preg_replace('/%(.*?)%/', '($context["$1"] ?? null)', $expected);
117+
} else {
118+
$expected = preg_replace('/%(.*?)%/', '(isset($context["$1"]) ? $context["$1"] : null)', $expected);
119+
}
110120

111121
$this->assertSame($expected, $compiler->compile($node)->getSource());
112122
}

src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ public function testCompile()
6666

6767
protected function getVariableGetter($name)
6868
{
69+
if (PHP_VERSION_ID >= 70000) {
70+
return sprintf('($context["%s"] ?? null)', $name, $name);
71+
}
72+
6973
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
7074
}
7175
}

src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes()
263263

264264
protected function getVariableGetter($name)
265265
{
266+
if (PHP_VERSION_ID >= 70000) {
267+
return sprintf('($context["%s"] ?? null)', $name, $name);
268+
}
269+
266270
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
267271
}
268272
}

src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,23 @@ public function testCompileStrict()
3939

4040
protected function getVariableGetterWithoutStrictCheck($name)
4141
{
42+
if (PHP_VERSION_ID >= 70000) {
43+
return sprintf('($context["%s"] ?? null)', $name, $name);
44+
}
45+
4246
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
4347
}
4448

4549
protected function getVariableGetterWithStrictCheck($name)
4650
{
47-
if (version_compare(\Twig_Environment::VERSION, '2.0.0-DEV', '>=')) {
51+
if (\Twig_Environment::MAJOR_VERSION >= 2) {
4852
return sprintf('(isset($context["%s"]) || array_key_exists("%s", $context) ? $context["%s"] : $this->notFound("%s", 0))', $name, $name, $name, $name);
4953
}
5054

51-
return sprintf('(isset($context["%1$s"]) ? $context["%1$s"] : $this->getContext($context, "%1$s"))', $name);
55+
if (PHP_VERSION_ID >= 70000) {
56+
return sprintf('($context["%s"] ?? $this->getContext($context, "%s"))', $name, $name, $name);
57+
}
58+
59+
return sprintf('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name);
5260
}
5361
}

src/Symfony/Bridge/Twig/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"require": {
1919
"php": ">=5.5.9",
20-
"twig/twig": "~1.27|~2.0"
20+
"twig/twig": "~1.28|~2.0"
2121
},
2222
"require-dev": {
2323
"symfony/asset": "~2.8|~3.0",

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
use Symfony\Component\Translation\Catalogue\MergeOperation;
2222
use Symfony\Component\Translation\MessageCatalogue;
2323
use Symfony\Component\Translation\Translator;
24+
use Symfony\Component\Translation\DataCollectorTranslator;
25+
use Symfony\Component\Translation\LoggingTranslator;
2426

2527
/**
2628
* Helps finding unused or missing translation messages in a given locale
@@ -295,7 +297,7 @@ private function loadFallbackCatalogues($locale, $transPaths, TranslationLoader
295297
{
296298
$fallbackCatalogues = array();
297299
$translator = $this->getContainer()->get('translator');
298-
if ($translator instanceof Translator) {
300+
if ($translator instanceof Translator || $translator instanceof DataCollectorTranslator || $translator instanceof LoggingTranslator) {
299301
foreach ($translator->getFallbackLocales() as $fallbackLocale) {
300302
if ($fallbackLocale === $locale) {
301303
continue;

src/Symfony/Component/Console/Command/Command.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,6 @@ protected function initialize(InputInterface $input, OutputInterface $output)
202202
*
203203
* @return int The command exit code
204204
*
205-
* @throws \Exception
206-
*
207205
* @see setCode()
208206
* @see execute()
209207
*/

src/Symfony/Component/DomCrawler/FormFieldRegistry.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
/**
1717
* This is an internal class that must not be used directly.
18+
*
19+
* @internal
1820
*/
1921
class FormFieldRegistry
2022
{

src/Symfony/Component/Form/Extension/Core/Type/TimeType.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
namespace Symfony\Component\Form\Extension\Core\Type;
1313

1414
use Symfony\Component\Form\AbstractType;
15+
use Symfony\Component\Form\FormEvent;
16+
use Symfony\Component\Form\FormEvents;
1517
use Symfony\Component\Form\FormInterface;
1618
use Symfony\Component\Form\FormBuilderInterface;
1719
use Symfony\Component\Form\ReversedTransformer;
@@ -54,6 +56,17 @@ public function buildForm(FormBuilderInterface $builder, array $options)
5456

5557
if ('single_text' === $options['widget']) {
5658
$builder->addViewTransformer(new DateTimeToStringTransformer($options['model_timezone'], $options['view_timezone'], $format));
59+
60+
// handle seconds ignored by user's browser when with_seconds enabled
61+
// https://codereview.chromium.org/450533009/
62+
if ($options['with_seconds']) {
63+
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $e) {
64+
$data = $e->getData();
65+
if ($data && preg_match('/^\d{2}:\d{2}$/', $data)) {
66+
$e->setData($data.':00');
67+
}
68+
});
69+
}
5770
} else {
5871
$hourOptions = $minuteOptions = $secondOptions = array(
5972
'error_bubbling' => true,

0 commit comments

Comments
 (0)