From 201603137c761579eeb5b2f5e3c76608285308c3 Mon Sep 17 00:00:00 2001 From: Lesnykh Ilia Date: Tue, 8 Nov 2016 16:51:01 +0300 Subject: [PATCH 1/9] Added single quotes for upgrade guides. --- UPGRADE-2.8.md | 4 ++-- UPGRADE-3.0.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/UPGRADE-2.8.md b/UPGRADE-2.8.md index 957f35b505..ae87a131a9 100644 --- a/UPGRADE-2.8.md +++ b/UPGRADE-2.8.md @@ -628,7 +628,7 @@ HttpFoundation After: ```php - $request->query->get('foo')[bar]; + $request->query->get('foo')['bar']; ``` Routing @@ -657,4 +657,4 @@ Routing // url generated in @router service $router->generate('blog_show', array('slug' => 'my-blog-post'), UrlGeneratorInterface::ABSOLUTE_URL); - ``` \ No newline at end of file + ``` diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md index 68e3780d8a..f6bd000ad1 100644 --- a/UPGRADE-3.0.md +++ b/UPGRADE-3.0.md @@ -1750,5 +1750,5 @@ UPGRADE FROM 2.x to 3.0 After: ```php - $request->query->get('foo')[bar]; + $request->query->get('foo')['bar']; ``` From 5a1bf6aa6e4eff880c376fe32f425942da357af8 Mon Sep 17 00:00:00 2001 From: Karim Miladi Date: Mon, 7 Nov 2016 18:16:01 +0100 Subject: [PATCH 2/9] [Command] Fixed method comments as phpDoc syntax --- src/Symfony/Component/Console/Command/Command.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index dcda54b637..0948d42b57 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -202,8 +202,6 @@ class Command * * @return int The command exit code * - * @throws \Exception - * * @see setCode() * @see execute() */ From dd47295c15b5644dadad5d8cb6c81eea37a8ec62 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Mon, 7 Nov 2016 22:01:27 +0100 Subject: [PATCH 3/9] fixed phpdoc --- src/Symfony/Component/Yaml/Inline.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 7f2a75b8c7..624088fbba 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -28,7 +28,7 @@ class Inline private static $objectForMap = false; /** - * Converts a YAML string to a PHP array. + * Converts a YAML string to a PHP value. * * @param string $value A YAML string * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise @@ -36,7 +36,7 @@ class Inline * @param bool $objectForMap true if maps should return a stdClass instead of array() * @param array $references Mapping of variable names to values * - * @return array A PHP array representing the YAML string + * @return mixed A PHP value * * @throws ParseException */ @@ -90,7 +90,7 @@ class Inline * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise * @param bool $objectSupport true if object support is enabled, false otherwise * - * @return string The YAML string representing the PHP array + * @return string The YAML string representing the PHP value * * @throws DumpException When trying to dump PHP resource */ @@ -210,7 +210,7 @@ class Inline } /** - * Parses a scalar to a YAML string. + * Parses a YAML scalar. * * @param string $scalar * @param string $delimiters @@ -219,7 +219,7 @@ class Inline * @param bool $evaluate * @param array $references * - * @return string A YAML string + * @return string * * @throws ParseException When malformed inline YAML string is parsed */ @@ -261,12 +261,12 @@ class Inline } /** - * Parses a quoted scalar to YAML. + * Parses a YAML quoted scalar. * * @param string $scalar * @param int &$i * - * @return string A YAML string + * @return string * * @throws ParseException When malformed inline YAML string is parsed */ @@ -291,13 +291,13 @@ class Inline } /** - * Parses a sequence to a YAML string. + * Parses a YAML sequence. * * @param string $sequence * @param int &$i * @param array $references * - * @return string A YAML string + * @return array * * @throws ParseException When malformed inline YAML string is parsed */ @@ -350,13 +350,13 @@ class Inline } /** - * Parses a mapping to a YAML string. + * Parses a YAML mapping. * * @param string $mapping * @param int &$i * @param array $references * - * @return string A YAML string + * @return array|\stdClass * * @throws ParseException When malformed inline YAML string is parsed */ From bac217dd833a60269e5a49f6a4c0be433aa389ae Mon Sep 17 00:00:00 2001 From: Abdellatif Ait boudad Date: Wed, 9 Nov 2016 19:27:17 +0000 Subject: [PATCH 4/9] [Translation] fixed nested fallback catalogue using multiple locales. --- .../Component/Translation/Tests/TranslatorTest.php | 10 ++++++++++ src/Symfony/Component/Translation/Translator.php | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Translation/Tests/TranslatorTest.php b/src/Symfony/Component/Translation/Tests/TranslatorTest.php index ac5aaf9ec1..8756844b46 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorTest.php @@ -273,6 +273,16 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase $translator->trans('foo'); } + public function testNestedFallbackCatalogueWhenUsingMultipleLocales() + { + $translator = new Translator('fr'); + $translator->setFallbackLocales(array('ru', 'en')); + + $translator->getCatalogue('fr'); + + $this->assertNotNull($translator->getCatalogue('ru')->getFallbackCatalogue()); + } + public function testFallbackCatalogueResources() { $translator = new Translator('en_GB', new MessageSelector()); diff --git a/src/Symfony/Component/Translation/Translator.php b/src/Symfony/Component/Translation/Translator.php index 48a801d375..ed80a5e49f 100644 --- a/src/Symfony/Component/Translation/Translator.php +++ b/src/Symfony/Component/Translation/Translator.php @@ -159,7 +159,7 @@ class Translator implements TranslatorInterface, TranslatorBagInterface * * @throws \InvalidArgumentException If a locale contains invalid characters * - * @deprecated since version 2.3, to be removed in 3.0. Use setFallbackLocales() instead. + * @deprecated since version 2.3, to be removed in 3.0. Use setFallbackLocales() instead */ public function setFallbackLocale($locales) { @@ -420,7 +420,7 @@ EOF foreach ($this->computeFallbackLocales($locale) as $fallback) { if (!isset($this->catalogues[$fallback])) { - $this->doLoadCatalogue($fallback); + $this->loadCatalogue($fallback); } $fallbackCatalogue = new MessageCatalogue($fallback, $this->catalogues[$fallback]->all()); From 31deea1d3dff2dd3b4ea8786776ea90288d832e0 Mon Sep 17 00:00:00 2001 From: Abdellatif Ait boudad Date: Wed, 9 Nov 2016 20:23:10 +0000 Subject: [PATCH 5/9] [TranslationDebug] workaround for getFallbackLocales. --- .../Command/TranslationDebugCommand.php | 4 +++- .../Translation/DataCollectorTranslator.php | 14 ++++++++++++++ .../Component/Translation/LoggingTranslator.php | 14 ++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php index 64beda5265..be4696adfd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php @@ -19,6 +19,8 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Translation\Translator; +use Symfony\Component\Translation\DataCollectorTranslator; +use Symfony\Component\Translation\LoggingTranslator; /** * Helps finding unused or missing translation messages in a given locale @@ -157,7 +159,7 @@ EOF // Load the fallback catalogues $fallbackCatalogues = array(); $translator = $this->getContainer()->get('translator'); - if ($translator instanceof Translator) { + if ($translator instanceof Translator || $translator instanceof DataCollectorTranslator || $translator instanceof LoggingTranslator) { foreach ($translator->getFallbackLocales() as $fallbackLocale) { if ($fallbackLocale === $locale) { continue; diff --git a/src/Symfony/Component/Translation/DataCollectorTranslator.php b/src/Symfony/Component/Translation/DataCollectorTranslator.php index f88a467a1d..b2049d4751 100644 --- a/src/Symfony/Component/Translation/DataCollectorTranslator.php +++ b/src/Symfony/Component/Translation/DataCollectorTranslator.php @@ -88,6 +88,20 @@ class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInter return $this->translator->getCatalogue($locale); } + /** + * Gets the fallback locales. + * + * @return array $locales The fallback locales + */ + public function getFallbackLocales() + { + if ($this->translator instanceof Translator) { + return $this->translator->getFallbackLocales(); + } + + return array(); + } + /** * Passes through all unknown calls onto the translator object. */ diff --git a/src/Symfony/Component/Translation/LoggingTranslator.php b/src/Symfony/Component/Translation/LoggingTranslator.php index fa5c5cc5b5..b259df5e0a 100644 --- a/src/Symfony/Component/Translation/LoggingTranslator.php +++ b/src/Symfony/Component/Translation/LoggingTranslator.php @@ -88,6 +88,20 @@ class LoggingTranslator implements TranslatorInterface, TranslatorBagInterface return $this->translator->getCatalogue($locale); } + /** + * Gets the fallback locales. + * + * @return array $locales The fallback locales + */ + public function getFallbackLocales() + { + if ($this->translator instanceof Translator) { + return $this->translator->getFallbackLocales(); + } + + return array(); + } + /** * Passes through all unknown calls onto the translator object. */ From f3fede2e833c1f42ee378ff542fb6cc0ceebcaad Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Thu, 10 Nov 2016 16:29:44 +0100 Subject: [PATCH 6/9] [Validator] Added missing swedish translation --- .../Validator/Resources/translations/validators.sv.xlf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.sv.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.sv.xlf index 693f12b5b1..879c0a5c55 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.sv.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.sv.xlf @@ -310,6 +310,10 @@ This value does not match the expected {{ charset }} charset. Detta värde har inte den förväntade teckenkodningen {{ charset }}. + + This is not a valid Business Identifier Code (BIC). + Detta är inte en giltig BIC-kod. + From bcb03e0a395f8e862fc5ac6be87e7d920cc2da8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Ram=C3=ADrez=20+Deimos+?= Date: Wed, 26 Oct 2016 03:27:22 -0500 Subject: [PATCH 7/9] [Form] Fix Date\TimeType marked as invalid on request with single_text and zero seconds --- .../Form/Extension/Core/Type/TimeType.php | 13 +++++++++++++ .../Tests/Extension/Core/Type/TimeTypeTest.php | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php index 8232170278..b482f079eb 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php @@ -12,6 +12,8 @@ namespace Symfony\Component\Form\Extension\Core\Type; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormEvent; +use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\ReversedTransformer; @@ -49,6 +51,17 @@ class TimeType extends AbstractType if ('single_text' === $options['widget']) { $builder->addViewTransformer(new DateTimeToStringTransformer($options['model_timezone'], $options['view_timezone'], $format)); + + // handle seconds ignored by user's browser when with_seconds enabled + // https://codereview.chromium.org/450533009/ + if ($options['with_seconds']) { + $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $e) { + $data = $e->getData(); + if ($data && preg_match('/^\d{2}:\d{2}$/', $data)) { + $e->setData($data.':00'); + } + }); + } } else { $hourOptions = $minuteOptions = $secondOptions = array( 'error_bubbling' => true, diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php index e8b95312b4..3a60d07988 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php @@ -221,6 +221,22 @@ class TimeTypeTest extends TestCase $this->assertEquals('03', $form->getViewData()); } + public function testSubmitWithSecondsAndBrowserOmissionSeconds() + { + $form = $this->factory->create('time', null, array( + 'model_timezone' => 'UTC', + 'view_timezone' => 'UTC', + 'input' => 'string', + 'widget' => 'single_text', + 'with_seconds' => true, + )); + + $form->submit('03:04'); + + $this->assertEquals('03:04:00', $form->getData()); + $this->assertEquals('03:04:00', $form->getViewData()); + } + public function testSetDataWithoutMinutes() { $form = $this->factory->create('time', null, array( From 0801f9723bb84b8f2fb9fec0c50f4605dda34cc6 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Sat, 12 Nov 2016 16:48:22 +0100 Subject: [PATCH 8/9] Tag the FormFieldRegistry as being internal --- src/Symfony/Component/DomCrawler/FormFieldRegistry.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Symfony/Component/DomCrawler/FormFieldRegistry.php b/src/Symfony/Component/DomCrawler/FormFieldRegistry.php index dbd08ff720..7dd3d3e7a3 100644 --- a/src/Symfony/Component/DomCrawler/FormFieldRegistry.php +++ b/src/Symfony/Component/DomCrawler/FormFieldRegistry.php @@ -15,6 +15,8 @@ use Symfony\Component\DomCrawler\Field\FormField; /** * This is an internal class that must not be used directly. + * + * @internal */ class FormFieldRegistry { From 1f1539579c245bef906944a442a740d9e43eb042 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 14 Nov 2016 08:52:03 +0100 Subject: [PATCH 9/9] [TwigBridge] fix tests Adapt tests for null coalescing support from twigphp/Twig#2238. --- .../Bridge/Twig/Tests/Node/DumpNodeTest.php | 17 +++++++++++++++-- .../Bridge/Twig/Tests/Node/FormThemeTest.php | 4 ++++ .../Tests/Node/SearchAndRenderBlockNodeTest.php | 4 ++++ .../Bridge/Twig/Tests/Node/TransNodeTest.php | 10 +++++++++- src/Symfony/Bridge/Twig/composer.json | 2 +- 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php index 5d8ea6f086..035dc4f671 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/DumpNodeTest.php @@ -80,7 +80,13 @@ if ($this->env->isDebug()) { } EOTXT; - $expected = preg_replace('/%(.*?)%/', PHP_VERSION_ID >= 50400 ? '(isset($context["$1"]) ? $context["$1"] : null)' : '$this->getContext($context, "$1")', $expected); + if (PHP_VERSION_ID >= 70000) { + $expected = preg_replace('/%(.*?)%/', '($context["$1"] ?? null)', $expected); + } elseif (PHP_VERSION_ID >= 50400) { + $expected = preg_replace('/%(.*?)%/', '(isset($context["$1"]) ? $context["$1"] : null)', $expected); + } else { + $expected = preg_replace('/%(.*?)%/', '$this->getContext($context, "$1")', $expected); + } $this->assertSame($expected, $compiler->compile($node)->getSource()); } @@ -106,7 +112,14 @@ if ($this->env->isDebug()) { } EOTXT; - $expected = preg_replace('/%(.*?)%/', PHP_VERSION_ID >= 50400 ? '(isset($context["$1"]) ? $context["$1"] : null)' : '$this->getContext($context, "$1")', $expected); + + if (PHP_VERSION_ID >= 70000) { + $expected = preg_replace('/%(.*?)%/', '($context["$1"] ?? null)', $expected); + } elseif (PHP_VERSION_ID >= 50400) { + $expected = preg_replace('/%(.*?)%/', '(isset($context["$1"]) ? $context["$1"] : null)', $expected); + } else { + $expected = preg_replace('/%(.*?)%/', '$this->getContext($context, "$1")', $expected); + } $this->assertSame($expected, $compiler->compile($node)->getSource()); } diff --git a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php index f407afdcd6..590b9ef75c 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php @@ -66,6 +66,10 @@ class FormThemeTest extends \PHPUnit_Framework_TestCase protected function getVariableGetter($name) { + if (PHP_VERSION_ID >= 70000) { + return sprintf('($context["%s"] ?? null)', $name, $name); + } + if (PHP_VERSION_ID >= 50400) { return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); } diff --git a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php index ad76e25e8e..0a3d30bdd5 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php @@ -263,6 +263,10 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase protected function getVariableGetter($name) { + if (PHP_VERSION_ID >= 70000) { + return sprintf('($context["%s"] ?? null)', $name, $name); + } + if (PHP_VERSION_ID >= 50400) { return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); } diff --git a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php index 032975a8f2..cbd21fc46e 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php @@ -39,6 +39,10 @@ class TransNodeTest extends \PHPUnit_Framework_TestCase protected function getVariableGetterWithoutStrictCheck($name) { + if (PHP_VERSION_ID >= 70000) { + return sprintf('($context["%s"] ?? null)', $name, $name); + } + if (PHP_VERSION_ID >= 50400) { return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); } @@ -48,10 +52,14 @@ class TransNodeTest extends \PHPUnit_Framework_TestCase protected function getVariableGetterWithStrictCheck($name) { - if (version_compare(\Twig_Environment::VERSION, '2.0.0-DEV', '>=')) { + if (\Twig_Environment::MAJOR_VERSION >= 2) { return sprintf('(isset($context["%s"]) || array_key_exists("%s", $context) ? $context["%s"] : $this->notFound("%s", 0))', $name, $name, $name, $name); } + if (PHP_VERSION_ID >= 70000) { + return sprintf('($context["%s"] ?? $this->getContext($context, "%s"))', $name, $name, $name); + } + if (PHP_VERSION_ID >= 50400) { return sprintf('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name); } diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index b83dc34c7f..74c98e93a5 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -17,7 +17,7 @@ ], "require": { "php": ">=5.3.9", - "twig/twig": "~1.27|~2.0" + "twig/twig": "~1.28|~2.0" }, "require-dev": { "symfony/asset": "~2.7",