From cd42e2de93c7ea1394aa2b83367756a3affee03e Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Tue, 14 Jul 2015 14:59:01 +0100 Subject: [PATCH 001/243] [FrameworkBundle] Add path verification to the template parsing test cases --- .../Templating/TemplateNameParserTest.php | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php index ca10c3a8fe861..d8e69a6a73f81 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php @@ -43,30 +43,31 @@ protected function tearDown() } /** - * @dataProvider getLogicalNameToTemplateProvider + * @dataProvider parseProvider */ - public function testParse($name, $ref) + public function testParse($name, $logicalName, $path, $ref) { $template = $this->parser->parse($name); - $this->assertEquals($template->getLogicalName(), $ref->getLogicalName()); - $this->assertEquals($template->getLogicalName(), $name); + $this->assertSame($ref->getLogicalName(), $template->getLogicalName()); + $this->assertSame($logicalName, $template->getLogicalName()); + $this->assertSame($path, $template->getPath()); } - public function getLogicalNameToTemplateProvider() + public function parseProvider() { return array( - array('FooBundle:Post:index.html.php', new TemplateReference('FooBundle', 'Post', 'index', 'html', 'php')), - array('FooBundle:Post:index.html.twig', new TemplateReference('FooBundle', 'Post', 'index', 'html', 'twig')), - array('FooBundle:Post:index.xml.php', new TemplateReference('FooBundle', 'Post', 'index', 'xml', 'php')), - array('SensioFooBundle:Post:index.html.php', new TemplateReference('SensioFooBundle', 'Post', 'index', 'html', 'php')), - array('SensioCmsFooBundle:Post:index.html.php', new TemplateReference('SensioCmsFooBundle', 'Post', 'index', 'html', 'php')), - array(':Post:index.html.php', new TemplateReference('', 'Post', 'index', 'html', 'php')), - array('::index.html.php', new TemplateReference('', '', 'index', 'html', 'php')), - array('FooBundle:Post:foo.bar.index.html.php', new TemplateReference('FooBundle', 'Post', 'foo.bar.index', 'html', 'php')), - array('/path/to/section/name.php', new BaseTemplateReference('/path/to/section/name.php', 'php')), - array('name.twig', new BaseTemplateReference('name.twig', 'twig')), - array('name', new BaseTemplateReference('name')), + array('FooBundle:Post:index.html.php', 'FooBundle:Post:index.html.php', '@FooBundle/Resources/views/Post/index.html.php', new TemplateReference('FooBundle', 'Post', 'index', 'html', 'php')), + array('FooBundle:Post:index.html.twig', 'FooBundle:Post:index.html.twig', '@FooBundle/Resources/views/Post/index.html.twig', new TemplateReference('FooBundle', 'Post', 'index', 'html', 'twig')), + array('FooBundle:Post:index.xml.php', 'FooBundle:Post:index.xml.php', '@FooBundle/Resources/views/Post/index.xml.php', new TemplateReference('FooBundle', 'Post', 'index', 'xml', 'php')), + array('SensioFooBundle:Post:index.html.php', 'SensioFooBundle:Post:index.html.php', '@SensioFooBundle/Resources/views/Post/index.html.php', new TemplateReference('SensioFooBundle', 'Post', 'index', 'html', 'php')), + array('SensioCmsFooBundle:Post:index.html.php', 'SensioCmsFooBundle:Post:index.html.php', '@SensioCmsFooBundle/Resources/views/Post/index.html.php', new TemplateReference('SensioCmsFooBundle', 'Post', 'index', 'html', 'php')), + array(':Post:index.html.php', ':Post:index.html.php', 'views/Post/index.html.php', new TemplateReference('', 'Post', 'index', 'html', 'php')), + array('::index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')), + array('FooBundle:Post:foo.bar.index.html.php', 'FooBundle:Post:foo.bar.index.html.php', '@FooBundle/Resources/views/Post/foo.bar.index.html.php', new TemplateReference('FooBundle', 'Post', 'foo.bar.index', 'html', 'php')), + array('/path/to/section/name.php', '/path/to/section/name.php', '/path/to/section/name.php', new BaseTemplateReference('/path/to/section/name.php', 'php')), + array('name.twig', 'name.twig', 'name.twig', new BaseTemplateReference('name.twig', 'twig')), + array('name', 'name', 'name', new BaseTemplateReference('name')), ); } From 132a4e4b6fb8382b41032f6f7b7eb2b35f2790c5 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Wed, 15 Jul 2015 08:00:45 +0100 Subject: [PATCH 002/243] [FrameworkBundle] Fix template location for PHP templates --- .../Bundle/FrameworkBundle/Templating/TemplateNameParser.php | 2 +- .../FrameworkBundle/Tests/Templating/TemplateNameParserTest.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php index 4777fbeadbb49..46e2983f5deab 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php @@ -56,7 +56,7 @@ public function parse($name) throw new \RuntimeException(sprintf('Template name "%s" contains invalid characters.', $name)); } - if (!preg_match('/^([^:]*):([^:]*):(.+)\.([^\.]+)\.([^\.]+)$/', $name, $matches)) { + if (!preg_match('/^(?:([^:]*):)?(?:([^:]*):)?(.+)\.([^\.]+)\.([^\.]+)$/', $name, $matches)) { return parent::parse($name); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php index d8e69a6a73f81..4ff824bf7ca82 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php @@ -64,10 +64,12 @@ public function parseProvider() array('SensioCmsFooBundle:Post:index.html.php', 'SensioCmsFooBundle:Post:index.html.php', '@SensioCmsFooBundle/Resources/views/Post/index.html.php', new TemplateReference('SensioCmsFooBundle', 'Post', 'index', 'html', 'php')), array(':Post:index.html.php', ':Post:index.html.php', 'views/Post/index.html.php', new TemplateReference('', 'Post', 'index', 'html', 'php')), array('::index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')), + array('index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')), array('FooBundle:Post:foo.bar.index.html.php', 'FooBundle:Post:foo.bar.index.html.php', '@FooBundle/Resources/views/Post/foo.bar.index.html.php', new TemplateReference('FooBundle', 'Post', 'foo.bar.index', 'html', 'php')), array('/path/to/section/name.php', '/path/to/section/name.php', '/path/to/section/name.php', new BaseTemplateReference('/path/to/section/name.php', 'php')), array('name.twig', 'name.twig', 'name.twig', new BaseTemplateReference('name.twig', 'twig')), array('name', 'name', 'name', new BaseTemplateReference('name')), + array('default/index.html.php', '::default/index.html.php', 'views/default/index.html.php', new TemplateReference(null, null, 'default/index', 'html', 'php')), ); } From 996317020dedd17dad4d01242fb801011dab03b2 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Sun, 18 Oct 2015 13:56:20 +0100 Subject: [PATCH 003/243] [HttpKernel] Lookup the response even if the lock was released after 2 seconds --- src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index 07179faec4873..20d5e3d8ca2f8 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -544,7 +544,7 @@ protected function lock(Request $request, Response $entry) $wait += 50000; } - if ($wait < 2000000) { + if ($wait < 5000000) { // replace the current entry with the fresh one $new = $this->lookup($request); $entry->headers = $new->headers; From 907bbece010920906044a362c76c47c4e05618d6 Mon Sep 17 00:00:00 2001 From: ogizanagi Date: Thu, 3 Dec 2015 14:16:45 +0100 Subject: [PATCH 004/243] [FrameworkBundle][Validator] Fix apc cache service deprecation --- UPGRADE-2.8.md | 22 +++++++++++++++++++ UPGRADE-3.0.md | 21 ++++++++++++++++++ .../DependencyInjection/Configuration.php | 10 ++++++++- .../Resources/config/validator.xml | 2 +- .../DependencyInjection/Fixtures/php/full.php | 2 +- .../DependencyInjection/Fixtures/xml/full.xml | 2 +- .../DependencyInjection/Fixtures/yml/full.yml | 2 +- .../FrameworkExtensionTest.php | 2 +- 8 files changed, 57 insertions(+), 6 deletions(-) diff --git a/UPGRADE-2.8.md b/UPGRADE-2.8.md index 1166e6ad56491..846532b2fd31c 100644 --- a/UPGRADE-2.8.md +++ b/UPGRADE-2.8.md @@ -453,6 +453,28 @@ FrameworkBundle cookie_httponly: false ``` + * The `validator.mapping.cache.apc` service is deprecated, and will be removed in 3.0. + Use `validator.mapping.cache.doctrine.apc` instead. + + * The ability to pass `apc` as the `framework.validation.cache` configuration key value is deprecated, + and will be removed in 3.0. Use `validator.mapping.cache.doctrine.apc` instead: + + Before: + + ```yaml + framework: + validation: + cache: apc + ``` + + After: + + ```yaml + framework: + validation: + cache: validator.mapping.cache.doctrine.apc + ``` + Security -------- diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md index 7acdcddfe990e..15347075c8b67 100644 --- a/UPGRADE-3.0.md +++ b/UPGRADE-3.0.md @@ -481,6 +481,27 @@ UPGRADE FROM 2.x to 3.0 interface. The `security.csrf.token_manager` should be used instead. + * The `validator.mapping.cache.apc` service has been removed in favor of the `validator.mapping.cache.doctrine.apc` one. + + * The ability to pass `apc` as the `framework.validation.cache` configuration key value has been removed. + Use `validator.mapping.cache.doctrine.apc` instead: + + Before: + + ```yaml + framework: + validation: + cache: apc + ``` + + After: + + ```yaml + framework: + validation: + cache: validator.mapping.cache.doctrine.apc + ``` + ### HttpKernel * The `Symfony\Component\HttpKernel\Log\LoggerInterface` has been removed in diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 309cc6c48ccb7..b351039da9b38 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -645,7 +645,15 @@ private function addValidationSection(ArrayNodeDefinition $rootNode) ->scalarNode('cache') ->beforeNormalization() // Can be removed in 3.0, once ApcCache support is dropped - ->ifString()->then(function ($v) { return 'apc' === $v ? 'validator.mapping.cache.apc' : $v; }) + ->ifString()->then(function ($v) { + if ('apc' === $v) { + @trigger_error('The ability to pass "apc" as the framework.validation.cache configuration key value is deprecated since version 2.8 and will be removed in 3.0. Use the "validator.mapping.cache.doctrine.apc" service id instead.', E_USER_DEPRECATED); + + return 'validator.mapping.cache.apc'; + } + + return $v; + }) ->end() ->end() ->booleanNode('enable_annotations')->defaultFalse()->end() diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml index de8709ffd1e5b..a18099f973177 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml @@ -37,6 +37,7 @@ %validator.mapping.cache.prefix% + The "%service_id%" service is deprecated since Symfony 2.5 and will be removed in 3.0. @@ -47,7 +48,6 @@ - The "%service_id%" service is deprecated since Symfony 2.8 and will be removed in 3.0. diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php index 7c135dfc352f3..b3e32a5eb599c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php @@ -55,7 +55,7 @@ ), 'validation' => array( 'enabled' => true, - 'cache' => 'apc', + 'cache' => 'validator.mapping.cache.doctrine.apc', ), 'annotations' => array( 'cache' => 'file', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml index b94f44762fda4..c0ebb67ea15a5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml @@ -37,7 +37,7 @@ %kernel.root_dir%/Fixtures/translations - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml index 13ceca12a4f13..b2693d7e0249b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml @@ -43,7 +43,7 @@ framework: paths: ['%kernel.root_dir%/Fixtures/translations'] validation: enabled: true - cache: apc + cache: validator.mapping.cache.doctrine.apc annotations: cache: file debug: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 188f421387596..88141caaf02b1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -293,7 +293,7 @@ public function testValidation() $this->assertSame('addMethodMapping', $calls[4][0]); $this->assertSame(array('loadValidatorMetadata'), $calls[4][1]); $this->assertSame('setMetadataCache', $calls[5][0]); - $this->assertEquals(array(new Reference('validator.mapping.cache.apc')), $calls[5][1]); + $this->assertEquals(array(new Reference('validator.mapping.cache.doctrine.apc')), $calls[5][1]); } /** From 23431e99d691ac6669439a21234e49d3d94f10f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 10 Dec 2015 11:46:31 +0100 Subject: [PATCH 005/243] [FrameworkBundle] Compute the kernel root hash only one time --- .../FrameworkExtension.php | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 08a7b12de4eb1..855fcf8ab7e71 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -38,6 +38,11 @@ class FrameworkExtension extends Extension private $translationConfigEnabled = false; private $sessionConfigEnabled = false; + /** + * @var string|null + */ + private $kernelRootHash; + /** * Responds to the app.config configuration parameter. * @@ -777,7 +782,7 @@ private function registerValidationConfiguration(array $config, ContainerBuilder if (isset($config['cache'])) { $container->setParameter( 'validator.mapping.cache.prefix', - 'validator_'.hash('sha256', $container->getParameter('kernel.root_dir')) + 'validator_'.$this->getKernelRootHash($container) ); $validatorBuilder->addMethodCall('setMetadataCache', array(new Reference($config['cache']))); @@ -959,7 +964,7 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder if (isset($config['cache']) && $config['cache']) { $container->setParameter( 'serializer.mapping.cache.prefix', - 'serializer_'.hash('sha256', $container->getParameter('kernel.root_dir')) + 'serializer_'.$this->getKernelRootHash($container) ); $container->getDefinition('serializer.mapping.class_metadata_factory')->replaceArgument( @@ -968,6 +973,22 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder } } + /** + * Gets a hash of the kernel root directory. + * + * @param ContainerBuilder $container + * + * @return string + */ + private function getKernelRootHash(ContainerBuilder $container) + { + if (!$this->kernelRootHash) { + $this->kernelRootHash = hash('sha256', $container->getParameter('kernel.root_dir')); + } + + return $this->kernelRootHash; + } + /** * Returns the base path for the XSD files. * From 1999e89e7c213d33d221288687a4658fb712ee05 Mon Sep 17 00:00:00 2001 From: Abdellatif Ait boudad Date: Thu, 10 Dec 2015 19:14:16 +0000 Subject: [PATCH 006/243] [TranslationUpdateCommand] fixed undefined resultMessage var. --- .../FrameworkBundle/Command/TranslationUpdateCommand.php | 4 ++-- .../Tests/Command/TranslationUpdateCommandTest.php | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index 01678dd890f8a..cb3dd0092c653 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -150,6 +150,8 @@ protected function execute(InputInterface $input, OutputInterface $output) return; } + $resultMessage = 'Translation files were successfully updated.'; + // show compiled list of messages if (true === $input->getOption('dump-messages')) { $extractedMessagesCount = 0; @@ -205,8 +207,6 @@ protected function execute(InputInterface $input, OutputInterface $output) if (true === $input->getOption('dump-messages')) { $resultMessage .= ' and translation files were updated.'; - } else { - $resultMessage = 'Translation files were successfully updated.'; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php index a04a0cccad77c..f7eca9d366d38 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php @@ -28,6 +28,14 @@ public function testDumpMessagesAndClean() $tester = $this->createCommandTester($this->getContainer(array('foo' => 'foo'))); $tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true)); $this->assertRegExp('/foo/', $tester->getDisplay()); + $this->assertRegExp('/2 messages were successfully extracted/', $tester->getDisplay()); + } + + public function testWriteMessages() + { + $tester = $this->createCommandTester($this->getContainer(array('foo' => 'foo'))); + $tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--force' => true)); + $this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay()); } protected function setUp() From 369b2d4876501ee5ff7043e42a60d8c4fba3dd17 Mon Sep 17 00:00:00 2001 From: Abdellatif Ait boudad Date: Tue, 8 Dec 2015 14:36:25 +0000 Subject: [PATCH 007/243] [Translation][Writer] avoid calling setBackup if the dumper is not an instance of FileDumper. --- .../Tests/Writer/TranslationWriterTest.php | 47 +++++++++++++++++++ .../Translation/Writer/TranslationWriter.php | 4 +- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php diff --git a/src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php b/src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php new file mode 100644 index 0000000000000..501ced82e3f37 --- /dev/null +++ b/src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Translation\Tests\Writer; + +use Symfony\Component\Translation\MessageCatalogue; +use Symfony\Component\Translation\Writer\TranslationWriter; + +class TranslationWriterTest extends \PHPUnit_Framework_TestCase +{ + public function testWriteTranslations() + { + $dumper = $this->getMock('Symfony\Component\Translation\Dumper\DumperInterface'); + $dumper + ->expects($this->once()) + ->method('dump'); + + $writer = new TranslationWriter(); + $writer->addDumper('test', $dumper); + $writer->writeTranslations(new MessageCatalogue(array()), 'test'); + } + + public function testDisableBackup() + { + $dumper = $this->getMock('Symfony\Component\Translation\Dumper\DumperInterface'); + $dumper + ->expects($this->never()) + ->method('setBackup'); + $phpDumper = $this->getMock('Symfony\Component\Translation\Dumper\PhpFileDumper'); + $phpDumper + ->expects($this->once()) + ->method('setBackup'); + + $writer = new TranslationWriter(); + $writer->addDumper('test', $dumper); + $writer->addDumper('php', $phpDumper); + $writer->disableBackup(); + } +} diff --git a/src/Symfony/Component/Translation/Writer/TranslationWriter.php b/src/Symfony/Component/Translation/Writer/TranslationWriter.php index 44ac182d74a16..da88c1fc52eba 100644 --- a/src/Symfony/Component/Translation/Writer/TranslationWriter.php +++ b/src/Symfony/Component/Translation/Writer/TranslationWriter.php @@ -45,7 +45,9 @@ public function addDumper($format, DumperInterface $dumper) public function disableBackup() { foreach ($this->dumpers as $dumper) { - $dumper->setBackup(false); + if (method_exists($dumper, 'setBackup')) { + $dumper->setBackup(false); + } } } From 79474a6a0257ace07413b7c97f92b29d71c25bb4 Mon Sep 17 00:00:00 2001 From: Andreas Schempp Date: Fri, 11 Dec 2015 10:18:56 +0100 Subject: [PATCH 008/243] Profiler CSS position conflicts with JS detection --- .../Resources/views/Profiler/toolbar.css.twig | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig index c0456f61310fb..c6290593211b2 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig @@ -416,9 +416,6 @@ .sf-toolbar-block .sf-toolbar-icon svg { top: 6px; } - .sf-toolbar-block-config:hover .sf-toolbar-info { - right: 0; - } .sf-toolbar-block-time .sf-toolbar-icon svg, .sf-toolbar-block-memory .sf-toolbar-icon svg { display: none; From 3dca549b95a7f3a3f64efa902c461996e35460bd Mon Sep 17 00:00:00 2001 From: Gregor Harlan Date: Mon, 21 Dec 2015 12:01:57 +0100 Subject: [PATCH 009/243] use nowdoc instead of heredoc --- .php_cs | 2 + .../Command/AssetsInstallCommand.php | 2 +- .../Command/CacheClearCommand.php | 2 +- .../Command/CacheWarmupCommand.php | 2 +- .../Command/ConfigDumpReferenceCommand.php | 2 +- .../Command/ContainerDebugCommand.php | 2 +- .../Command/RouterApacheDumperCommand.php | 2 +- .../Command/RouterDebugCommand.php | 2 +- .../Command/RouterMatchCommand.php | 2 +- .../Command/ServerRunCommand.php | 2 +- .../Command/TranslationUpdateCommand.php | 2 +- .../Translation/Translator.php | 6 +-- .../SecurityBundle/Command/InitAclCommand.php | 2 +- .../Bundle/TwigBundle/Command/LintCommand.php | 2 +- .../Command/ExportCommand.php | 2 +- .../Command/ImportCommand.php | 2 +- .../Tests/ClassCollectionLoaderTest.php | 16 +++---- .../Tests/Definition/ReferenceDumperTest.php | 2 +- .../Component/Console/Command/HelpCommand.php | 2 +- .../Component/Console/Command/ListCommand.php | 2 +- src/Symfony/Component/Console/Shell.php | 2 +- .../Console/Tests/Command/ListCommandTest.php | 8 ++-- .../Tests/Formatter/OutputFormatterTest.php | 8 ++-- .../Console/Tests/Helper/TableHelperTest.php | 18 ++++---- .../Component/Debug/ExceptionHandler.php | 4 +- .../DependencyInjection/Dumper/PhpDumper.php | 44 +++++++++--------- .../DomCrawler/Tests/CrawlerTest.php | 10 ++-- .../Data/Bundle/Writer/PhpBundleWriter.php | 2 +- .../Intl/Resources/bin/update-data.php | 2 +- .../Process/Tests/PhpProcessTest.php | 2 +- .../Generator/Dumper/PhpGeneratorDumper.php | 12 ++--- .../Security/Acl/Dbal/AclProvider.php | 2 +- .../Security/Acl/Dbal/MutableAclProvider.php | 4 +- .../Tests/ConstraintViolationListTest.php | 2 +- .../Tests/ConstraintViolationTest.php | 4 +- .../Component/Yaml/Tests/DumperTest.php | 12 ++--- .../Component/Yaml/Tests/ParserTest.php | 46 +++++++++---------- 37 files changed, 121 insertions(+), 119 deletions(-) diff --git a/.php_cs b/.php_cs index 11d42d1287e47..290e9bf5fbcba 100644 --- a/.php_cs +++ b/.php_cs @@ -24,5 +24,7 @@ return Symfony\CS\Config\Config::create() ->notPath('src/Symfony/Component/Yaml/Tests/Fixtures/sfTests.yml') // test template ->notPath('src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_name_entry_label.html.php') + // explicit heredoc test + ->notPath('src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php') ) ; diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php index 61182fa71e023..643368976ffbe 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php @@ -37,7 +37,7 @@ protected function configure() ->addOption('symlink', null, InputOption::VALUE_NONE, 'Symlinks the assets instead of copying it') ->addOption('relative', null, InputOption::VALUE_NONE, 'Make relative symlinks') ->setDescription('Installs bundles web assets under a public web directory') - ->setHelp(<<setHelp(<<<'EOT' The %command.name% command installs bundle assets into a given directory (e.g. the web directory). diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php index 049179075a5b3..2b0d1bb9c5877 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php @@ -37,7 +37,7 @@ protected function configure() new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'), )) ->setDescription('Clears the cache') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% command clears the application cache for a given environment and debug mode: diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php index 71f071105b62c..ea82751d84834 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php @@ -33,7 +33,7 @@ protected function configure() new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'), )) ->setDescription('Warms up an empty cache') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% command warms up the cache. Before running this command, the cache must be empty. diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php index 9376b084730ef..fa978b3ba9d1e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php @@ -35,7 +35,7 @@ protected function configure() new InputArgument('name', InputArgument::OPTIONAL, 'The Bundle or extension alias'), )) ->setDescription('Dumps default configuration for an extension') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% command dumps the default configuration for an extension/bundle. The extension alias or bundle name can be used: diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php index a10760a1b9c2c..67d7451fb565f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php @@ -49,7 +49,7 @@ protected function configure() new InputOption('parameters', null, InputOption::VALUE_NONE, 'Displays parameters for an application'), )) ->setDescription('Displays current services for an application') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% command displays all configured public services: php %command.full_name% diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php index 904a08d253496..0355dd6627c61 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterApacheDumperCommand.php @@ -53,7 +53,7 @@ protected function configure() new InputOption('base-uri', null, InputOption::VALUE_REQUIRED, 'The base URI'), )) ->setDescription('Dumps all routes as Apache rewrite rules') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% dumps all routes as Apache rewrite rules. These can then be used with the ApacheUrlMatcher to use Apache for route matching. diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php index 67c5bc9444d17..84172218aa5a4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php @@ -51,7 +51,7 @@ protected function configure() new InputArgument('name', InputArgument::OPTIONAL, 'A route name'), )) ->setDescription('Displays current routes for an application') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% displays the configured routes: php %command.full_name% diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php index a54f18294f9ff..5ad347ce590b7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php @@ -52,7 +52,7 @@ protected function configure() new InputArgument('path_info', InputArgument::REQUIRED, 'A path info'), )) ->setDescription('Helps debug routes by simulating a path info match') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% simulates a path info match: php %command.full_name% /foo diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php index d417357cf32a0..573b67020dc99 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php @@ -54,7 +54,7 @@ protected function configure() )) ->setName('server:run') ->setDescription('Runs PHP built-in web server') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% runs PHP built-in web server: %command.full_name% diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index bdea20fdf779d..5bdc2f86e6e41 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -43,7 +43,7 @@ protected function configure() new InputOption('clean', null, InputOption::VALUE_NONE, 'Should clean not found messages'), )) ->setDescription('Updates the translation file') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% command extract translation strings from templates of a given bundle. It can display them or merge the new ones into the translation files. When new translation strings are found it can automatically add a prefix to the translation diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php index f791a6350908f..75b995dacbc5d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php @@ -108,9 +108,9 @@ protected function loadCatalogue($locale) $fallbackSuffix = ucfirst(preg_replace($replacementPattern, '_', $fallback)); $currentSuffix = ucfirst(preg_replace($replacementPattern, '_', $current)); - $fallbackContent .= sprintf(<<addFallbackCatalogue(\$catalogue%s); + $fallbackContent .= sprintf(<<<'EOF' +$catalogue%s = new MessageCatalogue('%s', %s); +$catalogue%s->addFallbackCatalogue($catalogue%s); EOF diff --git a/src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php b/src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php index 14271dc459a08..e12859661298b 100644 --- a/src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php +++ b/src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php @@ -43,7 +43,7 @@ protected function configure() $this ->setName('init:acl') ->setDescription('Mounts ACL tables in the database') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% command mounts ACL tables in the database. php %command.full_name% diff --git a/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php b/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php index f164c03847c99..997f29fefacc7 100644 --- a/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php +++ b/src/Symfony/Bundle/TwigBundle/Command/LintCommand.php @@ -29,7 +29,7 @@ protected function configure() ->setName('twig:lint') ->setDescription('Lints a template and outputs encountered errors') ->addArgument('filename') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% command lints a template and outputs to stdout the first encountered syntax error. diff --git a/src/Symfony/Bundle/WebProfilerBundle/Command/ExportCommand.php b/src/Symfony/Bundle/WebProfilerBundle/Command/ExportCommand.php index cf405530e2a88..aef4973090aff 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Command/ExportCommand.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Command/ExportCommand.php @@ -53,7 +53,7 @@ protected function configure() ->setDefinition(array( new InputArgument('token', InputArgument::REQUIRED, 'The profile token'), )) - ->setHelp(<<setHelp(<<<'EOF' The %command.name% command exports a profile to the standard output: php %command.full_name% profile_token diff --git a/src/Symfony/Bundle/WebProfilerBundle/Command/ImportCommand.php b/src/Symfony/Bundle/WebProfilerBundle/Command/ImportCommand.php index 4862e9c27afa0..5add381c6ae10 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Command/ImportCommand.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Command/ImportCommand.php @@ -53,7 +53,7 @@ protected function configure() ->setDefinition(array( new InputArgument('filename', InputArgument::OPTIONAL, 'The profile path'), )) - ->setHelp(<<setHelp(<<<'EOF' The %command.name% command imports a profile: php %command.full_name% profile_filepath diff --git a/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php b/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php index 5019f26ee84c8..fb91fadae7cc6 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php @@ -241,26 +241,26 @@ public function testCommentStripping() spl_autoload_unregister($r); - $this->assertEquals(<<assertEquals(<<<'EOF' namespace Namespaced { class WithComments { -public static \$loaded = true; +public static $loaded = true; } -\$string ='string should not be modified {\$string}'; -\$heredoc = (<<setDescription('Displays help for a command') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% command displays help for a given command: php %command.full_name% list diff --git a/src/Symfony/Component/Console/Command/ListCommand.php b/src/Symfony/Component/Console/Command/ListCommand.php index f3d7438d09817..6bd3026ef0450 100644 --- a/src/Symfony/Component/Console/Command/ListCommand.php +++ b/src/Symfony/Component/Console/Command/ListCommand.php @@ -34,7 +34,7 @@ protected function configure() ->setName('list') ->setDefinition($this->createDefinition()) ->setDescription('Lists commands') - ->setHelp(<<setHelp(<<<'EOF' The %command.name% command lists all commands: php %command.full_name% diff --git a/src/Symfony/Component/Console/Shell.php b/src/Symfony/Component/Console/Shell.php index d0bcb7ee8a8c2..f95b9a07a9322 100644 --- a/src/Symfony/Component/Console/Shell.php +++ b/src/Symfony/Component/Console/Shell.php @@ -68,7 +68,7 @@ public function run() if ($this->processIsolation) { $finder = new PhpExecutableFinder(); $php = $finder->find(); - $this->output->writeln(<<output->writeln(<<<'EOF' Running with process isolation, you should consider this: * each command is executed as separate process, * commands don't support interactivity, all params must be passed explicitly, diff --git a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php index d5b5bfbdbb628..c29ec6b8761f5 100644 --- a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php @@ -38,7 +38,7 @@ public function testExecuteListsCommandsWithRawOption() $application = new Application(); $commandTester = new CommandTester($command = $application->get('list')); $commandTester->execute(array('command' => $command->getName(), '--raw' => true)); - $output = <<add(new \FooCommand()); $commandTester = new CommandTester($command = $application->get('list')); $commandTester->execute(array('command' => $command->getName(), 'namespace' => 'foo', '--raw' => true)); - $output = <<add(new \Foo6Command()); $commandTester = new CommandTester($command = $application->get('list')); $commandTester->execute(array('command' => $command->getName()), array('decorated' => false)); - $output = <<add(new \Foo6Command()); $commandTester = new CommandTester($command = $application->get('list')); $commandTester->execute(array('command' => $command->getName(), '--raw' => true)); - $output = <<format(<<format(<<<'EOF' some text EOF @@ -230,7 +230,7 @@ public function testContentWithLineBreaks() \033[32msome text \033[0m EOF - , $formatter->format(<<format(<<<'EOF' some text EOF @@ -241,7 +241,7 @@ public function testContentWithLineBreaks() some text \033[0m EOF - , $formatter->format(<<format(<<<'EOF' some text @@ -254,7 +254,7 @@ public function testContentWithLineBreaks() more text \033[0m EOF - , $formatter->format(<<format(<<<'EOF' some text more text diff --git a/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php index d862929a0ee2a..c39f04464fb43 100644 --- a/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php @@ -91,7 +91,7 @@ public function testRenderProvider() array('80-902734-1-6', 'And Then There Were None', 'Agatha Christie'), ), TableHelper::LAYOUT_DEFAULT, -<<Charles Dickens'), ), TableHelper::LAYOUT_DEFAULT, -<<
render($output = $this->getOutputStream()); $expected = -<<
render($output = $this->getOutputStream()); $expected = - <<
abbrClass($e['class']); $message = nl2br(htmlspecialchars($e['message'], $flags, $this->charset)); - $content .= sprintf(<<

%d/%d %s: %s

@@ -196,7 +196,7 @@ public function getContent(FlattenException $exception) */ public function getStylesheet(FlattenException $exception) { - return <<isPublic()) { - $doc .= <<addMethodMap(); $code .= $this->addAliases(); - $code .= <<services = - \$this->scopedServices = - \$this->scopeStacks = array(); + $this->services = + $this->scopedServices = + $this->scopeStacks = array(); EOF; $code .= "\n"; @@ -853,7 +853,7 @@ public function __construct() $code .= $this->addMethodMap(); $code .= $this->addAliases(); - $code .= <<container->isFrozen()) { - $code .= <<parameters[\$name]) || array_key_exists(\$name, \$this->parameters))) { - throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', \$name)); + if (!(isset($this->parameters[$name]) || array_key_exists($name, $this->parameters))) { + throw new InvalidArgumentException(sprintf('The parameter "%s" must be defined.', $name)); } - return \$this->parameters[\$name]; + return $this->parameters[$name]; } /** * {@inheritdoc} */ - public function hasParameter(\$name) + public function hasParameter($name) { - \$name = strtolower(\$name); + $name = strtolower($name); - return isset(\$this->parameters[\$name]) || array_key_exists(\$name, \$this->parameters); + return isset($this->parameters[$name]) || array_key_exists($name, $this->parameters); } /** * {@inheritdoc} */ - public function setParameter(\$name, \$value) + public function setParameter($name, $value) { throw new LogicException('Impossible to call set() on a frozen ParameterBag.'); } @@ -963,11 +963,11 @@ public function setParameter(\$name, \$value) */ public function getParameterBag() { - if (null === \$this->parameterBag) { - \$this->parameterBag = new FrozenParameterBag(\$this->parameters); + if (null === $this->parameterBag) { + $this->parameterBag = new FrozenParameterBag($this->parameters); } - return \$this->parameterBag; + return $this->parameterBag; } EOF; } @@ -1029,7 +1029,7 @@ private function exportParameters($parameters, $path = '', $indent = 12) */ private function endClass() { - return <<addHtmlContent(<<addHtmlContent(<<<'EOF' @@ -158,7 +158,7 @@ public function testAddXmlContentWithErrors() $internalErrors = libxml_use_internal_errors(true); $crawler = new Crawler(); - $crawler->addXmlContent(<<addXmlContent(<<<'EOF' @@ -518,7 +518,7 @@ public function testSelectButton() public function testSelectButtonWithSingleQuotesInNameAttribute() { - $html = << @@ -539,7 +539,7 @@ public function testSelectButtonWithSingleQuotesInNameAttribute() public function testSelectButtonWithDoubleQuotesInNameAttribute() { - $html = << @@ -578,7 +578,7 @@ public function testLink() public function testSelectLinkAndLinkFiltered() { - $html = << diff --git a/src/Symfony/Component/Intl/Data/Bundle/Writer/PhpBundleWriter.php b/src/Symfony/Component/Intl/Data/Bundle/Writer/PhpBundleWriter.php index a29972cd02100..53d943dcfeda9 100644 --- a/src/Symfony/Component/Intl/Data/Bundle/Writer/PhpBundleWriter.php +++ b/src/Symfony/Component/Intl/Data/Bundle/Writer/PhpBundleWriter.php @@ -25,7 +25,7 @@ class PhpBundleWriter implements BundleWriterInterface */ public function write($path, $locale, $data) { - $template = <<