From cd42e2de93c7ea1394aa2b83367756a3affee03e Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Tue, 14 Jul 2015 14:59:01 +0100 Subject: [PATCH 001/226] [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/226] [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/226] [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/226] [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/226] [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/226] [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/226] [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/226] 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 0d5f7e29050cf161dd620b4fa6d004d2cc7a81dc Mon Sep 17 00:00:00 2001 From: flip111 Date: Sat, 12 Dec 2015 17:45:35 +0100 Subject: [PATCH 009/226] Update FileSystem * Fixes edge case on windows where PHP does not generate a PHP Warning but instead returns a wrong result https://bugs.php.net/bug.php?id=71103 * Improved error reporting on `unlink` used in `remove()` --- .../Component/Filesystem/Filesystem.php | 27 +++++++++++++++-- .../Filesystem/Tests/FilesystemTest.php | 29 +++++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index 1b6eaa68cd22c..8b41db93b8e7f 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -100,6 +100,10 @@ public function mkdir($dirs, $mode = 0777) public function exists($files) { foreach ($this->toIterator($files) as $file) { + if ('\\' === DIRECTORY_SEPARATOR AND strlen($file) > 258) { + throw new IOException(sprintf('Could not check if file exist because path length exceeds 258 characters for file "%s"', $file)); + } + if (!file_exists($file)) { return false; } @@ -139,7 +143,7 @@ public function remove($files) $files = iterator_to_array($this->toIterator($files)); $files = array_reverse($files); foreach ($files as $file) { - if (!file_exists($file) && !is_link($file)) { + if (!$this->exists($file) && !is_link($file)) { continue; } @@ -157,7 +161,8 @@ public function remove($files) } } else { if (true !== @unlink($file)) { - throw new IOException(sprintf('Failed to remove file %s', $file)); + $error = error_get_last(); + throw new IOException(sprintf('Failed to remove file "%s": %s.', $file, $error['message'])); } } } @@ -253,7 +258,7 @@ public function chgrp($files, $group, $recursive = false) public function rename($origin, $target, $overwrite = false) { // we check that target does not exist - if (!$overwrite && is_readable($target)) { + if (!$overwrite && $this->isReadable($target)) { throw new IOException(sprintf('Cannot rename because the target "%s" already exist.', $target)); } @@ -262,6 +267,22 @@ public function rename($origin, $target, $overwrite = false) } } + /** + * Tells whether a file exists and is readable. + * + * @param string $filename Path to the file. + * + * @throws IOException When windows path is longer than 258 characters + */ + private function isReadable($filename) + { + if ('\\' === DIRECTORY_SEPARATOR AND strlen($filename) > 258) { + throw new IOException(sprintf('Could not check if file is readable because path length exceeds 258 characters for file "%s"', $filename)); + } + + return is_readable($filename); + } + /** * Creates a symbolic link or copy a directory. * diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index b57610cb81208..d6c27d1f77f76 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -19,6 +19,7 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase { private $umask; + private $longPathNamesWindows = array(); /** * @var string @@ -56,6 +57,12 @@ protected function setUp() protected function tearDown() { + if (!empty($this->longPathNamesWindows)) { + foreach ($this->longPathNamesWindows as $path) { + exec('DEL '.$path); + } + } + $this->filesystem->remove($this->workspace); umask($this->umask); } @@ -354,6 +361,28 @@ public function testFilesExists() $this->assertTrue($this->filesystem->exists($basePath.'folder')); } + /** + * @expectedException \Symfony\Component\Filesystem\Exception\IOException + */ + public function testFilesExistsFails() + { + if ('\\' !== DIRECTORY_SEPARATOR) { + $this->markTestSkipped('Test covers edge case on Windows only.'); + } + + $basePath = $this->workspace.'\\directory\\'; + + $oldPath = getcwd(); + mkdir($basePath); + chdir($basePath); + $file = str_repeat('T', 259 - strlen($basePath)); + $path = $basePath.$file; + exec('TYPE NUL >>'.$file); // equivalent of touch, we can not use the php touch() here because it suffers from the same limitation + $this->longPathNamesWindows[] = $path; // save this so we can clean up later + chdir($oldPath); + $this->filesystem->exists($path); + } + public function testFilesExistsTraversableObjectOfFilesAndDirectories() { $basePath = $this->workspace.DIRECTORY_SEPARATOR; From 1cd8aa1605b53b0bbea8f73ec5898ee7ca366b8a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 14 Jan 2016 10:14:30 +0100 Subject: [PATCH 010/226] updated CHANGELOG for 2.3.37 --- CHANGELOG-2.3.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CHANGELOG-2.3.md b/CHANGELOG-2.3.md index f520c60219662..bdc4cb0ef6468 100644 --- a/CHANGELOG-2.3.md +++ b/CHANGELOG-2.3.md @@ -7,6 +7,21 @@ in 2.3 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.3.0...v2.3.1 +* 2.3.37 (2016-01-14) + + * security #17359 do not ship with a custom rng implementation (xabbuh, fabpot) + * bug #17326 [Console] Display console application name even when no version set (polc) + * bug #17140 [Serializer] Remove normalizer cache in Serializer class (jvasseur) + * bug #17307 [FrameworkBundle] Fix paths with % in it (like urlencoded) (scaytrase) + * bug #17078 [Bridge] [Doctrine] [Validator] Added support \IteratorAggregate for UniqueEntityValidator (Disparity) + * bug #17287 [HttpKernel] Forcing string comparison on query parameters sort in UriSigner (Tim van Densen) + * bug #17278 [FrameworkBundle] Add case in Kernel directory guess for PHPUnit (tgalopin) + * bug #17276 [Process] Fix potential race condition (nicolas-grekas) + * bug #17183 [FrameworkBundle] Set the kernel.name properly after a cache warmup (jakzal) + * bug #17159 [Yaml] recognize when a block scalar is left (xabbuh) + * bug #17195 bug #14246 [Filesystem] dumpFile() non atomic (Hidde Boomsma) + * bug #17177 [Process] Fix potential race condition leading to transient tests (nicolas-grekas) + * 2.3.36 (2015-12-26) * bug #16864 [Yaml] fix indented line handling in folded blocks (xabbuh) From 656a1939a1d4bb90b013c72ac1e7f5ec5a8cf7a7 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 14 Jan 2016 10:14:40 +0100 Subject: [PATCH 011/226] update CONTRIBUTORS for 2.3.37 --- CONTRIBUTORS.md | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index e131844910157..5786f19dde7d6 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -75,45 +75,45 @@ Symfony is the result of the work of many people who made the code better - Arnaud Le Blanc (arnaud-lb) - Tim Nagel (merk) - Brice BERNARD (brikou) + - Graham Campbell (graham) - Jérôme Tamarelle (gromnan) - marc.weistroff + - Michal Piotrowski (eventhorizon) - lenar - - Graham Campbell (graham) - Włodzimierz Gajda (gajdaw) - - Michal Piotrowski (eventhorizon) - Florian Voutzinos (florianv) - Peter Rehm (rpet) - Colin Frei + - Dariusz Ruminski - Adrien Brault (adrienbrault) - excelwebzone - Jacob Dreesen (jdreesen) - - Dariusz Ruminski - Peter Kokot (maastermedia) - Fabien Pennequin (fabienpennequin) - Pierre du Plessis (pierredup) - Alexander Schwenn (xelaris) - Gordon Franke (gimler) + - Iltar van der Berg (kjarli) - Robert Schönthal (digitalkaoz) - Jérémy DERUSSÉ (jderusse) - Joshua Thijssen - Stefano Sala (stefano.sala) - David Buchmann (dbu) - Issei Murasawa (issei_m) - - Iltar van der Berg (kjarli) - Juti Noppornpitak (shiroyuki) - Eric GELOEN (gelo) - Sebastian Hörl (blogsh) - Daniel Gomes (danielcsgomes) - Hidenori Goto (hidenorigoto) + - Vladimir Reznichenko (kalessil) - Guilherme Blanco (guilhermeblanco) - Pablo Godel (pgodel) - - Vladimir Reznichenko (kalessil) + - Tigran Azatyan (tigranazatyan) - Jérémie Augustin (jaugustin) - Sebastiaan Stok (sstok) - Rafael Dohms (rdohms) - Arnaud Kleinpeter (nanocom) - Alexander M. Turek (derrabus) - - Tigran Azatyan (tigranazatyan) - Richard Shank (iampersistent) - Charles Sarrazin (csarrazi) - Clemens Tolboom @@ -149,6 +149,7 @@ Symfony is the result of the work of many people who made the code better - sun (sun) - Larry Garfield (crell) - Martin Schuhfuß (usefulthink) + - Jáchym Toušek - Matthieu Bontemps (mbontemps) - Pierre Minnieur (pminnieur) - fivestar @@ -166,7 +167,6 @@ Symfony is the result of the work of many people who made the code better - Rui Marinho (ruimarinho) - Julien Brochet (mewt) - Sergey Linnik (linniksa) - - Jáchym Toušek - Marcel Beerta (mazen) - Vincent AUBERT (vincent) - julien pauli (jpauli) @@ -177,6 +177,7 @@ Symfony is the result of the work of many people who made the code better - Elnur Abdurrakhimov (elnur) - Manuel Reinhard (sprain) - Danny Berger (dpb587) + - Diego Saint Esteben (dosten) - Roman Marintšenko (inori) - Xavier Montaña Carreras (xmontana) - Chris Wilkinson (thewilkybarkid) @@ -207,7 +208,6 @@ Symfony is the result of the work of many people who made the code better - Ruben Gonzalez (rubenrua) - Marcos Sánchez - Kim Hemsø Rasmussen (kimhemsoe) - - Diego Saint Esteben (dosten) - Tom Van Looy (tvlooy) - Wouter Van Hecke - Peter Kruithof (pkruithof) @@ -237,6 +237,7 @@ Symfony is the result of the work of many people who made the code better - Jan Decavele (jandc) - Gustavo Piltcher - Stepan Tanasiychuk (stfalcon) + - Titouan Galopin (tgalopin) - Tiago Ribeiro (fixe) - Bob den Otter (bopp) - Adrian Rudnik (kreischweide) @@ -321,6 +322,7 @@ Symfony is the result of the work of many people who made the code better - Jan Schumann - Niklas Fiekas - Mark Challoner (markchalloner) + - Gregor Harlan (gharlan) - Markus Bachmann (baachi) - lancergr - Olivier Dolbeau (odolbeau) @@ -337,6 +339,7 @@ Symfony is the result of the work of many people who made the code better - cedric lombardot (cedriclombardot) - Jonas Flodén (flojon) - Christian Schmidt + - Jakub Kucharovic (jkucharovic) - Marcin Sikoń (marphi) - Dominik Zogg (dominik.zogg) - Mathieu Lemoine @@ -396,7 +399,6 @@ Symfony is the result of the work of many people who made the code better - MatTheCat - John Bafford (jbafford) - Denis Gorbachev (starfall) - - Titouan Galopin (tgalopin) - Steven Surowiec - Kevin Saliou (kbsali) - Ryan @@ -440,7 +442,6 @@ Symfony is the result of the work of many people who made the code better - Wang Jingyu - Åsmund Garfors - Maxime Douailin - - Gregor Harlan - Michael Hirschler (mvhirsch) - Javier López (loalf) - Reinier Kip @@ -457,7 +458,6 @@ Symfony is the result of the work of many people who made the code better - Tristan Maindron (tmaindron) - Ke WANG (yktd26) - Strate - - Jakub Kucharovic - Miquel Rodríguez Telep (mrtorrent) - Sergey Kolodyazhnyy (skolodyazhnyy) - umpirski @@ -507,6 +507,7 @@ Symfony is the result of the work of many people who made the code better - Joshua Nye - Dave Marshall (davedevelopment) - avorobiev + - Gladhon - Venu - Lars Vierbergen - Dennis Hotson @@ -572,6 +573,7 @@ Symfony is the result of the work of many people who made the code better - Aleksey Podskrebyshev - Steffen Roßkamp - David Marín Carreño (davefx) + - Hidde Boomsma (hboomsma) - Jörn Lang (j.lang) - mwsaz - Benoît Bourgeois @@ -615,6 +617,7 @@ Symfony is the result of the work of many people who made the code better - Benoît Merlet (trompette) - Koen Kuipers - datibbaw + - Sébastien Santoro - Raul Fraile (raulfraile) - sensio - Patrick Kaufmann @@ -686,6 +689,7 @@ Symfony is the result of the work of many people who made the code better - Max Beutel - Michal Trojanowski - Catalin Dan + - Mihai Stancu - nacho - Piotr Antosik (antek88) - Artem Lopata @@ -698,6 +702,7 @@ Symfony is the result of the work of many people who made the code better - Max Grigorian (maxakawizard) - benatespina (benatespina) - Denis Kop + - EdgarPE - jfcixmedia - Martijn Evers - Benjamin Paap (benjaminpaap) @@ -980,6 +985,7 @@ Symfony is the result of the work of many people who made the code better - Michal Gebauer - Gleb Sidora - David Stone + - Adrien Lucas (adrienlucas) - Pablo Maria Martelletti (pmartelletti) - Yassine Guedidi (yguedidi) - Luis Muñoz @@ -1056,6 +1062,7 @@ Symfony is the result of the work of many people who made the code better - devel - Trevor Suarez - gedrox + - Mathieu MARCHOIS - dropfen - Andrey Chernykh - Edvinas Klovas @@ -1179,7 +1186,6 @@ Symfony is the result of the work of many people who made the code better - srsbiz - Taylan Kasap - Nicolas A. Bérard-Nault - - Gladhon - Saem Ghani - Stefan Oderbolz - Curtis @@ -1233,6 +1239,7 @@ Symfony is the result of the work of many people who made the code better - Eric J. Duran - cmfcmf - Drew Butler + - pawel-lewtak - Steve Müller - Andras Ratz - andreabreu98 @@ -1260,7 +1267,6 @@ Symfony is the result of the work of many people who made the code better - Pierre-Louis LAUNAY - djama - Eduardo Conceição - - Sébastien Santoro - Jon Cave - Sébastien HOUZE - Abdulkadir N. A. From 2f98f158c968d2bc247318fac612a7cc086316bc Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 14 Jan 2016 10:14:51 +0100 Subject: [PATCH 012/226] updated VERSION for 2.3.37 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 4a88fb37fb237..c90dadfbbd1de 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -58,12 +58,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.3.37-DEV'; + const VERSION = '2.3.37'; const VERSION_ID = 20337; const MAJOR_VERSION = 2; const MINOR_VERSION = 3; const RELEASE_VERSION = 37; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; /** * Constructor. From bbbb0796f43be4017720e868df6558a73a0363a5 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 14 Jan 2016 10:59:28 +0100 Subject: [PATCH 013/226] bumped Symfony version to 2.3.38 --- src/Symfony/Component/HttpKernel/Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index c90dadfbbd1de..04ec2c240b480 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -58,12 +58,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.3.37'; - const VERSION_ID = 20337; + const VERSION = '2.3.38-DEV'; + const VERSION_ID = 20338; const MAJOR_VERSION = 2; const MINOR_VERSION = 3; - const RELEASE_VERSION = 37; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 38; + const EXTRA_VERSION = 'DEV'; /** * Constructor. From 6852a46423970a0fbad0a97d782a5c20c874ce0e Mon Sep 17 00:00:00 2001 From: Possum Date: Thu, 14 Jan 2016 11:04:11 +0100 Subject: [PATCH 014/226] Normalize params only when used. --- src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php b/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php index 2d834d7d404cd..acd8cc0fcd510 100644 --- a/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php +++ b/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php @@ -49,12 +49,8 @@ public function startQuery($sql, array $params = null, array $types = null) $this->stopwatch->start('doctrine', 'doctrine'); } - if (is_array($params)) { - $params = $this->normalizeParams($params); - } - if (null !== $this->logger) { - $this->log($sql, null === $params ? array() : $params); + $this->log($sql, null === $params ? array() : $this->normalizeParams($params)); } } From 3653b6bc7baea54b75fff7301a6879e0e877bae1 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 14 Jan 2016 11:41:16 +0100 Subject: [PATCH 015/226] updated CHANGELOG for 2.7.9 --- CHANGELOG-2.7.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/CHANGELOG-2.7.md b/CHANGELOG-2.7.md index 0055a236352aa..2b6005c098882 100644 --- a/CHANGELOG-2.7.md +++ b/CHANGELOG-2.7.md @@ -7,6 +7,30 @@ in 2.7 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.7.0...v2.7.1 +* 2.7.9 (2016-01-14) + + * security #17359 do not ship with a custom rng implementation (xabbuh, fabpot) + * bug #17314 Fix max width for multibyte keys in choice question (mheki) + * bug #17326 [Console] Display console application name even when no version set (polc) + * bug #17328 [Serializer] Allow to use proxies in object_to_populate (dunglas) + * bug #17347 Workaround https://bugs.php.net/63206 (nicolas-grekas) + * bug #17140 [Serializer] Remove normalizer cache in Serializer class (jvasseur) + * bug #17307 [FrameworkBundle] Fix paths with % in it (like urlencoded) (scaytrase) + * bug #17078 [Bridge] [Doctrine] [Validator] Added support \IteratorAggregate for UniqueEntityValidator (Disparity) + * bug #17298 [FrameworkBundle] Use proper class to fetch $versionStrategy property (dosten) + * bug #17287 [HttpKernel] Forcing string comparison on query parameters sort in UriSigner (Tim van Densen) + * bug #17279 [FrameworkBundle] Add case in Kernel directory guess for PHPUnit (tgalopin) + * bug #17278 [FrameworkBundle] Add case in Kernel directory guess for PHPUnit (tgalopin) + * bug #17275 [PhpUnitBridge] Re-enable the garbage collector (nicolas-grekas) + * bug #17276 [Process] Fix potential race condition (nicolas-grekas) + * bug #17183 [FrameworkBundle] Set the kernel.name properly after a cache warmup (jakzal) + * bug #17159 [Yaml] recognize when a block scalar is left (xabbuh) + * bug #17195 bug #14246 [Filesystem] dumpFile() non atomic (Hidde Boomsma) + * feature #16747 [Form] Improved performance of ChoiceType and its subtypes (webmozart) + * bug #17177 [Process] Fix potential race condition leading to transient tests (nicolas-grekas) + * bug #17163 [Form] fix Catchable Fatal Error if choices is not an array (Gladhon, nicolas-grekas) + * bug #17119 [Form] improve deprecation message for "empty_value" and "choice_list" options. (hhamon) + * 2.7.8 (2015-12-26) * bug #16864 [Yaml] fix indented line handling in folded blocks (xabbuh) From c9b1a84656cabe97e42b9e95874b08805bf09c4d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 14 Jan 2016 11:41:45 +0100 Subject: [PATCH 016/226] updated VERSION for 2.7.9 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 9636d696af1cd..cacc29d2bcabf 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -58,12 +58,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.7.9-DEV'; + const VERSION = '2.7.9'; const VERSION_ID = 20709; const MAJOR_VERSION = 2; const MINOR_VERSION = 7; const RELEASE_VERSION = 9; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '05/2018'; const END_OF_LIFE = '05/2019'; From 07673dcd3828defb8c4d07e58c3f0983cf157be2 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 14 Jan 2016 12:52:48 +0100 Subject: [PATCH 017/226] bumped Symfony version to 2.7.10 --- src/Symfony/Component/HttpKernel/Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index cacc29d2bcabf..989517dcbb4a4 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -58,12 +58,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.7.9'; - const VERSION_ID = 20709; + const VERSION = '2.7.10-DEV'; + const VERSION_ID = 20710; const MAJOR_VERSION = 2; const MINOR_VERSION = 7; - const RELEASE_VERSION = 9; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 10; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '05/2018'; const END_OF_LIFE = '05/2019'; From 50d55f68552a0fd41745a94528f89b9d23c9d6a3 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Thu, 14 Jan 2016 14:17:14 +0100 Subject: [PATCH 018/226] [SecurityBundle] fix SecureRandom service constructor args --- .../Bundle/SecurityBundle/Resources/config/security.xml | 6 +----- src/Symfony/Bundle/SecurityBundle/composer.json | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml b/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml index 0e65fcfe1530c..956bf89aa4ee2 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml @@ -141,10 +141,6 @@ - - - %kernel.cache_dir%/secure_random.seed - - + diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json index 98f4fd0fff00c..2c18a26bc54cf 100644 --- a/src/Symfony/Bundle/SecurityBundle/composer.json +++ b/src/Symfony/Bundle/SecurityBundle/composer.json @@ -17,7 +17,7 @@ ], "require": { "php": ">=5.3.3", - "symfony/security": "~2.2", + "symfony/security": "~2.3.37|~2.6.13|~2.7.9|~2.8", "symfony/security-acl": "~2.2", "symfony/http-kernel": "~2.2" }, From d1f72d8ef4e1b2b4bc20c6c8736858004fcb7005 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 14 Jan 2016 14:08:57 +0100 Subject: [PATCH 019/226] Fix perf and mem issue when using token_get_all --- .../Translation/PhpExtractor.php | 6 +++--- .../ClassLoader/ClassCollectionLoader.php | 17 +++++++++-------- .../Component/ClassLoader/ClassMapGenerator.php | 17 +++++++++-------- src/Symfony/Component/HttpKernel/Kernel.php | 9 +++++---- .../Component/HttpKernel/Tests/KernelTest.php | 4 ++-- .../Routing/Loader/AnnotationFileLoader.php | 14 +++++++------- 6 files changed, 35 insertions(+), 32 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php index e8479eb5cfde8..8bfa99da62520 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php @@ -81,7 +81,7 @@ public function setPrefix($prefix) */ protected function normalizeToken($token) { - if (is_array($token)) { + if (isset($token[1]) && 'b"' !== $token) { return $token[1]; } @@ -95,7 +95,7 @@ private function seekToNextRelevantToken(\Iterator $tokenIterator) { for (; $tokenIterator->valid(); $tokenIterator->next()) { $t = $tokenIterator->current(); - if (!is_array($t) || ($t[0] !== T_WHITESPACE)) { + if (T_WHITESPACE !== $t[0]) { break; } } @@ -112,7 +112,7 @@ private function getMessage(\Iterator $tokenIterator) for (; $tokenIterator->valid(); $tokenIterator->next()) { $t = $tokenIterator->current(); - if (!is_array($t)) { + if (!isset($t[1])) { break; } diff --git a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php index f811cd0a71fa0..a137a3cf5c563 100644 --- a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php +++ b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php @@ -149,8 +149,9 @@ public static function fixNamespaceDeclarations($source) $inNamespace = false; $tokens = token_get_all($source); - for (reset($tokens); false !== $token = current($tokens); next($tokens)) { - if (is_string($token)) { + for ($i = 0; isset($tokens[$i]); ++$i) { + $token = $tokens[$i]; + if (!isset($token[1]) || 'b"' === $token) { $rawChunk .= $token; } elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) { // strip comments @@ -162,12 +163,12 @@ public static function fixNamespaceDeclarations($source) $rawChunk .= $token[1]; // namespace name and whitespaces - while (($t = next($tokens)) && is_array($t) && in_array($t[0], array(T_WHITESPACE, T_NS_SEPARATOR, T_STRING))) { - $rawChunk .= $t[1]; + while (isset($tokens[++$i][1]) && in_array($tokens[$i][0], array(T_WHITESPACE, T_NS_SEPARATOR, T_STRING))) { + $rawChunk .= $tokens[$i][1]; } - if ('{' === $t) { + if ('{' === $tokens[$i]) { $inNamespace = false; - prev($tokens); + --$i; } else { $rawChunk = rtrim($rawChunk)."\n{"; $inNamespace = true; @@ -175,8 +176,8 @@ public static function fixNamespaceDeclarations($source) } elseif (T_START_HEREDOC === $token[0]) { $output .= self::compressCode($rawChunk).$token[1]; do { - $token = next($tokens); - $output .= is_string($token) ? $token : $token[1]; + $token = $tokens[++$i]; + $output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token; } while ($token[0] !== T_END_HEREDOC); $output .= "\n"; $rawChunk = ''; diff --git a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php index a4ddce5115fa7..2f88df12e3d20 100644 --- a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php +++ b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php @@ -95,10 +95,10 @@ private static function findClasses($path) $classes = array(); $namespace = ''; - for ($i = 0, $max = count($tokens); $i < $max; ++$i) { + for ($i = 0; isset($tokens[$i]); ++$i) { $token = $tokens[$i]; - if (is_string($token)) { + if (!isset($token[1])) { continue; } @@ -108,9 +108,9 @@ private static function findClasses($path) case T_NAMESPACE: $namespace = ''; // If there is a namespace, extract it - while (($t = $tokens[++$i]) && is_array($t)) { - if (in_array($t[0], array(T_STRING, T_NS_SEPARATOR))) { - $namespace .= $t[1]; + while (isset($tokens[++$i][1])) { + if (in_array($tokens[$i][0], array(T_STRING, T_NS_SEPARATOR))) { + $namespace .= $tokens[$i][1]; } } $namespace .= '\\'; @@ -121,7 +121,7 @@ private static function findClasses($path) // Skip usage of ::class constant $isClassConstant = false; for ($j = $i - 1; $j > 0; --$j) { - if (is_string($tokens[$j])) { + if (!isset($tokens[$j][1])) { break; } @@ -138,10 +138,11 @@ private static function findClasses($path) } // Find the classname - while (($t = $tokens[++$i]) && is_array($t)) { + while (isset($tokens[++$i][1])) { + $t = $tokens[$i]; if (T_STRING === $t[0]) { $class .= $t[1]; - } elseif ($class !== '' && T_WHITESPACE == $t[0]) { + } elseif ('' !== $class && T_WHITESPACE === $t[0]) { break; } } diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 04ec2c240b480..6df51ae12d2cd 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -699,14 +699,15 @@ public static function stripComments($source) $output = ''; $tokens = token_get_all($source); $ignoreSpace = false; - for (reset($tokens); false !== $token = current($tokens); next($tokens)) { - if (is_string($token)) { + for ($i = 0; isset($tokens[$i]); ++$i) { + $token = $tokens[$i]; + if (!isset($token[1]) || 'b"' === $token) { $rawChunk .= $token; } elseif (T_START_HEREDOC === $token[0]) { $output .= $rawChunk.$token[1]; do { - $token = next($tokens); - $output .= $token[1]; + $token = $tokens[++$i]; + $output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token; } while ($token[0] !== T_END_HEREDOC); $rawChunk = ''; } elseif (T_WHITESPACE === $token[0]) { diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index 6bf5c258846d3..fa1294e80654c 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -307,7 +307,7 @@ public function testStripComments() $heredoc = << Date: Thu, 14 Jan 2016 14:31:24 +0100 Subject: [PATCH 020/226] bumped Symfony version to 2.8.3 --- src/Symfony/Component/HttpKernel/Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index da96ac0f5c6ff..547fd11b7ee9a 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.8.2'; - const VERSION_ID = 20802; + const VERSION = '2.8.3-DEV'; + const VERSION_ID = 20803; const MAJOR_VERSION = 2; const MINOR_VERSION = 8; - const RELEASE_VERSION = 2; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 3; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '11/2018'; const END_OF_LIFE = '11/2019'; From f1f9754bcb69fb69192fed08e298026e13d958e8 Mon Sep 17 00:00:00 2001 From: Wouter de Wild Date: Thu, 14 Jan 2016 13:21:56 +0100 Subject: [PATCH 021/226] [HttpFoundation][Cookie] Cookie DateTimeInterface fix --- src/Symfony/Component/HttpFoundation/Cookie.php | 16 ++++++++-------- .../HttpFoundation/Tests/CookieTest.php | 11 +++++++++++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Cookie.php b/src/Symfony/Component/HttpFoundation/Cookie.php index 061703d9ca0e8..13d69f3bd2edd 100644 --- a/src/Symfony/Component/HttpFoundation/Cookie.php +++ b/src/Symfony/Component/HttpFoundation/Cookie.php @@ -29,13 +29,13 @@ class Cookie /** * Constructor. * - * @param string $name The name of the cookie - * @param string $value The value of the cookie - * @param int|string|\DateTime $expire The time the cookie expires - * @param string $path The path on the server in which the cookie will be available on - * @param string $domain The domain that the cookie is available to - * @param bool $secure Whether the cookie should only be transmitted over a secure HTTPS connection from the client - * @param bool $httpOnly Whether the cookie will be made accessible only through the HTTP protocol + * @param string $name The name of the cookie + * @param string $value The value of the cookie + * @param int|string|\DateTime|\DateTimeInterface $expire The time the cookie expires + * @param string $path The path on the server in which the cookie will be available on + * @param string $domain The domain that the cookie is available to + * @param bool $secure Whether the cookie should only be transmitted over a secure HTTPS connection from the client + * @param bool $httpOnly Whether the cookie will be made accessible only through the HTTP protocol * * @throws \InvalidArgumentException */ @@ -51,7 +51,7 @@ public function __construct($name, $value = null, $expire = 0, $path = '/', $dom } // convert expiration time to a Unix timestamp - if ($expire instanceof \DateTime) { + if ($expire instanceof \DateTime || $expire instanceof \DateTimeInterface) { $expire = $expire->format('U'); } elseif (!is_numeric($expire)) { $expire = strtotime($expire); diff --git a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php index fd90103e42e3d..222786533ecca 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php @@ -85,6 +85,17 @@ public function testConstructorWithDateTime() $this->assertEquals($expire->format('U'), $cookie->getExpiresTime(), '->getExpiresTime() returns the expire date'); } + /** + * @requires PHP 5.5 + */ + public function testConstructorWithDateTimeImmutable() + { + $expire = new \DateTimeImmutable(); + $cookie = new Cookie('foo', 'bar', $expire); + + $this->assertEquals($expire->format('U'), $cookie->getExpiresTime(), '->getExpiresTime() returns the expire date'); + } + public function testGetExpiresTimeWithStringValue() { $value = '+1 day'; From 623595f0d6446ab29bfd40bf65fa3948ed8a77f9 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 11 Jan 2016 10:55:59 +0100 Subject: [PATCH 022/226] [ClassLoader] Use symfony/polyfill-apcu --- .travis.yml | 5 +++-- composer.json | 1 + src/Symfony/Component/ClassLoader/ApcClassLoader.php | 8 ++++---- src/Symfony/Component/ClassLoader/composer.json | 3 ++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 25897fabe6f78..20edf72737c31 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,8 +38,9 @@ before_install: - echo session.gc_probability = 0 >> $INI_FILE - if [[ $TRAVIS_PHP_VERSION = 5.* ]]; then echo extension = mongo.so >> $INI_FILE; fi; - if [[ $TRAVIS_PHP_VERSION = 5.* ]]; then echo extension = memcache.so >> $INI_FILE; fi; - - if [[ $TRAVIS_PHP_VERSION = 5.* ]]; then (echo yes | pecl install -f apcu-4.0.10 && echo apc.enable_cli = 1 >> $INI_FILE) || echo "Let's continue without apcu extension"; fi; - - if [[ $TRAVIS_PHP_VERSION = 5.* ]]; then pecl install -f memcached-2.1.0 || echo "Let's continue without memcached extension"; fi; + - if [[ $TRAVIS_PHP_VERSION = 5.* ]]; then (echo yes | pecl install -f apcu-4.0.10 && echo apc.enable_cli = 1 >> $INI_FILE); fi; + - if [[ $TRAVIS_PHP_VERSION = 7.* ]]; then (echo yes | pecl install -f apcu-5.1.2 && echo apc.enable_cli = 1 >> $INI_FILE); fi; + - if [[ $TRAVIS_PHP_VERSION = 5.* ]]; then pecl install -f memcached-2.1.0; fi; - if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then echo extension = ldap.so >> $INI_FILE; fi; - if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then phpenv config-rm xdebug.ini; fi; - if [[ $TRAVIS_REPO_SLUG = symfony/symfony ]]; then cp .composer-auth.json ~/.composer/auth.json; fi; diff --git a/composer.json b/composer.json index d460e34439cc9..0cd67a4c0930d 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,7 @@ "php": ">=5.3.3", "doctrine/common": "~2.4", "paragonie/random_compat": "~1.0", + "symfony/polyfill-apcu": "~1.0,>=1.0.2", "twig/twig": "~1.23|~2.0", "psr/log": "~1.0" }, diff --git a/src/Symfony/Component/ClassLoader/ApcClassLoader.php b/src/Symfony/Component/ClassLoader/ApcClassLoader.php index 9170929a1014b..4f71ea173d50b 100644 --- a/src/Symfony/Component/ClassLoader/ApcClassLoader.php +++ b/src/Symfony/Component/ClassLoader/ApcClassLoader.php @@ -67,8 +67,8 @@ class ApcClassLoader */ public function __construct($prefix, $decorated) { - if (!extension_loaded('apc')) { - throw new \RuntimeException('Unable to use ApcClassLoader as APC is not enabled.'); + if (!function_exists('apcu_fetch')) { + throw new \RuntimeException('Unable to use ApcClassLoader as APC is not installed.'); } if (!method_exists($decorated, 'findFile')) { @@ -122,8 +122,8 @@ public function loadClass($class) */ public function findFile($class) { - if (false === $file = apc_fetch($this->prefix.$class)) { - apc_store($this->prefix.$class, $file = $this->decorated->findFile($class)); + if (false === $file = apcu_fetch($this->prefix.$class)) { + apcu_store($this->prefix.$class, $file = $this->decorated->findFile($class)); } return $file; diff --git a/src/Symfony/Component/ClassLoader/composer.json b/src/Symfony/Component/ClassLoader/composer.json index 1796ab0b51f5b..86bb70a6d717e 100644 --- a/src/Symfony/Component/ClassLoader/composer.json +++ b/src/Symfony/Component/ClassLoader/composer.json @@ -17,7 +17,8 @@ ], "minimum-stability": "dev", "require": { - "php": ">=5.3.3" + "php": ">=5.3.3", + "symfony/polyfill-apcu": "~1.0,>=1.0.2" }, "require-dev": { "symfony/finder": "~2.0,>=2.0.5" From dc8f780f6b709071d69b741c073723d36f1f3185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1chym=20Tou=C5=A1ek?= Date: Thu, 14 Jan 2016 20:10:56 +0100 Subject: [PATCH 023/226] [TwigBridge] Use label_format option for checkbox and radio labels --- .../Resources/views/Form/bootstrap_3_layout.html.twig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig index 165236ef613ec..5affc7a6a1b92 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig @@ -167,7 +167,14 @@ {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ parent_label_class)|trim}) %} {% endif %} {% if label is not same as(false) and label is empty %} - {% set label = name|humanize %} + {%- if label_format is not empty -%} + {% set label = label_format|replace({ + '%name%': name, + '%id%': id, + }) %} + {%- else -%} + {% set label = name|humanize %} + {%- endif -%} {% endif %} {{- widget|raw }} {{ label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}} From 6fbd9a7cf644c9253821e0bb85513add41224852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1chym=20Tou=C5=A1ek?= Date: Thu, 14 Jan 2016 21:01:28 +0100 Subject: [PATCH 024/226] [TwigBridge] Use label_format option for checkbox and radio labels --- .../Resources/views/Form/foundation_5_layout.html.twig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/foundation_5_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/foundation_5_layout.html.twig index 77e37da0205ce..dc7bec9fb6ccd 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/foundation_5_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/foundation_5_layout.html.twig @@ -249,7 +249,14 @@ {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ parent_label_class)|trim}) %} {% endif %} {% if label is empty %} - {% set label = name|humanize %} + {%- if label_format is not empty -%} + {% set label = label_format|replace({ + '%name%': name, + '%id%': id, + }) %} + {%- else -%} + {% set label = name|humanize %} + {%- endif -%} {% endif %} {{ widget|raw }} From 2bb5f45aea15df6824eadf9bf9c10b9145a3ec11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vasseur?= Date: Wed, 6 Jan 2016 22:10:50 +0100 Subject: [PATCH 025/226] Refactor serializer normalize method --- .../Component/Serializer/Serializer.php | 42 ++++--------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/src/Symfony/Component/Serializer/Serializer.php b/src/Symfony/Component/Serializer/Serializer.php index eb83544b428ff..00e8b2b8ce527 100644 --- a/src/Symfony/Component/Serializer/Serializer.php +++ b/src/Symfony/Component/Serializer/Serializer.php @@ -127,10 +127,8 @@ public function normalize($data, $format = null, array $context = array()) if (null === $data || is_scalar($data)) { return $data; } - if (is_object($data) && $this->supportsNormalization($data, $format)) { - return $this->normalizeObject($data, $format, $context); - } - if ($data instanceof \Traversable) { + + if (is_array($data) || $data instanceof \Traversable) { $normalized = array(); foreach ($data as $key => $val) { $normalized[$key] = $this->normalize($val, $format, $context); @@ -138,16 +136,15 @@ public function normalize($data, $format = null, array $context = array()) return $normalized; } + if (is_object($data)) { - return $this->normalizeObject($data, $format, $context); - } - if (is_array($data)) { - foreach ($data as $key => $val) { - $data[$key] = $this->normalize($val, $format, $context); + if (!$this->normalizers) { + throw new LogicException('You must register at least one normalizer to be able to normalize objects.'); } - return $data; + throw new UnexpectedValueException(sprintf('Could not normalize object of type %s, no supporting normalizer found.', get_class($data))); } + throw new UnexpectedValueException(sprintf('An unexpected value could not be normalized: %s', var_export($data, true))); } @@ -230,31 +227,6 @@ final public function decode($data, $format, array $context = array()) return $this->decoder->decode($data, $format, $context); } - /** - * Normalizes an object into a set of arrays/scalars. - * - * @param object $object object to normalize - * @param string $format format name, present to give the option to normalizers to act differently based on formats - * @param array $context The context data for this particular normalization - * - * @return array|string|bool|int|float|null - * - * @throws LogicException - * @throws UnexpectedValueException - */ - private function normalizeObject($object, $format, array $context = array()) - { - if (!$this->normalizers) { - throw new LogicException('You must register at least one normalizer to be able to normalize objects.'); - } - - if ($normalizer = $this->getNormalizer($object, $format)) { - return $normalizer->normalize($object, $format, $context); - } - - throw new UnexpectedValueException(sprintf('Could not normalize object of type %s, no supporting normalizer found.', get_class($object))); - } - /** * Denormalizes data back into an object of the given class. * From 197413168c43e4366e8500abc01193924d669e6e Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 15 Jan 2016 09:07:14 +0100 Subject: [PATCH 026/226] Removed a duplicated test in CardSchemeValidatorTest --- .../Validator/Tests/Constraints/CardSchemeValidatorTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php index 11418ac707dcd..93cd84d4b180e 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php @@ -92,7 +92,6 @@ public function getValidNumbers() array('MAESTRO', '5020507657408074712'), array('MAESTRO', '5612559223580173965'), array('MAESTRO', '6759744069209'), - array('MAESTRO', '6759744069209'), array('MAESTRO', '6594371785970435599'), array('MASTERCARD', '5555555555554444'), array('MASTERCARD', '5105105105105100'), From e555aade120b0950ee63ed10e792dd602e749214 Mon Sep 17 00:00:00 2001 From: Peter Ward Date: Fri, 15 Jan 2016 08:12:11 +0000 Subject: [PATCH 027/226] Add gc_mem_caches() call for PHP7 after itoken_get_all() as new memory manager will not release small buckets to OS automatically --- .../FrameworkBundle/Translation/PhpExtractor.php | 5 +++++ .../Component/ClassLoader/ClassCollectionLoader.php | 10 +++++++++- .../Component/ClassLoader/ClassMapGenerator.php | 5 +++++ src/Symfony/Component/HttpKernel/Kernel.php | 6 ++++++ .../Component/Routing/Loader/AnnotationFileLoader.php | 4 ++++ 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php index 8bfa99da62520..f68f8a7979ae4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php @@ -61,6 +61,11 @@ public function extract($directory, MessageCatalogue $catalog) $files = $finder->files()->name('*.php')->in($directory); foreach ($files as $file) { $this->parseTokens(token_get_all(file_get_contents($file)), $catalog); + + if (PHP_VERSION_ID >= 70000) { + // PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098 + gc_mem_caches(); + } } } diff --git a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php index a137a3cf5c563..ba0b2e032a78a 100644 --- a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php +++ b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php @@ -193,7 +193,15 @@ public static function fixNamespaceDeclarations($source) $rawChunk .= "}\n"; } - return $output.self::compressCode($rawChunk); + $output .= self::compressCode($rawChunk); + + if (PHP_VERSION_ID >= 70000) { + // PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098 + unset($tokens, $rawChunk); + gc_mem_caches(); + } + + return $output; } /** diff --git a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php index 2f88df12e3d20..07c974f4283dd 100644 --- a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php +++ b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php @@ -72,6 +72,11 @@ public static function createMap($dir) $classes = self::findClasses($path); + if (PHP_VERSION_ID >= 70000) { + // PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098 + gc_mem_caches(); + } + foreach ($classes as $class) { $map[$class] = $path; } diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 6df51ae12d2cd..fa849e02a1f63 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -733,6 +733,12 @@ public static function stripComments($source) $output .= $rawChunk; + if (PHP_VERSION_ID >= 70000) { + // PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098 + unset($tokens, $rawChunk); + gc_mem_caches(); + } + return $output; } diff --git a/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php index 51ead25e79ac2..a3a7e0e5ae50e 100644 --- a/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php @@ -64,6 +64,10 @@ public function load($file, $type = null) $collection->addResource(new FileResource($path)); $collection->addCollection($this->loader->load($class, $type)); } + if (PHP_VERSION_ID >= 70000) { + // PHP 7 memory manager will not release after token_get_all(), see https://bugs.php.net/70098 + gc_mem_caches(); + } return $collection; } From c847feb5f3fbe6509e3cda29de77e7afb44f0f26 Mon Sep 17 00:00:00 2001 From: Robin van der Vleuten Date: Fri, 15 Jan 2016 15:32:28 +0100 Subject: [PATCH 028/226] Fixed correct class name in thrown exception --- src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php index 11d8f34d5ad41..24505add17b76 100644 --- a/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php +++ b/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php @@ -120,7 +120,7 @@ public function load($class, $type = null) $class = new \ReflectionClass($class); if ($class->isAbstract()) { - throw new \InvalidArgumentException(sprintf('Annotations from class "%s" cannot be read as it is abstract.', $class)); + throw new \InvalidArgumentException(sprintf('Annotations from class "%s" cannot be read as it is abstract.', $class->getName())); } if ($annot = $this->reader->getClassAnnotation($class, $this->routeAnnotationClass)) { From 51e3652aeb33587e163d39547938a2afea92cb07 Mon Sep 17 00:00:00 2001 From: Ener-Getick Date: Sat, 16 Jan 2016 14:42:15 +0100 Subject: [PATCH 029/226] Use is_subclass_of instead of Reflection when possible --- .../Component/Serializer/Normalizer/CustomNormalizer.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php index 83c3c14384622..e3f09a943613c 100644 --- a/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php @@ -59,8 +59,6 @@ public function supportsNormalization($data, $format = null) */ public function supportsDenormalization($data, $type, $format = null) { - $class = new \ReflectionClass($type); - - return $class->isSubclassOf('Symfony\Component\Serializer\Normalizer\DenormalizableInterface'); + return is_subclass_of($type, 'Symfony\Component\Serializer\Normalizer\DenormalizableInterface'); } } From 5af5d06f2e5ad11021365251c253f0b2c8d22e17 Mon Sep 17 00:00:00 2001 From: Ener-Getick Date: Sat, 16 Jan 2016 14:49:05 +0100 Subject: [PATCH 030/226] Use is_subclass_of instead of reflection --- .../DependencyInjection/Compiler/AddConsoleCommandPass.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConsoleCommandPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConsoleCommandPass.php index 3c96761ba3a6c..4ab0d82ed120a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConsoleCommandPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConsoleCommandPass.php @@ -37,8 +37,7 @@ public function process(ContainerBuilder $container) } $class = $container->getParameterBag()->resolveValue($definition->getClass()); - $r = new \ReflectionClass($class); - if (!$r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command')) { + if (!is_subclass_of($class, 'Symfony\\Component\\Console\\Command\\Command')) { throw new \InvalidArgumentException(sprintf('The service "%s" tagged "console.command" must be a subclass of "Symfony\\Component\\Console\\Command\\Command".', $id)); } $container->setAlias('console.command.'.strtolower(str_replace('\\', '_', $class)), $id); From aedeebb4f1c5108f40a8551f3eb7e02a92807c6a Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Sat, 16 Jan 2016 18:29:47 +0100 Subject: [PATCH 031/226] fix merge 2.3 into 2.7 for SecureRandom dependency --- src/Symfony/Bundle/FrameworkBundle/composer.json | 2 +- src/Symfony/Bundle/SecurityBundle/composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index 045d19c354e73..bcfce7b707007 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -26,7 +26,7 @@ "symfony/http-kernel": "~2.7", "symfony/filesystem": "~2.3", "symfony/routing": "~2.6,>2.6.4", - "symfony/security-core": "~2.6", + "symfony/security-core": "~2.6.13|~2.7.9|~2.8", "symfony/security-csrf": "~2.6", "symfony/stopwatch": "~2.3", "symfony/templating": "~2.1", diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json index e702a90990898..f00e09ca3c908 100644 --- a/src/Symfony/Bundle/SecurityBundle/composer.json +++ b/src/Symfony/Bundle/SecurityBundle/composer.json @@ -17,7 +17,7 @@ ], "require": { "php": ">=5.3.9", - "symfony/security": "~2.7.9|~2.8", + "symfony/security": "~2.7", "symfony/security-acl": "~2.7", "symfony/http-kernel": "~2.2" }, From 8d5b9d572a96faf57914f181d2eb14ee071e60f2 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 16 Jan 2016 19:17:20 +0100 Subject: [PATCH 032/226] synchronize 2.7 and 3.0 upgrade files --- UPGRADE-3.0.md | 63 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md index 5f045f7c51f51..c572a20a15ae5 100644 --- a/UPGRADE-3.0.md +++ b/UPGRADE-3.0.md @@ -19,6 +19,12 @@ UPGRADE FROM 2.x to 3.0 * The `DebugUniversalClassLoader` class has been removed in favor of `DebugClassLoader`. The difference is that the constructor now takes a loader to wrap. + ``` + +### Config + + * The `__toString()` method of the `\Symfony\Component\Config\ConfigCache` class + was removed in favor of the new `getPath()` method. ### Console @@ -99,6 +105,26 @@ UPGRADE FROM 2.x to 3.0 removed: `ContainerBuilder::synchronize()`, `Definition::isSynchronized()`, and `Definition::setSynchronized()`. +### DoctrineBridge + + * The `property` option of `DoctrineType` was removed in favor of the `choice_label` option. + + * The `loader` option of `DoctrineType` was removed. You now have to override the `getLoader()` + method in your custom type. + + * The `Symfony\Bridge\Doctrine\Form\ChoiceList\EntityChoiceList` was removed in favor + of `Symfony\Bridge\Doctrine\Form\ChoiceList\DoctrineChoiceLoader`. + + * Passing a query builder closure to `ORMQueryBuilderLoader` is not supported anymore. + You should pass resolved query builders only. + + Consequently, the arguments `$manager` and `$class` of `ORMQueryBuilderLoader` + have been removed as well. + + Note that the `query_builder` option of `DoctrineType` *does* support + closures, but the closure is now resolved in the type instead of in the + loader. + ### EventDispatcher * The interface `Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface` @@ -106,6 +132,11 @@ UPGRADE FROM 2.x to 3.0 ### Form + * The `ChoiceToBooleanArrayTransformer`, `ChoicesToBooleanArrayTransformer`, + `FixRadioInputListener`, and `FixCheckboxInputListener` classes were removed. + + * The `choice_list` option of `ChoiceType` was removed. + * The option "precision" was renamed to "scale". Before: @@ -271,11 +302,11 @@ UPGRADE FROM 2.x to 3.0 `NumberToLocalizedStringTransformer` were renamed to `ROUND_HALF_EVEN`, `ROUND_HALF_UP` and `ROUND_HALF_DOWN`. - * The methods `ChoiceListInterface::getIndicesForChoices()` and - `ChoiceListInterface::getIndicesForValues()` were removed. No direct - replacement exists, although in most cases - `ChoiceListInterface::getChoicesForValues()` and - `ChoiceListInterface::getValuesForChoices()` should be sufficient. + * The `Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface` was + removed in favor of `Symfony\Component\Form\ChoiceList\ChoiceListInterface`. + + * `Symfony\Component\Form\Extension\Core\View\ChoiceView` was removed in favor of + `Symfony\Component\Form\ChoiceList\View\ChoiceView`. * The interface `Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface` and all of its implementations were removed. Use the new interface @@ -544,7 +575,7 @@ UPGRADE FROM 2.x to 3.0 * Some route settings have been renamed: - * The `pattern` setting for a route has been deprecated in favor of `path` + * The `pattern` setting has been removed in favor of `path` * The `_scheme` and `_method` requirements have been moved to the `schemes` and `methods` settings Before: @@ -597,10 +628,23 @@ UPGRADE FROM 2.x to 3.0 the performance gains were minimal and it's hard to replicate the behaviour of PHP implementation. + * The `getMatcherDumperInstance()` and `getGeneratorDumperInstance()` methods in the + `Symfony\Component\Routing\Router` have been changed from `public` to `protected`. + ### Security * The `Resources/` directory was moved to `Core/Resources/` +### Serializer + + * The `setCamelizedAttributes()` method of the + `Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer` and + `Symfony\Component\Serializer\Normalizer\PropertyNormalizer` classes + was removed. + + * The `Symfony\Component\Serializer\Exception\Exception` interface was removed + in favor of the new `Symfony\Component\Serializer\Exception\ExceptionInterface`. + ### Translator * The `Translator::setFallbackLocale()` method has been removed in favor of @@ -665,11 +709,18 @@ UPGRADE FROM 2.x to 3.0 ### TwigBundle + * The `Symfony\Bundle\TwigBundle\TwigDefaultEscapingStrategy` was removed + in favor of `Twig_FileExtensionEscapingStrategy`. + * The `twig:debug` command has been deprecated since Symfony 2.7 and will be removed in Symfony 3.0. Use the `debug:twig` command instead. ### Validator + * The PHP7-incompatible constraints (`Null`, `True`, `False`) and their related + validators (`NullValidator`, `TrueValidator`, `FalseValidator`) have been + removed in favor of their `Is`-prefixed equivalent. + * The class `Symfony\Component\Validator\Mapping\Cache\ApcCache` has been removed in favor of `Symfony\Component\Validator\Mapping\Cache\DoctrineCache`. From 1ecbb32c3a89738cd46225b26ebe1a8ffde89c0f Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 16 Jan 2016 17:20:11 +0100 Subject: [PATCH 033/226] update upgrade files with CSRF related option info --- UPGRADE-2.8.md | 26 +++++++++++++++++++------- UPGRADE-3.0.md | 30 ++++++++++++++++++++---------- 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/UPGRADE-2.8.md b/UPGRADE-2.8.md index 7acc2baa347b6..9ebaf0e0be985 100644 --- a/UPGRADE-2.8.md +++ b/UPGRADE-2.8.md @@ -18,6 +18,12 @@ All components Form ---- + * The `intention` option was deprecated and will be removed in 3.0 in favor + of the new `csrf_token_id` option. + + * The `csrf_provider` option was deprecated and will be removed in 3.0 in favor + of the new `csrf_token_generator` option. + * The "cascade_validation" option was deprecated. Use the "constraints" option together with the `Valid` constraint instead. Contrary to "cascade_validation", "constraints" must be set on the respective child forms, @@ -203,7 +209,7 @@ Form * In Symfony 2.7 a small BC break was introduced with the new choices_as_values option. In order to have the choice values populated to the html value attribute you had to define the choice_value option. This is now not any more needed. - + Before: ```php @@ -221,9 +227,9 @@ Form }, )); ``` - + After (Symfony 2.8+): - + ```php $form->add('status', ChoiceType::class, array( 'choices' => array( @@ -262,13 +268,13 @@ Form } } ``` - + * The option "options" of the CollectionType has been renamed to "entry_options". The usage of the option "options" is deprecated and will be removed in Symfony 3.0. * The option "type" of the CollectionType has been renamed to "entry_type". The usage of the option "type" is deprecated and will be removed in Symfony 3.0. - As a value for the option you should provide the fully-qualified class name (FQCN) + As a value for the option you should provide the fully-qualified class name (FQCN) now as well. * Passing type instances to `Form::add()`, `FormBuilder::add()` and the @@ -409,8 +415,8 @@ DependencyInjection ``` - * `Symfony\Component\DependencyInjection\ContainerAware` has been deprecated, use - `Symfony\Component\DependencyInjection\ContainerAwareTrait` or implement + * `Symfony\Component\DependencyInjection\ContainerAware` has been deprecated, use + `Symfony\Component\DependencyInjection\ContainerAwareTrait` or implement `Symfony\Component\DependencyInjection\ContainerAwareInterface` manually WebProfiler @@ -522,12 +528,18 @@ Security * The `intention` option is deprecated for all the authentication listeners, and will be removed in 3.0. Use the `csrf_token_id` option instead. + * The `csrf_provider` option is deprecated for all the authentication listeners, + and will be removed in 3.0. Use the `csrf_token_generator` option instead. + SecurityBundle -------------- * The `intention` firewall listener setting is deprecated, and will be removed in 3.0. Use the `csrf_token_id` option instead. + * The `csrf_provider` firewall listener setting is deprecated, and will be removed in 3.0. + Use the `csrf_token_generator` option instead. + Config ------ diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md index 9467925e56c28..afc996a81a9d2 100644 --- a/UPGRADE-3.0.md +++ b/UPGRADE-3.0.md @@ -264,12 +264,12 @@ UPGRADE FROM 2.x to 3.0 // ... } ``` - + * The option "options" of the CollectionType has been renamed to "entry_options". * The option "type" of the CollectionType has been renamed to "entry_type". - As a value for the option you must provide the fully-qualified class name (FQCN) - now as well. + As a value for the option you must provide the fully-qualified class name (FQCN) + now as well. * The `FormIntegrationTestCase` and `FormPerformanceTestCase` classes were moved form the `Symfony\Component\Form\Tests` namespace to the `Symfony\Component\Form\Test` namespace. @@ -317,8 +317,8 @@ UPGRADE FROM 2.x to 3.0 * The `Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList` class has been removed in favor of `Symfony\Component\Form\ChoiceList\ArrayChoiceList`. - - * The `TimezoneType::getTimezones()` method was removed. You should not use + + * The `TimezoneType::getTimezones()` method was removed. You should not use this method. * The `Symfony\Component\Form\ChoiceList\ArrayKeyChoiceList` class has been removed in @@ -365,11 +365,11 @@ UPGRADE FROM 2.x to 3.0 } } ``` - + * In Symfony 2.7 a small BC break was introduced with the new choices_as_values option. In order to have the choice values populated to the html value attribute you had to define the choice_value option. This is now not any more needed. - + Before: ```php @@ -389,9 +389,9 @@ UPGRADE FROM 2.x to 3.0 }, )); ``` - + After: - + ```php $form->add('status', ChoiceType::class, array( 'choices' => array( @@ -400,7 +400,7 @@ UPGRADE FROM 2.x to 3.0 'Ignored' => Status::IGNORED, ) )); - ``` + ``` * The `request` service was removed. You must inject the `request_stack` service instead. @@ -774,6 +774,16 @@ UPGRADE FROM 2.x to 3.0 } ``` + * The `intention` option was renamed to `csrf_token_id` for all the authentication listeners. + + * The `csrf_provider` option was renamed to `csrf_token_generator` for all the authentication listeners. + +### SecurityBundle + + * The `intention` firewall listener setting was renamed to `csrf_token_id`. + + * The `csrf_provider` firewall listener setting was renamed to `csrf_token_generator`. + ### Translator * The `Translator::setFallbackLocale()` method has been removed in favor of From f6a078b96cd61556a6500c67735ba032eb94ab8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Par=C3=A1da=20J=C3=B3zsef?= Date: Sat, 16 Jan 2016 13:37:00 +0100 Subject: [PATCH 034/226] [FrameworkBundle] Optimize framework extension tests --- .../Tests/DependencyInjection/FrameworkExtensionTest.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 33b5fa7f3474e..5b64b4e5243d7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -18,6 +18,8 @@ abstract class FrameworkExtensionTest extends TestCase { + private static $containerCache = array(); + abstract protected function loadFromFile(ContainerBuilder $container, $file); public function testCsrfProtection() @@ -307,6 +309,10 @@ protected function createContainer(array $data = array()) protected function createContainerFromFile($file, $data = array()) { + $cacheKey = md5($file.serialize($data)); + if (isset(self::$containerCache[$cacheKey])) { + return self::$containerCache[$cacheKey]; + } $container = $this->createContainer($data); $container->registerExtension(new FrameworkExtension()); $this->loadFromFile($container, $file); @@ -315,6 +321,6 @@ protected function createContainerFromFile($file, $data = array()) $container->getCompilerPassConfig()->setRemovingPasses(array()); $container->compile(); - return $container; + return self::$containerCache[$cacheKey] = $container; } } From deab1276635890417ddddb8f02bc408155c3bdf6 Mon Sep 17 00:00:00 2001 From: Wouter J Date: Mon, 18 Jan 2016 10:52:44 +0100 Subject: [PATCH 035/226] Remove useless duplicated tests --- src/Symfony/Component/HttpFoundation/Tests/RequestTest.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index cbc1b74fc9faf..e17953819bde2 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -17,11 +17,6 @@ class RequestTest extends \PHPUnit_Framework_TestCase { - public function testConstructor() - { - $this->testInitialize(); - } - public function testInitialize() { $request = new Request(); From 73db0ec7b4ae33e735917084a9783167a838beee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 18 Jan 2016 11:44:30 +0100 Subject: [PATCH 036/226] [PropertyInfo] PhpDocExtractor: Fix a notice when the property doesn't exist --- .../Component/PropertyInfo/Extractor/PhpDocExtractor.php | 2 +- .../PropertyInfo/Tests/Extractors/PhpDocExtractorTest.php | 1 + .../PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php index 0e10fcbc13b10..b1f323c0bd6ed 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php @@ -189,7 +189,7 @@ private function getDocBlock($class, $property) break; default: - $data = array(null, null); + $data = array(null, null, null); } return $this->docBlocks[$propertyHash] = $data; diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractors/PhpDocExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractors/PhpDocExtractorTest.php index 2a1abd75095f9..038a30bdac888 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractors/PhpDocExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractors/PhpDocExtractorTest.php @@ -67,6 +67,7 @@ public function typesProvider() array('d', array(new Type(Type::BUILTIN_TYPE_BOOL)), null, null), array('e', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_RESOURCE))), null, null), array('f', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime'))), null, null), + array('donotexist', null, null, null), ); } } diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php index 8642c9731c0da..ab478dd12b0c3 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php @@ -71,6 +71,7 @@ public function typesProvider() array('d', array(new Type(Type::BUILTIN_TYPE_BOOL))), array('e', null), array('f', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime')))), + array('donotexist', null), ); } @@ -89,6 +90,7 @@ public function php7TypesProvider() array('foo', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true))), array('bar', array(new Type(Type::BUILTIN_TYPE_INT))), array('baz', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)))), + array('donotexist', null), ); } From b23f2ef9af13b49c8ce02a5fcb99c273a0cdfa22 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 18 Jan 2016 15:59:33 +0100 Subject: [PATCH 037/226] Fixed the form profiler when using long form types --- .../Resources/views/Collector/form.html.twig | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/form.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/form.html.twig index 07dd6bb23e777..0608c71a446e0 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/form.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/form.html.twig @@ -97,10 +97,6 @@ /* provide a bigger clickable area than just 10x10px */ width: 16px; height: 16px; - /* vertically center the button */ - position: absolute; - top: 50%; - margin-top: -8px; margin-left: -18px; } .tree .toggle-icon { @@ -110,7 +106,7 @@ margin-left: 3px; margin-top: 3px; background-size: 10px 20px; - background-color: #ccc; + background-color: #AAA; } .tree .toggle-icon.empty { width: 10px; @@ -437,7 +433,7 @@
{% endif %} - {{ name|default('(no name)') }} {% if data.type_class is defined and data.type is defined %}[{{ data.type }}]{% endif %} + {{ name|default('(no name)') }} {% if data.type_class is defined and data.type is defined %}[{{ data.type|split('\\')|last }}]{% endif %} {% if data.errors is defined and data.errors|length > 0 %}
{{ data.errors|length }}
From 67c7f05d961ee7212633d4ec4aeadc56fbc6de22 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 18 Jan 2016 17:01:35 +0100 Subject: [PATCH 038/226] Fixed Bootstrap form theme form "reset" buttons --- .../Form/bootstrap_3_horizontal_layout.html.twig | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_horizontal_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_horizontal_layout.html.twig index e997615d11378..5de20b1b8f181 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_horizontal_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_horizontal_layout.html.twig @@ -65,6 +65,17 @@ col-sm-2 {% endspaceless %} {% endblock submit_row %} +{% block reset_row -%} +{% spaceless %} +
+
+
+ {{ form_widget(form) }} +
+
+{% endspaceless %} +{% endblock reset_row %} + {% block form_group_class -%} col-sm-10 {%- endblock form_group_class %} From d662c2ae8fca7034e5f60401d4b1191426417d25 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 18 Jan 2016 17:25:45 +0100 Subject: [PATCH 039/226] Fixed the documentation of VoterInterface::supportsAttribute --- .../Security/Core/Authorization/Voter/VoterInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Core/Authorization/Voter/VoterInterface.php b/src/Symfony/Component/Security/Core/Authorization/Voter/VoterInterface.php index d00ff1cfaefae..1032cb200d657 100644 --- a/src/Symfony/Component/Security/Core/Authorization/Voter/VoterInterface.php +++ b/src/Symfony/Component/Security/Core/Authorization/Voter/VoterInterface.php @@ -27,7 +27,7 @@ interface VoterInterface /** * Checks if the voter supports the given attribute. * - * @param string $attribute An attribute + * @param mixed $attribute An attribute (usually the attribute name string) * * @return bool true if this Voter supports the attribute, false otherwise */ From c56c7bf869d952ba44ed48ab566fbca8361bd97b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 18 Jan 2016 17:42:55 +0100 Subject: [PATCH 040/226] [Serializer] Introduce constants for context keys --- .../Normalizer/AbstractNormalizer.php | 28 +++++++++++-------- .../Normalizer/AbstractNormalizerTest.php | 11 ++++---- .../Normalizer/GetSetMethodNormalizerTest.php | 14 +++++----- .../Tests/Normalizer/ObjectNormalizerTest.php | 12 ++++---- .../Normalizer/PropertyNormalizerTest.php | 12 ++++---- 5 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php index ae184bbeb6ea4..f12d3d2263081 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php @@ -27,6 +27,10 @@ */ abstract class AbstractNormalizer extends SerializerAwareNormalizer implements NormalizerInterface, DenormalizerInterface { + const CIRCULAR_REFERENCE_LIMIT = 'circular_reference_limit'; + const OBJECT_TO_POPULATE = 'object_to_populate'; + const GROUPS = 'groups'; + /** * @var int */ @@ -185,16 +189,16 @@ protected function isCircularReference($object, &$context) { $objectHash = spl_object_hash($object); - if (isset($context['circular_reference_limit'][$objectHash])) { - if ($context['circular_reference_limit'][$objectHash] >= $this->circularReferenceLimit) { - unset($context['circular_reference_limit'][$objectHash]); + if (isset($context[static::CIRCULAR_REFERENCE_LIMIT][$objectHash])) { + if ($context[static::CIRCULAR_REFERENCE_LIMIT][$objectHash] >= $this->circularReferenceLimit) { + unset($context[static::CIRCULAR_REFERENCE_LIMIT][$objectHash]); return true; } - ++$context['circular_reference_limit'][$objectHash]; + ++$context[static::CIRCULAR_REFERENCE_LIMIT][$objectHash]; } else { - $context['circular_reference_limit'][$objectHash] = 1; + $context[static::CIRCULAR_REFERENCE_LIMIT][$objectHash] = 1; } return false; @@ -248,13 +252,13 @@ protected function formatAttribute($attributeName) */ protected function getAllowedAttributes($classOrObject, array $context, $attributesAsString = false) { - if (!$this->classMetadataFactory || !isset($context['groups']) || !is_array($context['groups'])) { + if (!$this->classMetadataFactory || !isset($context[static::GROUPS]) || !is_array($context[static::GROUPS])) { return false; } $allowedAttributes = array(); foreach ($this->classMetadataFactory->getMetadataFor($classOrObject)->getAttributesMetadata() as $attributeMetadata) { - if (count(array_intersect($attributeMetadata->getGroups(), $context['groups']))) { + if (count(array_intersect($attributeMetadata->getGroups(), $context[static::GROUPS]))) { $allowedAttributes[] = $attributesAsString ? $attributeMetadata->getName() : $attributeMetadata; } } @@ -296,12 +300,12 @@ protected function prepareForDenormalization($data) protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes) { if ( - isset($context['object_to_populate']) && - is_object($context['object_to_populate']) && - $context['object_to_populate'] instanceof $class + isset($context[static::OBJECT_TO_POPULATE]) && + is_object($context[static::OBJECT_TO_POPULATE]) && + $context[static::OBJECT_TO_POPULATE] instanceof $class ) { - $object = $context['object_to_populate']; - unset($context['object_to_populate']); + $object = $context[static::OBJECT_TO_POPULATE]; + unset($context[static::OBJECT_TO_POPULATE]); return $object; } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php index b317ec276fad1..66ac992350319 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php @@ -5,6 +5,7 @@ use Symfony\Component\Serializer\Mapping\AttributeMetadata; use Symfony\Component\Serializer\Mapping\ClassMetadata; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface; +use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; use Symfony\Component\Serializer\Tests\Fixtures\AbstractNormalizerDummy; use Symfony\Component\Serializer\Tests\Fixtures\ProxyDummy; @@ -55,10 +56,10 @@ public function testGetAllowedAttributesAsString() $this->classMetadata->method('getMetadataFor')->willReturn($classMetadata); - $result = $this->normalizer->getAllowedAttributes('c', array('groups' => array('test')), true); + $result = $this->normalizer->getAllowedAttributes('c', array(AbstractNormalizer::GROUPS => array('test')), true); $this->assertEquals(array('a2', 'a4'), $result); - $result = $this->normalizer->getAllowedAttributes('c', array('groups' => array('other')), true); + $result = $this->normalizer->getAllowedAttributes('c', array(AbstractNormalizer::GROUPS => array('other')), true); $this->assertEquals(array('a3', 'a4'), $result); } @@ -84,10 +85,10 @@ public function testGetAllowedAttributesAsObjects() $this->classMetadata->method('getMetadataFor')->willReturn($classMetadata); - $result = $this->normalizer->getAllowedAttributes('c', array('groups' => array('test')), false); + $result = $this->normalizer->getAllowedAttributes('c', array(AbstractNormalizer::GROUPS => array('test')), false); $this->assertEquals(array($a2, $a4), $result); - $result = $this->normalizer->getAllowedAttributes('c', array('groups' => array('other')), false); + $result = $this->normalizer->getAllowedAttributes('c', array(AbstractNormalizer::GROUPS => array('other')), false); $this->assertEquals(array($a3, $a4), $result); } @@ -95,7 +96,7 @@ public function testObjectToPopulateWithProxy() { $proxyDummy = new ProxyDummy(); - $context = array('object_to_populate' => $proxyDummy); + $context = array(AbstractNormalizer::OBJECT_TO_POPULATE => $proxyDummy); $normalizer = new ObjectNormalizer(); $normalizer->denormalize(array('foo' => 'bar'), 'Symfony\Component\Serializer\Tests\Fixtures\ToBeProxyfiedDummy', null, $context); diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php index 1d487c2fdd5c1..9027bfa7ec026 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -277,7 +277,7 @@ public function testGroupsNormalize() $this->assertEquals(array( 'bar' => 'bar', - ), $this->normalizer->normalize($obj, null, array('groups' => array('c')))); + ), $this->normalizer->normalize($obj, null, array(GetSetMethodNormalizer::GROUPS => array('c')))); $this->assertEquals(array( 'symfony' => 'symfony', @@ -286,7 +286,7 @@ public function testGroupsNormalize() 'bar' => 'bar', 'kevin' => 'kevin', 'coopTilleuls' => 'coopTilleuls', - ), $this->normalizer->normalize($obj, null, array('groups' => array('a', 'c')))); + ), $this->normalizer->normalize($obj, null, array(GetSetMethodNormalizer::GROUPS => array('a', 'c')))); } public function testGroupsDenormalize() @@ -304,7 +304,7 @@ public function testGroupsDenormalize() $toNormalize, 'Symfony\Component\Serializer\Tests\Fixtures\GroupDummy', null, - array('groups' => array('a')) + array(GetSetMethodNormalizer::GROUPS => array('a')) ); $this->assertEquals($obj, $normalized); @@ -314,7 +314,7 @@ public function testGroupsDenormalize() $toNormalize, 'Symfony\Component\Serializer\Tests\Fixtures\GroupDummy', null, - array('groups' => array('a', 'b')) + array(GetSetMethodNormalizer::GROUPS => array('a', 'b')) ); $this->assertEquals($obj, $normalized); } @@ -336,7 +336,7 @@ public function testGroupsNormalizeWithNameConverter() 'foo_bar' => '@dunglas', 'symfony' => '@coopTilleuls', ), - $this->normalizer->normalize($obj, null, array('groups' => array('name_converter'))) + $this->normalizer->normalize($obj, null, array(GetSetMethodNormalizer::GROUPS => array('name_converter'))) ); } @@ -357,7 +357,7 @@ public function testGroupsDenormalizeWithNameConverter() 'foo_bar' => '@dunglas', 'symfony' => '@coopTilleuls', 'coop_tilleuls' => 'les-tilleuls.coop', - ), 'Symfony\Component\Serializer\Tests\Fixtures\GroupDummy', null, array('groups' => array('name_converter'))) + ), 'Symfony\Component\Serializer\Tests\Fixtures\GroupDummy', null, array(GetSetMethodNormalizer::GROUPS => array('name_converter'))) ); } @@ -533,7 +533,7 @@ public function testObjectToPopulate() array('bar' => 'bar'), __NAMESPACE__.'\GetSetDummy', null, - array('object_to_populate' => $dummy) + array(GetSetMethodNormalizer::OBJECT_TO_POPULATE => $dummy) ); $this->assertEquals($dummy, $obj); diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php index 80a021d08fa25..c0602d7fa6b7d 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php @@ -197,7 +197,7 @@ public function testGroupsNormalize() $this->assertEquals(array( 'bar' => 'bar', - ), $this->normalizer->normalize($obj, null, array('groups' => array('c')))); + ), $this->normalizer->normalize($obj, null, array(ObjectNormalizer::GROUPS => array('c')))); $this->assertEquals(array( 'symfony' => 'symfony', @@ -206,7 +206,7 @@ public function testGroupsNormalize() 'bar' => 'bar', 'kevin' => 'kevin', 'coopTilleuls' => 'coopTilleuls', - ), $this->normalizer->normalize($obj, null, array('groups' => array('a', 'c')))); + ), $this->normalizer->normalize($obj, null, array(ObjectNormalizer::GROUPS => array('a', 'c')))); } public function testGroupsDenormalize() @@ -224,7 +224,7 @@ public function testGroupsDenormalize() $toNormalize, 'Symfony\Component\Serializer\Tests\Fixtures\GroupDummy', null, - array('groups' => array('a')) + array(ObjectNormalizer::GROUPS => array('a')) ); $this->assertEquals($obj, $normalized); @@ -234,7 +234,7 @@ public function testGroupsDenormalize() $toNormalize, 'Symfony\Component\Serializer\Tests\Fixtures\GroupDummy', null, - array('groups' => array('a', 'b')) + array(ObjectNormalizer::GROUPS => array('a', 'b')) ); $this->assertEquals($obj, $normalized); } @@ -256,7 +256,7 @@ public function testGroupsNormalizeWithNameConverter() 'foo_bar' => '@dunglas', 'symfony' => '@coopTilleuls', ), - $this->normalizer->normalize($obj, null, array('groups' => array('name_converter'))) + $this->normalizer->normalize($obj, null, array(ObjectNormalizer::GROUPS => array('name_converter'))) ); } @@ -277,7 +277,7 @@ public function testGroupsDenormalizeWithNameConverter() 'foo_bar' => '@dunglas', 'symfony' => '@coopTilleuls', 'coop_tilleuls' => 'les-tilleuls.coop', - ), 'Symfony\Component\Serializer\Tests\Fixtures\GroupDummy', null, array('groups' => array('name_converter'))) + ), 'Symfony\Component\Serializer\Tests\Fixtures\GroupDummy', null, array(ObjectNormalizer::GROUPS => array('name_converter'))) ); } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php index fd303818006ff..381936ad006ee 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php @@ -214,7 +214,7 @@ public function testGroupsNormalize() $this->assertEquals(array( 'bar' => 'bar', - ), $this->normalizer->normalize($obj, null, array('groups' => array('c')))); + ), $this->normalizer->normalize($obj, null, array(PropertyNormalizer::GROUPS => array('c')))); // The PropertyNormalizer is not able to hydrate properties from parent classes $this->assertEquals(array( @@ -222,7 +222,7 @@ public function testGroupsNormalize() 'foo' => 'foo', 'fooBar' => 'fooBar', 'bar' => 'bar', - ), $this->normalizer->normalize($obj, null, array('groups' => array('a', 'c')))); + ), $this->normalizer->normalize($obj, null, array(PropertyNormalizer::GROUPS => array('a', 'c')))); } public function testGroupsDenormalize() @@ -240,7 +240,7 @@ public function testGroupsDenormalize() $toNormalize, 'Symfony\Component\Serializer\Tests\Fixtures\GroupDummy', null, - array('groups' => array('a')) + array(PropertyNormalizer::GROUPS => array('a')) ); $this->assertEquals($obj, $normalized); @@ -250,7 +250,7 @@ public function testGroupsDenormalize() $toNormalize, 'Symfony\Component\Serializer\Tests\Fixtures\GroupDummy', null, - array('groups' => array('a', 'b')) + array(PropertyNormalizer::GROUPS => array('a', 'b')) ); $this->assertEquals($obj, $normalized); } @@ -272,7 +272,7 @@ public function testGroupsNormalizeWithNameConverter() 'foo_bar' => '@dunglas', 'symfony' => '@coopTilleuls', ), - $this->normalizer->normalize($obj, null, array('groups' => array('name_converter'))) + $this->normalizer->normalize($obj, null, array(PropertyNormalizer::GROUPS => array('name_converter'))) ); } @@ -293,7 +293,7 @@ public function testGroupsDenormalizeWithNameConverter() 'foo_bar' => '@dunglas', 'symfony' => '@coopTilleuls', 'coop_tilleuls' => 'les-tilleuls.coop', - ), 'Symfony\Component\Serializer\Tests\Fixtures\GroupDummy', null, array('groups' => array('name_converter'))) + ), 'Symfony\Component\Serializer\Tests\Fixtures\GroupDummy', null, array(PropertyNormalizer::GROUPS => array('name_converter'))) ); } From 7f89158a0d488828f511150391b038bb6ecc4bbe Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 18 Jan 2016 18:32:04 +0100 Subject: [PATCH 041/226] [Process] Fix typo, no arguments needed anymore --- src/Symfony/Component/Process/Process.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index df36fd581d347..6660950b7aa97 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -1232,7 +1232,7 @@ private function getDescriptors() $this->processPipes = UnixPipes::create($this, $this->input); } - return $this->processPipes->getDescriptors($this->outputDisabled); + return $this->processPipes->getDescriptors(); } /** From a0dc3994d49369efd7188efde51e9774895d1c54 Mon Sep 17 00:00:00 2001 From: Geoff Date: Fri, 15 Jan 2016 15:06:34 -0800 Subject: [PATCH 042/226] [ClassLoader] Use symfony/polyfill-apcu --- .../Component/ClassLoader/ApcUniversalClassLoader.php | 6 +++--- .../ClassLoader/Tests/ApcUniversalClassLoaderTest.php | 9 +++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php b/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php index 3a3a8a4a44712..bedb30f8955ee 100644 --- a/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php +++ b/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php @@ -71,7 +71,7 @@ class ApcUniversalClassLoader extends UniversalClassLoader */ public function __construct($prefix) { - if (!extension_loaded('apc')) { + if (!function_exists('apcu_fetch')) { throw new \RuntimeException('Unable to use ApcUniversalClassLoader as APC is not enabled.'); } @@ -87,8 +87,8 @@ public function __construct($prefix) */ public function findFile($class) { - if (false === $file = apc_fetch($this->prefix.$class)) { - apc_store($this->prefix.$class, $file = parent::findFile($class)); + if (false === $file = apcu_fetch($this->prefix.$class)) { + apcu_store($this->prefix.$class, $file = parent::findFile($class)); } return $file; diff --git a/src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php b/src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php index 40046f5530112..e1a55a1cdac93 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php @@ -13,15 +13,12 @@ use Symfony\Component\ClassLoader\ApcUniversalClassLoader; -/** - * @requires extension apc - */ class ApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase { protected function setUp() { if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) { - apc_clear_cache('user'); + apcu_clear_cache(); } else { $this->markTestSkipped('APC is not enabled.'); } @@ -30,7 +27,7 @@ protected function setUp() protected function tearDown() { if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) { - apc_clear_cache('user'); + apcu_clear_cache(); } } @@ -39,7 +36,7 @@ public function testConstructor() $loader = new ApcUniversalClassLoader('test.prefix.'); $loader->registerNamespace('Apc\Namespaced', __DIR__.DIRECTORY_SEPARATOR.'Fixtures'); - $this->assertEquals($loader->findFile('\Apc\Namespaced\FooBar'), apc_fetch('test.prefix.\Apc\Namespaced\FooBar'), '__construct() takes a prefix as its first argument'); + $this->assertEquals($loader->findFile('\Apc\Namespaced\FooBar'), apcu_fetch('test.prefix.\Apc\Namespaced\FooBar'), '__construct() takes a prefix as its first argument'); } /** From f6fd5e47eda8c82d86c361083d56f2bd41cbe8f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Par=C3=A1da=20J=C3=B3zsef?= Date: Mon, 18 Jan 2016 23:07:25 +0100 Subject: [PATCH 043/226] Remove useless is_object condition --- src/Symfony/Component/Serializer/Serializer.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Symfony/Component/Serializer/Serializer.php b/src/Symfony/Component/Serializer/Serializer.php index eb83544b428ff..cb9fe14394087 100644 --- a/src/Symfony/Component/Serializer/Serializer.php +++ b/src/Symfony/Component/Serializer/Serializer.php @@ -185,10 +185,6 @@ public function supportsDenormalization($data, $type, $format = null) */ private function getNormalizer($data, $format) { - if ($isObject = is_object($data)) { - $class = get_class($data); - } - foreach ($this->normalizers as $normalizer) { if ($normalizer instanceof NormalizerInterface && $normalizer->supportsNormalization($data, $format)) { return $normalizer; From ab98bc1486c0448a985d8372e69e087d327d79e4 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 16 Jan 2016 19:39:57 +0100 Subject: [PATCH 044/226] synchronize 2.8 and 3.0 upgrade files --- UPGRADE-3.0.md | 305 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 284 insertions(+), 21 deletions(-) diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md index a5f1f86c00419..b5a4c7626dc6f 100644 --- a/UPGRADE-3.0.md +++ b/UPGRADE-3.0.md @@ -20,6 +20,13 @@ UPGRADE FROM 2.x to 3.0 `DebugClassLoader`. The difference is that the constructor now takes a loader to wrap. +### Config + + * `\Symfony\Component\Config\Resource\ResourceInterface::isFresh()` has been removed. Also, + cache validation through this method (which was still supported in 2.8 for BC) does no longer + work because the `\Symfony\Component\Config\Resource\BCResourceInterfaceChecker` helper class + has been removed as well. + ### Console * The `dialog` helper has been removed in favor of the `question` helper. @@ -90,6 +97,79 @@ UPGRADE FROM 2.x to 3.0 ### DependencyInjection + * The concept of scopes was removed, the removed methods are: + + - `Symfony\Component\DependencyInjection\ContainerBuilder::getScopes()` + - `Symfony\Component\DependencyInjection\ContainerBuilder::getScopeChildren()` + - `Symfony\Component\DependencyInjection\ContainerInterface::enterScope()` + - `Symfony\Component\DependencyInjection\ContainerInterface::leaveScope()` + - `Symfony\Component\DependencyInjection\ContainerInterface::addScope()` + - `Symfony\Component\DependencyInjection\ContainerInterface::hasScope()` + - `Symfony\Component\DependencyInjection\ContainerInterface::isScopeActive()` + - `Symfony\Component\DependencyInjection\Definition::setScope()` + - `Symfony\Component\DependencyInjection\Definition::getScope()` + - `Symfony\Component\DependencyInjection\Reference::isStrict()` + + Also, the `$scope` and `$strict` parameters of `Symfony\Component\DependencyInjection\ContainerInterface::set()` + and `Symfony\Component\DependencyInjection\Reference` respectively were removed. + + * A new `shared` flag has been added to the service definition + in replacement of the `prototype` scope. + + Before: + + ```php + use Symfony\Component\DependencyInjection\ContainerBuilder; + + $container = new ContainerBuilder(); + $container + ->register('foo', 'stdClass') + ->setScope(ContainerBuilder::SCOPE_PROTOTYPE) + ; + ``` + + ```yml + services: + foo: + class: stdClass + scope: prototype + ``` + + ```xml + + + + ``` + + After: + + ```php + use Symfony\Component\DependencyInjection\ContainerBuilder; + + $container = new ContainerBuilder(); + $container + ->register('foo', 'stdClass') + ->setShared(false) + ; + ``` + + ```yml + services: + foo: + class: stdClass + shared: false + ``` + + ```xml + + + + ``` + + * `Symfony\Component\DependencyInjection\ContainerAware` was removed, use + `Symfony\Component\DependencyInjection\ContainerAwareTrait` or implement + `Symfony\Component\DependencyInjection\ContainerAwareInterface` manually + * The methods `Definition::setFactoryClass()`, `Definition::setFactoryMethod()`, and `Definition::setFactoryService()` have been removed in favor of `Definition::setFactory()`. Services defined using @@ -106,12 +186,170 @@ UPGRADE FROM 2.x to 3.0 ### Form + * The option `options` of the `CollectionType` has been removed in favor + of the `entry_options` option. + + * The `cascade_validation` option was removed. Use the `constraints` option + together with the `Valid` constraint instead. + + * Type names were removed. Instead of referencing types by name, you must + reference them by their fully-qualified class name (FQCN) instead: + + Before: + + ```php + $form = $this->createFormBuilder() + ->add('name', 'text') + ->add('age', 'integer') + ->getForm(); + ``` + + After: + + ```php + use Symfony\Component\Form\Extension\Core\Type\IntegerType; + use Symfony\Component\Form\Extension\Core\Type\TextType; + + $form = $this->createFormBuilder() + ->add('name', TextType::class) + ->add('age', IntegerType::class) + ->getForm(); + ``` + + If you want to customize the block prefix of a type in Twig, you must now + implement `FormTypeInterface::getBlockPrefix()`: + + Before: + + ```php + class UserProfileType extends AbstractType + { + public function getName() + { + return 'profile'; + } + } + ``` + + After: + + ```php + class UserProfileType extends AbstractType + { + public function getBlockPrefix() + { + return 'profile'; + } + } + ``` + + If you don't customize `getBlockPrefix()`, it defaults to the class name + without "Type" suffix in underscore notation (here: "user_profile"). + + Type extension must return the fully-qualified class name of the extended + type from `FormTypeExtensionInterface::getExtendedType()` now. + + Before: + + ```php + class MyTypeExtension extends AbstractTypeExtension + { + public function getExtendedType() + { + return 'form'; + } + } + ``` + + After: + + ```php + use Symfony\Component\Form\Extension\Core\Type\FormType; + + class MyTypeExtension extends AbstractTypeExtension + { + public function getExtendedType() + { + return FormType::class; + } + } + ``` + + * The `FormTypeInterface::getName()` method was removed. + + * Returning type instances from `FormTypeInterface::getParent()` is not + supported anymore. Return the fully-qualified class name of the parent + type class instead. + + Before: + + ```php + class MyType + { + public function getParent() + { + return new ParentType(); + } + } + ``` + + After: + + ```php + class MyType + { + public function getParent() + { + return ParentType::class; + } + } + ``` + + * The option `type` of the `CollectionType` has been removed in favor of + the `entry_type` option. The value for the `entry_type` option must be + the fully-qualified class name (FQCN). + + * Passing type instances to `Form::add()`, `FormBuilder::add()` and the + `FormFactory::create*()` methods is not supported anymore. Pass the + fully-qualified class name of the type instead. + + Before: + + ```php + $form = $this->createForm(new MyType()); + ``` + + After: + + ```php + $form = $this->createForm(MyType::class); + ``` + + * The alias option of the `form.type_extension` tag was removed in favor of + the `extended_type`/`extended-type` option. + + Before: + ```xml + + + + ``` + + After: + ```xml + + + + ``` + * The option "precision" was renamed to "scale". Before: ```php - $builder->add('length', 'number', array( + use Symfony\Component\Form\Extension\Core\Type\NumberType; + + $builder->add('length', NumberType::class, array( 'precision' => 3, )); ``` @@ -119,7 +357,9 @@ UPGRADE FROM 2.x to 3.0 After: ```php - $builder->add('length', 'number', array( + use Symfony\Component\Form\Extension\Core\Type\NumberType; + + $builder->add('length', NumberType::class, array( 'scale' => 3, )); ``` @@ -129,7 +369,9 @@ UPGRADE FROM 2.x to 3.0 Before: ```php - $builder->add('address', 'form', array( + use Symfony\Component\Form\Extension\Core\Type\FormType; + + $builder->add('address', FormType::class, array( 'virtual' => true, )); ``` @@ -137,7 +379,9 @@ UPGRADE FROM 2.x to 3.0 After: ```php - $builder->add('address', 'form', array( + use Symfony\Component\Form\Extension\Core\Type\FormType; + + $builder->add('address', FormType::class, array( 'inherit_data' => true, )); ``` @@ -264,12 +508,12 @@ UPGRADE FROM 2.x to 3.0 // ... } ``` - + * The option "options" of the CollectionType has been renamed to "entry_options". * The option "type" of the CollectionType has been renamed to "entry_type". - As a value for the option you must provide the fully-qualified class name (FQCN) - now as well. + As a value for the option you must provide the fully-qualified class name (FQCN) + now as well. * The `FormIntegrationTestCase` and `FormPerformanceTestCase` classes were moved form the `Symfony\Component\Form\Tests` namespace to the `Symfony\Component\Form\Test` namespace. @@ -317,8 +561,8 @@ UPGRADE FROM 2.x to 3.0 * The `Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList` class has been removed in favor of `Symfony\Component\Form\ChoiceList\ArrayChoiceList`. - - * The `TimezoneType::getTimezones()` method was removed. You should not use + + * The `TimezoneType::getTimezones()` method was removed. You should not use this method. * The `Symfony\Component\Form\ChoiceList\ArrayKeyChoiceList` class has been removed in @@ -365,11 +609,11 @@ UPGRADE FROM 2.x to 3.0 } } ``` - + * In Symfony 2.7 a small BC break was introduced with the new choices_as_values option. In order to have the choice values populated to the html value attribute you had to define the choice_value option. This is now not any more needed. - + Before: ```php @@ -389,9 +633,9 @@ UPGRADE FROM 2.x to 3.0 }, )); ``` - + After: - + ```php $form->add('status', ChoiceType::class, array( 'choices' => array( @@ -400,7 +644,7 @@ UPGRADE FROM 2.x to 3.0 'Ignored' => Status::IGNORED, ) )); - ``` + ``` * The `request` service was removed. You must inject the `request_stack` service instead. @@ -647,6 +891,11 @@ UPGRADE FROM 2.x to 3.0 ### Security + * The `AbstractVoter` class was removed in favor of the new `Voter` class. + + * The `VoterInterface::supportsClass` and `supportsAttribute` methods were + removed from the interface. + * The `Resources/` directory was moved to `Core/Resources/` * The `key` settings of `anonymous`, `remember_me` and `http_digest` are @@ -779,6 +1028,10 @@ UPGRADE FROM 2.x to 3.0 * The `Translator::setFallbackLocale()` method has been removed in favor of `Translator::setFallbackLocales()`. + * The `getMessages()` method of the `Symfony\Component\Translation\Translator` + class was removed. You should use the `getCatalogue()` method of the + `Symfony\Component\Translation\TranslatorBagInterface`. + ### Twig Bridge * The `twig:lint` command has been deprecated since Symfony 2.7 and will be @@ -1308,15 +1561,25 @@ UPGRADE FROM 2.x to 3.0 Yaml::parse(file_get_contents($fileName)); ``` +### WebProfiler + + * The `profiler:import` and `profiler:export` commands have been deprecated and + will be removed in 3.0. + + * All the profiler storages different than `FileProfilerStorage` have been + removed. The removed classes are: + + - `Symfony\Component\HttpKernel\Profiler\BaseMemcacheProfilerStorage` + - `Symfony\Component\HttpKernel\Profiler\MemcachedProfilerStorage` + - `Symfony\Component\HttpKernel\Profiler\MemcacheProfilerStorage` + - `Symfony\Component\HttpKernel\Profiler\MongoDbProfilerStorage` + - `Symfony\Component\HttpKernel\Profiler\MysqlProfilerStorage` + - `Symfony\Component\HttpKernel\Profiler\PdoProfilerStorage` + - `Symfony\Component\HttpKernel\Profiler\RedisProfilerStorage` + - `Symfony\Component\HttpKernel\Profiler\SqliteProfilerStorage` + ### Process * `Process::setStdin()` and `Process::getStdin()` have been removed. Use `Process::setInput()` and `Process::getInput()` that works the same way. * `Process::setInput()` and `ProcessBuilder::setInput()` do not accept non-scalar types. - -### Config - - * `\Symfony\Component\Config\Resource\ResourceInterface::isFresh()` has been removed. Also, - cache validation through this method (which was still supported in 2.8 for BC) does no longer - work because the `\Symfony\Component\Config\Resource\BCResourceInterfaceChecker` helper class - has been removed as well. From 90d493ea9712f4684220d041f9fda14b5a09af71 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 31 Dec 2015 17:39:50 +0100 Subject: [PATCH 045/226] [FrameworkBundle] Don't log twice with the error handler --- .../DependencyInjection/FrameworkExtension.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index da54b51deaf8a..462a802a204fb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -139,6 +139,8 @@ public function load(array $configs, ContainerBuilder $container) } if ($container->getParameter('kernel.debug')) { + $definition->replaceArgument(2, -1 & ~(E_COMPILE_ERROR | E_PARSE | E_ERROR | E_CORE_ERROR | E_RECOVERABLE_ERROR)); + $loader->load('debug.xml'); $definition = $container->findDefinition('http_kernel'); @@ -150,7 +152,7 @@ public function load(array $configs, ContainerBuilder $container) $container->setDefinition('debug.event_dispatcher.parent', $definition); $container->setAlias('event_dispatcher', 'debug.event_dispatcher'); } else { - $definition->replaceArgument(2, E_COMPILE_ERROR | E_PARSE | E_ERROR | E_CORE_ERROR); + $definition->replaceArgument(1, null); } $this->addClassesToCompile(array( From da73125a9cfc0f9a908ce31ad0f2166134b5df75 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 18 Jan 2016 17:23:05 +0100 Subject: [PATCH 046/226] [Process] Use stream based storage to avoid memory issues --- src/Symfony/Component/Process/Process.php | 42 ++++++++++++++--------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index e0f49a7e3b2e7..157499d10f7e4 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -378,7 +378,11 @@ public function getOutput() $this->readPipes(false, '\\' === DIRECTORY_SEPARATOR ? !$this->processInformation['running'] : true); - return $this->stdout; + if (false === $ret = stream_get_contents($this->stdout, -1, 0)) { + return ''; + } + + return $ret; } /** @@ -395,16 +399,13 @@ public function getIncrementalOutput() { $this->requireProcessIsStarted(__FUNCTION__); - $data = $this->getOutput(); - - $latest = substr($data, $this->incrementalOutputOffset); + $latest = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset); + $this->incrementalOutputOffset = ftell($this->stdout); if (false === $latest) { return ''; } - $this->incrementalOutputOffset = strlen($data); - return $latest; } @@ -421,7 +422,11 @@ public function getErrorOutput() $this->readPipes(false, '\\' === DIRECTORY_SEPARATOR ? !$this->processInformation['running'] : true); - return $this->stderr; + if (false === $ret = stream_get_contents($this->stderr, -1, 0)) { + return ''; + } + + return $ret; } /** @@ -439,16 +444,13 @@ public function getIncrementalErrorOutput() { $this->requireProcessIsStarted(__FUNCTION__); - $data = $this->getErrorOutput(); - - $latest = substr($data, $this->incrementalErrorOutputOffset); + $latest = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset); + $this->incrementalErrorOutputOffset = ftell($this->stderr); if (false === $latest) { return ''; } - $this->incrementalErrorOutputOffset = strlen($data); - return $latest; } @@ -666,21 +668,29 @@ public function stop($timeout = 10, $signal = null) /** * Adds a line to the STDOUT stream. * + * @internal + * * @param string $line The line to append */ public function addOutput($line) { - $this->stdout .= $line; + fseek($this->stdout, 0, SEEK_END); + fwrite($this->stdout, $line); + fseek($this->stdout, $this->incrementalOutputOffset); } /** * Adds a line to the STDERR stream. * + * @internal + * * @param string $line The line to append */ public function addErrorOutput($line) { - $this->stderr .= $line; + fseek($this->stderr, 0, SEEK_END); + fwrite($this->stderr, $line); + fseek($this->stderr, $this->incrementalErrorOutputOffset); } /** @@ -1126,8 +1136,8 @@ private function resetProcessData() $this->exitcode = null; $this->fallbackStatus = array(); $this->processInformation = null; - $this->stdout = null; - $this->stderr = null; + $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'wb+'); + $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'wb+'); $this->process = null; $this->latestSignal = null; $this->status = self::STATUS_READY; From 1b170d7a851879d08a109d722392db2b1f1d7f6c Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Tue, 19 Jan 2016 11:31:11 +0100 Subject: [PATCH 047/226] Improve the phpdoc of SplFileInfo methods --- src/Symfony/Component/Finder/SplFileInfo.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/Finder/SplFileInfo.php b/src/Symfony/Component/Finder/SplFileInfo.php index c7fbe02191157..31a3f86a674d5 100644 --- a/src/Symfony/Component/Finder/SplFileInfo.php +++ b/src/Symfony/Component/Finder/SplFileInfo.php @@ -38,6 +38,8 @@ public function __construct($file, $relativePath, $relativePathname) /** * Returns the relative path. * + * This path does not contain the file name. + * * @return string the relative path */ public function getRelativePath() @@ -48,6 +50,8 @@ public function getRelativePath() /** * Returns the relative path name. * + * This path contains the file name. + * * @return string the relative path name */ public function getRelativePathname() From be056fd0bf1a15a87a73f33fba8a9d5d645a427c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Par=C3=A1da=20J=C3=B3zsef?= Date: Sun, 17 Jan 2016 01:29:59 +0100 Subject: [PATCH 048/226] [Form] ChoiceType: Fix a notice when 'choices' normalizer is replaced --- .../Form/Extension/Core/Type/ChoiceType.php | 4 ++ .../Extension/Core/Type/ChoiceTypeTest.php | 27 ++++++++++ .../Form/Tests/Fixtures/ChoiceSubType.php | 51 +++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 src/Symfony/Component/Form/Tests/Fixtures/ChoiceSubType.php diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index ef9a4b5baed00..515f104af692c 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -291,6 +291,10 @@ public function configureOptions(OptionsResolver $resolver) // forms) $labels = $choiceLabels->labels; + // The $choiceLabels object is shared with the 'choices' closure. + // Since that normalizer can be replaced, labels have to be cleared here. + $choiceLabels->labels = array(); + return function ($choice, $key) use ($labels) { return $labels[$key]; }; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php index d7536f7640d3d..cf74fec212ec5 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php @@ -14,6 +14,7 @@ use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView; use Symfony\Component\Form\ChoiceList\View\ChoiceView; use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList; +use Symfony\Component\Form\Tests\Fixtures\ChoiceSubType; class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase { @@ -1887,4 +1888,30 @@ public function testInitializeWithDefaultObjectChoice() // Trigger data initialization $form->getViewData(); } + + /** + * This covers the case when: + * - Custom choice type added after a choice type. + * - Custom type is expanded. + * - Custom type replaces 'choices' normalizer with a custom one. + * In this case, custom type should not inherit labels from the first added choice type. + */ + public function testCustomChoiceTypeDoesNotInheritChoiceLabels() + { + $builder = $this->factory->createBuilder(); + $builder->add('choice', 'choice', array( + 'choices' => array( + '1' => '1', + '2' => '2', + ), + ) + ); + $builder->add('subChoice', new ChoiceSubType()); + $form = $builder->getForm(); + + // The default 'choices' normalizer would fill the $choiceLabels, but it has been replaced + // in the custom choice type, so $choiceLabels->labels remains empty array. + // In this case the 'choice_label' closure returns null and not the closure from the first choice type. + $this->assertNull($form->get('subChoice')->getConfig()->getOption('choice_label')); + } } diff --git a/src/Symfony/Component/Form/Tests/Fixtures/ChoiceSubType.php b/src/Symfony/Component/Form/Tests/Fixtures/ChoiceSubType.php new file mode 100644 index 0000000000000..857dd5d5a77eb --- /dev/null +++ b/src/Symfony/Component/Form/Tests/Fixtures/ChoiceSubType.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests\Fixtures; + +use Symfony\Component\Form\AbstractType; +use Symfony\Component\OptionsResolver\OptionsResolver; + +/** + * @author Paráda József + */ +class ChoiceSubType extends AbstractType +{ + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults(array('expanded' => true)); + $resolver->setNormalizer('choices', function () { + return array( + 'attr1' => 'Attribute 1', + 'attr2' => 'Attribute 2', + ); + }); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'sub_choice'; + } + + /** + * {@inheritdoc} + */ + public function getParent() + { + return 'choice'; + } +} From 0d041c3f8a352fefa7eda54cfe7a427185fd5a86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Thu, 14 Jan 2016 14:25:27 +0100 Subject: [PATCH 049/226] ChooseBaseUrl should return an index Enforce chooseBaseUrl to return an integer index to the baseUrls member. --- src/Symfony/Component/Asset/UrlPackage.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Asset/UrlPackage.php b/src/Symfony/Component/Asset/UrlPackage.php index 3626ec843c48b..de9c1f07d5f5d 100644 --- a/src/Symfony/Component/Asset/UrlPackage.php +++ b/src/Symfony/Component/Asset/UrlPackage.php @@ -108,15 +108,15 @@ public function getBaseUrl($path) * Determines which base URL to use for the given path. * * Override this method to change the default distribution strategy. - * This method should always return the same base URL for a given path. + * This method should always return the same base URL index for a given path. * * @param string $path * - * @return string The base URL for the given path + * @return int The base URL index for the given path */ protected function chooseBaseUrl($path) { - return fmod(hexdec(substr(hash('sha256', $path), 0, 10)), count($this->baseUrls)); + return (int) fmod(hexdec(substr(hash('sha256', $path), 0, 10)), count($this->baseUrls)); } private function getSslUrls($urls) From bd70f2443d804e4fa2ef4b4d5acb8a6f26fbc11e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20Santo=20Stefano--F=C3=A9ron?= Date: Tue, 19 Jan 2016 14:59:47 +0100 Subject: [PATCH 050/226] Fix markdown typo --- UPGRADE-3.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md index 3e5d3817d20da..5776b14eff963 100644 --- a/UPGRADE-3.0.md +++ b/UPGRADE-3.0.md @@ -19,7 +19,7 @@ UPGRADE FROM 2.x to 3.0 * The `DebugUniversalClassLoader` class has been removed in favor of `DebugClassLoader`. The difference is that the constructor now takes a loader to wrap. - ``` + ### Config From 71f4a3200e36376ef5709cec7fe310f380f3fd56 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Tue, 19 Jan 2016 16:31:40 +0000 Subject: [PATCH 051/226] [Process] Remove a misleading comment The described behaviour was never implemented. --- src/Symfony/Component/Process/Process.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index e0f49a7e3b2e7..734c692795c12 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -201,9 +201,6 @@ public function run($callback = null) * The callback receives the type of output (out or err) and some bytes from * the output in real-time while writing the standard input to the process. * It allows to have feedback from the independent process during execution. - * If there is no callback passed, the wait() method can be called - * with true as a second parameter then the callback will get all data occurred - * in (and since) the start call. * * @param callback|null $callback A PHP callback to run whenever there is some * output available on STDOUT or STDERR From 5abac565d3aa86559691b1c5eb1799e50232aca9 Mon Sep 17 00:00:00 2001 From: Paulo Rodrigues Pinto Date: Tue, 19 Jan 2016 17:38:30 +0000 Subject: [PATCH 052/226] Fix upgrade guides concerning erroneous removal of assets helper --- UPGRADE-2.7.md | 4 ++-- UPGRADE-3.0.md | 45 --------------------------------------------- 2 files changed, 2 insertions(+), 47 deletions(-) diff --git a/UPGRADE-2.7.md b/UPGRADE-2.7.md index f52220fadc2ed..5de67ebede36c 100644 --- a/UPGRADE-2.7.md +++ b/UPGRADE-2.7.md @@ -596,11 +596,11 @@ TwigBundle FrameworkBundle --------------- - * The `templating.helper.assets` was refactored and returns now an object of the type + * The `templating.helper.assets` service was refactored and now returns an object of type `Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper` instead of `Symfony\Component\Templating\Helper\CoreAssetsHelper`. You can update your class definition or use the `assets.packages` service instead. Using the `assets.packages` service is the recommended - way. The `templating.helper.assets` service will be removed in Symfony 3.0. + way. Before: diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md index 3e5d3817d20da..e6f0e01182347 100644 --- a/UPGRADE-3.0.md +++ b/UPGRADE-3.0.md @@ -388,51 +388,6 @@ UPGRADE FROM 2.x to 3.0 * The `request` service was removed. You must inject the `request_stack` service instead. - * The `templating.helper.assets` was removed in Symfony 3.0. You should - use the `assets.package` service instead. - - Before: - - ```php - use Symfony\Component\Templating\Helper\CoreAssetsHelper; - - class DemoService - { - private $assetsHelper; - - public function __construct(CoreAssetsHelper $assetsHelper) - { - $this->assetsHelper = $assetsHelper; - } - - public function testMethod() - { - return $this->assetsHelper->getUrl('thumbnail.png', null, $this->assetsHelper->getVersion()); - } - } - ``` - - After: - - ```php - use Symfony\Component\Asset\Packages; - - class DemoService - { - private $assetPackages; - - public function __construct(Packages $assetPackages) - { - $this->assetPackages = $assetPackages; - } - - public function testMethod() - { - return $this->assetPackages->getUrl('thumbnail.png').$this->assetPackages->getVersion(); - } - } - ``` - * The `enctype` method of the `form` helper was removed. You should use the new method `start` instead. From 2d931f43e07435c6d3eb3e145749d800e6cb36db Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Mon, 18 Jan 2016 17:23:05 +0100 Subject: [PATCH 053/226] [Process] Use stream based storage to avoid memory issues --- src/Symfony/Component/Process/Process.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 98fa66a9406ce..32704df3f1769 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -491,6 +491,10 @@ public function getOutput() */ public function getIncrementalOutput() { + if ($this->outputDisabled) { + throw new LogicException('Output has been disabled.'); + } + $this->requireProcessIsStarted(__FUNCTION__); $latest = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset); @@ -510,7 +514,8 @@ public function getIncrementalOutput() */ public function clearOutput() { - $this->stdout = ''; + ftruncate($this->stdout, 0); + fseek($this->stdout, 0); $this->incrementalOutputOffset = 0; return $this; @@ -555,6 +560,10 @@ public function getErrorOutput() */ public function getIncrementalErrorOutput() { + if ($this->outputDisabled) { + throw new LogicException('Output has been disabled.'); + } + $this->requireProcessIsStarted(__FUNCTION__); $latest = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset); @@ -574,7 +583,8 @@ public function getIncrementalErrorOutput() */ public function clearErrorOutput() { - $this->stderr = ''; + ftruncate($this->stderr, 0); + fseek($this->stderr, 0); $this->incrementalErrorOutputOffset = 0; return $this; From 11b63ff6868e7e4b0921986a4a283cb28dd657d9 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 20 Jan 2016 10:38:59 +0100 Subject: [PATCH 054/226] Allow absolute URLs to be displayed in the debug toolbar --- .../Resources/views/Profiler/base_js.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig index e313380e51095..8c10c95655317 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig @@ -223,7 +223,7 @@ path = url.substr({{ (request.schemeAndHttpHost ~ request.basePath)|length }}); } - if (path.substr(0, 1) === '/' && !path.match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) { + if (!path.match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) { var stackElement = { loading: true, error: false, From 9d034787feca5f10d8933c41ddc1a62ed7e76fc9 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 20 Jan 2016 20:11:57 +0100 Subject: [PATCH 055/226] tag for dumped PHP objects must be a local one --- src/Symfony/Component/Yaml/Inline.php | 12 ++++++- .../Component/Yaml/Tests/DumperTest.php | 2 +- .../Component/Yaml/Tests/ParserTest.php | 34 +++++++++++++++---- 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index ca419e0565088..eafcbc7ab0018 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -102,7 +102,7 @@ public static function dump($value, $exceptionOnInvalidType = false, $objectSupp return 'null'; case is_object($value): if ($objectSupport) { - return '!!php/object:'.serialize($value); + return '!php/object:'.serialize($value); } if ($exceptionOnInvalidType) { @@ -434,6 +434,16 @@ private static function evaluateScalar($scalar, $references = array()) return (string) substr($scalar, 5); case 0 === strpos($scalar, '! '): return (int) self::parseScalar(substr($scalar, 2)); + case 0 === strpos($scalar, '!php/object:'): + if (self::$objectSupport) { + return unserialize(substr($scalar, 12)); + } + + if (self::$exceptionOnInvalidType) { + throw new ParseException('Object support when parsing a YAML file has been disabled.'); + } + + return; case 0 === strpos($scalar, '!!php/object:'): if (self::$objectSupport) { return unserialize(substr($scalar, 13)); diff --git a/src/Symfony/Component/Yaml/Tests/DumperTest.php b/src/Symfony/Component/Yaml/Tests/DumperTest.php index 1d81a287ae956..b1c44c44befce 100644 --- a/src/Symfony/Component/Yaml/Tests/DumperTest.php +++ b/src/Symfony/Component/Yaml/Tests/DumperTest.php @@ -181,7 +181,7 @@ public function testObjectSupportEnabled() { $dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, false, true); - $this->assertEquals('{ foo: !!php/object:O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}, bar: 1 }', $dump, '->dump() is able to dump objects'); + $this->assertEquals('{ foo: !php/object:O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}, bar: 1 }', $dump, '->dump() is able to dump objects'); } public function testObjectSupportDisabledButNoExceptions() diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 9d6d42befe94c..34cc81b2d353a 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -426,24 +426,46 @@ public function testObjectSupportEnabled() bar: 1 EOF; $this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($input, false, true), '->parse() is able to parse objects'); - } - public function testObjectSupportDisabledButNoExceptions() - { $input = <<assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($input, false, true), '->parse() is able to parse objects'); + } + /** + * @dataProvider invalidDumpedObjectProvider + */ + public function testObjectSupportDisabledButNoExceptions($input) + { $this->assertEquals(array('foo' => null, 'bar' => 1), $this->parser->parse($input), '->parse() does not parse objects'); } /** + * @dataProvider invalidDumpedObjectProvider * @expectedException \Symfony\Component\Yaml\Exception\ParseException */ - public function testObjectsSupportDisabledWithExceptions() + public function testObjectsSupportDisabledWithExceptions($yaml) + { + $this->parser->parse($yaml, true, false); + } + + public function invalidDumpedObjectProvider() { - $this->parser->parse('foo: !!php/object:O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";}', true, false); + $yamlTag = << array($yamlTag), + 'local-tag' => array($localTag), + ); } /** From 4d2930e52abc729440dbec52c8c2c036bb399f21 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 20 Jan 2016 20:58:57 +0100 Subject: [PATCH 056/226] make tests compatible with Symfony 2.8 and 3.0 --- .../Tests/Extension/Core/Type/ChoiceTypeTest.php | 6 +++--- .../Form/Tests/Fixtures/ChoiceSubType.php | 14 +++----------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php index a2e5649230095..6c3c89f4686e1 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php @@ -14,7 +14,6 @@ use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView; use Symfony\Component\Form\ChoiceList\View\ChoiceView; use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList; -use Symfony\Component\Form\Tests\Fixtures\ChoiceSubType; class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase { @@ -1914,14 +1913,15 @@ public function testInitializeWithDefaultObjectChoice() public function testCustomChoiceTypeDoesNotInheritChoiceLabels() { $builder = $this->factory->createBuilder(); - $builder->add('choice', 'choice', array( + $builder->add('choice', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( 'choices' => array( '1' => '1', '2' => '2', ), + 'choices_as_values' => true, ) ); - $builder->add('subChoice', new ChoiceSubType()); + $builder->add('subChoice', 'Symfony\Component\Form\Tests\Fixtures\ChoiceSubType'); $form = $builder->getForm(); // The default 'choices' normalizer would fill the $choiceLabels, but it has been replaced diff --git a/src/Symfony/Component/Form/Tests/Fixtures/ChoiceSubType.php b/src/Symfony/Component/Form/Tests/Fixtures/ChoiceSubType.php index 857dd5d5a77eb..0227cd71cc4cd 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/ChoiceSubType.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/ChoiceSubType.php @@ -16,7 +16,7 @@ /** * @author Paráda József - */ + */ class ChoiceSubType extends AbstractType { /** @@ -24,7 +24,7 @@ class ChoiceSubType extends AbstractType */ public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults(array('expanded' => true)); + $resolver->setDefaults(array('expanded' => true, 'choices_as_values' => true)); $resolver->setNormalizer('choices', function () { return array( 'attr1' => 'Attribute 1', @@ -33,19 +33,11 @@ public function configureOptions(OptionsResolver $resolver) }); } - /** - * {@inheritdoc} - */ - public function getName() - { - return 'sub_choice'; - } - /** * {@inheritdoc} */ public function getParent() { - return 'choice'; + return 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'; } } From b85059a672cffb192aa1df2f7d8c33244cc82f44 Mon Sep 17 00:00:00 2001 From: Stepan Anchugov Date: Wed, 20 Jan 2016 17:10:14 +0500 Subject: [PATCH 057/226] Remove default match from AbstractConfigCommand::findExtension Previously, findExtension would return the first extension that might not even match the $name parameter. --- .../Command/AbstractConfigCommand.php | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php index aee0eb1f00d8a..232d62ffc97a0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php @@ -48,26 +48,25 @@ protected function listBundles(OutputInterface $output) protected function findExtension($name) { - $extension = null; $bundles = $this->initializeBundles(); foreach ($bundles as $bundle) { - $extension = $bundle->getContainerExtension(); + if ($name === $bundle->getName()) { + return $bundle->getContainerExtension(); + } - if ($extension && ($name === $extension->getAlias() || $name === $bundle->getName())) { - break; + $extension = $bundle->getContainerExtension(); + if ($extension && $name === $extension->getAlias()) { + return $extension; } } - if (!$extension) { + if ('Bundle' !== substr($name, -6)) { + $message = sprintf('No extensions with configuration available for "%s"', $name); + } else { $message = sprintf('No extension with alias "%s" is enabled', $name); - if (preg_match('/Bundle$/', $name)) { - $message = sprintf('No extensions with configuration available for "%s"', $name); - } - - throw new \LogicException($message); } - return $extension; + throw new \LogicException($message); } public function validateConfiguration(ExtensionInterface $extension, $configuration) From 42862c4668561043b9a0aeda37e0785edb1d8d3d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 21 Jan 2016 07:28:40 +0100 Subject: [PATCH 058/226] fixed CS --- .../Extension/TranslationExtensionTest.php | 12 ++-- .../Component/Finder/Tests/FinderTest.php | 3 +- .../Session/Attribute/AttributeBagTest.php | 3 +- .../Attribute/NamespacedAttributeBagTest.php | 3 +- .../Routing/Tests/RouteCompilerTest.php | 68 +++++++++++-------- .../Component/Serializer/Serializer.php | 2 - .../Translation/Tests/fixtures/resources.php | 2 +- src/Symfony/Component/Yaml/Escaper.php | 4 +- 8 files changed, 55 insertions(+), 42 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php index 004cb8f57d23a..e8826f66a660b 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php @@ -88,17 +88,17 @@ public function getTransTests() // transchoice array('{% transchoice count from "messages" %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}', - 'There is no apples', array('count' => 0),), + 'There is no apples', array('count' => 0)), array('{% transchoice count %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}', - 'There is 5 apples', array('count' => 5),), + 'There is 5 apples', array('count' => 5)), array('{% transchoice count %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%){% endtranschoice %}', - 'There is 5 apples (Symfony)', array('count' => 5, 'name' => 'Symfony'),), + 'There is 5 apples (Symfony)', array('count' => 5, 'name' => 'Symfony')), array('{% transchoice count with { \'%name%\': \'Symfony\' } %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%){% endtranschoice %}', - 'There is 5 apples (Symfony)', array('count' => 5),), + 'There is 5 apples (Symfony)', array('count' => 5)), array('{% transchoice count into "fr"%}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}', - 'There is no apples', array('count' => 0),), + 'There is no apples', array('count' => 0)), array('{% transchoice 5 into "fr"%}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}', - 'There is 5 apples',), + 'There is 5 apples'), // trans filter array('{{ "Hello"|trans }}', 'Hello'), diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index cee8bd7530767..aa2e706189518 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -517,8 +517,7 @@ public function testRegexSpecialCharsLocationWithPathRestrictionContainingStartF $finder->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'r+e.gex[c]a(r)s') ->path('/^dir/'); - $expected = array('r+e.gex[c]a(r)s'.DIRECTORY_SEPARATOR.'dir', - 'r+e.gex[c]a(r)s'.DIRECTORY_SEPARATOR.'dir'.DIRECTORY_SEPARATOR.'bar.dat',); + $expected = array('r+e.gex[c]a(r)s'.DIRECTORY_SEPARATOR.'dir', 'r+e.gex[c]a(r)s'.DIRECTORY_SEPARATOR.'dir'.DIRECTORY_SEPARATOR.'bar.dat'); $this->assertIterator($this->toAbsoluteFixtures($expected), $finder); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php index 8d0e7a5c13e6d..ca6ce8a38670a 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php @@ -43,8 +43,9 @@ protected function setUp() 'category' => array( 'fishing' => array( 'first' => 'cod', - 'second' => 'sole',), + 'second' => 'sole', ), + ), ); $this->bag = new AttributeBag('_sf2'); $this->bag->initialize($this->array); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php index b8261da5d0c18..470038fe55170 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php @@ -43,8 +43,9 @@ protected function setUp() 'category' => array( 'fishing' => array( 'first' => 'cod', - 'second' => 'sole',), + 'second' => 'sole', ), + ), ); $this->bag = new NamespacedAttributeBag('_sf2', '/'); $this->bag->initialize($this->array); diff --git a/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php b/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php index 2b7c17faaac4c..f0a4aa4aed3e0 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php @@ -38,7 +38,8 @@ public function provideCompileData() array('/foo'), '/foo', '#^/foo$#s', array(), array( array('text', '/foo'), - ),), + ), + ), array( 'Route with a variable', @@ -46,7 +47,8 @@ public function provideCompileData() '/foo', '#^/foo/(?P[^/]++)$#s', array('bar'), array( array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), - ),), + ), + ), array( 'Route with a variable that has a default value', @@ -54,7 +56,8 @@ public function provideCompileData() '/foo', '#^/foo(?:/(?P[^/]++))?$#s', array('bar'), array( array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), - ),), + ), + ), array( 'Route with several variables', @@ -63,7 +66,8 @@ public function provideCompileData() array('variable', '/', '[^/]++', 'foobar'), array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), - ),), + ), + ), array( 'Route with several variables that have default values', @@ -72,7 +76,8 @@ public function provideCompileData() array('variable', '/', '[^/]++', 'foobar'), array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), - ),), + ), + ), array( 'Route with several variables but some of them have no default values', @@ -81,28 +86,32 @@ public function provideCompileData() array('variable', '/', '[^/]++', 'foobar'), array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), - ),), + ), + ), array( 'Route with an optional variable as the first segment', array('/{bar}', array('bar' => 'bar')), '', '#^/(?P[^/]++)?$#s', array('bar'), array( array('variable', '/', '[^/]++', 'bar'), - ),), + ), + ), array( 'Route with a requirement of 0', array('/{bar}', array('bar' => null), array('bar' => '0')), '', '#^/(?P0)?$#s', array('bar'), array( array('variable', '/', '0', 'bar'), - ),), + ), + ), array( 'Route with an optional variable as the first segment with requirements', array('/{bar}', array('bar' => 'bar'), array('bar' => '(foo|bar)')), '', '#^/(?P(foo|bar))?$#s', array('bar'), array( array('variable', '/', '(foo|bar)', 'bar'), - ),), + ), + ), array( 'Route with only optional variables', @@ -110,44 +119,49 @@ public function provideCompileData() '', '#^/(?P[^/]++)?(?:/(?P[^/]++))?$#s', array('foo', 'bar'), array( array('variable', '/', '[^/]++', 'bar'), array('variable', '/', '[^/]++', 'foo'), - ),), + ), + ), array( 'Route with a variable in last position', array('/foo-{bar}'), '/foo', '#^/foo\-(?P[^/]++)$#s', array('bar'), array( - array('variable', '-', '[^/]++', 'bar'), - array('text', '/foo'), - ),), + array('variable', '-', '[^/]++', 'bar'), + array('text', '/foo'), + ), + ), array( 'Route with nested placeholders', array('/{static{var}static}'), '/{static', '#^/\{static(?P[^/]+)static\}$#s', array('var'), array( - array('text', 'static}'), - array('variable', '', '[^/]+', 'var'), - array('text', '/{static'), - ),), + array('text', 'static}'), + array('variable', '', '[^/]+', 'var'), + array('text', '/{static'), + ), + ), array( 'Route without separator between variables', array('/{w}{x}{y}{z}.{_format}', array('z' => 'default-z', '_format' => 'html'), array('y' => '(y|Y)')), '', '#^/(?P[^/\.]+)(?P[^/\.]+)(?P(y|Y))(?:(?P[^/\.]++)(?:\.(?P<_format>[^/]++))?)?$#s', array('w', 'x', 'y', 'z', '_format'), array( - array('variable', '.', '[^/]++', '_format'), - array('variable', '', '[^/\.]++', 'z'), - array('variable', '', '(y|Y)', 'y'), - array('variable', '', '[^/\.]+', 'x'), - array('variable', '/', '[^/\.]+', 'w'), - ),), + array('variable', '.', '[^/]++', '_format'), + array('variable', '', '[^/\.]++', 'z'), + array('variable', '', '(y|Y)', 'y'), + array('variable', '', '[^/\.]+', 'x'), + array('variable', '/', '[^/\.]+', 'w'), + ), + ), array( 'Route with a format', array('/foo/{bar}.{_format}'), '/foo', '#^/foo/(?P[^/\.]++)\.(?P<_format>[^/]++)$#s', array('bar', '_format'), array( - array('variable', '.', '[^/]++', '_format'), - array('variable', '/', '[^/\.]++', 'bar'), - array('text', '/foo'), - ),), + array('variable', '.', '[^/]++', '_format'), + array('variable', '/', '[^/\.]++', 'bar'), + array('text', '/foo'), + ), + ), ); } diff --git a/src/Symfony/Component/Serializer/Serializer.php b/src/Symfony/Component/Serializer/Serializer.php index 1819def5f64ed..c3e07e821c023 100644 --- a/src/Symfony/Component/Serializer/Serializer.php +++ b/src/Symfony/Component/Serializer/Serializer.php @@ -237,7 +237,6 @@ private function normalizeObject($object, $format = null, array $context = array foreach ($this->normalizers as $normalizer) { if ($normalizer instanceof NormalizerInterface && $normalizer->supportsNormalization($object, $format)) { - return $normalizer->normalize($object, $format, $context); } } @@ -271,7 +270,6 @@ private function denormalizeObject($data, $class, $format = null, array $context foreach ($this->normalizers as $normalizer) { if ($normalizer instanceof DenormalizerInterface && $normalizer->supportsDenormalization($data, $class, $format)) { - return $normalizer->denormalize($data, $class, $format, $context); } } diff --git a/src/Symfony/Component/Translation/Tests/fixtures/resources.php b/src/Symfony/Component/Translation/Tests/fixtures/resources.php index c2913985391cb..0cc2bec1d52b5 100644 --- a/src/Symfony/Component/Translation/Tests/fixtures/resources.php +++ b/src/Symfony/Component/Translation/Tests/fixtures/resources.php @@ -1,5 +1,5 @@ 'bar', ); diff --git a/src/Symfony/Component/Yaml/Escaper.php b/src/Symfony/Component/Yaml/Escaper.php index ac325a2c2f259..cb676d0059c78 100644 --- a/src/Symfony/Component/Yaml/Escaper.php +++ b/src/Symfony/Component/Yaml/Escaper.php @@ -31,13 +31,13 @@ class Escaper "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f", "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f", - "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9",); + "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9"); private static $escaped = array('\\\\', '\\"', '\\\\', '\\"', '\\0', '\\x01', '\\x02', '\\x03', '\\x04', '\\x05', '\\x06', '\\a', '\\b', '\\t', '\\n', '\\v', '\\f', '\\r', '\\x0e', '\\x0f', '\\x10', '\\x11', '\\x12', '\\x13', '\\x14', '\\x15', '\\x16', '\\x17', '\\x18', '\\x19', '\\x1a', '\\e', '\\x1c', '\\x1d', '\\x1e', '\\x1f', - '\\N', '\\_', '\\L', '\\P',); + '\\N', '\\_', '\\L', '\\P'); /** * Determines if a PHP value would require double quoting in YAML. From 6eda9ad834a62f18342c799f4ff46e997e748285 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 21 Jan 2016 09:40:05 +0100 Subject: [PATCH 059/226] fixed test --- src/Symfony/Component/Translation/Tests/fixtures/resources.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Translation/Tests/fixtures/resources.php b/src/Symfony/Component/Translation/Tests/fixtures/resources.php index 0cc2bec1d52b5..c2913985391cb 100644 --- a/src/Symfony/Component/Translation/Tests/fixtures/resources.php +++ b/src/Symfony/Component/Translation/Tests/fixtures/resources.php @@ -1,5 +1,5 @@ 'bar', ); From 06b958a17e7bf41b2ce11a083c9f1ed4470e1a8a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 21 Jan 2016 09:36:03 +0100 Subject: [PATCH 060/226] fixed CS --- src/Symfony/Component/Debug/DebugClassLoader.php | 2 +- src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php | 6 +++--- .../Component/DependencyInjection/DefinitionDecorator.php | 1 - src/Symfony/Component/Filesystem/LockHandler.php | 2 +- src/Symfony/Component/Form/Tests/Fixtures/ChoiceSubType.php | 2 +- .../OptionsResolver/Tests/OptionsResolver2Dot6Test.php | 4 ++-- src/Symfony/Component/Routing/Tests/RouteCompilerTest.php | 2 +- .../Serializer/Tests/Normalizer/PropertyNormalizerTest.php | 1 - .../Component/Validator/ConstraintViolationInterface.php | 1 - .../VarDumper/Tests/Test/VarDumperTestTraitRequire54.php | 2 +- .../VarDumper/Tests/Test/VarDumperTestTraitTest.php | 1 - 11 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/Symfony/Component/Debug/DebugClassLoader.php b/src/Symfony/Component/Debug/DebugClassLoader.php index 95ccc8798e8c1..c3882fba6468b 100644 --- a/src/Symfony/Component/Debug/DebugClassLoader.php +++ b/src/Symfony/Component/Debug/DebugClassLoader.php @@ -224,7 +224,7 @@ public function loadClass($class) $i = count($tail) - 1; $j = count($real) - 1; - while (isset($tail[$i], $real[$j]) && $tail[$i] === $real[$j]) { + while (isset($tail[$i], $real[$j]) && $tail[$i] === $real[$j]) { --$i; --$j; } diff --git a/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php b/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php index 2f948d75727c6..50ffa7fd3c355 100644 --- a/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php +++ b/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php @@ -175,7 +175,7 @@ public function testClassAlias() */ public function testDeprecatedSuper($class, $super, $type) { - set_error_handler(function() { return false; }); + set_error_handler(function () { return false; }); $e = error_reporting(0); trigger_error('', E_USER_DEPRECATED); @@ -205,7 +205,7 @@ public function provideDeprecatedSuper() public function testDeprecatedSuperInSameNamespace() { - set_error_handler(function() { return false; }); + set_error_handler(function () { return false; }); $e = error_reporting(0); trigger_error('', E_USER_NOTICE); @@ -231,7 +231,7 @@ public function testReservedForPhp7() $this->markTestSkipped('PHP7 already prevents using reserved names.'); } - set_error_handler(function() { return false; }); + set_error_handler(function () { return false; }); $e = error_reporting(0); trigger_error('', E_USER_NOTICE); diff --git a/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php b/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php index 334127a3790bb..fd5b00cd203c0 100644 --- a/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php +++ b/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php @@ -78,7 +78,6 @@ public function setFactory($callable) /** * {@inheritdoc} - * */ public function setFactoryClass($class) { diff --git a/src/Symfony/Component/Filesystem/LockHandler.php b/src/Symfony/Component/Filesystem/LockHandler.php index b53d9f4d52d93..67e6f8f522c1c 100644 --- a/src/Symfony/Component/Filesystem/LockHandler.php +++ b/src/Symfony/Component/Filesystem/LockHandler.php @@ -69,7 +69,7 @@ public function lock($blocking = false) } // Silence error reporting - set_error_handler(function() {}); + set_error_handler(function () {}); if (!$this->handle = fopen($this->file, 'r')) { if ($this->handle = fopen($this->file, 'x')) { diff --git a/src/Symfony/Component/Form/Tests/Fixtures/ChoiceSubType.php b/src/Symfony/Component/Form/Tests/Fixtures/ChoiceSubType.php index 857dd5d5a77eb..6ada02f1ee3d3 100644 --- a/src/Symfony/Component/Form/Tests/Fixtures/ChoiceSubType.php +++ b/src/Symfony/Component/Form/Tests/Fixtures/ChoiceSubType.php @@ -16,7 +16,7 @@ /** * @author Paráda József - */ + */ class ChoiceSubType extends AbstractType { /** diff --git a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolver2Dot6Test.php b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolver2Dot6Test.php index 9158c5ba069ce..2dc4362375a41 100644 --- a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolver2Dot6Test.php +++ b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolver2Dot6Test.php @@ -1102,7 +1102,7 @@ public function testCatchedExceptionFromNormalizerDoesNotCrashOptionResolver() $this->resolver->setNormalizer('catcher', function (Options $options) { try { return $options['thrower']; - } catch(\Exception $e) { + } catch (\Exception $e) { return false; } }); @@ -1126,7 +1126,7 @@ public function testCatchedExceptionFromLazyDoesNotCrashOptionResolver() $this->resolver->setDefault('catcher', function (Options $options) { try { return $options['thrower']; - } catch(\Exception $e) { + } catch (\Exception $e) { return false; } }); diff --git a/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php b/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php index f0a4aa4aed3e0..b4b4f45a8379f 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php @@ -160,7 +160,7 @@ public function provideCompileData() array('variable', '.', '[^/]++', '_format'), array('variable', '/', '[^/\.]++', 'bar'), array('text', '/foo'), - ), + ), ), ); } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php index 381936ad006ee..a2d1a063d31b2 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php @@ -510,4 +510,3 @@ class StaticPropertyDummy { private static $property = 'value'; } - diff --git a/src/Symfony/Component/Validator/ConstraintViolationInterface.php b/src/Symfony/Component/Validator/ConstraintViolationInterface.php index 1ed09b3d96fe4..ecd07e32b0e84 100644 --- a/src/Symfony/Component/Validator/ConstraintViolationInterface.php +++ b/src/Symfony/Component/Validator/ConstraintViolationInterface.php @@ -60,7 +60,6 @@ public function getMessageTemplate(); * that appear in the message template. * * @see getMessageTemplate() - * * @deprecated since version 2.7, to be replaced by getParameters() in 3.0. */ public function getMessageParameters(); diff --git a/src/Symfony/Component/VarDumper/Tests/Test/VarDumperTestTraitRequire54.php b/src/Symfony/Component/VarDumper/Tests/Test/VarDumperTestTraitRequire54.php index 240cc926aaccc..54f86a59db4e5 100644 --- a/src/Symfony/Component/VarDumper/Tests/Test/VarDumperTestTraitRequire54.php +++ b/src/Symfony/Component/VarDumper/Tests/Test/VarDumperTestTraitRequire54.php @@ -14,7 +14,7 @@ use Symfony\Component\VarDumper\Test\VarDumperTestCase; use Symfony\Component\VarDumper\Test\VarDumperTestTrait; -class VarDumperTestTraitTest extends VarDumperTestCase +class VarDumperTestTraitRequire54 extends VarDumperTestCase { use VarDumperTestTrait; diff --git a/src/Symfony/Component/VarDumper/Tests/Test/VarDumperTestTraitTest.php b/src/Symfony/Component/VarDumper/Tests/Test/VarDumperTestTraitTest.php index 2be2f8c2a40e7..a87476be75217 100644 --- a/src/Symfony/Component/VarDumper/Tests/Test/VarDumperTestTraitTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Test/VarDumperTestTraitTest.php @@ -13,4 +13,3 @@ if (PHP_VERSION_ID >= 50400) { require __DIR__.'/VarDumperTestTraitRequire54.php'; } - From 3aafa78f4d449a329c6d8a58d3088cc4183de7b8 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 21 Jan 2016 10:24:53 +0100 Subject: [PATCH 061/226] fixed CS --- src/Symfony/Bridge/PhpUnit/ClockMock.php | 1 - .../Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php | 2 +- .../FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php | 2 +- .../DependencyInjection/Compiler/PropertyInfoPassTest.php | 2 +- .../SecurityBundle/DataCollector/SecurityDataCollector.php | 2 +- .../DependencyInjection/Security/UserProvider/LdapFactory.php | 2 +- src/Symfony/Component/Config/ResourceCheckerInterface.php | 1 - src/Symfony/Component/Console/Style/SymfonyStyle.php | 4 ++-- src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php | 2 +- .../Component/DependencyInjection/Dumper/PhpDumper.php | 1 - src/Symfony/Component/Filesystem/Tests/FilesystemTest.php | 1 - .../Component/Process/Tests/ProcessFailedExceptionTest.php | 2 +- src/Symfony/Component/Security/Core/User/LdapUserProvider.php | 1 - .../Component/Translation/Catalogue/TargetOperation.php | 2 +- .../Translation/Tests/Catalogue/TargetOperationTest.php | 1 - src/Symfony/Component/Yaml/Unescaper.php | 2 +- 16 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/Symfony/Bridge/PhpUnit/ClockMock.php b/src/Symfony/Bridge/PhpUnit/ClockMock.php index b81fee965880a..fe5cd851258d2 100644 --- a/src/Symfony/Bridge/PhpUnit/ClockMock.php +++ b/src/Symfony/Bridge/PhpUnit/ClockMock.php @@ -109,5 +109,4 @@ function usleep(\$us) ); } } - } diff --git a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php index e1ec80608c633..193e1e1f791ae 100644 --- a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php +++ b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php @@ -74,7 +74,7 @@ public function getProxyFactoryCode(Definition $definition, $id) if (defined('Symfony\Component\DependencyInjection\ContainerInterface::SCOPE_CONTAINER') && ContainerInterface::SCOPE_CONTAINER !== $scope = $definition->getScope(false)) { $instantiation .= " \$this->scopedServices['$scope']['$id'] ="; } - } + } $methodName = 'get'.Container::camelize($id).'Service'; $proxyClass = $this->getProxyClassName($definition); diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php index 47e46bc8e1231..209c01ed22bdd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php @@ -199,7 +199,7 @@ protected function describeContainerDefinition(Definition $definition, array $op $output .= "\n".'- Autowired: '.($definition->isAutowired() ? 'yes' : 'no'); foreach ($definition->getAutowiringTypes() as $autowiringType) { - $output .= "\n".'- Autowiring Type: `'.$autowiringType.'`'; + $output .= "\n".'- Autowiring Type: `'.$autowiringType.'`'; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php index 3d41fb12b09e5..74f0b607bda3e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php @@ -53,7 +53,7 @@ public function testReturningEmptyArrayWhenNoService() { $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder', array('findTaggedServiceIds')); - $container->expects($this->any()) + $container->expects($this->any()) ->method('findTaggedServiceIds') ->will($this->returnValue(array())); diff --git a/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php b/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php index 7b3e111974ea5..0fff7552e858d 100644 --- a/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php +++ b/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php @@ -89,7 +89,7 @@ public function collect(Request $request, Response $response, \Exception $except if (null !== $this->logoutUrlGenerator) { $logoutUrl = $this->logoutUrlGenerator->getLogoutPath(); } - } catch(\Exception $e) { + } catch (\Exception $e) { // fail silently when the logout URL cannot be generated } diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/UserProvider/LdapFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/UserProvider/LdapFactory.php index 068cda6a1fe81..8aea9074bd71a 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/UserProvider/LdapFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/UserProvider/LdapFactory.php @@ -52,7 +52,7 @@ public function addConfiguration(NodeDefinition $node) ->scalarNode('search_dn')->end() ->scalarNode('search_password')->end() ->arrayNode('default_roles') - ->beforeNormalization()->ifString()->then(function($v) { return preg_split('/\s*,\s*/', $v); })->end() + ->beforeNormalization()->ifString()->then(function ($v) { return preg_split('/\s*,\s*/', $v); })->end() ->requiresAtLeastOneElement() ->prototype('scalar')->end() ->end() diff --git a/src/Symfony/Component/Config/ResourceCheckerInterface.php b/src/Symfony/Component/Config/ResourceCheckerInterface.php index aaa5c5065e302..27a04745a81a4 100644 --- a/src/Symfony/Component/Config/ResourceCheckerInterface.php +++ b/src/Symfony/Component/Config/ResourceCheckerInterface.php @@ -45,5 +45,4 @@ public function supports(ResourceInterface $metadata); * @return bool True if the resource has not changed since the given timestamp, false otherwise. */ public function isFresh(ResourceInterface $resource, $timestamp); - } diff --git a/src/Symfony/Component/Console/Style/SymfonyStyle.php b/src/Symfony/Component/Console/Style/SymfonyStyle.php index c69b0dc61dfc4..47d7d1249d128 100644 --- a/src/Symfony/Component/Console/Style/SymfonyStyle.php +++ b/src/Symfony/Component/Console/Style/SymfonyStyle.php @@ -151,7 +151,7 @@ public function text($message) $messages = is_array($message) ? array_values($message) : array($message); foreach ($messages as $message) { - $this->writeln(sprintf(' %s', $message)); + $this->writeln(sprintf(' %s', $message)); } } @@ -164,7 +164,7 @@ public function comment($message) $messages = is_array($message) ? array_values($message) : array($message); foreach ($messages as $message) { - $this->writeln(sprintf(' // %s', $message)); + $this->writeln(sprintf(' // %s', $message)); } } diff --git a/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php b/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php index 7973f14b5156b..a5ce693078725 100644 --- a/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php +++ b/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php @@ -205,7 +205,7 @@ public function provideDeprecatedSuper() public function testInterfaceExtendsDeprecatedInterface() { - set_error_handler(function() { return false; }); + set_error_handler(function () { return false; }); $e = error_reporting(0); trigger_error('', E_USER_NOTICE); diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 23697cbf42cd7..32fa6036e486f 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -622,7 +622,6 @@ private function addService($id, $definition) * * This service is autowired. EOF; - } if ($definition->isLazy()) { diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index 73695fb7abb0b..7341536e4f948 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -1005,7 +1005,6 @@ public function testTempnamWithZlibSchemeFails() // The compress.zlib:// stream does not support mode x: creates the file, errors "failed to open stream: operation failed" and returns false $this->filesystem->tempnam($dirname, 'bar'); - } public function testTempnamWithPHPTempSchemeFails() diff --git a/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php b/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php index 0d763a470d19e..963bbb30105d6 100644 --- a/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php @@ -132,7 +132,7 @@ public function testDisabledOutputInFailedExceptionDoesNotPopulateOutput() ->method('isOutputDisabled') ->will($this->returnValue(true)); - $process->expects($this->once()) + $process->expects($this->once()) ->method('getWorkingDirectory') ->will($this->returnValue($workingDirectory)); diff --git a/src/Symfony/Component/Security/Core/User/LdapUserProvider.php b/src/Symfony/Component/Security/Core/User/LdapUserProvider.php index 988a595f58b00..15935648abd30 100644 --- a/src/Symfony/Component/Security/Core/User/LdapUserProvider.php +++ b/src/Symfony/Component/Security/Core/User/LdapUserProvider.php @@ -105,5 +105,4 @@ public function supportsClass($class) { return $class === 'Symfony\Component\Security\Core\User\User'; } - } diff --git a/src/Symfony/Component/Translation/Catalogue/TargetOperation.php b/src/Symfony/Component/Translation/Catalogue/TargetOperation.php index eea1fefe2fb22..e081e139a33fa 100644 --- a/src/Symfony/Component/Translation/Catalogue/TargetOperation.php +++ b/src/Symfony/Component/Translation/Catalogue/TargetOperation.php @@ -42,7 +42,7 @@ protected function processDomain($domain) // // For 'obsolete' messages, the code can't be simplifed as ``array_diff_assoc($this->source->all($domain), $this->target->all($domain))`` // because doing so will not exclude messages like {x: x ∈ source ∧ x ∉ target.all ∧ x ∈ target.fallback} - + foreach ($this->source->all($domain) as $id => $message) { if ($this->target->has($id, $domain)) { $this->messages[$domain]['all'][$id] = $message; diff --git a/src/Symfony/Component/Translation/Tests/Catalogue/TargetOperationTest.php b/src/Symfony/Component/Translation/Tests/Catalogue/TargetOperationTest.php index 0217162aea6fe..271d17fb8f311 100644 --- a/src/Symfony/Component/Translation/Tests/Catalogue/TargetOperationTest.php +++ b/src/Symfony/Component/Translation/Tests/Catalogue/TargetOperationTest.php @@ -79,5 +79,4 @@ protected function createOperation(MessageCatalogueInterface $source, MessageCat { return new TargetOperation($source, $target); } - } diff --git a/src/Symfony/Component/Yaml/Unescaper.php b/src/Symfony/Component/Yaml/Unescaper.php index d2f5054ad2786..bb3301615b4a2 100644 --- a/src/Symfony/Component/Yaml/Unescaper.php +++ b/src/Symfony/Component/Yaml/Unescaper.php @@ -34,7 +34,7 @@ class Unescaper /** * Regex fragment that matches an escaped character in a double quoted string. */ - const REGEX_ESCAPED_CHARACTER = "\\\\(x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|.)"; + const REGEX_ESCAPED_CHARACTER = '\\\\(x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|.)'; /** * Unescapes a single quoted string. From 548d80341512b871c3f0317fc4dc68710c58cbd4 Mon Sep 17 00:00:00 2001 From: Lebnik Date: Thu, 21 Jan 2016 15:16:05 +0300 Subject: [PATCH 062/226] Remove unnecessary code ``` php > echo (E_ALL | E_STRICT) & (0 | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED; 4352 php > echo (0 | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED; 4352 php > echo (2 | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED; 4354 ``` --- src/Symfony/Component/Debug/ErrorHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index 3ec11276a924c..c3cae81bde0d9 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -257,7 +257,7 @@ public function setExceptionHandler($handler) public function throwAt($levels, $replace = false) { $prev = $this->thrownErrors; - $this->thrownErrors = (E_ALL | E_STRICT) & ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED; + $this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED; if (!$replace) { $this->thrownErrors |= $prev; } From 53ebfda33ea6a0262c3cf49fce96b6b091182bba Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Thu, 21 Jan 2016 15:41:38 +0000 Subject: [PATCH 063/226] [HttpFoundation] Do not overwrite the Authorization header if it is already set --- .../Component/HttpFoundation/ServerBag.php | 4 ++++ .../HttpFoundation/Tests/ServerBagTest.php | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/Symfony/Component/HttpFoundation/ServerBag.php b/src/Symfony/Component/HttpFoundation/ServerBag.php index fa1cb2fc9f134..0d38c08ac0544 100644 --- a/src/Symfony/Component/HttpFoundation/ServerBag.php +++ b/src/Symfony/Component/HttpFoundation/ServerBag.php @@ -86,6 +86,10 @@ public function getHeaders() } } + if (isset($headers['AUTHORIZATION'])) { + return $headers; + } + // PHP_AUTH_USER/PHP_AUTH_PW if (isset($headers['PHP_AUTH_USER'])) { $headers['AUTHORIZATION'] = 'Basic '.base64_encode($headers['PHP_AUTH_USER'].':'.$headers['PHP_AUTH_PW']); diff --git a/src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php index 20773c4d7a3b6..41e44e10056ea 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php @@ -151,4 +151,19 @@ public function testOAuthBearerAuthWithRedirect() 'AUTHORIZATION' => $headerContent, ), $bag->getHeaders()); } + + /** + * @see https://github.com/symfony/symfony/issues/17345 + */ + public function testItDoesNotOverwriteTheAuthorizationHeaderIfItIsAlreadySet() + { + $headerContent = 'Bearer L-yLEOr9zhmUYRkzN1jwwxwQ-PBNiKDc8dgfB4hTfvo'; + $bag = new ServerBag(array('PHP_AUTH_USER' => 'foo', 'HTTP_AUTHORIZATION' => $headerContent)); + + $this->assertEquals(array( + 'AUTHORIZATION' => $headerContent, + 'PHP_AUTH_USER' => 'foo', + 'PHP_AUTH_PW' => '', + ), $bag->getHeaders()); + } } From d7b730f3e55e1b3ba3c391e0b80ccc3fd69733f1 Mon Sep 17 00:00:00 2001 From: Possum Date: Fri, 22 Jan 2016 08:50:32 +0100 Subject: [PATCH 064/226] Fixer findings. --- src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php | 1 + .../Console/Tests/Descriptor/AbstractDescriptorTest.php | 1 + .../Component/CssSelector/Tests/Node/AbstractNodeTest.php | 1 + .../CssSelector/Tests/Parser/Handler/AbstractHandlerTest.php | 2 ++ .../HttpFoundation/HttpFoundationRequestHandlerTest.php | 1 + src/Symfony/Component/HttpFoundation/Response.php | 1 + .../Tests/Fragment/RoutableFragmentRendererTest.php | 1 + .../Security/Tests/Core/Encoder/EncoderFactoryTest.php | 4 ++++ .../Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php | 1 + 9 files changed, 13 insertions(+) diff --git a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php index 4399ca7728769..26ba94a1bf0bd 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php @@ -36,6 +36,7 @@ public function testCompileStrict() trim($compiler->compile($node)->getSource()) ); } + protected function getVariableGetterWithoutStrictCheck($name) { if (PHP_VERSION_ID >= 50400) { diff --git a/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php b/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php index aab1cf376171f..9cd979271e87c 100644 --- a/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php +++ b/src/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php @@ -82,6 +82,7 @@ public function getDescribeApplicationTestData() } abstract protected function getDescriptor(); + abstract protected function getFormat(); private function getDescriptionTestData(array $objects) diff --git a/src/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTest.php b/src/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTest.php index 16a3a34d6497d..932e8030dd896 100644 --- a/src/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTest.php @@ -28,5 +28,6 @@ public function testSpecificityValue(NodeInterface $node, $value) } abstract public function getToStringConversionTestData(); + abstract public function getSpecificityValueTestData(); } diff --git a/src/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTest.php b/src/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTest.php index a06dca013bae7..57afa5a2422b0 100644 --- a/src/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTest.php @@ -43,7 +43,9 @@ public function testDontHandleValue($value) } abstract public function getHandleValueTestData(); + abstract public function getDontHandleValueTestData(); + abstract protected function generateHandler(); protected function assertStreamEmpty(TokenStream $stream) diff --git a/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php index 4d4ac86fe73af..e71a1fdfd8058 100644 --- a/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php @@ -28,6 +28,7 @@ public function testRequestShouldNotBeNull() { $this->requestHandler->handleRequest($this->getMockForm('name', 'GET')); } + /** * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException */ diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index a21e6b921cc68..0318b9be63254 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -977,6 +977,7 @@ public function isNotModified(Request $request) } // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html + /** * Is response invalid? * diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php index f0a1cf4084306..0222998ea2750 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php @@ -65,6 +65,7 @@ class Renderer extends RoutableFragmentRenderer public function render($uri, Request $request, array $options = array()) { } + public function getName() { } diff --git a/src/Symfony/Component/Security/Tests/Core/Encoder/EncoderFactoryTest.php b/src/Symfony/Component/Security/Tests/Core/Encoder/EncoderFactoryTest.php index 85d4e91356dad..4fe60adcd1fc8 100644 --- a/src/Symfony/Component/Security/Tests/Core/Encoder/EncoderFactoryTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Encoder/EncoderFactoryTest.php @@ -85,15 +85,19 @@ class SomeUser implements UserInterface public function getRoles() { } + public function getPassword() { } + public function getSalt() { } + public function getUsername() { } + public function eraseCredentials() { } diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php index 731ab835619f3..89fe9be80f478 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/AnnotationLoaderTest.php @@ -87,6 +87,7 @@ public function testLoadParentClassMetadata() $this->assertEquals($expected_parent, $parent_metadata); } + /** * Test MetaData merge with parent annotation. */ From 80d51e0d18f0ed0a5e9b74a9d338525fd477592d Mon Sep 17 00:00:00 2001 From: Stepan Anchugov Date: Fri, 22 Jan 2016 18:33:13 +0500 Subject: [PATCH 065/226] Sort bundles in config commands --- .../FrameworkBundle/Command/AbstractConfigCommand.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php index 232d62ffc97a0..711934c73ab36 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php @@ -30,7 +30,13 @@ protected function listBundles(OutputInterface $output) { $headers = array('Bundle name', 'Extension alias'); $rows = array(); - foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) { + + $bundles = $this->getContainer()->get('kernel')->getBundles(); + usort($bundles, function($bundleA, $bundleB) { + return strcmp($bundleA->getName(), $bundleB->getName()); + }); + + foreach ($bundles as $bundle) { $extension = $bundle->getContainerExtension(); $rows[] = array($bundle->getName(), $extension ? $extension->getAlias() : ''); } From 68292bb52b739b47d7f7d4293a2dd98ac05122ab Mon Sep 17 00:00:00 2001 From: "Issei.M" Date: Sat, 23 Jan 2016 17:56:23 +0900 Subject: [PATCH 066/226] [Form] ArrayChoiceList can now deal with a null in choices --- src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php | 2 +- .../Form/Tests/ChoiceList/ArrayChoiceListTest.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php b/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php index b1e6b3bf06b5c..e979455ef3799 100644 --- a/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php +++ b/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php @@ -141,7 +141,7 @@ public function getChoicesForValues(array $values) $choices = array(); foreach ($values as $i => $givenValue) { - if (isset($this->choices[$givenValue])) { + if (array_key_exists($givenValue, $this->choices)) { $choices[$i] = $this->choices[$givenValue]; } } diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php index 03cb7fce5705a..9ea5f631a1585 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php @@ -130,4 +130,11 @@ public function testCompareChoicesByIdentityByDefault() $this->assertSame(array(2 => 'value2'), $choiceList->getValuesForChoices(array(2 => $obj2))); $this->assertSame(array(2 => 'value2'), $choiceList->getValuesForChoices(array(2 => (object) array('value' => 'value2')))); } + + public function testGetChoicesForValuesWithContainingNull() + { + $choiceList = new ArrayChoiceList(array('Null' => null)); + + $this->assertSame(array(0 => null), $choiceList->getChoicesForValues(array('0'))); + } } From bf56d2fc17715fb05660fa9e6306a012e9d12384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Par=C3=A1da=20J=C3=B3zsef?= Date: Fri, 22 Jan 2016 17:31:58 +0100 Subject: [PATCH 067/226] [SecurityBundle] Optimize dependency injection tests --- .../DependencyInjection/CompleteConfigurationTest.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php index 86ddb828f5799..0e7736aa2b954 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php @@ -19,6 +19,8 @@ abstract class CompleteConfigurationTest extends \PHPUnit_Framework_TestCase { + private static $containerCache = array(); + abstract protected function loadFromFile(ContainerBuilder $container, $file); public function testRolesHierarchy() @@ -182,6 +184,9 @@ public function testCustomAclProvider() protected function getContainer($file) { + if (isset(self::$containerCache[$file])) { + return self::$containerCache[$file]; + } $container = new ContainerBuilder(); $security = new SecurityExtension(); $container->registerExtension($security); @@ -194,6 +199,6 @@ protected function getContainer($file) $container->getCompilerPassConfig()->setRemovingPasses(array()); $container->compile(); - return $container; + return self::$containerCache[$file] = $container; } } From 766a648dedf7fb08b59b966f812240a3281f525a Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 23 Jan 2016 10:36:08 +0100 Subject: [PATCH 068/226] CLI: use request context to generate absolute URLs --- .../Extension/HttpFoundationExtension.php | 22 +++++++++- .../Extension/HttpFoundationExtensionTest.php | 44 +++++++++++++++++++ .../TwigBundle/Resources/config/twig.xml | 1 + 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php b/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php index ad7949dfaa682..69d6d326f4d08 100644 --- a/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php @@ -13,6 +13,7 @@ use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\RequestContext; /** * Twig extension for the Symfony HttpFoundation component. @@ -22,10 +23,12 @@ class HttpFoundationExtension extends \Twig_Extension { private $requestStack; + private $requestContext; - public function __construct(RequestStack $requestStack) + public function __construct(RequestStack $requestStack, RequestContext $requestContext = null) { $this->requestStack = $requestStack; + $this->requestContext = $requestContext; } /** @@ -57,6 +60,23 @@ public function generateAbsoluteUrl($path) } if (!$request = $this->requestStack->getMasterRequest()) { + if (null !== $this->requestContext && '' !== $host = $this->requestContext->getHost()) { + $scheme = $this->requestContext->getScheme(); + $port = ''; + + if ('http' === $scheme && 80 != $this->requestContext->getHttpPort()) { + $port = ':'.$this->requestContext->getHttpPort(); + } elseif ('https' === $scheme && 443 != $this->requestContext->getHttpsPort()) { + $port = ':'.$this->requestContext->getHttpsPort(); + } + + if ('/' !== $path[0]) { + $path = rtrim($this->requestContext->getBaseUrl(), '/').'/'.$path; + } + + return $scheme.'://'.$host.$port.$path; + } + return $path; } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php index 91f978a909381..339d43d7c6bd1 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/HttpFoundationExtensionTest.php @@ -14,6 +14,7 @@ use Symfony\Bridge\Twig\Extension\HttpFoundationExtension; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\RequestContext; class HttpFoundationExtensionTest extends \PHPUnit_Framework_TestCase { @@ -43,6 +44,49 @@ public function getGenerateAbsoluteUrlData() ); } + /** + * @dataProvider getGenerateAbsoluteUrlRequestContextData + */ + public function testGenerateAbsoluteUrlWithRequestContext($path, $baseUrl, $host, $scheme, $httpPort, $httpsPort, $expected) + { + if (!class_exists('Symfony\Component\Routing\RequestContext')) { + $this->markTestSkipped('The Routing component is needed to run tests that depend on its request context.'); + } + + $requestContext = new RequestContext($baseUrl, 'GET', $host, $scheme, $httpPort, $httpsPort, $path); + $extension = new HttpFoundationExtension(new RequestStack(), $requestContext); + + $this->assertEquals($expected, $extension->generateAbsoluteUrl($path)); + } + + /** + * @dataProvider getGenerateAbsoluteUrlRequestContextData + */ + public function testGenerateAbsoluteUrlWithoutRequestAndRequestContext($path) + { + if (!class_exists('Symfony\Component\Routing\RequestContext')) { + $this->markTestSkipped('The Routing component is needed to run tests that depend on its request context.'); + } + + $extension = new HttpFoundationExtension(new RequestStack()); + + $this->assertEquals($path, $extension->generateAbsoluteUrl($path)); + } + + public function getGenerateAbsoluteUrlRequestContextData() + { + return array( + array('/foo.png', '/foo', 'localhost', 'http', 80, 443, 'http://localhost/foo.png'), + array('foo.png', '/foo', 'localhost', 'http', 80, 443, 'http://localhost/foo/foo.png'), + array('foo.png', '/foo/bar/', 'localhost', 'http', 80, 443, 'http://localhost/foo/bar/foo.png'), + array('/foo.png', '/foo', 'localhost', 'https', 80, 443, 'https://localhost/foo.png'), + array('foo.png', '/foo', 'localhost', 'https', 80, 443, 'https://localhost/foo/foo.png'), + array('foo.png', '/foo/bar/', 'localhost', 'https', 80, 443, 'https://localhost/foo/bar/foo.png'), + array('/foo.png', '/foo', 'localhost', 'http', 443, 80, 'http://localhost:443/foo.png'), + array('/foo.png', '/foo', 'localhost', 'https', 443, 80, 'https://localhost:80/foo.png'), + ); + } + public function testGenerateAbsoluteUrlWithScriptFileName() { $request = Request::create('http://localhost/app/web/app_dev.php'); diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml index 6a13980fcd048..f2c2a4cee007c 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml @@ -127,6 +127,7 @@ + From 124d1507741b2358b96fb86dc091d37cf67a1d57 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 20 Jan 2016 16:10:36 +0100 Subject: [PATCH 069/226] Display Ajax request from newest to oldest in the toolbar --- .../Resources/views/Profiler/base_js.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig index 84476a1977455..66055a4eca872 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig @@ -101,7 +101,7 @@ var request = requestStack[i]; var row = document.createElement('tr'); - rows.appendChild(row); + rows.insertBefore(row, rows.firstChild); var methodCell = document.createElement('td'); if (request.error) { From a5c881182f2c471dac9b9fbd8b6d52375c39672d Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 23 Jan 2016 17:38:15 +0100 Subject: [PATCH 070/226] sort bundles in config:dump-reference command This backports #17495 to the `2.3` branch. --- .../FrameworkBundle/Command/ConfigDumpReferenceCommand.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php index fa978b3ba9d1e..e116d83e88bb4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php @@ -66,6 +66,11 @@ protected function execute(InputInterface $input, OutputInterface $output) if (empty($name)) { $output->writeln('Available registered bundles with their extension alias if available:'); + + usort($bundles, function($bundleA, $bundleB) { + return strcmp($bundleA->getName(), $bundleB->getName()); + }); + foreach ($bundles as $bundle) { $extension = $bundle->getContainerExtension(); $output->writeln($bundle->getName().($extension ? ': '.$extension->getAlias() : '')); From 646fc9caaa998eee99bdf2f3e8f3d71ec2037f40 Mon Sep 17 00:00:00 2001 From: Evgeniy Sokolov Date: Mon, 9 Nov 2015 21:52:37 +0100 Subject: [PATCH 071/226] Ability to set empty version strategy in packages --- .../DependencyInjection/Configuration.php | 17 ++++++++++++++--- .../DependencyInjection/FrameworkExtension.php | 2 +- .../DependencyInjection/Fixtures/php/assets.php | 4 ++++ .../Fixtures/php/legacy_templating_assets.php | 4 ++++ .../DependencyInjection/Fixtures/xml/assets.xml | 3 +++ .../Fixtures/xml/legacy_templating_assets.xml | 3 +++ .../DependencyInjection/Fixtures/yml/assets.yml | 3 +++ .../Fixtures/yml/legacy_templating_assets.yml | 3 +++ .../FrameworkExtensionTest.php | 7 +++++-- 9 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index c14399c0c6504..936b9cf00dd8e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -99,7 +99,7 @@ public function getConfigTreeBuilder() foreach ($v['templating']['packages'] as $name => $config) { $v['assets']['packages'][$name] = array( - 'version' => (string) $config['version'], + 'version' => null === $config['version'] ? null : (string) $config['version'], 'version_format' => $config['version_format'], 'base_path' => '', 'base_urls' => array_values(array_unique(array_merge($config['base_urls']['http'], $config['base_urls']['ssl']))), @@ -488,7 +488,13 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode) ->prototype('array') ->fixXmlConfig('base_url') ->children() - ->scalarNode('version')->defaultNull()->end() + ->scalarNode('version') + ->defaultNull() + ->beforeNormalization() + ->ifTrue(function ($v) { return '' === $v; }) + ->then(function ($v) { return; }) + ->end() + ->end() ->scalarNode('version_format')->defaultValue('%%s?%%s')->end() ->arrayNode('base_urls') ->performNoDeepMerging() @@ -547,7 +553,12 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode) ->prototype('array') ->fixXmlConfig('base_url') ->children() - ->scalarNode('version')->defaultNull()->end() + ->scalarNode('version') + ->beforeNormalization() + ->ifTrue(function ($v) { return '' === $v; }) + ->then(function ($v) { return; }) + ->end() + ->end() ->scalarNode('version_format')->defaultNull()->end() ->scalarNode('base_path')->defaultValue('')->end() ->arrayNode('base_urls') diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 462a802a204fb..844bfa6f2669e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -589,7 +589,7 @@ private function registerAssetsConfiguration(array $config, ContainerBuilder $co $namedPackages = array(); foreach ($config['packages'] as $name => $package) { - if (null === $package['version']) { + if (!array_key_exists('version', $package)) { $version = $defaultVersion; } else { $format = $package['version_format'] ?: $config['version_format']; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets.php index e3532a7747cc6..1055251004bd9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets.php @@ -20,6 +20,10 @@ 'bar' => array( 'base_urls' => array('https://bar2.example.com'), ), + 'bar_null_version' => array( + 'version' => null, + 'base_urls' => array('https://bar3.example.com'), + ), ), ), )); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/legacy_templating_assets.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/legacy_templating_assets.php index 32bd56b3587d5..15df1015be15d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/legacy_templating_assets.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/legacy_templating_assets.php @@ -18,6 +18,10 @@ 'bar' => array( 'base_urls' => array('https://bar2.example.com'), ), + 'bar_null_version' => array( + 'version' => null, + 'base_urls' => array('https://bar3.example.com'), + ), ), ), )); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/assets.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/assets.xml index e39e15f900528..3e057d5b90254 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/assets.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/assets.xml @@ -18,6 +18,9 @@ https://bar2.example.com + + https://bar3.example.com + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/legacy_templating_assets.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/legacy_templating_assets.xml index 963848f767763..3b21e2cb4ed49 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/legacy_templating_assets.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/legacy_templating_assets.xml @@ -18,6 +18,9 @@ https://bar2.example.com + + https://bar3.example.com + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets.yml index 193dc59dfba3a..d3285ff58102c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets.yml @@ -14,3 +14,6 @@ framework: version_format: %%s-%%s bar: base_urls: ["https://bar2.example.com"] + bar_null_version: + version: null + base_urls: "https://bar3.example.com" diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/legacy_templating_assets.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/legacy_templating_assets.yml index e8cc6ce41d31c..f2c8ecfec6701 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/legacy_templating_assets.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/legacy_templating_assets.yml @@ -13,3 +13,6 @@ framework: version_format: %%s-%%s bar: base_urls: "https://bar2.example.com" + bar_null_version: + version: null + base_urls: "https://bar3.example.com" diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 3823cd6eab523..452ea55e21e37 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -511,7 +511,7 @@ private function checkAssetsPackages(ContainerBuilder $container, $legacy = fals // packages $packages = $packages->getArgument(1); - $this->assertCount($legacy ? 3 : 4, $packages); + $this->assertCount($legacy ? 4 : 5, $packages); if (!$legacy) { $package = $container->getDefinition($packages['images_path']); @@ -525,7 +525,10 @@ private function checkAssetsPackages(ContainerBuilder $container, $legacy = fals $this->assertPathPackage($container, $package, '', '1.0.0', '%%s-%%s'); $package = $container->getDefinition($packages['bar']); - $this->assertUrlPackage($container, $package, array('https://bar2.example.com'), $legacy ? '' : 'SomeVersionScheme', $legacy ? '%%s?%%s' : '%%s?version=%%s'); + $this->assertUrlPackage($container, $package, array('https://bar2.example.com'), $legacy ? null : 'SomeVersionScheme', $legacy ? '%%s?%%s' : '%%s?version=%%s'); + + $this->assertEquals($legacy ? 'assets.empty_version_strategy' : 'assets._version__default', (string) $container->getDefinition('assets._package_bar')->getArgument(1)); + $this->assertEquals('assets.empty_version_strategy', (string) $container->getDefinition('assets._package_bar_null_version')->getArgument(1)); } private function assertPathPackage(ContainerBuilder $container, DefinitionDecorator $package, $basePath, $version, $format) From 65adb7282c24cdd0b4695a82e6b3fb4bb7170877 Mon Sep 17 00:00:00 2001 From: Evgeniy Sokolov Date: Mon, 25 Jan 2016 01:05:43 +0100 Subject: [PATCH 072/226] add defaultNull to version --- .../Bundle/FrameworkBundle/DependencyInjection/Configuration.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 936b9cf00dd8e..909e1655570ae 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -554,6 +554,7 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode) ->fixXmlConfig('base_url') ->children() ->scalarNode('version') + ->defaultNull() ->beforeNormalization() ->ifTrue(function ($v) { return '' === $v; }) ->then(function ($v) { return; }) From fb729eecfa82979a9779a462a34ac8e30291f5f9 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 25 Jan 2016 08:27:56 +0100 Subject: [PATCH 073/226] fixed CS --- src/Symfony/Component/HttpFoundation/Response.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index 0318b9be63254..65d435ba5df19 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -976,12 +976,12 @@ public function isNotModified(Request $request) return $notModified; } - // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html - /** * Is response invalid? * * @return bool + * + * @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html */ public function isInvalid() { From cba206ab18b8705bf82d32f1c3a811cbd5f630ec Mon Sep 17 00:00:00 2001 From: Alex Bogomazov Date: Thu, 24 Dec 2015 01:45:26 +0300 Subject: [PATCH 074/226] [Finder] Check PHP version before applying a workaround for a PHP bug --- .../Finder/Iterator/FilterIterator.php | 22 ++++++++++--------- .../Iterator/RecursiveDirectoryIterator.php | 6 +++-- .../Component/Finder/Tests/FinderTest.php | 12 ++++++---- .../Tests/Iterator/FilterIteratorTest.php | 5 +++-- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/Symfony/Component/Finder/Iterator/FilterIterator.php b/src/Symfony/Component/Finder/Iterator/FilterIterator.php index f4da44c4cdd59..24adeb68f9040 100644 --- a/src/Symfony/Component/Finder/Iterator/FilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/FilterIterator.php @@ -12,9 +12,10 @@ namespace Symfony\Component\Finder\Iterator; /** - * This iterator just overrides the rewind method in order to correct a PHP bug. + * This iterator just overrides the rewind method in order to correct a PHP bug, + * which existed before version 5.5.23/5.6.7. * - * @see https://bugs.php.net/bug.php?id=49104 + * @see https://bugs.php.net/68557 * * @author Alex Bogomazov */ @@ -28,18 +29,19 @@ abstract class FilterIterator extends \FilterIterator */ public function rewind() { + if (PHP_VERSION_ID > 50607 || (PHP_VERSION_ID > 50523 && PHP_VERSION_ID < 50600)) { + parent::rewind(); + + return; + } + $iterator = $this; while ($iterator instanceof \OuterIterator) { $innerIterator = $iterator->getInnerIterator(); - if ($innerIterator instanceof RecursiveDirectoryIterator) { - if ($innerIterator->isRewindable()) { - $innerIterator->next(); - $innerIterator->rewind(); - } - } elseif ($iterator->getInnerIterator() instanceof \FilesystemIterator) { - $iterator->getInnerIterator()->next(); - $iterator->getInnerIterator()->rewind(); + if ($innerIterator instanceof \FilesystemIterator) { + $innerIterator->next(); + $innerIterator->rewind(); } $iterator = $iterator->getInnerIterator(); } diff --git a/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php b/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php index 3f65d69269756..402033a5c2816 100644 --- a/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php +++ b/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php @@ -118,8 +118,10 @@ public function rewind() return; } - // @see https://bugs.php.net/bug.php?id=49104 - parent::next(); + // @see https://bugs.php.net/68557 + if (PHP_VERSION_ID < 50523 || PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50607) { + parent::next(); + } parent::rewind(); } diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index cee8bd7530767..624d4547e519e 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -458,7 +458,7 @@ public function testNotContainsOnDirectory() * Searching in multiple locations involves AppendIterator which does an unnecessary rewind which leaves FilterIterator * with inner FilesystemIterator in an invalid state. * - * @see https://bugs.php.net/bug.php?id=49104 + * @see https://bugs.php.net/68557 */ public function testMultipleLocations() { @@ -468,8 +468,12 @@ public function testMultipleLocations() ); // it is expected that there are test.py test.php in the tmpDir - $finder = $this->buildFinder(); - $finder->in($locations)->depth('< 1')->name('test.php'); + $finder = new Finder(); + $finder->in($locations) + // the default flag IGNORE_DOT_FILES fixes the problem indirectly + // so we set it to false for better isolation + ->ignoreDotFiles(false) + ->depth('< 1')->name('test.php'); $this->assertCount(1, $finder); } @@ -479,7 +483,7 @@ public function testMultipleLocations() * AppendIterator which does an unnecessary rewind which leaves * FilterIterator with inner FilesystemIterator in an invalid state. * - * @see https://bugs.php.net/bug.php?id=49104 + * @see https://bugs.php.net/68557 */ public function testMultipleLocationsWithSubDirectories() { diff --git a/src/Symfony/Component/Finder/Tests/Iterator/FilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/FilterIteratorTest.php index 41e05a0a7b390..4f12d142e7f27 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/FilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/FilterIteratorTest.php @@ -43,8 +43,9 @@ public function testFilterFilesystemIterators() ++$c; } - // This would fail with \FilterIterator but works with Symfony\Component\Finder\Iterator\FilterIterator - // see https://bugs.php.net/bug.php?id=49104 + // This would fail in php older than 5.5.23/5.6.7 with \FilterIterator + // but works with Symfony\Component\Finder\Iterator\FilterIterator + // see https://bugs.php.net/68557 $this->assertEquals(1, $c); } } From f80e0eb143001d1d01998278d848e6ffcb548872 Mon Sep 17 00:00:00 2001 From: DZunke Date: Tue, 8 Dec 2015 09:03:22 +0100 Subject: [PATCH 075/226] [Form] Fix constraints could be null if not set --- .../Extension/Validator/Constraints/FormValidator.php | 2 +- .../Validator/Constraints/FormValidatorTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php index f862970a7fd81..5792aa40828c7 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php +++ b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php @@ -45,7 +45,7 @@ public function validate($form, Constraint $constraint) // Validate the data against the constraints defined // in the form - $constraints = $config->getOption('constraints'); + $constraints = $config->getOption('constraints', array()); foreach ($constraints as $constraint) { foreach ($groups as $group) { if (in_array($group, $constraint->groups)) { diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php index c440a0470abbe..1e30f237a5632 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php @@ -123,6 +123,17 @@ public function testDontValidateIfParentWithoutCascadeValidation() $this->assertNoViolation(); } + public function testNotExistingConstraintIndex() + { + $object = new \stdClass(); + $form = new FormBuilder('name', '\stdClass', $this->dispatcher, $this->factory); + $form = $form->setData($object)->getForm(); + + $this->validator->validate($form, new Form()); + + $this->assertNoViolation(); + } + public function testValidateConstraintsEvenIfNoCascadeValidation() { $object = $this->getMock('\stdClass'); From 898f3890ffadae149e0de04dbfdbed52f666738a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 25 Jan 2016 09:20:12 +0100 Subject: [PATCH 076/226] fixed typo --- .../Tests/Extension/Validator/Constraints/FormValidatorTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php index 1e30f237a5632..ca34a936dc84e 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php @@ -123,7 +123,7 @@ public function testDontValidateIfParentWithoutCascadeValidation() $this->assertNoViolation(); } - public function testNotExistingConstraintIndex() + public function testMissingConstraintIndex() { $object = new \stdClass(); $form = new FormBuilder('name', '\stdClass', $this->dispatcher, $this->factory); From 3dae8257f2f309b89e06aec3f4f6d52493f2add2 Mon Sep 17 00:00:00 2001 From: zorn Date: Mon, 7 Dec 2015 13:23:40 +1000 Subject: [PATCH 077/226] Able to load big xml files with DomCrawler --- src/Symfony/Component/DomCrawler/Crawler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 9dd3daa503bbe..a51463dd0fd84 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -230,7 +230,7 @@ public function addXmlContent($content, $charset = 'UTF-8') if ('' !== trim($content)) { // remove the default namespace to make XPath expressions simpler - @$dom->loadXML(str_replace('xmlns', 'ns', $content), LIBXML_NONET); + @$dom->loadXML(str_replace('xmlns', 'ns', $content), LIBXML_NONET | (defined('LIBXML_PARSEHUGE') ? LIBXML_PARSEHUGE : 0)); } libxml_use_internal_errors($internalErrors); From 156cdb5ab0b393ce5516dae438d8274a740b3ce2 Mon Sep 17 00:00:00 2001 From: FlorianLB Date: Sat, 5 Dec 2015 11:52:14 +0100 Subject: [PATCH 078/226] [TwigBridge] add missing unit tests (AppVariable) --- .../Bridge/Twig/Tests/AppVariableTest.php | 150 ++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 src/Symfony/Bridge/Twig/Tests/AppVariableTest.php diff --git a/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php b/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php new file mode 100644 index 0000000000000..c82d892557cf7 --- /dev/null +++ b/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php @@ -0,0 +1,150 @@ +appVariable = new AppVariable(); + } + + /** + * @dataProvider debugDataProvider + */ + public function testDebug($debugFlag) + { + $this->appVariable->setDebug($debugFlag); + + $this->assertEquals($debugFlag, $this->appVariable->getDebug()); + } + + public function debugDataProvider() + { + return array( + 'debug on' => array(true), + 'debug off' => array(false), + ); + } + + public function testEnvironment() + { + $this->appVariable->setEnvironment('dev'); + + $this->assertEquals('dev', $this->appVariable->getEnvironment()); + } + + public function testGetSession() + { + $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + $request->method('getSession')->willReturn($session = new Session()); + + $this->setRequestStack($request); + + $this->assertEquals($session, $this->appVariable->getSession()); + } + + public function testGetSessionWithNoRequest() + { + $this->setRequestStack(null); + + $this->assertNull($this->appVariable->getSession()); + } + + public function testGetRequest() + { + $this->setRequestStack($request = new Request()); + + $this->assertEquals($request, $this->appVariable->getRequest()); + } + + public function testGetUser() + { + $this->setTokenStorage($user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface')); + + $this->assertEquals($user, $this->appVariable->getUser()); + } + + public function testGetUserWithUsernameAsTokenUser() + { + $this->setTokenStorage($user = 'username'); + + $this->assertNull($this->appVariable->getUser()); + } + + public function testGetUserWithNoToken() + { + $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $this->appVariable->setTokenStorage($tokenStorage); + + $this->assertNull($this->appVariable->getUser()); + } + + /** + * @expectedException \RuntimeException + */ + public function testEnvironmentNotSet() + { + $this->appVariable->getEnvironment(); + } + + /** + * @expectedException \RuntimeException + */ + public function testDebugNotSet() + { + $this->appVariable->getDebug(); + } + + /** + * @expectedException \RuntimeException + */ + public function testGetUserWithTokenStorageNotSet() + { + $this->appVariable->getUser(); + } + + /** + * @expectedException \RuntimeException + */ + public function testGetRequestWithRequestStackNotSet() + { + $this->appVariable->getRequest(); + } + + /** + * @expectedException \RuntimeException + */ + public function testGetSessionWithRequestStackNotSet() + { + $this->appVariable->getSession(); + } + + protected function setRequestStack($request) + { + $requestStackMock = $this->getMock('Symfony\Component\HttpFoundation\RequestStack'); + $requestStackMock->method('getCurrentRequest')->willReturn($request); + + $this->appVariable->setRequestStack($requestStackMock); + } + + protected function setTokenStorage($user) + { + $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); + $this->appVariable->setTokenStorage($tokenStorage); + + $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $tokenStorage->method('getToken')->willReturn($token); + + $token->method('getUser')->willReturn($user); + } +} From 884368e7095073ced91be29a91571415ab65ff62 Mon Sep 17 00:00:00 2001 From: Stepan Anchugov Date: Fri, 22 Jan 2016 04:44:07 +0500 Subject: [PATCH 079/226] Throw for missing container extensions This covers cases when a bundle does not have an extension, which lead to FatalErrorException with ```Call to a member function getAlias() on null``` --- .../Bundle/FrameworkBundle/Command/AbstractConfigCommand.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php index 711934c73ab36..d1e0f9c771308 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AbstractConfigCommand.php @@ -57,6 +57,10 @@ protected function findExtension($name) $bundles = $this->initializeBundles(); foreach ($bundles as $bundle) { if ($name === $bundle->getName()) { + if (!$bundle->getContainerExtension()) { + throw new \LogicException(sprintf('Bundle "%s" does not have a container extension.', $name)); + } + return $bundle->getContainerExtension(); } From 233e5b8df7481a32742f7f3175e0d14dab30857f Mon Sep 17 00:00:00 2001 From: Christian Schmidt Date: Wed, 20 Jan 2016 17:27:56 +0100 Subject: [PATCH 080/226] [EventDispatcher] TraceableEventDispatcher resets listener priorities --- .../Debug/TraceableEventDispatcher.php | 7 +++--- .../Debug/TraceableEventDispatcherTest.php | 23 ++++++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php index 35df8162b1731..75ba2a760f45a 100644 --- a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php @@ -235,12 +235,12 @@ protected function postDispatch($eventName, Event $event) private function preProcess($eventName) { foreach ($this->dispatcher->getListeners($eventName) as $listener) { - $this->dispatcher->removeListener($eventName, $listener); $info = $this->getListenerInfo($listener, $eventName); $name = isset($info['class']) ? $info['class'] : $info['type']; $wrappedListener = new WrappedListener($listener, $name, $this->stopwatch, $this); $this->wrappedListeners[$eventName][] = $wrappedListener; - $this->dispatcher->addListener($eventName, $wrappedListener); + $this->dispatcher->removeListener($eventName, $listener); + $this->dispatcher->addListener($eventName, $wrappedListener, $info['priority']); } } @@ -253,8 +253,9 @@ private function postProcess($eventName) continue; } // Unwrap listener + $priority = $this->getListenerPriority($eventName, $listener); $this->dispatcher->removeListener($eventName, $listener); - $this->dispatcher->addListener($eventName, $listener->getWrappedListener()); + $this->dispatcher->addListener($eventName, $listener->getWrappedListener(), $priority); $info = $this->getListenerInfo($listener->getWrappedListener(), $eventName); if ($listener->wasCalled()) { diff --git a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php index 1d4a8c8506f8e..2dd8292a1b3e6 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php @@ -56,6 +56,23 @@ public function testHasListeners() $this->assertTrue($tdispatcher->hasListeners('foo')); } + public function testGetListenerPriority() + { + $dispatcher = new EventDispatcher(); + $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); + + $tdispatcher->addListener('foo', function () {}, 123); + + $listeners = $dispatcher->getListeners('foo'); + $this->assertSame(123, $tdispatcher->getListenerPriority('foo', $listeners[0])); + + // Verify that priority is preserved when listener is removed and re-added + // in preProcess() and postProcess(). + $tdispatcher->dispatch('foo', new Event()); + $listeners = $dispatcher->getListeners('foo'); + $this->assertSame(123, $tdispatcher->getListenerPriority('foo', $listeners[0])); + } + public function testAddRemoveSubscriber() { $dispatcher = new EventDispatcher(); @@ -138,12 +155,12 @@ public function testDispatchCallListeners() $dispatcher = new EventDispatcher(); $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); - $tdispatcher->addListener('foo', $listener1 = function () use (&$called) { $called[] = 'foo1'; }); - $tdispatcher->addListener('foo', $listener2 = function () use (&$called) { $called[] = 'foo2'; }); + $tdispatcher->addListener('foo', function () use (&$called) { $called[] = 'foo1'; }, 10); + $tdispatcher->addListener('foo', function () use (&$called) { $called[] = 'foo2'; }, 20); $tdispatcher->dispatch('foo'); - $this->assertEquals(array('foo1', 'foo2'), $called); + $this->assertSame(array('foo2', 'foo1'), $called); } public function testDispatchNested() From 6578806fc3417675bd991362e7c1f05abdd1cb97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Sun, 29 Nov 2015 00:02:58 +0100 Subject: [PATCH 081/226] [Request] Ignore invalid IP addresses sent by proxies Fixes symfony/symfony#15525 --- src/Symfony/Component/HttpFoundation/Request.php | 14 +++++++++++--- .../Component/HttpFoundation/Tests/RequestTest.php | 3 +++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index d2af44626cdcb..72bd9f114367a 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -769,8 +769,7 @@ public function getClientIps() $clientIps = array_map('trim', explode(',', $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_IP]))); $clientIps[] = $ip; // Complete the IP chain with the IP the request actually came from - - $ip = $clientIps[0]; // Fallback to this when the client IP falls into the range of trusted proxies + $firstTrustedIp = null; // Eliminate all IPs from the forwarded IP chain which are trusted proxies foreach ($clientIps as $key => $clientIp) { @@ -779,13 +778,22 @@ public function getClientIps() $clientIps[$key] = $clientIp = $match[1]; } + if (!filter_var($clientIp, FILTER_VALIDATE_IP)) { + unset($clientIps[$key]); + } + if (IpUtils::checkIp($clientIp, self::$trustedProxies)) { unset($clientIps[$key]); + + // Fallback to this when the client IP falls into the range of trusted proxies + if (null === $firstTrustedIp) { + $firstTrustedIp = $clientIp; + } } } // Now the IP chain contains only untrusted proxies and the client IP - return $clientIps ? array_reverse($clientIps) : array($ip); + return $clientIps ? array_reverse($clientIps) : array($firstTrustedIp); } /** diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index e17953819bde2..d601204231e98 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -863,6 +863,9 @@ public function testGetClientIpsProvider() // client IP with port array(array('88.88.88.88'), '127.0.0.1', '88.88.88.88:12345, 127.0.0.1', array('127.0.0.1')), + + // invalid forwarded IP is ignored + array(array('88.88.88.88'), '127.0.0.1', 'unknown,88.88.88.88', array('127.0.0.1')), ); } From 0fe08a800e8fbcb65e899de54f7c3186df72d109 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 25 Jan 2016 10:56:38 +0100 Subject: [PATCH 082/226] fixed test --- src/Symfony/Component/HttpFoundation/Tests/RequestTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index 9ddaa6b4c0811..458cd88b7eb1e 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -853,7 +853,7 @@ public function testGetClientIpsForwardedProvider() // $expected $remoteAddr $httpForwarded $trustedProxies return array( array(array('127.0.0.1'), '127.0.0.1', 'for="_gazonk"', null), - array(array('_gazonk'), '127.0.0.1', 'for="_gazonk"', array('127.0.0.1')), + array(array('127.0.0.1'), '127.0.0.1', 'for="_gazonk"', array('127.0.0.1')), array(array('88.88.88.88'), '127.0.0.1', 'for="88.88.88.88:80"', array('127.0.0.1')), array(array('192.0.2.60'), '::1', 'for=192.0.2.60;proto=http;by=203.0.113.43', array('::1')), array(array('2620:0:1cfe:face:b00c::3', '192.0.2.43'), '::1', 'for=192.0.2.43, for=2620:0:1cfe:face:b00c::3', array('::1')), From df8952f2a35cdf1fcaaf2329aa37716106416c66 Mon Sep 17 00:00:00 2001 From: Andrew Carter Date: Mon, 21 Dec 2015 16:05:25 +0000 Subject: [PATCH 083/226] Added 451 status code --- src/Symfony/Component/HttpFoundation/Response.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index 65d435ba5df19..c65ceb716393e 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -109,6 +109,7 @@ class Response 428 => 'Precondition Required', // RFC6585 429 => 'Too Many Requests', // RFC6585 431 => 'Request Header Fields Too Large', // RFC6585 + 451 => 'Unavailable For Legal Reasons', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', From 1ec3e51444ef4db31ebfca829b98e680feaa6ee4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 25 Jan 2016 12:39:25 +0100 Subject: [PATCH 084/226] added missing constant --- src/Symfony/Component/HttpFoundation/Response.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index 9fd6f6c48a9b7..9844775ee2055 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -67,6 +67,7 @@ class Response const HTTP_PRECONDITION_REQUIRED = 428; // RFC6585 const HTTP_TOO_MANY_REQUESTS = 429; // RFC6585 const HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431; // RFC6585 + const HTTP_UNAVAILABLE_FOR_LEGAL_REASONS = 451; const HTTP_INTERNAL_SERVER_ERROR = 500; const HTTP_NOT_IMPLEMENTED = 501; const HTTP_BAD_GATEWAY = 502; From 1f5f81cf1124d6ddd7da531d66edbcc6be38e5e8 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 11 Jan 2016 11:52:51 +0100 Subject: [PATCH 085/226] Limit the max height/width of icons in the profiler menu --- .../Resources/views/Profiler/profiler.css.twig | 5 +++++ .../Resources/views/Profiler/toolbar.css.twig | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig index b61f1c4204401..77db944870255 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig @@ -619,6 +619,11 @@ tr.status-warning td { width: 50px; text-align: center; } +#menu-profiler .label .icon img, +#menu-profiler .label .icon svg { + height: 24px; + max-width: 24px; +} #menu-profiler li a .label .icon svg path { fill: #DDD; } 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 893701359401b..3d38265408a28 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig @@ -50,8 +50,7 @@ } .sf-toolbarreset svg, .sf-toolbarreset img { - max-height: 20px; - max-width: 20px; + height: 20px; } .sf-toolbarreset .hide-button { From 5c2d534a1f04c738d50af2b3c4d275b05e39cdae Mon Sep 17 00:00:00 2001 From: Xavier Coureau Date: Wed, 13 Jan 2016 18:25:42 +0100 Subject: [PATCH 086/226] [DoctrineBridge][Validator] >= 2.3 Pass association instead of ID as argument --- .../Constraints/UniqueEntityValidatorTest.php | 26 +------------------ .../Constraints/UniqueEntityValidator.php | 11 -------- 2 files changed, 1 insertion(+), 36 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php index f5c37e6787ab4..7c061d7ac286b 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php @@ -16,7 +16,6 @@ use Doctrine\Common\Persistence\ObjectManager; use Doctrine\Common\Persistence\ObjectRepository; use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper; -use Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity; use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest; use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity; @@ -398,7 +397,7 @@ public function testAssociatedEntity() $this->buildViolation('myMessage') ->atPath('property.path.single') - ->setInvalidValue(1) + ->setInvalidValue($entity1) ->assertRaised(); } @@ -422,29 +421,6 @@ public function testAssociatedEntityWithNull() $this->assertNoViolation(); } - /** - * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException - * @expectedExceptionMessage Associated entities are not allowed to have more than one identifier field - */ - public function testAssociatedCompositeEntity() - { - $constraint = new UniqueEntity(array( - 'message' => 'myMessage', - 'fields' => array('composite'), - 'em' => self::EM_NAME, - )); - - $composite = new CompositeIntIdEntity(1, 1, 'test'); - $associated = new AssociationEntity(); - $associated->composite = $composite; - - $this->em->persist($composite); - $this->em->persist($associated); - $this->em->flush(); - - $this->validator->validate($associated, $constraint); - } - /** * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException * @expectedExceptionMessage Object manager "foo" does not exist. diff --git a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php index 2ee3f1da2e737..5ae077dc9f20f 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php +++ b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php @@ -92,17 +92,6 @@ public function validate($entity, Constraint $constraint) * getter methods in the Proxy are being bypassed. */ $em->initializeObject($criteria[$fieldName]); - - $relatedClass = $em->getClassMetadata($class->getAssociationTargetClass($fieldName)); - $relatedId = $relatedClass->getIdentifierValues($criteria[$fieldName]); - - if (count($relatedId) > 1) { - throw new ConstraintDefinitionException( - 'Associated entities are not allowed to have more than one identifier field to be '. - 'part of a unique constraint in: '.$class->getName().'#'.$fieldName - ); - } - $criteria[$fieldName] = array_pop($relatedId); } } From 209d08fe2db9c91d86146775f755e0e78e955dc9 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 25 Jan 2016 12:59:24 +0100 Subject: [PATCH 087/226] fixed CS --- .../FrameworkBundle/Command/TranslationUpdateCommand.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index 6ebbbf4821e10..04e62890b171e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -150,7 +150,7 @@ protected function execute(InputInterface $input, OutputInterface $output) return; } - $resultMessage = 'Translation files were successfully updated.'; + $resultMessage = 'Translation files were successfully updated'; // show compiled list of messages if (true === $input->getOption('dump-messages')) { @@ -206,10 +206,10 @@ protected function execute(InputInterface $input, OutputInterface $output) $writer->writeTranslations($operation->getResult(), $input->getOption('output-format'), array('path' => $bundleTransPath, 'default_locale' => $this->getContainer()->getParameter('kernel.default_locale'))); if (true === $input->getOption('dump-messages')) { - $resultMessage .= ' and translation files were updated.'; + $resultMessage .= ' and translation files were updated'; } } - $io->success($resultMessage); + $io->success($resultMessage.'.'); } } From 3188e1b5d2c5ae3be34143b4bcd8e1b3e8a20a32 Mon Sep 17 00:00:00 2001 From: Ivan Kurnosov Date: Mon, 7 Sep 2015 19:21:10 +1200 Subject: [PATCH 088/226] Added support for the `0.0.0.0/0` trusted proxy --- .../FrameworkBundle/DependencyInjection/Configuration.php | 4 ++++ .../Tests/DependencyInjection/ConfigurationTest.php | 1 + 2 files changed, 5 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 5126d27afaa1f..c7086f72c45c3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -52,6 +52,10 @@ public function getConfigTreeBuilder() } if (false !== strpos($v, '/')) { + if ('0.0.0.0/0' === $v) { + return false; + } + list($v, $mask) = explode('/', $v, 2); if (strcmp($mask, (int) $mask) || $mask < 1 || $mask > (false !== strpos($v, ':') ? 128 : 32)) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php index fba0fb2ab32aa..61eea7a0d0fd5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -66,6 +66,7 @@ public function getTestValidTrustedProxiesData() array(array(), array()), array(array('10.0.0.0/8'), array('10.0.0.0/8')), array(array('::ffff:0:0/96'), array('::ffff:0:0/96')), + array(array('0.0.0.0/0'), array('0.0.0.0/0')), ); } From 24160b3a2faa0f8bf4defc7ff8d17cda9dfb6004 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Mon, 25 Jan 2016 14:16:04 +0100 Subject: [PATCH 089/226] make apc class loader testable against apcu without apc bc layer --- .../Component/ClassLoader/Tests/ApcClassLoaderTest.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Symfony/Component/ClassLoader/Tests/ApcClassLoaderTest.php b/src/Symfony/Component/ClassLoader/Tests/ApcClassLoaderTest.php index 77257bc310a04..e96ba954087c0 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ApcClassLoaderTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ApcClassLoaderTest.php @@ -14,15 +14,12 @@ use Symfony\Component\ClassLoader\ApcClassLoader; use Symfony\Component\ClassLoader\ClassLoader; -/** - * @requires extension apc - */ class ApcClassLoaderTest extends \PHPUnit_Framework_TestCase { protected function setUp() { if (!(ini_get('apc.enabled') && ini_get('apc.enable_cli'))) { - $this->markTestSkipped('The apc extension is available, but not enabled.'); + $this->markTestSkipped('The apc extension is not enabled.'); } else { apcu_clear_cache(); } From 3b7f4c7050ce3fef04916fe36c264dcb81628a3b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 25 Jan 2016 15:43:10 +0100 Subject: [PATCH 090/226] fixed APCu dep version --- composer.json | 2 +- src/Symfony/Component/ClassLoader/composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 0cd67a4c0930d..f280ff8851133 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "php": ">=5.3.3", "doctrine/common": "~2.4", "paragonie/random_compat": "~1.0", - "symfony/polyfill-apcu": "~1.0,>=1.0.2", + "symfony/polyfill-apcu": "~1.1", "twig/twig": "~1.23|~2.0", "psr/log": "~1.0" }, diff --git a/src/Symfony/Component/ClassLoader/composer.json b/src/Symfony/Component/ClassLoader/composer.json index 86bb70a6d717e..ee9a834b82b13 100644 --- a/src/Symfony/Component/ClassLoader/composer.json +++ b/src/Symfony/Component/ClassLoader/composer.json @@ -18,7 +18,7 @@ "minimum-stability": "dev", "require": { "php": ">=5.3.3", - "symfony/polyfill-apcu": "~1.0,>=1.0.2" + "symfony/polyfill-apcu": "~1.1" }, "require-dev": { "symfony/finder": "~2.0,>=2.0.5" From 8e2a33ec2dbb2816a75b27cdacd9358ecc9cdd2c Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 25 Jan 2016 16:23:13 +0100 Subject: [PATCH 091/226] Fixed the phpDoc of UserInterface --- src/Symfony/Component/Security/Core/User/UserInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Core/User/UserInterface.php b/src/Symfony/Component/Security/Core/User/UserInterface.php index 1b52dab9965fe..747884282dcaa 100644 --- a/src/Symfony/Component/Security/Core/User/UserInterface.php +++ b/src/Symfony/Component/Security/Core/User/UserInterface.php @@ -47,7 +47,7 @@ interface UserInterface * and populated in any number of different ways when the user object * is created. * - * @return Role[] The user roles + * @return (Role|string)[] The user roles */ public function getRoles(); From 4b21351f363f344ecec96f2cca402634faecee39 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 25 Jan 2016 17:19:48 +0100 Subject: [PATCH 092/226] fixed undefined variable --- .../Resources/views/Profiler/toolbar_item.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_item.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_item.html.twig index 42bbfea5769b7..974fe4b29d297 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_item.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_item.html.twig @@ -1,4 +1,4 @@ -{% if link %} +{% if link|default(true) %} {% set icon %} {{ icon }} {% endset %} From 2c45f461c2a479cbd87a7f5309563c3a318591e0 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 25 Jan 2016 16:50:29 +0100 Subject: [PATCH 093/226] Escape the delimiter in Glob::toRegex --- src/Symfony/Component/Finder/Glob.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Finder/Glob.php b/src/Symfony/Component/Finder/Glob.php index fedcc5e708ece..fa64f50470c0f 100644 --- a/src/Symfony/Component/Finder/Glob.php +++ b/src/Symfony/Component/Finder/Glob.php @@ -65,7 +65,7 @@ public static function toRegex($glob, $strictLeadingDot = true, $strictWildcardS $firstByte = true; } - if ('.' === $car || '(' === $car || ')' === $car || '|' === $car || '+' === $car || '^' === $car || '$' === $car) { + if ($delimiter === $car || '.' === $car || '(' === $car || ')' === $car || '|' === $car || '+' === $car || '^' === $car || '$' === $car) { $regex .= "\\$car"; } elseif ('*' === $car) { $regex .= $escaping ? '\\*' : ($strictWildcardSlash ? '[^/]*' : '.*'); From 193d5c8dd59fbda6bf254bf1016bef20520a7db9 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 25 Jan 2016 17:36:36 +0100 Subject: [PATCH 094/226] added a test --- src/Symfony/Component/Finder/Tests/GlobTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/Finder/Tests/GlobTest.php b/src/Symfony/Component/Finder/Tests/GlobTest.php index 60884a7a2ecdd..dd73e257ba826 100755 --- a/src/Symfony/Component/Finder/Tests/GlobTest.php +++ b/src/Symfony/Component/Finder/Tests/GlobTest.php @@ -17,6 +17,7 @@ class GlobTest extends \PHPUnit_Framework_TestCase { public function testGlobToRegexDelimiters() { + $this->assertEquals('#^(?=[^\.])\#$#', Glob::toRegex('#')); $this->assertEquals('#^\.[^/]*$#', Glob::toRegex('.*')); $this->assertEquals('^\.[^/]*$', Glob::toRegex('.*', true, true, '')); $this->assertEquals('/^\.[^/]*$/', Glob::toRegex('.*', true, true, '/')); From 5e805850ccb377107b3f14929ce121b9774c5438 Mon Sep 17 00:00:00 2001 From: Tischoi Date: Wed, 25 Jun 2014 22:19:01 +0200 Subject: [PATCH 095/226] Update AnnotationDirectoryLoader.php --- .../Component/Routing/Loader/AnnotationDirectoryLoader.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php index abd68ed6c4fab..f6b99a16ae8b2 100644 --- a/src/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php +++ b/src/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php @@ -66,12 +66,16 @@ public function load($path, $type = null) */ public function supports($resource, $type = null) { + if (!is_string($resource)) { + return false; + } + try { $path = $this->locator->locate($resource); } catch (\Exception $e) { return false; } - return is_string($resource) && is_dir($path) && (!$type || 'annotation' === $type); + return is_dir($path) && (!$type || 'annotation' === $type); } } From 8db691ab94777b46711a11dfcebe46025bdeef5b Mon Sep 17 00:00:00 2001 From: "Konstantin.Myakshin" Date: Mon, 25 Jan 2016 19:00:36 +0200 Subject: [PATCH 096/226] Static code analysis --- .../AbstractDoctrineExtension.php | 2 +- .../CompilerPass/DoctrineValidationPass.php | 2 +- .../Command/TranslationUpdateCommand.php | 6 ++--- .../Resources/public/css/body.css | 2 +- .../DependencyInjection/TwigExtension.php | 2 +- .../Resources/views/Profiler/body.css.twig | 2 +- .../Resources/views/Profiler/layout.html.twig | 2 +- .../views/Profiler/profiler.css.twig | 12 ++++----- .../Resources/views/Profiler/toolbar.css.twig | 10 +++---- .../Controller/ProfilerControllerTest.php | 2 -- .../Tests/XPath/TranslatorTest.php | 2 +- .../Tests/Fixtures/containers/interfaces1.php | 12 --------- .../ContainerAwareEventDispatcherTest.php | 26 +++++++++++++++++-- .../Finder/Adapter/AbstractFindAdapter.php | 2 +- .../Form/Extension/Core/Type/ChoiceType.php | 4 +-- .../Constraints/FormValidatorTest.php | 5 ---- .../Type/BaseValidatorExtensionTest.php | 2 +- .../Form/Tests/Util/OrderedHashMapTest.php | 2 +- .../Component/HttpFoundation/Request.php | 2 -- .../Storage/Handler/PdoSessionHandlerTest.php | 2 +- .../HttpKernel/HttpCache/HttpCache.php | 4 +-- .../Profiler/SqliteProfilerStorage.php | 2 +- .../Data/Generator/CurrencyDataGenerator.php | 2 -- .../Data/Generator/LanguageDataGenerator.php | 3 --- .../Intl/Data/Util/LocaleScanner.php | 2 +- .../Intl/DateFormatter/IntlDateFormatter.php | 3 +-- .../Intl/NumberFormatter/NumberFormatter.php | 4 +-- .../Bundle/Reader/IntlBundleReaderTest.php | 1 - .../Bundle/Writer/JsonBundleWriterTest.php | 1 - .../Bundle/Writer/PhpBundleWriterTest.php | 1 - .../Tests/Data/Util/LocaleScannerTest.php | 4 +-- .../Tests/PropertyAccessorTest.php | 2 +- .../Tests/Generator/UrlGeneratorTest.php | 3 +-- .../Security/Acl/Dbal/MutableAclProvider.php | 2 +- .../Http/Firewall/RememberMeListenerTest.php | 2 +- .../TokenBasedRememberMeServicesTest.php | 3 +-- .../Normalizer/GetSetMethodNormalizerTest.php | 1 - .../Translation/Dumper/PhpFileDumper.php | 4 +-- .../Component/Yaml/Tests/InlineTest.php | 1 - 39 files changed, 63 insertions(+), 83 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php index b3b0d60778825..442903c3dfeaa 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php @@ -153,7 +153,7 @@ protected function setMappingDriverConfig(array $mappingConfig, $mappingName) */ protected function getMappingDriverBundleConfigDefaults(array $bundleConfig, \ReflectionClass $bundle, ContainerBuilder $container) { - $bundleDir = dirname($bundle->getFilename()); + $bundleDir = dirname($bundle->getFileName()); if (!$bundleConfig['type']) { $bundleConfig['type'] = $this->detectMetadataDriver($bundleDir, $container); diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/DoctrineValidationPass.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/DoctrineValidationPass.php index de35c55219f2e..96f05eb5b60c9 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/DoctrineValidationPass.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/DoctrineValidationPass.php @@ -60,7 +60,7 @@ private function updateValidatorMappingFiles(ContainerBuilder $container, $mappi foreach ($container->getParameter('kernel.bundles') as $bundle) { $reflection = new \ReflectionClass($bundle); - if (is_file($file = dirname($reflection->getFilename()).'/'.$validationPath)) { + if (is_file($file = dirname($reflection->getFileName()).'/'.$validationPath)) { $files[] = realpath($file); $container->addResource(new FileResource($file)); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index 5bdc2f86e6e41..54f65588d26dd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -95,7 +95,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $extractor = $this->getContainer()->get('translation.extractor'); $extractor->setPrefix($input->getOption('prefix')); foreach ($bundleTransPaths as $path) { - $path = $path.'views'; + $path .= 'views'; if (is_dir($path)) { $extractor->extract($path, $extractedCatalogue); } @@ -106,7 +106,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln('Loading translation files'); $loader = $this->getContainer()->get('translation.loader'); foreach ($bundleTransPaths as $path) { - $path = $path.'translations'; + $path .= 'translations'; if (is_dir($path)) { $loader->loadMessages($path, $currentCatalogue); } @@ -151,7 +151,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln('Writing files'); $bundleTransPath = false; foreach ($bundleTransPaths as $path) { - $path = $path.'translations'; + $path .= 'translations'; if (is_dir($path)) { $bundleTransPath = $path; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/public/css/body.css b/src/Symfony/Bundle/FrameworkBundle/Resources/public/css/body.css index 6b81755056337..c50c1a54c7868 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/public/css/body.css +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/public/css/body.css @@ -117,7 +117,7 @@ build: 56 background: transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAcCAYAAACtQ6WLAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAR1JREFUeNpiPHnyZCMDA8MNID5gZmb2nAEJMH7//v3N169fX969e/cYkL8WqGAHXPLv37//QYzfv39/fvPmzbUnT56sAXInmJub/2H5/x8sx8DCwsIrISFhDmQyPX78+CmQXs70798/BmQsKipqBNTgdvz4cWkmkE5kDATMioqKZkCFdiwg1eiAi4tLGqhQF24nMmBmZuYEigth1QkEbEBxTlySYPvJkwSJ00AnjYylgU6gxB8g/oFVEphkvgLF32KNMmCCewYUv4qhEyj47+HDhyeBzIMYOoEp8CxQw56wsLAncJ1//vz5/P79+2svX74EJc2V4BT58+fPd8CE/QKYHMGJOiIiAp6oWW7evDkNSF8DZYfIyEiU7AAQYACJ2vxVdJW4eQAAAABJRU5ErkJggg==) right top no-repeat; } .sf-button .btn-bg { - padding: 0px 14px; + padding: 0 14px; color: #636363; line-height: 28px; background: transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAcCAYAAACgXdXMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAClJREFUeNpiPnny5EKGf//+/Wf6//8/A4QAcrGzKCZwGc9sa2urBBBgAIbDUoYVp9lmAAAAAElFTkSuQmCC) repeat-x top left; diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php index 9b6f806f04913..f29d8a87427fd 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php @@ -75,7 +75,7 @@ public function load(array $configs, ContainerBuilder $container) } $reflection = new \ReflectionClass($class); - if (is_dir($dir = dirname($reflection->getFilename()).'/Resources/views')) { + if (is_dir($dir = dirname($reflection->getFileName()).'/Resources/views')) { $this->addTwigPath($twigFilesystemLoaderDefinition, $dir, $bundle); } } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/body.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/body.css.twig index fa4d076917434..8373e44d0ac8d 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/body.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/body.css.twig @@ -116,7 +116,7 @@ build: 56 background: transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAcCAYAAACtQ6WLAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAR1JREFUeNpiPHnyZCMDA8MNID5gZmb2nAEJMH7//v3N169fX969e/cYkL8WqGAHXPLv37//QYzfv39/fvPmzbUnT56sAXInmJub/2H5/x8sx8DCwsIrISFhDmQyPX78+CmQXs70798/BmQsKipqBNTgdvz4cWkmkE5kDATMioqKZkCFdiwg1eiAi4tLGqhQF24nMmBmZuYEigth1QkEbEBxTlySYPvJkwSJ00AnjYylgU6gxB8g/oFVEphkvgLF32KNMmCCewYUv4qhEyj47+HDhyeBzIMYOoEp8CxQw56wsLAncJ1//vz5/P79+2svX74EJc2V4BT58+fPd8CE/QKYHMGJOiIiAp6oWW7evDkNSF8DZYfIyEiU7AAQYACJ2vxVdJW4eQAAAABJRU5ErkJggg==) right top no-repeat; } .sf-button .btn-bg { - padding: 0px 14px; + padding: 0 14px; color: #636363; line-height: 28px; background: transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAcCAYAAACgXdXMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAClJREFUeNpiPnny5EKGf//+/Wf6//8/A4QAcrGzKCZwGc9sa2urBBBgAIbDUoYVp9lmAAAAAElFTkSuQmCC) repeat-x top left; diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig index e8c0900952539..6335bcd5e6cc5 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig @@ -66,7 +66,7 @@ var leftIconPath = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAhCAYAAADOHBvaAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA4tJREFUeNrkl19IU1Ecx7fZJN2arhq2JUWJlEZL1MAm1B582GBErMJqtabzRRAqFAYa9OfFFx+KQEG3MkYRZkkEJUUwctVSKCJWJojL1ZiydJvLtNXW98AW1znv7t0CHzrw5Xe3nXM/O/f8zvf8LjcajXJWo/E4q9T+P/CaNMZw29rahBMTE3LyoaKi4m1zc/M865swSS6bzZbT09NzfG5urjYUCikikYiQ+ntWVlZQKBQ+F4lE/Var9Ta+CmcK5hsMhpNer/fiwsLCFiYzycnJGZfJZOctFss9uj+wInhwcDDfbDb3+Hy+I+msoVQqNZtMpnNlZWUhxuChoaENHR0djwOBwN5MEkgsFtsGBgY0uPzOJKtzu7q6rmcKJW12dlaJpbqGy7WpwPyWlpZGj8dzkMX9B+l+dLlcda2trbrEHbQEPDY2Jh0dHTWxgF5AxqsRz9J1cjqdlxDWrwTO7u3tNWK7SFhAL8e221WE7pU6Ytk2t7e311JnTQWLJycntWyhpCmVShXCKboBMJyjCKJlzgVzKJiamtrBAKoH1JoAvU+2MN2g6enp3QgboRnqjHl2u70kHA7zU0APpQMlze/357vd7gKyhang7GAwKEsx1gLoAwp0E8JdJtB4w1LK4sw4OAtWl51inBGwAxT/9iLUQb+ZgsHgJ4I5hYWFAQZjbYBrKPB+hGNM4DweL1pUVBRMzOpweXm5WyAQ/GIAfwj4GbZwiUTyIy8vby7eLw4mQH9paamX4VO7kgTeTTeguLjYg0AOjAgVTD58UygUb1i41l84ogGhka4z+rwi9p3MQHwajeYRjrNFlvBbiDfoOmFtQzU1NU/J5JKBA3w+/71er3/J8hA6kSKpOPX19c9w+YH4VDIwqRbG1Wr1HZVK5eX8o6bVaj9XV1cTk3HFcinpsUjs7AWKNwvWO5gpFI93pqmpyYxLB0neVBUIcaI90OHOzs7TfX19ErZA8niNRuNXnU53M2apTmiBSc0lgEoh9cjIiBYV5i6c1YxKYblc/rOhoeEdIin2nkCfoHk2VSYpV7ZCVdB+h8OxDyocHh4WoEJZskRwvUhVVVUIcldWVtrx1XPoNfQFWkynvCWzzIe2QSXQTmg7Od5QT+WinuagliaFnI8kJvQxJpJIATo34zJ8WyR/YF2sfBFDpKCPHyqLMUeajSVniJq9mYKXjUtwPdY34a7W+/EfAQYAZM5kh2zoNWsAAAAASUVORK5CYII=", rightIconPath = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAhCAYAAADOHBvaAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA4tJREFUeNrsl11IU2EYx91ytrnpmmy4TYNkqGhEJGiiabuQ2EAiZ1kZW9NtF4pgoBB40weJeCHVjReygVmuIhP6gLoJJNQGadhiJcLa2sb8KN2nrprbel7YYh7WzjnOsIsO/Hnes533/Z33PB/nOZRIJJK2GwflP/ifBg8MDGTOzs4eQeOCggJjb2+vH4aRvwGmyeXyZq/Xe9rv99eGQqHs+D+pVKqfxWJNZ2VlPdRoNPfFYnEgVTBNpVI1Op3OG4FAQETkDul0uo3P518dHh6+B6dB0uC5uTlWf3//zcXFRfV2fMjlcsfUarVGIpG4yYCZDQ0Nz10ulziVAGKz2W+7u7ulNTU1q0TAdKVSOWi1Wlt2InqFQuFTvV5/HoYbW+ICc116T0/PBQLQl0TBEB8nYddtKF6SgXNMJtM1nLUuTUxMSMFeIQqfn5+/vLCwIPgTOL2vr++sx+PJS7LGEEBvowHY60ThkII8iHIVDDMSgbMtFssZnDXkkKOS2AkZuM1mk4HhJAJzV1ZWDuHMZ4DGE8AVeODl5eVin8+XiwVT7HZ7rtvt3kfg5hPB74I5lWxSMBikTU5OlsSYMTAVHoWQRJYg+COA8+PgT8Dokk2CkiuM+fk3mMFg0EiAQ6AWgC3FfoCbOA5GlfRuGQwE3bPFxyKRyAvFPkIQeg6gY3HQerRpvIn5+fkerI9DUN58PB4vsA1oJ5hneFAmk7lZVlZmj704YuAwSrfCwkInzvyhBNBbRHxTWlqK3IJeGJvYdHLBQm9w5rfBNUqyUHRUVVW9A7Ma3eSWlwRK7np4/w6azWYWzjp6UDNRqEAg+DEyMtJJo9Eew+k37I59oI+tra2vIMjw1momkQFpCoViGqAfYOhJVLnQs7dWV1ePy2SyLzvV1EEjsCSVSh/A0BzfkWC3hpxv6Ojo0NbV1a2lCgW/eru6ulBRmQKt4TYCoIMg2ejo6EWdTpcXDodJQ5uamr62t7ffgSHy63tQgEjrkwkqBp0wGo2NWq32MNgMIsCioqJN6DRN5eXl43D6AsUNaJ1Ml7kXFRvQUVDtzMzMMYPBsB/EcjgcVEx7E66oqFivrKx0gFBKvkYuA6FY+b6d9hbVVTboAKgkKtTmcqHgM6G/TuNwOBvRFPmMmg3QJ5Alvlik0tCng1Bu50TznRV9Iuj4iaoeKkDRAPIlA6b67UTBlFvSi+zaR9svAQYA6+V18DvfH/8AAAAASUVORK5CYII=", menu = document.getElementById('navigation'), savedState = Sfjs.getPreference('menu/displayState'), - displayState, elem, className; + displayState; if (null === savedState) { savedState = 'block'; diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig index 7f10150c72bfe..7a83c0e10399d 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig @@ -128,7 +128,7 @@ abbr { } #menu-profiler li a span.label { display: block; - padding: 20px 0px 16px 65px; + padding: 20px 0 16px 65px; min-height: 16px; overflow: hidden; } @@ -199,7 +199,7 @@ li { #resume { background-color: #f6f6f6; border-bottom: 1px solid #dfdfdf; - padding: 18px 10px 0px; + padding: 18px 10px 0; margin-left: 250px; height: 34px; color: #313131; @@ -266,7 +266,6 @@ ul.alt li.warning { margin-bottom: 1px; } ul.sf-call-stack li { - text-size: small; padding: 0 0 0 20px; } td.main, td.menu { @@ -366,13 +365,12 @@ td.main, td.menu { line-height: 1.5em; } .sf-profiler-timeline .legends span { - border-left-width: 10px; - border-left-style: solid; + border-left: 10px solid; padding: 0 10px 0 5px; } .sf-profiler-timeline canvas { - border: 1px solid #999; - border-width: 1px 0; + border: 1px #999; + border-style: solid none; } .collapsed-menu-parents #resume, .collapsed-menu-parents #collector-content { 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 129fd82d27f2a..5cc31d56b2e53 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig @@ -93,9 +93,9 @@ } .sf-toolbar-block .sf-toolbar-info-piece .sf-toolbar-status { - padding: 0px 5px; + padding: 0 5px; border-radius: 5px; - margin-bottom: 0px; + margin-bottom: 0; vertical-align: top; } @@ -129,13 +129,11 @@ display: none; position: absolute; background-color: #fff; - border: 1px solid #bbb; padding: 9px 0; margin-left: -1px; bottom: 38px; - border-bottom-width: 0; - border-bottom: 1px solid #bbb; + border: 1px solid #bbb; border-radius: 4px 4px 0 0; } @@ -198,7 +196,7 @@ } .sf-toolbar-block .sf-toolbar-icon > a, -.sf-toolbar-block .sf-toolbar-icon > a:link +.sf-toolbar-block .sf-toolbar-icon > a:link, .sf-toolbar-block .sf-toolbar-icon > a:hover { color: black !important; } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php index 1a29c75b43e0e..73625d13e147a 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php @@ -62,8 +62,6 @@ public function testReturns404onTokenNotFound() if ('found' == $token) { return new Profile($token); } - - return; })) ; diff --git a/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php b/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php index 143328f412774..407458f48f2cc 100644 --- a/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php +++ b/src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php @@ -74,7 +74,7 @@ public function testHtmlShakespear($css, $count) $document = simplexml_import_dom($document); $bodies = $document->xpath('//body'); $elements = $bodies[0]->xpath($translator->cssToXPath($css)); - $this->assertEquals($count, count($elements)); + $this->assertCount($count, $elements); } public function getXpathLiteralTestData() diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/interfaces1.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/interfaces1.php index 27503a351c674..4c93e32017914 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/interfaces1.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/interfaces1.php @@ -11,15 +11,3 @@ $container->setDefinition('foo', $definition); return $container; - -if (!class_exists('FooClass')) { - class FooClass - { - public $bar; - - public function setBar($bar) - { - $this->bar = $bar; - } - } -} diff --git a/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php index fb3b4caa26624..1f6b9502d52ce 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php @@ -52,6 +52,18 @@ public function testAddASubscriberService() ->with($event) ; + $service + ->expects($this->once()) + ->method('onEventWithPriority') + ->with($event) + ; + + $service + ->expects($this->once()) + ->method('onEventNested') + ->with($event) + ; + $container = new Container(); $container->set('service.subscriber', $service); @@ -59,6 +71,8 @@ public function testAddASubscriberService() $dispatcher->addSubscriberService('service.subscriber', 'Symfony\Component\EventDispatcher\Tests\SubscriberService'); $dispatcher->dispatch('onEvent', $event); + $dispatcher->dispatch('onEventWithPriority', $event); + $dispatcher->dispatch('onEventNested', $event); } public function testPreventDuplicateListenerService() @@ -233,12 +247,20 @@ public static function getSubscribedEvents() { return array( 'onEvent' => 'onEvent', - 'onEvent' => array('onEvent', 10), - 'onEvent' => array('onEvent'), + 'onEventWithPriority' => array('onEventWithPriority', 10), + 'onEventNested' => array(array('onEventNested')), ); } public function onEvent(Event $e) { } + + public function onEventWithPriority(Event $e) + { + } + + public function onEventNested(Event $e) + { + } } diff --git a/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php b/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php index 244301a739e29..da4004d6b525c 100644 --- a/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php +++ b/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php @@ -94,7 +94,7 @@ public function searchInDirectory($dir) $command->setErrorHandler( $this->ignoreUnreadableDirs // If directory is unreadable and finder is set to ignore it, `stderr` is ignored. - ? function ($stderr) { return; } + ? function ($stderr) { } : function ($stderr) { throw new AccessDeniedException($stderr); } ); diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index bde4ba723f3f8..2fe81e1b8eab7 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -71,10 +71,10 @@ public function buildForm(FormBuilderInterface $builder, array $options) if ($options['multiple']) { $builder->addViewTransformer(new ChoicesToBooleanArrayTransformer($options['choice_list'])); - $builder->addEventSubscriber(new FixCheckboxInputListener($options['choice_list']), 10); + $builder->addEventSubscriber(new FixCheckboxInputListener($options['choice_list'])); } else { $builder->addViewTransformer(new ChoiceToBooleanArrayTransformer($options['choice_list'], $builder->has('placeholder'))); - $builder->addEventSubscriber(new FixRadioInputListener($options['choice_list'], $builder->has('placeholder')), 10); + $builder->addEventSubscriber(new FixRadioInputListener($options['choice_list'], $builder->has('placeholder'))); } } else { if ($options['multiple']) { diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php index c440a0470abbe..cb999fc59c133 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php @@ -558,11 +558,6 @@ public function getValidationGroups(FormInterface $form) return array('group1', 'group2'); } - private function getMockExecutionContext() - { - return $this->getMock('Symfony\Component\Validator\ExecutionContextInterface'); - } - /** * @param string $name * @param string $dataClass diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTest.php index e26bf7f1b69dc..6a15bbfa9e6b6 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTest.php @@ -64,7 +64,7 @@ public function testValidationGroupsCanBeSetToCallback() public function testValidationGroupsCanBeSetToClosure() { $form = $this->createForm(array( - 'validation_groups' => function (FormInterface $form) { return; }, + 'validation_groups' => function (FormInterface $form) { }, )); $this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups'))); diff --git a/src/Symfony/Component/Form/Tests/Util/OrderedHashMapTest.php b/src/Symfony/Component/Form/Tests/Util/OrderedHashMapTest.php index 7adff69a3fa29..dd51fa5d23a36 100644 --- a/src/Symfony/Component/Form/Tests/Util/OrderedHashMapTest.php +++ b/src/Symfony/Component/Form/Tests/Util/OrderedHashMapTest.php @@ -482,6 +482,6 @@ public function testCount() unset($map[0]); $map[] = 3; - $this->assertSame(2, count($map)); + $this->assertCount(2, $map); } } diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index d2af44626cdcb..eea1ab91c60c8 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -1707,8 +1707,6 @@ protected function preparePathInfo() return '/'; } - $pathInfo = '/'; - // Remove the query string from REQUEST_URI if ($pos = strpos($requestUri, '?')) { $requestUri = substr($requestUri, 0, $pos); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php index 1936b1c2942f0..1c6b7b9635222 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php @@ -57,7 +57,7 @@ public function testWrongTableOptionsRead() { $storage = new PdoSessionHandler($this->pdo, array('db_table' => 'bad_name')); $this->setExpectedException('RuntimeException'); - $storage->read('foo', 'bar'); + $storage->read('foo'); } public function testWriteRead() diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index 07179faec4873..a330c8075e7ce 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -255,7 +255,7 @@ protected function invalidate(Request $request, $catch = false) // invalidate only when the response is successful if ($response->isSuccessful() || $response->isRedirect()) { try { - $this->store->invalidate($request, $catch); + $this->store->invalidate($request); // As per the RFC, invalidate Location and Content-Location URLs if present foreach (array('Location', 'Content-Location') as $header) { @@ -481,7 +481,7 @@ protected function forward(Request $request, $catch = false, Response $entry = n $this->processResponseBody($request, $response); if ($this->isPrivateRequest($request) && !$response->headers->hasCacheControlDirective('public')) { - $response->setPrivate(true); + $response->setPrivate(); } elseif ($this->options['default_ttl'] > 0 && null === $response->getTtl() && !$response->headers->getCacheControlDirective('must-revalidate')) { $response->setTtl($this->options['default_ttl']); } diff --git a/src/Symfony/Component/HttpKernel/Profiler/SqliteProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/SqliteProfilerStorage.php index 0c25bc950c3ae..33c11b68cdaf8 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/SqliteProfilerStorage.php +++ b/src/Symfony/Component/HttpKernel/Profiler/SqliteProfilerStorage.php @@ -77,7 +77,7 @@ protected function fetch($db, $query, array $args = array()) $return = array(); if ($db instanceof \SQLite3) { - $stmt = $this->prepareStatement($db, $query, true); + $stmt = $this->prepareStatement($db, $query); foreach ($args as $arg => $val) { $stmt->bindValue($arg, $val, is_int($val) ? \SQLITE3_INTEGER : \SQLITE3_TEXT); } diff --git a/src/Symfony/Component/Intl/Data/Generator/CurrencyDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/CurrencyDataGenerator.php index 9c978f8ea8cfb..19cf6eab00a70 100644 --- a/src/Symfony/Component/Intl/Data/Generator/CurrencyDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/CurrencyDataGenerator.php @@ -121,8 +121,6 @@ protected function generateDataForLocale(BundleReaderInterface $reader, $tempDir return $data; } - - return; } /** diff --git a/src/Symfony/Component/Intl/Data/Generator/LanguageDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/LanguageDataGenerator.php index 7c4dac8415f4e..65894340cb3b7 100644 --- a/src/Symfony/Component/Intl/Data/Generator/LanguageDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/LanguageDataGenerator.php @@ -133,8 +133,6 @@ protected function generateDataForLocale(BundleReaderInterface $reader, $tempDir return $data; } - - return; } /** @@ -142,7 +140,6 @@ protected function generateDataForLocale(BundleReaderInterface $reader, $tempDir */ protected function generateDataForRoot(BundleReaderInterface $reader, $tempDir) { - return; } /** diff --git a/src/Symfony/Component/Intl/Data/Util/LocaleScanner.php b/src/Symfony/Component/Intl/Data/Util/LocaleScanner.php index c2d097e527d81..0604593f6e1d2 100644 --- a/src/Symfony/Component/Intl/Data/Util/LocaleScanner.php +++ b/src/Symfony/Component/Intl/Data/Util/LocaleScanner.php @@ -67,7 +67,7 @@ public function scanLocales($sourceDir) */ public function scanAliases($sourceDir) { - $locales = $this->scanLocales($sourceDir, '.txt'); + $locales = $this->scanLocales($sourceDir); $aliases = array(); // Delete locales that are no aliases diff --git a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php index 11f8c0f9470cc..c309fc722dcdf 100644 --- a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php +++ b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php @@ -647,8 +647,7 @@ protected function getDefaultPattern() if (self::NONE !== $this->timetype) { $patternParts[] = $this->defaultTimeFormats[$this->timetype]; } - $pattern = implode(', ', $patternParts); - return $pattern; + return implode(', ', $patternParts); } } diff --git a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php index 0ee222ee50fd6..7bc7a2ba880fb 100644 --- a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php +++ b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php @@ -709,11 +709,9 @@ private function roundCurrency($value, $currency) private function round($value, $precision) { $precision = $this->getUnitializedPrecision($value, $precision); - $roundingMode = self::$phpRoundingMap[$this->getAttribute(self::ROUNDING_MODE)]; - $value = round($value, $precision, $roundingMode); - return $value; + return round($value, $precision, $roundingMode); } /** diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php index d6f4257647169..b2d7c63a93958 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Intl\Tests\Data\Bundle\Reader; use Symfony\Component\Intl\Data\Bundle\Reader\IntlBundleReader; -use Symfony\Component\Intl\Intl; /** * @author Bernhard Schussek diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php index b9d50976d98cc..5e4c4b225e2b9 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php @@ -13,7 +13,6 @@ use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Intl\Data\Bundle\Writer\JsonBundleWriter; -use Symfony\Component\Intl\Intl; /** * @author Bernhard Schussek diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/PhpBundleWriterTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/PhpBundleWriterTest.php index d11d3d204b3df..ee7b12f1ed040 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/PhpBundleWriterTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/PhpBundleWriterTest.php @@ -13,7 +13,6 @@ use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Intl\Data\Bundle\Writer\PhpBundleWriter; -use Symfony\Component\Intl\Intl; /** * @author Bernhard Schussek diff --git a/src/Symfony/Component/Intl/Tests/Data/Util/LocaleScannerTest.php b/src/Symfony/Component/Intl/Tests/Data/Util/LocaleScannerTest.php index 7c37c80720b1b..fa487ba3b5332 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Util/LocaleScannerTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Util/LocaleScannerTest.php @@ -64,13 +64,13 @@ public function testScanLocales() { $sortedLocales = array('de', 'de_alias', 'en', 'en_alias', 'fr', 'fr_alias'); - $this->assertSame($sortedLocales, $this->scanner->scanLocales($this->directory, '.txt')); + $this->assertSame($sortedLocales, $this->scanner->scanLocales($this->directory)); } public function testScanAliases() { $sortedAliases = array('de_alias' => 'de', 'en_alias' => 'en', 'fr_alias' => 'fr'); - $this->assertSame($sortedAliases, $this->scanner->scanAliases($this->directory, '.txt')); + $this->assertSame($sortedAliases, $this->scanner->scanAliases($this->directory)); } } diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php index a38a3ef967869..51bc6eabc2af1 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php @@ -337,7 +337,7 @@ public function testGetValueFailsIfMagicCallDisabled() { $value = new MagicianCall(); - $this->propertyAccessor->getValue($value, 'foobar', 'bam'); + $this->propertyAccessor->getValue($value, 'foobar'); } public function testGetValueReadsMagicCall() diff --git a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php index 2807e1011c1b8..d7b74f01e1bb3 100644 --- a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php +++ b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php @@ -623,9 +623,8 @@ protected function getGenerator(RouteCollection $routes, array $parameters = arr $method = 'set'.$key; $context->$method($value); } - $generator = new UrlGenerator($routes, $context, $logger); - return $generator; + return new UrlGenerator($routes, $context, $logger); } protected function getRoutes($name, Route $route) diff --git a/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php b/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php index 074c4a039d12f..3baaa9914ea41 100644 --- a/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php +++ b/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php @@ -856,7 +856,7 @@ private function updateOldFieldAceProperty($name, array $changes) */ private function updateNewAceProperty($name, array $changes) { - list($old, $new) = $changes; + list(, $new) = $changes; $sids = new \SplObjectStorage(); $classIds = new \SplObjectStorage(); diff --git a/src/Symfony/Component/Security/Tests/Http/Firewall/RememberMeListenerTest.php b/src/Symfony/Component/Security/Tests/Http/Firewall/RememberMeListenerTest.php index ad96243d47905..8316a8c69de5a 100644 --- a/src/Symfony/Component/Security/Tests/Http/Firewall/RememberMeListenerTest.php +++ b/src/Symfony/Component/Security/Tests/Http/Firewall/RememberMeListenerTest.php @@ -140,7 +140,7 @@ public function testOnCoreSecurity() public function testSessionStrategy() { - list($listener, $tokenStorage, $service, $manager) = $this->getListener(false, true, true); + list($listener, $tokenStorage, $service, $manager) = $this->getListener(); $tokenStorage ->expects($this->once()) diff --git a/src/Symfony/Component/Security/Tests/Http/RememberMe/TokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Tests/Http/RememberMe/TokenBasedRememberMeServicesTest.php index b988c7dc0f4a9..d1ec9b248d905 100644 --- a/src/Symfony/Component/Security/Tests/Http/RememberMe/TokenBasedRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Tests/Http/RememberMe/TokenBasedRememberMeServicesTest.php @@ -172,9 +172,8 @@ public function testLoginFail() { $service = $this->getService(null, array('name' => 'foo', 'path' => '/foo', 'domain' => 'foodomain.foo')); $request = new Request(); - $response = new Response(); - $service->loginFail($request, $response); + $service->loginFail($request); $cookie = $request->attributes->get(RememberMeServicesInterface::COOKIE_ATTR_NAME); $this->assertTrue($cookie->isCleared()); diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php index 1c5d699b5dca2..d870c82e0f867 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -208,7 +208,6 @@ public function provideCallbacks() array( array( 'bar' => function ($bar) { - return; }, ), 'baz', diff --git a/src/Symfony/Component/Translation/Dumper/PhpFileDumper.php b/src/Symfony/Component/Translation/Dumper/PhpFileDumper.php index b354c1245c993..60cc2ef65ea7b 100644 --- a/src/Symfony/Component/Translation/Dumper/PhpFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/PhpFileDumper.php @@ -25,9 +25,7 @@ class PhpFileDumper extends FileDumper */ protected function format(MessageCatalogue $messages, $domain) { - $output = "all($domain), true).";\n"; - - return $output; + return "all($domain), true).";\n"; } /** diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index dbb12f2834133..b259000e538d2 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -255,7 +255,6 @@ protected function getTestsForDump() '12.30e+02' => 12.30e+02, '1234' => 0x4D2, '1243' => 02333, - '.Inf' => -log(0), '-.Inf' => log(0), "'686e444'" => '686e444', '.Inf' => 646e444, From 1285a0d6374c215df0996fe8982ba220bc059306 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 25 Jan 2016 23:11:37 +0100 Subject: [PATCH 097/226] [Debug] Tell that the extension is for PHP 5 only --- src/Symfony/Component/Debug/Resources/ext/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Debug/Resources/ext/README.md b/src/Symfony/Component/Debug/Resources/ext/README.md index 0672ef8f4ace1..25dccf0766470 100644 --- a/src/Symfony/Component/Debug/Resources/ext/README.md +++ b/src/Symfony/Component/Debug/Resources/ext/README.md @@ -1,7 +1,9 @@ -Symfony Debug Extension -======================= +Symfony Debug Extension for PHP 5 +================================= This extension publishes several functions to help building powerful debugging tools. +It is compatible with PHP 5.3, 5.4, 5.5 and 5.6; with ZTS and non-ZTS modes. +It is not required thus not provided for PHP 7. symfony_zval_info() ------------------- @@ -122,7 +124,6 @@ array(3) { Usage ----- -The extension is compatible with ZTS mode, and should be supported by PHP5.3, 5.4, 5.5 and 5.6. To enable the extension from source, run: ``` From 0a3b87701c62d519e9f7ca2b87f0c7fa9a8933eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 18 Jan 2016 22:20:09 +0100 Subject: [PATCH 098/226] [Serializer] Ensure that groups are strings --- .../Serializer/Mapping/Loader/YamlFileLoader.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Symfony/Component/Serializer/Mapping/Loader/YamlFileLoader.php b/src/Symfony/Component/Serializer/Mapping/Loader/YamlFileLoader.php index 1c84698594e5b..84f983ed123d4 100644 --- a/src/Symfony/Component/Serializer/Mapping/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Serializer/Mapping/Loader/YamlFileLoader.php @@ -74,7 +74,15 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata) } if (isset($data['groups'])) { + if (!is_array($data['groups'])) { + throw new MappingException('The "groups" key must be an array of strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName()); + } + foreach ($data['groups'] as $group) { + if (!is_string($group)) { + throw new MappingException('Group names must be strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName()); + } + $attributeMetadata->addGroup($group); } } From e791fa0405c969cd7872cb0db27b929e31621c27 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 26 Jan 2016 08:10:13 +0100 Subject: [PATCH 099/226] [Form] fix tests --- .../Tests/Extension/Validator/Constraints/FormValidatorTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php index 00223d81e4001..9e7bdee25ee4b 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php @@ -135,6 +135,8 @@ public function testMissingConstraintIndex() $form = new FormBuilder('name', '\stdClass', $this->dispatcher, $this->factory); $form = $form->setData($object)->getForm(); + $this->expectValidateAt(0, 'data', $object, 'Default'); + $this->validator->validate($form, new Form()); $this->assertNoViolation(); From c376cf3e063752bd7e9e039ac96f9df796dbf35f Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 12 Dec 2015 16:57:50 +0100 Subject: [PATCH 100/226] Fix FileSystem tests on Windows --- .../Component/Filesystem/Tests/FilesystemTest.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index b57610cb81208..58dac8e5d07a1 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -868,7 +868,7 @@ public function testMirrorCopiesLinks() public function testMirrorCopiesLinkedDirectoryContents() { - $this->markAsSkippedIfSymlinkIsMissing(); + $this->markAsSkippedIfSymlinkIsMissing(true); $sourcePath = $this->workspace.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR; @@ -888,7 +888,7 @@ public function testMirrorCopiesLinkedDirectoryContents() public function testMirrorCopiesRelativeLinkedContents() { - $this->markAsSkippedIfSymlinkIsMissing(); + $this->markAsSkippedIfSymlinkIsMissing(true); $sourcePath = $this->workspace.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR; $oldPath = getcwd(); @@ -1012,7 +1012,10 @@ private function getFileGroup($filepath) $this->markTestSkipped('Unable to retrieve file group name'); } - private function markAsSkippedIfSymlinkIsMissing() + /** + * @param bool $relative Whether support for relative symlinks is required + */ + private function markAsSkippedIfSymlinkIsMissing($relative = false) { if (!function_exists('symlink')) { $this->markTestSkipped('symlink is not supported'); @@ -1021,6 +1024,11 @@ private function markAsSkippedIfSymlinkIsMissing() if (false === self::$symlinkOnWindows) { $this->markTestSkipped('symlink requires "Create symbolic links" privilege on Windows'); } + + // https://bugs.php.net/bug.php?id=69473 + if ($relative && '\\' === DIRECTORY_SEPARATOR && 1 === PHP_ZTS) { + $this->markTestSkipped('symlink does not support relative paths on thread safe Windows PHP versions'); + } } private function markAsSkippedIfChmodIsMissing() From ff568dc518afe25821371a9d66625becc399b48e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 18 Jan 2016 22:15:26 +0100 Subject: [PATCH 101/226] [Serializer] Minor: fix CS and PHPDoc --- .../Mapping/Factory/ClassMetadataFactory.php | 2 ++ .../Serializer/Mapping/Loader/YamlFileLoader.php | 1 + .../CamelCaseToSnakeCaseNameConverter.php | 1 + .../Serializer/Normalizer/AbstractNormalizer.php | 6 ++++++ src/Symfony/Component/Serializer/Serializer.php | 10 ++++++++-- 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php b/src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php index 3a354e354e9e3..601342ee61535 100644 --- a/src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php +++ b/src/Symfony/Component/Serializer/Mapping/Factory/ClassMetadataFactory.php @@ -27,10 +27,12 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface * @var LoaderInterface */ private $loader; + /** * @var Cache */ private $cache; + /** * @var array */ diff --git a/src/Symfony/Component/Serializer/Mapping/Loader/YamlFileLoader.php b/src/Symfony/Component/Serializer/Mapping/Loader/YamlFileLoader.php index 84f983ed123d4..ebe2a6e4b4799 100644 --- a/src/Symfony/Component/Serializer/Mapping/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Serializer/Mapping/Loader/YamlFileLoader.php @@ -65,6 +65,7 @@ public function loadClassMetadata(ClassMetadataInterface $classMetadata) if (isset($yaml['attributes']) && is_array($yaml['attributes'])) { $attributesMetadata = $classMetadata->getAttributesMetadata(); + foreach ($yaml['attributes'] as $attribute => $data) { if (isset($attributesMetadata[$attribute])) { $attributeMetadata = $attributesMetadata[$attribute]; diff --git a/src/Symfony/Component/Serializer/NameConverter/CamelCaseToSnakeCaseNameConverter.php b/src/Symfony/Component/Serializer/NameConverter/CamelCaseToSnakeCaseNameConverter.php index 8ef851c6528e5..80720fa6babeb 100644 --- a/src/Symfony/Component/Serializer/NameConverter/CamelCaseToSnakeCaseNameConverter.php +++ b/src/Symfony/Component/Serializer/NameConverter/CamelCaseToSnakeCaseNameConverter.php @@ -22,6 +22,7 @@ class CamelCaseToSnakeCaseNameConverter implements NameConverterInterface * @var array|null */ private $attributes; + /** * @var bool */ diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php index f12d3d2263081..63bfb871e819d 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php @@ -35,26 +35,32 @@ abstract class AbstractNormalizer extends SerializerAwareNormalizer implements N * @var int */ protected $circularReferenceLimit = 1; + /** * @var callable */ protected $circularReferenceHandler; + /** * @var ClassMetadataFactoryInterface|null */ protected $classMetadataFactory; + /** * @var NameConverterInterface|null */ protected $nameConverter; + /** * @var array */ protected $callbacks = array(); + /** * @var array */ protected $ignoredAttributes = array(); + /** * @var array */ diff --git a/src/Symfony/Component/Serializer/Serializer.php b/src/Symfony/Component/Serializer/Serializer.php index e9a92aa9f7e18..59943550a554a 100644 --- a/src/Symfony/Component/Serializer/Serializer.php +++ b/src/Symfony/Component/Serializer/Serializer.php @@ -41,18 +41,22 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz * @var Encoder\ChainEncoder */ protected $encoder; + /** * @var Encoder\ChainDecoder */ protected $decoder; + /** * @var array */ protected $normalizers = array(); + /** * @var array */ protected $normalizerCache = array(); + /** * @var array */ @@ -247,8 +251,10 @@ private function denormalizeObject($data, $class, $format, array $context = arra } foreach ($this->normalizers as $normalizer) { - if ($normalizer instanceof DenormalizerInterface - && $normalizer->supportsDenormalization($data, $class, $format)) { + if ( + $normalizer instanceof DenormalizerInterface && + $normalizer->supportsDenormalization($data, $class, $format) + ) { return $normalizer->denormalize($data, $class, $format, $context); } } From 37655be008ff1a2aa2f285df15a64b6415f03862 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 26 Jan 2016 09:13:20 +0100 Subject: [PATCH 102/226] Increase the inlining YAML level for config:debug --- .../Bundle/FrameworkBundle/Command/ConfigDebugCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php index 67ab40e0e9116..20deffcc3339f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php @@ -90,7 +90,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln(sprintf('# Current configuration for "%s"', $name)); } - $output->writeln(Yaml::dump(array($extension->getAlias() => $config), 3)); + $output->writeln(Yaml::dump(array($extension->getAlias() => $config), 10)); } private function compileContainer() From 03d31821291a7e565714ce752889ef2494226605 Mon Sep 17 00:00:00 2001 From: Tristan Roussel Date: Wed, 27 Jan 2016 01:08:23 +0100 Subject: [PATCH 103/226] Remove invalid CSS white-space value --- .../Bundle/FrameworkBundle/Resources/public/css/exception.css | 1 - .../Resources/views/Collector/exception.css.twig | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/public/css/exception.css b/src/Symfony/Bundle/FrameworkBundle/Resources/public/css/exception.css index 7426d44f885d4..10480b0757c9f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/public/css/exception.css +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/public/css/exception.css @@ -7,7 +7,6 @@ padding: 5px 4px; list-style-type: decimal; margin-left: 20px; - white-space: break-word; } .sf-reset #logs .traces li.error { font-style: normal; diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.css.twig index 1224081bd600a..7730f55f09416 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.css.twig @@ -7,7 +7,6 @@ padding: 5px 4px; list-style-type: decimal; margin-left: 20px; - white-space: break-word; } .sf-reset #logs .traces li.error { font-style: normal; From 4e97bb89c71a45bbf012547ad62e66c605bb3566 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 26 Jan 2016 22:55:09 +0100 Subject: [PATCH 104/226] Remove duplicate cursor property --- .../WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig | 1 - 1 file changed, 1 deletion(-) 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 a6fa8150fd0ee..a34d0fac64574 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig @@ -58,7 +58,6 @@ .sf-toolbarreset .hide-button { background: #444; - cursor: pointer; display: block; position: absolute; top: 0; From fce0af06048568036e55902dce648bf1b686b9a3 Mon Sep 17 00:00:00 2001 From: Adam Elsodaney Date: Tue, 26 Jan 2016 11:38:15 +0000 Subject: [PATCH 105/226] [WebProfilerBundle] Don't inherit CSS text-transform property for the toolbar. --- .../WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig | 1 + 1 file changed, 1 insertion(+) 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 a34d0fac64574..cade19d0b4c1a 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig @@ -45,6 +45,7 @@ position: fixed; right: 0; text-align: left; + text-transform: none; z-index: 99999; } .sf-toolbarreset abbr { From 7702189cb43972f08acbca14ae524bbf5576f0cb Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 27 Jan 2016 08:44:59 +0100 Subject: [PATCH 106/226] resolve aliases in factory services --- .../Compiler/ResolveReferencesToAliasesPass.php | 11 +++++++++++ .../ResolveReferencesToAliasesPassTest.php | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php index c90d76f48adf5..016778652314f 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php @@ -12,6 +12,7 @@ namespace Symfony\Component\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\Alias; +use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -42,6 +43,7 @@ public function process(ContainerBuilder $container) $definition->setArguments($this->processArguments($definition->getArguments())); $definition->setMethodCalls($this->processArguments($definition->getMethodCalls())); $definition->setProperties($this->processArguments($definition->getProperties())); + $definition->setFactoryService($this->processFactoryService($definition->getFactoryService())); } foreach ($container->getAliases() as $id => $alias) { @@ -76,6 +78,15 @@ private function processArguments(array $arguments) return $arguments; } + private function processFactoryService($factoryService) + { + if (null === $factoryService) { + return; + } + + return $this->getDefinitionId($factoryService); + } + /** * Resolves an alias into a definition id. * diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveReferencesToAliasesPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveReferencesToAliasesPassTest.php index 6fdc233941e64..c441548fc4ade 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveReferencesToAliasesPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveReferencesToAliasesPassTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\DependencyInjection\Tests\Compiler; +use Symfony\Component\DependencyInjection\Alias; +use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Compiler\ResolveReferencesToAliasesPass; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -59,6 +61,21 @@ public function testAliasCircularReference() $this->process($container); } + public function testResolveFactory() + { + $container = new ContainerBuilder(); + $container->register('factory', 'Factory'); + $container->setAlias('factory_alias', new Alias('factory')); + $foo = new Definition(); + $foo->setFactoryService('factory_alias'); + $foo->setFactoryMethod('createFoo'); + $container->setDefinition('foo', $foo); + + $this->process($container); + + $this->assertSame('factory', $foo->getFactoryService()); + } + protected function process(ContainerBuilder $container) { $pass = new ResolveReferencesToAliasesPass(); From fde10e799a599332dcc702b8b71ff8c4a63d847f Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 27 Jan 2016 08:44:59 +0100 Subject: [PATCH 107/226] resolve aliases in factories --- .../ResolveReferencesToAliasesPass.php | 17 ++++++++++++++ .../ResolveReferencesToAliasesPassTest.php | 23 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php index c90d76f48adf5..09441f3b14bf8 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php @@ -12,6 +12,7 @@ namespace Symfony\Component\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\Alias; +use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -42,6 +43,7 @@ public function process(ContainerBuilder $container) $definition->setArguments($this->processArguments($definition->getArguments())); $definition->setMethodCalls($this->processArguments($definition->getMethodCalls())); $definition->setProperties($this->processArguments($definition->getProperties())); + $definition->setFactory($this->processFactory($definition->getFactory())); } foreach ($container->getAliases() as $id => $alias) { @@ -76,6 +78,21 @@ private function processArguments(array $arguments) return $arguments; } + private function processFactory($factory) + { + if (null === $factory || !is_array($factory) || !$factory[0] instanceof Reference) { + return $factory; + } + + $defId = $this->getDefinitionId($id = (string) $factory[0]); + + if ($defId !== $id) { + $factory[0] = new Reference($defId, $factory[0]->getInvalidBehavior(), $factory[0]->isStrict()); + } + + return $factory; + } + /** * Resolves an alias into a definition id. * diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveReferencesToAliasesPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveReferencesToAliasesPassTest.php index 6fdc233941e64..0fe83960b78eb 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveReferencesToAliasesPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveReferencesToAliasesPassTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\DependencyInjection\Tests\Compiler; +use Symfony\Component\DependencyInjection\Alias; +use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Compiler\ResolveReferencesToAliasesPass; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -59,6 +61,27 @@ public function testAliasCircularReference() $this->process($container); } + public function testResolveFactory() + { + $container = new ContainerBuilder(); + $container->register('factory', 'Factory'); + $container->setAlias('factory_alias', new Alias('factory')); + $foo = new Definition(); + $foo->setFactory(array(new Reference('factory_alias'), 'createFoo')); + $container->setDefinition('foo', $foo); + $bar = new Definition(); + $bar->setFactory(array('Factory', 'createFoo')); + $container->setDefinition('bar', $bar); + + $this->process($container); + + $resolvedFooFactory = $container->getDefinition('foo')->getFactory(); + $resolvedBarFactory = $container->getDefinition('bar')->getFactory(); + + $this->assertSame('factory', (string) $resolvedFooFactory[0]); + $this->assertSame('Factory', (string) $resolvedBarFactory[0]); + } + protected function process(ContainerBuilder $container) { $pass = new ResolveReferencesToAliasesPass(); From 517a9a2aa5dcfe0af3bb7e8539d32711b5643944 Mon Sep 17 00:00:00 2001 From: Sam Fleming Date: Wed, 27 Jan 2016 10:06:30 +0000 Subject: [PATCH 108/226] Fixed HTTP Digest auth not being passed user checker Commit 05be5da1710ab681a04334d58126f8c3d431e3cb added the ability to configure a user checker on a per firewall basis. However, that commit seems to have missed updating the HttpDigestFactory. --- .../DependencyInjection/Security/Factory/HttpDigestFactory.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/HttpDigestFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/HttpDigestFactory.php index 63875f83081bc..2e61859a92adf 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/HttpDigestFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/HttpDigestFactory.php @@ -29,6 +29,7 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider, $container ->setDefinition($provider, new DefinitionDecorator('security.authentication.provider.dao')) ->replaceArgument(0, new Reference($userProvider)) + ->replaceArgument(1, new Reference('security.user_checker.'.$id)) ->replaceArgument(2, $id) ; From b5f524d40be6932b7d98506a2c3cbc925ef1e483 Mon Sep 17 00:00:00 2001 From: Gintautas Miselis Date: Wed, 29 Jul 2015 21:59:34 +0100 Subject: [PATCH 109/226] [BrowserKit] Corrected HTTP_HOST logic #15398 --- src/Symfony/Component/BrowserKit/Client.php | 11 +++--- .../Component/BrowserKit/Tests/ClientTest.php | 34 +++++-------------- 2 files changed, 13 insertions(+), 32 deletions(-) diff --git a/src/Symfony/Component/BrowserKit/Client.php b/src/Symfony/Component/BrowserKit/Client.php index 22c889ecd7608..54c967cb89165 100644 --- a/src/Symfony/Component/BrowserKit/Client.php +++ b/src/Symfony/Component/BrowserKit/Client.php @@ -110,7 +110,6 @@ public function insulate($insulated = true) public function setServerParameters(array $server) { $this->server = array_merge(array( - 'HTTP_HOST' => 'localhost', 'HTTP_USER_AGENT' => 'Symfony2 BrowserKit', ), $server); } @@ -273,21 +272,19 @@ public function request($method, $uri, array $parameters = array(), array $files $uri = $this->getAbsoluteUri($uri); - if (!empty($server['HTTP_HOST'])) { - $uri = preg_replace('{^(https?\://)'.preg_quote($this->extractHost($uri)).'}', '${1}'.$server['HTTP_HOST'], $uri); - } + $server = array_merge($this->server, $server); if (isset($server['HTTPS'])) { $uri = preg_replace('{^'.parse_url($uri, PHP_URL_SCHEME).'}', $server['HTTPS'] ? 'https' : 'http', $uri); } - $server = array_merge($this->server, $server); - if (!$this->history->isEmpty()) { $server['HTTP_REFERER'] = $this->history->current()->getUri(); } - $server['HTTP_HOST'] = $this->extractHost($uri); + if (empty($server['HTTP_HOST'])) { + $server['HTTP_HOST'] = $this->extractHost($uri); + } $server['HTTPS'] = 'https' == parse_url($uri, PHP_URL_SCHEME); $this->internalRequest = new Request($uri, $method, $parameters, $files, $this->cookieJar->allValues($uri), $server, $content); diff --git a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php index fe0037638547a..993e64a9e426c 100644 --- a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php @@ -93,12 +93,14 @@ public function testGetRequest() $this->assertEquals('http://example.com/', $client->getRequest()->getUri(), '->getCrawler() returns the Request of the last request'); } - public function testGetRequestWithIpAsHost() + public function testGetRequestWithIpAsHttpHost() { $client = new TestClient(); $client->request('GET', 'https://example.com/foo', array(), array(), array('HTTP_HOST' => '127.0.0.1')); - $this->assertEquals('https://127.0.0.1/foo', $client->getRequest()->getUri()); + $this->assertEquals('https://example.com/foo', $client->getRequest()->getUri()); + $headers = $client->getRequest()->getServer(); + $this->assertEquals('127.0.0.1', $headers['HTTP_HOST']); } public function testGetResponse() @@ -212,24 +214,6 @@ public function testRequestURIConversion() $this->assertEquals('http://www.example.com/http', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); } - public function testRequestURIConversionByServerHost() - { - $client = new TestClient(); - - $server = array('HTTP_HOST' => 'www.exampl+e.com:8000'); - $parameters = array(); - $files = array(); - - $client->request('GET', 'http://exampl+e.com', $parameters, $files, $server); - $this->assertEquals('http://www.exampl+e.com:8000', $client->getRequest()->getUri(), '->request() uses HTTP_HOST to add port'); - - $client->request('GET', 'http://exampl+e.com:8888', $parameters, $files, $server); - $this->assertEquals('http://www.exampl+e.com:8000', $client->getRequest()->getUri(), '->request() uses HTTP_HOST to modify existing port'); - - $client->request('GET', 'http://exampl+e.com:8000', $parameters, $files, $server); - $this->assertEquals('http://www.exampl+e.com:8000', $client->getRequest()->getUri(), '->request() uses HTTP_HOST respects correct set port'); - } - public function testRequestReferer() { $client = new TestClient(); @@ -572,7 +556,7 @@ public function testInsulatedRequests() public function testGetServerParameter() { $client = new TestClient(); - $this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST')); + $this->assertEquals('', $client->getServerParameter('HTTP_HOST')); $this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); $this->assertEquals('testvalue', $client->getServerParameter('testkey', 'testvalue')); } @@ -581,7 +565,7 @@ public function testSetServerParameter() { $client = new TestClient(); - $this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST')); + $this->assertEquals('', $client->getServerParameter('HTTP_HOST')); $this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); $client->setServerParameter('HTTP_HOST', 'testhost'); @@ -595,7 +579,7 @@ public function testSetServerParameterInRequest() { $client = new TestClient(); - $this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST')); + $this->assertEquals('', $client->getServerParameter('HTTP_HOST')); $this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); $client->request('GET', 'https://www.example.com/https/www.example.com', array(), array(), array( @@ -605,10 +589,10 @@ public function testSetServerParameterInRequest() 'NEW_SERVER_KEY' => 'new-server-key-value', )); - $this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST')); + $this->assertEquals('', $client->getServerParameter('HTTP_HOST')); $this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); - $this->assertEquals('http://testhost/https/www.example.com', $client->getRequest()->getUri()); + $this->assertEquals('http://www.example.com/https/www.example.com', $client->getRequest()->getUri()); $server = $client->getRequest()->getServer(); From 828fba4e1d7ea7636ba7d2c183b0ca9bf4c82b43 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 27 Jan 2016 11:46:45 +0100 Subject: [PATCH 110/226] fixed CS --- src/Symfony/Component/BrowserKit/Client.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/BrowserKit/Client.php b/src/Symfony/Component/BrowserKit/Client.php index 54c967cb89165..3fe681434c6b6 100644 --- a/src/Symfony/Component/BrowserKit/Client.php +++ b/src/Symfony/Component/BrowserKit/Client.php @@ -283,8 +283,9 @@ public function request($method, $uri, array $parameters = array(), array $files } if (empty($server['HTTP_HOST'])) { - $server['HTTP_HOST'] = $this->extractHost($uri); + $server['HTTP_HOST'] = $this->extractHost($uri); } + $server['HTTPS'] = 'https' == parse_url($uri, PHP_URL_SCHEME); $this->internalRequest = new Request($uri, $method, $parameters, $files, $this->cookieJar->allValues($uri), $server, $content); From 5fe735965957359780df801747a02b0e54f37f46 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Wed, 27 Jan 2016 11:47:13 +0000 Subject: [PATCH 111/226] Change couple of occurences of a public setUp() method to protected --- src/Symfony/Bridge/Twig/Tests/AppVariableTest.php | 2 +- .../Tests/Compiler/ExtensionCompilerPassTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php b/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php index c82d892557cf7..51a95bc4b57e0 100644 --- a/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php +++ b/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php @@ -13,7 +13,7 @@ class AppVariableTest extends \PHPUnit_Framework_TestCase */ protected $appVariable; - public function setUp() + protected function setUp() { $this->appVariable = new AppVariable(); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ExtensionCompilerPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ExtensionCompilerPassTest.php index 637ed7b67bf80..b786db95f6fe2 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ExtensionCompilerPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ExtensionCompilerPassTest.php @@ -21,7 +21,7 @@ class ExtensionCompilerPassTest extends \PHPUnit_Framework_TestCase private $container; private $pass; - public function setUp() + protected function setUp() { $this->container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'); $this->pass = new ExtensionCompilerPass(); From 6cd5ee3b267925a5cd4b5e3f570a2221eefb1e96 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 27 Jan 2016 12:46:36 +0100 Subject: [PATCH 112/226] [DependencyInjection] simplify the BC layer The change to the `setFactoryService()` method is consistent with what we did with the `getFactoryService()` before (and how we handle the deprecation of strict references in Symfony 2.8). --- .../Compiler/ResolveReferencesToAliasesPass.php | 5 +---- src/Symfony/Component/DependencyInjection/Definition.php | 6 ++++-- .../Component/DependencyInjection/DefinitionDecorator.php | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php index 579b85945d912..a1ba8a2732bb4 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveReferencesToAliasesPass.php @@ -44,10 +44,7 @@ public function process(ContainerBuilder $container) $definition->setMethodCalls($this->processArguments($definition->getMethodCalls())); $definition->setProperties($this->processArguments($definition->getProperties())); $definition->setFactory($this->processFactory($definition->getFactory())); - - if (null !== $factoryService = $definition->getFactoryService(false)) { - $definition->setFactoryService($this->processFactoryService($factoryService)); - } + $definition->setFactoryService($this->processFactoryService($definition->getFactoryService(false)), false); } foreach ($container->getAliases() as $id => $alias) { diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index 74da38203cf75..0c802b522f36e 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -194,9 +194,11 @@ public function getFactoryMethod($triggerDeprecationError = true) * * @deprecated since version 2.6, to be removed in 3.0. */ - public function setFactoryService($factoryService) + public function setFactoryService($factoryService, $triggerDeprecationError = true) { - @trigger_error(sprintf('%s(%s) is deprecated since version 2.6 and will be removed in 3.0. Use Definition::setFactory() instead.', __METHOD__, $factoryService), E_USER_DEPRECATED); + if ($triggerDeprecationError) { + @trigger_error(sprintf('%s(%s) is deprecated since version 2.6 and will be removed in 3.0. Use Definition::setFactory() instead.', __METHOD__, $factoryService), E_USER_DEPRECATED); + } $this->factoryService = $factoryService; diff --git a/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php b/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php index fd5b00cd203c0..ae47cc5367e79 100644 --- a/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php +++ b/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php @@ -99,7 +99,7 @@ public function setFactoryMethod($method) /** * {@inheritdoc} */ - public function setFactoryService($service) + public function setFactoryService($service, $triggerDeprecationError = true) { $this->changes['factory_service'] = true; From 0a883a94f1732cebb2e54ba5eabb36b8926f0e14 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Wed, 27 Jan 2016 11:49:43 +0000 Subject: [PATCH 113/226] Change few occurences of a public setUp() method to protected --- .../Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php | 2 +- .../FrameworkBundle/Tests/Routing/DelegatingLoaderTest.php | 2 +- .../PropertyInfo/Tests/Extractors/PhpDocExtractorTest.php | 2 +- .../PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php | 2 +- .../PropertyInfo/Tests/Extractors/SerializerExtractorTest.php | 2 +- .../Component/PropertyInfo/Tests/PropertyInfoExtractorTest.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php index 376208088c1d1..ac1bb5f96e41b 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php @@ -26,7 +26,7 @@ class DoctrineExtractorTest extends \PHPUnit_Framework_TestCase */ private $extractor; - public function setUp() + protected function setUp() { $config = Setup::createAnnotationMetadataConfiguration(array(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'), true); $entityManager = EntityManager::create(array('driver' => 'pdo_sqlite'), $config); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/DelegatingLoaderTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/DelegatingLoaderTest.php index e446efcd89715..31770872a6550 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/DelegatingLoaderTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/DelegatingLoaderTest.php @@ -12,7 +12,7 @@ class DelegatingLoaderTest extends \PHPUnit_Framework_TestCase /** @var ControllerNameParser */ private $controllerNameParser; - public function setUp() + protected function setUp() { $this->controllerNameParser = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser') ->disableOriginalConstructor() diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractors/PhpDocExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractors/PhpDocExtractorTest.php index 038a30bdac888..6049df7f63749 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractors/PhpDocExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractors/PhpDocExtractorTest.php @@ -24,7 +24,7 @@ class PhpDocExtractorTest extends \PHPUnit_Framework_TestCase */ private $extractor; - public function setUp() + protected function setUp() { $this->extractor = new PhpDocExtractor(); } diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php index ab478dd12b0c3..dfc13c025eb41 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php @@ -24,7 +24,7 @@ class ReflectionExtractorTest extends \PHPUnit_Framework_TestCase */ private $extractor; - public function setUp() + protected function setUp() { $this->extractor = new ReflectionExtractor(); } diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractors/SerializerExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractors/SerializerExtractorTest.php index c170f2237add9..92d18178ae209 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractors/SerializerExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractors/SerializerExtractorTest.php @@ -26,7 +26,7 @@ class SerializerExtractorTest extends \PHPUnit_Framework_TestCase */ private $extractor; - public function setUp() + protected function setUp() { $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader())); $this->extractor = new SerializerExtractor($classMetadataFactory); diff --git a/src/Symfony/Component/PropertyInfo/Tests/PropertyInfoExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/PropertyInfoExtractorTest.php index c7375d3006e0b..4cd4c04f675e0 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/PropertyInfoExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/PropertyInfoExtractorTest.php @@ -26,7 +26,7 @@ class PropertyInfoExtractorTest extends \PHPUnit_Framework_TestCase */ private $propertyInfo; - public function setUp() + protected function setUp() { $extractors = array(new NullExtractor(), new DummyExtractor()); $this->propertyInfo = new PropertyInfoExtractor($extractors, $extractors, $extractors, $extractors); From 0fe3088dea6f0210efc13cc1f9a0581192f560a3 Mon Sep 17 00:00:00 2001 From: Toni Uebernickel Date: Wed, 27 Jan 2016 13:18:03 +0100 Subject: [PATCH 114/226] register commands from kernel when accessing list --- .../FrameworkBundle/Console/Application.php | 38 ++++++-- .../Tests/Console/ApplicationTest.php | 86 ++++++++++++++++++- src/Symfony/Component/Console/Application.php | 8 +- 3 files changed, 118 insertions(+), 14 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Application.php b/src/Symfony/Bundle/FrameworkBundle/Console/Application.php index 6b02d3c5d2d6a..3ecdb0837b28b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Application.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Application.php @@ -11,14 +11,14 @@ namespace Symfony\Bundle\FrameworkBundle\Console; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\Console\Application as BaseApplication; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\HttpKernel\KernelInterface; -use Symfony\Component\HttpKernel\Kernel; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; +use Symfony\Component\HttpKernel\Kernel; +use Symfony\Component\HttpKernel\KernelInterface; /** * Application. @@ -69,12 +69,6 @@ public function doRun(InputInterface $input, OutputInterface $output) { $this->kernel->boot(); - if (!$this->commandsRegistered) { - $this->registerCommands(); - - $this->commandsRegistered = true; - } - $container = $this->kernel->getContainer(); foreach ($this->all() as $command) { @@ -96,8 +90,34 @@ public function doRun(InputInterface $input, OutputInterface $output) return parent::doRun($input, $output); } + /** + * {@inheritdoc} + */ + public function get($name) + { + $this->registerCommands(); + + return parent::get($name); + } + + /** + * {@inheritdoc} + */ + public function all($namespace = null) + { + $this->registerCommands(); + + return parent::all($namespace); + } + protected function registerCommands() { + if ($this->commandsRegistered) { + return; + } + + $this->commandsRegistered = true; + foreach ($this->kernel->getBundles() as $bundle) { if ($bundle instanceof Bundle) { $bundle->registerCommands($this); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php index 42fcb6f597dd7..dbc8fb868ba49 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php @@ -11,8 +11,9 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Console; -use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Bundle\FrameworkBundle\Console\Application; +use Symfony\Bundle\FrameworkBundle\Tests\TestCase; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Console\Tester\ApplicationTester; @@ -38,6 +39,89 @@ public function testBundleCommandsAreRegistered() $application = new Application($kernel); $application->doRun(new ArrayInput(array('list')), new NullOutput()); + + // Calling twice: registration should only be done once. + $application->doRun(new ArrayInput(array('list')), new NullOutput()); + } + + public function testBundleCommandsAreRetrievable() + { + $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle'); + $bundle->expects($this->once())->method('registerCommands'); + + $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); + $kernel + ->expects($this->any()) + ->method('getBundles') + ->will($this->returnValue(array($bundle))) + ; + + $application = new Application($kernel); + $application->all(); + + // Calling twice: registration should only be done once. + $application->all(); + } + + public function testBundleSingleCommandIsRetrievable() + { + $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle'); + $bundle->expects($this->once())->method('registerCommands'); + + $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); + $kernel + ->expects($this->any()) + ->method('getBundles') + ->will($this->returnValue(array($bundle))) + ; + + $application = new Application($kernel); + + $command = new Command('example'); + $application->add($command); + + $this->assertSame($command, $application->get('example')); + } + + public function testBundleCommandCanBeFound() + { + $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle'); + $bundle->expects($this->once())->method('registerCommands'); + + $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); + $kernel + ->expects($this->any()) + ->method('getBundles') + ->will($this->returnValue(array($bundle))) + ; + + $application = new Application($kernel); + + $command = new Command('example'); + $application->add($command); + + $this->assertSame($command, $application->find('example')); + } + + public function testBundleCommandCanBeFoundByAlias() + { + $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle'); + $bundle->expects($this->once())->method('registerCommands'); + + $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); + $kernel + ->expects($this->any()) + ->method('getBundles') + ->will($this->returnValue(array($bundle))) + ; + + $application = new Application($kernel); + + $command = new Command('example'); + $command->setAliases(array('alias')); + $application->add($command); + + $this->assertSame($command, $application->find('alias')); } public function testBundleCommandsHaveRightContainer() diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 78051c37ecf83..7a5b87ffbe45d 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -436,7 +436,7 @@ public function has($name) public function getNamespaces() { $namespaces = array(); - foreach ($this->commands as $command) { + foreach ($this->all() as $command) { $namespaces = array_merge($namespaces, $this->extractAllNamespaces($command->getName())); foreach ($command->getAliases() as $alias) { @@ -530,7 +530,7 @@ public function find($name) // name $commands = array(); - foreach ($this->commands as $command) { + foreach ($this->all() as $command) { $extractedNamespace = $this->extractNamespace($command->getName()); if ($extractedNamespace === $namespace || !empty($namespace) && 0 === strpos($extractedNamespace, $namespace) @@ -556,7 +556,7 @@ public function find($name) // aliases $aliases = array(); - foreach ($this->commands as $command) { + foreach ($this->all() as $command) { foreach ($command->getAliases() as $alias) { $extractedNamespace = $this->extractNamespace($alias); if ($extractedNamespace === $namespace @@ -1028,7 +1028,7 @@ private function findAlternativeCommands($name, $abbrevs) return $item->getName(); }; - return $this->findAlternatives($name, $this->commands, $abbrevs, $callback); + return $this->findAlternatives($name, $this->all(), $abbrevs, $callback); } /** From 7b2a538236dbc02c7c6bd7ef8a36d4a0278a3941 Mon Sep 17 00:00:00 2001 From: John Bafford Date: Sat, 23 Jan 2016 17:43:00 -0500 Subject: [PATCH 115/226] Update UPGRADE-3.0 with correct Voter details AbstractVoter was removed, but the upgrade instructions to use Voter were not complete and continued to reference AbstractVoter. --- UPGRADE-3.0.md | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md index f52ebd6eb4cde..8e7368c054019 100644 --- a/UPGRADE-3.0.md +++ b/UPGRADE-3.0.md @@ -898,11 +898,6 @@ UPGRADE FROM 2.x to 3.0 ### Security - * The `AbstractVoter` class was removed in favor of the new `Voter` class. - - * The `VoterInterface::supportsClass` and `supportsAttribute` methods were - removed from the interface. - * The `Resources/` directory was moved to `Core/Resources/` * The `key` settings of `anonymous`, `remember_me` and `http_digest` are @@ -994,8 +989,15 @@ UPGRADE FROM 2.x to 3.0 )); ``` - * The `AbstractVoter::getSupportedAttributes()` and `AbstractVoter::getSupportedClasses()` - methods have been removed in favor of `AbstractVoter::supports()`. + * The `AbstractVoter` class was removed. Instead, extend the new `Voter` class, + introduced in 2.8, and move your voting logic to the to the `supports($attribute, $subject)` + and `voteOnAttribute($attribute, $object, TokenInterface $token)` methods. + + * The `vote()` method from the `VoterInterface` was changed to now accept arbitrary + types, and not only objects. + + * The `supportsClass` and `supportsAttribute` methods were + removed from the `VoterInterface` interface. Before: @@ -1019,14 +1021,19 @@ UPGRADE FROM 2.x to 3.0 After: ```php - class MyVoter extends AbstractVoter + use Symfony\Component\Security\Core\Authorization\Voter\Voter; + + class MyVoter extends Voter { protected function supports($attribute, $object) { return $object instanceof Post && in_array($attribute, array('CREATE', 'EDIT')); } - // ... + protected function voteOnAttribute($attribute, $object, TokenInterface $token) + { + // Return true or false + } } ``` From 6a806e32b7a173db5cce112d6d3b12bbec1b061c Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Wed, 27 Jan 2016 16:53:33 +0000 Subject: [PATCH 116/226] [YAML] Refine the return value of Yaml::parse() --- src/Symfony/Component/Yaml/Yaml.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Yaml/Yaml.php b/src/Symfony/Component/Yaml/Yaml.php index cce18a657aa07..2e14a6c08352d 100644 --- a/src/Symfony/Component/Yaml/Yaml.php +++ b/src/Symfony/Component/Yaml/Yaml.php @@ -21,10 +21,7 @@ class Yaml { /** - * Parses YAML into a PHP array. - * - * The parse method, when supplied with a YAML stream (string or file), - * will do its best to convert YAML in a file into a PHP array. + * Parses YAML into a PHP value. * * Usage: * @@ -40,7 +37,7 @@ class Yaml * @param bool $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise * @param bool $objectSupport True if object support is enabled, false otherwise * - * @return array The YAML converted to a PHP array + * @return mixed The YAML converted to a PHP value * * @throws ParseException If the YAML is not valid */ From d86a3a7ba344f8a37c911ad10d0d520559c5bd73 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 10 Dec 2015 22:20:42 +0100 Subject: [PATCH 117/226] [DependencyInjection] enforce tags to have a name --- .../Loader/XmlFileLoader.php | 4 ++++ .../Loader/YamlFileLoader.php | 4 ++++ .../schema/dic/services/services-1.0.xsd | 2 +- .../Fixtures/xml/tag_with_empty_name.xml | 11 ++++++++++ .../Tests/Fixtures/xml/tag_without_name.xml | 11 ++++++++++ .../Fixtures/yaml/tag_name_empty_string.yml | 6 +++++ .../Fixtures/yaml/tag_name_no_string.yml | 6 +++++ .../Tests/Loader/XmlFileLoaderTest.php | 22 +++++++++++++++++++ .../Tests/Loader/YamlFileLoaderTest.php | 20 +++++++++++++++++ 9 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/tag_with_empty_name.xml create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/tag_without_name.xml create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/tag_name_empty_string.yml create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/tag_name_no_string.yml diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index b268cb99045d4..0314ba6809586 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -186,6 +186,10 @@ private function parseDefinition($id, $service, $file) $parameters[$name] = SimpleXMLElement::phpize($value); } + if ('' === (string) $tag['name']) { + throw new InvalidArgumentException(sprintf('The tag name for service "%s" in %s must be a non-empty string.', $id, $file)); + } + $definition->addTag((string) $tag['name'], $parameters); } diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index 91adf2b78d83d..4acdb702a11ed 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -245,6 +245,10 @@ private function parseDefinition($id, $service, $file) throw new InvalidArgumentException(sprintf('A "tags" entry is missing a "name" key for service "%s" in %s.', $id, $file)); } + if (!is_string($tag['name']) || '' === $tag['name']) { + throw new InvalidArgumentException(sprintf('The tag name for service "%s" in %s must be a non-empty string.', $id, $file)); + } + $name = $tag['name']; unset($tag['name']); diff --git a/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd b/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd index e62b475ba36d6..8ad313f8cf3bf 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd +++ b/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd @@ -97,7 +97,7 @@ - + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/tag_with_empty_name.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/tag_with_empty_name.xml new file mode 100644 index 0000000000000..1646292462475 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/tag_with_empty_name.xml @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/tag_without_name.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/tag_without_name.xml new file mode 100644 index 0000000000000..bc7373df73cf0 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/tag_without_name.xml @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/tag_name_empty_string.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/tag_name_empty_string.yml new file mode 100644 index 0000000000000..0ea5f53da8cd9 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/tag_name_empty_string.yml @@ -0,0 +1,6 @@ +services: + foo_service: + class: FooClass + tags: + # tag name is an empty string + - { name: '', foo: bar } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/tag_name_no_string.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/tag_name_no_string.yml new file mode 100644 index 0000000000000..f24cafd225b3c --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/tag_name_no_string.yml @@ -0,0 +1,6 @@ +services: + foo_service: + class: FooClass + tags: + # tag name is not a string + - { name: [], foo: bar } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php index c0e39ef7ad15c..e5dfa2a13e6bd 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -13,6 +13,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; @@ -207,6 +208,27 @@ public function testParsesTags() } } + /** + * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException + */ + public function testParseTagsWithoutNameThrowsException() + { + $container = new ContainerBuilder(); + $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); + $loader->load('tag_without_name.xml'); + } + + /** + * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException + * @expectedExceptionMessageRegExp /The tag name for service ".+" in .* must be a non-empty string/ + */ + public function testParseTagWithEmptyNameThrowsException() + { + $container = new ContainerBuilder(); + $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); + $loader->load('tag_with_empty_name.xml'); + } + public function testConvertDomElementToArray() { $doc = new \DOMDocument('1.0'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index bd53da0d5f510..2a096695862c1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -233,4 +233,24 @@ public function testTagWithAttributeArrayThrowsException() $this->assertStringStartsWith('A "tags" attribute must be of a scalar-type for service ', $e->getMessage(), '->load() throws an InvalidArgumentException if a tag-attribute is not a scalar'); } } + + /** + * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException + * @expectedExceptionMessageRegExp /The tag name for service ".+" in .+ must be a non-empty string/ + */ + public function testTagWithEmptyNameThrowsException() + { + $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); + $loader->load('tag_name_empty_string.yml'); + } + + /** + * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException + * @expectedExceptionMessageREgExp /The tag name for service "\.+" must be a non-empty string/ + */ + public function testTagWithNonStringNameThrowsException() + { + $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); + $loader->load('tag_name_no_string.yml'); + } } From e6853052921748712906f4088a239619573657b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Par=C3=A1da=20J=C3=B3zsef?= Date: Wed, 27 Jan 2016 23:49:30 +0100 Subject: [PATCH 118/226] [Ldap] Remove unused private property --- src/Symfony/Component/Ldap/LdapClient.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Symfony/Component/Ldap/LdapClient.php b/src/Symfony/Component/Ldap/LdapClient.php index 3fc0cb5454240..e7a0bc45e64d9 100644 --- a/src/Symfony/Component/Ldap/LdapClient.php +++ b/src/Symfony/Component/Ldap/LdapClient.php @@ -30,7 +30,6 @@ class LdapClient implements LdapClientInterface private $useStartTls; private $optReferrals; private $connection; - private $charmaps; /** * Constructor. From f7f82fa4f2ede3425b586023ee26354b2f9e2810 Mon Sep 17 00:00:00 2001 From: Christian Schmidt Date: Thu, 28 Jan 2016 23:27:35 +0100 Subject: [PATCH 119/226] [Translation] Add resources from fallback locale --- .../Translation/Tests/TranslatorTest.php | 24 +++++++++++++++++++ .../Component/Translation/Translator.php | 3 +++ 2 files changed, 27 insertions(+) diff --git a/src/Symfony/Component/Translation/Tests/TranslatorTest.php b/src/Symfony/Component/Translation/Tests/TranslatorTest.php index 0952a4514fb16..32b01772b62cf 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorTest.php @@ -239,6 +239,30 @@ public function testWhenAResourceHasNoRegisteredLoader() $translator->trans('foo'); } + public function testFallbackCatalogueResources() + { + $translator = new Translator('en_GB', new MessageSelector()); + $translator->addLoader('yml', new \Symfony\Component\Translation\Loader\YamlFileLoader()); + $translator->addResource('yml', __DIR__.'/fixtures/empty.yml', 'en_GB'); + $translator->addResource('yml', __DIR__.'/fixtures/resources.yml', 'en'); + + // force catalogue loading + $this->assertEquals('bar', $translator->trans('foo', array())); + + $cataloguesProperty = new \ReflectionProperty($translator, 'catalogues'); + $cataloguesProperty->setAccessible(true); + $catalogues = $cataloguesProperty->getValue($translator); + + $resources = $catalogues['en']->getResources(); + $this->assertCount(1, $resources); + $this->assertContains( __DIR__.'/fixtures/resources.yml', $resources); + + $resources = $catalogues['en_GB']->getResources(); + $this->assertCount(2, $resources); + $this->assertContains( __DIR__.'/fixtures/empty.yml', $resources); + $this->assertContains( __DIR__.'/fixtures/resources.yml', $resources); + } + /** * @dataProvider getTransTests */ diff --git a/src/Symfony/Component/Translation/Translator.php b/src/Symfony/Component/Translation/Translator.php index 96855e8fe08fb..07c3fc54e477a 100644 --- a/src/Symfony/Component/Translation/Translator.php +++ b/src/Symfony/Component/Translation/Translator.php @@ -255,6 +255,9 @@ private function loadFallbackCatalogues($locale) } $fallbackCatalogue = new MessageCatalogue($fallback, $this->catalogues[$fallback]->all()); + foreach ($this->catalogues[$fallback]->getResources() as $resource) { + $fallbackCatalogue->addResource($resource); + } $current->addFallbackCatalogue($fallbackCatalogue); $current = $fallbackCatalogue; } From cb1a921bb918f7fea25521ce02fcdda43be7f580 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 29 Jan 2016 13:24:08 +0100 Subject: [PATCH 120/226] Fixed the Bootstrap form theme for inlined checkbox/radio --- .../Twig/Resources/views/Form/bootstrap_3_layout.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig index 5affc7a6a1b92..dfb1965ca1048 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig @@ -115,7 +115,7 @@ {%- endblock choice_widget_expanded %} {% block checkbox_widget -%} - {% set parent_label_class = parent_label_class|default('') -%} + {%- set parent_label_class = parent_label_class|default(label_attr.class|default('')) -%} {% if 'checkbox-inline' in parent_label_class %} {{- form_label(form, null, { widget: parent() }) -}} {% else -%} @@ -126,7 +126,7 @@ {%- endblock checkbox_widget %} {% block radio_widget -%} - {%- set parent_label_class = parent_label_class|default('') -%} + {%- set parent_label_class = parent_label_class|default(label_attr.class|default('')) -%} {% if 'radio-inline' in parent_label_class %} {{- form_label(form, null, { widget: parent() }) -}} {% else -%} From d15c34a51fe60c47e56989e31f4fd95793f995ea Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Fri, 29 Jan 2016 17:58:49 +0100 Subject: [PATCH 121/226] remove duplicated value --- src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index 515f104af692c..58832ab2f8e06 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -407,7 +407,7 @@ public function configureOptions(OptionsResolver $resolver) $resolver->setAllowedTypes('choice_value', array('null', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath')); $resolver->setAllowedTypes('choice_attr', array('null', 'array', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath')); $resolver->setAllowedTypes('preferred_choices', array('array', '\Traversable', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath')); - $resolver->setAllowedTypes('group_by', array('null', 'array', '\Traversable', 'string', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath')); + $resolver->setAllowedTypes('group_by', array('null', 'array', '\Traversable', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath')); } /** From 25f735f78aa24e01702fab08393b418e377ada7f Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 27 Jan 2016 08:19:38 +0100 Subject: [PATCH 122/226] remove default null value for asset version Setting `null` as the version of a package means that it uses the empty version strategy. However, omitting the `version` option entirely was meant to fall back to the default version strategy. This is not possible when the default version value is `null` as there is no way to remove it. --- .../Bundle/FrameworkBundle/DependencyInjection/Configuration.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 8cbb97a2c0ca3..c1430f13c5186 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -558,7 +558,6 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode) ->fixXmlConfig('base_url') ->children() ->scalarNode('version') - ->defaultNull() ->beforeNormalization() ->ifTrue(function ($v) { return '' === $v; }) ->then(function ($v) { return; }) From 350625dd21ea836ac9ef409f65ab3150d9135fcd Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 30 Jan 2016 09:46:07 +0100 Subject: [PATCH 123/226] pass triggerDeprecationError arg to parent class --- .../Component/DependencyInjection/DefinitionDecorator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php b/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php index ae47cc5367e79..b3f3fee504132 100644 --- a/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php +++ b/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php @@ -103,7 +103,7 @@ public function setFactoryService($service, $triggerDeprecationError = true) { $this->changes['factory_service'] = true; - return parent::setFactoryService($service); + return parent::setFactoryService($service, $triggerDeprecationError); } /** From c8e1384b843429ce746c5d26d5263e6b9f0ff84a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Par=C3=A1da=20J=C3=B3zsef?= Date: Thu, 28 Jan 2016 00:14:34 +0100 Subject: [PATCH 124/226] [2.7] Fix tests --- .../Functional/app/Resources/{ => views}/fragment.html.php | 0 .../ClassLoader/Tests/LegacyApcUniversalClassLoaderTest.php | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Resources/{ => views}/fragment.html.php (100%) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Resources/fragment.html.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Resources/views/fragment.html.php similarity index 100% rename from src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Resources/fragment.html.php rename to src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Resources/views/fragment.html.php diff --git a/src/Symfony/Component/ClassLoader/Tests/LegacyApcUniversalClassLoaderTest.php b/src/Symfony/Component/ClassLoader/Tests/LegacyApcUniversalClassLoaderTest.php index 066068d88de23..512ff632a51db 100644 --- a/src/Symfony/Component/ClassLoader/Tests/LegacyApcUniversalClassLoaderTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/LegacyApcUniversalClassLoaderTest.php @@ -21,7 +21,7 @@ class LegacyApcUniversalClassLoaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) { - apcu_clear_cache('user'); + apcu_clear_cache(); } else { $this->markTestSkipped('APC is not enabled.'); } @@ -30,7 +30,7 @@ protected function setUp() protected function tearDown() { if (ini_get('apc.enabled') && ini_get('apc.enable_cli')) { - apcu_clear_cache('user'); + apcu_clear_cache(); } } From 0c4b636c241890dac1ed4faf94dbdb8558a181fd Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 30 Jan 2016 21:05:11 +0100 Subject: [PATCH 125/226] [Form] fix option name in changelog --- src/Symfony/Component/Form/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/CHANGELOG.md b/src/Symfony/Component/Form/CHANGELOG.md index b1387bb2e6396..58b0f3862b23f 100644 --- a/src/Symfony/Component/Form/CHANGELOG.md +++ b/src/Symfony/Component/Form/CHANGELOG.md @@ -62,7 +62,7 @@ CHANGELOG * moved CSRF implementation to the new Security CSRF sub-component * deprecated CsrfProviderInterface and its implementations - * deprecated options "csrf_provider" and "intention" in favor of the new options "csrf_token_generator" and "csrf_token_id" + * deprecated options "csrf_provider" and "intention" in favor of the new options "csrf_token_manager" and "csrf_token_id" 2.3.0 ----- From 0efb137492c2d6f81d4e9859eb57aa254bdb68ad Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 30 Jan 2016 21:06:33 +0100 Subject: [PATCH 126/226] [Form] fix option name in upgrade file --- UPGRADE-2.8.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UPGRADE-2.8.md b/UPGRADE-2.8.md index 825e0ec833648..18ea4dbc8d217 100644 --- a/UPGRADE-2.8.md +++ b/UPGRADE-2.8.md @@ -22,7 +22,7 @@ Form of the new `csrf_token_id` option. * The `csrf_provider` option was deprecated and will be removed in 3.0 in favor - of the new `csrf_token_generator` option. + of the new `csrf_token_manager` option. * The "cascade_validation" option was deprecated. Use the "constraints" option together with the `Valid` constraint instead. Contrary to From 29750e51ad352c2a711cb22b88f19036cf1b0a73 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 30 Jan 2016 22:24:39 +0100 Subject: [PATCH 127/226] fix container cache key generation If the actual class name were not taken into, we would not be able to detect inconsistencies between the different configuration formats (PHP, YAML, and XML) as the container built based on the first evaluated configuration format would be cached and reused by tests for the other formats too. --- .../Tests/DependencyInjection/FrameworkExtensionTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 5b64b4e5243d7..caed2c2916a18 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -309,7 +309,7 @@ protected function createContainer(array $data = array()) protected function createContainerFromFile($file, $data = array()) { - $cacheKey = md5($file.serialize($data)); + $cacheKey = md5(get_class($this).$file.serialize($data)); if (isset(self::$containerCache[$cacheKey])) { return self::$containerCache[$cacheKey]; } From ccc6d311b192e1f89f77413d836d8a5a14ce68c5 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 31 Jan 2016 08:57:13 +0100 Subject: [PATCH 128/226] simplified a test --- .../Component/Translation/Tests/TranslatorTest.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Translation/Tests/TranslatorTest.php b/src/Symfony/Component/Translation/Tests/TranslatorTest.php index 9fe9552d501a2..b0308f419d403 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorTest.php @@ -283,15 +283,11 @@ public function testFallbackCatalogueResources() // force catalogue loading $this->assertEquals('bar', $translator->trans('foo', array())); - $cataloguesProperty = new \ReflectionProperty($translator, 'catalogues'); - $cataloguesProperty->setAccessible(true); - $catalogues = $cataloguesProperty->getValue($translator); - - $resources = $catalogues['en']->getResources(); + $resources = $translator->getCatalogue('en')->getResources(); $this->assertCount(1, $resources); $this->assertContains( __DIR__.'/fixtures/resources.yml', $resources); - $resources = $catalogues['en_GB']->getResources(); + $resources = $translator->getCatalogue('en_GB')->getResources(); $this->assertCount(2, $resources); $this->assertContains( __DIR__.'/fixtures/empty.yml', $resources); $this->assertContains( __DIR__.'/fixtures/resources.yml', $resources); From d120c08f8b72236460de5cbe95140b60358799c0 Mon Sep 17 00:00:00 2001 From: Dmytro Boiko Date: Sat, 30 Jan 2016 19:26:34 +0200 Subject: [PATCH 129/226] [WebProfiler] Fixed styles for search block and menu profiler for IE Edge --- .../Bundle/WebProfilerBundle/Resources/views/Icon/search.svg | 2 +- .../Bundle/WebProfilerBundle/Resources/views/Icon/symfony.svg | 2 +- .../Resources/views/Profiler/profiler.css.twig | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/search.svg b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/search.svg index b5f0a2c85be48..7c8724aab54c1 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/search.svg +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/search.svg @@ -1,4 +1,4 @@ - + + Date: Sun, 31 Jan 2016 22:09:31 +0100 Subject: [PATCH 131/226] [FrameworkBundle] Remove unused code in test --- .../Tests/DependencyInjection/PhpFrameworkExtensionTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php index 01c73930db8b1..b077e80dc43e3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php @@ -28,7 +28,7 @@ protected function loadFromFile(ContainerBuilder $container, $file) */ public function testAssetsCannotHavePathAndUrl() { - $container = $this->createContainerFromClosure(function ($container) { + $this->createContainerFromClosure(function ($container) { $container->loadFromExtension('framework', array( 'assets' => array( 'base_urls' => 'http://cdn.example.com', @@ -43,7 +43,7 @@ public function testAssetsCannotHavePathAndUrl() */ public function testAssetPackageCannotHavePathAndUrl() { - $container = $this->createContainerFromClosure(function ($container) { + $this->createContainerFromClosure(function ($container) { $container->loadFromExtension('framework', array( 'assets' => array( 'packages' => array( From aab5decc5b68f64d0a4bb294f13369aa091535c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Sun, 31 Jan 2016 22:16:42 +0100 Subject: [PATCH 132/226] Move licenses according to new best practices --- src/Symfony/Bundle/FrameworkBundle/{Resources/meta => }/LICENSE | 0 src/Symfony/Bundle/SecurityBundle/{Resources/meta => }/LICENSE | 0 src/Symfony/Bundle/TwigBundle/{Resources/meta => }/LICENSE | 0 src/Symfony/Bundle/WebProfilerBundle/{Resources/meta => }/LICENSE | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename src/Symfony/Bundle/FrameworkBundle/{Resources/meta => }/LICENSE (100%) rename src/Symfony/Bundle/SecurityBundle/{Resources/meta => }/LICENSE (100%) rename src/Symfony/Bundle/TwigBundle/{Resources/meta => }/LICENSE (100%) rename src/Symfony/Bundle/WebProfilerBundle/{Resources/meta => }/LICENSE (100%) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/meta/LICENSE b/src/Symfony/Bundle/FrameworkBundle/LICENSE similarity index 100% rename from src/Symfony/Bundle/FrameworkBundle/Resources/meta/LICENSE rename to src/Symfony/Bundle/FrameworkBundle/LICENSE diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/meta/LICENSE b/src/Symfony/Bundle/SecurityBundle/LICENSE similarity index 100% rename from src/Symfony/Bundle/SecurityBundle/Resources/meta/LICENSE rename to src/Symfony/Bundle/SecurityBundle/LICENSE diff --git a/src/Symfony/Bundle/TwigBundle/Resources/meta/LICENSE b/src/Symfony/Bundle/TwigBundle/LICENSE similarity index 100% rename from src/Symfony/Bundle/TwigBundle/Resources/meta/LICENSE rename to src/Symfony/Bundle/TwigBundle/LICENSE diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/meta/LICENSE b/src/Symfony/Bundle/WebProfilerBundle/LICENSE similarity index 100% rename from src/Symfony/Bundle/WebProfilerBundle/Resources/meta/LICENSE rename to src/Symfony/Bundle/WebProfilerBundle/LICENSE From ceaeb436926f9d211d3236fffa623b12acbc3b02 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 1 Feb 2016 12:48:21 +0100 Subject: [PATCH 133/226] backport GlobTest from 2.7 branch --- .../Component/Finder/Tests/FinderTest.php | 1 + .../Component/Finder/Tests/GlobTest.php | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/Symfony/Component/Finder/Tests/GlobTest.php diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index bb6099dd671af..24e385bdd9faf 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -248,6 +248,7 @@ public function testIn() __DIR__.DIRECTORY_SEPARATOR.'BsdFinderTest.php', __DIR__.DIRECTORY_SEPARATOR.'FinderTest.php', __DIR__.DIRECTORY_SEPARATOR.'GnuFinderTest.php', + __DIR__.DIRECTORY_SEPARATOR.'GlobTest.php', ); $this->assertIterator($expected, $iterator); diff --git a/src/Symfony/Component/Finder/Tests/GlobTest.php b/src/Symfony/Component/Finder/Tests/GlobTest.php new file mode 100644 index 0000000000000..cf7d03563b7bd --- /dev/null +++ b/src/Symfony/Component/Finder/Tests/GlobTest.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Finder\Tests; + +use Symfony\Component\Finder\Glob; + +class GlobTest extends \PHPUnit_Framework_TestCase +{ + public function testGlobToRegexDelimiters() + { + $this->assertEquals('#^(?=[^\.])\#$#', Glob::toRegex('#')); + $this->assertEquals('#^\.[^/]*$#', Glob::toRegex('.*')); + } +} From 1a96c40f357acc0201a6f1f2d487c077621a4e3a Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 1 Feb 2016 20:40:12 +0100 Subject: [PATCH 134/226] [#17634] move DebugBundle license file --- src/Symfony/Bundle/DebugBundle/{Resources/meta => }/LICENSE | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/Symfony/Bundle/DebugBundle/{Resources/meta => }/LICENSE (100%) diff --git a/src/Symfony/Bundle/DebugBundle/Resources/meta/LICENSE b/src/Symfony/Bundle/DebugBundle/LICENSE similarity index 100% rename from src/Symfony/Bundle/DebugBundle/Resources/meta/LICENSE rename to src/Symfony/Bundle/DebugBundle/LICENSE From b58f4833dfe374d36680d062e85c19f0945e3362 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 1 Feb 2016 14:16:12 +0100 Subject: [PATCH 135/226] [appveyor] Fix failure reporting --- .travis.yml | 2 +- appveyor.yml | 2 +- .../PersistentTokenBasedRememberMeServicesTest.php | 9 +++++++++ .../Component/Serializer/Normalizer/CustomNormalizer.php | 4 ++++ .../Component/Translation/Tests/TranslatorTest.php | 6 +++--- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 20edf72737c31..f62aa14901466 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,7 +52,7 @@ install: - if [[ $deps != skip ]]; then COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); fi; - if [[ $deps != skip && $deps ]]; then php .travis.php $TRAVIS_COMMIT_RANGE $TRAVIS_BRANCH $COMPONENTS; fi; - if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then SYMFONY_VERSION=$(git ls-remote --heads | grep -o '/[1-9].*' | tail -n 1 | sed s/.//); else SYMFONY_VERSION=$(cat composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*'); fi; - - if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then git fetch origin $SYMFONY_VERSION; git checkout -m FETCH_HEAD; fi; + - if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then git fetch origin $SYMFONY_VERSION; git checkout -m FETCH_HEAD; COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); fi; - if [[ $deps = high && ${SYMFONY_VERSION%.*} != $(git show $(git ls-remote --heads | grep -FA1 /$SYMFONY_VERSION | tail -n 1):composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9]*' | head -n 1) ]]; then LEGACY=,legacy; fi; - export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev; - if [[ ! $deps ]]; then composer update --prefer-dist; else export SYMFONY_DEPRECATIONS_HELPER=weak; fi; diff --git a/appveyor.yml b/appveyor.yml index 61e8b56353541..555cd0f2a6d7a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,6 +14,7 @@ init: - SET PHP=1 - SET ANSICON=121x90 (121x90) - SET SYMFONY_PHPUNIT_SKIPPED_TESTS=phpunit.skipped + - REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Command Processor" /v DelayedExpansion /t REG_DWORD /d 1 /f install: - IF EXIST c:\php (SET PHP=0) ELSE (mkdir c:\php) @@ -57,7 +58,6 @@ install: test_script: - cd c:\projects\symfony - - Setlocal EnableDelayedExpansion - SET X=0 - copy /Y c:\php\php.ini-min c:\php\php.ini - php phpunit symfony --exclude-group benchmark,intl-data || SET X=!errorlevel! diff --git a/src/Symfony/Component/Security/Tests/Http/RememberMe/PersistentTokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Tests/Http/RememberMe/PersistentTokenBasedRememberMeServicesTest.php index 61c3559abf470..3ba8f9906c271 100644 --- a/src/Symfony/Component/Security/Tests/Http/RememberMe/PersistentTokenBasedRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Tests/Http/RememberMe/PersistentTokenBasedRememberMeServicesTest.php @@ -24,6 +24,15 @@ class PersistentTokenBasedRememberMeServicesTest extends \PHPUnit_Framework_TestCase { + public static function setUpBeforeClass() + { + try { + random_bytes(1); + } catch (\Exception $e) { + throw new \PHPUnit_Framework_SkippedTestError($e->getMessage()); + } + } + public function testAutoLoginReturnsNullWhenNoCookie() { $service = $this->getService(null, array('name' => 'foo')); diff --git a/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php index e3f09a943613c..bc3d432de5a0e 100644 --- a/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php @@ -59,6 +59,10 @@ public function supportsNormalization($data, $format = null) */ public function supportsDenormalization($data, $type, $format = null) { + if (PHP_VERSION_ID < 50307) { + return class_exists($type) && in_array('Symfony\Component\Serializer\Normalizer\DenormalizableInterface', class_implements($type), true); + } + return is_subclass_of($type, 'Symfony\Component\Serializer\Normalizer\DenormalizableInterface'); } } diff --git a/src/Symfony/Component/Translation/Tests/TranslatorTest.php b/src/Symfony/Component/Translation/Tests/TranslatorTest.php index 32b01772b62cf..50ca9cf75dfcf 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorTest.php @@ -255,12 +255,12 @@ public function testFallbackCatalogueResources() $resources = $catalogues['en']->getResources(); $this->assertCount(1, $resources); - $this->assertContains( __DIR__.'/fixtures/resources.yml', $resources); + $this->assertContains( __DIR__.DIRECTORY_SEPARATOR.'fixtures'.DIRECTORY_SEPARATOR.'resources.yml', $resources); $resources = $catalogues['en_GB']->getResources(); $this->assertCount(2, $resources); - $this->assertContains( __DIR__.'/fixtures/empty.yml', $resources); - $this->assertContains( __DIR__.'/fixtures/resources.yml', $resources); + $this->assertContains( __DIR__.DIRECTORY_SEPARATOR.'fixtures'.DIRECTORY_SEPARATOR.'empty.yml', $resources); + $this->assertContains( __DIR__.DIRECTORY_SEPARATOR.'fixtures'.DIRECTORY_SEPARATOR.'resources.yml', $resources); } /** From 49031493eff0a5ff6e12aed23fc860171a1d703c Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 1 Feb 2016 21:47:29 +0100 Subject: [PATCH 136/226] Fix merge --- .../Component/Serializer/Normalizer/CustomNormalizer.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php index bc3d432de5a0e..e3f09a943613c 100644 --- a/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php @@ -59,10 +59,6 @@ public function supportsNormalization($data, $format = null) */ public function supportsDenormalization($data, $type, $format = null) { - if (PHP_VERSION_ID < 50307) { - return class_exists($type) && in_array('Symfony\Component\Serializer\Normalizer\DenormalizableInterface', class_implements($type), true); - } - return is_subclass_of($type, 'Symfony\Component\Serializer\Normalizer\DenormalizableInterface'); } } From e874754dee648e8cd00d3c03ed3d5d2e3e8129d4 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 2 Feb 2016 10:46:12 +0100 Subject: [PATCH 137/226] [Console] Add missing `@require` annotation in test --- .../Component/Console/Tests/Helper/QuestionHelperTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php index 5a7a80bfaf9d8..f0621006eb36e 100644 --- a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php @@ -351,6 +351,9 @@ public function testNoInteraction() $this->assertEquals('not yet', $dialog->ask($this->createInputInterfaceMock(false), $this->createOutputInterface(), $question)); } + /** + * @requires function mb_strwidth + */ public function testChoiceOutputFormattingQuestionForUtf8Keys() { $question = 'Lorem ipsum?'; From 90455dfe56542b0f57306e8d73a5e4600ab7660e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 1 Feb 2016 14:00:12 +0100 Subject: [PATCH 138/226] [Process] Fix transient tests for incremental outputs --- phpunit | 2 +- .../HttpFoundation/Tests/RequestTest.php | 2 +- .../Component/Process/Tests/ProcessTest.php | 116 ++++-------------- 3 files changed, 26 insertions(+), 94 deletions(-) diff --git a/phpunit b/phpunit index 0517719add9e6..dba1222189066 100755 --- a/phpunit +++ b/phpunit @@ -27,7 +27,7 @@ if ('phpdbg' === PHP_SAPI) { $PHP .= ' -qrr'; } -$COMPOSER = file_exists($COMPOSER = __DIR__.'/composer.phar') || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? `where.exe composer.phar` : `which composer.phar`)) +$COMPOSER = file_exists($COMPOSER = __DIR__.'/composer.phar') || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar`) : `which composer.phar`)) ? $PHP.' '.ProcessUtils::escapeArgument($COMPOSER) : 'composer'; diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index d601204231e98..4e20366938b63 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -1669,7 +1669,7 @@ public function testVeryLongHosts($host) $request = Request::create('/'); $request->headers->set('host', $host); $this->assertEquals($host, $request->getHost()); - $this->assertLessThan(1, microtime(true) - $start); + $this->assertLessThan(3, microtime(true) - $start); } /** diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 7fc370bf81f3b..14daf2c286aa4 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -290,56 +290,40 @@ public function testGetErrorOutput() $this->assertEquals(3, preg_match_all('/ERROR/', $p->getErrorOutput(), $matches)); } - public function testGetIncrementalErrorOutput() + /** + * @dataProvider provideIncrementalOutput + */ + public function testIncrementalOutput($getOutput, $getIncrementalOutput, $uri) { - // use a lock file to toggle between writing ("W") and reading ("R") the - // error stream - $lock = tempnam(sys_get_temp_dir(), get_class($this).'Lock'); - file_put_contents($lock, 'W'); + $lock = tempnam(sys_get_temp_dir(), __FUNCTION__); - $p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n = 0; while ($n < 3) { if (\'W\' === file_get_contents('.var_export($lock, true).')) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; file_put_contents('.var_export($lock, true).', \'R\'); } usleep(100); }'))); + $p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('file_put_contents($s = \''.$uri.'\', \'foo\'); flock(fopen('.var_export($lock, true).', \'r\'), LOCK_EX); file_put_contents($s, \'bar\');'))); - $p->start(); - while ($p->isRunning()) { - if ('R' === file_get_contents($lock)) { - $this->assertLessThanOrEqual(1, preg_match_all('/ERROR/', $p->getIncrementalErrorOutput(), $matches)); - file_put_contents($lock, 'W'); - } - usleep(100); - } - - unlink($lock); - } - - public function testGetEmptyIncrementalErrorOutput() - { - // use a lock file to toggle between writing ("W") and reading ("R") the - // output stream - $lock = tempnam(sys_get_temp_dir(), get_class($this).'Lock'); - file_put_contents($lock, 'W'); - - $p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n = 0; while ($n < 3) { if (\'W\' === file_get_contents('.var_export($lock, true).')) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; file_put_contents('.var_export($lock, true).', \'R\'); } usleep(100); }'))); + $h = fopen($lock, 'w'); + flock($h, LOCK_EX); $p->start(); - $shouldWrite = false; + foreach (array('foo', 'bar') as $s) { + while (false === strpos($p->$getOutput(), $s)) { + usleep(1000); + } - while ($p->isRunning()) { - if ('R' === file_get_contents($lock)) { - if (!$shouldWrite) { - $this->assertLessThanOrEqual(1, preg_match_all('/ERROR/', $p->getIncrementalOutput(), $matches)); - $shouldWrite = true; - } else { - $this->assertSame('', $p->getIncrementalOutput()); + $this->assertSame($s, $p->$getIncrementalOutput()); + $this->assertSame('', $p->$getIncrementalOutput()); - file_put_contents($lock, 'W'); - $shouldWrite = false; - } - } - usleep(100); + flock($h, LOCK_UN); } - unlink($lock); + fclose($h); + } + + public function provideIncrementalOutput() + { + return array( + array('getOutput', 'getIncrementalOutput', 'php://stdout'), + array('getErrorOutput', 'getIncrementalErrorOutput', 'php://stderr'), + ); } public function testGetOutput() @@ -350,58 +334,6 @@ public function testGetOutput() $this->assertEquals(3, preg_match_all('/foo/', $p->getOutput(), $matches)); } - public function testGetIncrementalOutput() - { - // use a lock file to toggle between writing ("W") and reading ("R") the - // output stream - $lock = tempnam(sys_get_temp_dir(), get_class($this).'Lock'); - file_put_contents($lock, 'W'); - - $p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n = 0; while ($n < 3) { if (\'W\' === file_get_contents('.var_export($lock, true).')) { echo \' foo \'; $n++; file_put_contents('.var_export($lock, true).', \'R\'); } usleep(100); }'))); - - $p->start(); - while ($p->isRunning()) { - if ('R' === file_get_contents($lock)) { - $this->assertLessThanOrEqual(1, preg_match_all('/foo/', $p->getIncrementalOutput(), $matches)); - file_put_contents($lock, 'W'); - } - usleep(100); - } - - unlink($lock); - } - - public function testGetEmptyIncrementalOutput() - { - // use a lock file to toggle between writing ("W") and reading ("R") the - // output stream - $lock = tempnam(sys_get_temp_dir(), get_class($this).'Lock'); - file_put_contents($lock, 'W'); - - $p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n = 0; while ($n < 3) { if (\'W\' === file_get_contents('.var_export($lock, true).')) { echo \' foo \'; $n++; file_put_contents('.var_export($lock, true).', \'R\'); } usleep(100); }'))); - - $p->start(); - - $shouldWrite = false; - - while ($p->isRunning()) { - if ('R' === file_get_contents($lock)) { - if (!$shouldWrite) { - $this->assertLessThanOrEqual(1, preg_match_all('/foo/', $p->getIncrementalOutput(), $matches)); - $shouldWrite = true; - } else { - $this->assertSame('', $p->getIncrementalOutput()); - - file_put_contents($lock, 'W'); - $shouldWrite = false; - } - } - usleep(100); - } - - unlink($lock); - } - public function testZeroAsOutput() { if ('\\' === DIRECTORY_SEPARATOR) { From c71840193ceaf37475bdc3d32e85e3fbbccef84e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 2 Feb 2016 15:23:07 +0100 Subject: [PATCH 139/226] changed operator from and to && --- .../Resources/views/Form/choice_widget_collapsed.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_collapsed.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_collapsed.html.php index 0e180577ffff8..0399e433929f0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_collapsed.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_collapsed.html.php @@ -7,7 +7,7 @@ )) ?> multiple="multiple" > - + 0): ?> block($form, 'choice_widget_options', array('choices' => $preferred_choices)) ?> 0 && null !== $separator): ?> From 13ae32376dcd57339682bfec3442907d6477634f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 2 Feb 2016 17:13:46 +0100 Subject: [PATCH 140/226] [travis] Add some comments --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index f62aa14901466..34423e84b4e59 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,9 @@ cache: services: mongodb before_install: + # Matrix lines for intermediate PHP versions are skipped for pull requests - if [[ ! $deps && ! $TRAVIS_PHP_VERSION = ${MIN_PHP%.*} && $TRAVIS_PHP_VERSION != hhvm && $TRAVIS_PULL_REQUEST != false ]]; then deps=skip; fi; + # A sigchild-enabled-PHP is used to test the Process component on the lowest PHP matrix line - if [[ ! $deps && $TRAVIS_PHP_VERSION = ${MIN_PHP%.*} && ! -d php-$MIN_PHP/sapi ]]; then wget http://museum.php.net/php5/php-$MIN_PHP.tar.bz2 -O - | tar -xj; (cd php-$MIN_PHP; ./configure --enable-sigchild --enable-pcntl; make -j2); fi; - if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then INI_FILE=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; else INI_FILE=/etc/hhvm/php.ini; fi; - echo memory_limit = -1 >> $INI_FILE @@ -50,9 +52,12 @@ before_install: install: - if [[ $deps != skip ]]; then COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); fi; + # Create local composer packages for each patched components and reference them in composer.json files when cross-testing components - if [[ $deps != skip && $deps ]]; then php .travis.php $TRAVIS_COMMIT_RANGE $TRAVIS_BRANCH $COMPONENTS; fi; + # For the master branch when deps=high, the version before master is checked out and tested with the locally patched components - if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then SYMFONY_VERSION=$(git ls-remote --heads | grep -o '/[1-9].*' | tail -n 1 | sed s/.//); else SYMFONY_VERSION=$(cat composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*'); fi; - if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then git fetch origin $SYMFONY_VERSION; git checkout -m FETCH_HEAD; COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); fi; + # Legacy tests are skipped when deps=high and when the current branch version has not the same major version number than the next one - if [[ $deps = high && ${SYMFONY_VERSION%.*} != $(git show $(git ls-remote --heads | grep -FA1 /$SYMFONY_VERSION | tail -n 1):composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9]*' | head -n 1) ]]; then LEGACY=,legacy; fi; - export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev; - if [[ ! $deps ]]; then composer update --prefer-dist; else export SYMFONY_DEPRECATIONS_HELPER=weak; fi; From a45e8bbc34d4d8cd0f8ff0ac5cb43c82dfb0fafd Mon Sep 17 00:00:00 2001 From: Hugo Hamon Date: Wed, 3 Feb 2016 14:12:30 +0200 Subject: [PATCH 141/226] [Routing] added a suggestion to add the HttpFoundation component. --- src/Symfony/Component/Routing/composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/Routing/composer.json b/src/Symfony/Component/Routing/composer.json index 5b0f24416f486..d7760343f0e07 100644 --- a/src/Symfony/Component/Routing/composer.json +++ b/src/Symfony/Component/Routing/composer.json @@ -31,6 +31,7 @@ "symfony/config": "<2.7" }, "suggest": { + "symfony/http-foundation": "For using a Symfony Request object", "symfony/config": "For using the all-in-one router or any loader", "symfony/yaml": "For using the YAML loader", "symfony/expression-language": "For using expression matching", From 0e45a4a5de7bc8e087da5db3d0d6640ab59c97de Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 3 Feb 2016 18:56:43 +0100 Subject: [PATCH 142/226] [Console] remove readline support --- src/Symfony/Component/Console/CHANGELOG.md | 5 ++++ .../Console/Helper/QuestionHelper.php | 30 ++++--------------- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/src/Symfony/Component/Console/CHANGELOG.md b/src/Symfony/Component/Console/CHANGELOG.md index 4e29d2ed4517d..8021068edfb13 100644 --- a/src/Symfony/Component/Console/CHANGELOG.md +++ b/src/Symfony/Component/Console/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +2.8.3 +----- + + * remove readline support from the question helper as it caused issues + 2.8.0 ----- diff --git a/src/Symfony/Component/Console/Helper/QuestionHelper.php b/src/Symfony/Component/Console/Helper/QuestionHelper.php index a09a56c239e89..5bb30df8ad059 100644 --- a/src/Symfony/Component/Console/Helper/QuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/QuestionHelper.php @@ -134,7 +134,11 @@ public function doAsk(OutputInterface $output, Question $question) } if (false === $ret) { - $ret = $this->readFromInput($inputStream); + $ret = fgets($inputStream, 4096); + if (false === $ret) { + throw new \RuntimeException('Aborted'); + } + $ret = trim($ret); } } else { $ret = trim($this->autocomplete($output, $question, $inputStream)); @@ -427,30 +431,6 @@ private function getShell() return self::$shell; } - /** - * Reads user input. - * - * @param resource $stream The input stream - * - * @return string User input - * - * @throws RuntimeException - */ - private function readFromInput($stream) - { - if (STDIN === $stream && function_exists('readline')) { - $ret = readline(''); - } else { - $ret = fgets($stream, 4096); - } - - if (false === $ret) { - throw new RuntimeException('Aborted'); - } - - return trim($ret); - } - /** * Returns whether Stty is available or not. * From 4f865c758ae5c4fc1c320a032c7b7e008418e34c Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 3 Feb 2016 18:21:36 +0100 Subject: [PATCH 143/226] add files used in FileResource objects Starting with Symfony 3.1, the constructor of the `FileResource` class will throw an exception when the passed file does not exist. --- .../Component/DependencyInjection/ContainerBuilder.php | 4 +++- src/Symfony/Component/Routing/Tests/Fixtures/bar.xml | 0 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Component/Routing/Tests/Fixtures/bar.xml diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 6c52c47b651a9..3a72208c3e3b8 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -243,7 +243,9 @@ public function addClassResource(\ReflectionClass $class) } do { - $this->addResource(new FileResource($class->getFileName())); + if (is_file($class->getFileName())) { + $this->addResource(new FileResource($class->getFileName())); + } } while ($class = $class->getParentClass()); return $this; diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/bar.xml b/src/Symfony/Component/Routing/Tests/Fixtures/bar.xml new file mode 100644 index 0000000000000..e69de29bb2d1d From 73afd0f0e7205349aac91e23a4db2be32a914e0d Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 3 Feb 2016 18:21:36 +0100 Subject: [PATCH 144/226] add files used in FileResource objects Starting with Symfony 3.1, the constructor of the `FileResource` class will throw an exception when the passed file does not exist. --- .../Routing/Loader/ObjectRouteLoader.php | 4 ++- .../Routing/Tests/Fixtures/file_resource.yml | 0 .../Tests/Loader/ObjectRouteLoaderTest.php | 26 ++++++++++++------- .../Tests/RouteCollectionBuilderTest.php | 2 +- 4 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 src/Symfony/Component/Routing/Tests/Fixtures/file_resource.yml diff --git a/src/Symfony/Component/Routing/Loader/ObjectRouteLoader.php b/src/Symfony/Component/Routing/Loader/ObjectRouteLoader.php index 65d0ce36fa24b..4d79b6cfc3640 100644 --- a/src/Symfony/Component/Routing/Loader/ObjectRouteLoader.php +++ b/src/Symfony/Component/Routing/Loader/ObjectRouteLoader.php @@ -87,7 +87,9 @@ public function supports($resource, $type = null) private function addClassResource(\ReflectionClass $class, RouteCollection $collection) { do { - $collection->addResource(new FileResource($class->getFileName())); + if (is_file($class->getFileName())) { + $collection->addResource(new FileResource($class->getFileName())); + } } while ($class = $class->getParentClass()); } } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/file_resource.yml b/src/Symfony/Component/Routing/Tests/Fixtures/file_resource.yml new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php index 0fbd14fa0a00c..50b8d8ff992e5 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php @@ -25,17 +25,8 @@ public function testLoadCallsServiceAndReturnsCollection() $collection = new RouteCollection(); $collection->add('foo', new Route('/foo')); - // create some callable object - $service = $this->getMockBuilder('stdClass') - ->setMethods(array('loadRoutes')) - ->getMock(); - $service->expects($this->once()) - ->method('loadRoutes') - ->with($loader) - ->will($this->returnValue($collection)); - $loader->loaderMap = array( - 'my_route_provider_service' => $service, + 'my_route_provider_service' => new RouteService($collection), ); $actualRoutes = $loader->load( @@ -114,3 +105,18 @@ protected function getServiceObject($id) return isset($this->loaderMap[$id]) ? $this->loaderMap[$id] : null; } } + +class RouteService +{ + private $collection; + + public function __construct($collection) + { + $this->collection = $collection; + } + + public function loadRoutes() + { + return $this->collection; + } +} diff --git a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php index e3a98e3b72698..b944ffe80805e 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php @@ -30,7 +30,7 @@ public function testImport() $originalRoute = new Route('/foo/path'); $expectedCollection = new RouteCollection(); $expectedCollection->add('one_test_route', $originalRoute); - $expectedCollection->addResource(new FileResource('file_resource.yml')); + $expectedCollection->addResource(new FileResource(__DIR__.'/Fixtures/file_resource.yml')); $resolvedLoader ->expects($this->once()) From 1d4ea395126b91e68b23a036ea5c49235540049b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 4 Feb 2016 15:18:20 +0100 Subject: [PATCH 145/226] [appveyor] Ignore failures due to STATUS_ACCESS_VIOLATION errors --- phpunit | 4 ++-- .../Component/Config/Tests/Resource/DirectoryResourceTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/phpunit b/phpunit index dba1222189066..9cf03f071ecbf 100755 --- a/phpunit +++ b/phpunit @@ -160,8 +160,8 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) { unlink($file); } - // Fail on any individual component failures but ignore STATUS_STACK_BUFFER_OVERRUN (-1073740791) on Windows when APCu is enabled - if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !ini_get('apc.enable_cli') || -1073740791 !== $procStatus)) { + // Fail on any individual component failures but ignore STATUS_STACK_BUFFER_OVERRUN (-1073740791/0xC0000409) and STATUS_ACCESS_VIOLATION (-1073741819/0xC0000005) on Windows when APCu is enabled + if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !ini_get('apc.enable_cli') || (-1073740791 !== $procStatus && -1073741819 !== $procStatus))) { $exit = $procStatus; echo "\033[41mKO\033[0m $component\n\n"; } else { diff --git a/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php b/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php index 2bbaadc3a721e..0e64b4ce80917 100644 --- a/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php +++ b/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php @@ -19,7 +19,7 @@ class DirectoryResourceTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->directory = sys_get_temp_dir().'/symfonyDirectoryIterator'; + $this->directory = sys_get_temp_dir().DIRECTORY_SEPARATOR.'symfonyDirectoryIterator'; if (!file_exists($this->directory)) { mkdir($this->directory); } From 047c1953d2c9f2005b367a27ad403c9ee3be64ab Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 5 Feb 2016 10:56:37 +0100 Subject: [PATCH 146/226] [TwigBridge] forward compatibility with Yaml 3.1 --- src/Symfony/Bridge/Twig/Extension/YamlExtension.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Bridge/Twig/Extension/YamlExtension.php b/src/Symfony/Bridge/Twig/Extension/YamlExtension.php index fc9bf0e9e3308..7d330c4b8985e 100644 --- a/src/Symfony/Bridge/Twig/Extension/YamlExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/YamlExtension.php @@ -39,6 +39,10 @@ public function encode($input, $inline = 0, $dumpObjects = false) $dumper = new YamlDumper(); } + if (defined('Symfony\Component\Yaml\Yaml::DUMP_OBJECT')) { + $dumpObjects = (int) $dumpObjects; + } + return $dumper->dump($input, $inline, 0, false, $dumpObjects); } From 2419725cbb7ca0d6ddc59feeee93014a02a4bc5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Fri, 5 Feb 2016 11:56:40 +0100 Subject: [PATCH 147/226] [FrameworkBundle] Support autowiring for TranslationInterface --- .../Bundle/FrameworkBundle/Resources/config/translation.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/translation.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/translation.xml index ff4c18f212f2d..ea85f517aa399 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/translation.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/translation.xml @@ -48,6 +48,8 @@ + + Symfony\Component\Translation\TranslatorInterface From 0ba88c2a448fcb39bc44cbd227c4148542806a82 Mon Sep 17 00:00:00 2001 From: Alexandre Pavy Date: Mon, 8 Feb 2016 14:53:19 +0100 Subject: [PATCH 148/226] Add width attribute on SVG Fix Debug Toolbar on microsoft Edge --- .../Bundle/DebugBundle/Resources/views/Profiler/icon.svg | 2 +- .../Bundle/SecurityBundle/Resources/views/Collector/icon.svg | 2 +- .../Bundle/WebProfilerBundle/Resources/views/Icon/ajax.svg | 2 +- .../Bundle/WebProfilerBundle/Resources/views/Icon/close.svg | 2 +- .../Bundle/WebProfilerBundle/Resources/views/Icon/config.svg | 2 +- .../Bundle/WebProfilerBundle/Resources/views/Icon/event.svg | 2 +- .../Bundle/WebProfilerBundle/Resources/views/Icon/exception.svg | 2 +- .../Bundle/WebProfilerBundle/Resources/views/Icon/form.svg | 2 +- .../Bundle/WebProfilerBundle/Resources/views/Icon/logger.svg | 2 +- .../Bundle/WebProfilerBundle/Resources/views/Icon/memory.svg | 2 +- .../Bundle/WebProfilerBundle/Resources/views/Icon/menu.svg | 2 +- .../Bundle/WebProfilerBundle/Resources/views/Icon/no.svg | 2 +- .../Bundle/WebProfilerBundle/Resources/views/Icon/request.svg | 2 +- .../Bundle/WebProfilerBundle/Resources/views/Icon/router.svg | 2 +- .../Bundle/WebProfilerBundle/Resources/views/Icon/time.svg | 2 +- .../WebProfilerBundle/Resources/views/Icon/translation.svg | 2 +- .../Bundle/WebProfilerBundle/Resources/views/Icon/twig.svg | 2 +- .../Bundle/WebProfilerBundle/Resources/views/Icon/yes.svg | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Symfony/Bundle/DebugBundle/Resources/views/Profiler/icon.svg b/src/Symfony/Bundle/DebugBundle/Resources/views/Profiler/icon.svg index 2f7e708c8b3d4..ac4ead8fbbf0f 100644 --- a/src/Symfony/Bundle/DebugBundle/Resources/views/Profiler/icon.svg +++ b/src/Symfony/Bundle/DebugBundle/Resources/views/Profiler/icon.svg @@ -1,4 +1,4 @@ - + diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/icon.svg b/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/icon.svg index 02033fdc7f5e9..5bd2f3b8f3799 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/icon.svg +++ b/src/Symfony/Bundle/SecurityBundle/Resources/views/Collector/icon.svg @@ -1,3 +1,3 @@ - + diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/ajax.svg b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/ajax.svg index d8cad847d4710..bd878c3c6c21f 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/ajax.svg +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/ajax.svg @@ -1,4 +1,4 @@ - + + diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/config.svg b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/config.svg index 9bafe3830175f..a407719e8c761 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/config.svg +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/config.svg @@ -1,3 +1,3 @@ - + diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/event.svg b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/event.svg index 7d15a66f01033..898117ef94558 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/event.svg +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/event.svg @@ -1,4 +1,4 @@ - + + + + + diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/menu.svg b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/menu.svg index 856ea09ff85cb..51870801cf284 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/menu.svg +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/menu.svg @@ -1,3 +1,3 @@ - + diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/no.svg b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/no.svg index 02eb4e9c6abbb..c0bb768d40433 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/no.svg +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/no.svg @@ -1,4 +1,4 @@ - + diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/request.svg b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/request.svg index d74a72850dc04..68b092c6b8809 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/request.svg +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/request.svg @@ -1,4 +1,4 @@ - + + + diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/translation.svg b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/translation.svg index 93d42327ed859..b7aa1249304b2 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/translation.svg +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/translation.svg @@ -1,4 +1,4 @@ - + + diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/yes.svg b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/yes.svg index 0f129bffc21b0..da650231d520d 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/yes.svg +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Icon/yes.svg @@ -1,4 +1,4 @@ - + From f5daa0dea9df5e62e481cdbbb2f29cb027b2e1a3 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 9 Feb 2016 22:08:46 +0100 Subject: [PATCH 149/226] Added more exceptions to singularify method --- src/Symfony/Component/PropertyAccess/StringUtil.php | 9 +++++++++ .../Component/PropertyAccess/Tests/StringUtilTest.php | 3 +++ 2 files changed, 12 insertions(+) diff --git a/src/Symfony/Component/PropertyAccess/StringUtil.php b/src/Symfony/Component/PropertyAccess/StringUtil.php index 2f31925e73367..248a6483d8b0a 100644 --- a/src/Symfony/Component/PropertyAccess/StringUtil.php +++ b/src/Symfony/Component/PropertyAccess/StringUtil.php @@ -39,6 +39,9 @@ class StringUtil // nebulae (nebula) array('ea', 2, true, true, 'a'), + // services (service) + array('secivres', 8, true, true, 'service'), + // mice (mouse), lice (louse) array('eci', 3, false, true, 'ouse'), @@ -66,6 +69,12 @@ class StringUtil // movies (movie) array('seivom', 6, true, true, 'movie'), + // news (news) + array('swen', 4, true, true, 'news'), + + // series (series) + array('seires', 6, true, true, 'series'), + // babies (baby) array('sei', 3, false, true, 'y'), diff --git a/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php b/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php index c5691ed7bdc5b..0fd6bb69b2956 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php @@ -102,6 +102,7 @@ public function singularifyProvider() array('movies', 'movie'), array('nebulae', 'nebula'), array('neuroses', array('neuros', 'neurose', 'neurosis')), + array('news', 'news'), array('oases', array('oas', 'oase', 'oasis')), array('objectives', 'objective'), array('oxen', 'ox'), @@ -120,6 +121,8 @@ public function singularifyProvider() array('scarves', array('scarf', 'scarve', 'scarff')), array('schemas', 'schema'), //schemata array('selfies', 'selfie'), + array('series', 'series'), + array('services', 'service'), array('sheriffs', 'sheriff'), array('shoes', array('sho', 'shoe')), array('spies', 'spy'), From 89133e6a71f3978328ca78603d727df863007803 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Wed, 10 Feb 2016 10:18:08 +0000 Subject: [PATCH 150/226] [FrameworkBundle] Fix a typo --- .../Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index 54f65588d26dd..03f058dddcca1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -44,7 +44,7 @@ protected function configure() )) ->setDescription('Updates the translation file') ->setHelp(<<<'EOF' -The %command.name% command extract translation strings from templates +The %command.name% command extracts 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 message. From 3d7f6c69c252030ff9f90b42c2d6b49539ff06cc Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Wed, 10 Feb 2016 13:25:51 +0000 Subject: [PATCH 151/226] [DomCrawler] Remove the overridden getHash() method to prevent problems when cloning the crawler Overriding the SplObjectStorage::getHash() is affected by a PHP bug (https://bugs.php.net/bug.php?id=67582), which makes the Crawler unusable in Symfony 2.8 for anyone who relied on SplObjectStorage methods. Removing the getHash() method means we will no longer trigger the deprecation error. Given this method is unlikely to be used directly and other SplObjectStorage methods will trigger the error, it is the simplest thing we can do to maintain BC. --- src/Symfony/Component/DomCrawler/Crawler.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 66f93721af99e..c6d328e569e8b 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -950,16 +950,6 @@ public function offsetGet($object) return parent::offsetGet($object); } - /** - * @deprecated Using the SplObjectStorage API on the Crawler is deprecated as of 2.8 and will be removed in 3.0. - */ - public function getHash($object) - { - $this->triggerDeprecation(__METHOD__, true); - - return parent::getHash($object); - } - /** * Filters the list of nodes with an XPath expression. * From 120dfe48a612a64832acb5137af69efa9209917f Mon Sep 17 00:00:00 2001 From: possum Date: Wed, 10 Feb 2016 20:09:02 +0100 Subject: [PATCH 152/226] sendContent return as parent. --- .../HttpFoundation/BinaryFileResponse.php | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index d20880fceb2cd..d5b1c34bf4b3c 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -27,6 +27,9 @@ class BinaryFileResponse extends Response { protected static $trustXSendfileTypeHeader = false; + /** + * @var File + */ protected $file; protected $offset; protected $maxlen; @@ -179,7 +182,7 @@ public function prepare(Request $request) $this->headers->set('Content-Type', $this->file->getMimeType() ?: 'application/octet-stream'); } - if ('HTTP/1.0' != $request->server->get('SERVER_PROTOCOL')) { + if ('HTTP/1.0' !== $request->server->get('SERVER_PROTOCOL')) { $this->setProtocolVersion('1.1'); } @@ -196,17 +199,17 @@ public function prepare(Request $request) if (false === $path) { $path = $this->file->getPathname(); } - if (strtolower($type) == 'x-accel-redirect') { + if (strtolower($type) === 'x-accel-redirect') { // Do X-Accel-Mapping substitutions. // @link http://wiki.nginx.org/X-accel#X-Accel-Redirect foreach (explode(',', $request->headers->get('X-Accel-Mapping', '')) as $mapping) { $mapping = explode('=', $mapping, 2); - if (2 == count($mapping)) { + if (2 === count($mapping)) { $pathPrefix = trim($mapping[0]); $location = trim($mapping[1]); - if (substr($path, 0, strlen($pathPrefix)) == $pathPrefix) { + if (substr($path, 0, strlen($pathPrefix)) === $pathPrefix) { $path = $location.substr($path, strlen($pathPrefix)); break; } @@ -217,7 +220,7 @@ public function prepare(Request $request) $this->maxlen = 0; } elseif ($request->headers->has('Range')) { // Process the range headers. - if (!$request->headers->has('If-Range') || $this->getEtag() == $request->headers->get('If-Range')) { + if (!$request->headers->has('If-Range') || $this->getEtag() === $request->headers->get('If-Range')) { $range = $request->headers->get('Range'); $fileSize = $this->file->getSize(); @@ -252,17 +255,17 @@ public function prepare(Request $request) /** * Sends the file. + * + * {@inheritdoc} */ public function sendContent() { if (!$this->isSuccessful()) { - parent::sendContent(); - - return; + return parent::sendContent(); } if (0 === $this->maxlen) { - return; + return $this; } $out = fopen('php://output', 'wb'); @@ -272,6 +275,8 @@ public function sendContent() fclose($out); fclose($file); + + return $this; } /** From 2336d5c466325c41b3992d8d3eb0e26d2c4230fa Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Thu, 4 Feb 2016 21:56:26 +0100 Subject: [PATCH 153/226] fix choice_value option in EntityType and add some tests --- .../Form/ChoiceList/DoctrineChoiceLoader.php | 2 +- .../Tests/Form/Type/EntityTypeTest.php | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php index 1a09609b28556..2dc8c2cb2b28d 100644 --- a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php +++ b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php @@ -146,7 +146,7 @@ public function loadChoicesForValues(array $values, $value = null) // Optimize performance in case we have an object loader and // a single-field identifier - if (!$this->choiceList && $this->objectLoader && $this->idReader->isSingleId()) { + if (null === $value && !$this->choiceList && $this->objectLoader && $this->idReader->isSingleId()) { $unorderedObjects = $this->objectLoader->getEntitiesByIds($this->idReader->getIdField(), $values); $objectsById = array(); $objects = array(); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php index c5cdc60bbd342..c9ea820d95e97 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php @@ -740,6 +740,55 @@ public function testOverrideChoices() $this->assertSame('2', $field->getViewData()); } + public function testOverrideChoicesValues() + { + $entity1 = new SingleIntIdEntity(1, 'Foo'); + $entity2 = new SingleIntIdEntity(2, 'Bar'); + + $this->persist(array($entity1, $entity2)); + + $field = $this->factory->createNamed('name', 'entity', null, array( + 'em' => 'default', + 'class' => self::SINGLE_IDENT_CLASS, + 'choice_label' => 'name', + 'choice_value' => 'name', + )); + + $field->submit('Bar'); + + $this->assertEquals(array('Foo' => new ChoiceView($entity1, 'Foo', 'Foo'), 'Bar' => new ChoiceView($entity2, 'Bar', 'Bar')), $field->createView()->vars['choices']); + $this->assertTrue($field->isSynchronized(), 'Field should be synchronized.'); + $this->assertSame($entity2, $field->getData(), 'Entity should be loaded by custom value.'); + $this->assertSame('Bar', $field->getViewData()); + } + + public function testOverrideChoicesValuesWithCallable() + { + $entity1 = new GroupableEntity(1, 'Foo', 'BazGroup'); + $entity2 = new GroupableEntity(2, 'Bar', 'BooGroup'); + + $this->persist(array($entity1, $entity2)); + + $field = $this->factory->createNamed('name', 'entity', null, array( + 'em' => 'default', + 'class' => self::ITEM_GROUP_CLASS, + 'choice_label' => 'name', + 'choice_value' => function (GroupableEntity $entity) { + return $entity->groupName.'/'.$entity->name; + }, + )); + + $field->submit('BooGroup/Bar'); + + $this->assertEquals(array( + 'BazGroup/Foo' => new ChoiceView($entity1, 'BazGroup/Foo', 'Foo'), + 'BooGroup/Bar' => new ChoiceView($entity2, 'BooGroup/Bar', 'Bar'), + ), $field->createView()->vars['choices']); + $this->assertTrue($field->isSynchronized(), 'Field should be synchronized.'); + $this->assertSame($entity2, $field->getData(), 'Entity should be loaded by custom value.'); + $this->assertSame('BooGroup/Bar', $field->getViewData()); + } + public function testGroupByChoices() { $item1 = new GroupableEntity(1, 'Foo', 'Group1'); From bb29979218df0a10c778b5e342b342edd1677f2c Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Thu, 11 Feb 2016 09:15:16 -0500 Subject: [PATCH 154/226] avoid (string) catchable fatal error for __PHP_Incomplete_Class instances --- .../HttpKernel/DataCollector/DataCollector.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php index 94e6541c91154..e3a2d9fe11083 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php @@ -45,6 +45,10 @@ protected function varToString($var) return sprintf('Object(%s)', get_class($var)); } + if ($var instanceof \__PHP_Incomplete_Class) { + return sprintf('__PHP_Incomplete_Class(%s)', $this->getClassNameFromIncomplete($var)); + } + if (is_array($var)) { $a = array(); foreach ($var as $k => $v) { @@ -72,4 +76,11 @@ protected function varToString($var) return (string) $var; } + + private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $var) + { + $array = new \ArrayObject($var); + + return $array['__PHP_Incomplete_Class_Name']; + } } From 0a5df6f11aad8a6b2c0cbdac92bf6f79f84f00f1 Mon Sep 17 00:00:00 2001 From: Thomas Lallement Date: Thu, 11 Feb 2016 16:57:09 +0100 Subject: [PATCH 155/226] Update validators.fr.xlf --- .../Validator/Resources/translations/validators.fr.xlf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf index b50ecbc63a1b5..72d4d92973fdc 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf @@ -310,6 +310,10 @@ This value does not match the expected {{ charset }} charset. Cette valeur ne correspond pas au jeu de caractères {{ charset }} attendu. + + This is not a valid Business Identifier Code (BIC). + Ce n'est pas un code universel d'identification des banques (BIC) valide. + From ea52400097caf540745eb293c9ad78722e8a5add Mon Sep 17 00:00:00 2001 From: Trent Steel Date: Thu, 11 Feb 2016 21:12:43 +1000 Subject: [PATCH 156/226] remove unnecessary retrieval and setting of data --- .../Extension/Csrf/EventListener/CsrfValidationListener.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php b/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php index a800fc48d92c5..91871a828647e 100644 --- a/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php +++ b/src/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php @@ -84,9 +84,10 @@ public function __construct($fieldName, CsrfProviderInterface $csrfProvider, $in public function preSubmit(FormEvent $event) { $form = $event->getForm(); - $data = $event->getData(); if ($form->isRoot() && $form->getConfig()->getOption('compound')) { + $data = $event->getData(); + if (!isset($data[$this->fieldName]) || !$this->csrfProvider->isCsrfTokenValid($this->intention, $data[$this->fieldName])) { $errorMessage = $this->errorMessage; @@ -99,10 +100,9 @@ public function preSubmit(FormEvent $event) if (is_array($data)) { unset($data[$this->fieldName]); + $event->setData($data); } } - - $event->setData($data); } /** From 4b7ed987dd56066a9bf0d0b018ff1aea396088e2 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Thu, 4 Feb 2016 15:06:04 -0500 Subject: [PATCH 157/226] avoid (string) catchable fatal error for instances of __PHP_Incomplete_Class --- .../HttpKernel/DataCollector/Util/ValueExporter.php | 11 +++++++++++ .../Tests/DataCollector/Util/ValueExporterTest.php | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php b/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php index d2f0898605968..c9e51cc26ff12 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php @@ -35,6 +35,10 @@ public function exportValue($value, $depth = 1, $deep = false) return sprintf('Object(%s)', get_class($value)); } + if ($value instanceof \__PHP_Incomplete_Class) { + return sprintf('__PHP_Incomplete_Class(%s)', $this->getClassNameFromIncomplete($value)); + } + if (is_array($value)) { if (empty($value)) { return '[]'; @@ -75,4 +79,11 @@ public function exportValue($value, $depth = 1, $deep = false) return (string) $value; } + + private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value) + { + $array = new \ArrayObject($value); + + return $array['__PHP_Incomplete_Class_Name']; + } } diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/Util/ValueExporterTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/Util/ValueExporterTest.php index 2f2bb972da921..4bfa944f8a7e9 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/Util/ValueExporterTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/Util/ValueExporterTest.php @@ -39,4 +39,12 @@ public function testDateTimeImmutable() $dateTime = new \DateTimeImmutable('2014-06-10 07:35:40', new \DateTimeZone('UTC')); $this->assertSame('Object(DateTimeImmutable) - 2014-06-10T07:35:40+0000', $this->valueExporter->exportValue($dateTime)); } + + public function testIncompleteClass() + { + $foo = new \__PHP_Incomplete_Class(); + $array = new \ArrayObject($foo); + $array['__PHP_Incomplete_Class_Name'] = 'AppBundle/Foo'; + $this->assertSame('__PHP_Incomplete_Class(AppBundle/Foo)', $this->valueExporter->exportValue($foo)); + } } From be85d16940498946ead95e69ecbae46157b45adb Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Tue, 9 Feb 2016 20:58:01 +0100 Subject: [PATCH 158/226] [DependencyInjection] Fix #16461 Let Container::set() replace existing aliases `Container::set()` now overrides any previously alias defined with the same name. --- .../Component/DependencyInjection/Container.php | 4 ++++ .../DependencyInjection/Tests/ContainerBuilderTest.php | 10 ++++++++++ .../DependencyInjection/Tests/ContainerTest.php | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index 75de9c4fde03e..effa128eaaf10 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -200,6 +200,10 @@ public function set($id, $service, $scope = self::SCOPE_CONTAINER) $this->scopedServices[$scope][$id] = $service; } + if (isset($this->aliases[$id])) { + unset($this->aliases[$id]); + } + $this->services[$id] = $service; if (method_exists($this, $method = 'synchronize'.strtr($id, $this->underscoreMap).'Service')) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index 3a369d9d2ed18..183653673506b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -217,6 +217,16 @@ public function testAddAliases() $this->assertTrue(isset($aliases['foobar'])); } + public function testSetReplacesAlias() + { + $builder = new ContainerBuilder(); + $builder->setAlias('alias', 'aliased'); + $builder->set('aliased', new \stdClass()); + + $builder->set('alias', $foo = new \stdClass()); + $this->assertSame($foo, $builder->get('alias'), '->set() replaces an existing alias'); + } + public function testAddGetCompilerPass() { $builder = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php index 5acc3c3b842e2..e5cce945ec71f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php @@ -152,6 +152,14 @@ public function testSetAlsoSetsScopedService() $this->assertSame($foo, $services['foo']['foo']); } + public function testSetReplacesAlias() + { + $c = new ProjectServiceContainer(); + + $c->set('alias', $foo = new \stdClass()); + $this->assertSame($foo, $c->get('alias'), '->set() replaces an existing alias'); + } + public function testGet() { $sc = new ProjectServiceContainer(); From a694401e350cfcb3df9934d408c93fe3fd6da9dd Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Fri, 12 Feb 2016 10:02:25 +0000 Subject: [PATCH 159/226] [DomCrawler] Clarify the value returned by getPhpFiles() The comment was previously suggesting the returned value is similar to the one stored in $_FILES, while it is more similar to the way PHP stores submitted form values. It is actually more convenient to have it this way, so rather then changing the returned value (which would break BC), it is better to clarify the comment. --- src/Symfony/Component/DomCrawler/Form.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php index 4087788540114..3a16242fe9e7c 100644 --- a/src/Symfony/Component/DomCrawler/Form.php +++ b/src/Symfony/Component/DomCrawler/Form.php @@ -157,8 +157,12 @@ public function getPhpValues() * * This method converts fields with the array notation * (like foo[bar] to arrays) like PHP does. + * The returned array is consistent with the array for field values + * (@see getPhpValues), rather than uploaded files found in $_FILES. + * For a compound file field foo[bar] it will create foo[bar][name], + * instead of foo[name][bar] which would be found in $_FILES. * - * @return array An array of field values. + * @return array An array of file field values. */ public function getPhpFiles() { From 5d433cab96c973b9a1a4ec20edfdcc7360d32799 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 12 Feb 2016 18:39:33 +0100 Subject: [PATCH 160/226] [VarDumper] Fix tests on PHP 7 --- .../Component/VarDumper/Tests/CliDumperTest.php | 14 ++++---------- .../Component/VarDumper/Tests/HtmlDumperTest.php | 7 ++----- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php b/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php index 3e19dc6f2e094..8893b6b8d05ae 100644 --- a/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php +++ b/src/Symfony/Component/VarDumper/Tests/CliDumperTest.php @@ -69,15 +69,12 @@ class: "Symfony\Component\VarDumper\Tests\CliDumperTest" 7 => b"é\\x00" "[]" => [] "res" => stream resource {@{$res} - wrapper_type: "plainfile" +%A wrapper_type: "plainfile" stream_type: "STDIO" mode: "r" unread_bytes: 0 seekable: true - timed_out: false - blocked: true - eof: false - options: [] +%A options: [] } "obj" => Symfony\Component\VarDumper\Tests\Fixture\DumbFoo {#%d +foo: "foo" @@ -197,16 +194,13 @@ public function testThrowingCaster() $this->assertStringMatchesFormat( <<7 => b"é\\x00" "[]" => [] "res" => stream resource @{$res} - wrapper_type: "plainfile" +%A wrapper_type: "plainfile" stream_type: "STDIO" mode: "r" unread_bytes: 0 seekable: true - timed_out: false - blocked: true - eof: false - options: [] +%A options: [] } "obj" => DumbFoo {#%d +foo: "foo" From e9111e4ef1c09959fe266d6ea911d3a004dd6c73 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Sat, 13 Feb 2016 11:44:39 +0100 Subject: [PATCH 161/226] [Config] Fix EnumNodeDefinition to allow building enum nodes with one element --- .../Definition/Builder/EnumNodeDefinition.php | 4 +-- .../Builder/EnumNodeDefinitionTest.php | 28 +++++++++++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php index dc25fcbd26f26..5d3ff014f1823 100644 --- a/src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php @@ -31,8 +31,8 @@ public function values(array $values) { $values = array_unique($values); - if (count($values) <= 1) { - throw new \InvalidArgumentException('->values() must be called with at least two distinct values.'); + if (empty($values)) { + throw new \InvalidArgumentException('->values() must be called with at least one value.'); } $this->values = $values; diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/EnumNodeDefinitionTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/EnumNodeDefinitionTest.php index 69f7fcfb22e9a..8d7ab2f7f03e9 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/EnumNodeDefinitionTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/EnumNodeDefinitionTest.php @@ -15,14 +15,22 @@ class EnumNodeDefinitionTest extends \PHPUnit_Framework_TestCase { - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage ->values() must be called with at least two distinct values. - */ - public function testNoDistinctValues() + public function testWithOneValue() + { + $def = new EnumNodeDefinition('foo'); + $def->values(array('foo')); + + $node = $def->getNode(); + $this->assertEquals(array('foo'), $node->getValues()); + } + + public function testWithOneDistinctValue() { $def = new EnumNodeDefinition('foo'); $def->values(array('foo', 'foo')); + + $node = $def->getNode(); + $this->assertEquals(array('foo'), $node->getValues()); } /** @@ -35,6 +43,16 @@ public function testNoValuesPassed() $def->getNode(); } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage ->values() must be called with at least one value. + */ + public function testWithNoValues() + { + $def = new EnumNodeDefinition('foo'); + $def->values(array()); + } + public function testGetNode() { $def = new EnumNodeDefinition('foo'); From 0efbc30304113b987aced8f11e2d102b816a740c Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Sat, 13 Feb 2016 05:58:41 +0100 Subject: [PATCH 162/226] [Form] fix edge cases with choice placeholder --- .../views/Form/form_div_layout.html.twig | 2 +- .../Form/choice_widget_collapsed.html.php | 2 +- .../Factory/DefaultChoiceListFactory.php | 2 +- .../Form/ChoiceList/View/ChoiceListView.php | 20 ++++++++++++++++++ .../Form/Extension/Core/Type/ChoiceType.php | 5 ++++- .../Tests/AbstractBootstrap3LayoutTest.php | 21 +++++++++++++++++++ .../Form/Tests/AbstractLayoutTest.php | 21 +++++++++++++++++++ .../Extension/Core/Type/ChoiceTypeTest.php | 8 +++---- 8 files changed, 73 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig index e3a611c38ffc7..ae5d7fbed4a4a 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig @@ -52,7 +52,7 @@ {%- endblock choice_widget_expanded -%} {%- block choice_widget_collapsed -%} - {%- if required and placeholder is none and not placeholder_in_choices and not multiple -%} + {%- if required and placeholder is none and not placeholder_in_choices and not multiple and (attr.size is not defined or attr.size <= 1) -%} {% set required = false %} {%- endif -%} block($form, 'widget_attributes', array( diff --git a/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php b/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php index ef93ffdd76336..8cd8e29259aa2 100644 --- a/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php +++ b/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php @@ -246,7 +246,7 @@ private static function addChoiceViewGroupedBy($groupBy, $choice, $value, $label $groupLabel = (string) $groupLabel; - // Initialize the group views if necessary. Unnnecessarily built group + // Initialize the group views if necessary. Unnecessarily built group // views will be cleaned up at the end of createView() if (!isset($preferredViews[$groupLabel])) { $preferredViews[$groupLabel] = new ChoiceGroupView($groupLabel); diff --git a/src/Symfony/Component/Form/ChoiceList/View/ChoiceListView.php b/src/Symfony/Component/Form/ChoiceList/View/ChoiceListView.php index 9641f4b1d9435..99308b826f7a5 100644 --- a/src/Symfony/Component/Form/ChoiceList/View/ChoiceListView.php +++ b/src/Symfony/Component/Form/ChoiceList/View/ChoiceListView.php @@ -48,4 +48,24 @@ public function __construct(array $choices = array(), array $preferredChoices = $this->choices = $choices; $this->preferredChoices = $preferredChoices; } + + /** + * Returns whether a placeholder is in the choices. + * + * A placeholder must be the first child element, not be in a group and have an empty value. + * + * @return bool + */ + public function hasPlaceholder() + { + if ($this->preferredChoices) { + $firstChoice = reset($this->preferredChoices); + + return $firstChoice instanceof ChoiceView && '' === $firstChoice->value; + } + + $firstChoice = reset($this->choices); + + return $firstChoice instanceof ChoiceView && '' === $firstChoice->value; + } } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index 58832ab2f8e06..d8d1a8f57e3fe 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -199,7 +199,7 @@ public function buildView(FormView $view, FormInterface $form, array $options) } // Check if the choices already contain the empty value - $view->vars['placeholder_in_choices'] = 0 !== count($options['choice_list']->getChoicesForValues(array(''))); + $view->vars['placeholder_in_choices'] = $choiceListView->hasPlaceholder(); // Only add the empty value option if this is not the case if (null !== $options['placeholder'] && !$view->vars['placeholder_in_choices']) { @@ -343,6 +343,9 @@ public function configureOptions(OptionsResolver $resolver) if ($options['multiple']) { // never use an empty value for this case return; + } elseif ($options['required'] && ($options['expanded'] || isset($options['attr']['size']) && $options['attr']['size'] > 1)) { + // placeholder for required radio buttons or a select with size > 1 does not make sense + return; } elseif (false === $placeholder) { // an empty value should be added but the user decided otherwise return; diff --git a/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php index 3bafd0ea24591..8c846c643ed57 100644 --- a/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php @@ -232,6 +232,26 @@ public function testSingleChoice() ); } + public function testSelectWithSizeBiggerThanOneCanBeRequired() + { + $form = $this->factory->createNamed('name', 'choice', null, array( + 'choices' => array('a', 'b'), + 'choices_as_values' => true, + 'multiple' => false, + 'expanded' => false, + 'attr' => array('size' => 2), + )); + + $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => '')), +'/select + [@name="name"] + [@required="required"] + [@size="2"] + [count(./option)=2] +' + ); + } + public function testSingleChoiceWithoutTranslation() { $form = $this->factory->createNamed('name', 'choice', '&a', array( @@ -754,6 +774,7 @@ public function testSingleChoiceExpandedWithPlaceholder() 'multiple' => false, 'expanded' => true, 'placeholder' => 'Test&Me', + 'required' => false, )); $this->assertWidgetMatchesXpath($form->createView(), array(), diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index 0939a2b003a9c..c31513e2094fe 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -528,6 +528,26 @@ public function testSingleChoice() ); } + public function testSelectWithSizeBiggerThanOneCanBeRequired() + { + $form = $this->factory->createNamed('name', 'choice', null, array( + 'choices' => array('a', 'b'), + 'choices_as_values' => true, + 'multiple' => false, + 'expanded' => false, + 'attr' => array('size' => 2), + )); + + $this->assertWidgetMatchesXpath($form->createView(), array(), +'/select + [@name="name"] + [@required="required"] + [@size="2"] + [count(./option)=2] +' + ); + } + public function testSingleChoiceWithoutTranslation() { $form = $this->factory->createNamed('name', 'choice', '&a', array( @@ -1001,6 +1021,7 @@ public function testSingleChoiceExpandedWithPlaceholder() 'multiple' => false, 'expanded' => true, 'placeholder' => 'Test&Me', + 'required' => false, )); $this->assertWidgetMatchesXpath($form->createView(), array(), diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php index cf74fec212ec5..809a4a7d8d70d 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php @@ -1689,7 +1689,7 @@ public function testDontPassPlaceholderIfContainedInChoices($multiple, $expanded 'expanded' => $expanded, 'required' => $required, 'placeholder' => $placeholder, - 'choices' => array('A' => 'a', 'Empty' => ''), + 'choices' => array('Empty' => '', 'A' => 'a'), 'choices_as_values' => true, )); $view = $form->createView(); @@ -1716,9 +1716,9 @@ public function getOptionsWithPlaceholder() array(false, true, false, '', 'None'), array(false, true, false, null, null), array(false, true, false, false, null), - array(false, true, true, 'foobar', 'foobar'), - // radios should never have an empty label - array(false, true, true, '', 'None'), + // required radios should never have a placeholder + array(false, true, true, 'foobar', null), + array(false, true, true, '', null), array(false, true, true, null, null), array(false, true, true, false, null), // multiple non-expanded From 088c20c9b34de11cd55fb00f3c3e13e6578a711c Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Sat, 13 Feb 2016 18:06:22 +0100 Subject: [PATCH 163/226] [Form] remove useless code in ResizeFormListener --- .../Form/Extension/Core/EventListener/ResizeFormListener.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php index 01c3c1b0b202e..31bb7797e51e3 100644 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php +++ b/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php @@ -96,10 +96,6 @@ public function preSubmit(FormEvent $event) $form = $event->getForm(); $data = $event->getData(); - if (null === $data || '' === $data) { - $data = array(); - } - if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) { $data = array(); } From 94bec9a9938806930ca9fb25af4d82966a7775f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Par=C3=A1da=20J=C3=B3zsef?= Date: Sat, 13 Feb 2016 22:20:23 +0100 Subject: [PATCH 164/226] [FrameworkBundle] Remove unused private method. --- .../Console/Descriptor/TextDescriptor.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php index 65b816f93925d..62ebee9121cb4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php @@ -428,17 +428,6 @@ private function formatRouterConfig(array $config) return trim($configAsString); } - /** - * @param string $section - * @param string $message - * - * @return string - */ - private function formatSection($section, $message) - { - return sprintf('[%s] %s', $section, $message); - } - /** * @param callable $callable * From ee9ca936002417bf105c4c7e88ae5be6f9083af2 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 8 Feb 2016 19:04:09 +0100 Subject: [PATCH 165/226] [Yaml] properly parse lists in object maps * do not cast parsed sequences to objects * properly handle numeric mapping keys --- src/Symfony/Component/Yaml/Parser.php | 10 ++- .../Component/Yaml/Tests/ParserTest.php | 76 ++++++++++++++----- 2 files changed, 66 insertions(+), 20 deletions(-) diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 233a51d9cd0c7..41134e6b6c72e 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -303,8 +303,14 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = mb_internal_encoding($mbEncoding); } - if ($objectForMap && !is_object($data)) { - $data = (object) $data; + if ($objectForMap && !is_object($data) && 'mapping' === $context) { + $object = new \stdClass(); + + foreach ($data as $key => $value) { + $object->$key = $value; + } + + $data = $object; } return empty($data) ? null : $data; diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 062161836c6f0..deb59e4240494 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -442,35 +442,75 @@ public function testObjectSupportDisabledButNoExceptions($input) $this->assertEquals(array('foo' => null, 'bar' => 1), $this->parser->parse($input), '->parse() does not parse objects'); } - public function testObjectForMapEnabledWithMapping() + /** + * @dataProvider getObjectForMapTests + */ + public function testObjectForMap($yaml, $expected) + { + $this->assertEquals($expected, $this->parser->parse($yaml, false, false, true)); + } + + public function getObjectForMapTests() { + $tests = array(); + $yaml = <<parser->parse($yaml, false, false, true); - - $this->assertInstanceOf('stdClass', $result); - $this->assertInstanceOf('stdClass', $result->foo); - $this->assertEquals(array('cat'), $result->foo->fiz); - } - - public function testObjectForMapEnabledWithInlineMapping() - { - $result = $this->parser->parse('{ "foo": "bar", "fiz": "cat" }', false, false, true); + $expected = new \stdClass(); + $expected->foo = new \stdClass(); + $expected->foo->fiz = array('cat'); + $tests['mapping'] = array($yaml, $expected); - $this->assertInstanceOf('stdClass', $result); - $this->assertEquals('bar', $result->foo); - $this->assertEquals('cat', $result->fiz); - } + $yaml = '{ "foo": "bar", "fiz": "cat" }'; + $expected = new \stdClass(); + $expected->foo = 'bar'; + $expected->fiz = 'cat'; + $tests['inline-mapping'] = array($yaml, $expected); - public function testObjectForMapIsAppliedAfterParsing() - { + $yaml = "foo: bar\nbaz: foobar"; $expected = new \stdClass(); $expected->foo = 'bar'; $expected->baz = 'foobar'; + $tests['object-for-map-is-applied-after-parsing'] = array($yaml, $expected); - $this->assertEquals($expected, $this->parser->parse("foo: bar\nbaz: foobar", false, false, true)); + $yaml = <<array = array(); + $expected->array[0] = new \stdClass(); + $expected->array[0]->key = 'one'; + $expected->array[1] = new \stdClass(); + $expected->array[1]->key = 'two'; + $tests['nest-map-and-sequence'] = array($yaml, $expected); + + $yaml = <<map = new \stdClass(); + $expected->map->{1} = 'one'; + $expected->map->{2} = 'two'; + $tests['numeric-keys'] = array($yaml, $expected); + + $yaml = <<map = new \stdClass(); + $expected->map->{0} = 'one'; + $expected->map->{1} = 'two'; + $tests['zero-indexed-numeric-keys'] = array($yaml, $expected); + + return $tests; } /** From aecb0fae3af1f02556f194bb7aeda029f8cdced7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Makuch?= Date: Sun, 7 Feb 2016 19:10:24 +0100 Subject: [PATCH 166/226] [DependencyInjection] fixed exceptions thrown by get method of ContainerBuilder --- .../DependencyInjection/ContainerBuilder.php | 17 ++++++++++------- .../Tests/ContainerBuilderTest.php | 14 ++++++++------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 3a72208c3e3b8..08ad7684511a5 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -19,6 +19,8 @@ use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\LogicException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; +use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException; +use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\Config\Resource\FileResource; use Symfony\Component\Config\Resource\ResourceInterface; @@ -415,9 +417,9 @@ public function has($id) * * @return object The associated service * - * @throws InvalidArgumentException when no definitions are available - * @throws InactiveScopeException when the current scope is not active - * @throws LogicException when a circular dependency is detected + * @throws InvalidArgumentException when no definitions are available + * @throws ServiceCircularReferenceException When a circular reference is detected + * @throws ServiceNotFoundException When the service is not defined * @throws \Exception * * @see Reference @@ -440,7 +442,8 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV try { $definition = $this->getDefinition($id); - } catch (InvalidArgumentException $e) { + } catch (ServiceNotFoundException $e) { + if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { return; } @@ -790,14 +793,14 @@ public function hasDefinition($id) * * @return Definition A Definition instance * - * @throws InvalidArgumentException if the service definition does not exist + * @throws ServiceNotFoundException if the service definition does not exist */ public function getDefinition($id) { $id = strtolower($id); if (!array_key_exists($id, $this->definitions)) { - throw new InvalidArgumentException(sprintf('The service definition "%s" does not exist.', $id)); + throw new ServiceNotFoundException($id); } return $this->definitions[$id]; @@ -812,7 +815,7 @@ public function getDefinition($id) * * @return Definition A Definition instance * - * @throws InvalidArgumentException if the service definition does not exist + * @throws ServiceNotFoundException if the service definition does not exist */ public function findDefinition($id) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index 3a369d9d2ed18..3f72ca45debb2 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -21,6 +21,8 @@ use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\Exception\InactiveScopeException; +use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException; +use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; use Symfony\Component\DependencyInjection\Loader\ClosureLoader; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; @@ -50,9 +52,9 @@ public function testDefinitions() try { $builder->getDefinition('baz'); - $this->fail('->getDefinition() throws an InvalidArgumentException if the service definition does not exist'); - } catch (\InvalidArgumentException $e) { - $this->assertEquals('The service definition "baz" does not exist.', $e->getMessage(), '->getDefinition() throws an InvalidArgumentException if the service definition does not exist'); + $this->fail('->getDefinition() throws a ServiceNotFoundException if the service definition does not exist'); + } catch (ServiceNotFoundException $e) { + $this->assertEquals('You have requested a non-existent service "baz".', $e->getMessage(), '->getDefinition() throws a ServiceNotFoundException if the service definition does not exist'); } } @@ -79,9 +81,9 @@ public function testGet() $builder = new ContainerBuilder(); try { $builder->get('foo'); - $this->fail('->get() throws an InvalidArgumentException if the service does not exist'); - } catch (\InvalidArgumentException $e) { - $this->assertEquals('The service definition "foo" does not exist.', $e->getMessage(), '->get() throws an InvalidArgumentException if the service does not exist'); + $this->fail('->get() throws a ServiceNotFoundException if the service does not exist'); + } catch (ServiceNotFoundException $e) { + $this->assertEquals('You have requested a non-existent service "foo".', $e->getMessage(), '->get() throws a ServiceNotFoundException if the service does not exist'); } $this->assertNull($builder->get('foo', ContainerInterface::NULL_ON_INVALID_REFERENCE), '->get() returns null if the service does not exist and NULL_ON_INVALID_REFERENCE is passed as a second argument'); From 55b71ebd931cc85f54dab944d4cfcaf3b2a1e85d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 14 Feb 2016 11:04:53 +0100 Subject: [PATCH 167/226] fixed CS --- src/Symfony/Component/DependencyInjection/ContainerBuilder.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 08ad7684511a5..ad2f89ae77d0d 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -443,7 +443,6 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV try { $definition = $this->getDefinition($id); } catch (ServiceNotFoundException $e) { - if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { return; } From 29916394f8544d495240207fbec57ac5c9a616aa Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 12 Feb 2016 17:33:32 +0100 Subject: [PATCH 168/226] [TwigBridge] Symfony 3.1 forward compatibility --- src/Symfony/Bridge/Twig/Extension/YamlExtension.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Twig/Extension/YamlExtension.php b/src/Symfony/Bridge/Twig/Extension/YamlExtension.php index 7d330c4b8985e..2d46795b4a81e 100644 --- a/src/Symfony/Bridge/Twig/Extension/YamlExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/YamlExtension.php @@ -12,6 +12,7 @@ namespace Symfony\Bridge\Twig\Extension; use Symfony\Component\Yaml\Dumper as YamlDumper; +use Symfony\Component\Yaml\Yaml; /** * Provides integration of the Yaml component with Twig. @@ -40,7 +41,7 @@ public function encode($input, $inline = 0, $dumpObjects = false) } if (defined('Symfony\Component\Yaml\Yaml::DUMP_OBJECT')) { - $dumpObjects = (int) $dumpObjects; + return $dumper->dump($input, $inline, 0, is_bool($dumpObjects) ? Yaml::DUMP_OBJECT : 0); } return $dumper->dump($input, $inline, 0, false, $dumpObjects); From ab2ac93a45e0e55518aec34f6fe1cc0f095195db Mon Sep 17 00:00:00 2001 From: Valentin Jonovs Date: Sun, 14 Feb 2016 12:20:16 +0100 Subject: [PATCH 169/226] [Form] [Validator] Fix locale inconsistencies in Norwegian translations | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | N/A | License | MIT --- .../{validators.nb.xlf => validators.no.xlf} | 0 .../Resources/translations/validators.nb.xlf | 155 ------------ .../Resources/translations/validators.nn.xlf | 227 ++++++++++++++++++ .../Resources/translations/validators.no.xlf | 144 +++-------- 4 files changed, 263 insertions(+), 263 deletions(-) rename src/Symfony/Component/Form/Resources/translations/{validators.nb.xlf => validators.no.xlf} (100%) delete mode 100644 src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf create mode 100644 src/Symfony/Component/Validator/Resources/translations/validators.nn.xlf diff --git a/src/Symfony/Component/Form/Resources/translations/validators.nb.xlf b/src/Symfony/Component/Form/Resources/translations/validators.no.xlf similarity index 100% rename from src/Symfony/Component/Form/Resources/translations/validators.nb.xlf rename to src/Symfony/Component/Form/Resources/translations/validators.no.xlf diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf deleted file mode 100644 index a8b790c7d8640..0000000000000 --- a/src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - This value should be false. - Verdien skal være falsk. - - - This value should be true. - Verdien skal være sann. - - - This value should be of type {{ type }}. - Verdien skal være av typen {{ type }}. - - - This value should be blank. - Verdien skal være blank. - - - The value you selected is not a valid choice. - Verdien skal være en av de gitte valg. - - - You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices. - Du skal velge minst {{ limit }} valg. - - - You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices. - Du kan maks velge {{ limit }} valg. - - - One or more of the given values is invalid. - En eller flere av de oppgitte verdier er ugyldige. - - - This field was not expected. - Dette feltet ikke var forventet. - - - This field is missing. - Dette feltet mangler. - - - This value is not a valid date. - Verdien er ikke en gyldig dato. - - - This value is not a valid datetime. - Verdien er ikke en gyldig dato og tid. - - - This value is not a valid email address. - Verdien er ikke en gyldig e-mail adresse. - - - The file could not be found. - Filen kunne ikke finnes. - - - The file is not readable. - Filen kan ikke leses. - - - The file is too large ({{ size }} {{ suffix }}). Allowed maximum size is {{ limit }} {{ suffix }}. - Filen er for stor ({{ size }} {{ suffix }}). Tilatte maksimale størrelse {{ limit }} {{ suffix }}. - - - The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}. - Mimetypen av filen er ugyldig ({{ type }}). Tilatte mimetyper er {{ types }}. - - - This value should be {{ limit }} or less. - Verdien skal være {{ limit }} eller mindre. - - - This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less. - Verdien er for lang. Den skal ha {{ limit }} bokstaver eller mindre. - - - This value should be {{ limit }} or more. - Verdien skal være {{ limit }} eller mer. - - - This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more. - Verdien er for kort. Den skal ha {{ limit }} tegn eller flere. - - - This value should not be blank. - Verdien må ikke være blank. - - - This value should not be null. - Verdien må ikke være tom (null). - - - This value should be null. - Verdien skal være tom (null). - - - This value is not valid. - Verdien er ikke gyldig. - - - This value is not a valid time. - Verdien er ikke en gyldig tid. - - - This value is not a valid URL. - Verdien er ikke en gyldig URL. - - - The two values should be equal. - De to verdier skal være ens. - - - The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}. - Filen er for stor. Den maksimale størrelse er {{ limit }} {{ suffix }}. - - - The file is too large. - Filen er for stor. - - - The file could not be uploaded. - Filen kunne ikke lastes opp. - - - This value should be a valid number. - Denne verdi skal være et gyldig tall. - - - This file is not a valid image. - Denne filen er ikke et gyldig bilde. - - - This is not a valid IP address. - Dette er ikke en gyldig IP adresse. - - - This value is not a valid language. - Denne verdi er ikke et gyldig språk. - - - This value is not a valid locale. - Denne verdi er ikke en gyldig lokalitet. - - - This value is not a valid country. - Denne verdi er ikke et gyldig land. - - - - diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.nn.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.nn.xlf new file mode 100644 index 0000000000000..566b82e947aed --- /dev/null +++ b/src/Symfony/Component/Validator/Resources/translations/validators.nn.xlf @@ -0,0 +1,227 @@ + + + + + + This value should be false. + Verdien skulle ha vore tom/nei. + + + This value should be true. + Verdien skulla ha vore satt/ja. + + + This value should be of type {{ type }}. + Verdien må vere av typen {{ type }}. + + + This value should be blank. + Verdien skal vere blank. + + + The value you selected is not a valid choice. + Verdien du valgte er ikkje gyldig. + + + You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices. + Du må velge minst {{ limit }} valg. + + + You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices. + Du kan maksimalt gjere {{ limit }} valg. + + + One or more of the given values is invalid. + Ein eller fleire av dei opplyste verdiane er ugyldige. + + + This field was not expected. + Dette feltet var ikke forventet. + + + This field is missing. + Dette feltet mangler. + + + This value is not a valid date. + Verdien er ikkje ein gyldig dato. + + + This value is not a valid datetime. + Verdien er ikkje ein gyldig dato og tid. + + + This value is not a valid email address. + Verdien er ikkje ei gyldig e-postadresse. + + + The file could not be found. + Fila kunne ikkje finnes. + + + The file is not readable. + Fila kan ikkje lesast. + + + The file is too large ({{ size }} {{ suffix }}). Allowed maximum size is {{ limit }} {{ suffix }}. + Fila er for stor ({{ size }} {{ suffix }}). Tillatt maksimal størrelse er {{ limit }} {{ suffix }}. + + + The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}. + Mime-typen av fila er ugyldig ({{ type }}). Tillatte mime-typar er {{ types }}. + + + This value should be {{ limit }} or less. + Verdien må vere {{ limit }} eller mindre. + + + This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less. + Verdien er for lang. Den må vere {{ limit }} bokstavar eller mindre. + + + This value should be {{ limit }} or more. + Verdien må vere {{ limit }} eller meir. + + + This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more. + Verdien er for kort. Den må ha {{ limit }} teikn eller fleire. + + + This value should not be blank. + Verdien må ikkje vere blank. + + + This value should not be null. + Verdien må ikkje vere tom (null). + + + This value should be null. + Verdien må vere tom (null). + + + This value is not valid. + Verdien er ikkje gyldig. + + + This value is not a valid time. + Verdien er ikkje gyldig tidseining. + + + This value is not a valid URL. + Verdien er ikkje ein gyldig URL. + + + The two values should be equal. + Dei to verdiane må vere like. + + + The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}. + Fila er for stor. Den maksimale storleik er {{ limit }} {{ suffix }}. + + + The file is too large. + Fila er for stor. + + + The file could not be uploaded. + Fila kunne ikkje bli lasta opp. + + + This value should be a valid number. + Verdien må vere eit gyldig tal. + + + This file is not a valid image. + Fila er ikkje eit gyldig bilete. + + + This is not a valid IP address. + Dette er ikkje ei gyldig IP-adresse. + + + This value is not a valid language. + Verdien er ikkje eit gyldig språk. + + + This value is not a valid locale. + Verdien er ikkje ein gyldig lokalitet (språk/region). + + + This value is not a valid country. + Verdien er ikkje eit gyldig land. + + + This value is already used. + Verdien er allereie i bruk. + + + The size of the image could not be detected. + Storleiken på biletet kunne ikkje oppdagast. + + + The image width is too big ({{ width }}px). Allowed maximum width is {{ max_width }}px. + Biletbreidda er for stor, ({{ width }} pikslar). Tillatt maksimumsbreidde er {{ max_width }} pikslar. + + + The image width is too small ({{ width }}px). Minimum width expected is {{ min_width }}px. + Biletbreidda er for liten, ({{ width }} pikslar). Forventa minimumsbreidde er {{ min_width }} pikslar. + + + The image height is too big ({{ height }}px). Allowed maximum height is {{ max_height }}px. + Bilethøgda er for stor, ({{ height }} pikslar). Tillatt maksimumshøgde er {{ max_height }} pikslar. + + + The image height is too small ({{ height }}px). Minimum height expected is {{ min_height }}px. + Billethøgda er for låg, ({{ height }} pikslar). Forventa minimumshøgde er {{ min_height }} pikslar. + + + This value should be the user current password. + Verdien må vere brukaren sitt noverande passord. + + + This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters. + Verdien må vere nøyaktig {{ limit }} teikn. + + + The file was only partially uploaded. + Fila vart kun delvis opplasta. + + + No file was uploaded. + Inga fil vart lasta opp. + + + No temporary folder was configured in php.ini. + Førebels mappe (tmp) er ikkje konfigurert i php.ini. + + + Cannot write temporary file to disk. + Kan ikkje skrive førebels fil til disk. + + + A PHP extension caused the upload to fail. + Ei PHP-udviding forårsaka feil under opplasting. + + + This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more. + Denne samlinga må innehalde {{ limit }} element eller meir.|Denne samlinga må innehalde {{ limit }} element eller meir. + + + This collection should contain {{ limit }} element or less.|This collection should contain {{ limit }} elements or less. + Denne samlinga må innehalde {{ limit }} element eller færre.|Denne samlinga må innehalde {{ limit }} element eller færre. + + + This collection should contain exactly {{ limit }} element.|This collection should contain exactly {{ limit }} elements. + Denne samlinga må innehalde nøyaktig {{ limit }} element.|Denne samlinga må innehalde nøyaktig {{ limit }} element. + + + Invalid card number. + Ugyldig kortnummer. + + + Unsupported card type or invalid card number. + Korttypen er ikkje støtta eller ugyldig kortnummer. + + + + diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf index 566b82e947aed..a8b790c7d8640 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf @@ -4,39 +4,39 @@ This value should be false. - Verdien skulle ha vore tom/nei. + Verdien skal være falsk. This value should be true. - Verdien skulla ha vore satt/ja. + Verdien skal være sann. This value should be of type {{ type }}. - Verdien må vere av typen {{ type }}. + Verdien skal være av typen {{ type }}. This value should be blank. - Verdien skal vere blank. + Verdien skal være blank. The value you selected is not a valid choice. - Verdien du valgte er ikkje gyldig. + Verdien skal være en av de gitte valg. You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices. - Du må velge minst {{ limit }} valg. + Du skal velge minst {{ limit }} valg. You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices. - Du kan maksimalt gjere {{ limit }} valg. + Du kan maks velge {{ limit }} valg. One or more of the given values is invalid. - Ein eller fleire av dei opplyste verdiane er ugyldige. + En eller flere av de oppgitte verdier er ugyldige. This field was not expected. - Dette feltet var ikke forventet. + Dette feltet ikke var forventet. This field is missing. @@ -44,183 +44,111 @@ This value is not a valid date. - Verdien er ikkje ein gyldig dato. + Verdien er ikke en gyldig dato. This value is not a valid datetime. - Verdien er ikkje ein gyldig dato og tid. + Verdien er ikke en gyldig dato og tid. This value is not a valid email address. - Verdien er ikkje ei gyldig e-postadresse. + Verdien er ikke en gyldig e-mail adresse. The file could not be found. - Fila kunne ikkje finnes. + Filen kunne ikke finnes. The file is not readable. - Fila kan ikkje lesast. + Filen kan ikke leses. The file is too large ({{ size }} {{ suffix }}). Allowed maximum size is {{ limit }} {{ suffix }}. - Fila er for stor ({{ size }} {{ suffix }}). Tillatt maksimal størrelse er {{ limit }} {{ suffix }}. + Filen er for stor ({{ size }} {{ suffix }}). Tilatte maksimale størrelse {{ limit }} {{ suffix }}. The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}. - Mime-typen av fila er ugyldig ({{ type }}). Tillatte mime-typar er {{ types }}. + Mimetypen av filen er ugyldig ({{ type }}). Tilatte mimetyper er {{ types }}. This value should be {{ limit }} or less. - Verdien må vere {{ limit }} eller mindre. + Verdien skal være {{ limit }} eller mindre. This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less. - Verdien er for lang. Den må vere {{ limit }} bokstavar eller mindre. + Verdien er for lang. Den skal ha {{ limit }} bokstaver eller mindre. This value should be {{ limit }} or more. - Verdien må vere {{ limit }} eller meir. + Verdien skal være {{ limit }} eller mer. This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more. - Verdien er for kort. Den må ha {{ limit }} teikn eller fleire. + Verdien er for kort. Den skal ha {{ limit }} tegn eller flere. This value should not be blank. - Verdien må ikkje vere blank. + Verdien må ikke være blank. This value should not be null. - Verdien må ikkje vere tom (null). + Verdien må ikke være tom (null). This value should be null. - Verdien må vere tom (null). + Verdien skal være tom (null). This value is not valid. - Verdien er ikkje gyldig. + Verdien er ikke gyldig. This value is not a valid time. - Verdien er ikkje gyldig tidseining. + Verdien er ikke en gyldig tid. This value is not a valid URL. - Verdien er ikkje ein gyldig URL. + Verdien er ikke en gyldig URL. The two values should be equal. - Dei to verdiane må vere like. + De to verdier skal være ens. The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}. - Fila er for stor. Den maksimale storleik er {{ limit }} {{ suffix }}. + Filen er for stor. Den maksimale størrelse er {{ limit }} {{ suffix }}. The file is too large. - Fila er for stor. + Filen er for stor. The file could not be uploaded. - Fila kunne ikkje bli lasta opp. + Filen kunne ikke lastes opp. This value should be a valid number. - Verdien må vere eit gyldig tal. + Denne verdi skal være et gyldig tall. This file is not a valid image. - Fila er ikkje eit gyldig bilete. + Denne filen er ikke et gyldig bilde. This is not a valid IP address. - Dette er ikkje ei gyldig IP-adresse. + Dette er ikke en gyldig IP adresse. This value is not a valid language. - Verdien er ikkje eit gyldig språk. + Denne verdi er ikke et gyldig språk. This value is not a valid locale. - Verdien er ikkje ein gyldig lokalitet (språk/region). + Denne verdi er ikke en gyldig lokalitet. This value is not a valid country. - Verdien er ikkje eit gyldig land. - - - This value is already used. - Verdien er allereie i bruk. - - - The size of the image could not be detected. - Storleiken på biletet kunne ikkje oppdagast. - - - The image width is too big ({{ width }}px). Allowed maximum width is {{ max_width }}px. - Biletbreidda er for stor, ({{ width }} pikslar). Tillatt maksimumsbreidde er {{ max_width }} pikslar. - - - The image width is too small ({{ width }}px). Minimum width expected is {{ min_width }}px. - Biletbreidda er for liten, ({{ width }} pikslar). Forventa minimumsbreidde er {{ min_width }} pikslar. - - - The image height is too big ({{ height }}px). Allowed maximum height is {{ max_height }}px. - Bilethøgda er for stor, ({{ height }} pikslar). Tillatt maksimumshøgde er {{ max_height }} pikslar. - - - The image height is too small ({{ height }}px). Minimum height expected is {{ min_height }}px. - Billethøgda er for låg, ({{ height }} pikslar). Forventa minimumshøgde er {{ min_height }} pikslar. - - - This value should be the user current password. - Verdien må vere brukaren sitt noverande passord. - - - This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters. - Verdien må vere nøyaktig {{ limit }} teikn. - - - The file was only partially uploaded. - Fila vart kun delvis opplasta. - - - No file was uploaded. - Inga fil vart lasta opp. - - - No temporary folder was configured in php.ini. - Førebels mappe (tmp) er ikkje konfigurert i php.ini. - - - Cannot write temporary file to disk. - Kan ikkje skrive førebels fil til disk. - - - A PHP extension caused the upload to fail. - Ei PHP-udviding forårsaka feil under opplasting. - - - This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more. - Denne samlinga må innehalde {{ limit }} element eller meir.|Denne samlinga må innehalde {{ limit }} element eller meir. - - - This collection should contain {{ limit }} element or less.|This collection should contain {{ limit }} elements or less. - Denne samlinga må innehalde {{ limit }} element eller færre.|Denne samlinga må innehalde {{ limit }} element eller færre. - - - This collection should contain exactly {{ limit }} element.|This collection should contain exactly {{ limit }} elements. - Denne samlinga må innehalde nøyaktig {{ limit }} element.|Denne samlinga må innehalde nøyaktig {{ limit }} element. - - - Invalid card number. - Ugyldig kortnummer. - - - Unsupported card type or invalid card number. - Korttypen er ikkje støtta eller ugyldig kortnummer. + Denne verdi er ikke et gyldig land. From 67d343fd69f0ca7ec942c61dfed98ed2c6cde27a Mon Sep 17 00:00:00 2001 From: Valentin Jonovs Date: Fri, 12 Feb 2016 20:29:13 +0100 Subject: [PATCH 170/226] Fix locale and written standard inconsistencies for Norwegian translations --- .../{validators.nb.xlf => validators.no.xlf} | 0 .../Resources/translations/validators.nb.xlf | 155 ------------ .../Resources/translations/validators.nn.xlf | 227 ++++++++++++++++++ .../Resources/translations/validators.no.xlf | 144 +++-------- 4 files changed, 263 insertions(+), 263 deletions(-) rename src/Symfony/Component/Form/Resources/translations/{validators.nb.xlf => validators.no.xlf} (100%) delete mode 100644 src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf create mode 100644 src/Symfony/Component/Validator/Resources/translations/validators.nn.xlf diff --git a/src/Symfony/Component/Form/Resources/translations/validators.nb.xlf b/src/Symfony/Component/Form/Resources/translations/validators.no.xlf similarity index 100% rename from src/Symfony/Component/Form/Resources/translations/validators.nb.xlf rename to src/Symfony/Component/Form/Resources/translations/validators.no.xlf diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf deleted file mode 100644 index a8b790c7d8640..0000000000000 --- a/src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - This value should be false. - Verdien skal være falsk. - - - This value should be true. - Verdien skal være sann. - - - This value should be of type {{ type }}. - Verdien skal være av typen {{ type }}. - - - This value should be blank. - Verdien skal være blank. - - - The value you selected is not a valid choice. - Verdien skal være en av de gitte valg. - - - You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices. - Du skal velge minst {{ limit }} valg. - - - You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices. - Du kan maks velge {{ limit }} valg. - - - One or more of the given values is invalid. - En eller flere av de oppgitte verdier er ugyldige. - - - This field was not expected. - Dette feltet ikke var forventet. - - - This field is missing. - Dette feltet mangler. - - - This value is not a valid date. - Verdien er ikke en gyldig dato. - - - This value is not a valid datetime. - Verdien er ikke en gyldig dato og tid. - - - This value is not a valid email address. - Verdien er ikke en gyldig e-mail adresse. - - - The file could not be found. - Filen kunne ikke finnes. - - - The file is not readable. - Filen kan ikke leses. - - - The file is too large ({{ size }} {{ suffix }}). Allowed maximum size is {{ limit }} {{ suffix }}. - Filen er for stor ({{ size }} {{ suffix }}). Tilatte maksimale størrelse {{ limit }} {{ suffix }}. - - - The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}. - Mimetypen av filen er ugyldig ({{ type }}). Tilatte mimetyper er {{ types }}. - - - This value should be {{ limit }} or less. - Verdien skal være {{ limit }} eller mindre. - - - This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less. - Verdien er for lang. Den skal ha {{ limit }} bokstaver eller mindre. - - - This value should be {{ limit }} or more. - Verdien skal være {{ limit }} eller mer. - - - This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more. - Verdien er for kort. Den skal ha {{ limit }} tegn eller flere. - - - This value should not be blank. - Verdien må ikke være blank. - - - This value should not be null. - Verdien må ikke være tom (null). - - - This value should be null. - Verdien skal være tom (null). - - - This value is not valid. - Verdien er ikke gyldig. - - - This value is not a valid time. - Verdien er ikke en gyldig tid. - - - This value is not a valid URL. - Verdien er ikke en gyldig URL. - - - The two values should be equal. - De to verdier skal være ens. - - - The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}. - Filen er for stor. Den maksimale størrelse er {{ limit }} {{ suffix }}. - - - The file is too large. - Filen er for stor. - - - The file could not be uploaded. - Filen kunne ikke lastes opp. - - - This value should be a valid number. - Denne verdi skal være et gyldig tall. - - - This file is not a valid image. - Denne filen er ikke et gyldig bilde. - - - This is not a valid IP address. - Dette er ikke en gyldig IP adresse. - - - This value is not a valid language. - Denne verdi er ikke et gyldig språk. - - - This value is not a valid locale. - Denne verdi er ikke en gyldig lokalitet. - - - This value is not a valid country. - Denne verdi er ikke et gyldig land. - - - - diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.nn.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.nn.xlf new file mode 100644 index 0000000000000..ea01c63ee4aa4 --- /dev/null +++ b/src/Symfony/Component/Validator/Resources/translations/validators.nn.xlf @@ -0,0 +1,227 @@ + + + + + + This value should be false. + Verdien skulle ha vore tom/nei. + + + This value should be true. + Verdien skulla ha vore satt/ja. + + + This value should be of type {{ type }}. + Verdien må vere av typen {{ type }}. + + + This value should be blank. + Verdien skal vere blank. + + + The value you selected is not a valid choice. + Verdien du valgte er ikkje gyldig. + + + You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices. + Du må velge minst {{ limit }} valg. + + + You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices. + Du kan maksimalt gjere {{ limit }} valg. + + + One or more of the given values is invalid. + Ein eller fleire av dei opplyste verdiane er ugyldige. + + + This field was not expected. + Dette feltet var ikke forventet. + + + This field is missing. + Dette feltet mangler. + + + This value is not a valid date. + Verdien er ikkje ein gyldig dato. + + + This value is not a valid datetime. + Verdien er ikkje ein gyldig dato og tid. + + + This value is not a valid email address. + Verdien er ikkje ei gyldig e-postadresse. + + + The file could not be found. + Fila kunne ikkje finnes. + + + The file is not readable. + Fila kan ikkje lesast. + + + The file is too large ({{ size }} {{ suffix }}). Allowed maximum size is {{ limit }} {{ suffix }}. + Fila er for stor ({{ size }} {{ suffix }}). Tillatt maksimal størrelse er {{ limit }} {{ suffix }}. + + + The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}. + Mime-typen av fila er ugyldig ({{ type }}). Tillatte mime-typar er {{ types }}. + + + This value should be {{ limit }} or less. + Verdien må vere {{ limit }} eller mindre. + + + This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less. + Verdien er for lang. Den må vere {{ limit }} bokstavar eller mindre. + + + This value should be {{ limit }} or more. + Verdien må vere {{ limit }} eller meir. + + + This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more. + Verdien er for kort. Den må ha {{ limit }} teikn eller fleire. + + + This value should not be blank. + Verdien må ikkje vere blank. + + + This value should not be null. + Verdien må ikkje vere tom (null). + + + This value should be null. + Verdien må vere tom (null). + + + This value is not valid. + Verdien er ikkje gyldig. + + + This value is not a valid time. + Verdien er ikkje gyldig tidseining. + + + This value is not a valid URL. + Verdien er ikkje ein gyldig URL. + + + The two values should be equal. + Dei to verdiane må vere like. + + + The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}. + Fila er for stor. Den maksimale storleik er {{ limit }} {{ suffix }}. + + + The file is too large. + Fila er for stor. + + + The file could not be uploaded. + Fila kunne ikkje bli lasta opp. + + + This value should be a valid number. + Verdien må vere eit gyldig tal. + + + This file is not a valid image. + Fila er ikkje eit gyldig bilete. + + + This is not a valid IP address. + Dette er ikkje ei gyldig IP-adresse. + + + This value is not a valid language. + Verdien er ikkje eit gyldig språk. + + + This value is not a valid locale. + Verdien er ikkje ein gyldig lokalitet (språk/region). + + + This value is not a valid country. + Verdien er ikkje eit gyldig land. + + + This value is already used. + Verdien er allereie i bruk. + + + The size of the image could not be detected. + Storleiken på biletet kunne ikkje oppdagast. + + + The image width is too big ({{ width }}px). Allowed maximum width is {{ max_width }}px. + Biletbreidda er for stor, ({{ width }} pikslar). Tillatt maksimumsbreidde er {{ max_width }} pikslar. + + + The image width is too small ({{ width }}px). Minimum width expected is {{ min_width }}px. + Biletbreidda er for liten, ({{ width }} pikslar). Forventa minimumsbreidde er {{ min_width }} pikslar. + + + The image height is too big ({{ height }}px). Allowed maximum height is {{ max_height }}px. + Bilethøgda er for stor, ({{ height }} pikslar). Tillatt maksimumshøgde er {{ max_height }} pikslar. + + + The image height is too small ({{ height }}px). Minimum height expected is {{ min_height }}px. + Billethøgda er for låg, ({{ height }} pikslar). Forventa minimumshøgde er {{ min_height }} pikslar. + + + This value should be the user's current password. + Verdien må vere brukaren sitt noverande passord. + + + This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters. + Verdien må vere nøyaktig {{ limit }} teikn. + + + The file was only partially uploaded. + Fila vart kun delvis opplasta. + + + No file was uploaded. + Inga fil vart lasta opp. + + + No temporary folder was configured in php.ini. + Førebels mappe (tmp) er ikkje konfigurert i php.ini. + + + Cannot write temporary file to disk. + Kan ikkje skrive førebels fil til disk. + + + A PHP extension caused the upload to fail. + Ei PHP-udviding forårsaka feil under opplasting. + + + This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more. + Denne samlinga må innehalde {{ limit }} element eller meir.|Denne samlinga må innehalde {{ limit }} element eller meir. + + + This collection should contain {{ limit }} element or less.|This collection should contain {{ limit }} elements or less. + Denne samlinga må innehalde {{ limit }} element eller færre.|Denne samlinga må innehalde {{ limit }} element eller færre. + + + This collection should contain exactly {{ limit }} element.|This collection should contain exactly {{ limit }} elements. + Denne samlinga må innehalde nøyaktig {{ limit }} element.|Denne samlinga må innehalde nøyaktig {{ limit }} element. + + + Invalid card number. + Ugyldig kortnummer. + + + Unsupported card type or invalid card number. + Korttypen er ikkje støtta eller ugyldig kortnummer. + + + + diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf index ea01c63ee4aa4..a8b790c7d8640 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf @@ -4,39 +4,39 @@ This value should be false. - Verdien skulle ha vore tom/nei. + Verdien skal være falsk. This value should be true. - Verdien skulla ha vore satt/ja. + Verdien skal være sann. This value should be of type {{ type }}. - Verdien må vere av typen {{ type }}. + Verdien skal være av typen {{ type }}. This value should be blank. - Verdien skal vere blank. + Verdien skal være blank. The value you selected is not a valid choice. - Verdien du valgte er ikkje gyldig. + Verdien skal være en av de gitte valg. You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices. - Du må velge minst {{ limit }} valg. + Du skal velge minst {{ limit }} valg. You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices. - Du kan maksimalt gjere {{ limit }} valg. + Du kan maks velge {{ limit }} valg. One or more of the given values is invalid. - Ein eller fleire av dei opplyste verdiane er ugyldige. + En eller flere av de oppgitte verdier er ugyldige. This field was not expected. - Dette feltet var ikke forventet. + Dette feltet ikke var forventet. This field is missing. @@ -44,183 +44,111 @@ This value is not a valid date. - Verdien er ikkje ein gyldig dato. + Verdien er ikke en gyldig dato. This value is not a valid datetime. - Verdien er ikkje ein gyldig dato og tid. + Verdien er ikke en gyldig dato og tid. This value is not a valid email address. - Verdien er ikkje ei gyldig e-postadresse. + Verdien er ikke en gyldig e-mail adresse. The file could not be found. - Fila kunne ikkje finnes. + Filen kunne ikke finnes. The file is not readable. - Fila kan ikkje lesast. + Filen kan ikke leses. The file is too large ({{ size }} {{ suffix }}). Allowed maximum size is {{ limit }} {{ suffix }}. - Fila er for stor ({{ size }} {{ suffix }}). Tillatt maksimal størrelse er {{ limit }} {{ suffix }}. + Filen er for stor ({{ size }} {{ suffix }}). Tilatte maksimale størrelse {{ limit }} {{ suffix }}. The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}. - Mime-typen av fila er ugyldig ({{ type }}). Tillatte mime-typar er {{ types }}. + Mimetypen av filen er ugyldig ({{ type }}). Tilatte mimetyper er {{ types }}. This value should be {{ limit }} or less. - Verdien må vere {{ limit }} eller mindre. + Verdien skal være {{ limit }} eller mindre. This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less. - Verdien er for lang. Den må vere {{ limit }} bokstavar eller mindre. + Verdien er for lang. Den skal ha {{ limit }} bokstaver eller mindre. This value should be {{ limit }} or more. - Verdien må vere {{ limit }} eller meir. + Verdien skal være {{ limit }} eller mer. This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more. - Verdien er for kort. Den må ha {{ limit }} teikn eller fleire. + Verdien er for kort. Den skal ha {{ limit }} tegn eller flere. This value should not be blank. - Verdien må ikkje vere blank. + Verdien må ikke være blank. This value should not be null. - Verdien må ikkje vere tom (null). + Verdien må ikke være tom (null). This value should be null. - Verdien må vere tom (null). + Verdien skal være tom (null). This value is not valid. - Verdien er ikkje gyldig. + Verdien er ikke gyldig. This value is not a valid time. - Verdien er ikkje gyldig tidseining. + Verdien er ikke en gyldig tid. This value is not a valid URL. - Verdien er ikkje ein gyldig URL. + Verdien er ikke en gyldig URL. The two values should be equal. - Dei to verdiane må vere like. + De to verdier skal være ens. The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}. - Fila er for stor. Den maksimale storleik er {{ limit }} {{ suffix }}. + Filen er for stor. Den maksimale størrelse er {{ limit }} {{ suffix }}. The file is too large. - Fila er for stor. + Filen er for stor. The file could not be uploaded. - Fila kunne ikkje bli lasta opp. + Filen kunne ikke lastes opp. This value should be a valid number. - Verdien må vere eit gyldig tal. + Denne verdi skal være et gyldig tall. This file is not a valid image. - Fila er ikkje eit gyldig bilete. + Denne filen er ikke et gyldig bilde. This is not a valid IP address. - Dette er ikkje ei gyldig IP-adresse. + Dette er ikke en gyldig IP adresse. This value is not a valid language. - Verdien er ikkje eit gyldig språk. + Denne verdi er ikke et gyldig språk. This value is not a valid locale. - Verdien er ikkje ein gyldig lokalitet (språk/region). + Denne verdi er ikke en gyldig lokalitet. This value is not a valid country. - Verdien er ikkje eit gyldig land. - - - This value is already used. - Verdien er allereie i bruk. - - - The size of the image could not be detected. - Storleiken på biletet kunne ikkje oppdagast. - - - The image width is too big ({{ width }}px). Allowed maximum width is {{ max_width }}px. - Biletbreidda er for stor, ({{ width }} pikslar). Tillatt maksimumsbreidde er {{ max_width }} pikslar. - - - The image width is too small ({{ width }}px). Minimum width expected is {{ min_width }}px. - Biletbreidda er for liten, ({{ width }} pikslar). Forventa minimumsbreidde er {{ min_width }} pikslar. - - - The image height is too big ({{ height }}px). Allowed maximum height is {{ max_height }}px. - Bilethøgda er for stor, ({{ height }} pikslar). Tillatt maksimumshøgde er {{ max_height }} pikslar. - - - The image height is too small ({{ height }}px). Minimum height expected is {{ min_height }}px. - Billethøgda er for låg, ({{ height }} pikslar). Forventa minimumshøgde er {{ min_height }} pikslar. - - - This value should be the user's current password. - Verdien må vere brukaren sitt noverande passord. - - - This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters. - Verdien må vere nøyaktig {{ limit }} teikn. - - - The file was only partially uploaded. - Fila vart kun delvis opplasta. - - - No file was uploaded. - Inga fil vart lasta opp. - - - No temporary folder was configured in php.ini. - Førebels mappe (tmp) er ikkje konfigurert i php.ini. - - - Cannot write temporary file to disk. - Kan ikkje skrive førebels fil til disk. - - - A PHP extension caused the upload to fail. - Ei PHP-udviding forårsaka feil under opplasting. - - - This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more. - Denne samlinga må innehalde {{ limit }} element eller meir.|Denne samlinga må innehalde {{ limit }} element eller meir. - - - This collection should contain {{ limit }} element or less.|This collection should contain {{ limit }} elements or less. - Denne samlinga må innehalde {{ limit }} element eller færre.|Denne samlinga må innehalde {{ limit }} element eller færre. - - - This collection should contain exactly {{ limit }} element.|This collection should contain exactly {{ limit }} elements. - Denne samlinga må innehalde nøyaktig {{ limit }} element.|Denne samlinga må innehalde nøyaktig {{ limit }} element. - - - Invalid card number. - Ugyldig kortnummer. - - - Unsupported card type or invalid card number. - Korttypen er ikkje støtta eller ugyldig kortnummer. + Denne verdi er ikke et gyldig land. From beb70d9370f9672403f58ca825a622df12f58af8 Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Mon, 15 Feb 2016 09:50:51 +0100 Subject: [PATCH 171/226] fix FQCN in tests added by #17694 --- .../Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php index 54cb786046028..bdcea8ae638a7 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php @@ -773,7 +773,7 @@ public function testOverrideChoicesValues() $this->persist(array($entity1, $entity2)); - $field = $this->factory->createNamed('name', 'entity', null, array( + $field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array( 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'choice_label' => 'name', @@ -795,7 +795,7 @@ public function testOverrideChoicesValuesWithCallable() $this->persist(array($entity1, $entity2)); - $field = $this->factory->createNamed('name', 'entity', null, array( + $field = $this->factory->createNamed('name', 'Symfony\Bridge\Doctrine\Form\Type\EntityType', null, array( 'em' => 'default', 'class' => self::ITEM_GROUP_CLASS, 'choice_label' => 'name', From f005c80bc5244a4b4eceae263adc410355e6cbe9 Mon Sep 17 00:00:00 2001 From: Alessandro Chitolina Date: Tue, 22 Dec 2015 08:14:31 +0100 Subject: [PATCH 172/226] [Form] Fixed violation mapping if multiple forms are using the same (or part of the same) property path --- .../ViolationMapper/ViolationMapper.php | 55 +++++++------------ .../ViolationMapper/ViolationMapperTest.php | 21 +++++++ 2 files changed, 41 insertions(+), 35 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php index 7686809588d7d..bef225c422d5a 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php +++ b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php @@ -147,12 +147,9 @@ public function mapViolation(ConstraintViolation $violation, FormInterface $form */ private function matchChild(FormInterface $form, PropertyPathIteratorInterface $it) { - // Remember at what property path underneath "data" - // we are looking. Check if there is a child with that - // path, otherwise increase path by one more piece + $target = null; $chunk = ''; - $foundChild = null; - $foundAtIndex = 0; + $foundAtIndex = null; // Construct mapping rules for the given form $rules = array(); @@ -164,17 +161,11 @@ private function matchChild(FormInterface $form, PropertyPathIteratorInterface $ } } - // Skip forms inheriting their parent data when iterating the children - $childIterator = new \RecursiveIteratorIterator( + $children = iterator_to_array(new \RecursiveIteratorIterator( new InheritDataAwareIterator($form) - ); - - // Make the path longer until we find a matching child - while (true) { - if (!$it->valid()) { - return; - } + )); + while ($it->valid()) { if ($it->isIndex()) { $chunk .= '['.$it->current().']'; } else { @@ -196,33 +187,27 @@ private function matchChild(FormInterface $form, PropertyPathIteratorInterface $ } } - // Test children unless we already found one - if (null === $foundChild) { - foreach ($childIterator as $child) { - /* @var FormInterface $child */ - $childPath = (string) $child->getPropertyPath(); - - // Child found, mark as return value - if ($chunk === $childPath) { - $foundChild = $child; - $foundAtIndex = $it->key(); - } + /** @var FormInterface $child */ + foreach ($children as $key => $child) { + $childPath = (string) $child->getPropertyPath(); + if ($childPath === $chunk) { + $target = $child; + $foundAtIndex = $it->key(); + } elseif (0 === strpos($childPath, $chunk)) { + continue; } + + unset($children[$key]); } - // Add element to the chunk $it->next(); + } - // If we reached the end of the path or if there are no - // more matching mapping rules, return the found child - if (null !== $foundChild && (!$it->valid() || count($rules) === 0)) { - // Reset index in case we tried to find mapping - // rules further down the path - $it->seek($foundAtIndex); - - return $foundChild; - } + if (null !== $foundAtIndex) { + $it->seek($foundAtIndex); } + + return $target; } /** diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php index e4e0f9cc480e2..f6ad34eccb6b8 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php @@ -1474,4 +1474,25 @@ public function testErrorMappingForFormInheritingParentData($target, $childName, $this->assertEquals(array($this->getFormError()), $grandChild->getErrors(), $grandChildName.' should have an error, but has none'); } } + + public function testBacktrackIfSeveralSubFormsWithSamePropertyPath() + { + $violation = $this->getConstraintViolation('data.address[street]'); + $parent = $this->getForm('parent'); + $child1 = $this->getForm('subform1', 'address'); + $child2 = $this->getForm('subform2', 'address'); + $grandChild = $this->getForm('street'); + + $parent->add($child1); + $parent->add($child2); + $child2->add($grandChild); + + $this->mapper->mapViolation($violation, $parent); + + // The error occurred on the child of the second form with the same path + $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); + $this->assertCount(0, $child1->getErrors(), $child1->getName().' should not have an error, but has one'); + $this->assertCount(0, $child2->getErrors(), $child2->getName().' should not have an error, but has one'); + $this->assertEquals(array($this->getFormError()), $grandChild->getErrors(), $grandChild->getName().' should have an error, but has none'); + } } From d9af4bc606a0d92c88c4e36d2bf337623b3283cd Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 15 Feb 2016 18:58:30 +0100 Subject: [PATCH 173/226] fix YAML syntax in functional tests config --- .../Tests/DependencyInjection/Fixtures/yml/full.yml | 4 ++-- .../SecurityBundle/Tests/Functional/app/config/twig.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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 0a159ddc34c2d..1e607e9bb6cd2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml @@ -13,7 +13,7 @@ framework: only_exceptions: true enabled: false router: - resource: %kernel.root_dir%/config/routing.xml + resource: '%kernel.root_dir%/config/routing.xml' type: xml session: storage_id: session.storage.native @@ -54,5 +54,5 @@ framework: annotations: cache: file debug: true - file_cache_dir: %kernel.cache_dir%/annotations + file_cache_dir: '%kernel.cache_dir%/annotations' ide: file%%link%%format diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/twig.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/twig.yml index 861b1e709fd13..61c1a54d99ba5 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/twig.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/twig.yml @@ -3,5 +3,5 @@ framework: # Twig Configuration twig: - debug: %kernel.debug% - strict_variables: %kernel.debug% + debug: '%kernel.debug%' + strict_variables: '%kernel.debug%' From 2da40382abff4e7ccfee8228308b0974556de867 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 15 Feb 2016 19:07:52 +0100 Subject: [PATCH 174/226] [FrameworkBundle] fix YAML syntax --- .../Tests/DependencyInjection/Fixtures/yml/assets.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets.yml index d3285ff58102c..ba87d98b42ba6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets.yml @@ -1,7 +1,7 @@ framework: assets: version: SomeVersionScheme - version_format: %%s?version=%%s + version_format: '%%s?version=%%s' base_urls: http://cdn.example.com packages: images_path: @@ -11,7 +11,7 @@ framework: base_urls: ["http://images1.example.com", "http://images2.example.com"] foo: version: 1.0.0 - version_format: %%s-%%s + version_format: '%%s-%%s' bar: base_urls: ["https://bar2.example.com"] bar_null_version: From 7631202155628981a0bb8d0def7167324715ace5 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 15 Feb 2016 19:17:14 +0100 Subject: [PATCH 175/226] [Yaml] always restore the error handler in tests The error handler must be restored even when assertions failed. --- src/Symfony/Component/Yaml/Tests/ParserTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index deb59e4240494..d41c583ed53fc 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -896,10 +896,10 @@ public function testColonInMappingValueException() $this->parser->parse($yaml); + restore_error_handler(); + $this->assertCount(1, $deprecations); $this->assertContains('Using a colon in the unquoted mapping value "bar: baz" in line 1 is deprecated since Symfony 2.8 and will throw a ParseException in 3.0.', $deprecations[0]); - - restore_error_handler(); } public function testColonInMappingValueExceptionNotTriggeredByColonInComment() From 3c0615141eb7404ec82967e18b342a0a7ff28a29 Mon Sep 17 00:00:00 2001 From: Tomas Liubinas Date: Thu, 21 Jan 2016 20:00:49 +0200 Subject: [PATCH 176/226] Remove InputOption::VALUE_REQUIRED mode from $default parameter description as InputOption::setDefault() throws an exception only when called in InputOption::VALUE_NONE mode. In practice the $default value could still be accessed in InputOption::VALUE_REQUIRED mode in case InputOption was never set but accessed from InputDefinition::getOption() method --- src/Symfony/Component/Console/Command/Command.php | 2 +- src/Symfony/Component/Console/Input/InputOption.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index bd899158c4e68..3d3f2c14d78a5 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -370,7 +370,7 @@ public function addArgument($name, $mode = null, $description = '', $default = n * @param string $shortcut The shortcut (can be null) * @param int $mode The option mode: One of the InputOption::VALUE_* constants * @param string $description A description text - * @param mixed $default The default value (must be null for InputOption::VALUE_REQUIRED or InputOption::VALUE_NONE) + * @param mixed $default The default value (must be null for InputOption::VALUE_NONE) * * @return Command The current instance */ diff --git a/src/Symfony/Component/Console/Input/InputOption.php b/src/Symfony/Component/Console/Input/InputOption.php index 167f19901a8fc..26773ca599a39 100644 --- a/src/Symfony/Component/Console/Input/InputOption.php +++ b/src/Symfony/Component/Console/Input/InputOption.php @@ -36,7 +36,7 @@ class InputOption * @param string|array $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts * @param int $mode The option mode: One of the VALUE_* constants * @param string $description A description text - * @param mixed $default The default value (must be null for self::VALUE_REQUIRED or self::VALUE_NONE) + * @param mixed $default The default value (must be null for self::VALUE_NONE) * * @throws \InvalidArgumentException If option mode is invalid or incompatible */ From 30388f17ffc6b02ca592662cedae86025cf1dd21 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 15 Feb 2016 18:40:28 +0100 Subject: [PATCH 177/226] [DependencyInjection] fix dumped YAML snytax --- .../DependencyInjection/Dumper/YamlDumper.php | 4 ++-- .../Tests/Dumper/YamlDumperTest.php | 15 +++++++++------ .../Tests/Fixtures/yaml/services10.yml | 2 +- .../Tests/Fixtures/yaml/services6.yml | 2 +- .../Tests/Fixtures/yaml/services9.yml | 8 ++++---- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php index eca056dea16a5..84ad6f872a683 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php @@ -64,7 +64,7 @@ private function addService($id, $definition) $class = substr($class, 1); } - $code .= sprintf(" class: %s\n", $class); + $code .= sprintf(" class: %s\n", $this->dumper->dump($class)); } if (!$definition->isPublic()) { @@ -100,7 +100,7 @@ private function addService($id, $definition) } if ($definition->getFactoryClass()) { - $code .= sprintf(" factory_class: %s\n", $definition->getFactoryClass()); + $code .= sprintf(" factory_class: %s\n", $this->dumper->dump($definition->getFactoryClass())); } if ($definition->isLazy()) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php index f9747a7c2fae9..aec4109f24b1f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php @@ -13,6 +13,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Dumper\YamlDumper; +use Symfony\Component\Yaml\Yaml; class YamlDumperTest extends \PHPUnit_Framework_TestCase { @@ -27,24 +28,21 @@ public function testDump() { $dumper = new YamlDumper($container = new ContainerBuilder()); - $this->assertStringEqualsFile(self::$fixturesPath.'/yaml/services1.yml', $dumper->dump(), '->dump() dumps an empty container as an empty YAML file'); - - $container = new ContainerBuilder(); - $dumper = new YamlDumper($container); + $this->assertEqualYamlStructure(self::$fixturesPath.'/yaml/services1.yml', $dumper->dump(), '->dump() dumps an empty container as an empty YAML file'); } public function testAddParameters() { $container = include self::$fixturesPath.'/containers/container8.php'; $dumper = new YamlDumper($container); - $this->assertStringEqualsFile(self::$fixturesPath.'/yaml/services8.yml', $dumper->dump(), '->dump() dumps parameters'); + $this->assertEqualYamlStructure(self::$fixturesPath.'/yaml/services8.yml', $dumper->dump(), '->dump() dumps parameters'); } public function testAddService() { $container = include self::$fixturesPath.'/containers/container9.php'; $dumper = new YamlDumper($container); - $this->assertEquals(str_replace('%path%', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR, file_get_contents(self::$fixturesPath.'/yaml/services9.yml')), $dumper->dump(), '->dump() dumps services'); + $this->assertEqualYamlStructure(str_replace('%path%', self::$fixturesPath.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR, file_get_contents(self::$fixturesPath.'/yaml/services9.yml')), $dumper->dump(), '->dump() dumps services'); $dumper = new YamlDumper($container = new ContainerBuilder()); $container->register('foo', 'FooClass')->addArgument(new \stdClass()); @@ -56,4 +54,9 @@ public function testAddService() $this->assertEquals('Unable to dump a service container if a parameter is an object or a resource.', $e->getMessage(), '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources'); } } + + private function assertEqualYamlStructure($yaml, $expected, $message = '') + { + $this->assertEquals(Yaml::parse($expected), Yaml::parse($yaml), $message); + } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services10.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services10.yml index f2f8d953d57a3..c66084cdbe8e6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services10.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services10.yml @@ -6,4 +6,4 @@ services: class: BAR project: - test: %project.parameter.foo% + test: '%project.parameter.foo%' diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml index b79697b6e9399..4531cc57eecc9 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml @@ -5,7 +5,7 @@ services: scope.custom: { class: FooClass, scope: custom } scope.prototype: { class: FooClass, scope: prototype } constructor: { class: FooClass, factory_method: getInstance } - file: { class: FooClass, file: %path%/foo.php } + file: { class: FooClass, file: '%path%/foo.php' } arguments: { class: FooClass, arguments: [foo, '@foo', [true, false]] } configurator1: { class: FooClass, configurator: sc_configure } configurator2: { class: FooClass, configurator: ['@baz', configure] } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml index c6181ed549a61..ae673c17271ea 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml @@ -23,16 +23,16 @@ services: arguments: [foo, '@foo.baz', '%foo_bar%'] configurator: ['@foo.baz', configure] foo.baz: - class: %baz_class% - factory_class: %baz_class% + class: '%baz_class%' + factory_class: '%baz_class%' factory_method: getInstance configurator: ['%baz_class%', configureStatic1] foo_bar: - class: %foo_class% + class: '%foo_class%' scope: prototype method_call1: class: FooClass - file: %path%foo.php + file: '%path%foo.php' calls: - [setBar, ['@foo']] - [setBar, ['@?foo2']] From c8d387f13184e220bc64aca59474db2221465bce Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 16 Feb 2016 09:56:31 +0100 Subject: [PATCH 178/226] don't rely on deprecated YAML parser feature --- .../DependencyInjection/Tests/Dumper/YamlDumperTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php index aec4109f24b1f..5c61e4be2e73d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php @@ -28,14 +28,14 @@ public function testDump() { $dumper = new YamlDumper($container = new ContainerBuilder()); - $this->assertEqualYamlStructure(self::$fixturesPath.'/yaml/services1.yml', $dumper->dump(), '->dump() dumps an empty container as an empty YAML file'); + $this->assertEqualYamlStructure(file_get_contents(self::$fixturesPath.'/yaml/services1.yml'), $dumper->dump(), '->dump() dumps an empty container as an empty YAML file'); } public function testAddParameters() { $container = include self::$fixturesPath.'/containers/container8.php'; $dumper = new YamlDumper($container); - $this->assertEqualYamlStructure(self::$fixturesPath.'/yaml/services8.yml', $dumper->dump(), '->dump() dumps parameters'); + $this->assertEqualYamlStructure(file_get_contents(self::$fixturesPath.'/yaml/services8.yml'), $dumper->dump(), '->dump() dumps parameters'); } public function testAddService() From 2849152c5e975fbf349a848d7d8b684c22977201 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Tue, 16 Feb 2016 16:21:16 +0000 Subject: [PATCH 179/226] [HttpKernel] Prevent a fatal error when DebugHandlersListener is used with a kernel with no terminateWithException() method --- .../EventListener/DebugHandlersListener.php | 4 ++- .../DebugHandlersListenerTest.php | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php index 19a4c6d945f1e..2f523a54dbe4a 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php @@ -93,7 +93,9 @@ public function configure(Event $event = null) } if (!$this->exceptionHandler) { if ($event instanceof KernelEvent) { - $this->exceptionHandler = array($event->getKernel(), 'terminateWithException'); + if (method_exists($event->getKernel(), 'terminateWithException')) { + $this->exceptionHandler = array($event->getKernel(), 'terminateWithException'); + } } elseif ($event instanceof ConsoleEvent && $app = $event->getCommand()->getApplication()) { $output = $event->getOutput(); if ($output instanceof ConsoleOutputInterface) { diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php index 4584a48a76846..8e1c35b3457d7 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/DebugHandlersListenerTest.php @@ -21,7 +21,10 @@ use Symfony\Component\Debug\ErrorHandler; use Symfony\Component\Debug\ExceptionHandler; use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\Event\KernelEvent; use Symfony\Component\HttpKernel\EventListener\DebugHandlersListener; +use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\KernelEvents; /** @@ -62,6 +65,31 @@ public function testConfigure() $this->assertSame(array($logger, LogLevel::INFO), $loggers[E_DEPRECATED]); } + public function testConfigureForHttpKernelWithNoTerminateWithException() + { + $listener = new DebugHandlersListener(null); + $eHandler = new ErrorHandler(); + $event = new KernelEvent( + $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), + Request::create('/'), + HttpKernelInterface::MASTER_REQUEST + ); + + $exception = null; + $h = set_exception_handler(array($eHandler, 'handleException')); + try { + $listener->configure($event); + } catch (\Exception $exception) { + } + restore_exception_handler(); + + if (null !== $exception) { + throw $exception; + } + + $this->assertNull($h); + } + public function testConsoleEvent() { $dispatcher = new EventDispatcher(); From f87558d05ea7fbd5ee5761cbc03b29dd7da2a9b8 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 16 Feb 2016 20:34:40 +0100 Subject: [PATCH 180/226] [Form] fix violation mapper tests This takes into account the changes to the `getErrors()` in Symfony 2.5 (the method rturns a `FormErrorIterator` instead of an array) as well as the fact that non-submitted forms do not accept errors since #10567 anymore. --- .../Validator/ViolationMapper/ViolationMapperTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php index 1dc90e85da8fc..a099e104595ff 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php @@ -1552,12 +1552,14 @@ public function testBacktrackIfSeveralSubFormsWithSamePropertyPath() $parent->add($child2); $child2->add($grandChild); + $parent->submit(array()); + $this->mapper->mapViolation($violation, $parent); // The error occurred on the child of the second form with the same path $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); $this->assertCount(0, $child1->getErrors(), $child1->getName().' should not have an error, but has one'); $this->assertCount(0, $child2->getErrors(), $child2->getName().' should not have an error, but has one'); - $this->assertEquals(array($this->getFormError()), $grandChild->getErrors(), $grandChild->getName().' should have an error, but has none'); + $this->assertEquals(array($this->getFormError($violation, $grandChild)), iterator_to_array($grandChild->getErrors()), $grandChild->getName().' should have an error, but has none'); } } From 8eea65e0d86c8ef7611f16927ff68246bd4fe810 Mon Sep 17 00:00:00 2001 From: Robin Kanters Date: Tue, 16 Feb 2016 15:02:44 +0100 Subject: [PATCH 181/226] The exception should be thrown if an object doesn't implement Traversable AND doesn't implement Countable, not when it doesn't implement Traversable but DOES implement Countable --- src/Symfony/Component/Console/Question/Question.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Question/Question.php b/src/Symfony/Component/Console/Question/Question.php index ffe9417117f6a..02b190caed8a4 100644 --- a/src/Symfony/Component/Console/Question/Question.php +++ b/src/Symfony/Component/Console/Question/Question.php @@ -140,7 +140,7 @@ public function setAutocompleterValues($values) } if (null !== $values && !is_array($values)) { - if (!$values instanceof \Traversable || $values instanceof \Countable) { + if (!$values instanceof \Traversable || !$values instanceof \Countable) { throw new \InvalidArgumentException('Autocompleter values can be either an array, `null` or an object implementing both `Countable` and `Traversable` interfaces.'); } } From 2200b0c178572be1408d99437c91c3a856b92c8c Mon Sep 17 00:00:00 2001 From: Calin Mihai Pristavu Date: Wed, 17 Feb 2016 16:19:09 +0200 Subject: [PATCH 182/226] [Config] Add suggest to composer.json for symfony/yaml --- src/Symfony/Component/Config/composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Symfony/Component/Config/composer.json b/src/Symfony/Component/Config/composer.json index 28252b13ef37f..f1633c1c80f50 100644 --- a/src/Symfony/Component/Config/composer.json +++ b/src/Symfony/Component/Config/composer.json @@ -19,6 +19,9 @@ "php": ">=5.3.9", "symfony/filesystem": "~2.3" }, + "suggest": { + "symfony/yaml": "To use the yaml reference dumper" + }, "autoload": { "psr-4": { "Symfony\\Component\\Config\\": "" }, "exclude-from-classmap": [ From b1bb1352495310f786ee7cf5fef148a4c24658e7 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 17 Feb 2016 08:59:48 +0100 Subject: [PATCH 183/226] [DependencyInjection] fix dumped YAML string --- .../Component/DependencyInjection/Dumper/YamlDumper.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php index 84ad6f872a683..480857ee64625 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php @@ -88,7 +88,7 @@ private function addService($id, $definition) } if ($definition->getFile()) { - $code .= sprintf(" file: %s\n", $definition->getFile()); + $code .= sprintf(" file: %s\n", $this->dumper->dump($definition->getFile())); } if ($definition->isSynthetic()) { @@ -108,11 +108,11 @@ private function addService($id, $definition) } if ($definition->getFactoryMethod()) { - $code .= sprintf(" factory_method: %s\n", $definition->getFactoryMethod()); + $code .= sprintf(" factory_method: %s\n", $this->dumper->dump($definition->getFactoryMethod())); } if ($definition->getFactoryService()) { - $code .= sprintf(" factory_service: %s\n", $definition->getFactoryService()); + $code .= sprintf(" factory_service: %s\n", $this->dumper->dump($definition->getFactoryService())); } if ($definition->getArguments()) { @@ -128,7 +128,7 @@ private function addService($id, $definition) } if (ContainerInterface::SCOPE_CONTAINER !== $scope = $definition->getScope()) { - $code .= sprintf(" scope: %s\n", $scope); + $code .= sprintf(" scope: %s\n", $this->dumper->dump($scope)); } if ($callable = $definition->getConfigurator()) { From e9ee877e4b2ee4362766737bf24f1129c0cb590c Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 17 Feb 2016 22:15:58 +0100 Subject: [PATCH 184/226] [Yaml] fix default timezone to be UTC --- src/Symfony/Component/Yaml/Inline.php | 7 ++++++- .../Yaml/Tests/Fixtures/YtsSpecificationExamples.yml | 4 ++-- src/Symfony/Component/Yaml/Tests/InlineTest.php | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index eafcbc7ab0018..5f15e3c5b4a9b 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -475,7 +475,12 @@ private static function evaluateScalar($scalar, $references = array()) case preg_match('/^(-|\+)?[0-9,]+(\.[0-9]+)?$/', $scalar): return (float) str_replace(',', '', $scalar); case preg_match(self::getTimestampRegex(), $scalar): - return strtotime($scalar); + $timeZone = date_default_timezone_get(); + date_default_timezone_set('UTC'); + $time = strtotime($scalar); + date_default_timezone_set($timeZone); + + return $time; } default: return (string) $scalar; diff --git a/src/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml b/src/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml index a06df7fb316fa..cbbb257a027e8 100644 --- a/src/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml +++ b/src/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml @@ -752,7 +752,7 @@ yaml: | Billsmer @ 338-4338. php: | array( - 'invoice' => 34843, 'date' => mktime(0, 0, 0, 1, 23, 2001), + 'invoice' => 34843, 'date' => gmmktime(0, 0, 0, 1, 23, 2001), 'bill-to' => array( 'given' => 'Chris', 'family' => 'Dumars', 'address' => array( 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ) ) , 'ship-to' => @@ -877,7 +877,7 @@ yaml: | php: | array( 'invoice' => 34843, - 'date' => mktime(0, 0, 0, 1, 23, 2001), + 'date' => gmmktime(0, 0, 0, 1, 23, 2001), 'total' => 4443.52 ) --- diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index b259000e538d2..255928d16d2cd 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -202,7 +202,7 @@ protected function getTestsForParse() "'on'" => 'on', "'off'" => 'off', - '2007-10-30' => mktime(0, 0, 0, 10, 30, 2007), + '2007-10-30' => gmmktime(0, 0, 0, 10, 30, 2007), '2007-10-30T02:59:43Z' => gmmktime(2, 59, 43, 10, 30, 2007), '2007-10-30 02:59:43 Z' => gmmktime(2, 59, 43, 10, 30, 2007), '1960-10-30 02:59:43 Z' => gmmktime(2, 59, 43, 10, 30, 1960), From d27c4f4d68691ff4c1017b59b3bcd54ddec57330 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Thu, 18 Feb 2016 01:47:59 +0100 Subject: [PATCH 185/226] Remove duplicate validation in RedirectResponse --- src/Symfony/Component/HttpFoundation/RedirectResponse.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/RedirectResponse.php b/src/Symfony/Component/HttpFoundation/RedirectResponse.php index a21eb5cc516b2..e7f47aa259e2b 100644 --- a/src/Symfony/Component/HttpFoundation/RedirectResponse.php +++ b/src/Symfony/Component/HttpFoundation/RedirectResponse.php @@ -33,10 +33,6 @@ class RedirectResponse extends Response */ public function __construct($url, $status = 302, $headers = array()) { - if (empty($url)) { - throw new \InvalidArgumentException('Cannot redirect to an empty URL.'); - } - parent::__construct('', $status, $headers); $this->setTargetUrl($url); From ac8f8f8964a06ee65079a1c3e7ea8b873c43e6b1 Mon Sep 17 00:00:00 2001 From: Colin O'Dell Date: Wed, 17 Feb 2016 13:03:29 -0500 Subject: [PATCH 186/226] Create PULL_REQUEST_TEMPLATE.md --- .github/PULL_REQUEST_TEMPLATE.md | 10 ++++++++++ CONTRIBUTING.md | 13 ------------- 2 files changed, 10 insertions(+), 13 deletions(-) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000000000..1118d9caa21f9 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,10 @@ +| Q | A +| ------------- | --- +| Bug fix? | [yes|no] +| New feature? | [yes|no] +| BC breaks? | [yes|no] +| Deprecations? | [yes|no] +| Tests pass? | [yes|no] +| Fixed tickets | [comma-separated list of tickets fixed by the PR, if any] +| License | MIT +| Doc PR | [reference to the documentation PR, if any] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4def05128af43..170c0cadac9bf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,19 +12,6 @@ If you'd like to contribute, please read the following documents: * [Pull Request Template][3]: Template header to use in your pull request description; -```markdown -| Q | A -| ------------- | --- -| Bug fix? | yes/no -| New feature? | yes/no -| BC breaks? | no -| Deprecations? | no -| Tests pass? | yes -| Fixed tickets | #1234 -| License | MIT -| Doc PR | symfony/symfony-docs#1234 -``` - * [Backwards Compatibility][4]: Backward compatibility rules. [1]: http://symfony.com/doc/current/contributing/code/index.html From 00e38198b7859f38ab87405d13b4cffda8619461 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Wed, 17 Feb 2016 20:31:02 +0100 Subject: [PATCH 187/226] [Form] add test for ArrayChoiceList handling null --- .../Form/Tests/ChoiceList/AbstractChoiceListTest.php | 7 +++++++ .../Form/Tests/ChoiceList/ArrayChoiceListTest.php | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/AbstractChoiceListTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/AbstractChoiceListTest.php index 958bb66d506b0..08e4285f0cd53 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/AbstractChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/AbstractChoiceListTest.php @@ -209,6 +209,13 @@ public function testGetValuesForChoicesEmpty() $this->assertSame(array(), $this->list->getValuesForChoices(array())); } + public function testGetChoicesForValuesWithNull() + { + $values = $this->list->getValuesForChoices(array(null)); + + $this->assertNotEmpty($this->list->getChoicesForValues($values)); + } + /** * @return \Symfony\Component\Form\ChoiceList\ChoiceListInterface */ diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php index 9ea5f631a1585..f054fd70c07a6 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php @@ -22,9 +22,9 @@ class ArrayChoiceListTest extends AbstractChoiceListTest protected function setUp() { - parent::setUp(); - $this->object = new \stdClass(); + + parent::setUp(); } protected function createChoiceList() @@ -34,12 +34,12 @@ protected function createChoiceList() protected function getChoices() { - return array(0, 1, '1', 'a', false, true, $this->object); + return array(0, 1, '1', 'a', false, true, $this->object, null); } protected function getValues() { - return array('0', '1', '2', '3', '4', '5', '6'); + return array('0', '1', '2', '3', '4', '5', '6', '7'); } /** From 59944896f28c11bf9d94e03b6f04cea33426eda8 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 18 Feb 2016 14:55:37 +0100 Subject: [PATCH 188/226] documented the $url parameter better --- src/Symfony/Component/HttpFoundation/RedirectResponse.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/RedirectResponse.php b/src/Symfony/Component/HttpFoundation/RedirectResponse.php index e7f47aa259e2b..18d5794c0bf34 100644 --- a/src/Symfony/Component/HttpFoundation/RedirectResponse.php +++ b/src/Symfony/Component/HttpFoundation/RedirectResponse.php @@ -23,7 +23,8 @@ class RedirectResponse extends Response /** * Creates a redirect response so that it conforms to the rules defined for a redirect status code. * - * @param string $url The URL to redirect to + * @param string $url The URL to redirect to. The URL should be a full URL, with schema etc., + * but practically every browser redirects on paths only as well * @param int $status The status code (302 by default) * @param array $headers The headers (Location is always set to the given URL) * From 1f22290d8cc4fe73849c882cd742b4c958586480 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 18 Feb 2016 16:12:50 +0100 Subject: [PATCH 189/226] fixed CS --- src/Symfony/Component/Filesystem/Filesystem.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index 1b706ea068d9f..b1b8052254365 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -100,7 +100,7 @@ public function mkdir($dirs, $mode = 0777) public function exists($files) { foreach ($this->toIterator($files) as $file) { - if ('\\' === DIRECTORY_SEPARATOR AND strlen($file) > 258) { + if ('\\' === DIRECTORY_SEPARATOR && strlen($file) > 258) { throw new IOException(sprintf('Could not check if file exist because path length exceeds 258 characters for file "%s"', $file)); } @@ -276,7 +276,7 @@ public function rename($origin, $target, $overwrite = false) */ private function isReadable($filename) { - if ('\\' === DIRECTORY_SEPARATOR AND strlen($filename) > 258) { + if ('\\' === DIRECTORY_SEPARATOR && strlen($filename) > 258) { throw new IOException(sprintf('Could not check if file is readable because path length exceeds 258 characters for file "%s"', $filename)); } From a02967c9eee2e846d03c7a22bd5194706ab60646 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 18 Feb 2016 16:45:01 +0100 Subject: [PATCH 190/226] fixed CS --- src/Symfony/Bundle/FrameworkBundle/Console/Application.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Application.php b/src/Symfony/Bundle/FrameworkBundle/Console/Application.php index 3ecdb0837b28b..ddbbf8eb371c0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Application.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Application.php @@ -11,14 +11,14 @@ namespace Symfony\Bundle\FrameworkBundle\Console; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\Console\Application as BaseApplication; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Component\HttpKernel\Bundle\Bundle; -use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpKernel\KernelInterface; +use Symfony\Component\HttpKernel\Kernel; +use Symfony\Component\HttpKernel\Bundle\Bundle; /** * Application. From a2780357cad436c3feb342742aa4f1b6c79adde5 Mon Sep 17 00:00:00 2001 From: Alex Rock Ancelet Date: Fri, 19 Feb 2016 16:05:47 +0100 Subject: [PATCH 191/226] Simplify markdown for PR template --- .github/PULL_REQUEST_TEMPLATE.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 1118d9caa21f9..4cdf108270e66 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,10 +1,10 @@ | Q | A | ------------- | --- -| Bug fix? | [yes|no] -| New feature? | [yes|no] -| BC breaks? | [yes|no] -| Deprecations? | [yes|no] -| Tests pass? | [yes|no] -| Fixed tickets | [comma-separated list of tickets fixed by the PR, if any] +| Bug fix? | yes/no +| New feature? | yes/no +| BC breaks? | yes/no +| Deprecations? | yes/no +| Tests pass? | yes/no +| Fixed tickets | comma-separated list of tickets fixed by the PR, if any | License | MIT -| Doc PR | [reference to the documentation PR, if any] +| Doc PR | reference to the documentation PR, if any From 5ad065de9663d91277413285b4ff7adf9519b394 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 19 Feb 2016 17:33:18 +0100 Subject: [PATCH 192/226] Fixed the antialiasing of the toolbar text --- .../Resources/views/Profiler/toolbar.css.twig | 4 ++++ 1 file changed, 4 insertions(+) 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 cade19d0b4c1a..5dd26a41eb9fa 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig @@ -47,6 +47,10 @@ text-align: left; text-transform: none; z-index: 99999; + + /* neutralize the aliasing defined by external CSS styles */ + -webkit-font-smoothing: subpixel-antialiased; + -moz-osx-font-smoothing: auto; } .sf-toolbarreset abbr { border: dashed #777; From ce6e5ac5aa61d4a109e80041d8490b44b65243fb Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Fri, 19 Feb 2016 17:41:56 +0100 Subject: [PATCH 193/226] [2.7] [FrameworkBundle] minor fix tests added by #17569 --- .../Tests/Console/ApplicationTest.php | 62 +++++++------------ 1 file changed, 22 insertions(+), 40 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php index fc003431fad9e..fc0e7654db2ca 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php @@ -24,7 +24,7 @@ public function testBundleInterfaceImplementation() { $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface'); - $kernel = $this->getKernel(array($bundle)); + $kernel = $this->getKernel(array($bundle), true); $application = new Application($kernel); $application->doRun(new ArrayInput(array('list')), new NullOutput()); @@ -35,7 +35,7 @@ public function testBundleCommandsAreRegistered() $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle'); $bundle->expects($this->once())->method('registerCommands'); - $kernel = $this->getKernel(array($bundle)); + $kernel = $this->getKernel(array($bundle), true); $application = new Application($kernel); $application->doRun(new ArrayInput(array('list')), new NullOutput()); @@ -49,12 +49,7 @@ public function testBundleCommandsAreRetrievable() $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle'); $bundle->expects($this->once())->method('registerCommands'); - $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); - $kernel - ->expects($this->any()) - ->method('getBundles') - ->will($this->returnValue(array($bundle))) - ; + $kernel = $this->getKernel(array($bundle)); $application = new Application($kernel); $application->all(); @@ -68,12 +63,7 @@ public function testBundleSingleCommandIsRetrievable() $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle'); $bundle->expects($this->once())->method('registerCommands'); - $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); - $kernel - ->expects($this->any()) - ->method('getBundles') - ->will($this->returnValue(array($bundle))) - ; + $kernel = $this->getKernel(array($bundle)); $application = new Application($kernel); @@ -88,12 +78,7 @@ public function testBundleCommandCanBeFound() $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle'); $bundle->expects($this->once())->method('registerCommands'); - $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); - $kernel - ->expects($this->any()) - ->method('getBundles') - ->will($this->returnValue(array($bundle))) - ; + $kernel = $this->getKernel(array($bundle)); $application = new Application($kernel); @@ -108,12 +93,7 @@ public function testBundleCommandCanBeFoundByAlias() $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle'); $bundle->expects($this->once())->method('registerCommands'); - $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); - $kernel - ->expects($this->any()) - ->method('getBundles') - ->will($this->returnValue(array($bundle))) - ; + $kernel = $this->getKernel(array($bundle)); $application = new Application($kernel); @@ -130,7 +110,7 @@ public function testBundleCommandsHaveRightContainer() $command->setCode(function () {}); $command->expects($this->exactly(2))->method('setContainer'); - $application = new Application($this->getKernel(array())); + $application = new Application($this->getKernel(array(), true)); $application->setAutoExit(false); $application->setCatchExceptions(false); $application->add($command); @@ -143,21 +123,23 @@ public function testBundleCommandsHaveRightContainer() $tester->run(array('command' => 'foo')); } - private function getKernel(array $bundles) + private function getKernel(array $bundles, $useDispatcher = false) { - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $dispatcher - ->expects($this->atLeastOnce()) - ->method('dispatch') - ; - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); - $container - ->expects($this->atLeastOnce()) - ->method('get') - ->with($this->equalTo('event_dispatcher')) - ->will($this->returnValue($dispatcher)) - ; + + if ($useDispatcher) { + $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $dispatcher + ->expects($this->atLeastOnce()) + ->method('dispatch') + ; + $container + ->expects($this->atLeastOnce()) + ->method('get') + ->with($this->equalTo('event_dispatcher')) + ->will($this->returnValue($dispatcher)); + } + $container ->expects($this->once()) ->method('hasParameter') From 73a5d6c68431f14195d77666d68529553b346bac Mon Sep 17 00:00:00 2001 From: Valentin Jonovs Date: Fri, 19 Feb 2016 20:56:38 +0100 Subject: [PATCH 194/226] Improve Norwegian translations --- .../Resources/translations/validators.no.xlf | 2 +- .../Resources/translations/security.no.xlf | 4 +- .../Resources/translations/validators.no.xlf | 208 ++++++++++++++++-- 3 files changed, 189 insertions(+), 25 deletions(-) diff --git a/src/Symfony/Component/Form/Resources/translations/validators.no.xlf b/src/Symfony/Component/Form/Resources/translations/validators.no.xlf index 5e36bd5fec1d3..c64266c99189b 100644 --- a/src/Symfony/Component/Form/Resources/translations/validators.no.xlf +++ b/src/Symfony/Component/Form/Resources/translations/validators.no.xlf @@ -8,7 +8,7 @@ The uploaded file was too large. Please try to upload a smaller file. - Den opplastede file var for stor. Vennligst last opp en mindre fil. + Den opplastede filen var for stor. Vennligst last opp en mindre fil. The CSRF token is invalid. diff --git a/src/Symfony/Component/Security/Resources/translations/security.no.xlf b/src/Symfony/Component/Security/Resources/translations/security.no.xlf index 3369d43b77fd3..3635916971476 100644 --- a/src/Symfony/Component/Security/Resources/translations/security.no.xlf +++ b/src/Symfony/Component/Security/Resources/translations/security.no.xlf @@ -4,7 +4,7 @@ An authentication exception occurred. - En autentiserings feil har skjedd. + En autentiseringsfeil har skjedd. Authentication credentials could not be found. @@ -24,7 +24,7 @@ Not privileged to request the resource. - Ingen tilgang til å be om gitt kilde. + Ingen tilgang til å be om gitt ressurs. Invalid CSRF token. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf index a8b790c7d8640..9b5a20b088a2a 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf @@ -4,27 +4,27 @@ This value should be false. - Verdien skal være falsk. + Verdien må være usann. This value should be true. - Verdien skal være sann. + Verdien må være sann. This value should be of type {{ type }}. - Verdien skal være av typen {{ type }}. + Verdien må være av typen {{ type }}. This value should be blank. - Verdien skal være blank. + Verdien må være blank. The value you selected is not a valid choice. - Verdien skal være en av de gitte valg. + Den valgte verdien er ikke gyldig. You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices. - Du skal velge minst {{ limit }} valg. + Du må velge minst {{ limit }} valg. You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices. @@ -32,11 +32,11 @@ One or more of the given values is invalid. - En eller flere av de oppgitte verdier er ugyldige. + En eller flere av de oppgitte verdiene er ugyldige. This field was not expected. - Dette feltet ikke var forventet. + Dette feltet var ikke forventet. This field is missing. @@ -48,11 +48,11 @@ This value is not a valid datetime. - Verdien er ikke en gyldig dato og tid. + Verdien er ikke en gyldig dato/tid. This value is not a valid email address. - Verdien er ikke en gyldig e-mail adresse. + Verdien er ikke en gyldig e-postadresse. The file could not be found. @@ -60,7 +60,7 @@ The file is not readable. - Filen kan ikke leses. + Filen er ikke lesbar. The file is too large ({{ size }} {{ suffix }}). Allowed maximum size is {{ limit }} {{ suffix }}. @@ -72,19 +72,19 @@ This value should be {{ limit }} or less. - Verdien skal være {{ limit }} eller mindre. + Verdien må være {{ limit }} tegn lang eller mindre. This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less. - Verdien er for lang. Den skal ha {{ limit }} bokstaver eller mindre. + Verdien er for lang. Den må ha {{ limit }} tegn eller mindre. This value should be {{ limit }} or more. - Verdien skal være {{ limit }} eller mer. + Verdien må være {{ limit }} eller mer. This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more. - Verdien er for kort. Den skal ha {{ limit }} tegn eller flere. + Verdien er for kort. Den må ha {{ limit }} tegn eller flere. This value should not be blank. @@ -96,7 +96,7 @@ This value should be null. - Verdien skal være tom (null). + Verdien må være tom (null). This value is not valid. @@ -112,11 +112,11 @@ The two values should be equal. - De to verdier skal være ens. + Verdiene må være identiske. The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}. - Filen er for stor. Den maksimale størrelse er {{ limit }} {{ suffix }}. + Filen er for stor. Den maksimale størrelsen er {{ limit }} {{ suffix }}. The file is too large. @@ -128,7 +128,7 @@ This value should be a valid number. - Denne verdi skal være et gyldig tall. + Verdien må være et gyldig tall. This file is not a valid image. @@ -140,15 +140,179 @@ This value is not a valid language. - Denne verdi er ikke et gyldig språk. + Verdien er ikke et gyldig språk. This value is not a valid locale. - Denne verdi er ikke en gyldig lokalitet. + Verdien er ikke en gyldig lokalitet. This value is not a valid country. - Denne verdi er ikke et gyldig land. + Verdien er ikke et gyldig navn på land. + + + This value is already used. + Verdien er allerede brukt. + + + The size of the image could not be detected. + Bildestørrelsen kunne ikke oppdages. + + + The image width is too big ({{ width }}px). Allowed maximum width is {{ max_width }}px. + Bildebredden er for stor ({{ width }} piksler). Tillatt maksimumsbredde er {{ max_width }} piksler. + + + The image width is too small ({{ width }}px). Minimum width expected is {{ min_width }}px. + Bildebredden er for liten ({{ width }} piksler). Forventet minimumsbredde er {{ min_width }} piksler. + + + The image height is too big ({{ height }}px). Allowed maximum height is {{ max_height }}px. + Bildehøyden er for stor ({{ height }} piksler). Tillatt maksimumshøyde er {{ max_height }} piksler. + + + The image height is too small ({{ height }}px). Minimum height expected is {{ min_height }}px. + Bildehøyden er for liten ({{ height }} piksler). Forventet minimumshøyde er {{ min_height }} piksler. + + + This value should be the user's current password. + Verdien må være brukerens sitt nåværende passord. + + + This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters. + Verdien må være nøyaktig {{ limit }} tegn. + + + The file was only partially uploaded. + Filen var kun delvis opplastet. + + + No file was uploaded. + Ingen fil var lastet opp. + + + No temporary folder was configured in php.ini. + Den midlertidige mappen (tmp) er ikke konfigurert i php.ini. + + + Cannot write temporary file to disk. + Kan ikke skrive midlertidig fil til disk. + + + A PHP extension caused the upload to fail. + En PHP-utvidelse forårsaket en feil under opplasting. + + + This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more. + Denne samlingen må inneholde {{ limit }} element eller flere.|Denne samlingen må inneholde {{ limit }} elementer eller flere./target> + + + This collection should contain {{ limit }} element or less.|This collection should contain {{ limit }} elements or less. + Denne samlingen må inneholde {{ limit }} element eller færre.|Denne samlingen må inneholde {{ limit }} elementer eller færre. + + + This collection should contain exactly {{ limit }} element.|This collection should contain exactly {{ limit }} elements. + Denne samlingen må inneholde nøyaktig {{ limit }} element.|Denne samlingen må inneholde nøyaktig {{ limit }} elementer. + + + Invalid card number. + Ugyldig kortnummer. + + + Unsupported card type or invalid card number. + Korttypen er ikke støttet eller ugyldig kortnummer. + + + This is not a valid International Bank Account Number (IBAN). + Dette er ikke en gyldig IBAN. + + + This value is not a valid ISBN-10. + Verdien er ikke en gyldig ISBN-10. + + + This value is not a valid ISBN-13. + Verdien er ikke en gyldig ISBN-13. + + + This value is neither a valid ISBN-10 nor a valid ISBN-13. + Verdien er hverken en gyldig ISBN-10 eller ISBN-13. + + + This value is not a valid ISSN. + Verdien er ikke en gyldig ISSN. + + + This value is not a valid currency. + Verdien er ikke gyldig valuta. + + + This value should be equal to {{ compared_value }}. + Verdien må være lik {{ compared_value }}. + + + This value should be greater than {{ compared_value }}. + Verdien må være større enn {{ compared_value }}. + + + This value should be greater than or equal to {{ compared_value }}. + Verdien må være større enn eller lik {{ compared_value }}. + + + This value should be identical to {{ compared_value_type }} {{ compared_value }}. + Verdien må være identisk med {{ compared_value_type }} {{ compared_value }}. + + + This value should be less than {{ compared_value }}. + Verdien må være mindre enn {{ compared_value }}. + + + This value should be less than or equal to {{ compared_value }}. + Verdien må være mindre enn eller lik {{ compared_value }}. + + + This value should not be equal to {{ compared_value }}. + Verdien må ikke være lik {{ compared_value }}. + + + This value should not be identical to {{ compared_value_type }} {{ compared_value }}. + Verdien må ikke være identisk med {{ compared_value_type }} {{ compared_value }}. + + + The image ratio is too big ({{ ratio }}). Allowed maximum ratio is {{ max_ratio }}. + Bildeforholdet er for stort ({{ ratio }}). Tillatt maksimumsbildeforhold er {{ max_ratio }}. + + + The image ratio is too small ({{ ratio }}). Minimum ratio expected is {{ min_ratio }}. + Bildeforholdet er for lite ({{ ratio }}). Forventet maksimumsbildeforhold er {{ min_ratio }}. + + + The image is square ({{ width }}x{{ height }}px). Square images are not allowed. + Bildet er en kvadrat ({{ width }}x{{ height }}px). Kvadratiske bilder er ikke tillatt. + + + The image is landscape oriented ({{ width }}x{{ height }}px). Landscape oriented images are not allowed. + Bildet er i liggende retning ({{ width }}x{{ height }}px). Bilder i liggende retning er ikke tillatt. + + + The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed. + Bildet er i stående retning ({{ width }}x{{ height }}px). Bilder i stående retning er ikke tillatt. + + + An empty file is not allowed. + Tomme filer er ikke tilatt. + + + The host could not be resolved. + Vertsnavn kunne ikke løses. + + + This value does not match the expected {{ charset }} charset. + Verdien samsvarer ikke med forventet tegnsett {{ charset }}. + + + This is not a valid Business Identifier Code (BIC). + Dette er ikke en gyldig BIC. From 56f87982d8503f59423839a5f5f4c96549371ffd Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 20 Feb 2016 20:14:11 +0100 Subject: [PATCH 195/226] replace alias in factory services --- .../Compiler/ReplaceAliasByActualDefinitionPass.php | 11 +++++++++++ .../ReplaceAliasByActualDefinitionPassTest.php | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php index 8308937d4a512..fef070bcff07e 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php @@ -95,6 +95,8 @@ private function updateReferences($container, $currentId, $newId) $definition->setProperties( $this->updateArgumentReferences($definition->getProperties(), $currentId, $newId) ); + + $definition->setFactoryService($this->updateFactoryServiceReference($definition->getFactoryService(), $currentId, $newId)); } } @@ -122,4 +124,13 @@ private function updateArgumentReferences(array $arguments, $currentId, $newId) return $arguments; } + + private function updateFactoryServiceReference($factoryService, $currentId, $newId) + { + if (null === $factoryService) { + return; + } + + return $currentId === $factoryService ? $newId : $currentId; + } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ReplaceAliasByActualDefinitionPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ReplaceAliasByActualDefinitionPassTest.php index e4d22401d3cdd..ac1609f5d7d58 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ReplaceAliasByActualDefinitionPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ReplaceAliasByActualDefinitionPassTest.php @@ -21,7 +21,9 @@ public function testProcess() { $container = new ContainerBuilder(); - $container->register('a', '\stdClass'); + $aDefinition = $container->register('a', '\stdClass'); + $aDefinition->setFactoryService('b'); + $aDefinition->setFactoryMethod('createA'); $bDefinition = new Definition('\stdClass'); $bDefinition->setPublic(false); @@ -39,6 +41,7 @@ public function testProcess() $container->has('b_alias') && !$container->hasAlias('b_alias'), '->process() replaces alias to actual.' ); + $this->assertSame('b_alias', $aDefinition->getFactoryService()); } /** From 7aff7f42c1e771995b1498e989307c4be1733f65 Mon Sep 17 00:00:00 2001 From: SpacePossum Date: Sun, 21 Feb 2016 12:34:19 +0100 Subject: [PATCH 196/226] PhpUnitNoDedicateAssertFixer results --- .../CollectionToArrayTransformerTest.php | 8 ++++---- .../Tests/Definition/Builder/TreeBuilderTest.php | 2 +- .../Component/Finder/Tests/Shell/CommandTest.php | 2 +- .../Component/HttpFoundation/Tests/File/FileTest.php | 12 ++++++------ .../HttpFoundation/Tests/File/UploadedFileTest.php | 4 ++-- .../HttpKernel/Tests/CacheWarmer/CacheWarmerTest.php | 2 +- .../Data/Bundle/Reader/JsonBundleReaderTest.php | 2 +- .../Tests/Data/Bundle/Reader/PhpBundleReaderTest.php | 2 +- .../Security/Tests/Core/SecurityContextTest.php | 2 +- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Symfony/Bridge/Propel1/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php b/src/Symfony/Bridge/Propel1/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php index f8424dda9c635..9426d5c09b6e8 100644 --- a/src/Symfony/Bridge/Propel1/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php +++ b/src/Symfony/Bridge/Propel1/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php @@ -27,7 +27,7 @@ public function testTransform() { $result = $this->transformer->transform(new \PropelObjectCollection()); - $this->assertTrue(is_array($result)); + $this->assertInternalType('array', $result); $this->assertCount(0, $result); } @@ -35,7 +35,7 @@ public function testTransformWithNull() { $result = $this->transformer->transform(null); - $this->assertTrue(is_array($result)); + $this->assertInternalType('array', $result); $this->assertCount(0, $result); } @@ -54,7 +54,7 @@ public function testTransformWithData() $result = $this->transformer->transform($coll); - $this->assertTrue(is_array($result)); + $this->assertInternalType('array', $result); $this->assertCount(2, $result); $this->assertEquals('foo', $result[0]); $this->assertEquals('bar', $result[1]); @@ -93,7 +93,7 @@ public function testReverseTransformWithData() $this->assertInstanceOf('\PropelObjectCollection', $result); - $this->assertTrue(is_array($data)); + $this->assertInternalType('array', $data); $this->assertCount(2, $data); $this->assertEquals('foo', $data[0]); $this->assertEquals('bar', $data[1]); diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/TreeBuilderTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/TreeBuilderTest.php index 00e27c630a1dc..a146e89c32ae8 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/TreeBuilderTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/TreeBuilderTest.php @@ -120,7 +120,7 @@ public function testDefinitionExampleGetsTransferredToNode() $tree = $builder->buildTree(); $children = $tree->getChildren(); - $this->assertTrue(is_array($tree->getExample())); + $this->assertInternalType('array', $tree->getExample()); $this->assertEquals('example', $children['child']->getExample()); } } diff --git a/src/Symfony/Component/Finder/Tests/Shell/CommandTest.php b/src/Symfony/Component/Finder/Tests/Shell/CommandTest.php index e9145127eaba1..0c19ab47a88c1 100644 --- a/src/Symfony/Component/Finder/Tests/Shell/CommandTest.php +++ b/src/Symfony/Component/Finder/Tests/Shell/CommandTest.php @@ -146,7 +146,7 @@ public function testExecute() $cmd->add('--version'); $result = $cmd->execute(); - $this->assertTrue(is_array($result)); + $this->assertInternalType('array', $result); $this->assertNotEmpty($result); $this->assertRegexp('/PHP|HipHop/', $result[0]); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php b/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php index 90a143367abcb..d9b9b1f7a327a 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php @@ -81,8 +81,8 @@ public function testMove() $movedFile = $file->move($targetDir); $this->assertInstanceOf('Symfony\Component\HttpFoundation\File\File', $movedFile); - $this->assertTrue(file_exists($targetPath)); - $this->assertFalse(file_exists($path)); + $this->assertFileExists($targetPath); + $this->assertFileNotExists($path); $this->assertEquals(realpath($targetPath), $movedFile->getRealPath()); @unlink($targetPath); @@ -100,8 +100,8 @@ public function testMoveWithNewName() $file = new File($path); $movedFile = $file->move($targetDir, 'test.newname.gif'); - $this->assertTrue(file_exists($targetPath)); - $this->assertFalse(file_exists($path)); + $this->assertFileExists($targetPath); + $this->assertFileNotExists($path); $this->assertEquals(realpath($targetPath), $movedFile->getRealPath()); @unlink($targetPath); @@ -135,8 +135,8 @@ public function testMoveWithNonLatinName($filename, $sanitizedFilename) $movedFile = $file->move($targetDir, $filename); $this->assertInstanceOf('Symfony\Component\HttpFoundation\File\File', $movedFile); - $this->assertTrue(file_exists($targetPath)); - $this->assertFalse(file_exists($path)); + $this->assertFileExists($targetPath); + $this->assertFileNotExists($path); $this->assertEquals(realpath($targetPath), $movedFile->getRealPath()); @unlink($targetPath); diff --git a/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php b/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php index f6ea340091ba5..2e2d27409caa4 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/File/UploadedFileTest.php @@ -164,8 +164,8 @@ public function testMoveLocalFileIsAllowedInTestMode() $movedFile = $file->move(__DIR__.'/Fixtures/directory'); - $this->assertTrue(file_exists($targetPath)); - $this->assertFalse(file_exists($path)); + $this->assertFileExists($targetPath); + $this->assertFileNotExists($path); $this->assertEquals(realpath($targetPath), $movedFile->getRealPath()); @unlink($targetPath); diff --git a/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerTest.php b/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerTest.php index f0ab05d62efe2..fe5ecb2ed313a 100644 --- a/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerTest.php @@ -32,7 +32,7 @@ public function testWriteCacheFileCreatesTheFile() $warmer = new TestCacheWarmer(self::$cacheFile); $warmer->warmUp(dirname(self::$cacheFile)); - $this->assertTrue(file_exists(self::$cacheFile)); + $this->assertFileExists(self::$cacheFile); } /** diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/JsonBundleReaderTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/JsonBundleReaderTest.php index 2cc4607b1129e..a6183edfe0737 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/JsonBundleReaderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/JsonBundleReaderTest.php @@ -32,7 +32,7 @@ public function testReadReturnsArray() { $data = $this->reader->read(__DIR__.'/Fixtures/json', 'en'); - $this->assertTrue(is_array($data)); + $this->assertInternalType('array', $data); $this->assertSame('Bar', $data['Foo']); $this->assertFalse(isset($data['ExistsNot'])); } diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/PhpBundleReaderTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/PhpBundleReaderTest.php index 2beaec7ba26b8..3c58ee7c416cf 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/PhpBundleReaderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/PhpBundleReaderTest.php @@ -32,7 +32,7 @@ public function testReadReturnsArray() { $data = $this->reader->read(__DIR__.'/Fixtures/php', 'en'); - $this->assertTrue(is_array($data)); + $this->assertInternalType('array', $data); $this->assertSame('Bar', $data['Foo']); $this->assertFalse(isset($data['ExistsNot'])); } diff --git a/src/Symfony/Component/Security/Tests/Core/SecurityContextTest.php b/src/Symfony/Component/Security/Tests/Core/SecurityContextTest.php index 66958892d3205..3fba8d958cc49 100644 --- a/src/Symfony/Component/Security/Tests/Core/SecurityContextTest.php +++ b/src/Symfony/Component/Security/Tests/Core/SecurityContextTest.php @@ -92,6 +92,6 @@ public function testGetSetToken() public function testTranslationsAreNotInCore() { - $this->assertFalse(file_exists(__DIR__.'/../../Core/Resources/translations/')); + $this->assertFileNotExists(__DIR__.'/../../Core/Resources/translations/'); } } From aaad5bd3d193a94b8ac02b54357bee1042ae0a5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Fri, 29 Jan 2016 16:46:56 +0100 Subject: [PATCH 197/226] Add check on If-Range header Also verify edge case where no last-modified header is available --- .../HttpFoundation/BinaryFileResponse.php | 15 +++++- .../Tests/BinaryFileResponseTest.php | 50 +++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index d5b1c34bf4b3c..22f84da4a4758 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -220,7 +220,7 @@ public function prepare(Request $request) $this->maxlen = 0; } elseif ($request->headers->has('Range')) { // Process the range headers. - if (!$request->headers->has('If-Range') || $this->getEtag() === $request->headers->get('If-Range')) { + if (!$request->headers->has('If-Range') || $this->hasValidIfRangeHeader($request->headers->get('If-Range'))) { $range = $request->headers->get('Range'); $fileSize = $this->file->getSize(); @@ -253,6 +253,19 @@ public function prepare(Request $request) return $this; } + private function hasValidIfRangeHeader($header) + { + if ($this->getEtag() === $header) { + return true; + } + + if (null === $lastModified = $this->getLastModified()) { + return false; + } + + return $lastModified->format('D, d M Y H:i:s').' GMT' === $header; + } + /** * Sends the file. * diff --git a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php index 35dfab5366501..88fb251366c53 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php @@ -80,6 +80,37 @@ public function testRequests($requestRange, $offset, $length, $responseRange) $this->assertEquals($responseRange, $response->headers->get('Content-Range')); } + /** + * @dataProvider provideRanges + */ + public function testRequestsWithoutEtag($requestRange, $offset, $length, $responseRange) + { + $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, array('Content-Type' => 'application/octet-stream')); + + // do a request to get the LastModified + $request = Request::create('/'); + $response->prepare($request); + $lastModified = $response->headers->get('Last-Modified'); + + // prepare a request for a range of the testing file + $request = Request::create('/'); + $request->headers->set('If-Range', $lastModified); + $request->headers->set('Range', $requestRange); + + $file = fopen(__DIR__.'/File/Fixtures/test.gif', 'r'); + fseek($file, $offset); + $data = fread($file, $length); + fclose($file); + + $this->expectOutputString($data); + $response = clone $response; + $response->prepare($request); + $response->sendContent(); + + $this->assertEquals(206, $response->getStatusCode()); + $this->assertEquals($responseRange, $response->headers->get('Content-Range')); + } + public function provideRanges() { return array( @@ -91,6 +122,25 @@ public function provideRanges() ); } + public function testRangeRequestsWithoutLastModifiedDate() + { + // prevent auto last modified + $response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, array('Content-Type' => 'application/octet-stream'), true, null, false, false); + + // prepare a request for a range of the testing file + $request = Request::create('/'); + $request->headers->set('If-Range', date('D, d M Y H:i:s').' GMT'); + $request->headers->set('Range', 'bytes=1-4'); + + $this->expectOutputString(file_get_contents(__DIR__.'/File/Fixtures/test.gif')); + $response = clone $response; + $response->prepare($request); + $response->sendContent(); + + $this->assertEquals(200, $response->getStatusCode()); + $this->assertNull($response->headers->get('Content-Range')); + } + /** * @dataProvider provideFullFileRanges */ From d29f04c1494560c67c89ea26a8599a55daeb056c Mon Sep 17 00:00:00 2001 From: Tom Van Looy Date: Mon, 22 Feb 2016 14:30:57 +0100 Subject: [PATCH 198/226] Update twig.html.twig Replace base64 template icon with svg version. If you set the Content-Security-Policy you would need to provide "img-src 'self' data:;" just for that icon (or get an error in the console). This should be fixed in the new version of the toolbar but it would be nice to have a fix for 2.7 LTS too. --- .../Resources/views/Collector/twig.html.twig | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/twig.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/twig.html.twig index 0ecd469bd0732..ba23a3c83db6b 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/twig.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/twig.html.twig @@ -3,7 +3,13 @@ {% block toolbar %} {% set time = collector.templatecount ? '%0.0f ms'|format(collector.time) : 'n/a' %} {% set icon %} - Twig + + + + + + + {{ time }} {% endset %} {% set text %} @@ -29,7 +35,15 @@ {% block menu %} - Twig + + + + + + + + + Twig {{ collector.templatecount }} From 3eac4693ad8e63283bb715375ab690999717d92b Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Thu, 11 Feb 2016 09:01:47 +0100 Subject: [PATCH 199/226] [Form] fix choice value "false" in ChoiceType --- .../Form/ChoiceList/ArrayChoiceList.php | 6 +- .../ChoiceToValueTransformer.php | 4 +- .../Tests/ChoiceList/ArrayChoiceListTest.php | 25 +++ .../ChoiceToValueTransformerTest.php | 40 +++-- .../ChoicesToValuesTransformerTest.php | 20 ++- .../Extension/Core/Type/ChoiceTypeTest.php | 152 ++++++++++++++++++ 6 files changed, 230 insertions(+), 17 deletions(-) diff --git a/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php b/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php index e979455ef3799..b89d7b324c622 100644 --- a/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php +++ b/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php @@ -76,7 +76,7 @@ public function __construct($choices, $value = null) if (null === $value && $this->castableToString($choices)) { $value = function ($choice) { - return (string) $choice; + return false === $choice ? '0' : (string) $choice; }; } @@ -235,11 +235,11 @@ private function castableToString(array $choices, array &$cache = array()) continue; } elseif (!is_scalar($choice)) { return false; - } elseif (isset($cache[(string) $choice])) { + } elseif (isset($cache[$choice])) { return false; } - $cache[(string) $choice] = true; + $cache[$choice] = true; } return true; diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToValueTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToValueTransformer.php index ffffddedc3bef..c7a6655b4e65a 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToValueTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToValueTransformer.php @@ -39,8 +39,8 @@ public function transform($choice) public function reverseTransform($value) { - if (null !== $value && !is_scalar($value)) { - throw new TransformationFailedException('Expected a scalar.'); + if (null !== $value && !is_string($value)) { + throw new TransformationFailedException('Expected a string or null.'); } $choices = $this->choiceList->getChoicesForValues(array((string) $value)); diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php index 9ea5f631a1585..07574013bf7bf 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/ArrayChoiceListTest.php @@ -137,4 +137,29 @@ public function testGetChoicesForValuesWithContainingNull() $this->assertSame(array(0 => null), $choiceList->getChoicesForValues(array('0'))); } + + public function testGetChoicesForValuesWithContainingFalseAndNull() + { + $choiceList = new ArrayChoiceList(array('False' => false, 'Null' => null)); + + $this->assertSame(array(0 => null), $choiceList->getChoicesForValues(array('1'))); + $this->assertSame(array(0 => false), $choiceList->getChoicesForValues(array('0'))); + } + + public function testGetChoicesForValuesWithContainingEmptyStringAndNull() + { + $choiceList = new ArrayChoiceList(array('Empty String' => '', 'Null' => null)); + + $this->assertSame(array(0 => ''), $choiceList->getChoicesForValues(array('0'))); + $this->assertSame(array(0 => null), $choiceList->getChoicesForValues(array('1'))); + } + + public function testGetChoicesForValuesWithContainingEmptyStringAndBooleans() + { + $choiceList = new ArrayChoiceList(array('Empty String' => '', 'True' => true, 'False' => false)); + + $this->assertSame(array(0 => ''), $choiceList->getChoicesForValues(array(''))); + $this->assertSame(array(0 => true), $choiceList->getChoicesForValues(array('1'))); + $this->assertSame(array(0 => false), $choiceList->getChoicesForValues(array('0'))); + } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php index f60ef05abc507..5362ab9fc76cd 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php @@ -17,34 +17,41 @@ class ChoiceToValueTransformerTest extends \PHPUnit_Framework_TestCase { protected $transformer; + protected $transformerWithNull; protected function setUp() { - $list = new ArrayChoiceList(array('', false, 'X')); + $list = new ArrayChoiceList(array('', false, 'X', true)); + $listWithNull = new ArrayChoiceList(array('', false, 'X', null)); $this->transformer = new ChoiceToValueTransformer($list); + $this->transformerWithNull = new ChoiceToValueTransformer($listWithNull); } protected function tearDown() { $this->transformer = null; + $this->transformerWithNull = null; } public function transformProvider() { return array( // more extensive test set can be found in FormUtilTest - array('', '0'), - array(false, '1'), + array('', '', '', '0'), + array(false, '0', false, '1'), + array('X', 'X', 'X', '2'), + array(true, '1', null, '3'), ); } /** * @dataProvider transformProvider */ - public function testTransform($in, $out) + public function testTransform($in, $out, $inWithNull, $outWithNull) { $this->assertSame($out, $this->transformer->transform($in)); + $this->assertSame($outWithNull, $this->transformerWithNull->transform($inWithNull)); } public function reverseTransformProvider() @@ -52,25 +59,38 @@ public function reverseTransformProvider() return array( // values are expected to be valid choice keys already and stay // the same - array('0', ''), - array('1', false), - array('2', 'X'), + array('', '', '0', ''), + array('0', false, '1', false), + array('X', 'X', '2', 'X'), + array('1', true, '3', null), ); } /** * @dataProvider reverseTransformProvider */ - public function testReverseTransform($in, $out) + public function testReverseTransform($in, $out, $inWithNull, $outWithNull) { $this->assertSame($out, $this->transformer->reverseTransform($in)); + $this->assertSame($outWithNull, $this->transformerWithNull->reverseTransform($inWithNull)); + } + + public function reverseTransformExpectsStringOrNullProvider() + { + return array( + array(0), + array(true), + array(false), + array(array()), + ); } /** + * @dataProvider reverseTransformExpectsStringOrNullProvider * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ - public function testReverseTransformExpectsScalar() + public function testReverseTransformExpectsStringOrNull($value) { - $this->transformer->reverseTransform(array()); + $this->transformer->reverseTransform($value); } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php index f7747aaccd0f1..d6fe4edd31f0b 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php @@ -17,24 +17,34 @@ class ChoicesToValuesTransformerTest extends \PHPUnit_Framework_TestCase { protected $transformer; + protected $transformerWithNull; protected function setUp() { $list = new ArrayChoiceList(array('', false, 'X')); + $listWithNull = new ArrayChoiceList(array('', false, 'X', null)); + $this->transformer = new ChoicesToValuesTransformer($list); + $this->transformerWithNull = new ChoicesToValuesTransformer($listWithNull); } protected function tearDown() { $this->transformer = null; + $this->transformerWithNull = null; } public function testTransform() { $in = array('', false, 'X'); - $out = array('0', '1', '2'); + $out = array('', '0', 'X'); $this->assertSame($out, $this->transformer->transform($in)); + + $in[] = null; + $outWithNull = array('0', '1', '2', '3'); + + $this->assertSame($outWithNull, $this->transformerWithNull->transform($in)); } public function testTransformNull() @@ -53,15 +63,21 @@ public function testTransformExpectsArray() public function testReverseTransform() { // values are expected to be valid choices and stay the same - $in = array('0', '1', '2'); + $in = array('', '0', 'X'); $out = array('', false, 'X'); $this->assertSame($out, $this->transformer->reverseTransform($in)); + // values are expected to be valid choices and stay the same + $inWithNull = array('0','1','2','3'); + $out[] = null; + + $this->assertSame($out, $this->transformerWithNull->reverseTransform($inWithNull)); } public function testReverseTransformNull() { $this->assertSame(array(), $this->transformer->reverseTransform(null)); + $this->assertSame(array(), $this->transformerWithNull->reverseTransform(null)); } /** diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php index cf74fec212ec5..6128b3dfddfe7 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php @@ -26,6 +26,12 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase 'Roman' => 'e', ); + private $scalarChoices = array( + 'Yes' => true, + 'No' => false, + 'n/a' => '', + ); + private $numericChoicesFlipped = array( 0 => 'Bernhard', 1 => 'Fabien', @@ -139,6 +145,58 @@ public function testExpandedFlippedChoicesOptionsTurnIntoChildren() $this->assertCount(count($this->choices), $form, 'Each choice should become a new field'); } + public function testChoiceListWithScalarValues() + { + $view = $this->factory->create('choice', null, array( + 'choices' => $this->scalarChoices, + 'choices_as_values' => true, + ))->createView(); + + $this->assertSame('1', $view->vars['choices'][0]->value); + $this->assertSame('0', $view->vars['choices'][1]->value); + $this->assertSame('', $view->vars['choices'][2]->value); + $this->assertFalse($view->vars['is_selected']($view->vars['choices'][0], $view->vars['value']), 'True value should not be pre selected'); + $this->assertFalse($view->vars['is_selected']($view->vars['choices'][1], $view->vars['value']), 'False value should not be pre selected'); + $this->assertFalse($view->vars['is_selected']($view->vars['choices'][2], $view->vars['value']), 'Empty value should not be pre selected'); + } + + public function testChoiceListWithScalarValuesAndFalseAsPreSetData() + { + $view = $this->factory->create('choice', false, array( + 'choices' => $this->scalarChoices, + 'choices_as_values' => true, + ))->createView(); + + $this->assertTrue($view->vars['is_selected']($view->vars['choices'][1]->value, $view->vars['value']), 'False value should be pre selected'); + } + + public function testExpandedChoiceListWithScalarValues() + { + $view = $this->factory->create('choice', null, array( + 'choices' => $this->scalarChoices, + 'choices_as_values' => true, + 'expanded' => true, + ))->createView(); + + $this->assertFalse($view->children[0]->vars['checked'], 'True value should not be pre selected'); + $this->assertFalse($view->children[1]->vars['checked'], 'False value should not be pre selected'); + $this->assertTrue($view->children[2]->vars['checked'], 'Empty value should be pre selected'); + } + + public function testExpandedChoiceListWithScalarValuesAndFalseAsPreSetData() + { + $view = $this->factory->create('choice', false, array( + 'choices' => $this->scalarChoices, + 'choices_as_values' => true, + 'expanded' => true, + ))->createView(); + + $this->assertSame('1', $view->vars['choices'][0]->value); + $this->assertSame('0', $view->vars['choices'][1]->value); + $this->assertTrue($view->children[1]->vars['checked'], 'False value should be pre selected'); + $this->assertFalse($view->children[2]->vars['checked'], 'Empty value should not be pre selected'); + } + public function testPlaceholderPresentOnNonRequiredExpandedSingleChoice() { $form = $this->factory->create('choice', null, array( @@ -198,6 +256,100 @@ public function testPlaceholderNotPresentIfEmptyChoice() $this->assertCount(2, $form, 'Each choice should become a new field'); } + public function testPlaceholderWithBooleanChoices() + { + $form = $this->factory->create('choice', null, array( + 'multiple' => false, + 'expanded' => false, + 'required' => false, + 'choices' => array( + 'Yes' => true, + 'No' => false, + ), + 'placeholder' => 'Select an option', + 'choices_as_values' => true, + )); + + $view = $form->createView(); + + $this->assertSame('', $view->vars['value'], 'Value should be empty'); + $this->assertSame('1', $view->vars['choices'][0]->value); + $this->assertSame('0', $view->vars['choices'][1]->value, 'Choice "false" should have "0" as value'); + $this->assertFalse($view->vars['is_selected']($view->vars['choices'][1]->value, $view->vars['value']), 'Choice "false" should not be selected'); + } + + public function testPlaceholderWithBooleanChoicesWithFalseAsPreSetData() + { + $form = $this->factory->create('choice', false, array( + 'multiple' => false, + 'expanded' => false, + 'required' => false, + 'choices' => array( + 'Yes' => true, + 'No' => false, + ), + 'placeholder' => 'Select an option', + 'choices_as_values' => true, + )); + + $view = $form->createView(); + + $this->assertSame('0', $view->vars['value'], 'Value should be "0"'); + $this->assertSame('1', $view->vars['choices'][0]->value); + $this->assertSame('0', $view->vars['choices'][1]->value, 'Choice "false" should have "0" as value'); + $this->assertTrue($view->vars['is_selected']($view->vars['choices'][1]->value, $view->vars['value']), 'Choice "false" should be selected'); + } + + public function testPlaceholderWithExpandedBooleanChoices() + { + $form = $this->factory->create('choice', null, array( + 'multiple' => false, + 'expanded' => true, + 'required' => false, + 'choices' => array( + 'Yes' => true, + 'No' => false, + ), + 'placeholder' => 'Select an option', + 'choices_as_values' => true, + )); + + $this->assertTrue(isset($form['placeholder']), 'Placeholder should be set'); + $this->assertCount(3, $form, 'Each choice should become a new field, placeholder included'); + + $view = $form->createView(); + + $this->assertSame('', $view->vars['value'], 'Value should be empty'); + $this->assertSame('1', $view->vars['choices'][0]->value); + $this->assertSame('0', $view->vars['choices'][1]->value, 'Choice "false" should have "0" as value'); + $this->assertFalse($view->children[1]->vars['checked'], 'Choice "false" should not be selected'); + } + + public function testPlaceholderWithExpandedBooleanChoicesAndWithFalseAsPreSetData() + { + $form = $this->factory->create('choice', false, array( + 'multiple' => false, + 'expanded' => true, + 'required' => false, + 'choices' => array( + 'Yes' => true, + 'No' => false, + ), + 'placeholder' => 'Select an option', + 'choices_as_values' => true, + )); + + $this->assertTrue(isset($form['placeholder']), 'Placeholder should be set'); + $this->assertCount(3, $form, 'Each choice should become a new field, placeholder included'); + + $view = $form->createView(); + + $this->assertSame('0', $view->vars['value'], 'Value should be "0"'); + $this->assertSame('1', $view->vars['choices'][0]->value); + $this->assertSame('0', $view->vars['choices'][1]->value, 'Choice "false" should have "0" as value'); + $this->assertTrue($view->children[1]->vars['checked'], 'Choice "false" should be selected'); + } + public function testExpandedChoicesOptionsAreFlattened() { $form = $this->factory->create('choice', null, array( From 8f918e5f84c53826d025cbb1f3a0bfe093acc4e0 Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Fri, 19 Feb 2016 15:39:54 +0100 Subject: [PATCH 200/226] [Form] refactor `RadioListMapper::mapDataToForm()` This fixes "false" choice pre selection when `ChoiceType` is `expanded` and not `multiple` --- .../Form/Extension/Core/DataMapper/RadioListMapper.php | 6 ++---- .../Component/Form/Extension/Core/Type/ChoiceType.php | 8 ++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Core/DataMapper/RadioListMapper.php b/src/Symfony/Component/Form/Extension/Core/DataMapper/RadioListMapper.php index 19db183a28394..d08a603b5c90e 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataMapper/RadioListMapper.php +++ b/src/Symfony/Component/Form/Extension/Core/DataMapper/RadioListMapper.php @@ -38,13 +38,11 @@ public function __construct(ChoiceListInterface $choiceList) /** * {@inheritdoc} */ - public function mapDataToForms($choice, $radios) + public function mapDataToForms($data, $radios) { - $valueMap = array_flip($this->choiceList->getValuesForChoices(array($choice))); - foreach ($radios as $radio) { $value = $radio->getConfig()->getOption('value'); - $radio->setData(isset($valueMap[$value]) ? true : false); + $radio->setData($value === $data ? true : false); } } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index 58832ab2f8e06..ffabf8db4677a 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -143,6 +143,14 @@ public function buildForm(FormBuilderInterface $builder, array $options) $event->setData(null); } }); + // For radio lists, pre selection of the choice needs to pre set data + // with the string value so it can be matched in + // {@link \Symfony\Component\Form\Extension\Core\DataMapper\RadioListMapper::mapDataToForms()} + $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { + $choiceList = $event->getForm()->getConfig()->getOption('choice_list'); + $value = current($choiceList->getValuesForChoices(array($event->getData()))); + $event->setData((string) $value); + }); } } elseif ($options['multiple']) { //