From 0d5f7e29050cf161dd620b4fa6d004d2cc7a81dc Mon Sep 17 00:00:00 2001 From: flip111 Date: Sat, 12 Dec 2015 17:45:35 +0100 Subject: [PATCH 001/106] 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 0fe3088dea6f0210efc13cc1f9a0581192f560a3 Mon Sep 17 00:00:00 2001 From: Toni Uebernickel Date: Wed, 27 Jan 2016 13:18:03 +0100 Subject: [PATCH 002/106] 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 cb1a921bb918f7fea25521ce02fcdda43be7f580 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 29 Jan 2016 13:24:08 +0100 Subject: [PATCH 003/106] 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 d120c08f8b72236460de5cbe95140b60358799c0 Mon Sep 17 00:00:00 2001 From: Dmytro Boiko Date: Sat, 30 Jan 2016 19:26:34 +0200 Subject: [PATCH 004/106] [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 @@ - + + > - + 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 006/106] [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 007/106] [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 439303eb2488fc54f65ee3448bf227112c61c50c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 3 Feb 2016 14:57:15 +0100 Subject: [PATCH 008/106] bumped Symfony version to 3.0.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 df51e91ad80d5..da074722d1dbc 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 = '3.0.2'; - const VERSION_ID = 30002; + const VERSION = '3.0.3-DEV'; + const VERSION_ID = 30003; const MAJOR_VERSION = 3; const MINOR_VERSION = 0; - const RELEASE_VERSION = 2; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 3; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '07/2016'; const END_OF_LIFE = '01/2017'; From 0e45a4a5de7bc8e087da5db3d0d6640ab59c97de Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 3 Feb 2016 18:56:43 +0100 Subject: [PATCH 009/106] [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 010/106] 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 011/106] 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 012/106] [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 013/106] [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 a9d9d62e9b78b02d3b278c8bbbaabeb5aaf8fd37 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Sat, 16 Jan 2016 04:28:49 +0100 Subject: [PATCH 014/106] [Validator] remove obsolete context and PropertyAccess code --- .../Resources/config/validator.xml | 1 - .../Validator/Constraints/FormValidator.php | 27 ++--------- .../Validator/ConstraintValidatorFactory.php | 7 +-- .../Constraints/ExpressionValidator.php | 48 ++----------------- .../Constraints/ExpressionValidatorTest.php | 4 +- .../Component/Validator/ValidatorBuilder.php | 12 +---- src/Symfony/Component/Validator/composer.json | 1 - 7 files changed, 11 insertions(+), 89 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml index ac153f91b27a5..1776b0b8073dc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml @@ -38,7 +38,6 @@ - diff --git a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php index 9a35ebe047c8e..c9802909e7a1b 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php +++ b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php @@ -15,7 +15,6 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** @@ -38,11 +37,8 @@ public function validate($form, Constraint $constraint) /* @var FormInterface $form */ $config = $form->getConfig(); - $validator = null; - if ($this->context instanceof ExecutionContextInterface) { - $validator = $this->context->getValidator()->inContext($this->context); - } + $validator = $this->context->getValidator()->inContext($this->context); if ($form->isSynchronized()) { // Validate the form data only if transformation succeeded @@ -51,12 +47,7 @@ public function validate($form, Constraint $constraint) // Validate the data against its own constraints if (self::allowDataWalking($form)) { foreach ($groups as $group) { - if ($validator) { - $validator->atPath('data')->validate($form->getData(), null, $group); - } else { - // 2.4 API - $this->context->validate($form->getData(), 'data', $group, true); - } + $validator->atPath('data')->validate($form->getData(), null, $group); } } @@ -66,12 +57,7 @@ public function validate($form, Constraint $constraint) foreach ($constraints as $constraint) { // For the "Valid" constraint, validate the data in all groups if ($constraint instanceof Valid) { - if ($validator) { - $validator->atPath('data')->validate($form->getData(), $constraint, $groups); - } else { - // 2.4 API - $this->context->validateValue($form->getData(), $constraint, 'data', $groups); - } + $validator->atPath('data')->validate($form->getData(), $constraint, $groups); continue; } @@ -80,12 +66,7 @@ public function validate($form, Constraint $constraint) // matching group foreach ($groups as $group) { if (in_array($group, $constraint->groups)) { - if ($validator) { - $validator->atPath('data')->validate($form->getData(), $constraint, $group); - } else { - // 2.4 API - $this->context->validateValue($form->getData(), $constraint, 'data', $group); - } + $validator->atPath('data')->validate($form->getData(), $constraint, $group); // Prevent duplicate validation continue 2; diff --git a/src/Symfony/Component/Validator/ConstraintValidatorFactory.php b/src/Symfony/Component/Validator/ConstraintValidatorFactory.php index cc6981b9461ce..86e44e2a5580f 100644 --- a/src/Symfony/Component/Validator/ConstraintValidatorFactory.php +++ b/src/Symfony/Component/Validator/ConstraintValidatorFactory.php @@ -26,11 +26,8 @@ class ConstraintValidatorFactory implements ConstraintValidatorFactoryInterface { protected $validators = array(); - private $propertyAccessor; - - public function __construct($propertyAccessor = null) + public function __construct() { - $this->propertyAccessor = $propertyAccessor; } /** @@ -42,7 +39,7 @@ public function getInstance(Constraint $constraint) if (!isset($this->validators[$className])) { $this->validators[$className] = 'validator.expression' === $className - ? new ExpressionValidator($this->propertyAccessor) + ? new ExpressionValidator() : new $className(); } diff --git a/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php b/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php index 46ddceece0276..e2f3139af73b8 100644 --- a/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php @@ -12,12 +12,8 @@ namespace Symfony\Component\Validator\Constraints; use Symfony\Component\ExpressionLanguage\ExpressionLanguage; -use Symfony\Component\PropertyAccess\PropertyAccess; -use Symfony\Component\PropertyAccess\PropertyAccessorInterface; -use Symfony\Component\PropertyAccess\PropertyPath; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Exception\RuntimeException; use Symfony\Component\Validator\Exception\UnexpectedTypeException; @@ -27,19 +23,13 @@ */ class ExpressionValidator extends ConstraintValidator { - /** - * @var PropertyAccessorInterface - */ - private $propertyAccessor; - /** * @var ExpressionLanguage */ private $expressionLanguage; - public function __construct(PropertyAccessorInterface $propertyAccessor = null, ExpressionLanguage $expressionLanguage = null) + public function __construct($propertyAccessor = null, ExpressionLanguage $expressionLanguage = null) { - $this->propertyAccessor = $propertyAccessor; $this->expressionLanguage = $expressionLanguage; } @@ -53,28 +43,8 @@ public function validate($value, Constraint $constraint) } $variables = array(); - - // Symfony 2.5+ - if ($this->context instanceof ExecutionContextInterface) { - $variables['value'] = $value; - $variables['this'] = $this->context->getObject(); - } elseif (null === $this->context->getPropertyName()) { - $variables['value'] = $value; - $variables['this'] = $value; - } else { - $root = $this->context->getRoot(); - $variables['value'] = $value; - - if (is_object($root)) { - // Extract the object that the property belongs to from the object - // graph - $path = new PropertyPath($this->context->getPropertyPath()); - $parentPath = $path->getParent(); - $variables['this'] = $parentPath ? $this->getPropertyAccessor()->getValue($root, $parentPath) : $root; - } else { - $variables['this'] = null; - } - } + $variables['value'] = $value; + $variables['this'] = $this->context->getObject(); if (!$this->getExpressionLanguage()->evaluate($constraint->expression, $variables)) { $this->context->buildViolation($constraint->message) @@ -95,16 +65,4 @@ private function getExpressionLanguage() return $this->expressionLanguage; } - - private function getPropertyAccessor() - { - if (null === $this->propertyAccessor) { - if (!class_exists('Symfony\Component\PropertyAccess\PropertyAccess')) { - throw new RuntimeException('Unable to use expressions as the Symfony PropertyAccess component is not installed.'); - } - $this->propertyAccessor = PropertyAccess::createPropertyAccessor(); - } - - return $this->propertyAccessor; - } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php index 930edc780772e..c76920fbb20d4 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php @@ -11,17 +11,15 @@ namespace Symfony\Component\Validator\Tests\Constraints; -use Symfony\Component\PropertyAccess\PropertyAccess; use Symfony\Component\Validator\Constraints\Expression; use Symfony\Component\Validator\Constraints\ExpressionValidator; use Symfony\Component\Validator\Tests\Fixtures\Entity; -use Symfony\Component\Validator\Validation; class ExpressionValidatorTest extends AbstractConstraintValidatorTest { protected function createValidator() { - return new ExpressionValidator(PropertyAccess::createPropertyAccessor()); + return new ExpressionValidator(); } public function testExpressionIsEvaluatedWithNullValue() diff --git a/src/Symfony/Component/Validator/ValidatorBuilder.php b/src/Symfony/Component/Validator/ValidatorBuilder.php index fc3abd342355f..d82aca5612cdd 100644 --- a/src/Symfony/Component/Validator/ValidatorBuilder.php +++ b/src/Symfony/Component/Validator/ValidatorBuilder.php @@ -15,7 +15,6 @@ use Doctrine\Common\Annotations\CachedReader; use Doctrine\Common\Annotations\Reader; use Doctrine\Common\Cache\ArrayCache; -use Symfony\Component\PropertyAccess\PropertyAccessorInterface; use Symfony\Component\Translation\IdentityTranslator; use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Validator\Context\ExecutionContextFactory; @@ -89,11 +88,6 @@ class ValidatorBuilder implements ValidatorBuilderInterface */ private $translationDomain; - /** - * @var PropertyAccessorInterface|null - */ - private $propertyAccessor; - /** * {@inheritdoc} */ @@ -263,10 +257,6 @@ public function setMetadataCache(CacheInterface $cache) */ public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $validatorFactory) { - if (null !== $this->propertyAccessor) { - throw new ValidatorException('You cannot set a validator factory after setting a custom property accessor. Remove the call to setPropertyAccessor() if you want to call setConstraintValidatorFactory().'); - } - $this->validatorFactory = $validatorFactory; return $this; @@ -333,7 +323,7 @@ public function getValidator() $metadataFactory = new LazyLoadingMetadataFactory($loader, $this->metadataCache); } - $validatorFactory = $this->validatorFactory ?: new ConstraintValidatorFactory($this->propertyAccessor); + $validatorFactory = $this->validatorFactory ?: new ConstraintValidatorFactory(); $translator = $this->translator; if (null === $translator) { diff --git a/src/Symfony/Component/Validator/composer.json b/src/Symfony/Component/Validator/composer.json index 7365981fd6750..48d431cc79a54 100644 --- a/src/Symfony/Component/Validator/composer.json +++ b/src/Symfony/Component/Validator/composer.json @@ -24,7 +24,6 @@ "symfony/intl": "~2.8|~3.0", "symfony/yaml": "~2.8|~3.0", "symfony/config": "~2.8|~3.0", - "symfony/property-access": "~2.8|~3.0", "symfony/expression-language": "~2.8|~3.0", "doctrine/annotations": "~1.0", "doctrine/cache": "~1.0", 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 015/106] [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 016/106] 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 017/106] 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 018/106] [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 019/106] [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 020/106] 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 021/106] 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 022/106] 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 023/106] 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 024/106] 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 025/106] 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 026/106] [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 027/106] [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 028/106] [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 735f92e84e40f4b1ad3a65a342f96ddf5f8b1052 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Fri, 12 Feb 2016 22:47:32 +0100 Subject: [PATCH 029/106] [Form] remove deprecated empty_value_in_choices --- src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index dfe4ffb092d56..21011cb03333b 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -210,9 +210,6 @@ public function buildView(FormView $view, FormInterface $form, array $options) $view->vars['placeholder'] = $options['placeholder']; } - // BC - $view->vars['empty_value_in_choices'] = $view->vars['placeholder_in_choices']; - if ($options['multiple'] && !$options['expanded']) { // Add "[]" to the name in case a select tag with multiple options is // displayed. Otherwise only one of the selected options is sent in the From e9111e4ef1c09959fe266d6ea911d3a004dd6c73 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Sat, 13 Feb 2016 11:44:39 +0100 Subject: [PATCH 030/106] [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 031/106] [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 032/106] [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 033/106] [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 034/106] [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 035/106] [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 036/106] 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 037/106] [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 038/106] [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 039/106] 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 040/106] 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 041/106] [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 c0e41f9892f8e20fa615b210daa12b94a777cbde Mon Sep 17 00:00:00 2001 From: Calin Mihai Pristavu Date: Mon, 15 Feb 2016 18:23:19 +0200 Subject: [PATCH 042/106] [HttpFoundation] [Session] Removed unnecessary PHP version check as minimum requirement is now 5.5.9 --- .../Session/Storage/NativeSessionStorage.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index c58270a69a9ea..6d08fdfc68361 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -182,12 +182,7 @@ public function setName($name) public function regenerate($destroy = false, $lifetime = null) { // Cannot regenerate the session ID for non-active sessions. - if (PHP_VERSION_ID >= 50400 && \PHP_SESSION_ACTIVE !== session_status()) { - return false; - } - - // Check if session ID exists in PHP 5.3 - if (PHP_VERSION_ID < 50400 && '' === session_id()) { + if (\PHP_SESSION_ACTIVE !== session_status()) { return false; } From d9af4bc606a0d92c88c4e36d2bf337623b3283cd Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 15 Feb 2016 18:58:30 +0100 Subject: [PATCH 043/106] 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 044/106] [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 045/106] [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 046/106] 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 047/106] [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 048/106] 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 049/106] [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 050/106] [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 051/106] 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 052/106] [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 053/106] [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 054/106] [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 055/106] 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 056/106] 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 057/106] [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 058/106] 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 059/106] 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 060/106] 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 061/106] 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 062/106] 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 063/106] [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 064/106] 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 c18f781684814575986851dc94f7b26c70056c63 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 20 Feb 2016 17:27:18 +0100 Subject: [PATCH 065/106] disable the assets helper when assets are disabled --- .../DependencyInjection/FrameworkExtension.php | 6 +++++- .../Fixtures/php/templating_no_assets.php | 7 +++++++ .../php/templating_php_assets_disabled.php | 8 ++++++++ .../Fixtures/xml/templating_no_assets.xml | 14 ++++++++++++++ .../Fixtures/yml/templating_no_assets.yml | 3 +++ .../yml/templating_php_assets_disabled.yml | 4 ++++ .../DependencyInjection/FrameworkExtensionTest.php | 11 +++++++++-- .../XmlFrameworkExtensionTest.php | 5 +++++ 8 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_no_assets.php create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_assets_disabled.php create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_no_assets.xml create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_no_assets.yml create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_php_assets_disabled.yml diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 6909b15ae33d2..5f3173a0a469d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -547,7 +547,11 @@ private function registerTemplatingConfiguration(array $config, $ide, ContainerB 'Symfony\\Bundle\\FrameworkBundle\\Templating\\Loader\\FilesystemLoader', )); - $container->getDefinition('templating.helper.assets')->replaceArgument(0, new Reference('assets.packages')); + if ($container->has('assets.packages')) { + $container->getDefinition('templating.helper.assets')->replaceArgument(0, new Reference('assets.packages')); + } else { + $container->removeDefinition('templating.helper.assets'); + } } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_no_assets.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_no_assets.php new file mode 100644 index 0000000000000..bf12a8bc47e5f --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_no_assets.php @@ -0,0 +1,7 @@ +loadFromExtension('framework', array( + 'templating' => array( + 'engines' => array('php', 'twig'), + ), +)); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_assets_disabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_assets_disabled.php new file mode 100644 index 0000000000000..535a9a2e99c96 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_assets_disabled.php @@ -0,0 +1,8 @@ +loadFromExtension('framework', array( + 'assets' => false, + 'templating' => array( + 'engines' => array('php'), + ), +)); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_no_assets.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_no_assets.xml new file mode 100644 index 0000000000000..d579ed4c0a181 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_no_assets.xml @@ -0,0 +1,14 @@ + + + + + + php + twig + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_no_assets.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_no_assets.yml new file mode 100644 index 0000000000000..393477aeb49ac --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_no_assets.yml @@ -0,0 +1,3 @@ +framework: + templating: + engines: [php, twig] diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_php_assets_disabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_php_assets_disabled.yml new file mode 100644 index 0000000000000..7ef6b3e57c292 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_php_assets_disabled.yml @@ -0,0 +1,4 @@ +framework: + assets: false + templating: + engines: [php] diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index e655b52654d2c..a8aced55dd7fa 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -436,14 +436,21 @@ public function testAssetHelperWhenAssetsAreEnabled() $this->assertSame('assets.packages', (string) $packages); } - public function testAssetHelperWhenTemplatesAreEnabledAndAssetsAreDisabled() + public function testAssetHelperWhenTemplatesAreEnabledAndNoAssetsConfiguration() { - $container = $this->createContainerFromFile('full'); + $container = $this->createContainerFromFile('templating_no_assets'); $packages = $container->getDefinition('templating.helper.assets')->getArgument(0); $this->assertSame('assets.packages', (string) $packages); } + public function testAssetsHelperIsRemovedWhenPhpTemplatingEngineIsEnabledAndAssetsAreDisabled() + { + $container = $this->createContainerFromFile('templating_php_assets_disabled'); + + $this->assertTrue(!$container->has('templating.helper.assets'), 'The templating.helper.assets helper service is removed when assets are disabled.'); + } + public function testAssetHelperWhenAssetsAndTemplatesAreDisabled() { $container = $this->createContainerFromFile('default_config'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/XmlFrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/XmlFrameworkExtensionTest.php index 2c27eb0325112..03401e2482942 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/XmlFrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/XmlFrameworkExtensionTest.php @@ -22,4 +22,9 @@ protected function loadFromFile(ContainerBuilder $container, $file) $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/xml')); $loader->load($file.'.xml'); } + + public function testAssetsHelperIsRemovedWhenPhpTemplatingEngineIsEnabledAndAssetsAreDisabled() + { + $this->markTestSkipped('The assets key cannot be set to false using the XML configuration format.'); + } } From 56f87982d8503f59423839a5f5f4c96549371ffd Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 20 Feb 2016 20:14:11 +0100 Subject: [PATCH 066/106] 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 067/106] 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 068/106] 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 069/106] 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 070/106] [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 071/106] [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']) { //