From 1c0f572d2e97195e55ab2a1db4dcb543e56f19f3 Mon Sep 17 00:00:00 2001 From: Lesnykh Ilia Date: Mon, 7 Nov 2016 10:23:54 +0300 Subject: [PATCH 1/4] Update UPGRADE-2.7.md --- UPGRADE-2.7.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UPGRADE-2.7.md b/UPGRADE-2.7.md index 5de67ebede..1cf3d3df7f 100644 --- a/UPGRADE-2.7.md +++ b/UPGRADE-2.7.md @@ -40,7 +40,7 @@ Form ---- * In form types and extension overriding the "setDefaultOptions" of the - AbstractType or AbstractExtensionType has been deprecated in favor of + AbstractType or AbstractTypeExtension has been deprecated in favor of overriding the new "configureOptions" method. The method "setDefaultOptions(OptionsResolverInterface $resolver)" will From b2fa7c4f0772b0729892055fdbfaaff51e78bf6e Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Mon, 7 Nov 2016 13:32:19 +0100 Subject: [PATCH 2/4] Revert "bug #20184 [FrameworkBundle] Convert null prefix to an empty string in translation:update (chalasr)" This reverts commit 3f650f864cdd041d668336d917c6cfb2bbe4f156, reversing changes made to 962248dbd949421c9a6f66b43827395adaea4180. --- .../FrameworkBundle/Command/TranslationUpdateCommand.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index 920c50c1d7..f310613d10 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -118,9 +118,8 @@ EOF // load any messages from templates $extractedCatalogue = new MessageCatalogue($input->getArgument('locale')); $output->text('Parsing templates'); - $prefix = $input->getOption('prefix'); $extractor = $this->getContainer()->get('translation.extractor'); - $extractor->setPrefix(null === $prefix ? '' : $prefix); + $extractor->setPrefix($input->getOption('prefix')); foreach ($transPaths as $path) { $path .= 'views'; if (is_dir($path)) { From a2c0a785c2eaf4425c1b79d6cd080404d34c28b1 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Sat, 22 Oct 2016 10:49:12 +0000 Subject: [PATCH 3/4] [HttpFoundation] Avoid implicit null to array conversion in request matcher --- .../HttpFoundation/RequestMatcher.php | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/RequestMatcher.php b/src/Symfony/Component/HttpFoundation/RequestMatcher.php index ca094ca162..aa4f67b58b 100644 --- a/src/Symfony/Component/HttpFoundation/RequestMatcher.php +++ b/src/Symfony/Component/HttpFoundation/RequestMatcher.php @@ -19,22 +19,22 @@ namespace Symfony\Component\HttpFoundation; class RequestMatcher implements RequestMatcherInterface { /** - * @var string + * @var string|null */ private $path; /** - * @var string + * @var string|null */ private $host; /** - * @var array + * @var string[] */ private $methods = array(); /** - * @var string + * @var string[] */ private $ips = array(); @@ -76,13 +76,13 @@ class RequestMatcher implements RequestMatcherInterface */ public function matchScheme($scheme) { - $this->schemes = array_map('strtolower', (array) $scheme); + $this->schemes = null !== $scheme ? array_map('strtolower', (array) $scheme) : array(); } /** * Adds a check for the URL host name. * - * @param string $regexp A Regexp + * @param string|null $regexp A Regexp */ public function matchHost($regexp) { @@ -92,7 +92,7 @@ class RequestMatcher implements RequestMatcherInterface /** * Adds a check for the URL path info. * - * @param string $regexp A Regexp + * @param string|null $regexp A Regexp */ public function matchPath($regexp) { @@ -112,21 +112,21 @@ class RequestMatcher implements RequestMatcherInterface /** * Adds a check for the client IP. * - * @param string|string[] $ips A specific IP address or a range specified using IP/netmask like 192.168.1.0/24 + * @param string|string[]|null $ips A specific IP address or a range specified using IP/netmask like 192.168.1.0/24 */ public function matchIps($ips) { - $this->ips = (array) $ips; + $this->ips = null !== $ips ? (array) $ips : array(); } /** * Adds a check for the HTTP method. * - * @param string|string[] $method An HTTP method or an array of HTTP methods + * @param string|string[]|null $method An HTTP method or an array of HTTP methods */ public function matchMethod($method) { - $this->methods = array_map('strtoupper', (array) $method); + $this->methods = null !== $method ? array_map('strtoupper', (array) $method) : array(); } /** @@ -145,11 +145,11 @@ class RequestMatcher implements RequestMatcherInterface */ public function matches(Request $request) { - if ($this->schemes && !in_array($request->getScheme(), $this->schemes)) { + if ($this->schemes && !in_array($request->getScheme(), $this->schemes, true)) { return false; } - if ($this->methods && !in_array($request->getMethod(), $this->methods)) { + if ($this->methods && !in_array($request->getMethod(), $this->methods, true)) { return false; } From adbc529b7b355e93b00c2f8db0a1c843c5c646c5 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 7 Nov 2016 19:42:43 +0100 Subject: [PATCH 4/4] prefer getSourceContext() over getSource() --- .../Twig/Tests/Extension/TranslationExtensionTest.php | 2 +- src/Symfony/Bridge/Twig/TwigEngine.php | 4 ++-- .../Bundle/TwigBundle/Controller/ExceptionController.php | 4 ++-- .../HttpKernel/Fragment/HIncludeFragmentRenderer.php | 8 ++++++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php index 0235c4da32..e96bd4f9a3 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php @@ -36,7 +36,7 @@ class TranslationExtensionTest extends \PHPUnit_Framework_TestCase $twig = new \Twig_Environment($loader, array('debug' => true, 'cache' => false)); $twig->addExtension(new TranslationExtension(new Translator('en', new MessageSelector()))); - echo $twig->compile($twig->parse($twig->tokenize(new \Twig_Source($twig->getLoader()->getSource('index'), 'index'))))."\n\n"; + echo $twig->compile($twig->parse($twig->tokenize($twig->getLoader()->getSourceContext('index'))))."\n\n"; $this->assertEquals($expected, $this->getTemplate($template)->render($variables)); } diff --git a/src/Symfony/Bridge/Twig/TwigEngine.php b/src/Symfony/Bridge/Twig/TwigEngine.php index 3e3257e7fa..1ac9d0102e 100644 --- a/src/Symfony/Bridge/Twig/TwigEngine.php +++ b/src/Symfony/Bridge/Twig/TwigEngine.php @@ -75,14 +75,14 @@ class TwigEngine implements EngineInterface, StreamingEngineInterface $loader = $this->environment->getLoader(); - if ($loader instanceof \Twig_ExistsLoaderInterface) { + if ($loader instanceof \Twig_ExistsLoaderInterface || method_exists($loader, 'exists')) { return $loader->exists((string) $name); } try { // cast possible TemplateReferenceInterface to string because the // EngineInterface supports them but Twig_LoaderInterface does not - $loader->getSource((string) $name); + $loader->getSourceContext((string) $name)->getCode(); } catch (\Twig_Error_Loader $e) { return false; } diff --git a/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php b/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php index 3eec8d6be9..b6972fc635 100644 --- a/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php +++ b/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php @@ -131,12 +131,12 @@ class ExceptionController $template = (string) $template; $loader = $this->twig->getLoader(); - if ($loader instanceof \Twig_ExistsLoaderInterface) { + if ($loader instanceof \Twig_ExistsLoaderInterface || method_exists($loader, 'exists')) { return $loader->exists($template); } try { - $loader->getSource($template); + $loader->getSourceContext($template)->getCode(); return true; } catch (\Twig_Error_Loader $e) { diff --git a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php index 56c96b3ced..27051cfb77 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php +++ b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php @@ -140,12 +140,16 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer } $loader = $this->templating->getLoader(); - if ($loader instanceof \Twig_ExistsLoaderInterface) { + if ($loader instanceof \Twig_ExistsLoaderInterface || method_exists($loader, 'exists')) { return $loader->exists($template); } try { - $loader->getSource($template); + if (method_exists($loader, 'getSourceContext')) { + $loader->getSourceContext($template); + } else { + $loader->getSource($template); + } return true; } catch (\Twig_Error_Loader $e) {