From 0562463cb79db8bf484644fb59c3f097216dc1a0 Mon Sep 17 00:00:00 2001 From: Adrien BRAULT Date: Mon, 9 Jul 2012 01:05:31 +0200 Subject: [PATCH 0001/1305] [Security] Add an option to disable the hasPreviousSession() check in AbstractAuthenticationListener --- .../DependencyInjection/Security/Factory/AbstractFactory.php | 1 + .../Security/Http/Firewall/AbstractAuthenticationListener.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php index 611b0285c0638..288c5e3634125 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php @@ -36,6 +36,7 @@ abstract class AbstractFactory implements SecurityFactoryInterface 'use_referer' => false, 'failure_path' => null, 'failure_forward' => false, + 'require_previous_session' => true, ); public function create(ContainerBuilder $container, $id, $config, $userProviderId, $defaultEntryPointId) diff --git a/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php index 1caaf0af0ba66..a5924ffb0d3da 100644 --- a/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php @@ -98,6 +98,7 @@ public function __construct(SecurityContextInterface $securityContext, Authentic 'use_referer' => false, 'failure_path' => null, 'failure_forward' => false, + 'require_previous_session' => true, ), $options); $this->logger = $logger; $this->dispatcher = $dispatcher; @@ -132,7 +133,7 @@ public final function handle(GetResponseEvent $event) } try { - if (!$request->hasPreviousSession()) { + if ($this->options['require_previous_session'] && !$request->hasPreviousSession()) { throw new SessionUnavailableException('Your session has timed out, or you have disabled cookies.'); } From 92fbb0b6791792927b3712d63753e53393570cf3 Mon Sep 17 00:00:00 2001 From: Miha Vrhovnik Date: Thu, 19 Jul 2012 14:30:30 +0300 Subject: [PATCH 0002/1305] Classes should be removed only when adaptive is specified --- src/Symfony/Component/ClassLoader/ClassCollectionLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php index 7f5bdd1e47548..a3202a8dedcaa 100644 --- a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php +++ b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php @@ -95,7 +95,7 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive = $files = array(); $content = ''; foreach (self::getOrderedClasses($classes) as $class) { - if (in_array($class->getName(), $declared)) { + if ($adaptive && in_array($class->getName(), $declared)) { continue; } From e66bd14ca28cb7c80c6246286ddc142cd4232660 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Tue, 8 Jan 2013 18:27:02 +0100 Subject: [PATCH 0003/1305] [TwigBundle] Use display instead of visibility for exception page icons --- .../views/Exception/exception.html.twig | 18 +++++++++--------- .../Resources/views/Exception/trace.html.twig | 4 ++-- .../Resources/views/Exception/traces.html.twig | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.html.twig b/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.html.twig index 5b44b8121599b..a93d9c43255b2 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.html.twig +++ b/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception.html.twig @@ -47,8 +47,8 @@

Logs  - - - + + -

{% endspaceless %} @@ -74,8 +74,8 @@

Content of the Output  - - + + + +

{% endspaceless %} @@ -107,15 +107,15 @@ } function switchIcons(id1, id2) { - var icon1, icon2, visibility1, visibility2; + var icon1, icon2, display1, display2; icon1 = document.getElementById(id1); icon2 = document.getElementById(id2); - visibility1 = icon1.style.visibility; - visibility2 = icon2.style.visibility; + display1 = icon1.style.display; + display2 = icon2.style.display; - icon1.style.visibility = visibility2; - icon2.style.visibility = visibility1; + icon1.style.display = display2; + icon2.style.display = display1; } //]]> diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/trace.html.twig b/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/trace.html.twig index 37b2ecc2b4af2..d00a376a4589e 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/trace.html.twig +++ b/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/trace.html.twig @@ -12,8 +12,8 @@ in {{ trace.file|format_file(trace.line) }}  {% spaceless %} - - - + + - + + {% endspaceless %}
diff --git a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/traces.html.twig b/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/traces.html.twig index e9359959d21ea..cf49082cf4ecf 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/traces.html.twig +++ b/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/traces.html.twig @@ -5,8 +5,8 @@ {{ exception.class|abbr_class }}: {{ exception.message|nl2br|format_file_from_text }}  {% spaceless %} - - - + + - + + {% endspaceless %} From a557b89efc7cf5d8d9be838a170e044586d8f02c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haso=C5=88?= Date: Fri, 18 Jan 2013 13:53:35 +0100 Subject: [PATCH 0004/1305] [Process] Added ProcessUtils::escapeArgument() to fix the bug in escapeshellarg() function on Windows --- src/Symfony/Component/Process/CHANGELOG.md | 1 + .../Component/Process/ProcessBuilder.php | 2 +- .../Component/Process/ProcessUtils.php | 60 +++++++++++++++++++ .../Process/Tests/ProcessBuilderTest.php | 12 ++++ .../Process/Tests/ProcessUtilsTest.php | 42 +++++++++++++ 5 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Component/Process/ProcessUtils.php create mode 100644 src/Symfony/Component/Process/Tests/ProcessUtilsTest.php diff --git a/src/Symfony/Component/Process/CHANGELOG.md b/src/Symfony/Component/Process/CHANGELOG.md index 7fa5b72d50275..8a3f631a4e0a4 100644 --- a/src/Symfony/Component/Process/CHANGELOG.md +++ b/src/Symfony/Component/Process/CHANGELOG.md @@ -7,6 +7,7 @@ CHANGELOG * added ProcessBuilder::setArguments() to reset the arguments on a builder * added a way to retrieve the standard and error output incrementally * added Process:restart() + * added ProcessUtils::escapeArgument() to fix the bug in escapeshellarg() function on Windows 2.1.0 ----- diff --git a/src/Symfony/Component/Process/ProcessBuilder.php b/src/Symfony/Component/Process/ProcessBuilder.php index 1a95bd0df4926..45a5cd1d406c3 100644 --- a/src/Symfony/Component/Process/ProcessBuilder.php +++ b/src/Symfony/Component/Process/ProcessBuilder.php @@ -143,7 +143,7 @@ public function getProcess() $options = $this->options; - $script = implode(' ', array_map('escapeshellarg', $this->arguments)); + $script = implode(' ', array_map(array(__NAMESPACE__.'\\ProcessUtils', 'escapeArgument'), $this->arguments)); if ($this->inheritEnv) { $env = $this->env ? $this->env + $_ENV : null; diff --git a/src/Symfony/Component/Process/ProcessUtils.php b/src/Symfony/Component/Process/ProcessUtils.php new file mode 100644 index 0000000000000..73380be84d4ec --- /dev/null +++ b/src/Symfony/Component/Process/ProcessUtils.php @@ -0,0 +1,60 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Process; + +/** + * ProcessUtils is a bunch of utility methods. + * + * This class contains static methods only and is not meant to be instantiated. + * + * @author Martin Hasoň + */ +class ProcessUtils +{ + /** + * This class should not be instantiated + */ + private function __construct() + { + } + + /** + * Escapes a string to be used as a shell argument. + * + * @param string $argument The argument that will be escaped + * + * @return string The escaped argument + */ + public static function escapeArgument($argument) + { + //Fix for PHP bug #43784 escapeshellarg removes % from given string + //Fix for PHP bug #49446 escapeshellarg dosn`t work on windows + //@see https://bugs.php.net/bug.php?id=43784 + //@see https://bugs.php.net/bug.php?id=49446 + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $escapedArgument = ''; + foreach(preg_split('/([%"])/i', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) { + if ('"' == $part) { + $escapedArgument .= '\\"'; + } elseif ('%' == $part) { + $escapedArgument .= '^%'; + } else { + $escapedArgument .= escapeshellarg($part); + } + } + + return $escapedArgument; + } + + return escapeshellarg($argument); + } +} diff --git a/src/Symfony/Component/Process/Tests/ProcessBuilderTest.php b/src/Symfony/Component/Process/Tests/ProcessBuilderTest.php index 38e14910907e1..585aa9f137320 100644 --- a/src/Symfony/Component/Process/Tests/ProcessBuilderTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessBuilderTest.php @@ -115,4 +115,16 @@ public function testShouldSetArguments() $this->assertContains("second", $proc->getCommandLine()); } + + public function testShouldEscapeArguments() + { + $pb = new ProcessBuilder(array('%path%', 'foo " bar')); + $proc = $pb->getProcess(); + + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->assertSame('^%"path"^% "foo "\\"" bar"', $proc->getCommandLine()); + } else { + $this->assertSame("'%path%' 'foo \" bar'", $proc->getCommandLine()); + } + } } diff --git a/src/Symfony/Component/Process/Tests/ProcessUtilsTest.php b/src/Symfony/Component/Process/Tests/ProcessUtilsTest.php new file mode 100644 index 0000000000000..e51da5a5e22a8 --- /dev/null +++ b/src/Symfony/Component/Process/Tests/ProcessUtilsTest.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Process\Tests; + +use Symfony\Component\Process\ProcessUtils; + +class ProcessUtilsTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider dataArguments + */ + public function testEscapeArgument($result, $argument) + { + $this->assertSame($result, ProcessUtils::escapeArgument($argument)); + } + + public function dataArguments() + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + return array( + array('"foo bar"', 'foo bar'), + array('^%"path"^%', '%path%'), + array('"<|>"\\"" "\\""\'f"', '<|>" "\'f'), + ); + } + + return array( + array("'foo bar'", 'foo bar'), + array("'%path%'", '%path%'), + array("'<|>\" \"'\\''f'", '<|>" "\'f'), + ); + } +} From 3c3d34d03c48562eb9ccd664bfdc237b4ad50503 Mon Sep 17 00:00:00 2001 From: Benoit Garret Date: Fri, 25 Jan 2013 09:25:30 +0100 Subject: [PATCH 0005/1305] [FrameworkBundle] [Templating] added Stopwatch support to the PHP engine --- .../FrameworkExtension.php | 3 + .../Resources/config/templating_debug.xml | 8 +++ .../Templating/TimedPhpEngine.php | 59 +++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Templating/TimedPhpEngine.php diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 6423754059b24..e3d0418e72850 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -357,6 +357,9 @@ private function registerTemplatingConfiguration(array $config, $ide, ContainerB if ($container->getParameter('kernel.debug')) { $loader->load('templating_debug.xml'); + + $container->setDefinition('templating.engine.php', $container->findDefinition('debug.templating.engine.php')); + $container->setAlias('debug.templating.engine.php', 'templating.engine.php'); } // create package definitions and add them to the assets helper diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_debug.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_debug.xml index 0d3cebebea9a7..23da774223b45 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_debug.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_debug.xml @@ -6,6 +6,7 @@ Symfony\Bundle\FrameworkBundle\Templating\Debugger + Symfony\Bundle\FrameworkBundle\Templating\TimedPhpEngine @@ -13,5 +14,12 @@ + + + + + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/TimedPhpEngine.php b/src/Symfony/Bundle/FrameworkBundle/Templating/TimedPhpEngine.php new file mode 100644 index 0000000000000..56f529965df48 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/TimedPhpEngine.php @@ -0,0 +1,59 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Templating; + +use Symfony\Bundle\FrameworkBundle\Templating\PhpEngine; +use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables; +use Symfony\Component\Templating\TemplateNameParserInterface; +use Symfony\Component\HttpKernel\Debug\Stopwatch; +use Symfony\Component\Templating\Loader\LoaderInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; + +/** + * Times the time spent to render a template. + * + * @author Fabien Potencier + */ +class TimedPhpEngine extends PhpEngine +{ + protected $stopwatch; + + /** + * Constructor. + * + * @param TemplateNameParserInterface $parser A TemplateNameParserInterface instance + * @param ContainerInterface $container A ContainerInterface instance + * @param LoaderInterface $loader A LoaderInterface instance + * @param Stopwatch $stopwatch A Stopwatch instance + * @param GlobalVariables $globals A GlobalVariables instance + */ + public function __construct(TemplateNameParserInterface $parser, ContainerInterface $container, LoaderInterface $loader, Stopwatch $stopwatch, GlobalVariables $globals = null) + { + parent::__construct($parser, $container, $loader, $globals); + + $this->stopwatch = $stopwatch; + } + + /** + * {@inheritdoc} + */ + public function render($name, array $parameters = array()) + { + $e = $this->stopwatch->start(sprintf('template.php (%s)', $name), 'template'); + + $ret = parent::render($name, $parameters); + + $e->stop(); + + return $ret; + } +} From d0aaf625573254b5aff0a89cf12063d53067d81a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 31 Jan 2013 22:39:01 +0100 Subject: [PATCH 0006/1305] updated the branch alias in composer files --- composer.json | 2 +- src/Symfony/Bridge/Doctrine/composer.json | 2 +- src/Symfony/Bridge/Monolog/composer.json | 2 +- src/Symfony/Bridge/Propel1/composer.json | 2 +- src/Symfony/Bridge/Swiftmailer/composer.json | 2 +- src/Symfony/Bridge/Twig/composer.json | 2 +- src/Symfony/Bundle/FrameworkBundle/composer.json | 2 +- src/Symfony/Bundle/SecurityBundle/composer.json | 2 +- src/Symfony/Bundle/TwigBundle/composer.json | 2 +- src/Symfony/Bundle/WebProfilerBundle/composer.json | 2 +- src/Symfony/Component/BrowserKit/composer.json | 2 +- src/Symfony/Component/ClassLoader/composer.json | 2 +- src/Symfony/Component/Config/composer.json | 2 +- src/Symfony/Component/Console/composer.json | 2 +- src/Symfony/Component/CssSelector/composer.json | 2 +- src/Symfony/Component/DependencyInjection/composer.json | 2 +- src/Symfony/Component/DomCrawler/composer.json | 2 +- src/Symfony/Component/EventDispatcher/composer.json | 2 +- src/Symfony/Component/Filesystem/composer.json | 2 +- src/Symfony/Component/Finder/composer.json | 2 +- src/Symfony/Component/Form/composer.json | 2 +- src/Symfony/Component/HttpFoundation/composer.json | 2 +- src/Symfony/Component/HttpKernel/composer.json | 2 +- src/Symfony/Component/Locale/composer.json | 2 +- src/Symfony/Component/OptionsResolver/composer.json | 2 +- src/Symfony/Component/Process/composer.json | 2 +- src/Symfony/Component/PropertyAccess/composer.json | 2 +- src/Symfony/Component/Routing/composer.json | 2 +- src/Symfony/Component/Security/composer.json | 2 +- src/Symfony/Component/Serializer/composer.json | 2 +- src/Symfony/Component/Stopwatch/composer.json | 2 +- src/Symfony/Component/Templating/composer.json | 2 +- src/Symfony/Component/Translation/composer.json | 2 +- src/Symfony/Component/Validator/composer.json | 2 +- src/Symfony/Component/Yaml/composer.json | 2 +- 35 files changed, 35 insertions(+), 35 deletions(-) diff --git a/composer.json b/composer.json index 01aca2008abe5..d11e71b60ce14 100644 --- a/composer.json +++ b/composer.json @@ -74,7 +74,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json index 0ba9f1e93b608..ae790054cfbef 100644 --- a/src/Symfony/Bridge/Doctrine/composer.json +++ b/src/Symfony/Bridge/Doctrine/composer.json @@ -44,7 +44,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Bridge/Monolog/composer.json b/src/Symfony/Bridge/Monolog/composer.json index 0e89cf2346b0f..0ac1bb7ed024f 100644 --- a/src/Symfony/Bridge/Monolog/composer.json +++ b/src/Symfony/Bridge/Monolog/composer.json @@ -27,7 +27,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Bridge/Propel1/composer.json b/src/Symfony/Bridge/Propel1/composer.json index 3e9bdd329920e..2d56e57b890ae 100644 --- a/src/Symfony/Bridge/Propel1/composer.json +++ b/src/Symfony/Bridge/Propel1/composer.json @@ -32,7 +32,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Bridge/Swiftmailer/composer.json b/src/Symfony/Bridge/Swiftmailer/composer.json index 7d96c19300575..e2b76eb4d1e6a 100644 --- a/src/Symfony/Bridge/Swiftmailer/composer.json +++ b/src/Symfony/Bridge/Swiftmailer/composer.json @@ -29,7 +29,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index 885718c506353..e02681e0fbe0e 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -44,7 +44,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index 12bc33d882443..9c80b827adabf 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -45,7 +45,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json index f7be085bb7cc1..32e24fdccaa1c 100644 --- a/src/Symfony/Bundle/SecurityBundle/composer.json +++ b/src/Symfony/Bundle/SecurityBundle/composer.json @@ -26,7 +26,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Bundle/TwigBundle/composer.json b/src/Symfony/Bundle/TwigBundle/composer.json index b65b8923bd5f8..b505783577cdb 100644 --- a/src/Symfony/Bundle/TwigBundle/composer.json +++ b/src/Symfony/Bundle/TwigBundle/composer.json @@ -29,7 +29,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Bundle/WebProfilerBundle/composer.json b/src/Symfony/Bundle/WebProfilerBundle/composer.json index 338ad281d5ba6..8d5fba85dad53 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/composer.json +++ b/src/Symfony/Bundle/WebProfilerBundle/composer.json @@ -33,7 +33,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/BrowserKit/composer.json b/src/Symfony/Component/BrowserKit/composer.json index e1921435106fc..2c9e18ad2f312 100644 --- a/src/Symfony/Component/BrowserKit/composer.json +++ b/src/Symfony/Component/BrowserKit/composer.json @@ -33,7 +33,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/ClassLoader/composer.json b/src/Symfony/Component/ClassLoader/composer.json index cd56c8c2faa4f..ec594e5b7ad53 100644 --- a/src/Symfony/Component/ClassLoader/composer.json +++ b/src/Symfony/Component/ClassLoader/composer.json @@ -28,7 +28,7 @@ "target-dir": "Symfony/Component/ClassLoader", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Config/composer.json b/src/Symfony/Component/Config/composer.json index e148c27c09085..6a182492d1c22 100644 --- a/src/Symfony/Component/Config/composer.json +++ b/src/Symfony/Component/Config/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Console/composer.json b/src/Symfony/Component/Console/composer.json index 3369681580e30..a3c71521bb42b 100644 --- a/src/Symfony/Component/Console/composer.json +++ b/src/Symfony/Component/Console/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/CssSelector/composer.json b/src/Symfony/Component/CssSelector/composer.json index 54661fb87ba55..4a2f46192c2c0 100644 --- a/src/Symfony/Component/CssSelector/composer.json +++ b/src/Symfony/Component/CssSelector/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/DependencyInjection/composer.json b/src/Symfony/Component/DependencyInjection/composer.json index d951f3041d29d..87d49297b456a 100644 --- a/src/Symfony/Component/DependencyInjection/composer.json +++ b/src/Symfony/Component/DependencyInjection/composer.json @@ -33,7 +33,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/DomCrawler/composer.json b/src/Symfony/Component/DomCrawler/composer.json index 5696a86893435..492bb26edd8e2 100644 --- a/src/Symfony/Component/DomCrawler/composer.json +++ b/src/Symfony/Component/DomCrawler/composer.json @@ -31,7 +31,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/EventDispatcher/composer.json b/src/Symfony/Component/EventDispatcher/composer.json index 1a90992fd1867..c6eed3c37e789 100644 --- a/src/Symfony/Component/EventDispatcher/composer.json +++ b/src/Symfony/Component/EventDispatcher/composer.json @@ -32,7 +32,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Filesystem/composer.json b/src/Symfony/Component/Filesystem/composer.json index d1f97cf8d42d2..167dd506a9958 100644 --- a/src/Symfony/Component/Filesystem/composer.json +++ b/src/Symfony/Component/Filesystem/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Finder/composer.json b/src/Symfony/Component/Finder/composer.json index 2ad5b34ccb4a6..7480b3edb1ab1 100644 --- a/src/Symfony/Component/Finder/composer.json +++ b/src/Symfony/Component/Finder/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Form/composer.json b/src/Symfony/Component/Form/composer.json index 51afa67c3a15b..b5f5a89682aa1 100644 --- a/src/Symfony/Component/Form/composer.json +++ b/src/Symfony/Component/Form/composer.json @@ -37,7 +37,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/HttpFoundation/composer.json b/src/Symfony/Component/HttpFoundation/composer.json index 09b8725308d85..f77e08ebd6ace 100644 --- a/src/Symfony/Component/HttpFoundation/composer.json +++ b/src/Symfony/Component/HttpFoundation/composer.json @@ -26,7 +26,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/HttpKernel/composer.json b/src/Symfony/Component/HttpKernel/composer.json index 9680fadd2a760..01c6d83f251a2 100644 --- a/src/Symfony/Component/HttpKernel/composer.json +++ b/src/Symfony/Component/HttpKernel/composer.json @@ -47,7 +47,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Locale/composer.json b/src/Symfony/Component/Locale/composer.json index 1e977cb9e8bc4..f8267fd3c026c 100644 --- a/src/Symfony/Component/Locale/composer.json +++ b/src/Symfony/Component/Locale/composer.json @@ -29,7 +29,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/OptionsResolver/composer.json b/src/Symfony/Component/OptionsResolver/composer.json index 4812585a5277f..f13d246e95936 100644 --- a/src/Symfony/Component/OptionsResolver/composer.json +++ b/src/Symfony/Component/OptionsResolver/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Process/composer.json b/src/Symfony/Component/Process/composer.json index 1681ef6c1f97b..427e63b87fce4 100644 --- a/src/Symfony/Component/Process/composer.json +++ b/src/Symfony/Component/Process/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/PropertyAccess/composer.json b/src/Symfony/Component/PropertyAccess/composer.json index 3b85c0308edaa..318604274a3df 100644 --- a/src/Symfony/Component/PropertyAccess/composer.json +++ b/src/Symfony/Component/PropertyAccess/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Routing/composer.json b/src/Symfony/Component/Routing/composer.json index d29f645424d3e..341bfc98712c0 100644 --- a/src/Symfony/Component/Routing/composer.json +++ b/src/Symfony/Component/Routing/composer.json @@ -37,7 +37,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Security/composer.json b/src/Symfony/Component/Security/composer.json index 7192d5720293d..468b7203b69f5 100644 --- a/src/Symfony/Component/Security/composer.json +++ b/src/Symfony/Component/Security/composer.json @@ -44,7 +44,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Serializer/composer.json b/src/Symfony/Component/Serializer/composer.json index cff1e49cfa4fe..ab537b2955270 100644 --- a/src/Symfony/Component/Serializer/composer.json +++ b/src/Symfony/Component/Serializer/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Stopwatch/composer.json b/src/Symfony/Component/Stopwatch/composer.json index 30336fc65ceef..97e214fa2df2e 100644 --- a/src/Symfony/Component/Stopwatch/composer.json +++ b/src/Symfony/Component/Stopwatch/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Templating/composer.json b/src/Symfony/Component/Templating/composer.json index 234e28d63bdc7..b27f56c2f18bf 100644 --- a/src/Symfony/Component/Templating/composer.json +++ b/src/Symfony/Component/Templating/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Translation/composer.json b/src/Symfony/Component/Translation/composer.json index 52e4c43b403bf..c555b7698c736 100644 --- a/src/Symfony/Component/Translation/composer.json +++ b/src/Symfony/Component/Translation/composer.json @@ -33,7 +33,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Validator/composer.json b/src/Symfony/Component/Validator/composer.json index 9c65253c8e56d..55836561640ca 100644 --- a/src/Symfony/Component/Validator/composer.json +++ b/src/Symfony/Component/Validator/composer.json @@ -38,7 +38,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } diff --git a/src/Symfony/Component/Yaml/composer.json b/src/Symfony/Component/Yaml/composer.json index e04dabf3fc22c..1a009c16d6a27 100644 --- a/src/Symfony/Component/Yaml/composer.json +++ b/src/Symfony/Component/Yaml/composer.json @@ -25,7 +25,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } } } From bd0709c0b7217e773788eb1c2f66d587921f648f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Bj=C3=B8rnskov?= Date: Tue, 5 Feb 2013 09:33:19 +0100 Subject: [PATCH 0007/1305] Use REQUEST_TIME_FLOAT if available. This will give a more correct initialization time when using the DataCollectors without a KernelInterface implementation such as Silex. --- .../DataCollector/TimeDataCollector.php | 6 ++- .../DataCollector/TimeDataCollectorTest.php | 45 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php diff --git a/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php index 5fd237849903d..b01006064838a 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php @@ -35,8 +35,12 @@ public function __construct(KernelInterface $kernel = null) */ public function collect(Request $request, Response $response, \Exception $exception = null) { + if (null === $this->kernel) { + $requestTime = $request->server->get('REQUEST_TIME_FLOAT', $request->server->get('REQUEST_TIME')); + } + $this->data = array( - 'start_time' => (null !== $this->kernel ? $this->kernel->getStartTime() : $_SERVER['REQUEST_TIME']) * 1000, + 'start_time' => (isset($requestTime) ? $requestTime : $this->kernel->getStartTime()) * 1000, 'events' => array(), ); } diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php new file mode 100644 index 0000000000000..ef9886f022146 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\Tests\DataCollector; + +use Symfony\Component\HttpKernel\DataCollector\TimeDataCollector; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; + +class TimeDataCollectorTest extends \PHPUnit_Framework_TestCase +{ + protected function setUp() + { + if (!class_exists('Symfony\Component\HttpFoundation\Request')) { + $this->markTestSkipped('The "HttpFoundation" component is not available'); + } + } + + public function testCollectWithoutKernel() + { + $c = new TimeDataCollector; + + $request = new Request(); + $request->server->set('REQUEST_TIME', 1); + + $c->collect($request, new Response()); + + $this->assertEquals(1000, $c->getStartTime()); + + $request->server->set('REQUEST_TIME_FLOAT', 2); + + $c->collect($request, new Response()); + + $this->assertEquals(2000, $c->getStartTime()); + } + +} From fbffdf0b441407394f08e1432ea007fccd6702b9 Mon Sep 17 00:00:00 2001 From: marcosQuesada Date: Sat, 2 Feb 2013 17:53:42 +0100 Subject: [PATCH 0008/1305] Enabled camelCase format to be used on denormalize method, that way camel_case attribute can be used on object as getCamelCase() --- .../Normalizer/GetSetMethodNormalizer.php | 37 +++++++++++++- .../Normalizer/GetSetMethodNormalizerTest.php | 49 ++++++++++++++++++- 2 files changed, 82 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php index 63e7a1dea91ef..ae0805b1232d7 100644 --- a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php @@ -38,6 +38,7 @@ class GetSetMethodNormalizer extends SerializerAwareNormalizer implements Normal { protected $callbacks = array(); protected $ignoredAttributes = array(); + protected $camelizedAttributes = array(); /** * Set normalization callbacks @@ -66,6 +67,16 @@ public function setIgnoredAttributes(array $ignoredAttributes) $this->ignoredAttributes = $ignoredAttributes; } + /** + * Set attributes to be camelized on denormalize + * + * @param array $camelizedAttributes + */ + public function setCamelizedAttributes(array $camelizedAttributes) + { + $this->camelizedAttributes = $camelizedAttributes; + } + /** * {@inheritdoc} */ @@ -111,7 +122,7 @@ public function denormalize($data, $class, $format = null, array $context = arra $params = array(); foreach ($constructorParameters as $constructorParameter) { - $paramName = lcfirst($constructorParameter->name); + $paramName = lcfirst($this->formatAttribute($constructorParameter->name)); if (isset($data[$paramName])) { $params[] = $data[$paramName]; @@ -132,7 +143,8 @@ public function denormalize($data, $class, $format = null, array $context = arra } foreach ($data as $attribute => $value) { - $setter = 'set'.$attribute; + $setter = 'set'.$this->formatAttribute($attribute); + if (method_exists($object, $setter)) { $object->$setter($value); } @@ -141,6 +153,27 @@ public function denormalize($data, $class, $format = null, array $context = arra return $object; } + /** + * Format attribute name to access parameters or methods + * As option, if attribute name is found on camelizedAttributes array + * returns attribute name in camelcase format + * + * @param string $attribute + * @return string + */ + protected function formatAttribute($attributeName) + { + if (in_array($attributeName, $this->camelizedAttributes)) { + return preg_replace_callback( + '/(^|_|\.)+(.)/', function ($match) { + return ('.' === $match[1] ? '_' : '').strtoupper($match[2]); + }, $attributeName + ); + } + + return $attributeName; + } + /** * {@inheritDoc} */ diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php index 063753289401a..ea80f64eed8fb 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -26,8 +26,9 @@ public function testNormalize() $obj = new GetSetDummy; $obj->setFoo('foo'); $obj->setBar('bar'); + $obj->setCamelCase('camelcase'); $this->assertEquals( - array('foo' => 'foo', 'bar' => 'bar', 'fooBar' => 'foobar'), + array('foo' => 'foo', 'bar' => 'bar', 'fooBar' => 'foobar', 'camelCase' => 'camelcase'), $this->normalizer->normalize($obj, 'any') ); } @@ -43,6 +44,39 @@ public function testDenormalize() $this->assertEquals('bar', $obj->getBar()); } + public function testDenormalizeOnCamelCaseFormat() + { + $this->normalizer->setCamelizedAttributes(array('camel_case')); + $obj = $this->normalizer->denormalize( + array('camel_case' => 'camelCase'), + __NAMESPACE__.'\GetSetDummy' + ); + $this->assertEquals('camelCase', $obj->getCamelCase()); + } + + /** + * @dataProvider attributeProvider + */ + public function testFormatAttribute($attribute, $camelizedAttributes, $result) + { + $r = new \ReflectionObject($this->normalizer); + $m = $r->getMethod('formatAttribute'); + $m->setAccessible(true); + + $this->normalizer->setCamelizedAttributes($camelizedAttributes); + $this->assertEquals($m->invoke($this->normalizer, $attribute, $camelizedAttributes), $result); + } + + public function attributeProvider() + { + return array( + array('attribute_test', array('attribute_test'),'AttributeTest'), + array('attribute_test', array('any'),'attribute_test'), + array('attribute', array('attribute'),'Attribute'), + array('attribute', array(), 'attribute'), + ); + } + public function testConstructorDenormalize() { $obj = $this->normalizer->denormalize( @@ -82,7 +116,7 @@ public function testUncallableCallbacks() public function testIgnoredAttributes() { - $this->normalizer->setIgnoredAttributes(array('foo', 'bar')); + $this->normalizer->setIgnoredAttributes(array('foo', 'bar', 'camelCase')); $obj = new GetSetDummy; $obj->setFoo('foo'); @@ -160,6 +194,7 @@ class GetSetDummy { protected $foo; private $bar; + protected $camelCase; public function getFoo() { @@ -186,6 +221,16 @@ public function getFooBar() return $this->foo . $this->bar; } + public function getCamelCase() + { + return $this->camelCase; + } + + public function setCamelCase($camelCase) + { + $this->camelCase = $camelCase; + } + public function otherMethod() { throw new \RuntimeException("Dummy::otherMethod() should not be called"); From 5ca04b02fd858e4d275f3f07351c74442bca620a Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Tue, 5 Feb 2013 21:55:33 +0000 Subject: [PATCH 0009/1305] [Console] Cleaned up the unit tests. --- .../Console/Tests/ApplicationTest.php | 144 +++++---- .../Console/Tests/Command/CommandTest.php | 96 +++--- .../Console/Tests/Command/HelpCommandTest.php | 28 +- .../Console/Tests/Command/ListCommandTest.php | 18 +- .../Console/Tests/Input/ArgvInputTest.php | 303 ++++++++++-------- .../Console/Tests/Input/ArrayInputTest.php | 111 ++++--- .../Console/Tests/Input/InputArgumentTest.php | 71 ++-- .../Tests/Input/InputDefinitionTest.php | 183 +++++++---- .../Console/Tests/Input/InputOptionTest.php | 84 ++--- .../Console/Tests/Input/InputTest.php | 92 +++--- .../Console/Tests/Output/OutputTest.php | 54 +++- .../Console/Tests/Output/StreamOutputTest.php | 17 +- 12 files changed, 715 insertions(+), 486 deletions(-) diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index 23edd490b3658..2d2da94542212 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -129,14 +129,6 @@ public function testHasGet() $this->assertEquals($foo, $application->get('foo:bar'), '->get() returns a command by name'); $this->assertEquals($foo, $application->get('afoobar'), '->get() returns a command by alias'); - try { - $application->get('foofoo'); - $this->fail('->get() throws an \InvalidArgumentException if the command does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->get() throws an \InvalidArgumentException if the command does not exist'); - $this->assertEquals('The command "foofoo" does not exist.', $e->getMessage(), '->get() throws an \InvalidArgumentException if the command does not exist'); - } - $application = new Application(); $application->add($foo = new \FooCommand()); // simulate --help @@ -145,7 +137,17 @@ public function testHasGet() $p->setAccessible(true); $p->setValue($application, true); $command = $application->get('foo:bar'); - $this->assertEquals('Symfony\Component\Console\Command\HelpCommand', get_class($command), '->get() returns the help command if --help is provided as the input'); + $this->assertInstanceOf('Symfony\Component\Console\Command\HelpCommand', $command, '->get() returns the help command if --help is provided as the input'); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The command "foofoo" does not exist. + */ + public function testGetInvalidCommand() + { + $application = new Application(); + $application->get('foofoo'); } public function testGetNamespaces() @@ -164,84 +166,90 @@ public function testFindNamespace() $this->assertEquals('foo', $application->findNamespace('f'), '->findNamespace() finds a namespace given an abbreviation'); $application->add(new \Foo2Command()); $this->assertEquals('foo', $application->findNamespace('foo'), '->findNamespace() returns the given namespace if it exists'); - try { - $application->findNamespace('f'); - $this->fail('->findNamespace() throws an \InvalidArgumentException if the abbreviation is ambiguous'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->findNamespace() throws an \InvalidArgumentException if the abbreviation is ambiguous'); - $this->assertEquals('The namespace "f" is ambiguous (foo, foo1).', $e->getMessage(), '->findNamespace() throws an \InvalidArgumentException if the abbreviation is ambiguous'); - } + } - try { - $application->findNamespace('bar'); - $this->fail('->findNamespace() throws an \InvalidArgumentException if no command is in the given namespace'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->findNamespace() throws an \InvalidArgumentException if no command is in the given namespace'); - $this->assertEquals('There are no commands defined in the "bar" namespace.', $e->getMessage(), '->findNamespace() throws an \InvalidArgumentException if no command is in the given namespace'); - } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The namespace "f" is ambiguous (foo, foo1). + */ + public function testFindAmbiguousNamespace() + { + $application = new Application(); + $application->add(new \FooCommand()); + $application->add(new \Foo2Command()); + $application->findNamespace('f'); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage There are no commands defined in the "bar" namespace. + */ + public function testFindInvalidNamespace() + { + $application = new Application(); + $application->findNamespace('bar'); } public function testFind() { $application = new Application(); $application->add(new \FooCommand()); - $this->assertEquals('FooCommand', get_class($application->find('foo:bar')), '->find() returns a command if its name exists'); - $this->assertEquals('Symfony\Component\Console\Command\HelpCommand', get_class($application->find('h')), '->find() returns a command if its name exists'); - $this->assertEquals('FooCommand', get_class($application->find('f:bar')), '->find() returns a command if the abbreviation for the namespace exists'); - $this->assertEquals('FooCommand', get_class($application->find('f:b')), '->find() returns a command if the abbreviation for the namespace and the command name exist'); - $this->assertEquals('FooCommand', get_class($application->find('a')), '->find() returns a command if the abbreviation exists for an alias'); + $this->assertInstanceOf('FooCommand', $application->find('foo:bar'), '->find() returns a command if its name exists'); + $this->assertInstanceOf('Symfony\Component\Console\Command\HelpCommand', $application->find('h'), '->find() returns a command if its name exists'); + $this->assertInstanceOf('FooCommand', $application->find('f:bar'), '->find() returns a command if the abbreviation for the namespace exists'); + $this->assertInstanceOf('FooCommand', $application->find('f:b'), '->find() returns a command if the abbreviation for the namespace and the command name exist'); + $this->assertInstanceOf('FooCommand', $application->find('a'), '->find() returns a command if the abbreviation exists for an alias'); + } + + /** + * @dataProvider provideAmbiguousAbbreviations + */ + public function testFindWithAmbiguousAbbreviations($abbreviation, $expectedExceptionMessage) + { + $this->setExpectedException('InvalidArgumentException', $expectedExceptionMessage); + + $application = new Application(); + $application->add(new \FooCommand()); $application->add(new \Foo1Command()); $application->add(new \Foo2Command()); - try { - $application->find('f'); - $this->fail('->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for a namespace'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for a namespace'); - $this->assertRegExp('/Command "f" is not defined./', $e->getMessage(), '->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for a namespace'); - } - - try { - $application->find('a'); - $this->fail('->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for an alias'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for an alias'); - $this->assertEquals('Command "a" is ambiguous (afoobar, afoobar1 and 1 more).', $e->getMessage(), '->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for an alias'); - } + $application->find($abbreviation); + } - try { - $application->find('foo:b'); - $this->fail('->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for a command'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for a command'); - $this->assertEquals('Command "foo:b" is ambiguous (foo:bar, foo:bar1).', $e->getMessage(), '->find() throws an \InvalidArgumentException if the abbreviation is ambiguous for a command'); - } + public function provideAmbiguousAbbreviations() + { + return array( + array('f', 'Command "f" is not defined.'), + array('a', 'Command "a" is ambiguous (afoobar, afoobar1 and 1 more).'), + array('foo:b', 'Command "foo:b" is ambiguous (foo:bar, foo:bar1).') + ); } - public function testFindAlternativeExceptionMessage() + /** + * @dataProvider provideInvalidCommandNamesSingle + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Did you mean this + */ + public function testFindAlternativeExceptionMessageSingle($name) { $application = new Application(); $application->add(new \FooCommand()); + $application->find($name); + } - // Command + singular - try { - $application->find('foo:baR'); - $this->fail('->find() throws an \InvalidArgumentException if command does not exist, with one alternative'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->find() throws an \InvalidArgumentException if command does not exist, with one alternative'); - $this->assertRegExp('/Did you mean this/', $e->getMessage(), '->find() throws an \InvalidArgumentException if command does not exist, with one alternative'); - } - - // Namespace + singular - try { - $application->find('foO:bar'); - $this->fail('->find() throws an \InvalidArgumentException if command does not exist, with one alternative'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->find() throws an \InvalidArgumentException if command does not exist, with one alternative'); - $this->assertRegExp('/Did you mean this/', $e->getMessage(), '->find() throws an \InvalidArgumentException if command does not exist, with one alternative'); - } + public function provideInvalidCommandNamesSingle() + { + return array( + array('foo:baR'), + array('foO:bar') + ); + } + public function testFindAlternativeExceptionMessageMultiple() + { + $application = new Application(); + $application->add(new \FooCommand()); $application->add(new \Foo1Command()); $application->add(new \Foo2Command()); diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php index 166ce7879ea30..acbe2ea10ce38 100644 --- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php @@ -35,17 +35,19 @@ public static function setUpBeforeClass() public function testConstructor() { - try { - $command = new Command(); - $this->fail('__construct() throws a \LogicException if the name is null'); - } catch (\Exception $e) { - $this->assertInstanceOf('\LogicException', $e, '__construct() throws a \LogicException if the name is null'); - $this->assertEquals('The command name cannot be empty.', $e->getMessage(), '__construct() throws a \LogicException if the name is null'); - } $command = new Command('foo:bar'); $this->assertEquals('foo:bar', $command->getName(), '__construct() takes the command name as its first argument'); } + /** + * @expectedException \LogicException + * @expectedExceptionMessage The command name cannot be empty. + */ + public function testCommandNameCannotBeEmpty() + { + new Command(); + } + public function testSetApplication() { $application = new Application(); @@ -92,22 +94,25 @@ public function testGetNamespaceGetNameSetName() $ret = $command->setName('foobar:bar'); $this->assertEquals($command, $ret, '->setName() implements a fluent interface'); $this->assertEquals('foobar:bar', $command->getName(), '->setName() sets the command name'); + } + + /** + * @dataProvider provideInvalidCommandNames + */ + public function testInvalidCommandNames($name) + { + $this->setExpectedException('InvalidArgumentException', sprintf('Command name "%s" is invalid.', $name)); + + $command = new \TestCommand(); + $command->setName($name); + } - try { - $command->setName(''); - $this->fail('->setName() throws an \InvalidArgumentException if the name is empty'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->setName() throws an \InvalidArgumentException if the name is empty'); - $this->assertEquals('Command name "" is invalid.', $e->getMessage(), '->setName() throws an \InvalidArgumentException if the name is empty'); - } - - try { - $command->setName('foo:'); - $this->fail('->setName() throws an \InvalidArgumentException if the name is empty'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->setName() throws an \InvalidArgumentException if the name is empty'); - $this->assertEquals('Command name "foo:" is invalid.', $e->getMessage(), '->setName() throws an \InvalidArgumentException if the name is empty'); - } + public function provideInvalidCommandNames() + { + return array( + array(''), + array('foo:') + ); } public function testGetSetDescription() @@ -193,32 +198,43 @@ public function testMergeApplicationDefinition() $this->assertEquals(3, $command->getDefinition()->getArgumentCount(), '->mergeApplicationDefinition() does not try to merge twice the application arguments and options'); } - public function testRun() + public function testRunInteractive() { - $command = new \TestCommand(); - $tester = new CommandTester($command); - try { - $tester->execute(array('--bar' => true)); - $this->fail('->run() throws a \InvalidArgumentException when the input does not validate the current InputDefinition'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->run() throws a \InvalidArgumentException when the input does not validate the current InputDefinition'); - $this->assertEquals('The "--bar" option does not exist.', $e->getMessage(), '->run() throws a \InvalidArgumentException when the input does not validate the current InputDefinition'); - } + $tester = new CommandTester(new \TestCommand()); $tester->execute(array(), array('interactive' => true)); + $this->assertEquals('interact called'.PHP_EOL.'execute called'.PHP_EOL, $tester->getDisplay(), '->run() calls the interact() method if the input is interactive'); + } + + public function testRunNonInteractive() + { + $tester = new CommandTester(new \TestCommand()); $tester->execute(array(), array('interactive' => false)); + $this->assertEquals('execute called'.PHP_EOL, $tester->getDisplay(), '->run() does not call the interact() method if the input is not interactive'); + } + /** + * @expectedException \LogicException + * @expectedExceptionMessage You must override the execute() method in the concrete command class. + */ + public function testExecuteMethodNeedsToBeOverriden() + { $command = new Command('foo'); - try { - $command->run(new StringInput(''), new NullOutput()); - $this->fail('->run() throws a \LogicException if the execute() method has not been overridden and no code has been provided'); - } catch (\Exception $e) { - $this->assertInstanceOf('\LogicException', $e, '->run() throws a \LogicException if the execute() method has not been overridden and no code has been provided'); - $this->assertEquals('You must override the execute() method in the concrete command class.', $e->getMessage(), '->run() throws a \LogicException if the execute() method has not been overridden and no code has been provided'); - } + $command->run(new StringInput(''), new NullOutput()); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "--bar" option does not exist. + */ + public function testRunWithInvalidOption() + { + $command = new \TestCommand(); + $tester = new CommandTester($command); + $tester->execute(array('--bar' => true)); } public function testRunReturnsAlwaysInteger() @@ -251,7 +267,7 @@ public function testSetCodeWithNonClosureCallable() } /** - * @expectedException InvalidArgumentException + * @expectedException \InvalidArgumentException * @expectedExceptionMessage Invalid callable provided to Command::setCode. */ public function testSetCodeWithNonCallable() diff --git a/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php b/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php index b62973d9d637e..f9b72e6ae385e 100644 --- a/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/HelpCommandTest.php @@ -18,33 +18,51 @@ class HelpCommandTest extends \PHPUnit_Framework_TestCase { - public function testExecute() + public function testExecuteForCommandAlias() { $command = new HelpCommand(); - - $application = new Application(); - $command->setApplication($application); + $command->setApplication(new Application()); $commandTester = new CommandTester($command); $commandTester->execute(array('command_name' => 'li')); + $this->assertRegExp('/list \[--xml\] \[--raw\] \[namespace\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias'); + } + public function testExecuteForCommand() + { $command = new HelpCommand(); - $commandTester = new CommandTester($command); $command->setCommand(new ListCommand()); $commandTester->execute(array()); + $this->assertRegExp('/list \[--xml\] \[--raw\] \[namespace\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); + } + public function testExecuteForCommandWithXmlOption() + { + $command = new HelpCommand(); + $commandTester = new CommandTester($command); $command->setCommand(new ListCommand()); $commandTester->execute(array('--xml' => true)); + $this->assertRegExp('/getDisplay(), '->execute() returns an XML help text if --xml is passed'); + } + public function testExecuteForApplicationCommand() + { $application = new Application(); $commandTester = new CommandTester($application->get('help')); $commandTester->execute(array('command_name' => 'list')); + $this->assertRegExp('/list \[--xml\] \[--raw\] \[namespace\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); + } + public function testExecuteForApplicationCommandWithXmlOption() + { + $application = new Application(); + $commandTester = new CommandTester($application->get('help')); $commandTester->execute(array('command_name' => 'list', '--xml' => true)); + $this->assertRegExp('/getDisplay(), '->execute() returns an XML help text if --xml is passed'); } } diff --git a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php index fb0eaccb0c65d..cad313652c0aa 100644 --- a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php @@ -16,23 +16,35 @@ class ListCommandTest extends \PHPUnit_Framework_TestCase { - public function testExecute() + public function testExecuteListsCommands() { $application = new Application(); - $commandTester = new CommandTester($command = $application->get('list')); $commandTester->execute(array('command' => $command->getName()), array('decorated' => false)); + $this->assertRegExp('/help Displays help for a command/', $commandTester->getDisplay(), '->execute() returns a list of available commands'); + } + public function testExecuteListsCommandsWithXmlOption() + { + $application = new Application(); + $commandTester = new CommandTester($command = $application->get('list')); $commandTester->execute(array('command' => $command->getName(), '--xml' => true)); + $this->assertRegExp('//', $commandTester->getDisplay(), '->execute() returns a list of available commands in XML if --xml is passed'); + } + public function testExecuteListsCommandsWithRawOption() + { + $application = new Application(); + $commandTester = new CommandTester($command = $application->get('list')); $commandTester->execute(array('command' => $command->getName(), '--raw' => true)); $output = <<assertEquals(str_replace("\n", PHP_EOL, $output), $commandTester->getDisplay(), 'boo'); + + $this->assertEquals(str_replace("\n", PHP_EOL, $output), $commandTester->getDisplay()); } } diff --git a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php index fc7ab21834da2..38cc038ea70a3 100644 --- a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php @@ -29,7 +29,7 @@ public function testConstructor() $this->assertEquals(array('foo'), $p->getValue($input), '__construct() automatically get its input from the argv server variable'); } - public function testParser() + public function testParseArguments() { $input = new ArgvInput(array('cli.php', 'foo')); $input->bind(new InputDefinition(array(new InputArgument('name')))); @@ -37,142 +37,185 @@ public function testParser() $input->bind(new InputDefinition(array(new InputArgument('name')))); $this->assertEquals(array('name' => 'foo'), $input->getArguments(), '->parse() is stateless'); + } - $input = new ArgvInput(array('cli.php', '--foo')); - $input->bind(new InputDefinition(array(new InputOption('foo')))); - $this->assertEquals(array('foo' => true), $input->getOptions(), '->parse() parses long options without a value'); - - $input = new ArgvInput(array('cli.php', '--foo=bar')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)))); - $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses long options with a required value (with a = separator)'); - - $input = new ArgvInput(array('cli.php', '--foo', 'bar')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)))); - $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses long options with a required value (with a space separator)'); - - try { - $input = new ArgvInput(array('cli.php', '--foo')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)))); - $this->fail('->parse() throws a \RuntimeException if no value is passed to an option when it is required'); - } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->parse() throws a \RuntimeException if no value is passed to an option when it is required'); - $this->assertEquals('The "--foo" option requires a value.', $e->getMessage(), '->parse() throws a \RuntimeException if no value is passed to an option when it is required'); - } - - $input = new ArgvInput(array('cli.php', '-f')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f')))); - $this->assertEquals(array('foo' => true), $input->getOptions(), '->parse() parses short options without a value'); - - $input = new ArgvInput(array('cli.php', '-fbar')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)))); - $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses short options with a required value (with no separator)'); - - $input = new ArgvInput(array('cli.php', '-f', 'bar')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)))); - $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses short options with a required value (with a space separator)'); - - $input = new ArgvInput(array('cli.php', '-f', '')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)))); - $this->assertEquals(array('foo' => ''), $input->getOptions(), '->parse() parses short options with an optional empty value'); - - $input = new ArgvInput(array('cli.php', '-f', '', 'foo')); - $input->bind(new InputDefinition(array(new InputArgument('name'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)))); - $this->assertEquals(array('foo' => ''), $input->getOptions(), '->parse() parses short options with an optional empty value followed by an argument'); - - $input = new ArgvInput(array('cli.php', '-f', '', '-b')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b')))); - $this->assertEquals(array('foo' => '', 'bar' => true), $input->getOptions(), '->parse() parses short options with an optional empty value followed by an option'); - - $input = new ArgvInput(array('cli.php', '-f', '-b', 'foo')); - $input->bind(new InputDefinition(array(new InputArgument('name'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b')))); - $this->assertEquals(array('foo' => null, 'bar' => true), $input->getOptions(), '->parse() parses short options with an optional value which is not present'); - - try { - $input = new ArgvInput(array('cli.php', '-f')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)))); - $this->fail('->parse() throws a \RuntimeException if no value is passed to an option when it is required'); - } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->parse() throws a \RuntimeException if no value is passed to an option when it is required'); - $this->assertEquals('The "--foo" option requires a value.', $e->getMessage(), '->parse() throws a \RuntimeException if no value is passed to an option when it is required'); - } - - try { - $input = new ArgvInput(array('cli.php', '-ffoo')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_NONE)))); - $this->fail('->parse() throws a \RuntimeException if a value is passed to an option which does not take one'); - } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->parse() throws a \RuntimeException if a value is passed to an option which does not take one'); - $this->assertEquals('The "-o" option does not exist.', $e->getMessage(), '->parse() throws a \RuntimeException if a value is passed to an option which does not take one'); - } - - try { - $input = new ArgvInput(array('cli.php', 'foo', 'bar')); - $input->bind(new InputDefinition()); - $this->fail('->parse() throws a \RuntimeException if too many arguments are passed'); - } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->parse() throws a \RuntimeException if too many arguments are passed'); - $this->assertEquals('Too many arguments.', $e->getMessage(), '->parse() throws a \RuntimeException if too many arguments are passed'); - } - - try { - $input = new ArgvInput(array('cli.php', '--foo')); - $input->bind(new InputDefinition()); - $this->fail('->parse() throws a \RuntimeException if an unknown long option is passed'); - } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->parse() throws a \RuntimeException if an unknown long option is passed'); - $this->assertEquals('The "--foo" option does not exist.', $e->getMessage(), '->parse() throws a \RuntimeException if an unknown long option is passed'); - } - - try { - $input = new ArgvInput(array('cli.php', '-f')); - $input->bind(new InputDefinition()); - $this->fail('->parse() throws a \RuntimeException if an unknown short option is passed'); - } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->parse() throws a \RuntimeException if an unknown short option is passed'); - $this->assertEquals('The "-f" option does not exist.', $e->getMessage(), '->parse() throws a \RuntimeException if an unknown short option is passed'); - } - - $input = new ArgvInput(array('cli.php', '-fb')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f'), new InputOption('bar', 'b')))); - $this->assertEquals(array('foo' => true, 'bar' => true), $input->getOptions(), '->parse() parses short options when they are aggregated as a single one'); - - $input = new ArgvInput(array('cli.php', '-fb', 'bar')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::VALUE_REQUIRED)))); - $this->assertEquals(array('foo' => true, 'bar' => 'bar'), $input->getOptions(), '->parse() parses short options when they are aggregated as a single one and the last one has a required value'); - - $input = new ArgvInput(array('cli.php', '-fb', 'bar')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL)))); - $this->assertEquals(array('foo' => true, 'bar' => 'bar'), $input->getOptions(), '->parse() parses short options when they are aggregated as a single one and the last one has an optional value'); + /** + * @dataProvider provideOptions + */ + public function testParseOptions($input, $options, $expectedOptions, $message) + { + $input = new ArgvInput($input); + $input->bind(new InputDefinition($options)); - $input = new ArgvInput(array('cli.php', '-fbbar')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL)))); - $this->assertEquals(array('foo' => true, 'bar' => 'bar'), $input->getOptions(), '->parse() parses short options when they are aggregated as a single one and the last one has an optional value with no separator'); + $this->assertEquals($expectedOptions, $input->getOptions(), $message); + } - $input = new ArgvInput(array('cli.php', '-fbbar')); - $input->bind(new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL)))); - $this->assertEquals(array('foo' => 'bbar', 'bar' => null), $input->getOptions(), '->parse() parses short options when they are aggregated as a single one and one of them takes a value'); + public function provideOptions() + { + return array( + array( + array('cli.php', '--foo'), + array(new InputOption('foo')), + array('foo' => true), + '->parse() parses long options without a value' + ), + array( + array('cli.php', '--foo=bar'), + array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)), + array('foo' => 'bar'), + '->parse() parses long options with a required value (with a = separator)' + ), + array( + array('cli.php', '--foo', 'bar'), + array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)), + array('foo' => 'bar'), + '->parse() parses long options with a required value (with a space separator)' + ), + array( + array('cli.php', '-f'), + array(new InputOption('foo', 'f')), + array('foo' => true), + '->parse() parses short options without a value' + ), + array( + array('cli.php', '-fbar'), + array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)), + array('foo' => 'bar'), + '->parse() parses short options with a required value (with no separator)' + ), + array( + array('cli.php', '-f', 'bar'), + array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)), + array('foo' => 'bar'), + '->parse() parses short options with a required value (with a space separator)' + ), + array( + array('cli.php', '-f', ''), + array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)), + array('foo' => ''), + '->parse() parses short options with an optional empty value' + ), + array( + array('cli.php', '-f', '', 'foo'), + array(new InputArgument('name'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)), + array('foo' => ''), + '->parse() parses short options with an optional empty value followed by an argument' + ), + array( + array('cli.php', '-f', '', '-b'), + array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b')), + array('foo' => '', 'bar' => true), + '->parse() parses short options with an optional empty value followed by an option' + ), + array( + array('cli.php', '-f', '-b', 'foo'), + array(new InputArgument('name'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b')), + array('foo' => null, 'bar' => true), + '->parse() parses short options with an optional value which is not present' + ), + array( + array('cli.php', '-fb'), + array(new InputOption('foo', 'f'), new InputOption('bar', 'b')), + array('foo' => true, 'bar' => true), + '->parse() parses short options when they are aggregated as a single one' + ), + array( + array('cli.php', '-fb', 'bar'), + array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::VALUE_REQUIRED)), + array('foo' => true, 'bar' => 'bar'), + '->parse() parses short options when they are aggregated as a single one and the last one has a required value' + ), + array( + array('cli.php', '-fb', 'bar'), + array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL)), + array('foo' => true, 'bar' => 'bar'), + '->parse() parses short options when they are aggregated as a single one and the last one has an optional value' + ), + array( + array('cli.php', '-fbbar'), + array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL)), + array('foo' => true, 'bar' => 'bar'), + '->parse() parses short options when they are aggregated as a single one and the last one has an optional value with no separator' + ), + array( + array('cli.php', '-fbbar'), + array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL)), + array('foo' => 'bbar', 'bar' => null), + '->parse() parses short options when they are aggregated as a single one and one of them takes a value' + ) + ); + } + + /** + * @dataProvider provideInvalidInput + */ + public function testInvalidInput($argv, $definition, $expectedExceptionMessage) + { + $this->setExpectedException('RuntimeException', $expectedExceptionMessage); + + $input = new ArgvInput($argv); + $input->bind($definition); + } - try { - $input = new ArgvInput(array('cli.php', 'foo', 'bar', 'baz', 'bat')); - $input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::IS_ARRAY)))); - $this->assertEquals(array('name' => array('foo', 'bar', 'baz', 'bat')), $input->getArguments(), '->parse() parses array arguments'); - } catch (\RuntimeException $e) { - $this->assertNotEquals('Too many arguments.', $e->getMessage(), '->parse() parses array arguments'); - } + public function provideInvalidInput() + { + return array( + array( + array('cli.php', '--foo'), + new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED))), + 'The "--foo" option requires a value.' + ), + array( + array('cli.php', '-f'), + new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED))), + 'The "--foo" option requires a value.' + ), + array( + array('cli.php', '-ffoo'), + new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_NONE))), + 'The "-o" option does not exist.' + ), + array( + array('cli.php', 'foo', 'bar'), + new InputDefinition(), + 'Too many arguments.' + ), + array( + array('cli.php', '--foo'), + new InputDefinition(), + 'The "--foo" option does not exist.' + ), + array( + array('cli.php', '-f'), + new InputDefinition(), + 'The "-f" option does not exist.' + ), + array( + array('cli.php', '-1'), + new InputDefinition(array(new InputArgument('number'))), + 'The "-1" option does not exist.' + ) + ); + } + + public function testParseArrayArgument() + { + $input = new ArgvInput(array('cli.php', 'foo', 'bar', 'baz', 'bat')); + $input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::IS_ARRAY)))); + + $this->assertEquals(array('name' => array('foo', 'bar', 'baz', 'bat')), $input->getArguments(), '->parse() parses array arguments'); + } + public function testParseArrayOption() + { $input = new ArgvInput(array('cli.php', '--name=foo', '--name=bar', '--name=baz')); $input->bind(new InputDefinition(array(new InputOption('name', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY)))); - $this->assertEquals(array('name' => array('foo', 'bar', 'baz')), $input->getOptions()); - try { - $input = new ArgvInput(array('cli.php', '-1')); - $input->bind(new InputDefinition(array(new InputArgument('number')))); - $this->fail('->parse() throws a \RuntimeException if an unknown option is passed'); - } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->parse() parses arguments with leading dashes as options without having encountered a double-dash sequence'); - $this->assertEquals('The "-1" option does not exist.', $e->getMessage(), '->parse() parses arguments with leading dashes as options without having encountered a double-dash sequence'); - } + $this->assertEquals(array('name' => array('foo', 'bar', 'baz')), $input->getOptions()); + } + public function testParseNegativeNumberAfterDoubleDash() + { $input = new ArgvInput(array('cli.php', '--', '-1')); $input->bind(new InputDefinition(array(new InputArgument('number')))); $this->assertEquals(array('number' => '-1'), $input->getArguments(), '->parse() parses arguments with leading dashes as arguments after having encountered a double-dash sequence'); @@ -181,9 +224,13 @@ public function testParser() $input->bind(new InputDefinition(array(new InputArgument('number'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)))); $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses arguments with leading dashes as options before having encountered a double-dash sequence'); $this->assertEquals(array('number' => '-1'), $input->getArguments(), '->parse() parses arguments with leading dashes as arguments after having encountered a double-dash sequence'); + } + public function testParseEmptyStringArgument() + { $input = new ArgvInput(array('cli.php', '-f', 'bar', '')); $input->bind(new InputDefinition(array(new InputArgument('empty'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)))); + $this->assertEquals(array('empty' => ''), $input->getArguments(), '->parse() parses empty string arguments'); } diff --git a/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php b/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php index 82f477ef8e31e..e1838a721e926 100644 --- a/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php @@ -38,53 +38,86 @@ public function testHasParameterOption() $this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if an option is present in the passed parameters'); } - public function testParse() + public function testParseArguments() { $input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name')))); - $this->assertEquals(array('name' => 'foo'), $input->getArguments(), '->parse() parses required arguments'); - - try { - $input = new ArrayInput(array('foo' => 'foo'), new InputDefinition(array(new InputArgument('name')))); - $this->fail('->parse() throws an \InvalidArgumentException exception if an invalid argument is passed'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException exception if an invalid argument is passed'); - $this->assertEquals('The "foo" argument does not exist.', $e->getMessage(), '->parse() throws an \InvalidArgumentException exception if an invalid argument is passed'); - } - $input = new ArrayInput(array('--foo' => 'bar'), new InputDefinition(array(new InputOption('foo')))); - $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses long options'); + $this->assertEquals(array('name' => 'foo'), $input->getArguments(), '->parse() parses required arguments'); + } - $input = new ArrayInput(array('--foo' => 'bar'), new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')))); - $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses long options with a default value'); + /** + * @dataProvider provideOptions + */ + public function testParseOptions($input, $options, $expectedOptions, $message) + { + $input = new ArrayInput($input, new InputDefinition($options)); - $input = new ArrayInput(array('--foo' => null), new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')))); - $this->assertEquals(array('foo' => 'default'), $input->getOptions(), '->parse() parses long options with a default value'); + $this->assertEquals($expectedOptions, $input->getOptions(), $message); + } - try { - $input = new ArrayInput(array('--foo' => null), new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)))); - $this->fail('->parse() throws an \InvalidArgumentException exception if a required option is passed without a value'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException exception if a required option is passed without a value'); - $this->assertEquals('The "--foo" option requires a value.', $e->getMessage(), '->parse() throws an \InvalidArgumentException exception if a required option is passed without a value'); - } + public function provideOptions() + { + return array( + array( + array('--foo' => 'bar'), + array(new InputOption('foo')), + array('foo' => 'bar'), + '->parse() parses long options' + ), + array( + array('--foo' => 'bar'), + array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')), + array('foo' => 'bar'), + '->parse() parses long options with a default value' + ), + array( + array('--foo' => null), + array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')), + array('foo' => 'default'), + '->parse() parses long options with a default value' + ), + array( + array('-f' => 'bar'), + array(new InputOption('foo', 'f')), + array('foo' => 'bar'), + '->parse() parses short options' + ) + ); + } - try { - $input = new ArrayInput(array('--foo' => 'foo'), new InputDefinition()); - $this->fail('->parse() throws an \InvalidArgumentException exception if an invalid option is passed'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException exception if an invalid option is passed'); - $this->assertEquals('The "--foo" option does not exist.', $e->getMessage(), '->parse() throws an \InvalidArgumentException exception if an invalid option is passed'); - } + /** + * @dataProvider provideInvalidInput + */ + public function testParseInvalidInput($parameters, $definition, $expectedExceptionMessage) + { + $this->setExpectedException('InvalidArgumentException', $expectedExceptionMessage); - $input = new ArrayInput(array('-f' => 'bar'), new InputDefinition(array(new InputOption('foo', 'f')))); - $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses short options'); + new ArrayInput($parameters, $definition); + } - try { - $input = new ArrayInput(array('-o' => 'foo'), new InputDefinition()); - $this->fail('->parse() throws an \InvalidArgumentException exception if an invalid option is passed'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException exception if an invalid option is passed'); - $this->assertEquals('The "-o" option does not exist.', $e->getMessage(), '->parse() throws an \InvalidArgumentException exception if an invalid option is passed'); - } + public function provideInvalidInput() + { + return array( + array( + array('foo' => 'foo'), + new InputDefinition(array(new InputArgument('name'))), + 'The "foo" argument does not exist.' + ), + array( + array('--foo' => null), + new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED))), + 'The "--foo" option requires a value.' + ), + array( + array('--foo' => 'foo'), + new InputDefinition(), + 'The "--foo" option does not exist.' + ), + array( + array('-o' => 'foo'), + new InputDefinition(), + 'The "-o" option does not exist.' + ) + ); } } diff --git a/src/Symfony/Component/Console/Tests/Input/InputArgumentTest.php b/src/Symfony/Component/Console/Tests/Input/InputArgumentTest.php index 1d3144f6288ef..3bfc796696a9a 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputArgumentTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputArgumentTest.php @@ -19,8 +19,10 @@ public function testConstructor() { $argument = new InputArgument('foo'); $this->assertEquals('foo', $argument->getName(), '__construct() takes a name as its first argument'); + } - // mode argument + public function testModes() + { $argument = new InputArgument('foo'); $this->assertFalse($argument->isRequired(), '__construct() gives a "InputArgument::OPTIONAL" mode by default'); @@ -32,21 +34,24 @@ public function testConstructor() $argument = new InputArgument('foo', InputArgument::REQUIRED); $this->assertTrue($argument->isRequired(), '__construct() can take "InputArgument::REQUIRED" as its mode'); + } + + /** + * @dataProvider provideInvalidModes + */ + public function testInvalidModes($mode) + { + $this->setExpectedException('InvalidArgumentException', sprintf('Argument mode "%s" is not valid.', $mode)); + + new InputArgument('foo', $mode); + } - try { - $argument = new InputArgument('foo', 'ANOTHER_ONE'); - $this->fail('__construct() throws an \InvalidArgumentException if the mode is not valid'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the mode is not valid'); - $this->assertEquals('Argument mode "ANOTHER_ONE" is not valid.', $e->getMessage()); - } - try { - $argument = new InputArgument('foo', -1); - $this->fail('__construct() throws an \InvalidArgumentException if the mode is not valid'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the mode is not valid'); - $this->assertEquals('Argument mode "-1" is not valid.', $e->getMessage()); - } + public function provideInvalidModes() + { + return array( + array('ANOTHER_ONE'), + array(-1) + ); } public function testIsArray() @@ -82,23 +87,25 @@ public function testSetDefault() $argument = new InputArgument('foo', InputArgument::OPTIONAL | InputArgument::IS_ARRAY); $argument->setDefault(array(1, 2)); $this->assertEquals(array(1, 2), $argument->getDefault(), '->setDefault() changes the default value'); + } - try { - $argument = new InputArgument('foo', InputArgument::REQUIRED); - $argument->setDefault('default'); - $this->fail('->setDefault() throws a \LogicException if you give a default value for a required argument'); - } catch (\Exception $e) { - $this->assertInstanceOf('\LogicException', $e, '->setDefault() throws a \LogicException exception if an invalid option is passed'); - $this->assertEquals('Cannot set a default value except for InputArgument::OPTIONAL mode.', $e->getMessage()); - } - - try { - $argument = new InputArgument('foo', InputArgument::IS_ARRAY); - $argument->setDefault('default'); - $this->fail('->setDefault() throws a \LogicException if you give a default value which is not an array for a IS_ARRAY option'); - } catch (\Exception $e) { - $this->assertInstanceOf('\LogicException', $e, '->setDefault() throws a \LogicException if you give a default value which is not an array for a IS_ARRAY option'); - $this->assertEquals('A default value for an array argument must be an array.', $e->getMessage()); - } + /** + * @expectedException \LogicException + * @expectedExceptionMessage Cannot set a default value except for InputArgument::OPTIONAL mode. + */ + public function testSetDefaultWithRequiredArgument() + { + $argument = new InputArgument('foo', InputArgument::REQUIRED); + $argument->setDefault('default'); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage A default value for an array argument must be an array. + */ + public function testSetDefaultWithArrayArgument() + { + $argument = new InputArgument('foo', InputArgument::IS_ARRAY); + $argument->setDefault('default'); } } diff --git a/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php b/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php index c322ed42bca68..76316bd863f68 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php @@ -26,7 +26,7 @@ public static function setUpBeforeClass() self::$fixtures = __DIR__.'/../Fixtures/'; } - public function testConstructor() + public function testConstructorArguments() { $this->initializeArguments(); @@ -35,7 +35,10 @@ public function testConstructor() $definition = new InputDefinition(array($this->foo, $this->bar)); $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getArguments(), '__construct() takes an array of InputArgument objects as its first argument'); + } + public function testConstructorOptions() + { $this->initializeOptions(); $definition = new InputDefinition(); @@ -77,36 +80,45 @@ public function testAddArgument() $this->assertEquals(array('foo' => $this->foo), $definition->getArguments(), '->addArgument() adds a InputArgument object'); $definition->addArgument($this->bar); $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getArguments(), '->addArgument() adds a InputArgument object'); + } - // arguments must have different names - try { - $definition->addArgument($this->foo1); - $this->fail('->addArgument() throws a \LogicException if another argument is already registered with the same name'); - } catch (\Exception $e) { - $this->assertInstanceOf('\LogicException', $e, '->addArgument() throws a \LogicException if another argument is already registered with the same name'); - $this->assertEquals('An argument with name "foo" already exists.', $e->getMessage()); - } + /** + * @expectedException \LogicException + * @expectedExceptionMessage An argument with name "foo" already exists. + */ + public function testArgumentsMustHaveDifferentNames() + { + $this->initializeArguments(); - // cannot add a parameter after an array parameter + $definition = new InputDefinition(); + $definition->addArgument($this->foo); + $definition->addArgument($this->foo1); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Cannot add an argument after an array argument. + */ + public function testArrayArgumentHasToBeLast() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); $definition->addArgument(new InputArgument('fooarray', InputArgument::IS_ARRAY)); - try { - $definition->addArgument(new InputArgument('anotherbar')); - $this->fail('->addArgument() throws a \LogicException if there is an array parameter already registered'); - } catch (\Exception $e) { - $this->assertInstanceOf('\LogicException', $e, '->addArgument() throws a \LogicException if there is an array parameter already registered'); - $this->assertEquals('Cannot add an argument after an array argument.', $e->getMessage()); - } - - // cannot add a required argument after an optional one + $definition->addArgument(new InputArgument('anotherbar')); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Cannot add a required argument after an optional one. + */ + public function testRequiredArgumentCannotFollowAnOptionalOne() + { + $this->initializeArguments(); + $definition = new InputDefinition(); $definition->addArgument($this->foo); - try { - $definition->addArgument($this->foo2); - $this->fail('->addArgument() throws a \LogicException if you try to add a required argument after an optional one'); - } catch (\Exception $e) { - $this->assertInstanceOf('\LogicException', $e, '->addArgument() throws a \LogicException if you try to add a required argument after an optional one'); - $this->assertEquals('Cannot add a required argument after an optional one.', $e->getMessage()); - } + $definition->addArgument($this->foo2); } public function testGetArgument() @@ -116,13 +128,19 @@ public function testGetArgument() $definition = new InputDefinition(); $definition->addArguments(array($this->foo)); $this->assertEquals($this->foo, $definition->getArgument('foo'), '->getArgument() returns a InputArgument by its name'); - try { - $definition->getArgument('bar'); - $this->fail('->getArgument() throws an \InvalidArgumentException if the InputArgument name does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->getArgument() throws an \InvalidArgumentException if the InputArgument name does not exist'); - $this->assertEquals('The "bar" argument does not exist.', $e->getMessage()); - } + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "bar" argument does not exist. + */ + public function testGetInvalidArgument() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); + $definition->addArguments(array($this->foo)); + $definition->getArgument('bar'); } public function testHasArgument() @@ -131,6 +149,7 @@ public function testHasArgument() $definition = new InputDefinition(); $definition->addArguments(array($this->foo)); + $this->assertTrue($definition->hasArgument('foo'), '->hasArgument() returns true if a InputArgument exists for the given name'); $this->assertFalse($definition->hasArgument('bar'), '->hasArgument() returns false if a InputArgument exists for the given name'); } @@ -181,13 +200,19 @@ public function testSetOptions() $this->assertEquals(array('foo' => $this->foo), $definition->getOptions(), '->setOptions() sets the array of InputOption objects'); $definition->setOptions(array($this->bar)); $this->assertEquals(array('bar' => $this->bar), $definition->getOptions(), '->setOptions() clears all InputOption objects'); - try { - $definition->getOptionForShortcut('f'); - $this->fail('->setOptions() clears all InputOption objects'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->setOptions() clears all InputOption objects'); - $this->assertEquals('The "-f" option does not exist.', $e->getMessage()); - } + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "-f" option does not exist. + */ + public function testSetOptionsClearsOptions() + { + $this->initializeOptions(); + + $definition = new InputDefinition(array($this->foo)); + $definition->setOptions(array($this->bar)); + $definition->getOptionForShortcut('f'); } public function testAddOptions() @@ -209,20 +234,32 @@ public function testAddOption() $this->assertEquals(array('foo' => $this->foo), $definition->getOptions(), '->addOption() adds a InputOption object'); $definition->addOption($this->bar); $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getOptions(), '->addOption() adds a InputOption object'); - try { - $definition->addOption($this->foo2); - $this->fail('->addOption() throws a \LogicException if the another option is already registered with the same name'); - } catch (\Exception $e) { - $this->assertInstanceOf('\LogicException', $e, '->addOption() throws a \LogicException if the another option is already registered with the same name'); - $this->assertEquals('An option named "foo" already exists.', $e->getMessage()); - } - try { - $definition->addOption($this->foo1); - $this->fail('->addOption() throws a \LogicException if the another option is already registered with the same shortcut'); - } catch (\Exception $e) { - $this->assertInstanceOf('\LogicException', $e, '->addOption() throws a \LogicException if the another option is already registered with the same shortcut'); - $this->assertEquals('An option with shortcut "f" already exists.', $e->getMessage()); - } + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage An option named "foo" already exists. + */ + public function testAddDuplicateOption() + { + $this->initializeOptions(); + + $definition = new InputDefinition(); + $definition->addOption($this->foo); + $definition->addOption($this->foo2); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage An option with shortcut "f" already exists. + */ + public function testAddDuplicateShortcutOption() + { + $this->initializeOptions(); + + $definition = new InputDefinition(); + $definition->addOption($this->foo); + $definition->addOption($this->foo1); } public function testGetOption() @@ -231,13 +268,18 @@ public function testGetOption() $definition = new InputDefinition(array($this->foo)); $this->assertEquals($this->foo, $definition->getOption('foo'), '->getOption() returns a InputOption by its name'); - try { - $definition->getOption('bar'); - $this->fail('->getOption() throws an \InvalidArgumentException if the option name does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->getOption() throws an \InvalidArgumentException if the option name does not exist'); - $this->assertEquals('The "--bar" option does not exist.', $e->getMessage()); - } + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "--bar" option does not exist. + */ + public function testGetInvalidOption() + { + $this->initializeOptions(); + + $definition = new InputDefinition(array($this->foo)); + $definition->getOption('bar'); } public function testHasOption() @@ -264,13 +306,18 @@ public function testGetOptionForShortcut() $definition = new InputDefinition(array($this->foo)); $this->assertEquals($this->foo, $definition->getOptionForShortcut('f'), '->getOptionForShortcut() returns a InputOption by its shortcut'); - try { - $definition->getOptionForShortcut('l'); - $this->fail('->getOption() throws an \InvalidArgumentException if the shortcut does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->getOption() throws an \InvalidArgumentException if the shortcut does not exist'); - $this->assertEquals('The "-l" option does not exist.', $e->getMessage()); - } + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "-l" option does not exist. + */ + public function testGetOptionForInvalidShortcut() + { + $this->initializeOptions(); + + $definition = new InputDefinition(array($this->foo)); + $definition->getOptionForShortcut('l'); } public function testGetOptionDefaults() diff --git a/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php b/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php index 1e0de35e3f755..b50c090484070 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php @@ -21,24 +21,29 @@ public function testConstructor() $this->assertEquals('foo', $option->getName(), '__construct() takes a name as its first argument'); $option = new InputOption('--foo'); $this->assertEquals('foo', $option->getName(), '__construct() removes the leading -- of the option name'); + } - try { - $option = new InputOption('foo', 'f', InputOption::VALUE_IS_ARRAY); - $this->fail('__construct() throws an \InvalidArgumentException if VALUE_IS_ARRAY option is used when an option does not accept a value'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if VALUE_IS_ARRAY option is used when an option does not accept a value'); - $this->assertEquals('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.', $e->getMessage()); - } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value. + */ + public function testArrayModeWithoutValue() + { + new InputOption('foo', 'f', InputOption::VALUE_IS_ARRAY); + } - // shortcut argument + public function testShortcut() + { $option = new InputOption('foo', 'f'); $this->assertEquals('f', $option->getShortcut(), '__construct() can take a shortcut as its second argument'); $option = new InputOption('foo', '-f'); $this->assertEquals('f', $option->getShortcut(), '__construct() removes the leading - of the shortcut'); $option = new InputOption('foo'); $this->assertNull($option->getShortcut(), '__construct() makes the shortcut null by default'); + } - // mode argument + public function testModes() + { $option = new InputOption('foo', 'f'); $this->assertFalse($option->acceptValue(), '__construct() gives a "InputOption::VALUE_NONE" mode by default'); $this->assertFalse($option->isValueRequired(), '__construct() gives a "InputOption::VALUE_NONE" mode by default'); @@ -63,21 +68,24 @@ public function testConstructor() $this->assertTrue($option->acceptValue(), '__construct() can take "InputOption::VALUE_OPTIONAL" as its mode'); $this->assertFalse($option->isValueRequired(), '__construct() can take "InputOption::VALUE_OPTIONAL" as its mode'); $this->assertTrue($option->isValueOptional(), '__construct() can take "InputOption::VALUE_OPTIONAL" as its mode'); + } + + /** + * @dataProvider provideInvalidModes + */ + public function testInvalidModes($mode) + { + $this->setExpectedException('InvalidArgumentException', sprintf('Option mode "%s" is not valid.', $mode)); + + new InputOption('foo', 'f', $mode); + } - try { - $option = new InputOption('foo', 'f', 'ANOTHER_ONE'); - $this->fail('__construct() throws an \InvalidArgumentException if the mode is not valid'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the mode is not valid'); - $this->assertEquals('Option mode "ANOTHER_ONE" is not valid.', $e->getMessage()); - } - try { - $option = new InputOption('foo', 'f', -1); - $this->fail('__construct() throws an \InvalidArgumentException if the mode is not valid'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the mode is not valid'); - $this->assertEquals('Option mode "-1" is not valid.', $e->getMessage()); - } + public function provideInvalidModes() + { + return array( + array('ANOTHER_ONE'), + array(-1) + ); } /** @@ -147,24 +155,26 @@ public function testSetDefault() $option = new InputOption('foo', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY); $option->setDefault(array(1, 2)); $this->assertEquals(array(1, 2), $option->getDefault(), '->setDefault() changes the default value'); + } + /** + * @expectedException \LogicException + * @expectedExceptionMessage Cannot set a default value when using InputOption::VALUE_NONE mode. + */ + public function testDefaultValueWithValueNoneMode() + { $option = new InputOption('foo', 'f', InputOption::VALUE_NONE); - try { - $option->setDefault('default'); - $this->fail('->setDefault() throws a \LogicException if you give a default value for a VALUE_NONE option'); - } catch (\Exception $e) { - $this->assertInstanceOf('\LogicException', $e, '->setDefault() throws a \LogicException if you give a default value for a VALUE_NONE option'); - $this->assertEquals('Cannot set a default value when using InputOption::VALUE_NONE mode.', $e->getMessage()); - } + $option->setDefault('default'); + } + /** + * @expectedException \LogicException + * @expectedExceptionMessage A default value for an array option must be an array. + */ + public function testDefaultValueWithIsArrayMode() + { $option = new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY); - try { - $option->setDefault('default'); - $this->fail('->setDefault() throws a \LogicException if you give a default value which is not an array for a VALUE_IS_ARRAY option'); - } catch (\Exception $e) { - $this->assertInstanceOf('\LogicException', $e, '->setDefault() throws a \LogicException if you give a default value which is not an array for a VALUE_IS_ARRAY option'); - $this->assertEquals('A default value for an array option must be an array.', $e->getMessage()); - } + $option->setDefault('default'); } public function testEquals() diff --git a/src/Symfony/Component/Console/Tests/Input/InputTest.php b/src/Symfony/Component/Console/Tests/Input/InputTest.php index 2863ea4f34618..0b3e38fb6f4ce 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputTest.php @@ -36,22 +36,26 @@ public function testOptions() $input = new ArrayInput(array('--name' => 'foo'), new InputDefinition(array(new InputOption('name'), new InputOption('bar', '', InputOption::VALUE_OPTIONAL, '', 'default')))); $this->assertEquals('default', $input->getOption('bar'), '->getOption() returns the default value for optional options'); $this->assertEquals(array('name' => 'foo', 'bar' => 'default'), $input->getOptions(), '->getOptions() returns all option values, even optional ones'); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "foo" option does not exist. + */ + public function testSetInvalidOption() + { + $input = new ArrayInput(array('--name' => 'foo'), new InputDefinition(array(new InputOption('name'), new InputOption('bar', '', InputOption::VALUE_OPTIONAL, '', 'default')))); + $input->setOption('foo', 'bar'); + } - try { - $input->setOption('foo', 'bar'); - $this->fail('->setOption() throws a \InvalidArgumentException if the option does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->setOption() throws a \InvalidArgumentException if the option does not exist'); - $this->assertEquals('The "foo" option does not exist.', $e->getMessage()); - } - - try { - $input->getOption('foo'); - $this->fail('->getOption() throws a \InvalidArgumentException if the option does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->setOption() throws a \InvalidArgumentException if the option does not exist'); - $this->assertEquals('The "foo" option does not exist.', $e->getMessage()); - } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "foo" option does not exist. + */ + public function testGetInvalidOption() + { + $input = new ArrayInput(array('--name' => 'foo'), new InputDefinition(array(new InputOption('name'), new InputOption('bar', '', InputOption::VALUE_OPTIONAL, '', 'default')))); + $input->getOption('foo'); } public function testArguments() @@ -66,45 +70,45 @@ public function testArguments() $input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name'), new InputArgument('bar', InputArgument::OPTIONAL, '', 'default')))); $this->assertEquals('default', $input->getArgument('bar'), '->getArgument() returns the default value for optional arguments'); $this->assertEquals(array('name' => 'foo', 'bar' => 'default'), $input->getArguments(), '->getArguments() returns all argument values, even optional ones'); + } - try { - $input->setArgument('foo', 'bar'); - $this->fail('->setArgument() throws a \InvalidArgumentException if the argument does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->setOption() throws a \InvalidArgumentException if the option does not exist'); - $this->assertEquals('The "foo" argument does not exist.', $e->getMessage()); - } - - try { - $input->getArgument('foo'); - $this->fail('->getArgument() throws a \InvalidArgumentException if the argument does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->setOption() throws a \InvalidArgumentException if the option does not exist'); - $this->assertEquals('The "foo" argument does not exist.', $e->getMessage()); - } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "foo" argument does not exist. + */ + public function testSetInvalidArgument() + { + $input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name'), new InputArgument('bar', InputArgument::OPTIONAL, '', 'default')))); + $input->setArgument('foo', 'bar'); } - public function testValidate() + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "foo" argument does not exist. + */ + public function testGetInvalidArgument() + { + $input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name'), new InputArgument('bar', InputArgument::OPTIONAL, '', 'default')))); + $input->getArgument('foo'); + } + + /** + * @expectedException \RuntimeException + * @expectedExceptionMessage Not enough arguments. + */ + public function testValidateWithMissingArguments() { $input = new ArrayInput(array()); $input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::REQUIRED)))); + $input->validate(); + } - try { - $input->validate(); - $this->fail('->validate() throws a \RuntimeException if not enough arguments are given'); - } catch (\Exception $e) { - $this->assertInstanceOf('\RuntimeException', $e, '->validate() throws a \RuntimeException if not enough arguments are given'); - $this->assertEquals('Not enough arguments.', $e->getMessage()); - } - + public function testValidate() + { $input = new ArrayInput(array('name' => 'foo')); $input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::REQUIRED)))); - try { - $input->validate(); - } catch (\RuntimeException $e) { - $this->fail('->validate() does not throw a \RuntimeException if enough arguments are given'); - } + $this->assertNull($input->validate()); } public function testSetGetInteractive() diff --git a/src/Symfony/Component/Console/Tests/Output/OutputTest.php b/src/Symfony/Component/Console/Tests/Output/OutputTest.php index aa4a2046b8bf9..be58b72d3c248 100644 --- a/src/Symfony/Component/Console/Tests/Output/OutputTest.php +++ b/src/Symfony/Component/Console/Tests/Output/OutputTest.php @@ -37,43 +37,69 @@ public function testSetGetVerbosity() $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '->setVerbosity() sets the verbosity'); } - public function testWrite() + public function testWriteWithVerbosityQuiet() { - $fooStyle = new OutputFormatterStyle('yellow', 'red', array('blink')); $output = new TestOutput(Output::VERBOSITY_QUIET); $output->writeln('foo'); $this->assertEquals('', $output->output, '->writeln() outputs nothing if verbosity is set to VERBOSITY_QUIET'); + } + public function testWriteAnArrayOfMessages() + { $output = new TestOutput(); $output->writeln(array('foo', 'bar')); $this->assertEquals("foo\nbar\n", $output->output, '->writeln() can take an array of messages to output'); + } + /** + * @dataProvider provideWriteArguments + */ + public function testWriteRawMessage($message, $type, $expectedOutput) + { $output = new TestOutput(); - $output->writeln('foo', Output::OUTPUT_RAW); - $this->assertEquals("foo\n", $output->output, '->writeln() outputs the raw message if OUTPUT_RAW is specified'); + $output->writeln($message, $type); + $this->assertEquals($expectedOutput, $output->output); + } - $output = new TestOutput(); - $output->writeln('foo', Output::OUTPUT_PLAIN); - $this->assertEquals("foo\n", $output->output, '->writeln() strips decoration tags if OUTPUT_PLAIN is specified'); + public function provideWriteArguments() + { + return array( + array('foo', Output::OUTPUT_RAW, "foo\n"), + array('foo', Output::OUTPUT_PLAIN, "foo\n"), + ); + } + public function testWriteWithDecorationTurnedOff() + { $output = new TestOutput(); $output->setDecorated(false); $output->writeln('foo'); $this->assertEquals("foo\n", $output->output, '->writeln() strips decoration tags if decoration is set to false'); + } + public function testWriteDecoratedMessage() + { + $fooStyle = new OutputFormatterStyle('yellow', 'red', array('blink')); $output = new TestOutput(); $output->getFormatter()->setStyle('FOO', $fooStyle); $output->setDecorated(true); $output->writeln('foo'); $this->assertEquals("\033[33;41;5mfoo\033[0m\n", $output->output, '->writeln() decorates the output'); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Unknown output type given (24) + */ + public function testWriteWithInvalidOutputType() + { + $output = new TestOutput(); + $output->writeln('foo', 24); + } - try { - $output->writeln('foo', 24); - $this->fail('->writeln() throws an \InvalidArgumentException when the type does not exist'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '->writeln() throws an \InvalidArgumentException when the type does not exist'); - $this->assertEquals('Unknown output type given (24)', $e->getMessage()); - } + public function testWriteWithInvalidStyle() + { + $output = new TestOutput(); $output->clear(); $output->write('foo'); diff --git a/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php b/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php index b151a486df27c..2fd4f612142e8 100644 --- a/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php +++ b/src/Symfony/Component/Console/Tests/Output/StreamOutputTest.php @@ -30,19 +30,20 @@ protected function tearDown() public function testConstructor() { - try { - $output = new StreamOutput('foo'); - $this->fail('__construct() throws an \InvalidArgumentException if the first argument is not a stream'); - } catch (\Exception $e) { - $this->assertInstanceOf('\InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the first argument is not a stream'); - $this->assertEquals('The StreamOutput class needs a stream as its first argument.', $e->getMessage()); - } - $output = new StreamOutput($this->stream, Output::VERBOSITY_QUIET, true); $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument'); $this->assertTrue($output->isDecorated(), '__construct() takes the decorated flag as its second argument'); } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The StreamOutput class needs a stream as its first argument. + */ + public function testStreamIsRequired() + { + new StreamOutput('foo'); + } + public function testGetStream() { $output = new StreamOutput($this->stream); From ed58e362f77cad12969ac5a3d78a994728332fc2 Mon Sep 17 00:00:00 2001 From: Bilal Amarni Date: Thu, 7 Feb 2013 17:01:11 +0100 Subject: [PATCH 0010/1305] [HttpKernel] CLI - don't always display errors --- src/Symfony/Component/HttpKernel/Kernel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 46440a3468717..1587ba8039a55 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -105,7 +105,7 @@ public function init() ErrorHandler::register($this->errorReportingLevel); if ('cli' !== php_sapi_name()) { ExceptionHandler::register(); - } else { + } elseif (!ini_get('log_errors') || ini_get('error_log')) { ini_set('display_errors', 1); } } From bf9a483b3e1a00121fae55bd6e0f1ecbf4fffb71 Mon Sep 17 00:00:00 2001 From: Lee McDermott Date: Thu, 7 Feb 2013 22:33:28 +0000 Subject: [PATCH 0011/1305] CSS3, HTML5 cleanuos --- .../Resources/views/Collector/config.html.twig | 8 ++++---- .../Resources/views/Collector/events.html.twig | 2 +- .../Resources/views/Collector/exception.css.twig | 4 ---- .../Resources/views/Collector/exception.html.twig | 4 ++-- .../Resources/views/Collector/logger.html.twig | 12 ++++++------ .../Resources/views/Collector/memory.html.twig | 2 +- .../Resources/views/Collector/request.html.twig | 4 ++-- .../Resources/views/Collector/router.html.twig | 2 +- .../Resources/views/Collector/time.html.twig | 10 +++++----- .../Resources/views/Profiler/admin.html.twig | 6 +++--- .../Resources/views/Profiler/base.html.twig | 12 ++++++------ .../Resources/views/Profiler/base_js.html.twig | 2 +- .../Resources/views/Profiler/body.css.twig | 2 -- .../Resources/views/Profiler/header.html.twig | 6 +++--- .../Resources/views/Profiler/layout.html.twig | 4 ++-- .../Resources/views/Profiler/profiler.css.twig | 8 -------- .../Resources/views/Profiler/search.html.twig | 12 ++++++------ .../Resources/views/Profiler/toolbar.css.twig | 6 +----- .../Resources/views/Profiler/toolbar.html.twig | 4 ++-- .../Resources/views/Profiler/toolbar_js.html.twig | 2 +- 20 files changed, 47 insertions(+), 65 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig index dc4eb861b9daa..9e8558a8b0c31 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig @@ -4,7 +4,7 @@ {# Symfony Logo #} {% set icon %} - Symfony + Symfony {{ collector.symfonyversion }} {% endset %} @@ -21,7 +21,7 @@ {# PHP Information #} {% set icon %} - PHP + PHP {% endset %} {% set text %} @@ -46,7 +46,7 @@ {# Environment #} {% set debug_status_class %}sf-toolbar-status sf-toolbar-status-{{ collector.debug ? 'green' : 'red' }}{% endset %} {% set icon %} - Environment + Environment {{ token }} @@ -84,7 +84,7 @@ {% block menu %} - Configuration + Configuration Config {% endblock %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/events.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/events.html.twig index 50bd06f960699..6072ff69f2fe3 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/events.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/events.html.twig @@ -4,7 +4,7 @@ {% block menu %} - Events + Events Events {% endblock %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.css.twig index bfd9094f30483..1224081bd600a 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.css.twig @@ -29,8 +29,6 @@ margin: 10px 0 20px; } .sf-reset .block-exception { - -moz-border-radius: 16px; - -webkit-border-radius: 16px; border-radius: 16px; margin-bottom: 20px; background-color: #f6f6f6; @@ -86,8 +84,6 @@ .sf-reset .error-count span { display: inline-block; background-color: #aacd4e; - -moz-border-radius: 6px; - -webkit-border-radius: 6px; border-radius: 6px; padding: 4px; color: white; diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.html.twig index 273749ffd6db3..121a9ee5d6964 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/exception.html.twig @@ -2,7 +2,7 @@ {% block head %} {% if collector.hasexception %} - {% endif %} @@ -11,7 +11,7 @@ {% block menu %} - Exception + Exception Exception {% if collector.hasexception %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig index fbba52f36f1b6..7523bf2714908 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig @@ -5,7 +5,7 @@ {% block toolbar %} {% if collector.counterrors or collector.countdeprecations %} {% set icon %} - Logs + Logs {% if collector.counterrors %} {% set status_color = "red" %} {% else %} @@ -34,7 +34,7 @@ {% block menu %} - Logger + Logger Logs {% if collector.counterrors or collector.countdeprecations %} {% set error_count = collector.counterrors + collector.countdeprecations %} @@ -55,7 +55,7 @@ Filter
- +
@@ -94,8 +94,8 @@ DEPRECATION - {{ log.message }} {% set id = 'sf-call-stack-' ~ log_index %} - - + + + + {% for index, call in log.context.stack if index > 1 %} {% if index == 2 %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/memory.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/memory.html.twig index 2b6dc69978af7..7567eb935f28e 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/memory.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/memory.html.twig @@ -3,7 +3,7 @@ {% block toolbar %} {% set icon %} - Memory Usage + Memory Usage {{ '%.1f'|format(collector.memory / 1024 / 1024) }} MB {% endset %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig index 4fc3dd9d2f2ac..b1c19e6a66ce2 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig @@ -15,7 +15,7 @@ {% set request_status_code_color = (400 > collector.statuscode) ? ((200 == collector.statuscode) ? 'green' : 'yellow') : 'red'%} {% set request_route = collector.route ? collector.route : 'NONE' %} {% set icon %} - Request + Request {{ collector.statuscode }} {{ request_handler }} on {{ request_route }} @@ -45,7 +45,7 @@ {% block menu %} - Request + Request Request {% endblock %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/router.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/router.html.twig index 1e1f3287d5899..782465dc61b80 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/router.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/router.html.twig @@ -5,7 +5,7 @@ {% block menu %} - Routing + Routing Routing {% endblock %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig index b8853213f3bfc..f273651ead6ad 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/time.html.twig @@ -18,7 +18,7 @@ {% block toolbar %} {% set duration = collector.events|length ? '%.0f ms'|format(collector.duration) : 'n/a' %} {% set icon %} - Time + Time {{ duration }} {% endset %} {% set text %} @@ -32,7 +32,7 @@ {% block menu %} - Timeline + Timeline Timeline {% endblock %} @@ -50,7 +50,7 @@ {% block panelContent %}
- + @@ -62,7 +62,7 @@ - +
Total time
Threshold ms ms
@@ -93,7 +93,7 @@ {% endfor %} {% endif %} - From 6e57380d14a9ecead8eab962ce9c5eb1daa4857f Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Sat, 26 Apr 2014 13:09:19 +0200 Subject: [PATCH 1000/1305] [Console] Fixed the rendering of exceptions on HHVM with a terminal width --- src/Symfony/Component/Console/Application.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 4e394f284b035..e1e83dee3e46c 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -728,8 +728,11 @@ public function renderException($e, $output) do { $title = sprintf(' [%s] ', get_class($e)); $len = $strlen($title); + $width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 1 : PHP_INT_MAX; // HHVM only accepts 32 bits integer in str_split, even when PHP_INT_MAX is a 64 bit integer: https://github.com/facebook/hhvm/issues/1327 - $width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 1 : (defined('HHVM_VERSION') ? 1 << 31 : PHP_INT_MAX); + if (defined('HHVM_VERSION') && $width > 1 << 31) { + $width = 1 << 31; + } $formatter = $output->getFormatter(); $lines = array(); foreach (preg_split('/\r?\n/', $e->getMessage()) as $line) { From f096093d44def2472a8bd414db00fda256e7c4ab Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 27 Apr 2014 10:33:05 +0200 Subject: [PATCH 1001/1305] updated CHANGELOG for 2.3.13 --- CHANGELOG-2.3.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/CHANGELOG-2.3.md b/CHANGELOG-2.3.md index b542528211148..c8b2938fd25ae 100644 --- a/CHANGELOG-2.3.md +++ b/CHANGELOG-2.3.md @@ -7,6 +7,29 @@ in 2.3 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.3.0...v2.3.1 +* 2.3.13 (2014-04-27) + + * bug #10789 [Console] Fixed the rendering of exceptions on HHVM with a terminal width (stof) + * bug #10773 [WebProfilerBundle ] Fixed an edge case on WDT loading (tucksaun) + * bug #10763 [Process] Disable TTY mode on Windows platform (romainneutron) + * bug #10772 [Finder] Fix ignoring of unreadable dirs in the RecursiveDirectoryIterator (jakzal) + * bug #10757 [Process] Setting STDIN while running should not be possible (romainneutron) + * bug #10749 Fixed incompatibility of x509 auth with nginx (alcaeus) + * bug #10735 [Translation] [PluralizationRules] Little correction for case 'ar' (klyk50) + * bug #10720 [HttpFoundation] Fix DbalSessionHandler (Tobion) + * bug #10721 [HttpFoundation] status 201 is allowed to have a body (Tobion) + * bug #10728 [Process] Fix #10681, process are failing on Windows Server 2003 (romainneutron) + * bug #10733 [DomCrawler] Textarea value should default to empty string instead of null. (Berdir) + * bug #10723 [Security] fix DBAL connection typehint (Tobion) + * bug #10700 Fixes various inconsistencies in the code (fabpot) + * bug #10697 [Translation] Make IcuDatFileLoader/IcuResFileLoader::load invalid resource compatible with HHVM. (idn2104) + * bug #10652 [HttpFoundation] fix PDO session handler under high concurrency (Tobion) + * bug #10669 [Profiler] Prevent throwing fatal errors when searching timestamps or invalid dates (stloyd) + * bug #10670 [Templating] PhpEngine should propagate charset to its helpers (stloyd) + * bug #10665 [DependencyInjection] Fix ticket #10663 - Added setCharset method call to PHP templating engine (koku) + * bug #10654 Changed the typehint of the EsiFragmentRenderer to the interface (stof) + * bug #10649 [BrowserKit] Fix #10641 : BrowserKit is broken when using ip as host (romainneutron) + * 2.3.12 (2014-04-03) * bug #10586 Fixes URL validator to accept single part urls (merk) From 096d3c983c211bc74440ecb2d7eb76f2337c2b75 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 27 Apr 2014 10:34:15 +0200 Subject: [PATCH 1002/1305] update CONTRIBUTORS for 2.3.13 --- CONTRIBUTORS.md | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index edfb9e706765b..d67d7509e16f0 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -23,9 +23,9 @@ Symfony2 is the result of the work of many people who made the code better - Benjamin Eberlei (beberlei) - Igor Wiedler (igorw) - Hugo Hamon (hhamon) + - Romain Neutron (romain) - Eriksen Costa (eriksencosta) - Martin Hasoň (hason) - - Romain Neutron (romain) - Jonathan Wage (jwage) - Alexandre Salomé (alexandresalome) - William Durand (couac) @@ -48,49 +48,49 @@ Symfony2 is the result of the work of many people who made the code better - Dariusz Górecki (canni) - Andrej Hudec (pulzarraider) - Arnout Boks (aboks) + - Michel Weimerskirch (mweimerskirch) - Lee McDermott - Brandon Turner + - Douglas Greenshields (shieldo) - Daniel Holmes (dholmes) - Jordan Alliot (jalliot) - Christian Raue - - Douglas Greenshields (shieldo) - John Wards (johnwards) - Fran Moreno (franmomu) - Bart van den Burg (burgov) - Antoine Hérault (herzult) - Toni Uebernickel (havvg) - - Michel Weimerskirch (mweimerskirch) - Arnaud Le Blanc (arnaud-lb) - Brice BERNARD (brikou) - Luis Cordova (cordoval) + - Tim Nagel (merk) - Kevin Bond (kbond) - marc.weistroff - lenar - - Tim Nagel (merk) - Włodzimierz Gajda (gajdaw) - Colin Frei - excelwebzone - Fabien Pennequin (fabienpennequin) - Jacob Dreesen (jdreesen) - Adrien Brault (adrienbrault) + - Gábor Egyed (1ed) - Michal Piotrowski (eventhorizon) - Florian Voutzinos (florianv) - Robert Schönthal (digitalkaoz) - Juti Noppornpitak (shiroyuki) - Sebastian Hörl (blogsh) - Hidenori Goto (hidenorigoto) - - Gábor Egyed (1ed) - Daniel Gomes (danielcsgomes) + - Peter Kokot (maastermedia) - Jérémie Augustin (jaugustin) - David Buchmann (dbu) - Ait Boudad Abdellatif (aitboudad) - - Peter Kokot (maastermedia) + - Jérôme Tamarelle (gromnan) - Tigran Azatyan (tigranazatyan) - Javier Eguiluz (javier.eguiluz) - Rafael Dohms (rdohms) - Richard Shank (iampersistent) - Gordon Franke (gimler) - - Jérôme Tamarelle (gromnan) - Helmer Aaviksoo - Sebastiaan Stok (sstok) - Matthieu Ouellette-Vachon (maoueh) @@ -99,6 +99,7 @@ Symfony2 is the result of the work of many people who made the code better - Jonathan Ingram (jonathaningram) - Artur Kotyrba - Guilherme Blanco (guilhermeblanco) + - Nicolas Grekas (nicolas-grekas) - Pablo Godel (pgodel) - Eric GELOEN (gelo) - Dmitrii Chekaliuk (lazyhammer) @@ -122,7 +123,6 @@ Symfony2 is the result of the work of many people who made the code better - fivestar - Dominique Bongiraud - Leszek Prabucki (l3l0) - - Nicolas Grekas (nicolas-grekas) - François Zaninotto (fzaninotto) - Dustin Whittle (dustinwhittle) - jeff @@ -228,6 +228,7 @@ Symfony2 is the result of the work of many people who made the code better - Xavier HAUSHERR - Albert Jessurum (ajessu) - Laszlo Korte + - Miha Vrhovnik - Alessandro Desantis - hubert lecorche (hlecorche) - Eugene Leonovich (rybakit) @@ -259,11 +260,13 @@ Symfony2 is the result of the work of many people who made the code better - Vitaliy Tverdokhlib (vitaliytv) - Dirk Pahl (dirkaholic) - cedric lombardot (cedriclombardot) + - Charles Sarrazin (csarrazi) - Jonas Flodén (flojon) - Marcin Sikoń (marphi) - franek (franek) - Adam Harvey - Robbert Klarenbeek (robbertkl) + - François-Xavier de Guillebon (de-gui_f) - boombatower - Fabrice Bernhard (fabriceb) - Fabian Lange (codingfabian) @@ -285,6 +288,7 @@ Symfony2 is the result of the work of many people who made the code better - Maks Slesarenko - Markus Lanthaler (lanthaler) - Vicent Soria Durá (vicentgodella) + - Ioan Negulescu - Andrew Udvare (audvare) - alexpods - Erik Trapman (eriktrapman) @@ -312,10 +316,10 @@ Symfony2 is the result of the work of many people who made the code better - Aurélien Fredouelle - Karoly Negyesi (chx) - Pavel Campr (pcampr) - - Miha Vrhovnik - Geoffrey Tran (geoff) - Jan Behrens - Thomas Lallement (raziel057) + - alcaeus - vitaliytv - Markus Bachmann (baachi) - aubx @@ -349,8 +353,8 @@ Symfony2 is the result of the work of many people who made the code better - Chris Heng (gigablah) - Ulumuddin Yunus (joenoez) - Antoine Corcy + - Sascha Grossenbacher - Ben Davies (bendavies) - - François-Xavier de Guillebon (de-gui_f) - Hossein Bukhamsin - Paweł Wacławczyk (pwc) - Oleg Zinchenko (cystbear) @@ -387,6 +391,7 @@ Symfony2 is the result of the work of many people who made the code better - Casper Valdemar Poulsen - Josiah (josiah) - John Bohn (jbohn) + - Jakub Škvára (jskvara) - Andrew Hilobok (hilobok) - Christian Soronellas (theunic) - Jérôme Vieilledent (lolautruche) @@ -400,6 +405,7 @@ Symfony2 is the result of the work of many people who made the code better - Jayson Xu (superjavason) - Jaik Dean (jaikdean) - Jan Prieser + - Issei Murasawa (issei_m) - James Michael DuPont - Tom Klingenberg - Christopher Hall (mythmakr) @@ -458,13 +464,14 @@ Symfony2 is the result of the work of many people who made the code better - Robert Gruendler (pulse00) - Simon Terrien (sterrien) - Benoît Merlet (trompette) + - Koen Kuipers - Raul Fraile (raulfraile) - sensio - Patrick Kaufmann - - alcaeus - Ben Ramsey (ramsey) - Christian Jul Jensen - The Whole Life to Learn + - Liverbool (liverbool) - Phan Thanh Ha (haphan) - Chris Jones (leek) - Colin O'Dell (colinodell) @@ -506,7 +513,6 @@ Symfony2 is the result of the work of many people who made the code better - Catalin Dan - Piotr Antosik (antek88) - Artem Lopata - - Sascha Grossenbacher - Marcos Quesada (marcos_quesada) - Dan Finnie - Ken Marfilla (marfillaster) @@ -570,6 +576,7 @@ Symfony2 is the result of the work of many people who made the code better - heccjj - Alexandre Melard - Sergey Yuferev + - Mario Young - Mo Di (modi) - Jeroen van den Enden (stoefke) - Quique Porta (quiqueporta) @@ -623,7 +630,6 @@ Symfony2 is the result of the work of many people who made the code better - WedgeSama - Beth Binkovitz - Romain Geissler - - Charles Sarrazin (csarrazi) - Marcus Stöhr (dafish) - Emmanuel Vella (emmanuel.vella) - Carsten Nielsen (phreaknerd) @@ -674,7 +680,6 @@ Symfony2 is the result of the work of many people who made the code better - Olivier - pscheit - Ramon Kleiss (akathos) - - Jakub Škvára (jskvara) - Nicolas Badey (nico-b) - Shane Preece (shane) - povilas @@ -698,6 +703,7 @@ Symfony2 is the result of the work of many people who made the code better - 2manypeople - Wing - Thomas Bibb + - catch - Alexandre Segura - Josef Cech - Matthew Foster (mfoster) @@ -748,6 +754,7 @@ Symfony2 is the result of the work of many people who made the code better - Jordi Llonch (jordillonch) - Cédric Dugat (ph3nol) - Philip Dahlstrøm (phidah) + - Loick Piera (pyrech) - Rénald Casagraude (rcasagraude) - Robin Duval (robin-duval) - Artem Lopata (bumz) @@ -814,6 +821,7 @@ Symfony2 is the result of the work of many people who made the code better - Alex - Klaas Naaijkens - Rafał + - Adria Lopez (adlpz) - Masao Maeda (brtriver) - Dave Hulbert (dave1010) - Dave Marshall (davedevelopment) @@ -861,6 +869,7 @@ Symfony2 is the result of the work of many people who made the code better - Myke79 - Brian Debuire - Sylvain Lorinet + - klyk50 - jc - BenjaminBeck - Aurelijus Rožėnas @@ -948,6 +957,7 @@ Symfony2 is the result of the work of many people who made the code better - Yohan Giarelli (frequence-web) - Massimiliano Arione (garak) - Ghazy Ben Ahmed (ghazy) + - ibasaw (ibasaw) - Vladislav Krupenkin (ideea) - joris de wit (jdewit) - Jérémy CROMBEZ (jeremy) @@ -992,6 +1002,7 @@ Symfony2 is the result of the work of many people who made the code better - Gustavo Adrian - Michael - fh-github@fholzhauer.de + - Mark Topper - Xavier REN - Philipp Scheit - max From 9c4b11915d7409a9cecd155d954f2ade273f3359 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 27 Apr 2014 10:34:33 +0200 Subject: [PATCH 1003/1305] updated VERSION for 2.3.13 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 713d3b186664a..8c030ba81e085 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.3.13-DEV'; + const VERSION = '2.3.13'; const VERSION_ID = '20313'; const MAJOR_VERSION = '2'; const MINOR_VERSION = '3'; const RELEASE_VERSION = '13'; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; /** * Constructor. From d28149f75eb06b8229a8156da78798050aabe6dc Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 27 Apr 2014 15:16:57 +0200 Subject: [PATCH 1004/1305] bumped Symfony version to 2.3.14 --- 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 8c030ba81e085..cad359a8c48f8 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.3.13'; - const VERSION_ID = '20313'; + const VERSION = '2.3.14-DEV'; + const VERSION_ID = '20314'; const MAJOR_VERSION = '2'; const MINOR_VERSION = '3'; - const RELEASE_VERSION = '13'; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = '14'; + const EXTRA_VERSION = 'DEV'; /** * Constructor. From 074191e705e4734a513a1d245a9fa05fe38092a7 Mon Sep 17 00:00:00 2001 From: Asmir Mustafic Date: Wed, 9 Apr 2014 08:27:01 +0200 Subject: [PATCH 1005/1305] Removed strict check when found variables inside a translation --- src/Symfony/Bridge/Twig/Node/TransNode.php | 8 ++- .../Bridge/Twig/Tests/Node/TransNodeTest.php | 60 +++++++++++++++++++ 2 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php diff --git a/src/Symfony/Bridge/Twig/Node/TransNode.php b/src/Symfony/Bridge/Twig/Node/TransNode.php index 924f2b9298966..e8571d5be1e0f 100644 --- a/src/Symfony/Bridge/Twig/Node/TransNode.php +++ b/src/Symfony/Bridge/Twig/Node/TransNode.php @@ -36,7 +36,7 @@ public function compile(\Twig_Compiler $compiler) $defaults = $this->getNode('vars'); $vars = null; } - list($msg, $defaults) = $this->compileString($this->getNode('body'), $defaults); + list($msg, $defaults) = $this->compileString($this->getNode('body'), $defaults, (boolean) $vars); $method = null === $this->getNode('count') ? 'trans' : 'transChoice'; @@ -83,7 +83,7 @@ public function compile(\Twig_Compiler $compiler) $compiler->raw(");\n"); } - protected function compileString(\Twig_NodeInterface $body, \Twig_Node_Expression_Array $vars) + protected function compileString(\Twig_NodeInterface $body, \Twig_Node_Expression_Array $vars, $ignoreStrictCheck = false) { if ($body instanceof \Twig_Node_Expression_Constant) { $msg = $body->getAttribute('value'); @@ -98,7 +98,9 @@ protected function compileString(\Twig_NodeInterface $body, \Twig_Node_Expressio foreach ($matches[1] as $var) { $key = new \Twig_Node_Expression_Constant('%'.$var.'%', $body->getLine()); if (!$vars->hasElement($key)) { - $vars->addElement(new \Twig_Node_Expression_Name($var, $body->getLine()), $key); + $varExpr = new \Twig_Node_Expression_Name($var, $body->getLine()); + $varExpr->setAttribute('ignore_strict_check', $ignoreStrictCheck); + $vars->addElement($varExpr, $key); } } diff --git a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php new file mode 100644 index 0000000000000..d331186c40c6c --- /dev/null +++ b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php @@ -0,0 +1,60 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\Twig\Tests\Node; + +use Symfony\Bridge\Twig\Node\TransNode; + +/** + * + * @author Asmir Mustafic + * + */ +class TransNodeTest extends \PHPUnit_Framework_TestCase +{ + + public function testCompileStrict() + { + $body = new \Twig_Node_Text('trans %var%', 0); + $vars = new \Twig_Node_Expression_Name('foo', 0); + $node = new TransNode($body, null, null, $vars); + + $env = new \Twig_Environment(null, array( + 'strict_variables' => true, + )); + $compiler = new \Twig_Compiler($env); + + $this->assertEquals( + sprintf( + 'echo $this->env->getExtension(\'translator\')->getTranslator()->trans("trans %%var%%", array_merge(array("%%var%%" => %s), %s), "messages");', + $this->getVariableGetterWithoutStrictCheck('var'), + $this->getVariableGetterWithStrictCheck('foo') + ), + trim($compiler->compile($node)->getSource()) + ); + } + protected function getVariableGetterWithoutStrictCheck($name) + { + if (version_compare(phpversion(), '5.4.0RC1', '>=')) { + return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); + } + + return sprintf('$this->getContext($context, "%s", true)', $name); + } + protected function getVariableGetterWithStrictCheck($name) + { + if (version_compare(phpversion(), '5.4.0RC1', '>=')) { + return sprintf('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name); + } + + return sprintf('$this->getContext($context, "%s")', $name); + } +} From 17d7186cf84134ad7fae82cd155b4f6e5b66aa8e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 28 Apr 2014 11:30:24 +0200 Subject: [PATCH 1006/1305] fixed CS --- src/Symfony/Bridge/Twig/Node/TransNode.php | 2 +- src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Node/TransNode.php b/src/Symfony/Bridge/Twig/Node/TransNode.php index e8571d5be1e0f..2409090699b7e 100644 --- a/src/Symfony/Bridge/Twig/Node/TransNode.php +++ b/src/Symfony/Bridge/Twig/Node/TransNode.php @@ -36,7 +36,7 @@ public function compile(\Twig_Compiler $compiler) $defaults = $this->getNode('vars'); $vars = null; } - list($msg, $defaults) = $this->compileString($this->getNode('body'), $defaults, (boolean) $vars); + list($msg, $defaults) = $this->compileString($this->getNode('body'), $defaults, (bool) $vars); $method = null === $this->getNode('count') ? 'trans' : 'transChoice'; diff --git a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php index d331186c40c6c..e02637f237e38 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php @@ -14,22 +14,17 @@ use Symfony\Bridge\Twig\Node\TransNode; /** - * * @author Asmir Mustafic - * */ class TransNodeTest extends \PHPUnit_Framework_TestCase { - public function testCompileStrict() { $body = new \Twig_Node_Text('trans %var%', 0); $vars = new \Twig_Node_Expression_Name('foo', 0); $node = new TransNode($body, null, null, $vars); - $env = new \Twig_Environment(null, array( - 'strict_variables' => true, - )); + $env = new \Twig_Environment(null, array('strict_variables' => true)); $compiler = new \Twig_Compiler($env); $this->assertEquals( @@ -49,6 +44,7 @@ protected function getVariableGetterWithoutStrictCheck($name) return sprintf('$this->getContext($context, "%s", true)', $name); } + protected function getVariableGetterWithStrictCheck($name) { if (version_compare(phpversion(), '5.4.0RC1', '>=')) { From 6daa2951fcbb20d9cfaccdb85cdb394bf55cd1ed Mon Sep 17 00:00:00 2001 From: Charles-Eric Gorron Date: Mon, 7 Apr 2014 11:07:52 +0200 Subject: [PATCH 1007/1305] Add upgrade instructions for the LoggerInterface --- UPGRADE-2.2.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/UPGRADE-2.2.md b/UPGRADE-2.2.md index 7c7b31c9fe438..5960d998dae04 100644 --- a/UPGRADE-2.2.md +++ b/UPGRADE-2.2.md @@ -646,3 +646,23 @@ extended with an optional `$context` array. This was necessary to allow for more complex use-cases that require context information during the (de)normalization and en-/decoding steps. + +### HttpKernel + + * The `Symfony\Component\HttpKernel\Log\LoggerInterface` now extends `Psr\Log\LoggerInterface`. + So if you have implemented your own logger, you need to implement these methods: + + * `emergency` + * `critical` + * `error` + * `warning` + * `log` + +#### Deprecations: + + * The following Logger methods are deprecated and will be removed in 3.0. You should use the new PSR-3 methods: + + * `emerg()` -> `emergency()` + * `crit()` -> `critical()` + * `err()` -> `error()` + * `warn()` -> `warning()` From fc04ad21342bf360c62ef8bff024e654360eb48b Mon Sep 17 00:00:00 2001 From: Andreas Lutro Date: Mon, 28 Apr 2014 14:17:03 +0200 Subject: [PATCH 1008/1305] Allow File instance to be passed to BinaryFileResponse --- src/Symfony/Component/HttpFoundation/BinaryFileResponse.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index d43e0732cd009..55c2ac5dd6e72 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -81,7 +81,9 @@ public static function create($file = null, $status = 200, $headers = array(), $ */ public function setFile($file, $contentDisposition = null, $autoEtag = false, $autoLastModified = true) { - $file = new File((string) $file); + if (!$file instanceof File) { + $file = new File((string) $file); + } if (!$file->isReadable()) { throw new FileException('File must be readable.'); From ed0ed80286aece30c26f6bdf44983681f60719fd Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 28 Apr 2014 18:07:34 +0200 Subject: [PATCH 1009/1305] [Debug] ErrorHandler: remove $GLOBALS from context in PHP5.3 fix #10292 --- src/Symfony/Component/Debug/ErrorHandler.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index 2436a1f249ccb..038b8b6a3d4cd 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -126,6 +126,10 @@ function ($row) { require __DIR__.'/Exception/ContextErrorException.php'; } + if (PHP_VERSION_ID < 50400 && isset($context['GLOBALS'])) { + unset($context['GLOBALS']); + } + $exception = new ContextErrorException(sprintf('%s: %s in %s line %d', isset($this->levels[$level]) ? $this->levels[$level] : $level, $message, $file, $line), 0, $level, $file, $line, $context); // Exceptions thrown from error handlers are sometimes not caught by the exception From 988a5dc937c1c45681d6c201f81e31b944d08873 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 28 Apr 2014 20:50:14 +0200 Subject: [PATCH 1010/1305] [Debug] fix ErrorHandlerTest when context is not an array --- src/Symfony/Component/Debug/ErrorHandler.php | 2 +- .../Component/Debug/Tests/ErrorHandlerTest.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index 038b8b6a3d4cd..7e8bbc55421c2 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -126,7 +126,7 @@ function ($row) { require __DIR__.'/Exception/ContextErrorException.php'; } - if (PHP_VERSION_ID < 50400 && isset($context['GLOBALS'])) { + if (PHP_VERSION_ID < 50400 && isset($context['GLOBALS']) && is_array($context)) { unset($context['GLOBALS']); } diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 287eb44335aae..2731e4630f891 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -165,18 +165,18 @@ public function testConstruct() public function testHandle() { $handler = ErrorHandler::register(0); - $this->assertFalse($handler->handle(0, 'foo', 'foo.php', 12, 'foo')); + $this->assertFalse($handler->handle(0, 'foo', 'foo.php', 12, array())); restore_error_handler(); $handler = ErrorHandler::register(3); - $this->assertFalse($handler->handle(4, 'foo', 'foo.php', 12, 'foo')); + $this->assertFalse($handler->handle(4, 'foo', 'foo.php', 12, array())); restore_error_handler(); $handler = ErrorHandler::register(3); try { - $handler->handle(111, 'foo', 'foo.php', 12, 'foo'); + $handler->handle(111, 'foo', 'foo.php', 12, array()); } catch (\ErrorException $e) { $this->assertSame('111: foo in foo.php line 12', $e->getMessage()); $this->assertSame(111, $e->getSeverity()); @@ -187,12 +187,12 @@ public function testHandle() restore_error_handler(); $handler = ErrorHandler::register(E_USER_DEPRECATED); - $this->assertTrue($handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, 'foo')); + $this->assertTrue($handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, array())); restore_error_handler(); $handler = ErrorHandler::register(E_DEPRECATED); - $this->assertTrue($handler->handle(E_DEPRECATED, 'foo', 'foo.php', 12, 'foo')); + $this->assertTrue($handler->handle(E_DEPRECATED, 'foo', 'foo.php', 12, array())); restore_error_handler(); @@ -215,7 +215,7 @@ public function testHandle() $handler = ErrorHandler::register(E_USER_DEPRECATED); $handler->setLogger($logger); - $handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, 'foo'); + $handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, array()); restore_error_handler(); } From b147cfaf15492660d6d878d6815512943446401b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 29 Apr 2014 21:42:43 +0200 Subject: [PATCH 1011/1305] [Debug] fix #10313: FlattenException not found because of https://bugs.php.net/42098 --- src/Symfony/Component/Debug/ErrorHandler.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index 7e8bbc55421c2..d0566ae18ea7b 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -125,6 +125,9 @@ function ($row) { if (!class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) { require __DIR__.'/Exception/ContextErrorException.php'; } + if (!class_exists('Symfony\Component\Debug\Exception\FlattenException')) { + require __DIR__.'/Exception/FlattenException.php'; + } if (PHP_VERSION_ID < 50400 && isset($context['GLOBALS']) && is_array($context)) { unset($context['GLOBALS']); From f308f521a654900de2f8e35ad0d9c39f2dc49167 Mon Sep 17 00:00:00 2001 From: umpirsky Date: Tue, 29 Apr 2014 17:14:35 +0200 Subject: [PATCH 1012/1305] Fixed issue #5427 --- src/Symfony/Component/Translation/Loader/PoFileLoader.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Translation/Loader/PoFileLoader.php b/src/Symfony/Component/Translation/Loader/PoFileLoader.php index 73f7f02364152..8ba96680aa544 100644 --- a/src/Symfony/Component/Translation/Loader/PoFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/PoFileLoader.php @@ -157,7 +157,7 @@ private function parse($resource) private function addMessage(array &$messages, array $item) { if (is_array($item['translated'])) { - $messages[$item['ids']['singular']] = stripslashes($item['translated'][0]); + $messages[$item['ids']['singular']] = stripcslashes($item['translated'][0]); if (isset($item['ids']['plural'])) { $plurals = $item['translated']; // PO are by definition indexed so sort by index. @@ -172,7 +172,7 @@ private function addMessage(array &$messages, array $item) $messages[$item['ids']['plural']] = stripcslashes(implode('|', $plurals)); } } elseif (!empty($item['ids']['singular'])) { - $messages[$item['ids']['singular']] = stripslashes($item['translated']); + $messages[$item['ids']['singular']] = stripcslashes($item['translated']); } } } From e93cbd773562f40dc527f1edd973c73b8b82800c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 28 Apr 2014 19:51:17 +0200 Subject: [PATCH 1013/1305] changed travis to run on the nightly builds of HHVM until everything gets stable --- .travis.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6ec8f1434bd4e..2523c2cc9614c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,21 +6,21 @@ php: - 5.4 - 5.5 - 5.6 - - hhvm + - hhvm-nightly matrix: allow_failures: - - php: hhvm + - php: hhvm-nightly services: mongodb before_script: - travis_retry sudo apt-get install parallel - - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini; fi;' - - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ] && [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' + - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then echo "" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini; fi;' + - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' + - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ] && [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' + - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' + - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - sudo locale-gen fr_FR.UTF-8 && sudo update-locale - COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev install From 7b425d229d6f2a215fbafb2b22fb3e8513fcce80 Mon Sep 17 00:00:00 2001 From: Tugdual Saunier Date: Wed, 30 Apr 2014 09:30:54 +0200 Subject: [PATCH 1014/1305] [WebProfilerBundle] Added test case for #10806 --- .../Controller/ProfilerControllerTest.php | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php new file mode 100644 index 0000000000000..de8a952fe937d --- /dev/null +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\WebProfilerBundle\Tests\Controller; + +use Symfony\Bundle\FrameworkBundle\Tests\TestCase; +use Symfony\Bundle\WebProfilerBundle\Controller\ProfilerController; +use Symfony\Component\HttpFoundation\Request; + +class ProfilerControllerTest extends TestCase +{ + /** + * @dataProvider getEmptyTokenCases + */ + public function testEmptyToken($token) + { + $urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface'); + $twig = $this->getMock('Twig_Environment'); + $profiler = $this + ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') + ->disableOriginalConstructor() + ->getMock(); + + $controller = new ProfilerController($urlGenerator, $profiler, $twig, array()); + + $response = $controller->toolbarAction(Request::create('/_wdt/empty'), $token); + $this->assertEquals(200, $response->getStatusCode()); + } + + public function getEmptyTokenCases() + { + return array( + array(null), + // "empty" is also a valid empty token case, see https://github.com/symfony/symfony/issues/10806 + array('empty'), + ); + } +} From 5b91e70777c2e3bb72970f0f7b8e217b62074196 Mon Sep 17 00:00:00 2001 From: Tugdual Saunier Date: Wed, 30 Apr 2014 09:32:22 +0200 Subject: [PATCH 1015/1305] [WebProfilerBundle] fixed profiler homepage, fixed #10806 --- .../Bundle/WebProfilerBundle/Controller/ProfilerController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php index cd3e17c7f5c93..a106feae990f7 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -232,7 +232,7 @@ public function toolbarAction(Request $request, $token) $session->getFlashBag()->setAll($session->getFlashBag()->peekAll()); } - if (null === $token) { + if ('empty' === $token || null === $token) { return new Response('', 200, array('Content-Type' => 'text/html')); } From 16dd0e5dda25edd50e2a1a83ac70c03fb8fee673 Mon Sep 17 00:00:00 2001 From: Tugdual Saunier Date: Wed, 30 Apr 2014 09:45:11 +0200 Subject: [PATCH 1016/1305] [WebProfilerBundle] added test case for #10773 --- .../Controller/ProfilerControllerTest.php | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php index de8a952fe937d..bff1919aa9b1a 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php @@ -13,6 +13,7 @@ use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Bundle\WebProfilerBundle\Controller\ProfilerController; +use Symfony\Component\HttpKernel\Profiler\Profile; use Symfony\Component\HttpFoundation\Request; class ProfilerControllerTest extends TestCase @@ -43,4 +44,34 @@ public function getEmptyTokenCases() array('empty'), ); } + + public function testReturns404onTokenNotFound() + { + $urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface'); + $twig = $this->getMock('Twig_Environment'); + $profiler = $this + ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') + ->disableOriginalConstructor() + ->getMock(); + + $controller = new ProfilerController($urlGenerator, $profiler, $twig, array()); + + $profiler + ->expects($this->exactly(2)) + ->method('loadProfile') + ->will($this->returnCallback(function ($token) { + if ('found' == $token) { + return new Profile($token); + } + + return; + })) + ; + + $response = $controller->toolbarAction(Request::create('/_wdt/found'), 'found'); + $this->assertEquals(200, $response->getStatusCode()); + + $response = $controller->toolbarAction(Request::create('/_wdt/notFound'), 'notFound'); + $this->assertEquals(404, $response->getStatusCode()); + } } From a94b4e0ae2446a010175185cda9b0febec0fd99c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 30 Apr 2014 09:15:56 +0200 Subject: [PATCH 1017/1305] [Validator] fixed wrong test --- .../Tests/Mapping/Loader/StaticMethodLoaderTest.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/StaticMethodLoaderTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/StaticMethodLoaderTest.php index f90310cd26875..80dac2d8661fc 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/StaticMethodLoaderTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/StaticMethodLoaderTest.php @@ -79,10 +79,16 @@ public function testLoadClassMetadataInAbstractClasses() public function testLoadClassMetadataIgnoresAbstractMethods() { $loader = new StaticMethodLoader('loadMetadata'); + $caught = false; try { - include __DIR__ . '/AbstractMethodStaticLoader.php'; - $this->fail('AbstractMethodStaticLoader should produce a strict standard error.'); + include __DIR__.'/AbstractMethodStaticLoader.php'; } catch (\Exception $e) { + // catching the PHP notice that is converted to an exception by PHPUnit + $caught = true; + } + + if (!$caught) { + $this->fail('AbstractMethodStaticLoader should produce a strict standard error.'); } $metadata = new ClassMetadata(__NAMESPACE__.'\AbstractMethodStaticLoader'); From c7befd53805d2f7534928d16e47636cbf4953c79 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Wed, 30 Apr 2014 14:05:40 +0200 Subject: [PATCH 1018/1305] Update PHPUnit before run --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2523c2cc9614c..ca4c19d38177a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,7 @@ before_script: - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - sudo locale-gen fr_FR.UTF-8 && sudo update-locale - COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev install + - wget https://phar.phpunit.de/phpunit.phar && rm `which phpunit` && sudo cp phpunit.phar /usr/local/bin/phpunit && sudo chmod +x /usr/local/bin/phpunit script: - ls -d src/Symfony/*/* | parallel --gnu --keep-order 'echo "Running {} tests"; phpunit --exclude-group tty,benchmark {};' || exit 1 From 32e5f6727a88489647f331b7042ae0c94e270dc8 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Wed, 30 Apr 2014 11:57:12 +0200 Subject: [PATCH 1019/1305] [DependencyInjection] Fix travis unit tests --- .../DependencyInjection/Tests/Fixtures/xml/services8.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml index c5fa5fb52d151..b17e50043cd1b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml @@ -1,4 +1,4 @@ - + Date: Thu, 1 May 2014 19:10:47 +0100 Subject: [PATCH 1020/1305] [TwigBridge][Transchoice] set %count% from the current context. --- src/Symfony/Bridge/Twig/Node/TransNode.php | 10 +++++++--- .../Twig/Tests/Extension/TranslationExtensionTest.php | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Node/TransNode.php b/src/Symfony/Bridge/Twig/Node/TransNode.php index 2409090699b7e..d459290b6fa41 100644 --- a/src/Symfony/Bridge/Twig/Node/TransNode.php +++ b/src/Symfony/Bridge/Twig/Node/TransNode.php @@ -98,9 +98,13 @@ protected function compileString(\Twig_NodeInterface $body, \Twig_Node_Expressio foreach ($matches[1] as $var) { $key = new \Twig_Node_Expression_Constant('%'.$var.'%', $body->getLine()); if (!$vars->hasElement($key)) { - $varExpr = new \Twig_Node_Expression_Name($var, $body->getLine()); - $varExpr->setAttribute('ignore_strict_check', $ignoreStrictCheck); - $vars->addElement($varExpr, $key); + if ('count' === $var) { + $vars->addElement($this->getNode('count'), $key); + } else { + $varExpr = new \Twig_Node_Expression_Name($var, $body->getLine()); + $varExpr->setAttribute('ignore_strict_check', $ignoreStrictCheck); + $vars->addElement($varExpr, $key); + } } } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php index 524b86bc62e9b..11c2d5ad7970a 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php @@ -110,6 +110,8 @@ public function getTransTests() 'There is 5 apples (Symfony2)', array('count' => 5)), array('{% transchoice count into "fr"%}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}', 'There is no apples', array('count' => 0)), + array('{% transchoice 5 into "fr"%}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}', + 'There is 5 apples'), // trans filter array('{{ "Hello"|trans }}', 'Hello'), From f3b0ef1a6f74725f30c39553d17d0dbc7cc25ddc Mon Sep 17 00:00:00 2001 From: Hugo Hamon Date: Fri, 2 May 2014 00:38:16 +0200 Subject: [PATCH 1021/1305] [Finder] fixed typehint of the Finder::addAdapter() method --- src/Symfony/Component/Finder/Finder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Finder/Finder.php b/src/Symfony/Component/Finder/Finder.php index e945fab13eb9e..db4d8517405df 100644 --- a/src/Symfony/Component/Finder/Finder.php +++ b/src/Symfony/Component/Finder/Finder.php @@ -94,7 +94,7 @@ public static function create() * * @return Finder The current Finder instance */ - public function addAdapter(Adapter\AdapterInterface $adapter, $priority = 0) + public function addAdapter(AdapterInterface $adapter, $priority = 0) { $this->adapters[$adapter->getName()] = array( 'adapter' => $adapter, From 93544aadfa4021ffb3452759a7fa497e5718b136 Mon Sep 17 00:00:00 2001 From: n-aleha Date: Fri, 2 May 2014 22:42:57 +0000 Subject: [PATCH 1022/1305] [DependencyInjection] Fix parameter description in ConfigurationExtensionInterface | Q | A | ------------- | --- | Fixed tickets | #10845 | License | MIT This fixes the description of parameter `array $config` in file ConfigurationExtensionInterface.php by removing the extra `$config`. --- .../Extension/ConfigurationExtensionInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Extension/ConfigurationExtensionInterface.php b/src/Symfony/Component/DependencyInjection/Extension/ConfigurationExtensionInterface.php index 6fcd9018dc761..51bff080124e2 100644 --- a/src/Symfony/Component/DependencyInjection/Extension/ConfigurationExtensionInterface.php +++ b/src/Symfony/Component/DependencyInjection/Extension/ConfigurationExtensionInterface.php @@ -24,7 +24,7 @@ interface ConfigurationExtensionInterface /** * Returns extension configuration * - * @param array $config $config An array of configuration values + * @param array $config An array of configuration values * @param ContainerBuilder $container A ContainerBuilder instance * * @return ConfigurationInterface|null The configuration or null From 239b738e983e4a972212449e756cc1bd03333006 Mon Sep 17 00:00:00 2001 From: Wouter J Date: Mon, 5 May 2014 19:22:30 +0200 Subject: [PATCH 1023/1305] Added more IDE links --- .../FrameworkBundle/DependencyInjection/FrameworkExtension.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 0c22c27e86e14..1a79e8651d3a8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -359,6 +359,8 @@ private function registerTemplatingConfiguration(array $config, $ide, ContainerB $links = array( 'textmate' => 'txmt://open?url=file://%%f&line=%%l', 'macvim' => 'mvim://open?url=file://%%f&line=%%l', + 'emacs' => 'emacs://open?url=file://%file&line=%line', + 'sublime' => 'subl://open?url=file://%file&line=%line', ); $container->setParameter('templating.helper.code.file_link_format', isset($links[$ide]) ? $links[$ide] : $ide); From b0bc83d2ac9f7a9b97c95af6e3bc4d543543b4bf Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Thu, 8 May 2014 17:33:56 +0200 Subject: [PATCH 1024/1305] [Form] Fixed TrimListenerTest as of PHP 5.5 --- .../Core/EventListener/TrimListenerTest.php | 53 +++++++++++++++---- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php index 4e36893380bbd..358620b9c469a 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php @@ -48,32 +48,65 @@ public function testTrimSkipNonStrings() } /** - * @dataProvider codePointProvider + * @dataProvider spaceProvider */ - public function testTrimUtf8($chars) + public function testTrimUtf8Separators($hex) { if (!function_exists('mb_check_encoding')) { $this->markTestSkipped('The "mb_check_encoding" function is not available'); } - $data = mb_convert_encoding(pack('H*', implode('', $chars)), 'UTF-8', 'UCS-2BE'); - $data = $data."ab\ncd".$data; + // Convert hexadecimal representation into binary + // H: hex string, high nibble first (UCS-2BE) + // *: repeat until end of string + $binary = pack('H*', $hex); + + // Convert UCS-2BE to UTF-8 + $symbol = mb_convert_encoding($binary, 'UTF-8', 'UCS-2BE'); + $symbol = $symbol."ab\ncd".$symbol; $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $event = new FormEvent($form, $data); + $event = new FormEvent($form, $symbol); $filter = new TrimListener(); $filter->preSubmit($event); - $this->assertSame("ab\ncd", $event->getData(), 'TrimListener should trim character(s): '.implode(', ', $chars)); + $this->assertSame("ab\ncd", $event->getData()); } - public function codePointProvider() + public function spaceProvider() { return array( - 'General category: Separator' => array(array('0020', '00A0', '1680', '180E', '2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '200A', '2028', '2029', '202F', '205F', '3000')), - 'General category: Other, control' => array(array('0009', '000A', '000B', '000C', '000D', '0085')), - //'General category: Other, format. ZERO WIDTH SPACE' => array(array('200B')), + // separators + array('0020'), + array('00A0'), + array('1680'), +// array('180E'), + array('2000'), + array('2001'), + array('2002'), + array('2003'), + array('2004'), + array('2005'), + array('2006'), + array('2007'), + array('2008'), + array('2009'), + array('200A'), + array('2028'), + array('2029'), + array('202F'), + array('205F'), + array('3000'), + // controls + array('0009'), + array('000A'), + array('000B'), + array('000C'), + array('000D'), + array('0085'), + // zero width space +// array('200B'), ); } } From a605a3d925a0f21f88cce540bd4405bf92e89ee9 Mon Sep 17 00:00:00 2001 From: Arturs Vonda Date: Wed, 7 May 2014 11:42:46 +0300 Subject: [PATCH 1025/1305] [Security] Add check for supported attributes in AclVoter --- .../Component/Security/Acl/Voter/AclVoter.php | 6 +++- .../Security/Tests/Acl/Voter/AclVoterTest.php | 31 +++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Security/Acl/Voter/AclVoter.php b/src/Symfony/Component/Security/Acl/Voter/AclVoter.php index d401ef3beda2d..b21b1e675bb6d 100644 --- a/src/Symfony/Component/Security/Acl/Voter/AclVoter.php +++ b/src/Symfony/Component/Security/Acl/Voter/AclVoter.php @@ -48,12 +48,16 @@ public function __construct(AclProviderInterface $aclProvider, ObjectIdentityRet public function supportsAttribute($attribute) { - return $this->permissionMap->contains($attribute); + return is_string($attribute) && $this->permissionMap->contains($attribute); } public function vote(TokenInterface $token, $object, array $attributes) { foreach ($attributes as $attribute) { + if (!$this->supportsAttribute($attribute)) { + continue; + } + if (null === $masks = $this->permissionMap->getMasks($attribute, $object)) { continue; } diff --git a/src/Symfony/Component/Security/Tests/Acl/Voter/AclVoterTest.php b/src/Symfony/Component/Security/Tests/Acl/Voter/AclVoterTest.php index 2474515b5c5a2..98e5ab9c55e11 100644 --- a/src/Symfony/Component/Security/Tests/Acl/Voter/AclVoterTest.php +++ b/src/Symfony/Component/Security/Tests/Acl/Voter/AclVoterTest.php @@ -27,7 +27,7 @@ class AclVoterTest extends \PHPUnit_Framework_TestCase */ public function testSupportsAttribute($attribute, $supported) { - list($voter,, $permissionMap,,) = $this->getVoter(); + list($voter,, $permissionMap,,) = $this->getVoter(true, false); $permissionMap ->expects($this->once()) @@ -39,6 +39,16 @@ public function testSupportsAttribute($attribute, $supported) $this->assertSame($supported, $voter->supportsAttribute($attribute)); } + /** + * @dataProvider getSupportsAttributeNonStringTests + */ + public function testSupportsAttributeNonString($attribute) + { + list($voter,,,,,) = $this->getVoter(true, false); + + $this->assertFalse($voter->supportsAttribute($attribute)); + } + public function getSupportsAttributeTests() { return array( @@ -47,6 +57,16 @@ public function getSupportsAttributeTests() ); } + public function getSupportsAttributeNonStringTests() + { + return array( + array(new \stdClass()), + array(1), + array(true), + array(array()), + ); + } + /** * @dataProvider getSupportsClassTests */ @@ -387,13 +407,20 @@ protected function getToken() return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); } - protected function getVoter($allowIfObjectIdentityUnavailable = true) + protected function getVoter($allowIfObjectIdentityUnavailable = true, $alwaysContains = true) { $provider = $this->getMock('Symfony\Component\Security\Acl\Model\AclProviderInterface'); $permissionMap = $this->getMock('Symfony\Component\Security\Acl\Permission\PermissionMapInterface'); $oidStrategy = $this->getMock('Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface'); $sidStrategy = $this->getMock('Symfony\Component\Security\Acl\Model\SecurityIdentityRetrievalStrategyInterface'); + if ($alwaysContains) { + $permissionMap + ->expects($this->any()) + ->method('contains') + ->will($this->returnValue(true)); + } + return array( new AclVoter($provider, $oidStrategy, $sidStrategy, $permissionMap, null, $allowIfObjectIdentityUnavailable), $provider, From a4b805dbf2b7d1cab0e1cde09f60eed496468c28 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 12 May 2014 10:37:25 +0200 Subject: [PATCH 1026/1305] Lower mbstring dep, remove it for Yaml and CssSelector components --- .../Tests/Helper/FormatterHelperTest.php | 2 +- .../Parser/Tokenizer/TokenizerEscaping.php | 16 ++++-- .../NumberToLocalizedStringTransformer.php | 16 ++---- ...NumberToLocalizedStringTransformerTest.php | 8 +-- .../Core/EventListener/TrimListenerTest.php | 4 +- .../Tests/Dumper/IcuResFileDumperTest.php | 2 +- src/Symfony/Component/Yaml/Parser.php | 2 +- .../Component/Yaml/Tests/ParserTest.php | 10 +--- src/Symfony/Component/Yaml/Unescaper.php | 55 +++++++++---------- 9 files changed, 51 insertions(+), 64 deletions(-) diff --git a/src/Symfony/Component/Console/Tests/Helper/FormatterHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/FormatterHelperTest.php index 87a45e1d44a13..a0105761ce8d4 100644 --- a/src/Symfony/Component/Console/Tests/Helper/FormatterHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/FormatterHelperTest.php @@ -54,7 +54,7 @@ public function testFormatBlock() public function testFormatBlockWithDiacriticLetters() { - if (!extension_loaded('mbstring')) { + if (!function_exists('mb_detect_encoding')) { $this->markTestSkipped('This test requires mbstring to work.'); } diff --git a/src/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerEscaping.php b/src/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerEscaping.php index c90fc1044d3a9..921fc393a9231 100644 --- a/src/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerEscaping.php +++ b/src/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerEscaping.php @@ -65,14 +65,18 @@ public function escapeUnicodeAndNewLine($value) */ private function replaceUnicodeSequences($value) { - return preg_replace_callback($this->patterns->getUnicodeEscapePattern(), function (array $match) { - $code = $match[1]; + return preg_replace_callback($this->patterns->getUnicodeEscapePattern(), function ($match) { + $c = hexdec($match[1]); - if (bin2hex($code) > 0xFFFD) { - $code = '\\FFFD'; + if (0x80 > $c %= 0x200000) { + return chr($c); + } + if (0x800 > $c) { + return chr(0xC0 | $c>>6).chr(0x80 | $c & 0x3F); + } + if (0x10000 > $c) { + return chr(0xE0 | $c>>12).chr(0x80 | $c>>6 & 0x3F).chr(0x80 | $c & 0x3F); } - - return mb_convert_encoding(pack('H*', $code), 'UTF-8', 'UCS-2BE'); }, $value); } } diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php index bb8da2fc754b7..c3a7609a5f496 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php @@ -133,25 +133,19 @@ public function reverseTransform($value) } if (function_exists('mb_detect_encoding') && false !== $encoding = mb_detect_encoding($value)) { - $strlen = function ($string) use ($encoding) { - return mb_strlen($string, $encoding); - }; - $substr = function ($string, $offset, $length) use ($encoding) { - return mb_substr($string, $offset, $length, $encoding); - }; + $length = mb_strlen($value, $encoding); + $remainder = mb_substr($value, $position, $length, $encoding); } else { - $strlen = 'strlen'; - $substr = 'substr'; + $length = strlen($value); + $remainder = substr($value, $position, $length); } - $length = $strlen($value); - // After parsing, position holds the index of the character where the // parsing stopped if ($position < $length) { // Check if there are unrecognized characters at the end of the // number (excluding whitespace characters) - $remainder = trim($substr($value, $position, $length), " \t\n\r\0\x0b\xc2\xa0"); + $remainder = trim($remainder, " \t\n\r\0\x0b\xc2\xa0"); if ('' !== $remainder) { throw new TransformationFailedException( diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php index c58e3f60e7475..971dd0a738d6c 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php @@ -119,7 +119,7 @@ public function testReverseTransformWithGrouping($to, $from, $locale) // https://github.com/symfony/symfony/issues/7609 public function testReverseTransformWithGroupingAndFixedSpaces() { - if (!extension_loaded('mbstring')) { + if (!function_exists('mb_detect_encoding')) { $this->markTestSkipped('The "mbstring" extension is required for this test.'); } @@ -335,7 +335,7 @@ public function testReverseTransformDisallowsCenteredExtraCharacters() */ public function testReverseTransformDisallowsCenteredExtraCharactersMultibyte() { - if (!extension_loaded('mbstring')) { + if (!function_exists('mb_detect_encoding')) { $this->markTestSkipped('The "mbstring" extension is required for this test.'); } @@ -352,7 +352,7 @@ public function testReverseTransformDisallowsCenteredExtraCharactersMultibyte() */ public function testReverseTransformIgnoresTrailingSpacesInExceptionMessage() { - if (!extension_loaded('mbstring')) { + if (!function_exists('mb_detect_encoding')) { $this->markTestSkipped('The "mbstring" extension is required for this test.'); } @@ -380,7 +380,7 @@ public function testReverseTransformDisallowsTrailingExtraCharacters() */ public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte() { - if (!extension_loaded('mbstring')) { + if (!function_exists('mb_detect_encoding')) { $this->markTestSkipped('The "mbstring" extension is required for this test.'); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php index 358620b9c469a..606f6a2b05b64 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php @@ -52,8 +52,8 @@ public function testTrimSkipNonStrings() */ public function testTrimUtf8Separators($hex) { - if (!function_exists('mb_check_encoding')) { - $this->markTestSkipped('The "mb_check_encoding" function is not available'); + if (!function_exists('mb_convert_encoding')) { + $this->markTestSkipped('The "mb_convert_encoding" function is not available'); } // Convert hexadecimal representation into binary diff --git a/src/Symfony/Component/Translation/Tests/Dumper/IcuResFileDumperTest.php b/src/Symfony/Component/Translation/Tests/Dumper/IcuResFileDumperTest.php index 7d969ce27290f..cb30c6661ca73 100644 --- a/src/Symfony/Component/Translation/Tests/Dumper/IcuResFileDumperTest.php +++ b/src/Symfony/Component/Translation/Tests/Dumper/IcuResFileDumperTest.php @@ -18,7 +18,7 @@ class IcuResFileDumperTest extends \PHPUnit_Framework_TestCase { public function testDump() { - if (!extension_loaded('mbstring')) { + if (!function_exists('mb_convert_encoding')) { $this->markTestSkipped('This test requires mbstring to work.'); } diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index d4e0a9fa66b6b..9bde67b57b548 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -55,7 +55,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = $this->currentLine = ''; $this->lines = explode("\n", $this->cleanup($value)); - if (function_exists('mb_detect_encoding') && false === mb_detect_encoding($value, 'UTF-8', true)) { + if (!preg_match('//u', $value)) { throw new ParseException('The YAML value does not appear to be valid UTF-8.'); } diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 07e6222d7e078..2335efc55990f 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -33,12 +33,6 @@ protected function tearDown() */ public function testSpecifications($file, $expected, $yaml, $comment) { - if ('escapedCharacters' == $file) { - if (!function_exists('iconv') && !function_exists('mb_convert_encoding')) { - $this->markTestSkipped('The iconv and mbstring extensions are not available.'); - } - } - $this->assertEquals($expected, var_export($this->parser->parse($yaml), true), $comment); } @@ -446,8 +440,8 @@ public function testObjectsSupportDisabledWithExceptions() public function testNonUtf8Exception() { - if (!function_exists('mb_detect_encoding') || !function_exists('iconv')) { - $this->markTestSkipped('Exceptions for non-utf8 charsets require the mb_detect_encoding() and iconv() functions.'); + if (!function_exists('iconv')) { + $this->markTestSkipped('Exceptions for non-utf8 charsets require the iconv() function.'); return; } diff --git a/src/Symfony/Component/Yaml/Unescaper.php b/src/Symfony/Component/Yaml/Unescaper.php index 1b8eeed57a94a..b47d4a59285b9 100644 --- a/src/Symfony/Component/Yaml/Unescaper.php +++ b/src/Symfony/Component/Yaml/Unescaper.php @@ -21,6 +21,7 @@ class Unescaper { // Parser and Inline assume UTF-8 encoding, so escaped Unicode characters // must be converted to that encoding. + // @deprecated since 2.5, to be removed in 3.0 const ENCODING = 'UTF-8'; // Regex fragment that matches an escaped character in a double quoted @@ -80,13 +81,13 @@ public function unescapeCharacter($value) case 'n': return "\n"; case 'v': - return "\xb"; + return "\xB"; case 'f': - return "\xc"; + return "\xC"; case 'r': - return "\xd"; + return "\r"; case 'e': - return "\x1b"; + return "\x1B"; case ' ': return ' '; case '"': @@ -97,50 +98,44 @@ public function unescapeCharacter($value) return '\\'; case 'N': // U+0085 NEXT LINE - return $this->convertEncoding("\x00\x85", self::ENCODING, 'UCS-2BE'); + return "\xC2\x85"; case '_': // U+00A0 NO-BREAK SPACE - return $this->convertEncoding("\x00\xA0", self::ENCODING, 'UCS-2BE'); + return "\xC2\xA0"; case 'L': // U+2028 LINE SEPARATOR - return $this->convertEncoding("\x20\x28", self::ENCODING, 'UCS-2BE'); + return "\xE2\x80\xA8"; case 'P': // U+2029 PARAGRAPH SEPARATOR - return $this->convertEncoding("\x20\x29", self::ENCODING, 'UCS-2BE'); + return "\xE2\x80\xA9"; case 'x': - $char = pack('n', hexdec(substr($value, 2, 2))); - - return $this->convertEncoding($char, self::ENCODING, 'UCS-2BE'); + return self::utf8chr(hexdec(substr($value, 2, 2))); case 'u': - $char = pack('n', hexdec(substr($value, 2, 4))); - - return $this->convertEncoding($char, self::ENCODING, 'UCS-2BE'); + return self::utf8chr(hexdec(substr($value, 2, 4))); case 'U': - $char = pack('N', hexdec(substr($value, 2, 8))); - - return $this->convertEncoding($char, self::ENCODING, 'UCS-4BE'); + return self::utf8chr(hexdec(substr($value, 2, 8))); } } /** - * Convert a string from one encoding to another. + * Get the UTF-8 character for the given code point. * - * @param string $value The string to convert - * @param string $to The input encoding - * @param string $from The output encoding + * @param int $c The unicode code point * - * @return string The string with the new encoding - * - * @throws \RuntimeException if no suitable encoding function is found (iconv or mbstring) + * @return string The corresponding UTF-8 character */ - private function convertEncoding($value, $to, $from) + private static function utf8chr($c) { - if (function_exists('mb_convert_encoding')) { - return mb_convert_encoding($value, $to, $from); - } elseif (function_exists('iconv')) { - return iconv($from, $to, $value); + if (0x80 > $c %= 0x200000) { + return chr($c); + } + if (0x800 > $c) { + return chr(0xC0 | $c>>6).chr(0x80 | $c & 0x3F); + } + if (0x10000 > $c) { + return chr(0xE0 | $c>>12).chr(0x80 | $c>>6 & 0x3F).chr(0x80 | $c & 0x3F); } - throw new \RuntimeException('No suitable convert encoding function (install the iconv or mbstring extension).'); + return chr(0xF0 | $c>>18).chr(0x80 | $c>>12 & 0x3F).chr(0x80 | $c>>6 & 0x3F).chr(0x80 | $c & 0x3F); } } From a52f41d4142e882ba628832d9a2666b3e62d6e65 Mon Sep 17 00:00:00 2001 From: Daisuke Ohata Date: Tue, 15 Apr 2014 19:04:31 +0900 Subject: [PATCH 1027/1305] [Console]Improve formatter for double-width character --- src/Symfony/Component/Console/Application.php | 91 +++++++++++++------ .../Component/Console/Helper/Helper.php | 6 +- .../Console/Tests/ApplicationTest.php | 27 ++++++ ...plication_renderexception_doublewidth1.txt | 11 +++ ..._renderexception_doublewidth1decorated.txt | 11 +++ ...plication_renderexception_doublewidth2.txt | 12 +++ .../Tests/Helper/FormatterHelperTest.php | 15 +++ 7 files changed, 143 insertions(+), 30 deletions(-) create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth1.txt create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth1decorated.txt create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth2.txt diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 0753e19ed903f..2833bd23def6b 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -99,7 +99,7 @@ public function setDispatcher(EventDispatcherInterface $dispatcher) * @param InputInterface $input An Input instance * @param OutputInterface $output An Output instance * - * @return integer 0 if everything went fine, or an error code + * @return int 0 if everything went fine, or an error code * * @throws \Exception When doRun returns Exception * @@ -159,7 +159,7 @@ public function run(InputInterface $input = null, OutputInterface $output = null * @param InputInterface $input An Input instance * @param OutputInterface $output An Output instance * - * @return integer 0 if everything went fine, or an error code + * @return int 0 if everything went fine, or an error code */ public function doRun(InputInterface $input, OutputInterface $output) { @@ -270,7 +270,7 @@ public function getHelp() /** * Sets whether to catch exceptions or not during commands execution. * - * @param bool $boolean Whether to catch exceptions or not during commands execution + * @param bool $boolean Whether to catch exceptions or not during commands execution * * @api */ @@ -282,7 +282,7 @@ public function setCatchExceptions($boolean) /** * Sets whether to automatically exit after a command execution or not. * - * @param bool $boolean Whether to automatically exit after a command execution or not + * @param bool $boolean Whether to automatically exit after a command execution or not * * @api */ @@ -449,7 +449,7 @@ public function get($name) * * @param string $name The command name or alias * - * @return Boolean true if the command exists, false otherwise + * @return bool true if the command exists, false otherwise * * @api */ @@ -674,8 +674,8 @@ public static function getAbbreviations($names) /** * Returns a text representation of the Application. * - * @param string $namespace An optional namespace name - * @param bool $raw Whether to return raw command list + * @param string $namespace An optional namespace name + * @param bool $raw Whether to return raw command list * * @return string A string representing the Application * @@ -691,8 +691,8 @@ public function asText($namespace = null, $raw = false) /** * Returns an XML representation of the Application. * - * @param string $namespace An optional namespace name - * @param bool $asDom Whether to return a DOM or an XML string + * @param string $namespace An optional namespace name + * @param bool $asDom Whether to return a DOM or an XML string * * @return string|\DOMDocument An XML string representing the Application * @@ -708,34 +708,22 @@ public function asXml($namespace = null, $asDom = false) /** * Renders a caught exception. * - * @param \Exception $e An exception instance + * @param \Exception $e An exception instance * @param OutputInterface $output An OutputInterface instance */ public function renderException($e, $output) { - $strlen = function ($string) { - if (!function_exists('mb_strlen')) { - return strlen($string); - } - - if (false === $encoding = mb_detect_encoding($string)) { - return strlen($string); - } - - return mb_strlen($string, $encoding); - }; - do { $title = sprintf(' [%s] ', get_class($e)); - $len = $strlen($title); + $len = $this->stringWidth($title); // HHVM only accepts 32 bits integer in str_split, even when PHP_INT_MAX is a 64 bit integer: https://github.com/facebook/hhvm/issues/1327 $width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 1 : (defined('HHVM_VERSION') ? 1 << 31 : PHP_INT_MAX); $formatter = $output->getFormatter(); $lines = array(); foreach (preg_split('/\r?\n/', $e->getMessage()) as $line) { - foreach (str_split($line, $width - 4) as $line) { + foreach ($this->splitStringByWidth($line, $width - 4) as $line) { // pre-format lines to get the right string length - $lineLength = $strlen(preg_replace('/\[[^m]*m/', '', $formatter->format($line))) + 4; + $lineLength = $this->stringWidth(preg_replace('/\[[^m]*m/', '', $formatter->format($line))) + 4; $lines[] = array($line, $lineLength); $len = max($lineLength, $len); @@ -744,7 +732,7 @@ public function renderException($e, $output) $messages = array('', ''); $messages[] = $emptyLine = $formatter->format(sprintf('%s', str_repeat(' ', $len))); - $messages[] = $formatter->format(sprintf('%s%s', $title, str_repeat(' ', max(0, $len - $strlen($title))))); + $messages[] = $formatter->format(sprintf('%s%s', $title, str_repeat(' ', max(0, $len - $this->stringWidth($title))))); foreach ($lines as $line) { $messages[] = $formatter->format(sprintf(' %s %s', $line[0], str_repeat(' ', $len - $line[1]))); } @@ -890,7 +878,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output) * @param InputInterface $input An Input instance * @param OutputInterface $output An Output instance * - * @return integer 0 if everything went fine, or an error code + * @return int 0 if everything went fine, or an error code */ protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { @@ -1125,4 +1113,53 @@ private function findAlternatives($name, $collection, $abbrevs, $callback = null return array_keys($alternatives); } + + private function stringWidth($string) + { + if (!function_exists('mb_strwidth')) { + return strlen($string); + } + + if (false === $encoding = mb_detect_encoding($string)) { + return strlen($string); + } + + return mb_strwidth($string, $encoding); + } + + private function splitStringByWidth($string, $width) + { + // str_split is not suitable for multi-byte characters, we should use preg_split to get char array properly. + // additionally, array_slice() is not enough as some character has doubled width. + // we need a function to split string not by character count but by string width + + if (!function_exists('mb_strwidth')) { + return str_split($string, $width); + } + + if (false === $encoding = mb_detect_encoding($string)) { + return str_split($string, $width); + } + + $utf8String = mb_convert_encoding($string, 'utf8', $encoding); + $lines = array(); + $line = ''; + foreach (preg_split('//u', $utf8String) as $char) { + // test if $char could be appended to current line + if (mb_strwidth($line.$char) <= $width) { + $line .= $char; + continue; + } + // if not, push current line to array and make new line + $lines[] = str_pad($line, $width); + $line = $char; + } + if (strlen($line)) { + $lines[] = count($lines) ? str_pad($line, $width) : $line; + } + + mb_convert_variables($encoding, 'utf8', $lines); + + return $lines; + } } diff --git a/src/Symfony/Component/Console/Helper/Helper.php b/src/Symfony/Component/Console/Helper/Helper.php index 534b9f4319737..b2a8389fa0776 100644 --- a/src/Symfony/Component/Console/Helper/Helper.php +++ b/src/Symfony/Component/Console/Helper/Helper.php @@ -45,11 +45,11 @@ public function getHelperSet() * * @param string $string The string to check its length * - * @return integer The length of the string + * @return int The length of the string */ protected function strlen($string) { - if (!function_exists('mb_strlen')) { + if (!function_exists('mb_strwidth')) { return strlen($string); } @@ -57,6 +57,6 @@ protected function strlen($string) return strlen($string); } - return mb_strlen($string, $encoding); + return mb_strwidth($string, $encoding); } } diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index 10dcb309515ed..0965d24ad5743 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -469,6 +469,33 @@ public function testRenderException() $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception4.txt', $tester->getDisplay(true), '->renderException() wraps messages when they are bigger than the terminal'); } + public function testRenderExceptionWithDoubleWidthCharacters() + { + $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth')); + $application->setAutoExit(false); + $application->expects($this->any()) + ->method('getTerminalWidth') + ->will($this->returnValue(120)); + $application->register('foo')->setCode(function () {throw new \Exception('エラーメッセージ');}); + $tester = new ApplicationTester($application); + + $tester->run(array('command' => 'foo'), array('decorated' => false)); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception_doublewidth1.txt', $tester->getDisplay(true), '->renderException() renderes a pretty exceptions with previous exceptions'); + + $tester->run(array('command' => 'foo'), array('decorated' => true)); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception_doublewidth1decorated.txt', $tester->getDisplay(true), '->renderException() renderes a pretty exceptions with previous exceptions'); + + $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth')); + $application->setAutoExit(false); + $application->expects($this->any()) + ->method('getTerminalWidth') + ->will($this->returnValue(32)); + $application->register('foo')->setCode(function () {throw new \Exception('コマンドの実行中にエラーが発生しました。');}); + $tester = new ApplicationTester($application); + $tester->run(array('command' => 'foo'), array('decorated' => false)); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception_doublewidth2.txt', $tester->getDisplay(true), '->renderException() wraps messages when they are bigger than the terminal'); + } + public function testRun() { $application = new Application(); diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth1.txt b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth1.txt new file mode 100644 index 0000000000000..6a98660364219 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth1.txt @@ -0,0 +1,11 @@ + + + + [Exception] + エラーメッセージ + + + +foo + + diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth1decorated.txt b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth1decorated.txt new file mode 100644 index 0000000000000..c68a60f564df0 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth1decorated.txt @@ -0,0 +1,11 @@ + + +  + [Exception]  + エラーメッセージ  +  + + +foo + + diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth2.txt b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth2.txt new file mode 100644 index 0000000000000..545cd7b0b49f9 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth2.txt @@ -0,0 +1,12 @@ + + + + [Exception] + コマンドの実行中にエラーが + 発生しました。 + + + +foo + + diff --git a/src/Symfony/Component/Console/Tests/Helper/FormatterHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/FormatterHelperTest.php index 87a45e1d44a13..34d70d8fc2b2f 100644 --- a/src/Symfony/Component/Console/Tests/Helper/FormatterHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/FormatterHelperTest.php @@ -69,6 +69,21 @@ public function testFormatBlockWithDiacriticLetters() ); } + public function testFormatBlockWithDoubleWidthDiacriticLetters() + { + if (!extension_loaded('mbstring')) { + $this->markTestSkipped('This test requires mbstring to work.'); + } + $formatter = new FormatterHelper(); + $this->assertEquals( + ' '."\n" . + ' 表示するテキスト '."\n" . + ' ', + $formatter->formatBlock('表示するテキスト', 'error', true), + '::formatBlock() formats a message in a block' + ); + } + public function testFormatBlockLGEscaping() { $formatter = new FormatterHelper(); From ab1198f4da4aaab5afed543beaed6128341353e4 Mon Sep 17 00:00:00 2001 From: Geoffrey Brier Date: Fri, 2 May 2014 17:23:01 +0200 Subject: [PATCH 1028/1305] [DomCrawler] Fixed image input case sensitive --- src/Symfony/Component/DomCrawler/Crawler.php | 5 +++-- .../Component/DomCrawler/Field/ChoiceFormField.php | 4 ++-- .../Component/DomCrawler/Field/FileFormField.php | 2 +- .../Component/DomCrawler/Field/InputFormField.php | 4 ++-- src/Symfony/Component/DomCrawler/Form.php | 12 ++++++------ src/Symfony/Component/DomCrawler/Tests/FormTest.php | 7 +++++++ 6 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index a96d1db89abaf..770e4026b84d9 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -651,8 +651,9 @@ public function selectLink($value) */ public function selectButton($value) { - $xpath = sprintf('//input[((@type="submit" or @type="button") and contains(concat(\' \', normalize-space(string(@value)), \' \'), %s)) ', static::xpathLiteral(' '.$value.' ')). - sprintf('or (@type="image" and contains(concat(\' \', normalize-space(string(@alt)), \' \'), %s)) or @id="%s" or @name="%s"] ', static::xpathLiteral(' '.$value.' '), $value, $value). + $translate = 'translate(@type, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")'; + $xpath = sprintf('//input[((contains(%s, "submit") or contains(%s, "button")) and contains(concat(\' \', normalize-space(string(@value)), \' \'), %s)) ', $translate, $translate, static::xpathLiteral(' '.$value.' ')). + sprintf('or (contains(%s, "image") and contains(concat(\' \', normalize-space(string(@alt)), \' \'), %s)) or @id="%s" or @name="%s"] ', $translate, static::xpathLiteral(' '.$value.' '), $value, $value). sprintf('| //button[contains(concat(\' \', normalize-space(string(.)), \' \'), %s) or @id="%s" or @name="%s"]', static::xpathLiteral(' '.$value.' '), $value, $value); return $this->filterXPath($xpath); diff --git a/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php b/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php index 58a6bf0bed716..efdcf5b9228aa 100644 --- a/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php @@ -206,7 +206,7 @@ protected function initialize() throw new \LogicException(sprintf('A ChoiceFormField can only be created from an input or select tag (%s given).', $this->node->nodeName)); } - if ('input' == $this->node->nodeName && 'checkbox' != $this->node->getAttribute('type') && 'radio' != $this->node->getAttribute('type')) { + if ('input' == $this->node->nodeName && 'checkbox' != strtolower($this->node->getAttribute('type')) && 'radio' != strtolower($this->node->getAttribute('type'))) { throw new \LogicException(sprintf('A ChoiceFormField can only be created from an input tag with a type of checkbox or radio (given type is %s).', $this->node->getAttribute('type'))); } @@ -215,7 +215,7 @@ protected function initialize() $this->multiple = false; if ('input' == $this->node->nodeName) { - $this->type = $this->node->getAttribute('type'); + $this->type = strtolower($this->node->getAttribute('type')); $optionValue = $this->buildOptionValue($this->node); $this->options[] = $optionValue; diff --git a/src/Symfony/Component/DomCrawler/Field/FileFormField.php b/src/Symfony/Component/DomCrawler/Field/FileFormField.php index c65b5c9c4f18d..160ddc6e0d877 100644 --- a/src/Symfony/Component/DomCrawler/Field/FileFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/FileFormField.php @@ -103,7 +103,7 @@ protected function initialize() throw new \LogicException(sprintf('A FileFormField can only be created from an input tag (%s given).', $this->node->nodeName)); } - if ('file' != $this->node->getAttribute('type')) { + if ('file' != strtolower($this->node->getAttribute('type'))) { throw new \LogicException(sprintf('A FileFormField can only be created from an input tag with a type of file (given type is %s).', $this->node->getAttribute('type'))); } diff --git a/src/Symfony/Component/DomCrawler/Field/InputFormField.php b/src/Symfony/Component/DomCrawler/Field/InputFormField.php index d3d3957934d2d..00141d84c6c04 100644 --- a/src/Symfony/Component/DomCrawler/Field/InputFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/InputFormField.php @@ -34,11 +34,11 @@ protected function initialize() throw new \LogicException(sprintf('An InputFormField can only be created from an input or button tag (%s given).', $this->node->nodeName)); } - if ('checkbox' == $this->node->getAttribute('type')) { + if ('checkbox' == strtolower($this->node->getAttribute('type'))) { throw new \LogicException('Checkboxes should be instances of ChoiceFormField.'); } - if ('file' == $this->node->getAttribute('type')) { + if ('file' == strtolower($this->node->getAttribute('type'))) { throw new \LogicException('File inputs should be instances of FileFormField.'); } diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php index 2b9e43c701f28..a19cc79da7ff8 100644 --- a/src/Symfony/Component/DomCrawler/Form.php +++ b/src/Symfony/Component/DomCrawler/Form.php @@ -352,7 +352,7 @@ public function offsetUnset($name) protected function setNode(\DOMNode $node) { $this->button = $node; - if ('button' == $node->nodeName || ('input' == $node->nodeName && in_array($node->getAttribute('type'), array('submit', 'button', 'image')))) { + if ('button' == $node->nodeName || ('input' == $node->nodeName && in_array(strtolower($node->getAttribute('type')), array('submit', 'button', 'image')))) { if ($node->hasAttribute('form')) { // if the node has the HTML5-compliant 'form' attribute, use it $formId = $node->getAttribute('form'); @@ -394,7 +394,7 @@ private function initialize() // add submitted button if it has a valid name if ('form' !== $this->button->nodeName && $this->button->hasAttribute('name') && $this->button->getAttribute('name')) { - if ('input' == $this->button->nodeName && 'image' == $this->button->getAttribute('type')) { + if ('input' == $this->button->nodeName && 'image' == strtolower($this->button->getAttribute('type'))) { $name = $this->button->getAttribute('name'); $this->button->setAttribute('value', '0'); @@ -445,17 +445,17 @@ private function addField(\DOMNode $node) } $nodeName = $node->nodeName; - if ('select' == $nodeName || 'input' == $nodeName && 'checkbox' == $node->getAttribute('type')) { + if ('select' == $nodeName || 'input' == $nodeName && 'checkbox' == strtolower($node->getAttribute('type'))) { $this->set(new Field\ChoiceFormField($node)); - } elseif ('input' == $nodeName && 'radio' == $node->getAttribute('type')) { + } elseif ('input' == $nodeName && 'radio' == strtolower($node->getAttribute('type'))) { if ($this->has($node->getAttribute('name'))) { $this->get($node->getAttribute('name'))->addChoice($node); } else { $this->set(new Field\ChoiceFormField($node)); } - } elseif ('input' == $nodeName && 'file' == $node->getAttribute('type')) { + } elseif ('input' == $nodeName && 'file' == strtolower($node->getAttribute('type'))) { $this->set(new Field\FileFormField($node)); - } elseif ('input' == $nodeName && !in_array($node->getAttribute('type'), array('submit', 'button', 'image'))) { + } elseif ('input' == $nodeName && !in_array(strtolower($node->getAttribute('type')), array('submit', 'button', 'image'))) { $this->set(new Field\InputFormField($node)); } elseif ('textarea' == $nodeName) { $this->set(new Field\TextareaFormField($node)); diff --git a/src/Symfony/Component/DomCrawler/Tests/FormTest.php b/src/Symfony/Component/DomCrawler/Tests/FormTest.php index ecb7207c2e55d..1fbfbb983df59 100644 --- a/src/Symfony/Component/DomCrawler/Tests/FormTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/FormTest.php @@ -631,6 +631,13 @@ public function testSubmitWithoutAFormButton() $this->assertSame($nodes->item(0), $form->getFormNode(), '->getFormNode() returns the form node associated with this form'); } + public function testTypeAttributeIsCaseInsensitive() + { + $form = $this->createForm('
'); + $this->assertTrue($form->has('example.x'), '->has() returns true if the image input was correctly turned into an x and a y fields'); + $this->assertTrue($form->has('example.y'), '->has() returns true if the image input was correctly turned into an x and a y fields'); + } + /** * @expectedException \InvalidArgumentException */ From bc42dae162bcab809cfd817363c21a3159470d37 Mon Sep 17 00:00:00 2001 From: alquerci Date: Tue, 31 Dec 2013 17:23:37 +0100 Subject: [PATCH 1029/1305] Added test when TTL has expired --- .../Tests/HttpCache/HttpCacheTest.php | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php index 50a1de907da95..c54caf832e918 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php @@ -595,6 +595,89 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformation() $this->assertEquals('Hello World', $this->response->getContent()); } + public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAfterTtlWasExpired() + { + $this->setNextResponse(); + + $this->cacheConfig['default_ttl'] = 2; + $this->request('GET', '/'); + $this->assertHttpKernelIsCalled(); + $this->assertTraceContains('miss'); + $this->assertTraceContains('store'); + $this->assertEquals('Hello World', $this->response->getContent()); + $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); + + $this->cacheConfig['default_ttl'] = 2; + $this->request('GET', '/'); + $this->assertHttpKernelIsNotCalled(); + $this->assertEquals(200, $this->response->getStatusCode()); + $this->assertTraceContains('fresh'); + $this->assertTraceNotContains('store'); + $this->assertEquals('Hello World', $this->response->getContent()); + + sleep(4); + + $this->cacheConfig['default_ttl'] = 2; + $this->request('GET', '/'); + $this->assertHttpKernelIsCalled(); + $this->assertEquals(200, $this->response->getStatusCode()); + $this->assertTraceContains('stale'); + $this->assertTraceContains('invalid'); + $this->assertTraceContains('store'); + $this->assertEquals('Hello World', $this->response->getContent()); + + $this->cacheConfig['default_ttl'] = 2; + $this->request('GET', '/'); + $this->assertHttpKernelIsNotCalled(); + $this->assertEquals(200, $this->response->getStatusCode()); + $this->assertTraceContains('fresh'); + $this->assertTraceNotContains('store'); + $this->assertEquals('Hello World', $this->response->getContent()); + } + + public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAfterTtlWasExpiredWithStatus304() + { + $this->setNextResponse(); + + $this->cacheConfig['default_ttl'] = 2; + $this->request('GET', '/'); + $this->assertHttpKernelIsCalled(); + $this->assertTraceContains('miss'); + $this->assertTraceContains('store'); + $this->assertEquals('Hello World', $this->response->getContent()); + $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); + + $this->cacheConfig['default_ttl'] = 2; + $this->request('GET', '/'); + $this->assertHttpKernelIsNotCalled(); + $this->assertEquals(200, $this->response->getStatusCode()); + $this->assertTraceContains('fresh'); + $this->assertTraceNotContains('store'); + $this->assertEquals('Hello World', $this->response->getContent()); + + sleep(4); + + $this->setNextResponse(304); + + $this->cacheConfig['default_ttl'] = 2; + $this->request('GET', '/'); + $this->assertHttpKernelIsCalled(); + $this->assertEquals(200, $this->response->getStatusCode()); + $this->assertTraceContains('stale'); + $this->assertTraceContains('valid'); + $this->assertTraceContains('store'); + $this->assertTraceNotContains('miss'); + $this->assertEquals('Hello World', $this->response->getContent()); + + $this->cacheConfig['default_ttl'] = 2; + $this->request('GET', '/'); + $this->assertHttpKernelIsNotCalled(); + $this->assertEquals(200, $this->response->getStatusCode()); + $this->assertTraceContains('fresh'); + $this->assertTraceNotContains('store'); + $this->assertEquals('Hello World', $this->response->getContent()); + } + public function testDoesNotAssignDefaultTtlWhenResponseHasMustRevalidateDirective() { $this->setNextResponse(200, array('Cache-Control' => 'must-revalidate')); From e3983e8ec584311d6eced6a8547eae5a6113e8df Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 12 May 2014 17:25:47 +0200 Subject: [PATCH 1030/1305] [HttpKernel] fixed default TTL not applied under certain conditions --- .../HttpKernel/HttpCache/HttpCache.php | 12 +++--- .../Tests/HttpCache/HttpCacheTest.php | 38 ++++++++++++++----- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index 2bea9f58baf55..871b3a87fc900 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -428,12 +428,6 @@ protected function fetch(Request $request, $catch = false) $response = $this->forward($subRequest, $catch); - if ($this->isPrivateRequest($request) && !$response->headers->hasCacheControlDirective('public')) { - $response->setPrivate(true); - } elseif ($this->options['default_ttl'] > 0 && null === $response->getTtl() && !$response->headers->getCacheControlDirective('must-revalidate')) { - $response->setTtl($this->options['default_ttl']); - } - if ($response->isCacheable()) { $this->store($request, $response); } @@ -487,6 +481,12 @@ protected function forward(Request $request, $catch = false, Response $entry = n $this->processResponseBody($request, $response); + if ($this->isPrivateRequest($request) && !$response->headers->hasCacheControlDirective('public')) { + $response->setPrivate(true); + } elseif ($this->options['default_ttl'] > 0 && null === $response->getTtl() && !$response->headers->getCacheControlDirective('must-revalidate')) { + $response->setTtl($this->options['default_ttl']); + } + return $response; } diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php index c54caf832e918..e08f1982811f9 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php @@ -593,6 +593,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformation() $this->assertTraceContains('fresh'); $this->assertTraceNotContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); + $this->assertRegExp('/s-maxage=10/', $this->response->headers->get('Cache-Control')); } public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAfterTtlWasExpired() @@ -607,17 +608,25 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft $this->assertEquals('Hello World', $this->response->getContent()); $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); - $this->cacheConfig['default_ttl'] = 2; $this->request('GET', '/'); $this->assertHttpKernelIsNotCalled(); $this->assertEquals(200, $this->response->getStatusCode()); $this->assertTraceContains('fresh'); $this->assertTraceNotContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); + $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); - sleep(4); + // expires the cache + $values = $this->getMetaStorageValues(); + $this->assertCount(1, $values); + $tmp = unserialize($values[0]); + $time = \DateTime::createFromFormat('U', time()); + $tmp[0][1]['date'] = \DateTime::createFromFormat('U', time() - 5)->format(DATE_RFC2822); + $r = new \ReflectionObject($this->store); + $m = $r->getMethod('save'); + $m->setAccessible(true); + $m->invoke($this->store, 'md'.sha1('http://localhost/'), serialize($tmp)); - $this->cacheConfig['default_ttl'] = 2; $this->request('GET', '/'); $this->assertHttpKernelIsCalled(); $this->assertEquals(200, $this->response->getStatusCode()); @@ -625,14 +634,17 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft $this->assertTraceContains('invalid'); $this->assertTraceContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); + $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); + + $this->setNextResponse(); - $this->cacheConfig['default_ttl'] = 2; $this->request('GET', '/'); $this->assertHttpKernelIsNotCalled(); $this->assertEquals(200, $this->response->getStatusCode()); $this->assertTraceContains('fresh'); $this->assertTraceNotContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); + $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); } public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAfterTtlWasExpiredWithStatus304() @@ -647,7 +659,6 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft $this->assertEquals('Hello World', $this->response->getContent()); $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); - $this->cacheConfig['default_ttl'] = 2; $this->request('GET', '/'); $this->assertHttpKernelIsNotCalled(); $this->assertEquals(200, $this->response->getStatusCode()); @@ -655,11 +666,17 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft $this->assertTraceNotContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); - sleep(4); - - $this->setNextResponse(304); + // expires the cache + $values = $this->getMetaStorageValues(); + $this->assertCount(1, $values); + $tmp = unserialize($values[0]); + $time = \DateTime::createFromFormat('U', time()); + $tmp[0][1]['date'] = \DateTime::createFromFormat('U', time() - 5)->format(DATE_RFC2822); + $r = new \ReflectionObject($this->store); + $m = $r->getMethod('save'); + $m->setAccessible(true); + $m->invoke($this->store, 'md'.sha1('http://localhost/'), serialize($tmp)); - $this->cacheConfig['default_ttl'] = 2; $this->request('GET', '/'); $this->assertHttpKernelIsCalled(); $this->assertEquals(200, $this->response->getStatusCode()); @@ -668,14 +685,15 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft $this->assertTraceContains('store'); $this->assertTraceNotContains('miss'); $this->assertEquals('Hello World', $this->response->getContent()); + $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); - $this->cacheConfig['default_ttl'] = 2; $this->request('GET', '/'); $this->assertHttpKernelIsNotCalled(); $this->assertEquals(200, $this->response->getStatusCode()); $this->assertTraceContains('fresh'); $this->assertTraceNotContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); + $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); } public function testDoesNotAssignDefaultTtlWhenResponseHasMustRevalidateDirective() From 46725c9cc8b6e81e29a743417e297839776b475d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 13 May 2014 10:47:23 +0200 Subject: [PATCH 1031/1305] fixed CS --- src/Symfony/Component/Console/Tests/ApplicationTest.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index 0965d24ad5743..2c27339a6ef1b 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -476,7 +476,9 @@ public function testRenderExceptionWithDoubleWidthCharacters() $application->expects($this->any()) ->method('getTerminalWidth') ->will($this->returnValue(120)); - $application->register('foo')->setCode(function () {throw new \Exception('エラーメッセージ');}); + $application->register('foo')->setCode(function () { + throw new \Exception('エラーメッセージ'); + }); $tester = new ApplicationTester($application); $tester->run(array('command' => 'foo'), array('decorated' => false)); @@ -490,7 +492,9 @@ public function testRenderExceptionWithDoubleWidthCharacters() $application->expects($this->any()) ->method('getTerminalWidth') ->will($this->returnValue(32)); - $application->register('foo')->setCode(function () {throw new \Exception('コマンドの実行中にエラーが発生しました。');}); + $application->register('foo')->setCode(function () { + throw new \Exception('コマンドの実行中にエラーが発生しました。'); + }); $tester = new ApplicationTester($application); $tester->run(array('command' => 'foo'), array('decorated' => false)); $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception_doublewidth2.txt', $tester->getDisplay(true), '->renderException() wraps messages when they are bigger than the terminal'); From 8cadb49613054722efc607daa6d95dd36d02203b Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Tue, 13 May 2014 14:44:05 +0100 Subject: [PATCH 1032/1305] Update the fixtures. --- .../application_renderexception_doublewidth2.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth2.txt b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth2.txt index 545cd7b0b49f9..5605f1069736c 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth2.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth2.txt @@ -1,10 +1,11 @@ - - [Exception] - コマンドの実行中にエラーが - 発生しました。 - + + [Exception] + コマンドの実行中に + エラーが発生しまし + た。 + foo From 61108b91856234af98057727c5ca2e511ca24679 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Tue, 13 May 2014 22:34:13 +0100 Subject: [PATCH 1033/1305] Disable 5.6 until it is stable again. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index ca4c19d38177a..6e4c449744a07 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ php: matrix: allow_failures: + - php: 5.6 - php: hhvm-nightly services: mongodb From 619ff5818f9540362ec2aa35dec0cc39263b6278 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Wed, 14 May 2014 14:23:19 +0100 Subject: [PATCH 1034/1305] Explicitly define the encoding. --- src/Symfony/Component/Console/Application.php | 2 +- .../application_renderexception_doublewidth2.txt | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 32650e5a9e947..88162a210e0b3 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -1151,7 +1151,7 @@ private function splitStringByWidth($string, $width) $line = ''; foreach (preg_split('//u', $utf8String) as $char) { // test if $char could be appended to current line - if (mb_strwidth($line.$char) <= $width) { + if (mb_strwidth($line.$char, 'utf8') <= $width) { $line .= $char; continue; } diff --git a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth2.txt b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth2.txt index 5605f1069736c..545cd7b0b49f9 100644 --- a/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth2.txt +++ b/src/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth2.txt @@ -1,11 +1,10 @@ - - [Exception] - コマンドの実行中に - エラーが発生しまし - た。 - + + [Exception] + コマンドの実行中にエラーが + 発生しました。 + foo From c7a77c55b74a078f3c2f1ff55e7e876f6315936e Mon Sep 17 00:00:00 2001 From: Charles Sarrazin Date: Fri, 16 May 2014 11:21:11 +0200 Subject: [PATCH 1035/1305] Fixed incorrect regular plural for -ves words Fixes singularization for words like caves (cave), staves (staff). --- .../Component/PropertyAccess/StringUtil.php | 4 ++-- .../PropertyAccess/Tests/StringUtilTest.php | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Component/PropertyAccess/StringUtil.php b/src/Symfony/Component/PropertyAccess/StringUtil.php index 509bce4b92d8c..50a8eb40920a7 100644 --- a/src/Symfony/Component/PropertyAccess/StringUtil.php +++ b/src/Symfony/Component/PropertyAccess/StringUtil.php @@ -81,8 +81,8 @@ class StringUtil // moves (move) array('sevom', 5, true, true, 'move'), - // hooves (hoof), dwarves (dwarf), elves (elf), leaves (leaf) - array('sev', 3, true, true, 'f'), + // hooves (hoof), dwarves (dwarf), elves (elf), leaves (leaf), caves (cave), staves (staff) + array('sev', 3, true, true, array('f', 've', 'ff')), // axes (axis), axes (ax), axes (axe) array('sexa', 4, false, false, array('ax', 'axe', 'axis')), diff --git a/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php b/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php index e33f01dd9c88d..92df8f1f73546 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php @@ -38,7 +38,7 @@ public function singularifyProvider() array('feet', 'foot'), array('nebulae', 'nebula'), array('babies', 'baby'), - array('hooves', 'hoof'), + array('hooves', array('hoof', 'hoove', 'hooff')), array('chateaux', 'chateau'), array('echoes', array('echo', 'echoe')), array('analyses', array('analys', 'analyse', 'analysis')), @@ -64,14 +64,14 @@ public function singularifyProvider() array('batches', array('batch', 'batche')), array('bushes', array('bush', 'bushe')), array('buses', array('bus', 'buse', 'busis')), - array('calves', 'calf'), + array('calves', array('calf', 'calve', 'calff')), array('circuses', array('circus', 'circuse', 'circusis')), array('crises', array('cris', 'crise', 'crisis')), - array('dwarves', 'dwarf'), - array('elves', 'elf'), + array('dwarves', array('dwarf', 'dwarve', 'dwarff')), + array('elves', array('elf', 'elve', 'elff')), array('emphases', array('emphas', 'emphase', 'emphasis')), array('faxes', 'fax'), - array('halves', 'half'), + array('halves', array('half', 'halve', 'halff')), array('heroes', array('hero', 'heroe')), array('hoaxes', 'hoax'), array('irises', array('iris', 'irise', 'irisis')), @@ -86,13 +86,15 @@ public function singularifyProvider() array('plateaux', 'plateau'), array('poppies', 'poppy'), array('quizzes', 'quiz'), - array('scarves', 'scarf'), + array('scarves', array('scarf', 'scarve', 'scarff')), array('spies', 'spy'), array('stories', 'story'), array('syllabi', 'syllabus'), - array('thieves', 'thief'), + array('thieves', array('thief', 'thieve', 'thieff')), array('waltzes', array('waltz', 'waltze')), - array('wharves', 'wharf'), + array('wharves', array('wharf', 'wharve', 'wharff')), + array('caves', array('caf', 'cave', 'caff')), + array('staves', array('staf', 'stave', 'staff')), array('wives', 'wife'), array('ions', 'ion'), array('bases', array('bas', 'base', 'basis')), From a379298db9c7323780e45b7e80e84f94f0c41c59 Mon Sep 17 00:00:00 2001 From: Tugdual Saunier Date: Tue, 4 Mar 2014 11:12:50 +0000 Subject: [PATCH 1036/1305] [Form] Automatically add step attribute to HTML5 time widgets to display seconds if needed --- .../Form/Extension/Core/Type/TimeType.php | 8 ++++++ .../Extension/Core/Type/TimeTypeTest.php | 27 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php index d7a2a9efba519..6bf41517ac0d7 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php @@ -140,6 +140,14 @@ public function buildView(FormView $view, FormInterface $form, array $options) if ('single_text' === $options['widget']) { $view->vars['type'] = 'time'; + + // we need to force the browser to display the seconds by + // adding the HTML attribute step if not already defined. + // Otherwise the browser will not display and so not send the seconds + // therefore the value will always be considered as invalid. + if ($options['with_seconds'] && !isset($view->vars['attr']['step'])) { + $view->vars['attr']['step'] = 1; + } } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php index 9bdfe1567b3ce..ca186207ac29f 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php @@ -492,6 +492,33 @@ public function testSingleTextWidgetShouldUseTheRightInputType() $this->assertEquals('time', $view->vars['type']); } + public function testSingleTextWidgetWithSecondsShouldHaveRightStepAttribute() + { + $form = $this->factory->create('time', null, array( + 'widget' => 'single_text', + 'with_seconds' => true, + )); + + $view = $form->createView(); + $this->assertArrayHasKey('step', $view->vars['attr']); + $this->assertEquals(1, $view->vars['attr']['step']); + } + + public function testSingleTextWidgetWithSecondsShouldNotOverrideStepAttribute() + { + $form = $this->factory->create('time', null, array( + 'widget' => 'single_text', + 'with_seconds' => true, + 'attr' => array( + 'step' => 30 + ) + )); + + $view = $form->createView(); + $this->assertArrayHasKey('step', $view->vars['attr']); + $this->assertEquals(30, $view->vars['attr']['step']); + } + public function testPassDefaultEmptyValueToViewIfNotRequired() { $form = $this->factory->create('time', null, array( From b505708dddf4d0a10de72c3cd7a28b09ef01431f Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Sat, 17 May 2014 12:38:54 +0200 Subject: [PATCH 1037/1305] Fixed the handling of boolean attributes in ChoiceFormField An option is marked as selected by the presence of the selected attribute, not by the presence of a non-empty selected attribute. The same is true for checked radio buttons or checkboxes. --- .../DomCrawler/Field/ChoiceFormField.php | 8 ++-- .../Tests/Field/ChoiceFormFieldTest.php | 43 ++++++++++++++++++- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php b/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php index efdcf5b9228aa..3d582ff013d6d 100644 --- a/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php @@ -170,7 +170,7 @@ public function addChoice(\DOMNode $node) $option = $this->buildOptionValue($node); $this->options[] = $option; - if ($node->getAttribute('checked')) { + if ($node->hasAttribute('checked')) { $this->value = $option['value']; } } @@ -219,7 +219,7 @@ protected function initialize() $optionValue = $this->buildOptionValue($this->node); $this->options[] = $optionValue; - if ($this->node->getAttribute('checked')) { + if ($this->node->hasAttribute('checked')) { $this->value = $optionValue['value']; } } else { @@ -234,7 +234,7 @@ protected function initialize() foreach ($this->xpath->query('descendant::option', $this->node) as $option) { $this->options[] = $this->buildOptionValue($option); - if ($option->getAttribute('selected')) { + if ($option->hasAttribute('selected')) { $found = true; if ($this->multiple) { $this->value[] = $option->getAttribute('value'); @@ -265,7 +265,7 @@ private function buildOptionValue($node) $defaultValue = (isset($node->nodeValue) && !empty($node->nodeValue)) ? $node->nodeValue : '1'; $option['value'] = $node->hasAttribute('value') ? $node->getAttribute('value') : $defaultValue; - $option['disabled'] = ($node->hasAttribute('disabled') && $node->getAttribute('disabled') == 'disabled'); + $option['disabled'] = $node->hasAttribute('disabled'); return $option; } diff --git a/src/Symfony/Component/DomCrawler/Tests/Field/ChoiceFormFieldTest.php b/src/Symfony/Component/DomCrawler/Tests/Field/ChoiceFormFieldTest.php index cf7cd5a2f2663..c3709abd2ef08 100644 --- a/src/Symfony/Component/DomCrawler/Tests/Field/ChoiceFormFieldTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/Field/ChoiceFormFieldTest.php @@ -73,6 +73,11 @@ public function testIsMultiple() $field = new ChoiceFormField($node); $this->assertTrue($field->isMultiple(), '->isMultiple() returns true for selects with the multiple attribute'); + + $node = $this->createNode('select', '', array('multiple' => '')); + $field = new ChoiceFormField($node); + + $this->assertTrue($field->isMultiple(), '->isMultiple() returns true for selects with an empty multiple attribute'); } public function testSelects() @@ -107,6 +112,14 @@ public function testSelects() } } + public function testSelectWithEmptyBooleanAttribute() + { + $node = $this->createSelectNode(array('foo' => false, 'bar' => true), array(), ''); + $field = new ChoiceFormField($node); + + $this->assertEquals('bar', $field->getValue()); + } + public function testMultipleSelects() { $node = $this->createSelectNode(array('foo' => false, 'bar' => false), array('multiple' => 'multiple')); @@ -166,12 +179,25 @@ public function testRadioButtons() } } + public function testRadioButtonsWithEmptyBooleanAttribute() + { + $node = $this->createNode('input', '', array('type' => 'radio', 'name' => 'name', 'value' => 'foo')); + $field = new ChoiceFormField($node); + $node = $this->createNode('input', '', array('type' => 'radio', 'name' => 'name', 'value' => 'bar', 'checked' => '')); + $field->addChoice($node); + + $this->assertTrue($field->hasValue(), '->hasValue() returns true when a radio button is selected'); + $this->assertEquals('bar', $field->getValue(), '->getValue() returns the value attribute of the selected radio button'); + } + public function testRadioButtonIsDisabled() { $node = $this->createNode('input', '', array('type' => 'radio', 'name' => 'name', 'value' => 'foo', 'disabled' => 'disabled')); $field = new ChoiceFormField($node); $node = $this->createNode('input', '', array('type' => 'radio', 'name' => 'name', 'value' => 'bar')); $field->addChoice($node); + $node = $this->createNode('input', '', array('type' => 'radio', 'name' => 'name', 'value' => 'baz', 'disabled' => '')); + $field->addChoice($node); $field->select('foo'); $this->assertEquals('foo', $field->getValue(), '->getValue() returns the value attribute of the selected radio button'); @@ -180,6 +206,10 @@ public function testRadioButtonIsDisabled() $field->select('bar'); $this->assertEquals('bar', $field->getValue(), '->getValue() returns the value attribute of the selected radio button'); $this->assertFalse($field->isDisabled()); + + $field->select('baz'); + $this->assertEquals('baz', $field->getValue(), '->getValue() returns the value attribute of the selected radio button'); + $this->assertTrue($field->isDisabled()); } public function testCheckboxes() @@ -225,6 +255,15 @@ public function testCheckboxes() } } + public function testCheckboxWithEmptyBooleanAttribute() + { + $node = $this->createNode('input', '', array('type' => 'checkbox', 'name' => 'name', 'value' => 'foo', 'checked' => '')); + $field = new ChoiceFormField($node); + + $this->assertTrue($field->hasValue(), '->hasValue() returns true when the checkbox is checked'); + $this->assertEquals('foo', $field->getValue()); + } + public function testTick() { $node = $this->createSelectNode(array('foo' => false, 'bar' => false)); @@ -284,7 +323,7 @@ public function testOptionWithNoValue() $this->assertEquals('foo', $field->getValue(), '->select() changes the selected option'); } - protected function createSelectNode($options, $attributes = array()) + protected function createSelectNode($options, $attributes = array(), $selectedAttrText = 'selected') { $document = new \DOMDocument(); $node = $document->createElement('select'); @@ -298,7 +337,7 @@ protected function createSelectNode($options, $attributes = array()) $option = $document->createElement('option', $value); $option->setAttribute('value', $value); if ($selected) { - $option->setAttribute('selected', 'selected'); + $option->setAttribute('selected', $selectedAttrText); } $node->appendChild($option); } From 78cff96230e7b9f14354bc067c698a7fe923c458 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Sat, 17 May 2014 12:49:12 +0200 Subject: [PATCH 1038/1305] [DomCrawler] Fixed the initial state for options without value attribute --- .../Component/DomCrawler/Field/ChoiceFormField.php | 12 ++++++------ .../DomCrawler/Tests/Field/ChoiceFormFieldTest.php | 5 +++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php b/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php index efdcf5b9228aa..0cbd0d5fccc9d 100644 --- a/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php @@ -232,22 +232,22 @@ protected function initialize() $found = false; foreach ($this->xpath->query('descendant::option', $this->node) as $option) { - $this->options[] = $this->buildOptionValue($option); + $optionValue = $this->buildOptionValue($option); + $this->options[] = $optionValue; if ($option->getAttribute('selected')) { $found = true; if ($this->multiple) { - $this->value[] = $option->getAttribute('value'); + $this->value[] = $optionValue['value']; } else { - $this->value = $option->getAttribute('value'); + $this->value = $optionValue['value']; } } } // if no option is selected and if it is a simple select box, take the first option as the value - $option = $this->xpath->query('descendant::option', $this->node)->item(0); - if (!$found && !$this->multiple && $option instanceof \DOMElement) { - $this->value = $option->getAttribute('value'); + if (!$found && !$this->multiple && !empty($this->options)) { + $this->value = $this->options[0]['value']; } } } diff --git a/src/Symfony/Component/DomCrawler/Tests/Field/ChoiceFormFieldTest.php b/src/Symfony/Component/DomCrawler/Tests/Field/ChoiceFormFieldTest.php index cf7cd5a2f2663..926778f6fc9ae 100644 --- a/src/Symfony/Component/DomCrawler/Tests/Field/ChoiceFormFieldTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/Field/ChoiceFormFieldTest.php @@ -280,6 +280,11 @@ public function testOptionWithNoValue() { $node = $this->createSelectNodeWithEmptyOption(array('foo' => false, 'bar' => false)); $field = new ChoiceFormField($node); + $this->assertEquals('foo', $field->getValue()); + + $node = $this->createSelectNodeWithEmptyOption(array('foo' => false, 'bar' => true)); + $field = new ChoiceFormField($node); + $this->assertEquals('bar', $field->getValue()); $field->select('foo'); $this->assertEquals('foo', $field->getValue(), '->select() changes the selected option'); } From c1450b465cba49c3765ff1cde1c393b654fc580b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 12 May 2014 16:13:41 +0200 Subject: [PATCH 1039/1305] [HttpKernel] removed absolute paths from the generated container --- src/Symfony/Component/HttpKernel/Kernel.php | 35 +++++++++++++++++++ .../app/cache/dev/withAbsolutePaths.php | 7 ++++ .../app/cache/dev/withoutAbsolutePaths.php | 7 ++++ .../Fixtures/DumpedContainers/composer.json | 1 + .../Tests/Fixtures/KernelForTest.php | 5 +++ .../Component/HttpKernel/Tests/KernelTest.php | 28 +++++++++++++++ .../Component/HttpKernel/composer.json | 4 ++- 7 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withAbsolutePaths.php create mode 100644 src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withoutAbsolutePaths.php create mode 100644 src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/composer.json diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index cad359a8c48f8..0f4a73768cda2 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -32,6 +32,7 @@ use Symfony\Component\Config\Loader\DelegatingLoader; use Symfony\Component\Config\ConfigCache; use Symfony\Component\ClassLoader\ClassCollectionLoader; +use Symfony\Component\Filesystem\Filesystem; /** * The Kernel is the heart of the Symfony system. @@ -716,9 +717,43 @@ protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container $content = static::stripComments($content); } + $content = $this->removeAbsolutePathsFromContainer($content); + $cache->write($content, $container->getResources()); } + /** + * Converts absolute paths to relative ones in the dumped container. + */ + private function removeAbsolutePathsFromContainer($content) + { + if (!class_exists('Symfony\Component\Filesystem\Filesystem')) { + return $content; + } + + // find the "real" root dir (by finding the composer.json file) + $rootDir = $this->getRootDir(); + $previous = $rootDir; + while (!file_exists($rootDir.'/composer.json')) { + if ($previous === $rootDir = realpath($rootDir.'/..')) { + // unable to detect the project root, give up + return $content; + } + + $previous = $rootDir; + } + + $rootDir = rtrim($rootDir, '/'); + $cacheDir = $this->getCacheDir(); + $filesystem = new Filesystem(); + + return preg_replace_callback("{'([^']*)(".preg_quote($rootDir)."[^']*)'}", function ($match) use ($filesystem, $cacheDir) { + $prefix = isset($match[1]) && $match[1] ? "'$match[1]'.__DIR__.'/" : "__DIR__.'/"; + + return $prefix.rtrim($filesystem->makePathRelative($match[2], $cacheDir), '/')."'"; + }, $content); + } + /** * Returns a loader for the container. * diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withAbsolutePaths.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withAbsolutePaths.php new file mode 100644 index 0000000000000..54e0dedc4bfd5 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withAbsolutePaths.php @@ -0,0 +1,7 @@ +'ROOT_DIR/app/cache/dev/foo' +'ROOT_DIR/app/cache/foo' +'ROOT_DIR/foo/bar.php' + +'/some/where/else/foo' + +'file:ROOT_DIR/app/cache/dev/profiler' diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withoutAbsolutePaths.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withoutAbsolutePaths.php new file mode 100644 index 0000000000000..09ce8b5683927 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withoutAbsolutePaths.php @@ -0,0 +1,7 @@ +__DIR__.'/foo' +__DIR__.'/../foo' +__DIR__.'/../../../foo/bar.php' + +'/some/where/else/foo' + +'file:'.__DIR__.'/profiler' diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/composer.json b/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/composer.json new file mode 100644 index 0000000000000..0967ef424bce6 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/composer.json @@ -0,0 +1 @@ +{} diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php index 21583ad40a49f..3eb765d2b5bde 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php @@ -16,6 +16,11 @@ class KernelForTest extends Kernel { + public function setRootDir($dir) + { + $this->rootDir = $dir; + } + public function getBundleMap() { return $this->bundleMap; diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index a19bc32679608..95e8942d08e67 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -824,6 +824,34 @@ public function testTerminateDelegatesTerminationOnlyForTerminableInterface() $kernel->terminate(Request::create('/'), new Response()); } + public function testRemoveAbsolutePathsFromContainer() + { + $kernel = new KernelForTest('dev', true); + $kernel->setRootDir($symfonyRootDir = __DIR__.'/Fixtures/DumpedContainers/app'); + + $content = file_get_contents($symfonyRootDir.'/cache/dev/withAbsolutePaths.php'); + $content = str_replace('ROOT_DIR', __DIR__.'/Fixtures/DumpedContainers', $content); + + $m = new \ReflectionMethod($kernel, 'removeAbsolutePathsFromContainer'); + $m->setAccessible(true); + $content = $m->invoke($kernel, $content); + $this->assertEquals(file_get_contents($symfonyRootDir.'/cache/dev/withoutAbsolutePaths.php'), $content); + } + + public function testRemoveAbsolutePathsFromContainerGiveUpWhenComposerJsonPathNotGuessable() + { + $kernel = new KernelForTest('dev', true); + $kernel->setRootDir($symfonyRootDir = sys_get_temp_dir()); + + $content = file_get_contents(__DIR__.'/Fixtures/DumpedContainers/app/cache/dev/withAbsolutePaths.php'); + $content = str_replace('ROOT_DIR', __DIR__.'/Fixtures/DumpedContainers', $content); + + $m = new \ReflectionMethod($kernel, 'removeAbsolutePathsFromContainer'); + $m->setAccessible(true); + $newContent = $m->invoke($kernel, $content); + $this->assertEquals($newContent, $content); + } + protected function getBundle($dir = null, $parent = null, $className = null, $bundleName = null) { $bundle = $this diff --git a/src/Symfony/Component/HttpKernel/composer.json b/src/Symfony/Component/HttpKernel/composer.json index af659da904092..9b52591d9ff30 100644 --- a/src/Symfony/Component/HttpKernel/composer.json +++ b/src/Symfony/Component/HttpKernel/composer.json @@ -29,6 +29,7 @@ "symfony/console": "~2.2", "symfony/dependency-injection": "~2.0", "symfony/finder": "~2.0", + "symfony/filesystem": "~2.4", "symfony/process": "~2.0", "symfony/routing": "~2.2", "symfony/stopwatch": "~2.2", @@ -40,7 +41,8 @@ "symfony/config": "", "symfony/console": "", "symfony/dependency-injection": "", - "symfony/finder": "" + "symfony/finder": "", + "symfony/filesystem": "" }, "autoload": { "psr-0": { "Symfony\\Component\\HttpKernel\\": "" } From 77b446c904f51a948b6b4edfa88a2f616ce9344d Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Sat, 17 May 2014 15:30:22 +0200 Subject: [PATCH 1040/1305] [DomCrawler] Fixed the coding standards to use strict comparisons --- .../Component/DomCrawler/Field/ChoiceFormField.php | 12 ++++++------ .../Component/DomCrawler/Field/FileFormField.php | 4 ++-- .../Component/DomCrawler/Field/InputFormField.php | 6 +++--- .../Component/DomCrawler/Field/TextareaFormField.php | 2 +- src/Symfony/Component/DomCrawler/Form.php | 8 ++++---- .../Component/DomCrawler/FormFieldRegistry.php | 4 ++-- src/Symfony/Component/DomCrawler/Link.php | 2 +- src/Symfony/Component/DomCrawler/Tests/FormTest.php | 2 -- 8 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php b/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php index 4bd4ff76eca6b..dda0c362f9753 100644 --- a/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php @@ -119,10 +119,10 @@ public function untick() */ public function setValue($value) { - if ('checkbox' == $this->type && false === $value) { + if ('checkbox' === $this->type && false === $value) { // uncheck $this->value = null; - } elseif ('checkbox' == $this->type && true === $value) { + } elseif ('checkbox' === $this->type && true === $value) { // check $this->value = $this->options[0]['value']; } else { @@ -163,7 +163,7 @@ public function setValue($value) */ public function addChoice(\DOMNode $node) { - if (!$this->multiple && 'radio' != $this->type) { + if (!$this->multiple && 'radio' !== $this->type) { throw new \LogicException(sprintf('Unable to add a choice for "%s" as it is not multiple or is not a radio button.', $this->name)); } @@ -202,11 +202,11 @@ public function isMultiple() */ protected function initialize() { - if ('input' != $this->node->nodeName && 'select' != $this->node->nodeName) { + if ('input' !== $this->node->nodeName && 'select' !== $this->node->nodeName) { throw new \LogicException(sprintf('A ChoiceFormField can only be created from an input or select tag (%s given).', $this->node->nodeName)); } - if ('input' == $this->node->nodeName && 'checkbox' != strtolower($this->node->getAttribute('type')) && 'radio' != strtolower($this->node->getAttribute('type'))) { + if ('input' === $this->node->nodeName && 'checkbox' !== strtolower($this->node->getAttribute('type')) && 'radio' !== strtolower($this->node->getAttribute('type'))) { throw new \LogicException(sprintf('A ChoiceFormField can only be created from an input tag with a type of checkbox or radio (given type is %s).', $this->node->getAttribute('type'))); } @@ -271,7 +271,7 @@ private function buildOptionValue($node) } /** - * Checks whether given vale is in the existing options + * Checks whether given value is in the existing options * * @param string $optionValue * @param array $options diff --git a/src/Symfony/Component/DomCrawler/Field/FileFormField.php b/src/Symfony/Component/DomCrawler/Field/FileFormField.php index 160ddc6e0d877..bbdf46799424d 100644 --- a/src/Symfony/Component/DomCrawler/Field/FileFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/FileFormField.php @@ -99,11 +99,11 @@ public function setFilePath($path) */ protected function initialize() { - if ('input' != $this->node->nodeName) { + if ('input' !== $this->node->nodeName) { throw new \LogicException(sprintf('A FileFormField can only be created from an input tag (%s given).', $this->node->nodeName)); } - if ('file' != strtolower($this->node->getAttribute('type'))) { + if ('file' !== strtolower($this->node->getAttribute('type'))) { throw new \LogicException(sprintf('A FileFormField can only be created from an input tag with a type of file (given type is %s).', $this->node->getAttribute('type'))); } diff --git a/src/Symfony/Component/DomCrawler/Field/InputFormField.php b/src/Symfony/Component/DomCrawler/Field/InputFormField.php index 00141d84c6c04..b9bd0a482958a 100644 --- a/src/Symfony/Component/DomCrawler/Field/InputFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/InputFormField.php @@ -30,15 +30,15 @@ class InputFormField extends FormField */ protected function initialize() { - if ('input' != $this->node->nodeName && 'button' != $this->node->nodeName) { + if ('input' !== $this->node->nodeName && 'button' !== $this->node->nodeName) { throw new \LogicException(sprintf('An InputFormField can only be created from an input or button tag (%s given).', $this->node->nodeName)); } - if ('checkbox' == strtolower($this->node->getAttribute('type'))) { + if ('checkbox' === strtolower($this->node->getAttribute('type'))) { throw new \LogicException('Checkboxes should be instances of ChoiceFormField.'); } - if ('file' == strtolower($this->node->getAttribute('type'))) { + if ('file' === strtolower($this->node->getAttribute('type'))) { throw new \LogicException('File inputs should be instances of FileFormField.'); } diff --git a/src/Symfony/Component/DomCrawler/Field/TextareaFormField.php b/src/Symfony/Component/DomCrawler/Field/TextareaFormField.php index 242a9d3724621..a14e70783b70c 100644 --- a/src/Symfony/Component/DomCrawler/Field/TextareaFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/TextareaFormField.php @@ -27,7 +27,7 @@ class TextareaFormField extends FormField */ protected function initialize() { - if ('textarea' != $this->node->nodeName) { + if ('textarea' !== $this->node->nodeName) { throw new \LogicException(sprintf('A TextareaFormField can only be created from a textarea tag (%s given).', $this->node->nodeName)); } diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php index a19cc79da7ff8..0f28d45d5310f 100644 --- a/src/Symfony/Component/DomCrawler/Form.php +++ b/src/Symfony/Component/DomCrawler/Form.php @@ -28,7 +28,7 @@ class Form extends Link implements \ArrayAccess private $button; /** - * @var Field\FormField[] + * @var FormFieldRegistry */ private $fields; @@ -352,7 +352,7 @@ public function offsetUnset($name) protected function setNode(\DOMNode $node) { $this->button = $node; - if ('button' == $node->nodeName || ('input' == $node->nodeName && in_array(strtolower($node->getAttribute('type')), array('submit', 'button', 'image')))) { + if ('button' === $node->nodeName || ('input' === $node->nodeName && in_array(strtolower($node->getAttribute('type')), array('submit', 'button', 'image')))) { if ($node->hasAttribute('form')) { // if the node has the HTML5-compliant 'form' attribute, use it $formId = $node->getAttribute('form'); @@ -369,8 +369,8 @@ protected function setNode(\DOMNode $node) if (null === $node = $node->parentNode) { throw new \LogicException('The selected node does not have a form ancestor.'); } - } while ('form' != $node->nodeName); - } elseif ('form' != $node->nodeName) { + } while ('form' !== $node->nodeName); + } elseif ('form' !== $node->nodeName) { throw new \LogicException(sprintf('Unable to submit on a "%s" tag.', $node->nodeName)); } diff --git a/src/Symfony/Component/DomCrawler/FormFieldRegistry.php b/src/Symfony/Component/DomCrawler/FormFieldRegistry.php index f37e05025c564..150f94dfc6879 100644 --- a/src/Symfony/Component/DomCrawler/FormFieldRegistry.php +++ b/src/Symfony/Component/DomCrawler/FormFieldRegistry.php @@ -137,7 +137,7 @@ public function set($name, $value) /** * Returns the list of field with their value. * - * @return array The list of fields as array((string) Fully qualified name => (mixed) value) + * @return FormField[] The list of fields as array((string) Fully qualified name => (mixed) value) */ public function all() { @@ -196,7 +196,7 @@ private function walk(array $array, $base = '', array &$output = array()) * * @param string $name The name of the field * - * @return array The list of segments + * @return string[] The list of segments * * @throws \InvalidArgumentException when the name is malformed */ diff --git a/src/Symfony/Component/DomCrawler/Link.php b/src/Symfony/Component/DomCrawler/Link.php index d662f8937c855..05d5e927a2f62 100644 --- a/src/Symfony/Component/DomCrawler/Link.php +++ b/src/Symfony/Component/DomCrawler/Link.php @@ -188,7 +188,7 @@ protected function canonicalizePath($path) */ protected function setNode(\DOMNode $node) { - if ('a' != $node->nodeName && 'area' != $node->nodeName) { + if ('a' !== $node->nodeName && 'area' !== $node->nodeName) { throw new \LogicException(sprintf('Unable to click on a "%s" tag.', $node->nodeName)); } diff --git a/src/Symfony/Component/DomCrawler/Tests/FormTest.php b/src/Symfony/Component/DomCrawler/Tests/FormTest.php index 1fbfbb983df59..02e7fbba4b6ef 100644 --- a/src/Symfony/Component/DomCrawler/Tests/FormTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/FormTest.php @@ -793,7 +793,6 @@ protected function createForm($form, $method = null, $currentUri = null) $dom = new \DOMDocument(); $dom->loadHTML(''.$form.''); - $nodes = $dom->getElementsByTagName('input'); $xPath = new \DOMXPath($dom); $nodes = $xPath->query('//input | //button'); @@ -856,5 +855,4 @@ public function testgetPhpValuesWithEmptyTextarea() $form = new Form($nodes->item(0), 'http://example.com'); $this->assertEquals($form->getPhpValues(), array('example' => '')); } - } From 50ec82864241ae37a9b74178c68d10326f47270c Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Thu, 15 May 2014 19:19:48 +0200 Subject: [PATCH 1041/1305] [HttpFoundation] implement session locking for PDO --- .../stubs/SessionHandlerInterface.php | 12 + .../Storage/Handler/PdoSessionHandler.php | 306 ++++++++++++++---- .../Storage/Handler/PdoSessionHandlerTest.php | 124 ++++--- 3 files changed, 327 insertions(+), 115 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php b/src/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php index 24280e38fca4a..9557135bcfbd1 100644 --- a/src/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php +++ b/src/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php @@ -12,6 +12,14 @@ /** * SessionHandlerInterface for PHP < 5.4 * + * The order in which these methods are invoked by PHP are: + * 1. open [session_start] + * 2. read + * 3. gc [optional depending on probability settings: gc_probability / gc_divisor] + * 4. destroy [optional when session_regenerate_id(true) is used] + * 5. write [session_write_close] or destroy [session_destroy] + * 6. close + * * Extensive documentation can be found at php.net, see links: * * @see http://php.net/sessionhandlerinterface @@ -19,6 +27,7 @@ * @see http://php.net/session-set-save-handler * * @author Drak + * @author Tobias Schultze */ interface SessionHandlerInterface { @@ -57,6 +66,9 @@ public function read($sessionId); /** * Writes the session data to the storage. * + * Care, the session ID passed to write() can be different from the one previously + * received in read() when the session ID changed due to session_regenerate_id(). + * * @see http://php.net/sessionhandlerinterface.write * * @param string $sessionId Session ID , see http://php.net/function.session-id diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php index e81db4de85b33..aabd123a3efbc 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php @@ -12,7 +12,19 @@ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; /** - * PdoSessionHandler. + * Session handler using a PDO connection to read and write data. + * + * It works with MySQL, PostgreSQL, Oracle, SQL Server and SQLite and implements + * locking of sessions to prevent loss of data by concurrent access to the same session. + * This means requests for the same session will wait until the other one finished. + * PHPs internal files session handler also works this way. + * + * Attention: Since SQLite does not support row level locks but locks the whole database, + * it means only one session can be accessed at a time. Even different sessions would wait + * for another to finish. So saving session in SQLite should only be considered for + * development or prototypes. + * + * @see http://php.net/sessionhandlerinterface * * @author Fabien Potencier * @author Michael Williams @@ -25,6 +37,11 @@ class PdoSessionHandler implements \SessionHandlerInterface */ private $pdo; + /** + * @var string Database driver + */ + private $driver; + /** * @var string Table name */ @@ -45,39 +62,50 @@ class PdoSessionHandler implements \SessionHandlerInterface */ private $timeCol; + /** + * @var bool Whether a transaction is active + */ + private $inTransaction = false; + + /** + * @var bool Whether gc() has been called + */ + private $gcCalled = false; + /** * Constructor. * * List of available options: - * * db_table: The name of the table [required] + * * db_table: The name of the table [default: sessions] * * db_id_col: The column where to store the session id [default: sess_id] * * db_data_col: The column where to store the session data [default: sess_data] * * db_time_col: The column where to store the timestamp [default: sess_time] * - * @param \PDO $pdo A \PDO instance - * @param array $dbOptions An associative array of DB options + * @param \PDO $pdo A \PDO instance + * @param array $options An associative array of DB options * - * @throws \InvalidArgumentException When "db_table" option is not provided + * @throws \InvalidArgumentException When PDO error mode is not PDO::ERRMODE_EXCEPTION */ - public function __construct(\PDO $pdo, array $dbOptions = array()) + public function __construct(\PDO $pdo, array $options = array()) { - if (!array_key_exists('db_table', $dbOptions)) { - throw new \InvalidArgumentException('You must provide the "db_table" option for a PdoSessionStorage.'); - } if (\PDO::ERRMODE_EXCEPTION !== $pdo->getAttribute(\PDO::ATTR_ERRMODE)) { throw new \InvalidArgumentException(sprintf('"%s" requires PDO error mode attribute be set to throw Exceptions (i.e. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION))', __CLASS__)); } + $this->pdo = $pdo; - $dbOptions = array_merge(array( + $this->driver = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME); + + $options = array_replace(array( + 'db_table' => 'sessions', 'db_id_col' => 'sess_id', 'db_data_col' => 'sess_data', 'db_time_col' => 'sess_time', - ), $dbOptions); + ), $options); - $this->table = $dbOptions['db_table']; - $this->idCol = $dbOptions['db_id_col']; - $this->dataCol = $dbOptions['db_data_col']; - $this->timeCol = $dbOptions['db_time_col']; + $this->table = $options['db_table']; + $this->idCol = $options['db_id_col']; + $this->dataCol = $options['db_data_col']; + $this->timeCol = $options['db_time_col']; } /** @@ -85,34 +113,45 @@ public function __construct(\PDO $pdo, array $dbOptions = array()) */ public function open($savePath, $sessionName) { - return true; - } + $this->gcCalled = false; - /** - * {@inheritdoc} - */ - public function close() - { return true; } /** * {@inheritdoc} */ - public function destroy($sessionId) + public function read($sessionId) { - // delete the record associated with this id - $sql = "DELETE FROM $this->table WHERE $this->idCol = :id"; + $this->beginTransaction(); try { + $this->lockSession($sessionId); + + // We need to make sure we do not return session data that is already considered garbage according + // to the session.gc_maxlifetime setting because gc() is called after read() and only sometimes. + $maxlifetime = (int) ini_get('session.gc_maxlifetime'); + + $sql = "SELECT $this->dataCol FROM $this->table WHERE $this->idCol = :id AND $this->timeCol > :time"; + $stmt = $this->pdo->prepare($sql); $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); + $stmt->bindValue(':time', time() - $maxlifetime, \PDO::PARAM_INT); $stmt->execute(); + + // We use fetchAll instead of fetchColumn to make sure the DB cursor gets closed + $sessionRows = $stmt->fetchAll(\PDO::FETCH_NUM); + + if ($sessionRows) { + return base64_decode($sessionRows[0][0]); + } + + return ''; } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to delete a session: %s', $e->getMessage()), 0, $e); - } + $this->rollback(); - return true; + throw $e; + } } /** @@ -120,16 +159,9 @@ public function destroy($sessionId) */ public function gc($maxlifetime) { - // delete the session records that have expired - $sql = "DELETE FROM $this->table WHERE $this->timeCol < :time"; - - try { - $stmt = $this->pdo->prepare($sql); - $stmt->bindValue(':time', time() - $maxlifetime, \PDO::PARAM_INT); - $stmt->execute(); - } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to delete expired sessions: %s', $e->getMessage()), 0, $e); - } + // We delay gc() to close() so that it is executed outside the transactional and blocking read-write process. + // This way, pruning expired sessions does not block them from being started while the current session is used. + $this->gcCalled = true; return true; } @@ -137,26 +169,22 @@ public function gc($maxlifetime) /** * {@inheritdoc} */ - public function read($sessionId) + public function destroy($sessionId) { - $sql = "SELECT $this->dataCol FROM $this->table WHERE $this->idCol = :id"; + // delete the record associated with this id + $sql = "DELETE FROM $this->table WHERE $this->idCol = :id"; try { $stmt = $this->pdo->prepare($sql); $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); $stmt->execute(); - - // We use fetchAll instead of fetchColumn to make sure the DB cursor gets closed - $sessionRows = $stmt->fetchAll(\PDO::FETCH_NUM); - - if ($sessionRows) { - return base64_decode($sessionRows[0][0]); - } - - return ''; } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to read the session data: %s', $e->getMessage()), 0, $e); + $this->rollback(); + + throw $e; } + + return true; } /** @@ -167,8 +195,10 @@ public function write($sessionId, $data) // Session data can contain non binary safe characters so we need to encode it. $encoded = base64_encode($data); + // The session ID can be different from the one previously received in read() + // when the session ID changed due to session_regenerate_id(). So we have to + // do an insert or update even if we created a row in read() for locking. // We use a MERGE SQL query when supported by the database. - // Otherwise we have to use a transactional DELETE followed by INSERT to prevent duplicate entries under high concurrency. try { $mergeSql = $this->getMergeSql(); @@ -183,15 +213,18 @@ public function write($sessionId, $data) return true; } - $this->pdo->beginTransaction(); - - try { - $deleteStmt = $this->pdo->prepare( - "DELETE FROM $this->table WHERE $this->idCol = :id" - ); - $deleteStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); - $deleteStmt->execute(); - + $updateStmt = $this->pdo->prepare( + "UPDATE $this->table SET $this->dataCol = :data, $this->timeCol = :time WHERE $this->idCol = :id" + ); + $updateStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); + $updateStmt->bindParam(':data', $encoded, \PDO::PARAM_STR); + $updateStmt->bindValue(':time', time(), \PDO::PARAM_INT); + $updateStmt->execute(); + + // Since we have a lock on the session, this is safe to do. Otherwise it would be prone to + // race conditions in high concurrency. And if it's a regenerated session ID it should be + // unique anyway. + if (!$updateStmt->rowCount()) { $insertStmt = $this->pdo->prepare( "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time)" ); @@ -199,18 +232,153 @@ public function write($sessionId, $data) $insertStmt->bindParam(':data', $encoded, \PDO::PARAM_STR); $insertStmt->bindValue(':time', time(), \PDO::PARAM_INT); $insertStmt->execute(); + } + } catch (\PDOException $e) { + $this->rollback(); + + throw $e; + } + + return true; + } + + /** + * {@inheritdoc} + */ + public function close() + { + $this->commit(); + + if ($this->gcCalled) { + $maxlifetime = (int) ini_get('session.gc_maxlifetime'); + + // delete the session records that have expired + $sql = "DELETE FROM $this->table WHERE $this->timeCol <= :time"; - $this->pdo->commit(); + $stmt = $this->pdo->prepare($sql); + $stmt->bindValue(':time', time() - $maxlifetime, \PDO::PARAM_INT); + $stmt->execute(); + } + + return true; + } + + /** + * Helper method to begin a transaction. + * + * Since SQLite does not support row level locks, we have to acquire a reserved lock + * on the database immediately. Because of https://bugs.php.net/42766 we have to create + * such a transaction manually which also means we cannot use PDO::commit or + * PDO::rollback or PDO::inTransaction for SQLite. + */ + private function beginTransaction() + { + if ($this->inTransaction) { + $this->rollback(); + + throw new \BadMethodCallException( + 'Session handler methods have been invoked in wrong sequence. ' . + 'Expected sequence: open() -> read() -> destroy() / write() -> close()'); + } + + if ('sqlite' === $this->driver) { + $this->pdo->exec('BEGIN IMMEDIATE TRANSACTION'); + } else { + $this->pdo->beginTransaction(); + } + $this->inTransaction = true; + } + + /** + * Helper method to commit a transaction. + */ + private function commit() + { + if ($this->inTransaction) { + try { + // commit read-write transaction which also releases the lock + if ('sqlite' === $this->driver) { + $this->pdo->exec('COMMIT'); + } else { + $this->pdo->commit(); + } + $this->inTransaction = false; } catch (\PDOException $e) { - $this->pdo->rollback(); + $this->rollback(); throw $e; } - } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to write the session data: %s', $e->getMessage()), 0, $e); } + } - return true; + /** + * Helper method to rollback a transaction. + */ + private function rollback() + { + // We only need to rollback if we are in a transaction. Otherwise the resulting + // error would hide the real problem why rollback was called. We might not be + // in a transaction when two callbacks (e.g. destroy and write) are invoked that + // both fail. + if ($this->inTransaction) { + if ('sqlite' === $this->driver) { + $this->pdo->exec('ROLLBACK'); + } else { + $this->pdo->rollback(); + } + $this->inTransaction = false; + } + } + + /** + * Exclusively locks the row so other concurrent requests on the same session will block. + * + * This prevents loss of data by keeping the data consistent between read() and write(). + * We do not use SELECT FOR UPDATE because it does not lock non-existent rows. And a following + * INSERT when not found can result in a deadlock for one connection. + * + * @param string $sessionId Session ID + */ + private function lockSession($sessionId) + { + switch ($this->driver) { + case 'mysql': + // will also lock the row when actually nothing got updated (id = id) + $sql = "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) " . + "ON DUPLICATE KEY UPDATE $this->idCol = $this->idCol"; + break; + case 'oci': + // DUAL is Oracle specific dummy table + $sql = "MERGE INTO $this->table USING DUAL ON ($this->idCol = :id) " . + "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) " . + "WHEN MATCHED THEN UPDATE SET $this->idCol = $this->idCol"; + break; + case 'sqlsrv': + // MS SQL Server requires MERGE be terminated by semicolon + $sql = "MERGE INTO $this->table USING (SELECT 'x' AS dummy) AS src ON ($this->idCol = :id) " . + "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) " . + "WHEN MATCHED THEN UPDATE SET $this->idCol = $this->idCol;"; + break; + case 'pgsql': + // obtain an exclusive transaction level advisory lock + $sql = 'SELECT pg_advisory_xact_lock(:lock_id)'; + $stmt = $this->pdo->prepare($sql); + $stmt->bindValue(':lock_id', hexdec(substr($sessionId, 0, 15)), \PDO::PARAM_INT); + $stmt->execute(); + + return; + default: + return; + } + + // We create a DML lock for the session by inserting empty data or updating the row. + // This is safer than an application level advisory lock because it also prevents concurrent modification + // of the session from other parts of the application. + $stmt = $this->pdo->prepare($sql); + $stmt->bindParam(':id', $sessionId, \PDO::PARAM_STR); + $stmt->bindValue(':data', '', \PDO::PARAM_STR); + $stmt->bindValue(':time', time(), \PDO::PARAM_INT); + $stmt->execute(); } /** @@ -220,9 +388,7 @@ public function write($sessionId, $data) */ private function getMergeSql() { - $driver = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME); - - switch ($driver) { + switch ($this->driver) { case 'mysql': return "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) " . "ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->timeCol = VALUES($this->timeCol)"; @@ -230,12 +396,12 @@ private function getMergeSql() // DUAL is Oracle specific dummy table return "MERGE INTO $this->table USING DUAL ON ($this->idCol = :id) " . "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) " . - "WHEN MATCHED THEN UPDATE SET $this->dataCol = :data"; + "WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->timeCol = :time"; case 'sqlsrv': // MS SQL Server requires MERGE be terminated by semicolon return "MERGE INTO $this->table USING (SELECT 'x' AS dummy) AS src ON ($this->idCol = :id) " . "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) " . - "WHEN MATCHED THEN UPDATE SET $this->dataCol = :data;"; + "WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->timeCol = :time;"; case 'sqlite': return "INSERT OR REPLACE INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time)"; } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php index 14e2dba52648b..32195f96f42b5 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php @@ -29,73 +29,107 @@ protected function setUp() $this->pdo->exec($sql); } - public function testIncompleteOptions() - { - $this->setExpectedException('InvalidArgumentException'); - $storage = new PdoSessionHandler($this->pdo, array()); - } - + /** + * @expectedException \InvalidArgumentException + */ public function testWrongPdoErrMode() { - $pdo = new \PDO("sqlite::memory:"); - $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT); - $pdo->exec("CREATE TABLE sessions (sess_id VARCHAR(255) PRIMARY KEY, sess_data TEXT, sess_time INTEGER)"); + $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT); - $this->setExpectedException('InvalidArgumentException'); - $storage = new PdoSessionHandler($pdo, array('db_table' => 'sessions')); + $storage = new PdoSessionHandler($this->pdo); } - public function testWrongTableOptionsWrite() + /** + * @expectedException \RuntimeException + */ + public function testInexistentTable() { - $storage = new PdoSessionHandler($this->pdo, array('db_table' => 'bad_name')); - $this->setExpectedException('RuntimeException'); - $storage->write('foo', 'bar'); + $storage = new PdoSessionHandler($this->pdo, array('db_table' => 'inexistent_table')); + $storage->open('', 'sid'); + $storage->read('id'); + $storage->write('id', 'data'); + $storage->close(); } - public function testWrongTableOptionsRead() + public function testReadWriteRead() { - $storage = new PdoSessionHandler($this->pdo, array('db_table' => 'bad_name')); - $this->setExpectedException('RuntimeException'); - $storage->read('foo', 'bar'); + $storage = new PdoSessionHandler($this->pdo); + $storage->open('', 'sid'); + $this->assertSame('', $storage->read('id'), 'New session returns empty string data'); + $storage->write('id', 'data'); + $storage->close(); + + $storage->open('', 'sid'); + $this->assertSame('data', $storage->read('id'), 'Written value can be read back correctly'); + $storage->close(); } - public function testWriteRead() + /** + * Simulates session_regenerate_id(true) which will require an INSERT or UPDATE (replace) + */ + public function testWriteDifferentSessionIdThanRead() { - $storage = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions')); - $storage->write('foo', 'bar'); - $this->assertEquals('bar', $storage->read('foo'), 'written value can be read back correctly'); + $storage = new PdoSessionHandler($this->pdo); + $storage->open('', 'sid'); + $storage->read('id'); + $storage->destroy('id'); + $storage->write('new_id', 'data_of_new_session_id'); + $storage->close(); + + $storage->open('', 'sid'); + $this->assertSame('data_of_new_session_id', $storage->read('new_id'), 'Data of regenerated session id is available'); + $storage->close(); } - public function testMultipleInstances() + /** + * @expectedException \BadMethodCallException + */ + public function testWrongUsage() { - $storage1 = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions')); - $storage1->write('foo', 'bar'); - - $storage2 = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions')); - $this->assertEquals('bar', $storage2->read('foo'), 'values persist between instances'); + $storage = new PdoSessionHandler($this->pdo); + $storage->open('', 'sid'); + $storage->read('id'); + $storage->read('id'); } public function testSessionDestroy() { - $storage = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions')); - $storage->write('foo', 'bar'); - $this->assertCount(1, $this->pdo->query('SELECT * FROM sessions')->fetchAll()); - - $storage->destroy('foo'); - - $this->assertCount(0, $this->pdo->query('SELECT * FROM sessions')->fetchAll()); + $storage = new PdoSessionHandler($this->pdo); + + $storage->open('', 'sid'); + $storage->read('id'); + $storage->write('id', 'data'); + $storage->close(); + $this->assertEquals(1, $this->pdo->query('SELECT COUNT(*) FROM sessions')->fetchColumn()); + + $storage->open('', 'sid'); + $storage->read('id'); + $storage->destroy('id'); + $storage->close(); + $this->assertEquals(0, $this->pdo->query('SELECT COUNT(*) FROM sessions')->fetchColumn()); + + $storage->open('', 'sid'); + $this->assertSame('', $storage->read('id'), 'Destroyed session returns empty string'); + $storage->close(); } public function testSessionGC() { - $storage = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions')); - - $storage->write('foo', 'bar'); - $storage->write('baz', 'bar'); - - $this->assertCount(2, $this->pdo->query('SELECT * FROM sessions')->fetchAll()); - - $storage->gc(-1); - $this->assertCount(0, $this->pdo->query('SELECT * FROM sessions')->fetchAll()); + $previousLifeTime = ini_set('session.gc_maxlifetime', 0); + $storage = new PdoSessionHandler($this->pdo); + + $storage->open('', 'sid'); + $storage->read('id'); + $storage->write('id', 'data'); + $storage->close(); + $this->assertEquals(1, $this->pdo->query('SELECT COUNT(*) FROM sessions')->fetchColumn()); + + $storage->open('', 'sid'); + $this->assertSame('', $storage->read('id'), 'Session already considered garbage, so not returning data even if it is not pruned yet'); + $storage->gc(0); + $storage->close(); + $this->assertEquals(0, $this->pdo->query('SELECT COUNT(*) FROM sessions')->fetchColumn()); + + ini_set('session.gc_maxlifetime', $previousLifeTime); } } From 583092b6dac886295baa69c5c0f25fb0e2f70247 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Sat, 17 May 2014 19:27:19 +0200 Subject: [PATCH 1042/1305] [Process] Add validation on Process input --- src/Symfony/Component/Process/Process.php | 5 +- .../Component/Process/ProcessBuilder.php | 6 ++- .../Component/Process/ProcessUtils.php | 25 +++++++++ .../Process/Tests/AbstractProcessTest.php | 53 +++++++++++++++++++ .../Process/Tests/ProcessBuilderTest.php | 10 ++++ 5 files changed, 95 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 822671467b277..2ccad53d775c8 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -880,7 +880,8 @@ public function getStdin() * * @return self The current Process instance * - * @throws LogicException In case the process is running + * @throws LogicException In case the process is running + * @throws InvalidArgumentException In case the argument is invalid */ public function setStdin($stdin) { @@ -888,7 +889,7 @@ public function setStdin($stdin) throw new LogicException('STDIN can not be set while the process is running.'); } - $this->stdin = $stdin; + $this->stdin = ProcessUtils::validateInput(sprintf('%s::%s', __CLASS__, __FUNCTION__), $stdin); return $this; } diff --git a/src/Symfony/Component/Process/ProcessBuilder.php b/src/Symfony/Component/Process/ProcessBuilder.php index 3e3eed892058b..ef1fefc3d991b 100644 --- a/src/Symfony/Component/Process/ProcessBuilder.php +++ b/src/Symfony/Component/Process/ProcessBuilder.php @@ -148,13 +148,15 @@ public function setEnv($name, $value) /** * Sets the input of the process. * - * @param string $stdin The input as a string + * @param string|null $stdin The input as a string * * @return ProcessBuilder + * + * @throws InvalidArgumentException In case the argument is invalid */ public function setInput($stdin) { - $this->stdin = $stdin; + $this->stdin = ProcessUtils::validateInput(sprintf('%s::%s', __CLASS__, __FUNCTION__), $stdin); return $this; } diff --git a/src/Symfony/Component/Process/ProcessUtils.php b/src/Symfony/Component/Process/ProcessUtils.php index 5317cd0883949..441522d388048 100644 --- a/src/Symfony/Component/Process/ProcessUtils.php +++ b/src/Symfony/Component/Process/ProcessUtils.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Process; +use Symfony\Component\Process\Exception\InvalidArgumentException; + /** * ProcessUtils is a bunch of utility methods. * @@ -72,6 +74,29 @@ public static function escapeArgument($argument) return escapeshellarg($argument); } + /** + * Validates and normalized a Process input + * + * @param string $caller The name of method call that validates the input + * @param mixed $input The input to validate + * + * @return string The validated input + * + * @throws InvalidArgumentException In case the input is not valid + */ + public static function validateInput($caller, $input) + { + if (null !== $input) { + if (is_scalar($input) || (is_object($input) && method_exists($input, '__toString'))) { + return (string) $input; + } + + throw new InvalidArgumentException(sprintf('%s only accepts strings.', $caller)); + } + + return $input; + } + private static function isSurroundedBy($arg, $char) { return 2 < strlen($arg) && $char === $arg[0] && $char === $arg[strlen($arg) - 1]; diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index 50d80cae77716..91b8aca20d06a 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -171,6 +171,47 @@ public function testSetStdinWhileRunningThrowsAnException() $process->stop(); } + /** + * @dataProvider provideInvalidStdinValues + * @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException + * @expectedExceptionMessage Symfony\Component\Process\Process::setStdin only accepts strings. + */ + public function testInvalidStdin($value) + { + $process = $this->getProcess('php -v'); + $process->setStdin($value); + } + + public function provideInvalidStdinValues() + { + return array( + array(array()), + array(new NonStringifiable()), + array(fopen('php://temporary', 'w')), + ); + } + + /** + * @dataProvider provideStdinValues + */ + public function testValidStdin($expected, $value) + { + $process = $this->getProcess('php -v'); + $process->setStdin($value); + $this->assertSame($expected, $process->getStdin()); + } + + public function provideStdinValues() + { + return array( + array(null, null), + array('24.5', 24.5), + array('input data', 'input data'), + // to maintain BC, supposed to be removed in 3.0 + array('stringifiable', new Stringifiable()), + ); + } + public function chainedCommandsOutputProvider() { if (defined('PHP_WINDOWS_VERSION_BUILD')) { @@ -813,3 +854,15 @@ public function methodProvider() */ abstract protected function getProcess($commandline, $cwd = null, array $env = null, $stdin = null, $timeout = 60, array $options = array()); } + +class Stringifiable +{ + public function __toString() + { + return 'stringifiable'; + } +} + +class NonStringifiable +{ +} diff --git a/src/Symfony/Component/Process/Tests/ProcessBuilderTest.php b/src/Symfony/Component/Process/Tests/ProcessBuilderTest.php index d0611f0b415ed..70245e0a4272a 100644 --- a/src/Symfony/Component/Process/Tests/ProcessBuilderTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessBuilderTest.php @@ -197,4 +197,14 @@ public function testShouldNotThrowALogicExceptionIfNoPrefix() $this->assertEquals("'/usr/bin/php'", $process->getCommandLine()); } } + + /** + * @expectedException \Symfony\Component\Process\Exception\InvalidArgumentException + * @expectedExceptionMessage Symfony\Component\Process\ProcessBuilder::setInput only accepts strings. + */ + public function testInvalidInput() + { + $builder = ProcessBuilder::create(); + $builder->setInput(array()); + } } From 4735e56c44ea13aa8418a69f28aacce3c08d6e62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20L=C3=A9v=C3=AAque?= Date: Sun, 18 May 2014 15:17:34 +0200 Subject: [PATCH 1043/1305] Fix "absolute path" when we look to the cache directory We should get __DIR__ instead of __DIR__ . '/.' --- src/Symfony/Component/HttpKernel/Kernel.php | 10 ++++++++-- .../app/cache/dev/withAbsolutePaths.php | 1 + .../app/cache/dev/withoutAbsolutePaths.php | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 0f4a73768cda2..219c707ee13a3 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -748,9 +748,15 @@ private function removeAbsolutePathsFromContainer($content) $filesystem = new Filesystem(); return preg_replace_callback("{'([^']*)(".preg_quote($rootDir)."[^']*)'}", function ($match) use ($filesystem, $cacheDir) { - $prefix = isset($match[1]) && $match[1] ? "'$match[1]'.__DIR__.'/" : "__DIR__.'/"; + $prefix = isset($match[1]) && $match[1] ? "'$match[1]'.__DIR__" : "__DIR__"; - return $prefix.rtrim($filesystem->makePathRelative($match[2], $cacheDir), '/')."'"; + $relativePath = rtrim($filesystem->makePathRelative($match[2], $cacheDir), '/'); + + if ($relativePath === '.') { + return $prefix; + } + + return $prefix . ".'/" . $relativePath . "'"; }, $content); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withAbsolutePaths.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withAbsolutePaths.php index 54e0dedc4bfd5..b8644ecb9fe00 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withAbsolutePaths.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withAbsolutePaths.php @@ -1,6 +1,7 @@ 'ROOT_DIR/app/cache/dev/foo' 'ROOT_DIR/app/cache/foo' 'ROOT_DIR/foo/bar.php' +'ROOT_DIR/app/cache/dev' '/some/where/else/foo' diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withoutAbsolutePaths.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withoutAbsolutePaths.php index 09ce8b5683927..36823dfc160c8 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withoutAbsolutePaths.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/DumpedContainers/app/cache/dev/withoutAbsolutePaths.php @@ -1,6 +1,7 @@ __DIR__.'/foo' __DIR__.'/../foo' __DIR__.'/../../../foo/bar.php' +__DIR__ '/some/where/else/foo' From 11816c5e518bf6e1aa25f457bd861394a6e4bf1d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 18 May 2014 17:36:43 +0200 Subject: [PATCH 1044/1305] fixed CS --- src/Symfony/Component/HttpKernel/Kernel.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 219c707ee13a3..5fbdddbf0c344 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -750,13 +750,11 @@ private function removeAbsolutePathsFromContainer($content) return preg_replace_callback("{'([^']*)(".preg_quote($rootDir)."[^']*)'}", function ($match) use ($filesystem, $cacheDir) { $prefix = isset($match[1]) && $match[1] ? "'$match[1]'.__DIR__" : "__DIR__"; - $relativePath = rtrim($filesystem->makePathRelative($match[2], $cacheDir), '/'); - - if ($relativePath === '.') { + if ('.' === $relativePath = rtrim($filesystem->makePathRelative($match[2], $cacheDir), '/')) { return $prefix; } - return $prefix . ".'/" . $relativePath . "'"; + return $prefix.".'/".$relativePath."'"; }, $content); } From 2e64fb1db3b892132cd4695888904d340cb7edfc Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Tue, 20 May 2014 16:25:35 +0200 Subject: [PATCH 1045/1305] Fixed the Travis build to avoid exiting too early --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6e4c449744a07..e6fddf33626cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,5 +27,5 @@ before_script: - wget https://phar.phpunit.de/phpunit.phar && rm `which phpunit` && sudo cp phpunit.phar /usr/local/bin/phpunit && sudo chmod +x /usr/local/bin/phpunit script: - - ls -d src/Symfony/*/* | parallel --gnu --keep-order 'echo "Running {} tests"; phpunit --exclude-group tty,benchmark {};' || exit 1 + - ls -d src/Symfony/*/* | parallel --gnu --keep-order 'echo "Running {} tests"; phpunit --exclude-group tty,benchmark {};' || false - echo "Running tests requiring tty"; phpunit --group tty From fad38e82f43abd985c08d08e8bbb3dd46350954e Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Wed, 21 May 2014 13:33:13 +0200 Subject: [PATCH 1046/1305] Fixed test cases failing when the Intl extension is not installed --- .../Component/Translation/Tests/IdentityTranslatorTest.php | 4 ++++ .../Validator/Tests/Constraints/CountryValidatorTest.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/Symfony/Component/Translation/Tests/IdentityTranslatorTest.php b/src/Symfony/Component/Translation/Tests/IdentityTranslatorTest.php index cec702a1b99b6..cfd282a294644 100644 --- a/src/Symfony/Component/Translation/Tests/IdentityTranslatorTest.php +++ b/src/Symfony/Component/Translation/Tests/IdentityTranslatorTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Translation\Tests; +use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Translation\IdentityTranslator; use Symfony\Component\Translation\MessageSelector; @@ -59,6 +60,9 @@ public function testGetSetLocale() public function testGetLocaleReturnsDefaultLocaleIfNotSet() { + // in order to test with "pt_BR" + IntlTestHelper::requireFullIntl($this); + $translator = new IdentityTranslator(new MessageSelector()); \Locale::setDefault('en'); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php index 95851e8097ad7..5fabee67fb399 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php @@ -107,7 +107,11 @@ public function getInvalidCountries() public function testValidateUsingCountrySpecificLocale() { + // in order to test with "en_GB" + IntlTestHelper::requireFullIntl($this); + \Locale::setDefault('en_GB'); + $existingCountry = 'GB'; $this->context->expects($this->never()) ->method('addViolation'); From 6f56d878c91c1570003f9d43a6aa27fec4cb408e Mon Sep 17 00:00:00 2001 From: realmfoo Date: Wed, 21 May 2014 00:16:09 +0400 Subject: [PATCH 1047/1305] [HttpKernel] fixed file uploads in functional tests when no file was selected Allow user to submit a form with no file selected. --- src/Symfony/Component/HttpKernel/Client.php | 6 +++--- .../Component/HttpKernel/Tests/ClientTest.php | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Client.php b/src/Symfony/Component/HttpKernel/Client.php index a663350bf1e6c..5ef739ba8d209 100644 --- a/src/Symfony/Component/HttpKernel/Client.php +++ b/src/Symfony/Component/HttpKernel/Client.php @@ -143,7 +143,9 @@ protected function filterRequest(DomRequest $request) { $httpRequest = Request::create($request->getUri(), $request->getMethod(), $request->getParameters(), $request->getCookies(), $request->getFiles(), $request->getServer(), $request->getContent()); - $httpRequest->files->replace($this->filterFiles($httpRequest->files->all())); + foreach ($this->filterFiles($httpRequest->files->all()) as $key => $value) { + $httpRequest->files->set($key, $value); + } return $httpRequest; } @@ -189,8 +191,6 @@ protected function filterFiles(array $files) true ); } - } else { - $filtered[$key] = $value; } } diff --git a/src/Symfony/Component/HttpKernel/Tests/ClientTest.php b/src/Symfony/Component/HttpKernel/Tests/ClientTest.php index 8e1b6c1e6f783..4d9918b504920 100644 --- a/src/Symfony/Component/HttpKernel/Tests/ClientTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/ClientTest.php @@ -143,6 +143,21 @@ public function testUploadedFile() unlink($target); } + public function testUploadedFileWhenNoFileSelected() + { + $kernel = new TestHttpKernel(); + $client = new Client($kernel); + + $file = array('tmp_name' => '', 'name' => '', 'type' => '', 'size' => 0, 'error' => UPLOAD_ERR_NO_FILE); + + $client->request('POST', '/', array(), array('foo' => $file)); + + $files = $client->getRequest()->files->all(); + + $this->assertCount(1, $files); + $this->assertNull($files['foo']); + } + public function testUploadedFileWhenSizeExceedsUploadMaxFileSize() { $source = tempnam(sys_get_temp_dir(), 'source'); From 8f706c97b9a15a4b10dde0ae51aab5069f4151b0 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Sun, 18 May 2014 02:01:43 +0200 Subject: [PATCH 1048/1305] [DomCrawler] Added more tests for the XPath filtering This will ensure we don't introduce regressions again when fixing #10206. --- .../DomCrawler/Tests/CrawlerTest.php | 63 +++++++++++++++++++ .../Component/DomCrawler/Tests/FormTest.php | 40 ++++++++++++ 2 files changed, 103 insertions(+) diff --git a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php index 07a08d0d04dfe..8c90caea08bf1 100644 --- a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php @@ -368,6 +368,27 @@ public function testExtract() $this->assertEquals(array(), $this->createTestCrawler()->filterXPath('//ol')->extract('_text'), '->extract() returns an empty array if the node list is empty'); } + public function testFilterXpathComplexQueries() + { + $crawler = $this->createTestCrawler()->filterXPath('//body'); + + $this->assertCount(0, $crawler->filterXPath('/input')); + $this->assertCount(0, $crawler->filterXPath('/body')); + $this->assertCount(1, $crawler->filterXPath('/_root/body')); + $this->assertCount(1, $crawler->filterXPath('./body')); + $this->assertCount(4, $crawler->filterXPath('//form')->filterXPath('//button | //input')); + $this->assertCount(1, $crawler->filterXPath('body')); + $this->assertCount(6, $crawler->filterXPath('//button | //input')); + $this->assertCount(1, $crawler->filterXPath('//body')); + $this->assertCount(1, $crawler->filterXPath('descendant-or-self::body')); + $this->assertCount(1, $crawler->filterXPath('//div[@id="parent"]')->filterXPath('./div'), 'A child selection finds only the current div'); + $this->assertCount(2, $crawler->filterXPath('//div[@id="parent"]')->filterXPath('descendant::div'), 'A descendant selector matches the current div and its child'); + $this->assertCount(2, $crawler->filterXPath('//div[@id="parent"]')->filterXPath('//div'), 'A descendant selector matches the current div and its child'); + $this->assertCount(5, $crawler->filterXPath('(//a | //div)//img')); + $this->assertCount(7, $crawler->filterXPath('((//a | //div)//img | //ul)')); + $this->assertCount(7, $crawler->filterXPath('( ( //a | //div )//img | //ul )')); + } + /** * @covers Symfony\Component\DomCrawler\Crawler::filterXPath */ @@ -455,6 +476,44 @@ public function testLink() } } + public function testSelectLinkAndLinkFiltered() + { + $html = << + + +
+ Login +
+
+ +
+ + +HTML; + + $crawler = new Crawler($html); + $filtered = $crawler->filterXPath("descendant-or-self::*[@id = 'login-form']"); + + $this->assertCount(0, $filtered->selectLink('Login')); + $this->assertCount(1, $filtered->selectButton('Submit')); + + $filtered = $crawler->filterXPath("descendant-or-self::*[@id = 'action']"); + + $this->assertCount(1, $filtered->selectLink('Login')); + $this->assertCount(0, $filtered->selectButton('Submit')); + + $this->assertCount(1, $crawler->selectLink('Login')->selectLink('Login')); + $this->assertCount(1, $crawler->selectButton('Submit')->selectButton('Submit')); + } + + public function testChaining() + { + $crawler = new Crawler('
'); + + $this->assertEquals('a', $crawler->filterXPath('//div')->filterXPath('div')->filterXPath('div')->attr('name')); + } + public function testLinks() { $crawler = $this->createTestCrawler('http://example.com/bar/')->selectLink('Foo'); @@ -665,6 +724,10 @@ public function createTestCrawler($uri = null)
  • Two Bis
  • Three Bis
  • +
    +
    +
    +
    '); diff --git a/src/Symfony/Component/DomCrawler/Tests/FormTest.php b/src/Symfony/Component/DomCrawler/Tests/FormTest.php index 02e7fbba4b6ef..0c12b08dc849f 100644 --- a/src/Symfony/Component/DomCrawler/Tests/FormTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/FormTest.php @@ -85,6 +85,20 @@ public function testConstructorThrowsExceptionIfNoRelatedForm() $form = new Form($nodes->item(1), 'http://example.com'); } + public function testConstructorLoadsOnlyFieldsOfTheRightForm() + { + $dom = $this->createTestMultipleForm(); + + $nodes = $dom->getElementsByTagName('form'); + $buttonElements = $dom->getElementsByTagName('button'); + + $form = new Form($nodes->item(0), 'http://example.com'); + $this->assertCount(3, $form->all()); + + $form = new Form($buttonElements->item(1), 'http://example.com'); + $this->assertCount(5, $form->all()); + } + public function testConstructorHandlesFormAttribute() { $dom = $this->createTestHtml5Form(); @@ -840,6 +854,32 @@ protected function createTestHtml5Form() return $dom; } + protected function createTestMultipleForm() + { + $dom = new \DOMDocument(); + $dom->loadHTML(' + +

    Hello form

    +
    +
    + +
    + + +
    +
    +
    +
    + + + +
    + + + + +HTML; + + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->selectButton('Click \'Here\'')); + } + + public function testSelectButtonWithDoubleQuotesInNameAttribute() + { + $html = << + + +
    + Login +
    +
    + +
    + + +HTML; + + $crawler = new Crawler($html); + + $this->assertCount(1, $crawler->selectButton('Click "Here"')); + } + public function testLink() { $crawler = $this->createTestCrawler('http://example.com/bar/')->selectLink('Foo'); From 5bb2345790f3eac835eb2c9855f8c17d6002ad54 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 24 Jun 2014 23:45:04 +0200 Subject: [PATCH 1109/1305] [Components][Serializer] optional constructor arguments can be omitted during the denormalization process --- .../Normalizer/GetSetMethodNormalizer.php | 4 +- .../Normalizer/GetSetMethodNormalizerTest.php | 44 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php index 3d7dad39750c8..e4e3d82291b7d 100644 --- a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php @@ -128,7 +128,9 @@ public function denormalize($data, $class, $format = null, array $context = arra $params[] = $data[$paramName]; // don't run set for a parameter passed to the constructor unset($data[$paramName]); - } elseif (!$constructorParameter->isOptional()) { + } elseif ($constructorParameter->isOptional()) { + $params[] = $constructorParameter->getDefaultValue(); + } else { throw new RuntimeException( 'Cannot create an instance of '.$class. ' from serialized data because its constructor requires '. diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php index 7ec4814d71fc9..e4f1b5c656cbb 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -86,6 +86,16 @@ public function testConstructorDenormalize() $this->assertEquals('bar', $obj->getBar()); } + public function testConstructorDenormalizeWithMissingOptionalArgument() + { + $obj = $this->normalizer->denormalize( + array('foo' => 'test', 'baz' => array(1, 2, 3)), + __NAMESPACE__.'\GetConstructorOptionalArgsDummy', 'any'); + $this->assertEquals('test', $obj->getFoo()); + $this->assertEquals(array(), $obj->getBar()); + $this->assertEquals(array(1, 2, 3), $obj->getBaz()); + } + /** * @dataProvider provideCallbacks */ @@ -263,3 +273,37 @@ public function otherMethod() throw new \RuntimeException("Dummy::otherMethod() should not be called"); } } + +class GetConstructorOptionalArgsDummy +{ + protected $foo; + private $bar; + private $baz; + + public function __construct($foo, $bar = array(), $baz = array()) + { + $this->foo = $foo; + $this->bar = $bar; + $this->baz = $baz; + } + + public function getFoo() + { + return $this->foo; + } + + public function getBar() + { + return $this->bar; + } + + public function getBaz() + { + return $this->baz; + } + + public function otherMethod() + { + throw new \RuntimeException("Dummy::otherMethod() should not be called"); + } +} From 7b2e3d91d8dc61439bb742aefebe64b7a513509f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 26 Jun 2014 08:10:31 +0200 Subject: [PATCH 1110/1305] [ClassLoader] fixed PHP warning on PHP 5.3 --- src/Symfony/Component/ClassLoader/ClassMapGenerator.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php index 59c99d0f1b75d..7f83dbc5592d1 100644 --- a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php +++ b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php @@ -11,6 +11,10 @@ namespace Symfony\Component\ClassLoader; +if (!defined('T_TRAIT')) { + define('T_TRAIT', 0); +} + /** * ClassMapGenerator * @@ -84,7 +88,6 @@ private static function findClasses($path) { $contents = file_get_contents($path); $tokens = token_get_all($contents); - $T_TRAIT = version_compare(PHP_VERSION, '5.4', '<') ? -1 : T_TRAIT; $classes = array(); @@ -111,7 +114,7 @@ private static function findClasses($path) break; case T_CLASS: case T_INTERFACE: - case $T_TRAIT: + case T_TRAIT: // Find the classname while (($t = $tokens[++$i]) && is_array($t)) { if (T_STRING === $t[0]) { From 1c5c694196f8ad8ba12b48cdc939d60e8012c4df Mon Sep 17 00:00:00 2001 From: Julien Pauli Date: Wed, 25 Jun 2014 18:49:15 +0200 Subject: [PATCH 1111/1305] Fix mocks to support >=5.5.14 and >=5.4.30 --- .../HttpFoundationRequestHandlerTest.php | 5 +-- .../Resources/stubs/FakeFile.php | 45 +++++++++++++++++++ .../Tests/BinaryFileResponseTest.php | 14 +----- 3 files changed, 49 insertions(+), 15 deletions(-) create mode 100644 src/Symfony/Component/HttpFoundation/Resources/stubs/FakeFile.php diff --git a/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php index b25380aea7c49..cf5d63d90e09c 100644 --- a/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php @@ -14,6 +14,7 @@ use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler; use Symfony\Component\Form\Tests\AbstractRequestHandlerTest; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\File\UploadedFile; /** * @author Bernhard Schussek @@ -47,8 +48,6 @@ protected function getRequestHandler() protected function getMockFile() { - return $this->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile') - ->setConstructorArgs(array(__DIR__.'/../../Fixtures/foo', 'foo')) - ->getMock(); + return new UploadedFile(__DIR__.'/../../Fixtures/foo', 'foo'); } } diff --git a/src/Symfony/Component/HttpFoundation/Resources/stubs/FakeFile.php b/src/Symfony/Component/HttpFoundation/Resources/stubs/FakeFile.php new file mode 100644 index 0000000000000..0aecc20b08f0f --- /dev/null +++ b/src/Symfony/Component/HttpFoundation/Resources/stubs/FakeFile.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpFoundation\Resources\stubs; + +use Symfony\Component\HttpFoundation\File\File as OrigFile; + +class FakeFile extends OrigFile +{ + private $realpath; + + public function __construct($realpath, $path) + { + $this->realpath = $realpath; + parent::__construct($path, false); + } + + public function isReadable() + { + return true; + } + + public function getRealpath() + { + return $this->realpath; + } + + public function getSize() + { + return 42; + } + + public function getMTime() + { + return time(); + } +} diff --git a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php index d7d1b03c3c76d..397192b8853aa 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php @@ -14,6 +14,7 @@ use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\ResponseHeaderBag; +use Symfony\Component\HttpFoundation\Resources\stubs\FakeFile; class BinaryFileResponseTest extends ResponseTestCase { @@ -179,18 +180,7 @@ public function testXAccelMapping($realpath, $mapping, $virtual) $request->headers->set('X-Sendfile-Type', 'X-Accel-Redirect'); $request->headers->set('X-Accel-Mapping', $mapping); - $file = $this->getMockBuilder('Symfony\Component\HttpFoundation\File\File') - ->setConstructorArgs(array(__DIR__.'/File/Fixtures/test')) - ->getMock(); - $file->expects($this->any()) - ->method('getRealPath') - ->will($this->returnValue($realpath)); - $file->expects($this->any()) - ->method('isReadable') - ->will($this->returnValue(true)); - $file->expects($this->any()) - ->method('getMTime') - ->will($this->returnValue(time())); + $file = new FakeFile($realpath, __DIR__.'/File/Fixtures/test'); BinaryFileResponse::trustXSendFileTypeHeader(); $response = new BinaryFileResponse($file); From 994f81fd8696a95104b5c1e3817a82173b029b4c Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Fri, 27 Jun 2014 01:18:27 +0200 Subject: [PATCH 1112/1305] Refactored the CssSelector to remove the circular object graph This allows the translator and its extensions to be garbage collected based on the refcount rather than requiring the garbage collector run, making it much more likely to happen at the end of the CssSelector::toXPath call. --- .../XPath/Extension/ExtensionInterface.php | 2 + .../XPath/Extension/NodeExtension.php | 63 ++++++++++--------- .../CssSelector/XPath/Translator.php | 4 +- 3 files changed, 36 insertions(+), 33 deletions(-) diff --git a/src/Symfony/Component/CssSelector/XPath/Extension/ExtensionInterface.php b/src/Symfony/Component/CssSelector/XPath/Extension/ExtensionInterface.php index 65ab287770f27..22312659429a4 100644 --- a/src/Symfony/Component/CssSelector/XPath/Extension/ExtensionInterface.php +++ b/src/Symfony/Component/CssSelector/XPath/Extension/ExtensionInterface.php @@ -24,6 +24,8 @@ interface ExtensionInterface /** * Returns node translators. * + * These callables will receive the node as first argument and the translator as second argument. + * * @return callable[] */ public function getNodeTranslators(); diff --git a/src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php b/src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php index f86f2b967266a..d71baaa96bcd3 100644 --- a/src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php +++ b/src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php @@ -29,11 +29,6 @@ class NodeExtension extends AbstractExtension const ATTRIBUTE_NAME_IN_LOWER_CASE = 2; const ATTRIBUTE_VALUE_IN_LOWER_CASE = 4; - /** - * @var Translator - */ - private $translator; - /** * @var int */ @@ -42,12 +37,10 @@ class NodeExtension extends AbstractExtension /** * Constructor. * - * @param Translator $translator - * @param int $flags + * @param int $flags */ - public function __construct(Translator $translator, $flags = 0) + public function __construct($flags = 0) { - $this->translator = $translator; $this->flags = $flags; } @@ -100,33 +93,36 @@ public function getNodeTranslators() /** * @param Node\SelectorNode $node + * @param Translator $translator * * @return XPathExpr */ - public function translateSelector(Node\SelectorNode $node) + public function translateSelector(Node\SelectorNode $node, Translator $translator) { - return $this->translator->nodeToXPath($node->getTree()); + return $translator->nodeToXPath($node->getTree()); } /** * @param Node\CombinedSelectorNode $node + * @param Translator $translator * * @return XPathExpr */ - public function translateCombinedSelector(Node\CombinedSelectorNode $node) + public function translateCombinedSelector(Node\CombinedSelectorNode $node, Translator $translator) { - return $this->translator->addCombination($node->getCombinator(), $node->getSelector(), $node->getSubSelector()); + return $translator->addCombination($node->getCombinator(), $node->getSelector(), $node->getSubSelector()); } /** * @param Node\NegationNode $node + * @param Translator $translator * * @return XPathExpr */ - public function translateNegation(Node\NegationNode $node) + public function translateNegation(Node\NegationNode $node, Translator $translator) { - $xpath = $this->translator->nodeToXPath($node->getSelector()); - $subXpath = $this->translator->nodeToXPath($node->getSubSelector()); + $xpath = $translator->nodeToXPath($node->getSelector()); + $subXpath = $translator->nodeToXPath($node->getSubSelector()); $subXpath->addNameTest(); if ($subXpath->getCondition()) { @@ -138,34 +134,37 @@ public function translateNegation(Node\NegationNode $node) /** * @param Node\FunctionNode $node + * @param Translator $translator * * @return XPathExpr */ - public function translateFunction(Node\FunctionNode $node) + public function translateFunction(Node\FunctionNode $node, Translator $translator) { - $xpath = $this->translator->nodeToXPath($node->getSelector()); + $xpath = $translator->nodeToXPath($node->getSelector()); - return $this->translator->addFunction($xpath, $node); + return $translator->addFunction($xpath, $node); } /** * @param Node\PseudoNode $node + * @param Translator $translator * * @return XPathExpr */ - public function translatePseudo(Node\PseudoNode $node) + public function translatePseudo(Node\PseudoNode $node, Translator $translator) { - $xpath = $this->translator->nodeToXPath($node->getSelector()); + $xpath = $translator->nodeToXPath($node->getSelector()); - return $this->translator->addPseudoClass($xpath, $node->getIdentifier()); + return $translator->addPseudoClass($xpath, $node->getIdentifier()); } /** * @param Node\AttributeNode $node + * @param Translator $translator * * @return XPathExpr */ - public function translateAttribute(Node\AttributeNode $node) + public function translateAttribute(Node\AttributeNode $node, Translator $translator) { $name = $node->getAttribute(); $safe = $this->isSafeName($name); @@ -181,37 +180,39 @@ public function translateAttribute(Node\AttributeNode $node) $attribute = $safe ? '@'.$name : sprintf('attribute::*[name() = %s]', Translator::getXpathLiteral($name)); $value = $node->getValue(); - $xpath = $this->translator->nodeToXPath($node->getSelector()); + $xpath = $translator->nodeToXPath($node->getSelector()); if ($this->hasFlag(self::ATTRIBUTE_VALUE_IN_LOWER_CASE)) { $value = strtolower($value); } - return $this->translator->addAttributeMatching($xpath, $node->getOperator(), $attribute, $value); + return $translator->addAttributeMatching($xpath, $node->getOperator(), $attribute, $value); } /** * @param Node\ClassNode $node + * @param Translator $translator * * @return XPathExpr */ - public function translateClass(Node\ClassNode $node) + public function translateClass(Node\ClassNode $node, Translator $translator) { - $xpath = $this->translator->nodeToXPath($node->getSelector()); + $xpath = $translator->nodeToXPath($node->getSelector()); - return $this->translator->addAttributeMatching($xpath, '~=', '@class', $node->getName()); + return $translator->addAttributeMatching($xpath, '~=', '@class', $node->getName()); } /** * @param Node\HashNode $node + * @param Translator $translator * * @return XPathExpr */ - public function translateHash(Node\HashNode $node) + public function translateHash(Node\HashNode $node, Translator $translator) { - $xpath = $this->translator->nodeToXPath($node->getSelector()); + $xpath = $translator->nodeToXPath($node->getSelector()); - return $this->translator->addAttributeMatching($xpath, '=', '@id', $node->getId()); + return $translator->addAttributeMatching($xpath, '=', '@id', $node->getId()); } /** diff --git a/src/Symfony/Component/CssSelector/XPath/Translator.php b/src/Symfony/Component/CssSelector/XPath/Translator.php index 5a8eb99017a1b..4676677ea4884 100644 --- a/src/Symfony/Component/CssSelector/XPath/Translator.php +++ b/src/Symfony/Component/CssSelector/XPath/Translator.php @@ -76,7 +76,7 @@ public function __construct(ParserInterface $parser = null) $this->mainParser = $parser ?: new Parser(); $this - ->registerExtension(new Extension\NodeExtension($this)) + ->registerExtension(new Extension\NodeExtension()) ->registerExtension(new Extension\CombinationExtension()) ->registerExtension(new Extension\FunctionExtension()) ->registerExtension(new Extension\PseudoClassExtension()) @@ -207,7 +207,7 @@ public function nodeToXPath(NodeInterface $node) throw new ExpressionErrorException(sprintf('Node "%s" not supported.', $node->getNodeName())); } - return call_user_func($this->nodeTranslators[$node->getNodeName()], $node); + return call_user_func($this->nodeTranslators[$node->getNodeName()], $node, $this); } /** From b8f8c0ec4dc9b08f4ca3d5f83a3487e0514fce1d Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 20 Jun 2014 08:36:55 +0100 Subject: [PATCH 1113/1305] [Process] Fix ExecutableFinder with open basedir --- .../Component/Process/ExecutableFinder.php | 2 +- .../Process/Tests/ExecutableFinderTest.php | 112 ++++++++++++++++++ 2 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Component/Process/Tests/ExecutableFinderTest.php diff --git a/src/Symfony/Component/Process/ExecutableFinder.php b/src/Symfony/Component/Process/ExecutableFinder.php index 5cc99c7692051..44f1605fa956b 100644 --- a/src/Symfony/Component/Process/ExecutableFinder.php +++ b/src/Symfony/Component/Process/ExecutableFinder.php @@ -53,7 +53,7 @@ public function addSuffix($suffix) public function find($name, $default = null, array $extraDirs = array()) { if (ini_get('open_basedir')) { - $searchPath = explode(PATH_SEPARATOR, getenv('open_basedir')); + $searchPath = explode(PATH_SEPARATOR, ini_get('open_basedir')); $dirs = array(); foreach ($searchPath as $path) { if (is_dir($path)) { diff --git a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php new file mode 100644 index 0000000000000..abaa47d8ddd70 --- /dev/null +++ b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php @@ -0,0 +1,112 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Process\Tests; + +use Symfony\Component\Process\ExecutableFinder; + +/** + * @author Chris Smith + */ +class ExecutableFinderTest extends \PHPUnit_Framework_TestCase +{ + private $path; + + public function tearDown() + { + if ($this->path) { + // Restore path if it was changed. + putenv('PATH='.$this->path); + } + } + + private function setPath($path) + { + $this->path = getenv('PATH'); + putenv('PATH='.$path); + } + + public function testFind() + { + if (!defined('PHP_BINARY')) { + $this->markTestSkipped('Requires the PHP_BINARY constant'); + } + + if (ini_get('open_basedir')) { + $this->markTestSkipped('Cannot test when open_basedir is set'); + } + + $this->setPath(dirname(PHP_BINARY)); + + $finder = new ExecutableFinder; + $result = $finder->find(basename(PHP_BINARY)); + + $this->assertEquals($result, PHP_BINARY); + } + + public function testFindWithDefault() + { + if (ini_get('open_basedir')) { + $this->markTestSkipped('Cannot test when open_basedir is set'); + } + + $expected = 'defaultValue'; + + $this->setPath(''); + + $finder = new ExecutableFinder; + $result = $finder->find('foo', $expected); + + $this->assertEquals($expected, $result); + } + + public function testFindWithExtraDirs() + { + if (!defined('PHP_BINARY')) { + $this->markTestSkipped('Requires the PHP_BINARY constant'); + } + + if (ini_get('open_basedir')) { + $this->markTestSkipped('Cannot test when open_basedir is set'); + } + + $this->setPath(''); + + $extraDirs = array(dirname(PHP_BINARY)); + + $finder = new ExecutableFinder; + $result = $finder->find(basename(PHP_BINARY), null, $extraDirs); + + $this->assertEquals(PHP_BINARY, $result); + } + + public function testFindWithOpenBaseDir() + { + if (!defined('PHP_BINARY')) { + $this->markTestSkipped('Requires the PHP_BINARY constant'); + } + + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->markTestSkipped('Cannot run test on windows'); + } + + if (ini_get('open_basedir')) { + $this->markTestSkipped('Cannot test when open_basedir is set'); + } + + ini_set('open_basedir', dirname(PHP_BINARY).PATH_SEPARATOR.'/'); + + $finder = new ExecutableFinder; + $result = $finder->find(basename(PHP_BINARY)); + + $this->assertEquals(PHP_BINARY, $result); + } +} From 3b9902ae770b58a612248594b9fb90fce3724712 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 28 Jun 2014 15:47:37 +0200 Subject: [PATCH 1114/1305] enabled PHP 5.6 for tests --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e746bb793530f..0be40d36e36f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,6 @@ php: matrix: allow_failures: - - php: 5.6 - php: hhvm-nightly services: mongodb From de2bef5886c9630cea327ea4ef10a95e8130ae70 Mon Sep 17 00:00:00 2001 From: Curtis Date: Mon, 30 Jun 2014 11:26:47 -0700 Subject: [PATCH 1115/1305] Fixed failed config schema loads due to libxml_disable_entity_loader usage. Applied CS patch. --- src/Symfony/Component/Config/Util/XmlUtils.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Config/Util/XmlUtils.php b/src/Symfony/Component/Config/Util/XmlUtils.php index 71f8bf1558edb..b120fdf18875f 100644 --- a/src/Symfony/Component/Config/Util/XmlUtils.php +++ b/src/Symfony/Component/Config/Util/XmlUtils.php @@ -80,7 +80,8 @@ public static function loadFile($file, $schemaOrCallable = null) $valid = false; } } elseif (!is_array($schemaOrCallable) && is_file((string) $schemaOrCallable)) { - $valid = @$dom->schemaValidate($schemaOrCallable); + $schemaSource = file_get_contents((string) $schemaOrCallable); + $valid = @$dom->schemaValidateSource($schemaSource); } else { libxml_use_internal_errors($internalErrors); From 64328d967d130ba5950a98b1d434fe317684c2c7 Mon Sep 17 00:00:00 2001 From: akimsko Date: Wed, 2 Jul 2014 11:31:46 +0200 Subject: [PATCH 1116/1305] [Console] Make sure formatter is the same The parent constructor will create a new formatter if the $formatter parameter is null This fix avoids that the formatter becomes 2 different instances in $this and $this->stderr --- src/Symfony/Component/Console/Output/ConsoleOutput.php | 2 +- .../Component/Console/Tests/Output/ConsoleOutputTest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Output/ConsoleOutput.php b/src/Symfony/Component/Console/Output/ConsoleOutput.php index b5eaf154fab5a..3560f1c6fc5aa 100644 --- a/src/Symfony/Component/Console/Output/ConsoleOutput.php +++ b/src/Symfony/Component/Console/Output/ConsoleOutput.php @@ -50,7 +50,7 @@ public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = nu parent::__construct(fopen($outputStream, 'w'), $verbosity, $decorated, $formatter); - $this->stderr = new StreamOutput(fopen('php://stderr', 'w'), $verbosity, $decorated, $formatter); + $this->stderr = new StreamOutput(fopen('php://stderr', 'w'), $verbosity, $decorated, $this->getFormatter()); } /** diff --git a/src/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php b/src/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php index 7a3ede3ba874e..1afbbb6e6cffc 100644 --- a/src/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php +++ b/src/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php @@ -20,5 +20,6 @@ public function testConstructor() { $output = new ConsoleOutput(Output::VERBOSITY_QUIET, true); $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument'); + $this->assertSame($output->getFormatter(), $output->getErrorOutput()->getFormatter(), '__construct() takes a formatter or null as the third argument'); } } From e8d01c9669671ed8089843ec21c2b3d11b23375b Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Thu, 3 Jul 2014 14:53:01 +0200 Subject: [PATCH 1117/1305] Simplified the Travis test command There is no reason to turn a failure into a different failure. And this will avoid Travis to say that the "false" command failed. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0be40d36e36f2..00e07241bced4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,5 +26,5 @@ before_script: - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "5.3.3" ]; then phpunit --self-update; fi;' script: - - ls -d src/Symfony/*/* | parallel --gnu --keep-order 'echo "Running {} tests"; phpunit --exclude-group tty,benchmark {};' || false + - ls -d src/Symfony/*/* | parallel --gnu --keep-order 'echo "Running {} tests"; phpunit --exclude-group tty,benchmark {};' - echo "Running tests requiring tty"; phpunit --group tty From fe5d2d1554097861cb5535ee70595bd1e2ba6530 Mon Sep 17 00:00:00 2001 From: Benjamin Grandfond Date: Sat, 21 Jun 2014 22:15:52 +0200 Subject: [PATCH 1118/1305] [DomCrawler] Remove the query string and the anchor of the uri of a link --- src/Symfony/Component/DomCrawler/Link.php | 67 ++++++++++++++----- .../Component/DomCrawler/Tests/LinkTest.php | 4 ++ 2 files changed, 54 insertions(+), 17 deletions(-) diff --git a/src/Symfony/Component/DomCrawler/Link.php b/src/Symfony/Component/DomCrawler/Link.php index 05d5e927a2f62..57cf2b4f211e0 100644 --- a/src/Symfony/Component/DomCrawler/Link.php +++ b/src/Symfony/Component/DomCrawler/Link.php @@ -98,34 +98,23 @@ public function getUri() return $this->currentUri; } - // only an anchor + // an anchor if ('#' === $uri[0]) { - $baseUri = $this->currentUri; - if (false !== $pos = strpos($baseUri, '#')) { - $baseUri = substr($baseUri, 0, $pos); - } - - return $baseUri.$uri; + return $this->cleanupAnchor($this->currentUri).$uri; } - // only a query string - if ('?' === $uri[0]) { - $baseUri = $this->currentUri; - - // remove the query string from the current URI - if (false !== $pos = strpos($baseUri, '?')) { - $baseUri = substr($baseUri, 0, $pos); - } + $baseUri = $this->cleanupUri($this->currentUri); + if ('?' === $uri[0]) { return $baseUri.$uri; } // absolute URL with relative schema if (0 === strpos($uri, '//')) { - return preg_replace('#^([^/]*)//.*$#', '$1', $this->currentUri).$uri; + return preg_replace('#^([^/]*)//.*$#', '$1', $baseUri).$uri; } - $baseUri = preg_replace('#^(.*?//[^/]*)(?:\/.*)?$#', '$1', $this->currentUri); + $baseUri = preg_replace('#^(.*?//[^/]*)(?:\/.*)?$#', '$1', $baseUri); // absolute path if ('/' === $uri[0]) { @@ -194,4 +183,48 @@ protected function setNode(\DOMNode $node) $this->node = $node; } + + /** + * Removes the query string and the anchor from the given uri. + * + * @param string $uri The uri to clean + * + * @return string + */ + private function cleanupUri($uri) + { + return $this->cleanupQuery($this->cleanupAnchor($uri)); + } + + /** + * Remove the query string from the uri. + * + * @param $uri + * + * @return array + */ + private function cleanupQuery($uri) + { + if (false !== $pos = strpos($uri, '?')) { + return substr($uri, 0, $pos); + } + + return $uri; + } + + /** + * Remove the anchor from the uri. + * + * @param $uri + * + * @return string + */ + private function cleanupAnchor($uri) + { + if (false !== $pos = strpos($uri, '#')) { + return substr($uri, 0, $pos); + } + + return $uri; + } } diff --git a/src/Symfony/Component/DomCrawler/Tests/LinkTest.php b/src/Symfony/Component/DomCrawler/Tests/LinkTest.php index a17142830fdf1..941e4b2f6dd2e 100644 --- a/src/Symfony/Component/DomCrawler/Tests/LinkTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/LinkTest.php @@ -101,7 +101,9 @@ public function getGetUriTests() array('', 'http://localhost/bar/', 'http://localhost/bar/'), array('#', 'http://localhost/bar/', 'http://localhost/bar/#'), + array('#bar', 'http://localhost/bar?a=b', 'http://localhost/bar?a=b#bar'), array('#bar', 'http://localhost/bar/#foo', 'http://localhost/bar/#bar'), + array('?a=b', 'http://localhost/bar#foo', 'http://localhost/bar?a=b'), array('?a=b', 'http://localhost/bar/', 'http://localhost/bar/?a=b'), array('http://login.foo.com/foo', 'http://localhost/bar/', 'http://login.foo.com/foo'), @@ -135,6 +137,8 @@ public function getGetUriTests() array('../../', 'http://localhost/', 'http://localhost/'), array('../../', 'http://localhost', 'http://localhost/'), + array('/foo', 'http://localhost?bar=1', 'http://localhost/foo'), + array('/foo', 'http://localhost#bar', 'http://localhost/foo'), array('/foo', 'file:///', 'file:///foo'), array('/foo', 'file:///bar/baz', 'file:///foo'), array('foo', 'file:///', 'file:///foo'), From 5cbe13e371783e3c46eea6440f6695e2a38d2476 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Thu, 3 Jul 2014 23:56:58 +0100 Subject: [PATCH 1119/1305] [DomCrawler] Fix docblocks and formatting. --- src/Symfony/Component/DomCrawler/Link.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/DomCrawler/Link.php b/src/Symfony/Component/DomCrawler/Link.php index 57cf2b4f211e0..3eb9e8d50ba06 100644 --- a/src/Symfony/Component/DomCrawler/Link.php +++ b/src/Symfony/Component/DomCrawler/Link.php @@ -24,10 +24,12 @@ class Link * @var \DOMNode A \DOMNode instance */ protected $node; + /** * @var string The method to use for the link */ protected $method; + /** * @var string The URI of the page where the link is embedded (or the base href) */ @@ -187,7 +189,7 @@ protected function setNode(\DOMNode $node) /** * Removes the query string and the anchor from the given uri. * - * @param string $uri The uri to clean + * @param string $uri The uri to clean * * @return string */ @@ -199,9 +201,9 @@ private function cleanupUri($uri) /** * Remove the query string from the uri. * - * @param $uri + * @param string $uri * - * @return array + * @return string */ private function cleanupQuery($uri) { @@ -215,7 +217,7 @@ private function cleanupQuery($uri) /** * Remove the anchor from the uri. * - * @param $uri + * @param string $uri * * @return string */ From b74afe0700c570afa1488f43eb5e1ec0ab83be25 Mon Sep 17 00:00:00 2001 From: Michele Orselli Date: Fri, 27 Jun 2014 18:35:29 +0200 Subject: [PATCH 1120/1305] updated italian translation for validation messages --- .../Resources/translations/validators.it.xlf | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf index e0a8e453fce54..11db4d8743f1c 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf @@ -246,6 +246,62 @@ This value is not a valid currency. Questo valore non è una valuta valida. + + This value should be equal to {{ compared_value }}. + Questo valore dovrebbe essere uguale a {{ compared_value }}. + + + This value should be greater than {{ compared_value }}. + Questo valore dovrebbe essere maggiore di {{ compared_value }}. + + + This value should be greater than or equal to {{ compared_value }}. + Questo valore dovrebbe essere maggiore o uguale a {{ compared_value }}. + + + This value should be identical to {{ compared_value_type }} {{ compared_value }}. + Questo valore dovrebbe essere identico a {{ compared_value_type }} {{ compared_value }}. + + + This value should be less than {{ compared_value }}. + Questo valore dovrebbe essere minore di {{ compared_value }}. + + + This value should be less than or equal to {{ compared_value }}. + Questo valore dovrebbe essere minore o uguale a {{ compared_value }}. + + + This value should not be equal to {{ compared_value }}. + Questo valore dovrebbe essere diverso da {{ compared_value }}. + + + This value should not be identical to {{ compared_value_type }} {{ compared_value }}. + Questo valore dovrebbe essere diverso da {{ compared_value_type }} {{ compared_value }}. + + + The image ratio is too big ({{ ratio }}). Allowed maximum ratio is {{ max_ratio }}. + Il rapporto di aspetto dell'immagine è troppo grande ({{ ratio }}). Il rapporto massimo consentito è {{ max_ratio }}. + + + The image ratio is too small ({{ ratio }}). Minimum ratio expected is {{ min_ratio }}. + Il rapporto di aspetto dell'immagine è troppo piccolo ({{ ratio }}). Il rapporto minimo consentito è {{ min_ratio }}. + + + The image is square ({{ width }}x{{ height }}px). Square images are not allowed. + L'immagine è quadrata ({{ width }}x{{ height }}px). Le immagini quadrate non sono consentite. + + + The image is landscape oriented ({{ width }}x{{ height }}px). Landscape oriented images are not allowed. + L'immagine è orizzontale ({{ width }}x{{ height }}px). Le immagini orizzontali non sono consentite. + + + The image is portrait oriented ({{ width }}x{{ height }}px). Portrait oriented images are not allowed. + L'immagine è verticale ({{ width }}x{{ height }}px). Le immagini verticali non sono consentite. + + + An empty file is not allowed. + Un file vuoto non è consentito. + From 816a4a9ff11cfd4923318aae14672f485611248a Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Thu, 26 Jun 2014 13:49:13 +0000 Subject: [PATCH 1121/1305] [Translation] Added unescaping of ids in PoFileLoader --- .../Translation/Loader/PoFileLoader.php | 6 ++--- .../Tests/Loader/PoFileLoaderTest.php | 24 +++++++++++++++++++ .../Tests/fixtures/escaped-id-plurals.po | 10 ++++++++ .../Translation/Tests/fixtures/escaped-id.po | 8 +++++++ 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 src/Symfony/Component/Translation/Tests/fixtures/escaped-id-plurals.po create mode 100644 src/Symfony/Component/Translation/Tests/fixtures/escaped-id.po diff --git a/src/Symfony/Component/Translation/Loader/PoFileLoader.php b/src/Symfony/Component/Translation/Loader/PoFileLoader.php index 8ba96680aa544..a1aff1a872476 100644 --- a/src/Symfony/Component/Translation/Loader/PoFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/PoFileLoader.php @@ -157,7 +157,7 @@ private function parse($resource) private function addMessage(array &$messages, array $item) { if (is_array($item['translated'])) { - $messages[$item['ids']['singular']] = stripcslashes($item['translated'][0]); + $messages[stripcslashes($item['ids']['singular'])] = stripcslashes($item['translated'][0]); if (isset($item['ids']['plural'])) { $plurals = $item['translated']; // PO are by definition indexed so sort by index. @@ -169,10 +169,10 @@ private function addMessage(array &$messages, array $item) $empties = array_fill(0, $count+1, '-'); $plurals += $empties; ksort($plurals); - $messages[$item['ids']['plural']] = stripcslashes(implode('|', $plurals)); + $messages[stripcslashes($item['ids']['plural'])] = stripcslashes(implode('|', $plurals)); } } elseif (!empty($item['ids']['singular'])) { - $messages[$item['ids']['singular']] = stripcslashes($item['translated']); + $messages[stripcslashes($item['ids']['singular'])] = stripcslashes($item['translated']); } } } diff --git a/src/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php index cd3d85a1a14bc..92fc58b188e7a 100644 --- a/src/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php +++ b/src/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php @@ -76,4 +76,28 @@ public function testLoadEmptyTranslation() $this->assertEquals('en', $catalogue->getLocale()); $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources()); } + + public function testEscapedId() + { + $loader = new PoFileLoader(); + $resource = __DIR__.'/../fixtures/escaped-id.po'; + $catalogue = $loader->load($resource, 'en', 'domain1'); + + $messages = $catalogue->all('domain1'); + $this->assertArrayHasKey('escaped "foo"', $messages); + $this->assertEquals('escaped "bar"', $messages['escaped "foo"']); + } + + public function testEscapedIdPlurals() + { + $loader = new PoFileLoader(); + $resource = __DIR__.'/../fixtures/escaped-id-plurals.po'; + $catalogue = $loader->load($resource, 'en', 'domain1'); + + $messages = $catalogue->all('domain1'); + $this->assertArrayHasKey('escaped "foo"', $messages); + $this->assertArrayHasKey('escaped "foos"', $messages); + $this->assertEquals('escaped "bar"', $messages['escaped "foo"']); + $this->assertEquals('escaped "bar"|escaped "bars"', $messages['escaped "foos"']); + } } diff --git a/src/Symfony/Component/Translation/Tests/fixtures/escaped-id-plurals.po b/src/Symfony/Component/Translation/Tests/fixtures/escaped-id-plurals.po new file mode 100644 index 0000000000000..c412aa26ec89c --- /dev/null +++ b/src/Symfony/Component/Translation/Tests/fixtures/escaped-id-plurals.po @@ -0,0 +1,10 @@ +msgid "" +msgstr "" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: en\n" + +msgid "escaped \"foo\"" +msgid_plural "escaped \"foos\"" +msgstr[0] "escaped \"bar\"" +msgstr[1] "escaped \"bars\"" diff --git a/src/Symfony/Component/Translation/Tests/fixtures/escaped-id.po b/src/Symfony/Component/Translation/Tests/fixtures/escaped-id.po new file mode 100644 index 0000000000000..308eadd92659e --- /dev/null +++ b/src/Symfony/Component/Translation/Tests/fixtures/escaped-id.po @@ -0,0 +1,8 @@ +msgid "" +msgstr "" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: en\n" + +msgid "escaped \"foo\"" +msgstr "escaped \"bar\"" From eb63270bab655190548f8c43d35b4e0177a7a734 Mon Sep 17 00:00:00 2001 From: Christian Lopez Espinola Date: Sat, 5 Jul 2014 17:36:34 +0200 Subject: [PATCH 1122/1305] bug #11319 [HttpKernel] Ensure the storage exists before purging it in ProfilerTest --- .../Component/HttpKernel/Tests/Profiler/ProfilerTest.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Tests/Profiler/ProfilerTest.php b/src/Symfony/Component/HttpKernel/Tests/Profiler/ProfilerTest.php index bf9724aa2aca8..eee1a366587ca 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Profiler/ProfilerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Profiler/ProfilerTest.php @@ -79,9 +79,11 @@ protected function setUp() protected function tearDown() { - $this->storage->purge(); - $this->storage = null; + if (null !== $this->storage) { + $this->storage->purge(); + $this->storage = null; - @unlink($this->tmp); + @unlink($this->tmp); + } } } From 84b558152131a378cd20ebefee6086bb4c420524 Mon Sep 17 00:00:00 2001 From: Christian Raue Date: Sun, 6 Jul 2014 11:04:43 +0200 Subject: [PATCH 1123/1305] added XSD to PHPUnit configuration --- phpunit.xml.dist | 5 +++-- src/Symfony/Bridge/Doctrine/phpunit.xml.dist | 5 +++-- src/Symfony/Bridge/Monolog/phpunit.xml.dist | 5 +++-- src/Symfony/Bridge/Propel1/phpunit.xml.dist | 5 +++-- .../Bridge/ProxyManager/phpunit.xml.dist | 22 +++++++++---------- src/Symfony/Bridge/Twig/phpunit.xml.dist | 5 +++-- .../Bundle/FrameworkBundle/phpunit.xml.dist | 5 +++-- .../Bundle/SecurityBundle/phpunit.xml.dist | 5 +++-- .../Bundle/TwigBundle/phpunit.xml.dist | 5 +++-- .../Bundle/WebProfilerBundle/phpunit.xml.dist | 5 +++-- .../Component/BrowserKit/phpunit.xml.dist | 5 +++-- .../Component/ClassLoader/phpunit.xml.dist | 5 +++-- src/Symfony/Component/Config/phpunit.xml.dist | 5 +++-- .../Component/Console/phpunit.xml.dist | 5 +++-- .../Component/CssSelector/phpunit.xml.dist | 5 +++-- src/Symfony/Component/Debug/phpunit.xml.dist | 5 +++-- .../DependencyInjection/phpunit.xml.dist | 5 +++-- .../Component/DomCrawler/phpunit.xml.dist | 5 +++-- .../EventDispatcher/phpunit.xml.dist | 5 +++-- .../Component/Filesystem/phpunit.xml.dist | 5 +++-- src/Symfony/Component/Finder/phpunit.xml.dist | 5 +++-- src/Symfony/Component/Form/phpunit.xml.dist | 5 +++-- .../Component/HttpFoundation/phpunit.xml.dist | 5 +++-- .../Component/HttpKernel/phpunit.xml.dist | 5 +++-- src/Symfony/Component/Intl/phpunit.xml.dist | 5 +++-- src/Symfony/Component/Locale/phpunit.xml.dist | 5 +++-- .../OptionsResolver/phpunit.xml.dist | 5 +++-- .../Component/Process/phpunit.xml.dist | 5 +++-- .../Component/PropertyAccess/phpunit.xml.dist | 5 +++-- .../Component/Routing/phpunit.xml.dist | 5 +++-- .../Component/Security/phpunit.xml.dist | 5 +++-- .../Component/Serializer/phpunit.xml.dist | 5 +++-- .../Component/Stopwatch/phpunit.xml.dist | 5 +++-- .../Component/Templating/phpunit.xml.dist | 5 +++-- .../Component/Translation/phpunit.xml.dist | 5 +++-- .../Component/Validator/phpunit.xml.dist | 5 +++-- src/Symfony/Component/Yaml/phpunit.xml.dist | 5 +++-- 37 files changed, 119 insertions(+), 83 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 823b03f7c0d72..74dd3bdda2d0e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Bridge/Doctrine/phpunit.xml.dist b/src/Symfony/Bridge/Doctrine/phpunit.xml.dist index c8f58f3232207..9958a1e696e70 100644 --- a/src/Symfony/Bridge/Doctrine/phpunit.xml.dist +++ b/src/Symfony/Bridge/Doctrine/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Bridge/Monolog/phpunit.xml.dist b/src/Symfony/Bridge/Monolog/phpunit.xml.dist index 9dca6482fc0d5..d7efb8e2c9bfb 100644 --- a/src/Symfony/Bridge/Monolog/phpunit.xml.dist +++ b/src/Symfony/Bridge/Monolog/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Bridge/Propel1/phpunit.xml.dist b/src/Symfony/Bridge/Propel1/phpunit.xml.dist index 7a5c82b5fffed..2d2791f5db2b6 100644 --- a/src/Symfony/Bridge/Propel1/phpunit.xml.dist +++ b/src/Symfony/Bridge/Propel1/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Bridge/ProxyManager/phpunit.xml.dist b/src/Symfony/Bridge/ProxyManager/phpunit.xml.dist index 5e7c4337f91b5..0df7655a0c77c 100644 --- a/src/Symfony/Bridge/ProxyManager/phpunit.xml.dist +++ b/src/Symfony/Bridge/ProxyManager/phpunit.xml.dist @@ -1,16 +1,16 @@ - diff --git a/src/Symfony/Bridge/Twig/phpunit.xml.dist b/src/Symfony/Bridge/Twig/phpunit.xml.dist index cc9e0e86b19bd..94215c4408f1c 100644 --- a/src/Symfony/Bridge/Twig/phpunit.xml.dist +++ b/src/Symfony/Bridge/Twig/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Bundle/FrameworkBundle/phpunit.xml.dist b/src/Symfony/Bundle/FrameworkBundle/phpunit.xml.dist index 663faf41e838e..58e2a75999033 100644 --- a/src/Symfony/Bundle/FrameworkBundle/phpunit.xml.dist +++ b/src/Symfony/Bundle/FrameworkBundle/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Bundle/SecurityBundle/phpunit.xml.dist b/src/Symfony/Bundle/SecurityBundle/phpunit.xml.dist index 2cffc1e59e9e2..40d28e33604c9 100644 --- a/src/Symfony/Bundle/SecurityBundle/phpunit.xml.dist +++ b/src/Symfony/Bundle/SecurityBundle/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Bundle/TwigBundle/phpunit.xml.dist b/src/Symfony/Bundle/TwigBundle/phpunit.xml.dist index 56e10bdad3fba..c175c0cf39af4 100644 --- a/src/Symfony/Bundle/TwigBundle/phpunit.xml.dist +++ b/src/Symfony/Bundle/TwigBundle/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Bundle/WebProfilerBundle/phpunit.xml.dist b/src/Symfony/Bundle/WebProfilerBundle/phpunit.xml.dist index 7750cbdff74c2..f193c99acfa4f 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/phpunit.xml.dist +++ b/src/Symfony/Bundle/WebProfilerBundle/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/BrowserKit/phpunit.xml.dist b/src/Symfony/Component/BrowserKit/phpunit.xml.dist index 8dff1ea1f99d5..ae508db7481e5 100644 --- a/src/Symfony/Component/BrowserKit/phpunit.xml.dist +++ b/src/Symfony/Component/BrowserKit/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/ClassLoader/phpunit.xml.dist b/src/Symfony/Component/ClassLoader/phpunit.xml.dist index 0d29c115323ee..182c597c896b6 100644 --- a/src/Symfony/Component/ClassLoader/phpunit.xml.dist +++ b/src/Symfony/Component/ClassLoader/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/Config/phpunit.xml.dist b/src/Symfony/Component/Config/phpunit.xml.dist index 7ba6e55234471..d6cdbe736505a 100644 --- a/src/Symfony/Component/Config/phpunit.xml.dist +++ b/src/Symfony/Component/Config/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/Console/phpunit.xml.dist b/src/Symfony/Component/Console/phpunit.xml.dist index 8a7edd46af51b..e90c5ce5ddbb5 100644 --- a/src/Symfony/Component/Console/phpunit.xml.dist +++ b/src/Symfony/Component/Console/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/CssSelector/phpunit.xml.dist b/src/Symfony/Component/CssSelector/phpunit.xml.dist index a19dc00b348f1..c015e7ef6d47e 100644 --- a/src/Symfony/Component/CssSelector/phpunit.xml.dist +++ b/src/Symfony/Component/CssSelector/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/Debug/phpunit.xml.dist b/src/Symfony/Component/Debug/phpunit.xml.dist index 8bab165e10537..31324f26e708a 100644 --- a/src/Symfony/Component/Debug/phpunit.xml.dist +++ b/src/Symfony/Component/Debug/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/DependencyInjection/phpunit.xml.dist b/src/Symfony/Component/DependencyInjection/phpunit.xml.dist index 53f5f99d6002f..36f4d0b4b50b4 100644 --- a/src/Symfony/Component/DependencyInjection/phpunit.xml.dist +++ b/src/Symfony/Component/DependencyInjection/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/DomCrawler/phpunit.xml.dist b/src/Symfony/Component/DomCrawler/phpunit.xml.dist index 0f8d2da7575cb..7c8f58bab2bf6 100644 --- a/src/Symfony/Component/DomCrawler/phpunit.xml.dist +++ b/src/Symfony/Component/DomCrawler/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/EventDispatcher/phpunit.xml.dist b/src/Symfony/Component/EventDispatcher/phpunit.xml.dist index 0c3de4f7b214e..a3e430dde8a9c 100644 --- a/src/Symfony/Component/EventDispatcher/phpunit.xml.dist +++ b/src/Symfony/Component/EventDispatcher/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/Filesystem/phpunit.xml.dist b/src/Symfony/Component/Filesystem/phpunit.xml.dist index ef0bf954137ec..9612e394f3a13 100644 --- a/src/Symfony/Component/Filesystem/phpunit.xml.dist +++ b/src/Symfony/Component/Filesystem/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/Finder/phpunit.xml.dist b/src/Symfony/Component/Finder/phpunit.xml.dist index 23272235b9693..54bde1eef86ce 100644 --- a/src/Symfony/Component/Finder/phpunit.xml.dist +++ b/src/Symfony/Component/Finder/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/Form/phpunit.xml.dist b/src/Symfony/Component/Form/phpunit.xml.dist index d0d261f194298..83736cbe5feb7 100644 --- a/src/Symfony/Component/Form/phpunit.xml.dist +++ b/src/Symfony/Component/Form/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/HttpFoundation/phpunit.xml.dist b/src/Symfony/Component/HttpFoundation/phpunit.xml.dist index df11f72c0ff3b..6fdeb6abbbb5e 100644 --- a/src/Symfony/Component/HttpFoundation/phpunit.xml.dist +++ b/src/Symfony/Component/HttpFoundation/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/HttpKernel/phpunit.xml.dist b/src/Symfony/Component/HttpKernel/phpunit.xml.dist index f8490c3f9e663..a6d1f071fdfb8 100644 --- a/src/Symfony/Component/HttpKernel/phpunit.xml.dist +++ b/src/Symfony/Component/HttpKernel/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/Intl/phpunit.xml.dist b/src/Symfony/Component/Intl/phpunit.xml.dist index 5e709f137f60a..0e6e13fd4e9d7 100644 --- a/src/Symfony/Component/Intl/phpunit.xml.dist +++ b/src/Symfony/Component/Intl/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/Locale/phpunit.xml.dist b/src/Symfony/Component/Locale/phpunit.xml.dist index ebaa3ef8d0d5e..0180f7bb3f983 100644 --- a/src/Symfony/Component/Locale/phpunit.xml.dist +++ b/src/Symfony/Component/Locale/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/OptionsResolver/phpunit.xml.dist b/src/Symfony/Component/OptionsResolver/phpunit.xml.dist index ad24d17ba8108..d855fc9ba41e6 100644 --- a/src/Symfony/Component/OptionsResolver/phpunit.xml.dist +++ b/src/Symfony/Component/OptionsResolver/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/Process/phpunit.xml.dist b/src/Symfony/Component/Process/phpunit.xml.dist index 9d5830f9e24e9..f77a3f8bc00cc 100644 --- a/src/Symfony/Component/Process/phpunit.xml.dist +++ b/src/Symfony/Component/Process/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/PropertyAccess/phpunit.xml.dist b/src/Symfony/Component/PropertyAccess/phpunit.xml.dist index 8799eaccf59f6..760b76a5bb8e0 100644 --- a/src/Symfony/Component/PropertyAccess/phpunit.xml.dist +++ b/src/Symfony/Component/PropertyAccess/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/Routing/phpunit.xml.dist b/src/Symfony/Component/Routing/phpunit.xml.dist index 830066aab59b4..5f91149105a0c 100644 --- a/src/Symfony/Component/Routing/phpunit.xml.dist +++ b/src/Symfony/Component/Routing/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/Security/phpunit.xml.dist b/src/Symfony/Component/Security/phpunit.xml.dist index f45a44ec5a3d3..875857fea5d5e 100644 --- a/src/Symfony/Component/Security/phpunit.xml.dist +++ b/src/Symfony/Component/Security/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/Serializer/phpunit.xml.dist b/src/Symfony/Component/Serializer/phpunit.xml.dist index 691219da83c16..83cb47d12c7b3 100644 --- a/src/Symfony/Component/Serializer/phpunit.xml.dist +++ b/src/Symfony/Component/Serializer/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/Stopwatch/phpunit.xml.dist b/src/Symfony/Component/Stopwatch/phpunit.xml.dist index d3b5ba7cea666..f7805624c0387 100644 --- a/src/Symfony/Component/Stopwatch/phpunit.xml.dist +++ b/src/Symfony/Component/Stopwatch/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/Templating/phpunit.xml.dist b/src/Symfony/Component/Templating/phpunit.xml.dist index 89288dd30e6ba..e71dc18e8c574 100644 --- a/src/Symfony/Component/Templating/phpunit.xml.dist +++ b/src/Symfony/Component/Templating/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/Translation/phpunit.xml.dist b/src/Symfony/Component/Translation/phpunit.xml.dist index 1b37f2142a247..cba02055e71ec 100644 --- a/src/Symfony/Component/Translation/phpunit.xml.dist +++ b/src/Symfony/Component/Translation/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/Validator/phpunit.xml.dist b/src/Symfony/Component/Validator/phpunit.xml.dist index c7f1cef07028a..d2a0ec7e18b75 100644 --- a/src/Symfony/Component/Validator/phpunit.xml.dist +++ b/src/Symfony/Component/Validator/phpunit.xml.dist @@ -1,6 +1,8 @@ - diff --git a/src/Symfony/Component/Yaml/phpunit.xml.dist b/src/Symfony/Component/Yaml/phpunit.xml.dist index aa77e9de77ce0..9894db629b890 100644 --- a/src/Symfony/Component/Yaml/phpunit.xml.dist +++ b/src/Symfony/Component/Yaml/phpunit.xml.dist @@ -1,6 +1,8 @@ - From afc49309009d8723ae0cc8012c8b480600955294 Mon Sep 17 00:00:00 2001 From: Christian Raue Date: Mon, 7 Jul 2014 12:13:42 +0200 Subject: [PATCH 1124/1305] removed defaults from PHPUnit configuration --- phpunit.xml.dist | 6 ------ src/Symfony/Bridge/Doctrine/phpunit.xml.dist | 6 ------ src/Symfony/Bridge/Monolog/phpunit.xml.dist | 6 ------ src/Symfony/Bridge/Propel1/phpunit.xml.dist | 6 ------ src/Symfony/Bridge/ProxyManager/phpunit.xml.dist | 6 ------ src/Symfony/Bridge/Twig/phpunit.xml.dist | 6 ------ src/Symfony/Bundle/FrameworkBundle/phpunit.xml.dist | 6 ------ src/Symfony/Bundle/SecurityBundle/phpunit.xml.dist | 6 ------ src/Symfony/Bundle/TwigBundle/phpunit.xml.dist | 6 ------ src/Symfony/Bundle/WebProfilerBundle/phpunit.xml.dist | 6 ------ src/Symfony/Component/BrowserKit/phpunit.xml.dist | 6 ------ src/Symfony/Component/ClassLoader/phpunit.xml.dist | 6 ------ src/Symfony/Component/Config/phpunit.xml.dist | 6 ------ src/Symfony/Component/Console/phpunit.xml.dist | 6 ------ src/Symfony/Component/CssSelector/phpunit.xml.dist | 6 ------ src/Symfony/Component/Debug/phpunit.xml.dist | 6 ------ src/Symfony/Component/DependencyInjection/phpunit.xml.dist | 6 ------ src/Symfony/Component/DomCrawler/phpunit.xml.dist | 6 ------ src/Symfony/Component/EventDispatcher/phpunit.xml.dist | 6 ------ src/Symfony/Component/Filesystem/phpunit.xml.dist | 6 ------ src/Symfony/Component/Finder/phpunit.xml.dist | 6 ------ src/Symfony/Component/Form/phpunit.xml.dist | 6 ------ src/Symfony/Component/HttpFoundation/phpunit.xml.dist | 6 ------ src/Symfony/Component/HttpKernel/phpunit.xml.dist | 6 ------ src/Symfony/Component/Intl/phpunit.xml.dist | 6 ------ src/Symfony/Component/Locale/phpunit.xml.dist | 6 ------ src/Symfony/Component/OptionsResolver/phpunit.xml.dist | 6 ------ src/Symfony/Component/Process/phpunit.xml.dist | 6 ------ src/Symfony/Component/PropertyAccess/phpunit.xml.dist | 6 ------ src/Symfony/Component/Routing/phpunit.xml.dist | 6 ------ src/Symfony/Component/Security/phpunit.xml.dist | 6 ------ src/Symfony/Component/Serializer/phpunit.xml.dist | 6 ------ src/Symfony/Component/Stopwatch/phpunit.xml.dist | 6 ------ src/Symfony/Component/Templating/phpunit.xml.dist | 6 ------ src/Symfony/Component/Translation/phpunit.xml.dist | 6 ------ src/Symfony/Component/Validator/phpunit.xml.dist | 6 ------ src/Symfony/Component/Yaml/phpunit.xml.dist | 6 ------ 37 files changed, 222 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 74dd3bdda2d0e..0a5ed5cfaa807 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Bridge/Doctrine/phpunit.xml.dist b/src/Symfony/Bridge/Doctrine/phpunit.xml.dist index 9958a1e696e70..f7f3d49ac035a 100644 --- a/src/Symfony/Bridge/Doctrine/phpunit.xml.dist +++ b/src/Symfony/Bridge/Doctrine/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Bridge/Monolog/phpunit.xml.dist b/src/Symfony/Bridge/Monolog/phpunit.xml.dist index d7efb8e2c9bfb..1afee95c4e4eb 100644 --- a/src/Symfony/Bridge/Monolog/phpunit.xml.dist +++ b/src/Symfony/Bridge/Monolog/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Bridge/Propel1/phpunit.xml.dist b/src/Symfony/Bridge/Propel1/phpunit.xml.dist index 2d2791f5db2b6..a2e9ba2b93b88 100644 --- a/src/Symfony/Bridge/Propel1/phpunit.xml.dist +++ b/src/Symfony/Bridge/Propel1/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Bridge/ProxyManager/phpunit.xml.dist b/src/Symfony/Bridge/ProxyManager/phpunit.xml.dist index 0df7655a0c77c..0314075d3c183 100644 --- a/src/Symfony/Bridge/ProxyManager/phpunit.xml.dist +++ b/src/Symfony/Bridge/ProxyManager/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Bridge/Twig/phpunit.xml.dist b/src/Symfony/Bridge/Twig/phpunit.xml.dist index 94215c4408f1c..645101a5b8a76 100644 --- a/src/Symfony/Bridge/Twig/phpunit.xml.dist +++ b/src/Symfony/Bridge/Twig/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Bundle/FrameworkBundle/phpunit.xml.dist b/src/Symfony/Bundle/FrameworkBundle/phpunit.xml.dist index 58e2a75999033..e01faa1316de4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/phpunit.xml.dist +++ b/src/Symfony/Bundle/FrameworkBundle/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Bundle/SecurityBundle/phpunit.xml.dist b/src/Symfony/Bundle/SecurityBundle/phpunit.xml.dist index 40d28e33604c9..ffad320be557c 100644 --- a/src/Symfony/Bundle/SecurityBundle/phpunit.xml.dist +++ b/src/Symfony/Bundle/SecurityBundle/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Bundle/TwigBundle/phpunit.xml.dist b/src/Symfony/Bundle/TwigBundle/phpunit.xml.dist index c175c0cf39af4..67921d2bea916 100644 --- a/src/Symfony/Bundle/TwigBundle/phpunit.xml.dist +++ b/src/Symfony/Bundle/TwigBundle/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Bundle/WebProfilerBundle/phpunit.xml.dist b/src/Symfony/Bundle/WebProfilerBundle/phpunit.xml.dist index f193c99acfa4f..712fa0b308c64 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/phpunit.xml.dist +++ b/src/Symfony/Bundle/WebProfilerBundle/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/BrowserKit/phpunit.xml.dist b/src/Symfony/Component/BrowserKit/phpunit.xml.dist index ae508db7481e5..51a0f31d18ab3 100644 --- a/src/Symfony/Component/BrowserKit/phpunit.xml.dist +++ b/src/Symfony/Component/BrowserKit/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/ClassLoader/phpunit.xml.dist b/src/Symfony/Component/ClassLoader/phpunit.xml.dist index 182c597c896b6..3602188f09af7 100644 --- a/src/Symfony/Component/ClassLoader/phpunit.xml.dist +++ b/src/Symfony/Component/ClassLoader/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/Config/phpunit.xml.dist b/src/Symfony/Component/Config/phpunit.xml.dist index d6cdbe736505a..9b13467ddb318 100644 --- a/src/Symfony/Component/Config/phpunit.xml.dist +++ b/src/Symfony/Component/Config/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/Console/phpunit.xml.dist b/src/Symfony/Component/Console/phpunit.xml.dist index e90c5ce5ddbb5..13e0f33748186 100644 --- a/src/Symfony/Component/Console/phpunit.xml.dist +++ b/src/Symfony/Component/Console/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/CssSelector/phpunit.xml.dist b/src/Symfony/Component/CssSelector/phpunit.xml.dist index c015e7ef6d47e..3eb0a1ece0c36 100644 --- a/src/Symfony/Component/CssSelector/phpunit.xml.dist +++ b/src/Symfony/Component/CssSelector/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/Debug/phpunit.xml.dist b/src/Symfony/Component/Debug/phpunit.xml.dist index 31324f26e708a..2a8cb8143e1a6 100644 --- a/src/Symfony/Component/Debug/phpunit.xml.dist +++ b/src/Symfony/Component/Debug/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/DependencyInjection/phpunit.xml.dist b/src/Symfony/Component/DependencyInjection/phpunit.xml.dist index 36f4d0b4b50b4..d636cde6dc9f9 100644 --- a/src/Symfony/Component/DependencyInjection/phpunit.xml.dist +++ b/src/Symfony/Component/DependencyInjection/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/DomCrawler/phpunit.xml.dist b/src/Symfony/Component/DomCrawler/phpunit.xml.dist index 7c8f58bab2bf6..9be3b45ab1ffa 100644 --- a/src/Symfony/Component/DomCrawler/phpunit.xml.dist +++ b/src/Symfony/Component/DomCrawler/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/EventDispatcher/phpunit.xml.dist b/src/Symfony/Component/EventDispatcher/phpunit.xml.dist index a3e430dde8a9c..cca1259b37938 100644 --- a/src/Symfony/Component/EventDispatcher/phpunit.xml.dist +++ b/src/Symfony/Component/EventDispatcher/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/Filesystem/phpunit.xml.dist b/src/Symfony/Component/Filesystem/phpunit.xml.dist index 9612e394f3a13..790283551c779 100644 --- a/src/Symfony/Component/Filesystem/phpunit.xml.dist +++ b/src/Symfony/Component/Filesystem/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/Finder/phpunit.xml.dist b/src/Symfony/Component/Finder/phpunit.xml.dist index 54bde1eef86ce..ccef55ac462fb 100644 --- a/src/Symfony/Component/Finder/phpunit.xml.dist +++ b/src/Symfony/Component/Finder/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/Form/phpunit.xml.dist b/src/Symfony/Component/Form/phpunit.xml.dist index 83736cbe5feb7..bd91d7b831ab1 100644 --- a/src/Symfony/Component/Form/phpunit.xml.dist +++ b/src/Symfony/Component/Form/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/HttpFoundation/phpunit.xml.dist b/src/Symfony/Component/HttpFoundation/phpunit.xml.dist index 6fdeb6abbbb5e..bbc5dc6dc8d7e 100644 --- a/src/Symfony/Component/HttpFoundation/phpunit.xml.dist +++ b/src/Symfony/Component/HttpFoundation/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/HttpKernel/phpunit.xml.dist b/src/Symfony/Component/HttpKernel/phpunit.xml.dist index a6d1f071fdfb8..f572ab27d3798 100644 --- a/src/Symfony/Component/HttpKernel/phpunit.xml.dist +++ b/src/Symfony/Component/HttpKernel/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/Intl/phpunit.xml.dist b/src/Symfony/Component/Intl/phpunit.xml.dist index 0e6e13fd4e9d7..4d4f32b0ab648 100644 --- a/src/Symfony/Component/Intl/phpunit.xml.dist +++ b/src/Symfony/Component/Intl/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/Locale/phpunit.xml.dist b/src/Symfony/Component/Locale/phpunit.xml.dist index 0180f7bb3f983..c72b2438a8680 100644 --- a/src/Symfony/Component/Locale/phpunit.xml.dist +++ b/src/Symfony/Component/Locale/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/OptionsResolver/phpunit.xml.dist b/src/Symfony/Component/OptionsResolver/phpunit.xml.dist index d855fc9ba41e6..42fa6df152de6 100644 --- a/src/Symfony/Component/OptionsResolver/phpunit.xml.dist +++ b/src/Symfony/Component/OptionsResolver/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/Process/phpunit.xml.dist b/src/Symfony/Component/Process/phpunit.xml.dist index f77a3f8bc00cc..fcb230a06259f 100644 --- a/src/Symfony/Component/Process/phpunit.xml.dist +++ b/src/Symfony/Component/Process/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/PropertyAccess/phpunit.xml.dist b/src/Symfony/Component/PropertyAccess/phpunit.xml.dist index 760b76a5bb8e0..cd114f81e8ffe 100644 --- a/src/Symfony/Component/PropertyAccess/phpunit.xml.dist +++ b/src/Symfony/Component/PropertyAccess/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/Routing/phpunit.xml.dist b/src/Symfony/Component/Routing/phpunit.xml.dist index 5f91149105a0c..8cf6352f3a5f7 100644 --- a/src/Symfony/Component/Routing/phpunit.xml.dist +++ b/src/Symfony/Component/Routing/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/Security/phpunit.xml.dist b/src/Symfony/Component/Security/phpunit.xml.dist index 875857fea5d5e..9c53c60896f46 100644 --- a/src/Symfony/Component/Security/phpunit.xml.dist +++ b/src/Symfony/Component/Security/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/Serializer/phpunit.xml.dist b/src/Symfony/Component/Serializer/phpunit.xml.dist index 83cb47d12c7b3..aa28252cab787 100644 --- a/src/Symfony/Component/Serializer/phpunit.xml.dist +++ b/src/Symfony/Component/Serializer/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/Stopwatch/phpunit.xml.dist b/src/Symfony/Component/Stopwatch/phpunit.xml.dist index f7805624c0387..1795afc19ae87 100644 --- a/src/Symfony/Component/Stopwatch/phpunit.xml.dist +++ b/src/Symfony/Component/Stopwatch/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/Templating/phpunit.xml.dist b/src/Symfony/Component/Templating/phpunit.xml.dist index e71dc18e8c574..fcb78e17e49a8 100644 --- a/src/Symfony/Component/Templating/phpunit.xml.dist +++ b/src/Symfony/Component/Templating/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/Translation/phpunit.xml.dist b/src/Symfony/Component/Translation/phpunit.xml.dist index cba02055e71ec..6392d3d5577fa 100644 --- a/src/Symfony/Component/Translation/phpunit.xml.dist +++ b/src/Symfony/Component/Translation/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/Validator/phpunit.xml.dist b/src/Symfony/Component/Validator/phpunit.xml.dist index d2a0ec7e18b75..3713ca85ada70 100644 --- a/src/Symfony/Component/Validator/phpunit.xml.dist +++ b/src/Symfony/Component/Validator/phpunit.xml.dist @@ -3,13 +3,7 @@ diff --git a/src/Symfony/Component/Yaml/phpunit.xml.dist b/src/Symfony/Component/Yaml/phpunit.xml.dist index 9894db629b890..90e0bcc27efe8 100644 --- a/src/Symfony/Component/Yaml/phpunit.xml.dist +++ b/src/Symfony/Component/Yaml/phpunit.xml.dist @@ -3,13 +3,7 @@ From d393ddd11a464d5949872aa913f67efd56e4894f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 7 Jul 2014 14:57:40 +0200 Subject: [PATCH 1125/1305] updated CHANGELOG for 2.3.17 --- CHANGELOG-2.3.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CHANGELOG-2.3.md b/CHANGELOG-2.3.md index 5ac62abb70cf4..9b0b1f994e1d4 100644 --- a/CHANGELOG-2.3.md +++ b/CHANGELOG-2.3.md @@ -7,6 +7,28 @@ in 2.3 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.3.0...v2.3.1 +* 2.3.17 (2014-07-07) + + * bug #11238 [Translation] Added unescaping of ids in PoFileLoader (JustBlackBird) + * bug #11194 [DomCrawler] Remove the query string and the anchor of the uri of a link (benja-M-1) + * bug #11272 [Console] Make sure formatter is the same. (akimsko) + * bug #11259 [Config] Fixed failed config schema loads due to libxml_disable_entity_loader usage (ccorliss) + * bug #11234 [ClassLoader] fixed PHP warning on PHP 5.3 (fabpot) + * bug #11179 [Process] Fix ExecutableFinder with open basedir (cs278) + * bug #11242 [CssSelector] Refactored the CssSelector to remove the circular object graph (stof) + * bug #11219 [DomCrawler] properly handle buttons with single and double quotes insid... (xabbuh) + * bug #11220 [Components][Serializer] optional constructor arguments can be omitted during the denormalization process (xabbuh) + * bug #11186 Added missing `break` statement (apfelbox) + * bug #11169 [Console] Fixed notice in DialogHelper (florianv) + * bug #11144 [HttpFoundation] Fixed Request::getPort returns incorrect value under IPv6 (kicken) + * bug #10966 PHP Fatal error when getContainer method of ContainerAwareCommand has be... (kevinvergauwen) + * bug #10981 [HttpFoundation] Fixed isSecure() check to be compliant with the docs (Jannik Zschiesche) + * bug #11092 [HttpFoundation] Fix basic authentication in url with PHP-FPM (Kdecherf) + * bug #10808 [DomCrawler] Empty select with attribute name="foo[]" bug fix (darles) + * bug #11063 [HttpFoundation] fix switch statement (Tobion) + * bug #11009 [HttpFoundation] smaller fixes for PdoSessionHandler (Tobion) + * bug #11041 Remove undefined variable $e (skydiablo) + * 2.3.16 (2014-05-31) * bug #11014 [Validator] Remove property and method targets from the optional and required constraints (jakzal) From c09ff16cbc92bad6b652e6a5e646cd105cc62b9f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 7 Jul 2014 14:58:57 +0200 Subject: [PATCH 1126/1305] update CONTRIBUTORS for 2.3.17 --- CONTRIBUTORS.md | 75 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index cb8fee8b7a06b..007ceffdf4759 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -9,21 +9,21 @@ Symfony2 is the result of the work of many people who made the code better - Victor Berchet (victor) - Jordi Boggiano (seldaek) - Johannes S (johannes) - - Kris Wallsmith (kriswallsmith) - Tobias Schultze (tobion) + - Kris Wallsmith (kriswallsmith) - Christophe Coevoet (stof) - Pascal Borreli (pborreli) - - Karma Dordrak (drak) - Jakub Zalas (jakubzalas) + - Karma Dordrak (drak) - Joseph Bielawski (stloyd) - Ryan Weaver (weaverryan) - Lukas Kahwe Smith (lsmith) - Jeremy Mikola (jmikola) - Jean-François Simon (jfsimon) + - Romain Neutron (romain) - Benjamin Eberlei (beberlei) - Igor Wiedler (igorw) - Hugo Hamon (hhamon) - - Romain Neutron (romain) - Eriksen Costa (eriksencosta) - Martin Hasoň (hason) - Jonathan Wage (jwage) @@ -35,14 +35,15 @@ Symfony2 is the result of the work of many people who made the code better - Bulat Shakirzyanov (avalanche123) - Grégoire Pineau (lyrixx) - Francis Besset (francisbesset) + - Saša Stamenković (umpirsky) - Miha Vrhovnik - Henrik Bjørnskov (henrikbjorn) - - Saša Stamenković (umpirsky) - Konstantin Kudryashov (everzet) - Bilal Amarni (bamarni) - Florin Patan (florinpatan) - Wouter De Jong (wouterj) - Eric Clemmons (ericclemmons) + - Nicolas Grekas (nicolas-grekas) - Deni - Henrik Westphal (snc) - Dariusz Górecki (canni) @@ -59,41 +60,43 @@ Symfony2 is the result of the work of many people who made the code better - Fran Moreno (franmomu) - Bart van den Burg (burgov) - Antoine Hérault (herzult) - - Nicolas Grekas (nicolas-grekas) - Toni Uebernickel (havvg) - Arnaud Le Blanc (arnaud-lb) - - Brice BERNARD (brikou) - Luis Cordova (cordoval) - - Tim Nagel (merk) - Kevin Bond (kbond) + - Brice BERNARD (brikou) + - Tim Nagel (merk) - marc.weistroff - lenar - Włodzimierz Gajda (gajdaw) - Colin Frei - excelwebzone + - Florian Voutzinos (florianv) - Fabien Pennequin (fabienpennequin) - Jacob Dreesen (jdreesen) - - Adrien Brault (adrienbrault) - Gábor Egyed (1ed) + - Adrien Brault (adrienbrault) - Michal Piotrowski (eventhorizon) - Ait Boudad Abdellatif (aitboudad) - - Florian Voutzinos (florianv) - Robert Schönthal (digitalkaoz) - Juti Noppornpitak (shiroyuki) - Sebastian Hörl (blogsh) - - Hidenori Goto (hidenorigoto) - Daniel Gomes (danielcsgomes) + - Hidenori Goto (hidenorigoto) - Peter Kokot (maastermedia) - Jérémie Augustin (jaugustin) - David Buchmann (dbu) - Jérôme Tamarelle (gromnan) - Tigran Azatyan (tigranazatyan) - Javier Eguiluz (javier.eguiluz) + - Christian Flothmann (xabbuh) - Rafael Dohms (rdohms) - Richard Shank (iampersistent) - Gordon Franke (gimler) + - Eric GELOEN (gelo) - Helmer Aaviksoo - Sebastiaan Stok (sstok) + - Hiromi Hishida (77web) - Matthieu Ouellette-Vachon (maoueh) - Michał Pipa (michal.pipa) - Amal Raghav (kertz) @@ -101,10 +104,9 @@ Symfony2 is the result of the work of many people who made the code better - Artur Kotyrba - Guilherme Blanco (guilhermeblanco) - Pablo Godel (pgodel) - - Eric GELOEN (gelo) + - Clemens Tolboom - Dmitrii Chekaliuk (lazyhammer) - Clément JOBEILI (dator) - - Hiromi Hishida (77web) - Dorian Villet (gnutix) - Richard Miller (mr_r_miller) - Arnaud Kleinpeter (nanocom) @@ -127,7 +129,6 @@ Symfony2 is the result of the work of many people who made the code better - François Zaninotto (fzaninotto) - Dustin Whittle (dustinwhittle) - jeff - - Clemens Tolboom - Justin Hileman (bobthecow) - Sven Paulus (subsven) - Andréia Bohner (andreia) @@ -141,6 +142,7 @@ Symfony2 is the result of the work of many people who made the code better - Francois Zaninotto - Alexander Kotynia (olden) - Daniel Tschinder + - Elnur Abdurrakhimov (elnur) - Manuel Reinhard (sprain) - Danny Berger (dpb587) - Xavier Montaña Carreras (xmontana) @@ -153,8 +155,8 @@ Symfony2 is the result of the work of many people who made the code better - Stefano Sala (stefano.sala) - Joseph Rouff (rouffj) - Félix Labrecque (woodspire) - - Christian Flothmann (xabbuh) - GordonsLondon + - Lars Strojny (lstrojny) - Jan Sorgalla (jsor) - Ray - Chekote @@ -162,7 +164,6 @@ Symfony2 is the result of the work of many people who made the code better - Albert Casademont (acasademont) - jdhoek - Wodor Wodorski - - Elnur Abdurrakhimov (elnur) - Beau Simensen (simensen) - Robert Kiss (kepten) - Kim Hemsø Rasmussen (kimhemsoe) @@ -172,9 +173,9 @@ Symfony2 is the result of the work of many people who made the code better - Marc Weistroff (futurecat) - Pierre-Yves LEBECQ (pylebecq) - Roman Marintšenko (inori) + - Chris Smith (cs278) - Florian Klein (docteurklein) - Manuel Kiessling (manuelkiessling) - - Lars Strojny (lstrojny) - Bertrand Zuchuat (garfield-fr) - Gabor Toth (tgabi333) - realmfoo @@ -194,6 +195,7 @@ Symfony2 is the result of the work of many people who made the code better - janschoenherr - Marco Pivetta (ocramius) - Ricard Clau (ricardclau) + - Kévin Dunglas (dunglas) - Erin Millard - Matthew Lewinski (lewinski) - alquerci @@ -219,6 +221,7 @@ Symfony2 is the result of the work of many people who made the code better - Greg Thornton (xdissent) - Atsuhiro KUBO (iteman) - Grégoire Paris (greg0ire) + - julien pauli (jpauli) - Costin Bereveanu (schniper) - Loïc Chardonnet (gnusat) - Marek Kalnik (marekkalnik) @@ -227,6 +230,7 @@ Symfony2 is the result of the work of many people who made the code better - Tobias Naumann (tna) - Ismael Ambrosi (iambrosi) - Shein Alexey + - Issei Murasawa (issei_m) - Joe Lencioni - Kai - Xavier HAUSHERR @@ -241,6 +245,7 @@ Symfony2 is the result of the work of many people who made the code better - Christophe L. (christophelau) - Anthon Pang (robocoder) - Jáchym Toušek + - Jannik Zschiesche (apfelbox) - Emanuele Gaspari (inmarelibero) - Brian King - Michel Salib (michelsalib) @@ -258,7 +263,6 @@ Symfony2 is the result of the work of many people who made the code better - Tobias Sjösten (tobiassjosten) - vagrant - Asier Illarramendi (doup) - - Kévin Dunglas (dunglas) - Christoph Mewes (xrstf) - Vitaliy Tverdokhlib (vitaliytv) - Dirk Pahl (dirkaholic) @@ -284,6 +288,7 @@ Symfony2 is the result of the work of many people who made the code better - Ricardo Oliveira (ricardolotr) - ondrowan - Andrew Moore (finewolf) + - Vyacheslav Salakhutdinov (megazoll) - Evan S Kaufman (evanskaufman) - mcben - Maks Slesarenko @@ -293,9 +298,9 @@ Symfony2 is the result of the work of many people who made the code better - Andrew Udvare (audvare) - alexpods - Erik Trapman (eriktrapman) + - hacfi (hifi) - De Cock Xavier (xdecock) - Alex Pott - - Issei Murasawa (issei_m) - Norbert Orzechowicz (norzechowicz) - Matthijs van den Bos (matthijs) - Nils Adermann (naderman) @@ -304,7 +309,6 @@ Symfony2 is the result of the work of many people who made the code better - sasezaki - Denis Gorbachev (starfall) - Steven Surowiec - - Chris Smith - Daniel Tschinder - Ryan - Alexander Deruwe (aderuwe) @@ -314,7 +318,6 @@ Symfony2 is the result of the work of many people who made the code better - Ned Schwartz - Ziumin - Lenar Lõhmus - - julien pauli (jpauli) - Zach Badgett (zachbadgett) - Aurélien Fredouelle - Karoly Negyesi (chx) @@ -325,6 +328,7 @@ Symfony2 is the result of the work of many people who made the code better - alcaeus - vitaliytv - Markus Bachmann (baachi) + - Jérémy DERUSSÉ (jderusse) - aubx - Ricky Su (ricky) - Gildas Quéméner (gquemener) @@ -356,6 +360,7 @@ Symfony2 is the result of the work of many people who made the code better - umpirski - Chris Heng (gigablah) - Ulumuddin Yunus (joenoez) + - Johann Saunier (prophet777) - Antoine Corcy - Arturs Vonda - Sascha Grossenbacher @@ -395,6 +400,7 @@ Symfony2 is the result of the work of many people who made the code better - Leevi Graham (leevigraham) - Casper Valdemar Poulsen - Josiah (josiah) + - Marek Štípek (maryo) - John Bohn (jbohn) - Jakub Škvára (jskvara) - Chris Wilkinson (thewilkybarkid) @@ -403,7 +409,7 @@ Symfony2 is the result of the work of many people who made the code better - Jérôme Vieilledent (lolautruche) - Degory Valentine - Benoit Lévêque (benoit_leveque) - - hacfi (hifi) + - Jeroen Fiege (fieg) - Krzysiek Łabuś - Xavier Lacot (xavier) - Olivier Maisonneuve (olineuve) @@ -494,6 +500,7 @@ Symfony2 is the result of the work of many people who made the code better - Anton Babenko (antonbabenko) - Irmantas Šiupšinskas (irmantas) - Danilo Silva + - Zachary Tong (polyfractal) - dantleech - Tero Alén (tero) - DerManoMann @@ -528,7 +535,6 @@ Symfony2 is the result of the work of many people who made the code better - Simon Schick (simonsimcity) - Christian - Sergii Smertin (nfx) - - Johann Saunier (prophet777) - Eddie Jaoude - Haritz Iturbe (hizai) - Nerijus Arlauskas (nercury) @@ -569,6 +575,7 @@ Symfony2 is the result of the work of many people who made the code better - Max Voloshin (maxvoloshin) - Nicolas Fabre (nfabre) - Raul Rodriguez (raul782) + - Patrick Landolt (scube) - Derek Lambert - Felicitus - Krzysztof Przybyszewski @@ -610,12 +617,14 @@ Symfony2 is the result of the work of many people who made the code better - Saem Ghani - Sebastian Utz - Karol Sójko (karolsojko) + - sl_toto (sl_toto) - Sébastien HOUZÉ - steveYeah - Samy Dindane (dinduks) - Keri Henare (kerihenare) - Cédric Lahouste (rapotor) - Samuel Vogel (samuelvogel) + - Berat Doğan - Anthony Ferrara - ShiraNai7 - Janusz Jabłoński (yanoosh) @@ -631,12 +640,15 @@ Symfony2 is the result of the work of many people who made the code better - caponica - Matt Daum (daum) - Alberto Pirovano (geezmo) + - Pete Mitchell (peterjmit) - Martin Pärtel - Evgeniy (ewgraf) - Patrick Daley (padrig) - Xavier Briand (xavierbriand) - Max Summe - WedgeSama + - Felds Liscia + - Tadcka - Beth Binkovitz - Romain Geissler - Marcus Stöhr (dafish) @@ -672,6 +684,7 @@ Symfony2 is the result of the work of many people who made the code better - Sebastian Ionescu - Thomas Ploch - Simon Neidhold + - Seb Koelen - Kevin Dew - James Cowgill - Jeremy Livingston (jeremylivingston) @@ -684,6 +697,7 @@ Symfony2 is the result of the work of many people who made the code better - Stelian Mocanita (stelian) - Flavian (2much) - mike + - Keith Maika - Mephistofeles - Hoffmann András - Olivier @@ -700,6 +714,7 @@ Symfony2 is the result of the work of many people who made the code better - Bouke Haarsma - Harm van Tilborg - Martin Eckhardt + - Denis Zunke - Jonathan Poston - Przemysław Piechota (kibao) - Leonid Terentyev (li0n) @@ -716,6 +731,7 @@ Symfony2 is the result of the work of many people who made the code better - Alexandre Segura - Josef Cech - Matthew Foster (mfoster) + - Maximilian Reichel (phramz) - Paul Seiffert (seiffert) - Vasily Khayrulin (sirian) - Stefan Koopmanschap (skoop) @@ -755,8 +771,10 @@ Symfony2 is the result of the work of many people who made the code better - Warwick - Chris - efeen + - Michał Dąbrowski (defrag) - Dominik Zogg (dominik.zogg) - Simone Fumagalli (hpatoio) + - Kevin Vergauwen (innocenzo) - Alessio Baglio (ioalessio) - John Bafford (jbafford) - Jérôme Macias (jeromemacias) @@ -776,6 +794,7 @@ Symfony2 is the result of the work of many people who made the code better - Bram Van der Sype (brammm) - Julien Moulin (lizjulien) - Matthieu Auger (matthieuauger) + - Kevin Decherf - dened - Sam Ward - devel @@ -786,6 +805,7 @@ Symfony2 is the result of the work of many people who made the code better - Drew Butler - J Bruni - Alexey Prilipko + - Hans Nilsson (hansnilsson) - Jan Marek (janmarek) - Mark de Haan (markdehaan) - Dan Patrick (mdpatrick) @@ -823,6 +843,7 @@ Symfony2 is the result of the work of many people who made the code better - Alan Chen - Maerlyn - Even André Fiskvik + - Diego Agulló - Lenar Lõhmus - Cristian Gonzalez - Juan M Martínez @@ -833,6 +854,7 @@ Symfony2 is the result of the work of many people who made the code better - Rafał - Adria Lopez (adlpz) - Masao Maeda (brtriver) + - Darius Leskauskas (darles) - Dave Hulbert (dave1010) - Dave Marshall (davedevelopment) - David Joos (djoos) @@ -844,7 +866,6 @@ Symfony2 is the result of the work of many people who made the code better - Ian Jenkins (jenkoian) - Jorge Martin (jorgemartind) - Kevin Herrera (kherge) - - Marek Štípek (maryo) - Matthew Davis (mdavis1982) - Muriel (metalmumu) - Michaël Perrin (michael.perrin) @@ -860,6 +881,7 @@ Symfony2 is the result of the work of many people who made the code better - Gladhon - Saem Ghani - Stefan Oderbolz + - Curtis - Alexey Popkov - Joseph Deray - Arnaud Buathier (arnapou) @@ -927,7 +949,6 @@ Symfony2 is the result of the work of many people who made the code better - Michael Squires - Matt Janssen - Peter Gribanov - - Chris Smith - kwiateusz - David Soria Parra - Sergiy Sokolenko @@ -949,8 +970,8 @@ Symfony2 is the result of the work of many people who made the code better - Nicolas Roudaire - Lee Rowlands - Andreas Forsblom (aforsblo) + - Alaattin Kahramanlar (alaattin) - Alex Olmos (alexolmos) - - Jannik Zschiesche (apfelbox) - Juan Ases García (ases) - Daniel Basten (axhm3a) - Bill Hance (billhance) @@ -975,6 +996,7 @@ Symfony2 is the result of the work of many people who made the code better - Vladislav Krupenkin (ideea) - joris de wit (jdewit) - Jérémy CROMBEZ (jeremy) + - Jose Manuel Gonzalez (jgonzalez) - Jorge Maiden (jorgemaiden) - Justin Rainbow (jrainbow) - JuntaTom (juntatom) @@ -998,9 +1020,11 @@ Symfony2 is the result of the work of many people who made the code better - Sebastian Busch (sebu) - André Filipe Gonçalves Neves (seven) - Andrea Giuliano (shark) + - Volker (skydiablo) - Julien Sanchez (sumbobyboys) - Guillermo Gisinger (t3chn0r) - Markus Tacker (tacker) + - Tristan Maindron (tmaindron) - Tyler Stroud (tystr) - Víctor Mateo (victormateo) - Vincent (vincent1870) @@ -1025,6 +1049,7 @@ Symfony2 is the result of the work of many people who made the code better - Muharrem Demirci (mdemirci) - Evgeny Z (meze) - Nicolas de Marqué (nicola) + - Kevin (oxfouzer) - Pierre Geyer (ptheg) - Erik Saunier (snickers) - Matej Žilák (teo_sk) From c02f56f7948f2699c8cc8b118c7faeb13470e357 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 7 Jul 2014 14:59:36 +0200 Subject: [PATCH 1127/1305] updated VERSION for 2.3.17 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 0e35a428ee69a..dbee2a5739840 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.3.17-DEV'; + const VERSION = '2.3.17'; const VERSION_ID = '20317'; const MAJOR_VERSION = '2'; const MINOR_VERSION = '3'; const RELEASE_VERSION = '17'; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; /** * Constructor. From ebf967de8f9cc2fe8ec10b9fa1243f5bfdf0385f Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Sun, 6 Jul 2014 15:41:58 +0200 Subject: [PATCH 1128/1305] [Form] Check if IntlDateFormatter constructor returned a valid object before using it --- .../DateTimeToLocalizedStringTransformer.php | 8 ++++++++ .../Component/Form/Extension/Core/Type/DateType.php | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php index 56a3ca928b0cb..e992b01fc1797 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php @@ -152,6 +152,8 @@ public function reverseTransform($value) * Returns a preconfigured IntlDateFormatter instance * * @return \IntlDateFormatter + * + * @throws TransformationFailedException in case the date formatter can not be constructed. */ protected function getIntlDateFormatter() { @@ -162,6 +164,12 @@ protected function getIntlDateFormatter() $pattern = $this->pattern; $intlDateFormatter = new \IntlDateFormatter(\Locale::getDefault(), $dateFormat, $timeFormat, $timezone, $calendar, $pattern); + + // new \intlDateFormatter may return null instead of false in case of failure, see https://bugs.php.net/bug.php?id=66323 + if (!$intlDateFormatter) { + throw new TransformationFailedException(intl_get_error_message(), intl_get_error_code()); + } + $intlDateFormatter->setLenient(false); return $intlDateFormatter; diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php index 022a41493205a..1748d2e31f6bb 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php @@ -77,6 +77,12 @@ public function buildForm(FormBuilderInterface $builder, array $options) $calendar, $pattern ); + + // new \intlDateFormatter may return null instead of false in case of failure, see https://bugs.php.net/bug.php?id=66323 + if (!$formatter) { + throw new InvalidOptionsException(intl_get_error_message(), intl_get_error_code()); + } + $formatter->setLenient(false); if ('choice' === $options['widget']) { From bf72e871f607e1f740620923783a6ee2ff368897 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 8 Jul 2014 13:19:32 +0200 Subject: [PATCH 1129/1305] bumped Symfony version to 2.3.18 --- 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 dbee2a5739840..3718155aded36 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.3.17'; - const VERSION_ID = '20317'; + const VERSION = '2.3.18-DEV'; + const VERSION_ID = '20318'; const MAJOR_VERSION = '2'; const MINOR_VERSION = '3'; - const RELEASE_VERSION = '17'; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = '18'; + const EXTRA_VERSION = 'DEV'; /** * Constructor. From 9dbe89dba63212fd6fe5a573f2a5ae27ca635e3e Mon Sep 17 00:00:00 2001 From: Simon Schick Date: Fri, 27 Jun 2014 09:57:31 +0200 Subject: [PATCH 1130/1305] [HttpFoundation] Remove content-related headers if content is empty --- .../Component/HttpFoundation/Response.php | 58 ++++++++++--------- .../HttpFoundation/Tests/ResponseTest.php | 2 + 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index 00502dd8ab1aa..d6fd08750d3ff 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -209,36 +209,42 @@ public function prepare(Request $request) if ($this->isInformational() || in_array($this->statusCode, array(204, 304))) { $this->setContent(null); - } - - // Content-type based on the Request - if (!$headers->has('Content-Type')) { - $format = $request->getRequestFormat(); - if (null !== $format && $mimeType = $request->getMimeType($format)) { - $headers->set('Content-Type', $mimeType); + $headers->remove('Content-Type'); + $headers->remove('Content-Length'); + } else { + // Content-type based on the Request + if (!$headers->has('Content-Type')) { + $format = $request->getRequestFormat(); + if (null !== $format && $mimeType = $request->getMimeType($format)) { + $headers->set('Content-Type', $mimeType); + } } - } - // Fix Content-Type - $charset = $this->charset ?: 'UTF-8'; - if (!$headers->has('Content-Type')) { - $headers->set('Content-Type', 'text/html; charset='.$charset); - } elseif (0 === stripos($headers->get('Content-Type'), 'text/') && false === stripos($headers->get('Content-Type'), 'charset')) { - // add the charset - $headers->set('Content-Type', $headers->get('Content-Type').'; charset='.$charset); - } + // Fix Content-Type + $charset = $this->charset ?: 'UTF-8'; + if (!$headers->has('Content-Type')) { + $headers->set('Content-Type', 'text/html; charset=' . $charset); + } elseif (0 === stripos($headers->get('Content-Type'), 'text/') && false === stripos( + $headers->get('Content-Type'), + 'charset' + ) + ) { + // add the charset + $headers->set('Content-Type', $headers->get('Content-Type') . '; charset=' . $charset); + } - // Fix Content-Length - if ($headers->has('Transfer-Encoding')) { - $headers->remove('Content-Length'); - } + // Fix Content-Length + if ($headers->has('Transfer-Encoding')) { + $headers->remove('Content-Length'); + } - if ($request->isMethod('HEAD')) { - // cf. RFC2616 14.13 - $length = $headers->get('Content-Length'); - $this->setContent(null); - if ($length) { - $headers->set('Content-Length', $length); + if ($request->isMethod('HEAD')) { + // cf. RFC2616 14.13 + $length = $headers->get('Content-Length'); + $this->setContent(null); + if ($length) { + $headers->set('Content-Length', $length); + } } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index 8143c56a07b10..7b3402ce6d233 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -374,6 +374,8 @@ public function testPrepareRemovesContentForHeadRequests() $response->prepare($request); $this->assertEquals('', $response->getContent()); + $this->assertFalse($response->headers->has('Content-Type')); + $this->assertFalse($response->headers->has('Content-Length')); } public function testPrepareSetsPragmaOnHttp10Only() From 5955f8edfe62cc8c2eb49381e5025728ad5890f5 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 9 Jul 2014 11:04:31 +0200 Subject: [PATCH 1131/1305] fixed CS --- src/Symfony/Component/HttpFoundation/Response.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index d6fd08750d3ff..cfff05ff97d08 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -224,11 +224,7 @@ public function prepare(Request $request) $charset = $this->charset ?: 'UTF-8'; if (!$headers->has('Content-Type')) { $headers->set('Content-Type', 'text/html; charset=' . $charset); - } elseif (0 === stripos($headers->get('Content-Type'), 'text/') && false === stripos( - $headers->get('Content-Type'), - 'charset' - ) - ) { + } elseif (0 === stripos($headers->get('Content-Type'), 'text/') && false === stripos($headers->get('Content-Type'), 'charset')) { // add the charset $headers->set('Content-Type', $headers->get('Content-Type') . '; charset=' . $charset); } From a67bc7612e59ae7f91f28b99319ac2590fb3b192 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Wed, 9 Jul 2014 12:03:33 +0200 Subject: [PATCH 1132/1305] [2.3][Form] Cleanup & fix phpdocs --- src/Symfony/Component/Form/Button.php | 16 +++--- src/Symfony/Component/Form/ButtonBuilder.php | 56 +++++++++---------- .../Component/Form/CallbackTransformer.php | 8 +-- .../Component/Form/ClickableInterface.php | 2 +- .../Extension/Core/ChoiceList/ChoiceList.php | 18 +++--- .../Core/ChoiceList/ObjectChoiceList.php | 6 +- .../Core/ChoiceList/SimpleChoiceList.php | 4 +- .../BaseDateTimeTransformer.php | 2 +- .../BooleanToStringTransformer.php | 4 +- .../DateTimeToArrayTransformer.php | 8 +-- .../DateTimeToTimestampTransformer.php | 2 +- .../MoneyToLocalizedStringTransformer.php | 5 +- .../NumberToLocalizedStringTransformer.php | 4 +- .../PercentToLocalizedStringTransformer.php | 12 ++-- .../EventListener/MergeCollectionListener.php | 8 +-- src/Symfony/Component/Form/FormBuilder.php | 1 + .../Component/Form/FormBuilderInterface.php | 6 +- .../Component/Form/FormConfigBuilder.php | 10 ++-- .../Form/FormConfigBuilderInterface.php | 29 +++++----- .../Component/Form/FormConfigInterface.php | 43 +++++++------- src/Symfony/Component/Form/FormError.php | 10 ++-- .../Component/Form/FormExtensionInterface.php | 4 +- .../Component/Form/FormFactoryBuilder.php | 8 +-- src/Symfony/Component/Form/FormRegistry.php | 6 +- .../Component/Form/FormRegistryInterface.php | 2 +- .../Form/FormRendererEngineInterface.php | 52 ++++++++--------- .../Component/Form/FormRendererInterface.php | 4 +- .../Form/FormTypeExtensionInterface.php | 12 ++-- .../Component/Form/FormTypeGuesserChain.php | 2 +- .../Component/Form/FormTypeInterface.php | 12 ++-- src/Symfony/Component/Form/FormView.php | 6 +- src/Symfony/Component/Form/Guess/Guess.php | 6 +- .../Component/Form/Guess/TypeGuess.php | 10 ++-- .../Component/Form/Guess/ValueGuess.php | 6 +- .../Component/Form/PreloadedExtension.php | 4 +- .../Component/Form/ResolvedFormType.php | 3 - .../Form/ResolvedFormTypeInterface.php | 8 ++- .../Form/Test/FormBuilderInterface.php | 4 +- .../Form/Test/FormIntegrationTestCase.php | 3 +- .../Component/Form/Test/FormInterface.php | 4 +- .../Form/Test/FormPerformanceTestCase.php | 9 ++- 41 files changed, 208 insertions(+), 211 deletions(-) diff --git a/src/Symfony/Component/Form/Button.php b/src/Symfony/Component/Form/Button.php index 50034606377fd..b6404a97d9158 100644 --- a/src/Symfony/Component/Form/Button.php +++ b/src/Symfony/Component/Form/Button.php @@ -51,7 +51,7 @@ public function __construct(FormConfigInterface $config) * * @param mixed $offset * - * @return bool Always returns false. + * @return bool Always returns false. */ public function offsetExists($offset) { @@ -152,7 +152,7 @@ public function get($name) * * @param string $name * - * @return bool Always returns false. + * @return bool Always returns false. */ public function has($name) { @@ -254,7 +254,7 @@ public function getConfig() /** * Returns whether the button is submitted. * - * @return bool true if the button was submitted. + * @return bool true if the button was submitted. */ public function isSubmitted() { @@ -295,7 +295,7 @@ public function addError(FormError $error) /** * Unsupported method. * - * @return bool Always returns true. + * @return bool Always returns true. */ public function isValid() { @@ -305,7 +305,7 @@ public function isValid() /** * Unsupported method. * - * @return bool Always returns false. + * @return bool Always returns false. */ public function isRequired() { @@ -327,7 +327,7 @@ public function isDisabled() /** * Unsupported method. * - * @return bool Always returns true. + * @return bool Always returns true. */ public function isEmpty() { @@ -337,7 +337,7 @@ public function isEmpty() /** * Unsupported method. * - * @return bool Always returns true. + * @return bool Always returns true. */ public function isSynchronized() { @@ -418,7 +418,7 @@ public function createView(FormView $parent = null) /** * Unsupported method. * - * @return int Always returns 0. + * @return int Always returns 0. */ public function count() { diff --git a/src/Symfony/Component/Form/ButtonBuilder.php b/src/Symfony/Component/Form/ButtonBuilder.php index 325b4a3c16880..9302af4190e54 100644 --- a/src/Symfony/Component/Form/ButtonBuilder.php +++ b/src/Symfony/Component/Form/ButtonBuilder.php @@ -75,9 +75,9 @@ public function __construct($name, array $options = array()) * * This method should not be invoked. * - * @param string|int|FormBuilderInterface $child - * @param string|FormTypeInterface $type - * @param array $options + * @param string|int|FormBuilderInterface $child + * @param string|FormTypeInterface $type + * @param array $options * * @throws BadMethodCallException */ @@ -135,7 +135,7 @@ public function remove($name) * * @param string $name * - * @return bool Always returns false. + * @return bool Always returns false. */ public function has($name) { @@ -283,7 +283,7 @@ public function setDataMapper(DataMapperInterface $dataMapper = null) /** * Set whether the button is disabled. * - * @param bool $disabled Whether the button is disabled + * @param bool $disabled Whether the button is disabled * * @return ButtonBuilder The button builder. */ @@ -313,7 +313,7 @@ public function setEmptyData($emptyData) * * This method should not be invoked. * - * @param bool $errorBubbling + * @param bool $errorBubbling * * @throws BadMethodCallException */ @@ -327,7 +327,7 @@ public function setErrorBubbling($errorBubbling) * * This method should not be invoked. * - * @param bool $required + * @param bool $required * * @throws BadMethodCallException */ @@ -355,7 +355,7 @@ public function setPropertyPath($propertyPath) * * This method should not be invoked. * - * @param bool $mapped + * @param bool $mapped * * @throws BadMethodCallException */ @@ -369,7 +369,7 @@ public function setMapped($mapped) * * This method should not be invoked. * - * @param bool $byReference + * @param bool $byReference * * @throws BadMethodCallException */ @@ -383,7 +383,7 @@ public function setByReference($byReference) * * This method should not be invoked. * - * @param bool $virtual + * @param bool $virtual * * @throws BadMethodCallException */ @@ -397,7 +397,7 @@ public function setVirtual($virtual) * * This method should not be invoked. * - * @param bool $compound + * @param bool $compound * * @throws BadMethodCallException */ @@ -439,7 +439,7 @@ public function setData($data) * * This method should not be invoked. * - * @param bool $locked + * @param bool $locked * * @throws BadMethodCallException */ @@ -455,8 +455,6 @@ public function setDataLocked($locked) * * @param FormFactoryInterface $formFactory * - * @return void - * * @throws BadMethodCallException */ public function setFormFactory(FormFactoryInterface $formFactory) @@ -503,7 +501,7 @@ public function setRequestHandler(RequestHandlerInterface $requestHandler) /** * Unsupported method. * - * @param bool $initialize + * @param bool $initialize * * @throws BadMethodCallException */ @@ -519,7 +517,7 @@ public function setAutoInitialize($initialize) /** * Unsupported method. * - * @param bool $inheritData + * @param bool $inheritData * * @throws BadMethodCallException */ @@ -571,7 +569,7 @@ public function getPropertyPath() /** * Unsupported method. * - * @return bool Always returns false. + * @return bool Always returns false. */ public function getMapped() { @@ -581,7 +579,7 @@ public function getMapped() /** * Unsupported method. * - * @return bool Always returns false. + * @return bool Always returns false. */ public function getByReference() { @@ -591,7 +589,7 @@ public function getByReference() /** * Unsupported method. * - * @return bool Always returns false. + * @return bool Always returns false. */ public function getVirtual() { @@ -601,7 +599,7 @@ public function getVirtual() /** * Unsupported method. * - * @return bool Always returns false. + * @return bool Always returns false. */ public function getCompound() { @@ -650,7 +648,7 @@ public function getDataMapper() /** * Unsupported method. * - * @return bool Always returns false. + * @return bool Always returns false. */ public function getRequired() { @@ -660,7 +658,7 @@ public function getRequired() /** * Returns whether the button is disabled. * - * @return bool Whether the button is disabled. + * @return bool Whether the button is disabled. */ public function getDisabled() { @@ -670,7 +668,7 @@ public function getDisabled() /** * Unsupported method. * - * @return bool Always returns false. + * @return bool Always returns false. */ public function getErrorBubbling() { @@ -701,7 +699,7 @@ public function getAttributes() * * @param string $name The attribute name. * - * @return bool Whether the attribute exists. + * @return bool Whether the attribute exists. */ public function hasAttribute($name) { @@ -742,7 +740,7 @@ public function getDataClass() /** * Unsupported method. * - * @return bool Always returns false. + * @return bool Always returns false. */ public function getDataLocked() { @@ -788,7 +786,7 @@ public function getRequestHandler() /** * Unsupported method. * - * @return bool Always returns false. + * @return bool Always returns false. */ public function getAutoInitialize() { @@ -798,7 +796,7 @@ public function getAutoInitialize() /** * Unsupported method. * - * @return bool Always returns false. + * @return bool Always returns false. */ public function getInheritData() { @@ -820,7 +818,7 @@ public function getOptions() * * @param string $name The option name, * - * @return bool Whether the option exists. + * @return bool Whether the option exists. */ public function hasOption($name) { @@ -843,7 +841,7 @@ public function getOption($name, $default = null) /** * Unsupported method. * - * @return int Always returns 0. + * @return int Always returns 0. */ public function count() { diff --git a/src/Symfony/Component/Form/CallbackTransformer.php b/src/Symfony/Component/Form/CallbackTransformer.php index b35da45bc7fbe..c53c6df78846c 100644 --- a/src/Symfony/Component/Form/CallbackTransformer.php +++ b/src/Symfony/Component/Form/CallbackTransformer.php @@ -47,8 +47,8 @@ public function __construct(\Closure $transform, \Closure $reverseTransform) * * @return mixed The value in the transformed representation * - * @throws UnexpectedTypeException when the argument is not a string - * @throws TransformationFailedException when the transformation fails + * @throws UnexpectedTypeException when the argument is not a string + * @throws TransformationFailedException when the transformation fails */ public function transform($data) { @@ -63,8 +63,8 @@ public function transform($data) * * @return mixed The value in the original representation * - * @throws UnexpectedTypeException when the argument is not of the expected type - * @throws TransformationFailedException when the transformation fails + * @throws UnexpectedTypeException when the argument is not of the expected type + * @throws TransformationFailedException when the transformation fails */ public function reverseTransform($data) { diff --git a/src/Symfony/Component/Form/ClickableInterface.php b/src/Symfony/Component/Form/ClickableInterface.php index 9df55449fb81e..6e45eff1a7f1a 100644 --- a/src/Symfony/Component/Form/ClickableInterface.php +++ b/src/Symfony/Component/Form/ClickableInterface.php @@ -21,7 +21,7 @@ interface ClickableInterface /** * Returns whether this element was clicked. * - * @return bool Whether this element was clicked. + * @return bool Whether this element was clicked. */ public function isClicked(); } diff --git a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php b/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php index d3d8e7dd09629..db21fc2c99aff 100644 --- a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php +++ b/src/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php @@ -75,10 +75,10 @@ class ChoiceList implements ChoiceListInterface * the sub-hierarchy can be stored in the array * key pointing to the nested array. The topmost * level of the hierarchy may also be a \Traversable. - * @param array $labels The array of labels. The structure of this array - * should match the structure of $choices. - * @param array $preferredChoices A flat array of choices that should be - * presented to the user with priority. + * @param array $labels The array of labels. The structure of this array + * should match the structure of $choices. + * @param array $preferredChoices A flat array of choices that should be + * presented to the user with priority. * * @throws UnexpectedTypeException If the choices are not an array or \Traversable. */ @@ -255,7 +255,7 @@ public function getIndicesForValues(array $values) * @param array $labels The labels corresponding to the choices. * @param array $preferredChoices The preferred choices. * - * @throws InvalidArgumentException If the structures of the choices and labels array do not match. + * @throws InvalidArgumentException If the structures of the choices and labels array do not match. * @throws InvalidConfigurationException If no valid value or index could be created for a choice. */ protected function addChoices(array &$bucketForPreferred, array &$bucketForRemaining, $choices, array $labels, array $preferredChoices) @@ -377,7 +377,7 @@ protected function addChoice(array &$bucketForPreferred, array &$bucketForRemain * @param mixed $choice The choice to test. * @param array $preferredChoices An array of preferred choices. * - * @return bool Whether the choice is preferred. + * @return bool Whether the choice is preferred. */ protected function isPreferred($choice, array $preferredChoices) { @@ -391,8 +391,8 @@ protected function isPreferred($choice, array $preferredChoices) * * @param mixed $choice The choice to create an index for * - * @return int|string A unique index containing only ASCII letters, - * digits and underscores. + * @return int|string A unique index containing only ASCII letters, + * digits and underscores. */ protected function createIndex($choice) { @@ -451,7 +451,7 @@ protected function fixValues(array $values) * * @param mixed $index The choice index. * - * @return int|string The index as PHP array key. + * @return int|string The index as PHP array key. */ protected function fixIndex($index) { diff --git a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ObjectChoiceList.php b/src/Symfony/Component/Form/Extension/Core/ChoiceList/ObjectChoiceList.php index 22035b8f75879..14c6f238d3e50 100644 --- a/src/Symfony/Component/Form/Extension/Core/ChoiceList/ObjectChoiceList.php +++ b/src/Symfony/Component/Form/Extension/Core/ChoiceList/ObjectChoiceList.php @@ -72,7 +72,7 @@ class ObjectChoiceList extends ChoiceList * be a \Traversable. * @param string $labelPath A property path pointing to the property used * for the choice labels. The value is obtained - * by calling the getter on the object. If the + * by calling the getter on the object. If the * path is NULL, the object's __toString() method * is used instead. * @param array $preferredChoices A flat array of choices that should be @@ -105,7 +105,7 @@ public function __construct($choices, $labelPath = null, array $preferredChoices * @param array $preferredChoices The choices to display with priority. * * @throws InvalidArgumentException When passing a hierarchy of choices and using - * the "groupPath" option at the same time. + * the "groupPath" option at the same time. */ protected function initialize($choices, array $labels, array $preferredChoices) { @@ -157,7 +157,7 @@ protected function initialize($choices, array $labels, array $preferredChoices) * * @param mixed $choice The choice to create a value for * - * @return int|string A unique value without character limitations. + * @return int|string A unique value without character limitations. */ protected function createValue($choice) { diff --git a/src/Symfony/Component/Form/Extension/Core/ChoiceList/SimpleChoiceList.php b/src/Symfony/Component/Form/Extension/Core/ChoiceList/SimpleChoiceList.php index dbe54265b1777..7a5fb346ceeed 100644 --- a/src/Symfony/Component/Form/Extension/Core/ChoiceList/SimpleChoiceList.php +++ b/src/Symfony/Component/Form/Extension/Core/ChoiceList/SimpleChoiceList.php @@ -124,7 +124,7 @@ protected function addChoices(array &$bucketForPreferred, array &$bucketForRemai * @param mixed $choice The choice to test. * @param array $preferredChoices An array of preferred choices. * - * @return bool Whether the choice is preferred. + * @return bool Whether the choice is preferred. */ protected function isPreferred($choice, array $preferredChoices) { @@ -137,7 +137,7 @@ protected function isPreferred($choice, array $preferredChoices) * * @param mixed $choice The choice. * - * @return string|int A valid PHP array key. + * @return string|int A valid PHP array key. */ protected function fixChoice($choice) { diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php index 9c1b92d741162..0cf9741dce7ef 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php @@ -35,7 +35,7 @@ abstract class BaseDateTimeTransformer implements DataTransformerInterface * @param string $inputTimezone The name of the input timezone * @param string $outputTimezone The name of the output timezone * - * @throws UnexpectedTypeException if a timezone is not a string + * @throws UnexpectedTypeException if a timezone is not a string * @throws InvalidArgumentException if a timezone is not valid */ public function __construct($inputTimezone = null, $outputTimezone = null) diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/BooleanToStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/BooleanToStringTransformer.php index c6b47803affb1..d839427877c3e 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/BooleanToStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/BooleanToStringTransformer.php @@ -41,7 +41,7 @@ public function __construct($trueValue) /** * Transforms a Boolean into a string. * - * @param bool $value Boolean value. + * @param bool $value Boolean value. * * @return string String value. * @@ -65,7 +65,7 @@ public function transform($value) * * @param string $value String value. * - * @return bool Boolean value. + * @return bool Boolean value. * * @throws TransformationFailedException If the given value is not a string. */ diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php index ea2ab40e6f0f7..eeeb9fafac7fe 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php @@ -29,10 +29,10 @@ class DateTimeToArrayTransformer extends BaseDateTimeTransformer /** * Constructor. * - * @param string $inputTimezone The input timezone - * @param string $outputTimezone The output timezone - * @param array $fields The date fields - * @param bool $pad Whether to use padding + * @param string $inputTimezone The input timezone + * @param string $outputTimezone The output timezone + * @param array $fields The date fields + * @param bool $pad Whether to use padding * * @throws UnexpectedTypeException if a timezone is not a string */ diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToTimestampTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToTimestampTransformer.php index 7c40b4f6ca999..38073f8291267 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToTimestampTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToTimestampTransformer.php @@ -26,7 +26,7 @@ class DateTimeToTimestampTransformer extends BaseDateTimeTransformer * * @param \DateTime $value A \DateTime object * - * @return int A timestamp + * @return int A timestamp * * @throws TransformationFailedException If the given value is not an instance * of \DateTime or if the output diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php index 5b8e9d96641b7..d746961d2de08 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php @@ -21,7 +21,6 @@ */ class MoneyToLocalizedStringTransformer extends NumberToLocalizedStringTransformer { - private $divisor; public function __construct($precision = null, $grouping = null, $roundingMode = null, $divisor = null) @@ -46,7 +45,7 @@ public function __construct($precision = null, $grouping = null, $roundingMode = /** * Transforms a normalized format into a localized money string. * - * @param number $value Normalized number + * @param int|float $value Normalized number * * @return string Localized money string. * @@ -71,7 +70,7 @@ public function transform($value) * * @param string $value Localized money string * - * @return number Normalized number + * @return int|float Normalized number * * @throws TransformationFailedException If the given value is not a string * or if the value can not be transformed. diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php index c3a7609a5f496..8b30c7f696e8a 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php @@ -55,7 +55,7 @@ public function __construct($precision = null, $grouping = null, $roundingMode = /** * Transforms a number type into localized number. * - * @param int|float $value Number value. + * @param int|float $value Number value. * * @return string Localized value. * @@ -90,7 +90,7 @@ public function transform($value) * * @param string $value The localized value * - * @return int|float The numeric value + * @return int|float The numeric value * * @throws TransformationFailedException If the given value is not a string * or if the value can not be transformed. diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php index bbf4761fa06f2..2e02478e812b9 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php @@ -40,8 +40,8 @@ class PercentToLocalizedStringTransformer implements DataTransformerInterface * * @see self::$types for a list of supported types * - * @param int $precision The precision - * @param string $type One of the supported types + * @param int $precision The precision + * @param string $type One of the supported types * * @throws UnexpectedTypeException if the given value of type is unknown */ @@ -66,9 +66,9 @@ public function __construct($precision = null, $type = null) /** * Transforms between a normalized format (integer or float) into a percentage value. * - * @param number $value Normalized value + * @param int|float $value Normalized value * - * @return number Percentage value + * @return string Percentage value * * @throws TransformationFailedException If the given value is not numeric or * if the value could not be transformed. @@ -101,9 +101,9 @@ public function transform($value) /** * Transforms between a percentage value into a normalized format (integer or float). * - * @param number $value Percentage value. + * @param string $value Percentage value. * - * @return number Normalized value. + * @return int|float Normalized value. * * @throws TransformationFailedException If the given value is not a string or * if the value could not be transformed. diff --git a/src/Symfony/Component/Form/Extension/Core/EventListener/MergeCollectionListener.php b/src/Symfony/Component/Form/Extension/Core/EventListener/MergeCollectionListener.php index b0fbdb54c3ed5..982a78679b8cd 100644 --- a/src/Symfony/Component/Form/Extension/Core/EventListener/MergeCollectionListener.php +++ b/src/Symfony/Component/Form/Extension/Core/EventListener/MergeCollectionListener.php @@ -36,10 +36,10 @@ class MergeCollectionListener implements EventSubscriberInterface /** * Creates a new listener. * - * @param bool $allowAdd Whether values might be added to the - * collection. - * @param bool $allowDelete Whether values might be removed from the - * collection. + * @param bool $allowAdd Whether values might be added to the + * collection. + * @param bool $allowDelete Whether values might be removed from the + * collection. */ public function __construct($allowAdd = false, $allowDelete = false) { diff --git a/src/Symfony/Component/Form/FormBuilder.php b/src/Symfony/Component/Form/FormBuilder.php index 2caefe48bef4c..434afa861a5e4 100644 --- a/src/Symfony/Component/Form/FormBuilder.php +++ b/src/Symfony/Component/Form/FormBuilder.php @@ -198,6 +198,7 @@ public function count() */ public function getFormConfig() { + /** @var $config self */ $config = parent::getFormConfig(); $config->children = array(); diff --git a/src/Symfony/Component/Form/FormBuilderInterface.php b/src/Symfony/Component/Form/FormBuilderInterface.php index 3294a3d3bd864..998d3ec0d31a0 100644 --- a/src/Symfony/Component/Form/FormBuilderInterface.php +++ b/src/Symfony/Component/Form/FormBuilderInterface.php @@ -23,9 +23,9 @@ interface FormBuilderInterface extends \Traversable, \Countable, FormConfigBuild * If you add a nested group, this group should also be represented in the * object hierarchy. * - * @param string|int|FormBuilderInterface $child - * @param string|FormTypeInterface $type - * @param array $options + * @param string|int|FormBuilderInterface $child + * @param string|FormTypeInterface $type + * @param array $options * * @return FormBuilderInterface The builder object. */ diff --git a/src/Symfony/Component/Form/FormConfigBuilder.php b/src/Symfony/Component/Form/FormConfigBuilder.php index 730c63527acfe..733b79dfdd3ff 100644 --- a/src/Symfony/Component/Form/FormConfigBuilder.php +++ b/src/Symfony/Component/Form/FormConfigBuilder.php @@ -186,7 +186,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface * @param array $options The form options * * @throws InvalidArgumentException If the data class is not a valid class or if - * the name contains invalid characters. + * the name contains invalid characters. */ public function __construct($name, $dataClass, EventDispatcherInterface $dispatcher, array $options = array()) { @@ -713,7 +713,7 @@ public function setInheritData($inheritData) /** * Alias of {@link setInheritData()}. * - * @param bool $inheritData Whether the form should inherit its parent's data. + * @param bool $inheritData Whether the form should inherit its parent's data. * * @return FormConfigBuilder The configuration object. * @@ -879,9 +879,9 @@ public function getFormConfig() /** * Validates whether the given variable is a valid form name. * - * @param string|int $name The tested form name. + * @param string|int $name The tested form name. * - * @throws UnexpectedTypeException If the name is not a string or an integer. + * @throws UnexpectedTypeException If the name is not a string or an integer. * @throws InvalidArgumentException If the name contains invalid characters. */ public static function validateName($name) @@ -910,7 +910,7 @@ public static function validateName($name) * * @param string $name The tested form name. * - * @return bool Whether the name is valid. + * @return bool Whether the name is valid. */ public static function isValidName($name) { diff --git a/src/Symfony/Component/Form/FormConfigBuilderInterface.php b/src/Symfony/Component/Form/FormConfigBuilderInterface.php index 276a2fa44674e..da2da0b66895d 100644 --- a/src/Symfony/Component/Form/FormConfigBuilderInterface.php +++ b/src/Symfony/Component/Form/FormConfigBuilderInterface.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Form; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\PropertyAccess\PropertyPathInterface; /** * @author Bernhard Schussek @@ -88,7 +89,7 @@ public function resetModelTransformers(); * Sets the value for an attribute. * * @param string $name The name of the attribute - * @param string $value The value of the attribute + * @param mixed $value The value of the attribute * * @return self The configuration object. */ @@ -115,7 +116,7 @@ public function setDataMapper(DataMapperInterface $dataMapper = null); /** * Set whether the form is disabled. * - * @param bool $disabled Whether the form is disabled + * @param bool $disabled Whether the form is disabled * * @return self The configuration object. */ @@ -133,7 +134,7 @@ public function setEmptyData($emptyData); /** * Sets whether errors bubble up to the parent. * - * @param bool $errorBubbling + * @param bool $errorBubbling * * @return self The configuration object. */ @@ -142,7 +143,7 @@ public function setErrorBubbling($errorBubbling); /** * Sets whether this field is required to be filled out when submitted. * - * @param bool $required + * @param bool $required * * @return self The configuration object. */ @@ -151,7 +152,7 @@ public function setRequired($required); /** * Sets the property path that the form should be mapped to. * - * @param null|string|\Symfony\Component\PropertyAccess\PropertyPathInterface $propertyPath + * @param null|string|PropertyPathInterface $propertyPath * The property path or null if the path should be set * automatically based on the form's name. * @@ -163,7 +164,7 @@ public function setPropertyPath($propertyPath); * Sets whether the form should be mapped to an element of its * parent's data. * - * @param bool $mapped Whether the form should be mapped. + * @param bool $mapped Whether the form should be mapped. * * @return self The configuration object. */ @@ -172,7 +173,7 @@ public function setMapped($mapped); /** * Sets whether the form's data should be modified by reference. * - * @param bool $byReference Whether the data should be + * @param bool $byReference Whether the data should be * modified by reference. * * @return self The configuration object. @@ -182,7 +183,7 @@ public function setByReference($byReference); /** * Sets whether the form should read and write the data of its parent. * - * @param bool $inheritData Whether the form should inherit its parent's data. + * @param bool $inheritData Whether the form should inherit its parent's data. * * @return self The configuration object. */ @@ -191,7 +192,7 @@ public function setInheritData($inheritData); /** * Sets whether the form should be compound. * - * @param bool $compound Whether the form should be compound. + * @param bool $compound Whether the form should be compound. * * @return self The configuration object. * @@ -224,7 +225,7 @@ public function setData($data); * this configuration. The data can only be modified then by * submitting the form. * - * @param bool $locked Whether to lock the default data. + * @param bool $locked Whether to lock the default data. * * @return self The configuration object. */ @@ -269,10 +270,10 @@ public function setRequestHandler(RequestHandlerInterface $requestHandler); * * Should be set to true only for root forms. * - * @param bool $initialize True to initialize the form automatically, - * false to suppress automatic initialization. - * In the second case, you need to call - * {@link FormInterface::initialize()} manually. + * @param bool $initialize True to initialize the form automatically, + * false to suppress automatic initialization. + * In the second case, you need to call + * {@link FormInterface::initialize()} manually. * * @return self The configuration object. */ diff --git a/src/Symfony/Component/Form/FormConfigInterface.php b/src/Symfony/Component/Form/FormConfigInterface.php index ea19165407d89..179905850f749 100644 --- a/src/Symfony/Component/Form/FormConfigInterface.php +++ b/src/Symfony/Component/Form/FormConfigInterface.php @@ -11,6 +11,9 @@ namespace Symfony\Component\Form; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\PropertyAccess\PropertyPathInterface; + /** * The configuration of a {@link Form} object. * @@ -21,7 +24,7 @@ interface FormConfigInterface /** * Returns the event dispatcher used to dispatch form events. * - * @return \Symfony\Component\EventDispatcher\EventDispatcherInterface The dispatcher. + * @return EventDispatcherInterface The dispatcher. */ public function getEventDispatcher(); @@ -35,7 +38,7 @@ public function getName(); /** * Returns the property path that the form should be mapped to. * - * @return null|\Symfony\Component\PropertyAccess\PropertyPathInterface The property path. + * @return null|PropertyPathInterface The property path. */ public function getPropertyPath(); @@ -43,21 +46,21 @@ public function getPropertyPath(); * Returns whether the form should be mapped to an element of its * parent's data. * - * @return bool Whether the form is mapped. + * @return bool Whether the form is mapped. */ public function getMapped(); /** * Returns whether the form's data should be modified by reference. * - * @return bool Whether to modify the form's data by reference. + * @return bool Whether to modify the form's data by reference. */ public function getByReference(); /** * Returns whether the form should read and write the data of its parent. * - * @return bool Whether the form should inherit its parent's data. + * @return bool Whether the form should inherit its parent's data. */ public function getInheritData(); @@ -68,7 +71,7 @@ public function getInheritData(); * children. A form can be compound and have no children at all, like * for example an empty collection form. * - * @return bool Whether the form is compound. + * @return bool Whether the form is compound. */ public function getCompound(); @@ -103,21 +106,21 @@ public function getDataMapper(); /** * Returns whether the form is required. * - * @return bool Whether the form is required. + * @return bool Whether the form is required. */ public function getRequired(); /** * Returns whether the form is disabled. * - * @return bool Whether the form is disabled. + * @return bool Whether the form is disabled. */ public function getDisabled(); /** * Returns whether errors attached to the form will bubble to its parent. * - * @return bool Whether errors will bubble up. + * @return bool Whether errors will bubble up. */ public function getErrorBubbling(); @@ -138,17 +141,17 @@ public function getAttributes(); /** * Returns whether the attribute with the given name exists. * - * @param string $name The attribute name. + * @param string $name The attribute name. * - * @return bool Whether the attribute exists. + * @return bool Whether the attribute exists. */ public function hasAttribute($name); /** * Returns the value of the given attribute. * - * @param string $name The attribute name. - * @param mixed $default The value returned if the attribute does not exist. + * @param string $name The attribute name. + * @param mixed $default The value returned if the attribute does not exist. * * @return mixed The attribute value. */ @@ -175,7 +178,7 @@ public function getDataClass(); * this configuration. The data can only be modified then by * submitting the form. * - * @return bool Whether the data is locked. + * @return bool Whether the data is locked. */ public function getDataLocked(); @@ -210,8 +213,8 @@ public function getRequestHandler(); /** * Returns whether the form should be initialized upon creation. * - * @return bool Returns true if the form should be initialized - * when created, false otherwise. + * @return bool Returns true if the form should be initialized + * when created, false otherwise. */ public function getAutoInitialize(); @@ -225,17 +228,17 @@ public function getOptions(); /** * Returns whether a specific option exists. * - * @param string $name The option name, + * @param string $name The option name, * - * @return bool Whether the option exists. + * @return bool Whether the option exists. */ public function hasOption($name); /** * Returns the value of a specific option. * - * @param string $name The option name. - * @param mixed $default The value returned if the option does not exist. + * @param string $name The option name. + * @param mixed $default The value returned if the option does not exist. * * @return mixed The option value. */ diff --git a/src/Symfony/Component/Form/FormError.php b/src/Symfony/Component/Form/FormError.php index 8927a760659ab..e29147be798d0 100644 --- a/src/Symfony/Component/Form/FormError.php +++ b/src/Symfony/Component/Form/FormError.php @@ -47,11 +47,11 @@ class FormError * Any array key in $messageParameters will be used as a placeholder in * $messageTemplate. * - * @param string $message The translated error message - * @param string|null $messageTemplate The template for the error message - * @param array $messageParameters The parameters that should be - * substituted in the message template. - * @param int|null $messagePluralization The value for error message pluralization + * @param string $message The translated error message + * @param string|null $messageTemplate The template for the error message + * @param array $messageParameters The parameters that should be + * substituted in the message template. + * @param int|null $messagePluralization The value for error message pluralization * * @see \Symfony\Component\Translation\Translator */ diff --git a/src/Symfony/Component/Form/FormExtensionInterface.php b/src/Symfony/Component/Form/FormExtensionInterface.php index 4fcf0b8f73793..1449b1f1e78cf 100644 --- a/src/Symfony/Component/Form/FormExtensionInterface.php +++ b/src/Symfony/Component/Form/FormExtensionInterface.php @@ -32,7 +32,7 @@ public function getType($name); * * @param string $name The name of the type * - * @return bool Whether the type is supported by this extension + * @return bool Whether the type is supported by this extension */ public function hasType($name); @@ -50,7 +50,7 @@ public function getTypeExtensions($name); * * @param string $name The name of the type * - * @return bool Whether the given type has extensions + * @return bool Whether the given type has extensions */ public function hasTypeExtensions($name); diff --git a/src/Symfony/Component/Form/FormFactoryBuilder.php b/src/Symfony/Component/Form/FormFactoryBuilder.php index 10383e841cc6e..a5bf5b38fdbce 100644 --- a/src/Symfony/Component/Form/FormFactoryBuilder.php +++ b/src/Symfony/Component/Form/FormFactoryBuilder.php @@ -24,22 +24,22 @@ class FormFactoryBuilder implements FormFactoryBuilderInterface private $resolvedTypeFactory; /** - * @var array + * @var FormExtensionInterface[] */ private $extensions = array(); /** - * @var array + * @var FormTypeInterface[] */ private $types = array(); /** - * @var array + * @var FormTypeExtensionInterface[] */ private $typeExtensions = array(); /** - * @var array + * @var FormTypeGuesserInterface[] */ private $typeGuessers = array(); diff --git a/src/Symfony/Component/Form/FormRegistry.php b/src/Symfony/Component/Form/FormRegistry.php index 0267a5657b398..b2912fb05267f 100644 --- a/src/Symfony/Component/Form/FormRegistry.php +++ b/src/Symfony/Component/Form/FormRegistry.php @@ -30,7 +30,7 @@ class FormRegistry implements FormRegistryInterface private $extensions = array(); /** - * @var array + * @var FormTypeInterface[] */ private $types = array(); @@ -74,11 +74,9 @@ public function getType($name) } if (!isset($this->types[$name])) { - /** @var FormTypeInterface $type */ $type = null; foreach ($this->extensions as $extension) { - /* @var FormExtensionInterface $extension */ if ($extension->hasType($name)) { $type = $extension->getType($name); break; @@ -115,7 +113,6 @@ private function resolveAndAddType(FormTypeInterface $type) $typeExtensions = array(); foreach ($this->extensions as $extension) { - /* @var FormExtensionInterface $extension */ $typeExtensions = array_merge( $typeExtensions, $extension->getTypeExtensions($type->getName()) @@ -156,7 +153,6 @@ public function getTypeGuesser() $guessers = array(); foreach ($this->extensions as $extension) { - /* @var FormExtensionInterface $extension */ $guesser = $extension->getTypeGuesser(); if ($guesser) { diff --git a/src/Symfony/Component/Form/FormRegistryInterface.php b/src/Symfony/Component/Form/FormRegistryInterface.php index b15131c39b507..b42b2b581872e 100644 --- a/src/Symfony/Component/Form/FormRegistryInterface.php +++ b/src/Symfony/Component/Form/FormRegistryInterface.php @@ -37,7 +37,7 @@ public function getType($name); * * @param string $name The name of the type * - * @return bool Whether the type is supported + * @return bool Whether the type is supported */ public function hasType($name); diff --git a/src/Symfony/Component/Form/FormRendererEngineInterface.php b/src/Symfony/Component/Form/FormRendererEngineInterface.php index 9f04e1999a7a6..31528e05317d2 100644 --- a/src/Symfony/Component/Form/FormRendererEngineInterface.php +++ b/src/Symfony/Component/Form/FormRendererEngineInterface.php @@ -70,19 +70,15 @@ public function getResourceForBlockName(FormView $view, $blockName); * The type of the resource is decided by the implementation. The resource * is later passed to {@link renderBlock()} by the rendering algorithm. * - * @param FormView $view The view for determining the - * used themes. First the themes - * attached directly to the view - * with {@link setTheme()} are - * considered, then the ones of - * its parent etc. - * @param array $blockNameHierarchy The block name hierarchy, with - * the root block at the beginning. - * @param int $hierarchyLevel The level in the hierarchy at - * which to start looking. Level 0 - * indicates the root block, i.e. - * the first element of - * $blockNameHierarchy. + * @param FormView $view The view for determining the used themes. + * First the themes attached directly to + * the view with {@link setTheme()} are + * considered, then the ones of its parent etc. + * @param array $blockNameHierarchy The block name hierarchy, with the root block + * at the beginning. + * @param int $hierarchyLevel The level in the hierarchy at which to start + * looking. Level 0 indicates the root block, i.e. + * the first element of $blockNameHierarchy. * * @return mixed The renderer resource or false, if none was found. */ @@ -114,19 +110,15 @@ public function getResourceForBlockNameHierarchy(FormView $view, array $blockNam * The type of the resource is decided by the implementation. The resource * is later passed to {@link renderBlock()} by the rendering algorithm. * - * @param FormView $view The view for determining the - * used themes. First the themes - * attached directly to the view - * with {@link setTheme()} are - * considered, then the ones of - * its parent etc. - * @param array $blockNameHierarchy The block name hierarchy, with - * the root block at the beginning. - * @param int $hierarchyLevel The level in the hierarchy at - * which to start looking. Level 0 - * indicates the root block, i.e. - * the first element of - * $blockNameHierarchy. + * @param FormView $view The view for determining the used themes. + * First the themes attached directly to + * the view with {@link setTheme()} are + * considered, then the ones of its parent etc. + * @param array $blockNameHierarchy The block name hierarchy, with the root block + * at the beginning. + * @param int $hierarchyLevel The level in the hierarchy at which to start + * looking. Level 0 indicates the root block, i.e. + * the first element of $blockNameHierarchy. * * @return int|bool The hierarchy level or false, if no resource was found. */ @@ -139,10 +131,10 @@ public function getResourceHierarchyLevel(FormView $view, array $blockNameHierar * or {@link getResourceForBlockHierarchy()}. The type of the resource is * decided by the implementation. * - * @param FormView $view The view to render. - * @param mixed $resource The renderer resource. - * @param string $blockName The name of the block to render. - * @param array $variables The variables to pass to the template. + * @param FormView $view The view to render. + * @param mixed $resource The renderer resource. + * @param string $blockName The name of the block to render. + * @param array $variables The variables to pass to the template. * * @return string The HTML markup. */ diff --git a/src/Symfony/Component/Form/FormRendererInterface.php b/src/Symfony/Component/Form/FormRendererInterface.php index 848e7125ca329..76e305c352f2f 100644 --- a/src/Symfony/Component/Form/FormRendererInterface.php +++ b/src/Symfony/Component/Form/FormRendererInterface.php @@ -29,8 +29,8 @@ public function getEngine(); * Sets the theme(s) to be used for rendering a view and its children. * * @param FormView $view The view to assign the theme(s) to. - * @param mixed $themes The theme(s). The type of these themes - * is open to the implementation. + * @param mixed $themes The theme(s). The type of these themes + * is open to the implementation. */ public function setTheme(FormView $view, $themes); diff --git a/src/Symfony/Component/Form/FormTypeExtensionInterface.php b/src/Symfony/Component/Form/FormTypeExtensionInterface.php index 9866b28b64a6e..946c7a74b3e57 100644 --- a/src/Symfony/Component/Form/FormTypeExtensionInterface.php +++ b/src/Symfony/Component/Form/FormTypeExtensionInterface.php @@ -39,9 +39,9 @@ public function buildForm(FormBuilderInterface $builder, array $options); * * @see FormTypeInterface::buildView() * - * @param FormView $view The view - * @param FormInterface $form The form - * @param array $options The options + * @param FormView $view The view + * @param FormInterface $form The form + * @param array $options The options */ public function buildView(FormView $view, FormInterface $form, array $options); @@ -53,9 +53,9 @@ public function buildView(FormView $view, FormInterface $form, array $options); * * @see FormTypeInterface::finishView() * - * @param FormView $view The view - * @param FormInterface $form The form - * @param array $options The options + * @param FormView $view The view + * @param FormInterface $form The form + * @param array $options The options */ public function finishView(FormView $view, FormInterface $form, array $options); diff --git a/src/Symfony/Component/Form/FormTypeGuesserChain.php b/src/Symfony/Component/Form/FormTypeGuesserChain.php index 27db88902605d..979a7214d8490 100644 --- a/src/Symfony/Component/Form/FormTypeGuesserChain.php +++ b/src/Symfony/Component/Form/FormTypeGuesserChain.php @@ -85,7 +85,7 @@ public function guessPattern($class, $property) * return values * * @param \Closure $closure The closure to execute. Accepts a guesser - * as argument and should return a Guess instance + * as argument and should return a Guess instance * * @return Guess|null The guess with the highest confidence */ diff --git a/src/Symfony/Component/Form/FormTypeInterface.php b/src/Symfony/Component/Form/FormTypeInterface.php index 5f6850b7cd930..78f8bd008365a 100644 --- a/src/Symfony/Component/Form/FormTypeInterface.php +++ b/src/Symfony/Component/Form/FormTypeInterface.php @@ -43,9 +43,9 @@ public function buildForm(FormBuilderInterface $builder, array $options); * * @see FormTypeExtensionInterface::buildView() * - * @param FormView $view The view - * @param FormInterface $form The form - * @param array $options The options + * @param FormView $view The view + * @param FormInterface $form The form + * @param array $options The options */ public function buildView(FormView $view, FormInterface $form, array $options); @@ -62,9 +62,9 @@ public function buildView(FormView $view, FormInterface $form, array $options); * * @see FormTypeExtensionInterface::finishView() * - * @param FormView $view The view - * @param FormInterface $form The form - * @param array $options The options + * @param FormView $view The view + * @param FormInterface $form The form + * @param array $options The options */ public function finishView(FormView $view, FormInterface $form, array $options); diff --git a/src/Symfony/Component/Form/FormView.php b/src/Symfony/Component/Form/FormView.php index a8075518545d5..c2c3679f0b773 100644 --- a/src/Symfony/Component/Form/FormView.php +++ b/src/Symfony/Component/Form/FormView.php @@ -35,7 +35,7 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable /** * The child views. - * @var array + * @var FormView[] */ public $children = array(); @@ -110,7 +110,7 @@ public function offsetGet($name) * * @param string $name The child name * - * @return bool Whether the child view exists + * @return bool Whether the child view exists */ public function offsetExists($name) { @@ -150,7 +150,7 @@ public function getIterator() /** * Implements \Countable. * - * @return int The number of children views + * @return int The number of children views */ public function count() { diff --git a/src/Symfony/Component/Form/Guess/Guess.php b/src/Symfony/Component/Form/Guess/Guess.php index 93568c3c52e57..e999f5421a287 100644 --- a/src/Symfony/Component/Form/Guess/Guess.php +++ b/src/Symfony/Component/Form/Guess/Guess.php @@ -86,7 +86,7 @@ public static function getBestGuess(array $guesses) /** * Constructor. * - * @param int $confidence The confidence + * @param int $confidence The confidence * * @throws InvalidArgumentException if the given value of confidence is unknown */ @@ -103,8 +103,8 @@ public function __construct($confidence) /** * Returns the confidence that the guessed value is correct. * - * @return int One of the constants VERY_HIGH_CONFIDENCE, - * HIGH_CONFIDENCE, MEDIUM_CONFIDENCE and LOW_CONFIDENCE + * @return int One of the constants VERY_HIGH_CONFIDENCE, HIGH_CONFIDENCE, + * MEDIUM_CONFIDENCE and LOW_CONFIDENCE */ public function getConfidence() { diff --git a/src/Symfony/Component/Form/Guess/TypeGuess.php b/src/Symfony/Component/Form/Guess/TypeGuess.php index 7136b7874b699..50ab944d6f8d7 100644 --- a/src/Symfony/Component/Form/Guess/TypeGuess.php +++ b/src/Symfony/Component/Form/Guess/TypeGuess.php @@ -34,11 +34,11 @@ class TypeGuess extends Guess /** * Constructor * - * @param string $type The guessed field type - * @param array $options The options for creating instances of the - * guessed class - * @param int $confidence The confidence that the guessed class name - * is correct + * @param string $type The guessed field type + * @param array $options The options for creating instances of the + * guessed class + * @param int $confidence The confidence that the guessed class name + * is correct */ public function __construct($type, array $options, $confidence) { diff --git a/src/Symfony/Component/Form/Guess/ValueGuess.php b/src/Symfony/Component/Form/Guess/ValueGuess.php index bf450d6002dd5..c101201ff8ab5 100644 --- a/src/Symfony/Component/Form/Guess/ValueGuess.php +++ b/src/Symfony/Component/Form/Guess/ValueGuess.php @@ -27,9 +27,9 @@ class ValueGuess extends Guess /** * Constructor * - * @param string $value The guessed value - * @param int $confidence The confidence that the guessed class name - * is correct + * @param string $value The guessed value + * @param int $confidence The confidence that the guessed class name + * is correct */ public function __construct($value, $confidence) { diff --git a/src/Symfony/Component/Form/PreloadedExtension.php b/src/Symfony/Component/Form/PreloadedExtension.php index 454affd3ebeb6..804841e7b7b92 100644 --- a/src/Symfony/Component/Form/PreloadedExtension.php +++ b/src/Symfony/Component/Form/PreloadedExtension.php @@ -21,12 +21,12 @@ class PreloadedExtension implements FormExtensionInterface { /** - * @var array + * @var FormTypeInterface[] */ private $types = array(); /** - * @var array + * @var array[FormTypeExtensionInterface[]] */ private $typeExtensions = array(); diff --git a/src/Symfony/Component/Form/ResolvedFormType.php b/src/Symfony/Component/Form/ResolvedFormType.php index 0f676e53de062..b922e32561565 100644 --- a/src/Symfony/Component/Form/ResolvedFormType.php +++ b/src/Symfony/Component/Form/ResolvedFormType.php @@ -158,7 +158,6 @@ public function buildForm(FormBuilderInterface $builder, array $options) $this->innerType->buildForm($builder, $options); foreach ($this->typeExtensions as $extension) { - /* @var FormTypeExtensionInterface $extension */ $extension->buildForm($builder, $options); } } @@ -184,7 +183,6 @@ public function buildView(FormView $view, FormInterface $form, array $options) $this->innerType->buildView($view, $form, $options); foreach ($this->typeExtensions as $extension) { - /* @var FormTypeExtensionInterface $extension */ $extension->buildView($view, $form, $options); } } @@ -235,7 +233,6 @@ public function getOptionsResolver() $this->innerType->setDefaultOptions($this->optionsResolver); foreach ($this->typeExtensions as $extension) { - /* @var FormTypeExtensionInterface $extension */ $extension->setDefaultOptions($this->optionsResolver); } } diff --git a/src/Symfony/Component/Form/ResolvedFormTypeInterface.php b/src/Symfony/Component/Form/ResolvedFormTypeInterface.php index 5fd37f4b46340..e6a61c753b571 100644 --- a/src/Symfony/Component/Form/ResolvedFormTypeInterface.php +++ b/src/Symfony/Component/Form/ResolvedFormTypeInterface.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Form; +use Symfony\Component\OptionsResolver\OptionsResolverInterface; + /** * A wrapper for a form type and its extensions. * @@ -60,8 +62,8 @@ public function createBuilder(FormFactoryInterface $factory, $name, array $optio /** * Creates a new form view for a form of this type. * - * @param FormInterface $form The form to create a view for. - * @param FormView $parent The parent view or null. + * @param FormInterface $form The form to create a view for. + * @param FormView $parent The parent view or null. * * @return FormView The created form view. */ @@ -100,7 +102,7 @@ public function finishView(FormView $view, FormInterface $form, array $options); /** * Returns the configured options resolver used for this type. * - * @return \Symfony\Component\OptionsResolver\OptionsResolverInterface The options resolver. + * @return OptionsResolverInterface The options resolver. */ public function getOptionsResolver(); } diff --git a/src/Symfony/Component/Form/Test/FormBuilderInterface.php b/src/Symfony/Component/Form/Test/FormBuilderInterface.php index 711cecd0b810a..185a8a12d621f 100644 --- a/src/Symfony/Component/Form/Test/FormBuilderInterface.php +++ b/src/Symfony/Component/Form/Test/FormBuilderInterface.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Form\Test; -interface FormBuilderInterface extends \Iterator, \Symfony\Component\Form\FormBuilderInterface +use Symfony\Component\Form\FormBuilderInterface as BaseFormBuilderInterface; + +interface FormBuilderInterface extends \Iterator, BaseFormBuilderInterface { } diff --git a/src/Symfony/Component/Form/Test/FormIntegrationTestCase.php b/src/Symfony/Component/Form/Test/FormIntegrationTestCase.php index 68e5f2445ec8c..a5cf86c412f3e 100644 --- a/src/Symfony/Component/Form/Test/FormIntegrationTestCase.php +++ b/src/Symfony/Component/Form/Test/FormIntegrationTestCase.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Form\Test; use Symfony\Component\Form\Forms; +use Symfony\Component\Form\FormFactoryInterface; /** * @author Bernhard Schussek @@ -19,7 +20,7 @@ abstract class FormIntegrationTestCase extends \PHPUnit_Framework_TestCase { /** - * @var \Symfony\Component\Form\FormFactoryInterface + * @var FormFactoryInterface */ protected $factory; diff --git a/src/Symfony/Component/Form/Test/FormInterface.php b/src/Symfony/Component/Form/Test/FormInterface.php index 22a83fd76f127..4af46030870cf 100644 --- a/src/Symfony/Component/Form/Test/FormInterface.php +++ b/src/Symfony/Component/Form/Test/FormInterface.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Form\Test; -interface FormInterface extends \Iterator, \Symfony\Component\Form\FormInterface +use Symfony\Component\Form\FormInterface as BaseFormInterface; + +interface FormInterface extends \Iterator, BaseFormInterface { } diff --git a/src/Symfony/Component/Form/Test/FormPerformanceTestCase.php b/src/Symfony/Component/Form/Test/FormPerformanceTestCase.php index b0d07555d9944..30604729751a0 100644 --- a/src/Symfony/Component/Form/Test/FormPerformanceTestCase.php +++ b/src/Symfony/Component/Form/Test/FormPerformanceTestCase.php @@ -22,11 +22,12 @@ abstract class FormPerformanceTestCase extends FormIntegrationTestCase { /** - * @var int + * @var int */ protected $maxRunningTime = 0; /** + * {@inheritdoc} */ protected function runTest() { @@ -47,7 +48,8 @@ protected function runTest() } /** - * @param int $maxRunningTime + * @param int $maxRunningTime + * * @throws \InvalidArgumentException */ public function setMaxRunningTime($maxRunningTime) @@ -60,8 +62,9 @@ public function setMaxRunningTime($maxRunningTime) } /** + * @since Method available since Release 2.3.0 + * * @return int - * @since Method available since Release 2.3.0 */ public function getMaxRunningTime() { From deb70c7eea6c418831e3c03e495e9f5dcca747ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 9 Jul 2014 17:16:57 +0200 Subject: [PATCH 1133/1305] [Upgrade] Fixed markdown syntax --- UPGRADE-2.3.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UPGRADE-2.3.md b/UPGRADE-2.3.md index 0b64a58a86264..f03a76f7b60e1 100644 --- a/UPGRADE-2.3.md +++ b/UPGRADE-2.3.md @@ -110,9 +110,9 @@ Form } ``` - * The *_SET_DATA events are now guaranteed to be fired *after* the children + * The `*_SET_DATA` events are now guaranteed to be fired *after* the children were added by the FormBuilder (unless setData() is called manually). Before, - the *_SET_DATA events were sometimes thrown before adding child forms, + the `*_SET_DATA` events were sometimes thrown before adding child forms, which made it impossible to remove child forms dynamically. A consequence of this change is that you need to set the "auto_initialize" From 3d63f801ffe485f1ad867efa14b25053c416da14 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Thu, 10 Jul 2014 09:54:15 +0200 Subject: [PATCH 1134/1305] [HttpFoundation] Fix wrong assertion in Response test --- src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index 7b3402ce6d233..f1e37fff7b7a9 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -374,7 +374,7 @@ public function testPrepareRemovesContentForHeadRequests() $response->prepare($request); $this->assertEquals('', $response->getContent()); - $this->assertFalse($response->headers->has('Content-Type')); + $this->assertTrue($response->headers->has('Content-Type')); $this->assertFalse($response->headers->has('Content-Length')); } From 4201d419a2b355d9c3f6db06bdc38370adbc95bb Mon Sep 17 00:00:00 2001 From: Matthew Davis Date: Fri, 6 Dec 2013 17:04:55 -0500 Subject: [PATCH 1135/1305] fix issue #8171 on configuration tree for twig extension -- pairing up with @cordoval --- .../Bundle/TwigBundle/DependencyInjection/Configuration.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php index 4089aee5a1066..5d46be0b3266b 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php @@ -136,6 +136,7 @@ private function addTwigOptions(ArrayNodeDefinition $rootNode) ->scalarNode('optimizations')->end() ->arrayNode('paths') ->normalizeKeys(false) + ->useAttributeAsKey('paths') ->beforeNormalization() ->always() ->then(function ($paths) { From 9aa88e44943c4a366de338877d6a5274f6ff3c13 Mon Sep 17 00:00:00 2001 From: Luis Cordova Date: Sun, 22 Dec 2013 02:17:37 -0500 Subject: [PATCH 1136/1305] added regression test --- .../Tests/DependencyInjection/Fixtures/php/extra.php | 7 +++++++ .../Tests/DependencyInjection/Fixtures/php/full.php | 4 ++-- .../Tests/DependencyInjection/Fixtures/xml/extra.xml | 12 ++++++++++++ .../Tests/DependencyInjection/Fixtures/xml/full.xml | 4 ++-- .../Tests/DependencyInjection/Fixtures/yml/extra.yml | 3 +++ .../Tests/DependencyInjection/Fixtures/yml/full.yml | 4 ++-- .../Tests/DependencyInjection/TwigExtensionTest.php | 6 ++++-- src/Symfony/Component/Finder/Tests/FinderTest.php | 3 +-- 8 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/extra.php create mode 100644 src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/extra.xml create mode 100644 src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/extra.yml diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/extra.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/extra.php new file mode 100644 index 0000000000000..47d00ef445f1c --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/extra.php @@ -0,0 +1,7 @@ +loadFromExtension('twig', array( + 'paths' => array( + 'namespaced_path3' => 'namespace3', + ), +)); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php index 24ba3f60d3317..3d2a14d00d327 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php @@ -22,7 +22,7 @@ 'paths' => array( 'path1', 'path2', - 'namespaced_path1' => 'namespace', - 'namespaced_path2' => 'namespace', + 'namespaced_path1' => 'namespace1', + 'namespaced_path2' => 'namespace2', ), )); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/extra.xml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/extra.xml new file mode 100644 index 0000000000000..174b3e1b6c2d6 --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/extra.xml @@ -0,0 +1,12 @@ + + + + + + namespaced_path3 + + diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/full.xml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/full.xml index 85e2d8fd9a488..3e1acaeb6eefa 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/full.xml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/full.xml @@ -15,7 +15,7 @@ 3.14 path1 path2 - namespaced_path1 - namespaced_path2 + namespaced_path1 + namespaced_path2
    diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/extra.yml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/extra.yml new file mode 100644 index 0000000000000..3c5e6a3b5937a --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/extra.yml @@ -0,0 +1,3 @@ +twig: + paths: + namespaced_path3: namespace3 diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/full.yml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/full.yml index ecbc92aff390e..1d453c553fabc 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/full.yml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/full.yml @@ -17,5 +17,5 @@ twig: paths: path1: '' path2: '' - namespaced_path1: namespace - namespaced_path2: namespace + namespaced_path1: namespace1 + namespaced_path2: namespace2 diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php index 558187486d981..6d0fc467e5f4d 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php @@ -145,6 +145,7 @@ public function testTwigLoaderPaths($format) $container = $this->createContainer(); $container->registerExtension(new TwigExtension()); $this->loadFromFile($container, 'full', $format); + $this->loadFromFile($container, 'extra', $format); $this->compileContainer($container); $def = $container->getDefinition('twig.loader.filesystem'); @@ -160,8 +161,9 @@ public function testTwigLoaderPaths($format) $this->assertEquals(array( array('path1'), array('path2'), - array('namespaced_path1', 'namespace'), - array('namespaced_path2', 'namespace'), + array('namespaced_path1', 'namespace1'), + array('namespaced_path2', 'namespace2'), + array('namespaced_path3', 'namespace3'), array(__DIR__.'/Fixtures/Resources/TwigBundle/views', 'Twig'), array(realpath(__DIR__.'/../..').'/Resources/views', 'Twig'), array(__DIR__.'/Fixtures/Resources/views'), diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index a42b0d7c650ff..9f9e47b6469af 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -16,7 +16,6 @@ class FinderTest extends Iterator\RealIteratorTestCase { - public function testCreate() { $this->assertInstanceOf('Symfony\Component\Finder\Finder', Finder::create()); @@ -796,7 +795,7 @@ function (Adapter\AdapterInterface $adapter) { ); } - /** + /** * Searching in multiple locations with sub directories involves * AppendIterator which does an unnecessary rewind which leaves * FilterIterator with inner FilesystemIterator in an invalid state. From 6af3d05b851161a42d29b1c032f30611c0b873ce Mon Sep 17 00:00:00 2001 From: Andrew Moore Date: Thu, 10 Jul 2014 09:27:11 -0400 Subject: [PATCH 1137/1305] [HttpFoundation] Fix to prevent magic bytes injection in JSONP responses (Prevents CVE-2014-4671) --- src/Symfony/Component/HttpFoundation/JsonResponse.php | 2 +- src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/JsonResponse.php b/src/Symfony/Component/HttpFoundation/JsonResponse.php index 15e7b582f74fa..83a607cd6ef21 100644 --- a/src/Symfony/Component/HttpFoundation/JsonResponse.php +++ b/src/Symfony/Component/HttpFoundation/JsonResponse.php @@ -111,7 +111,7 @@ protected function update() // Not using application/javascript for compatibility reasons with older browsers. $this->headers->set('Content-Type', 'text/javascript'); - return $this->setContent(sprintf('%s(%s);', $this->callback, $this->data)); + return $this->setContent(sprintf('/**/%s(%s);', $this->callback, $this->data)); } // Only set the header when there is none or when it equals 'text/javascript' (from a previous update with callback) diff --git a/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php index ef392ca59dbe6..2cb6b68550f16 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php @@ -155,7 +155,7 @@ public function testSetCallback() { $response = JsonResponse::create(array('foo' => 'bar'))->setCallback('callback'); - $this->assertEquals('callback({"foo":"bar"});', $response->getContent()); + $this->assertEquals('/**/callback({"foo":"bar"});', $response->getContent()); $this->assertEquals('text/javascript', $response->headers->get('Content-Type')); } From ea45769aaba270d05010bb36c23e25ad6fceb55a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 11 Jul 2014 11:32:34 +0200 Subject: [PATCH 1138/1305] fixed typo --- .../Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php b/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php index e63c26305208e..e292a24e3d923 100644 --- a/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php +++ b/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php @@ -51,7 +51,7 @@ public function warmUp($cacheDir) /** * Checks whether this warmer is optional or not. * - * @return bool always true + * @return bool always false */ public function isOptional() { From 9e1ea4aa4b21db1040d6e92a2b6dfa0bf5ad672a Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Tue, 1 Jul 2014 20:28:47 +0700 Subject: [PATCH 1139/1305] [Process] Use correct test for empty string in UnixPipes --- src/Symfony/Component/Process/ProcessPipes.php | 4 ++-- src/Symfony/Component/Process/Tests/AbstractProcessTest.php | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Process/ProcessPipes.php b/src/Symfony/Component/Process/ProcessPipes.php index f35d1c1287775..850741e6a8155 100644 --- a/src/Symfony/Component/Process/ProcessPipes.php +++ b/src/Symfony/Component/Process/ProcessPipes.php @@ -313,11 +313,11 @@ private function readStreams($blocking, $close = false) $type = array_search($pipe, $this->pipes); $data = ''; - while ($dataread = fread($pipe, self::CHUNK_SIZE)) { + while ('' !== $dataread = (string) fread($pipe, self::CHUNK_SIZE)) { $data .= $dataread; } - if ($data) { + if ('' !== $data) { $read[$type] = $data; } diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index 91b8aca20d06a..307487474348d 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -287,6 +287,12 @@ public function testGetIncrementalOutput() } } + public function testZeroAsOutput(){ + $p = $this->getProcess('printf 0'); + $p->run(); + $this->assertSame('0', $p->getOutput()); + } + public function testExitCodeCommandFailed() { if (defined('PHP_WINDOWS_VERSION_BUILD')) { From 8f9ed3ebb9ef126cc8940da493f252619671c0f3 Mon Sep 17 00:00:00 2001 From: Christopher Davis Date: Sun, 13 Jul 2014 13:09:52 -0400 Subject: [PATCH 1140/1305] Remove Spaceless Blocks from Twig Form Templates In favor of using Twig's whitespace control operators. See #11277 --- .../views/Form/form_div_layout.html.twig | 418 +++++++----------- .../views/Form/form_table_layout.html.twig | 44 +- 2 files changed, 187 insertions(+), 275 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 9440658cbe7a6..c14031a713fab 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 @@ -1,393 +1,313 @@ {# Widgets #} -{% block form_widget %} -{% spaceless %} +{% block form_widget -%} {% if compound %} - {{ block('form_widget_compound') }} + {{- block('form_widget_compound') -}} {% else %} - {{ block('form_widget_simple') }} + {{- block('form_widget_simple') -}} {% endif %} -{% endspaceless %} -{% endblock form_widget %} +{%- endblock form_widget %} -{% block form_widget_simple %} -{% spaceless %} - {% set type = type|default('text') %} +{% block form_widget_simple -%} + {%- set type = type|default('text') -%} -{% endspaceless %} -{% endblock form_widget_simple %} +{%- endblock form_widget_simple %} -{% block form_widget_compound %} -{% spaceless %} +{% block form_widget_compound -%}
    - {% if form.parent is empty %} + {%- if form.parent is empty -%} {{ form_errors(form) }} - {% endif %} - {{ block('form_rows') }} - {{ form_rest(form) }} + {%- endif -%} + {{- block('form_rows') -}} + {{- form_rest(form) -}}
    -{% endspaceless %} -{% endblock form_widget_compound %} +{%- endblock form_widget_compound %} -{% block collection_widget %} -{% spaceless %} +{% block collection_widget -%} {% if prototype is defined %} - {% set attr = attr|merge({'data-prototype': form_row(prototype) }) %} + {%- set attr = attr|merge({'data-prototype': form_row(prototype) }) -%} {% endif %} - {{ block('form_widget') }} -{% endspaceless %} -{% endblock collection_widget %} + {{- block('form_widget') -}} +{%- endblock collection_widget %} -{% block textarea_widget %} -{% spaceless %} +{% block textarea_widget -%} -{% endspaceless %} -{% endblock textarea_widget %} +{%- endblock textarea_widget %} -{% block choice_widget %} -{% spaceless %} +{% block choice_widget -%} {% if expanded %} - {{ block('choice_widget_expanded') }} + {{- block('choice_widget_expanded') -}} {% else %} - {{ block('choice_widget_collapsed') }} + {{- block('choice_widget_collapsed') -}} {% endif %} -{% endspaceless %} -{% endblock choice_widget %} +{%- endblock choice_widget %} -{% block choice_widget_expanded %} -{% spaceless %} +{% block choice_widget_expanded -%}
    {% for child in form %} - {{ form_widget(child) }} - {{ form_label(child) }} + {{- form_widget(child) -}} + {{- form_label(child) -}} {% endfor %}
    -{% endspaceless %} -{% endblock choice_widget_expanded %} +{%- endblock choice_widget_expanded %} -{% block choice_widget_collapsed %} -{% spaceless %} +{% block choice_widget_collapsed -%} {% if required and empty_value is none and not empty_value_in_choices and not multiple %} {% set required = false %} {% endif %} -{% endspaceless %} -{% endblock choice_widget_collapsed %} +{%- endblock choice_widget_collapsed %} -{% block choice_widget_options %} -{% spaceless %} +{% block choice_widget_options -%} {% for group_label, choice in options %} - {% if choice is iterable %} + {%- if choice is iterable -%} {% set options = choice %} - {{ block('choice_widget_options') }} + {{- block('choice_widget_options') -}} - {% else %} + {%- else -%} - {% endif %} + {%- endif -%} {% endfor %} -{% endspaceless %} -{% endblock choice_widget_options %} +{%- endblock choice_widget_options %} -{% block checkbox_widget %} -{% spaceless %} +{% block checkbox_widget -%} -{% endspaceless %} -{% endblock checkbox_widget %} +{%- endblock checkbox_widget %} -{% block radio_widget %} -{% spaceless %} +{% block radio_widget -%} -{% endspaceless %} -{% endblock radio_widget %} +{%- endblock radio_widget %} -{% block datetime_widget %} -{% spaceless %} +{% block datetime_widget -%} {% if widget == 'single_text' %} - {{ block('form_widget_simple') }} - {% else %} + {{- block('form_widget_simple') -}} + {% else -%}
    - {{ form_errors(form.date) }} - {{ form_errors(form.time) }} - {{ form_widget(form.date) }} - {{ form_widget(form.time) }} + {{- form_errors(form.date) -}} + {{- form_errors(form.time) -}} + {{- form_widget(form.date) -}} + {{- form_widget(form.time) -}}
    - {% endif %} -{% endspaceless %} -{% endblock datetime_widget %} + {%- endif %} +{%- endblock datetime_widget %} -{% block date_widget %} -{% spaceless %} - {% if widget == 'single_text' %} +{% block date_widget -%} + {% if widget == 'single_text' -%} {{ block('form_widget_simple') }} - {% else %} + {%- else -%}
    - {{ date_pattern|replace({ + {{- date_pattern|replace({ '{{ year }}': form_widget(form.year), '{{ month }}': form_widget(form.month), '{{ day }}': form_widget(form.day), - })|raw }} + })|raw -}}
    - {% endif %} -{% endspaceless %} -{% endblock date_widget %} + {%- endif %} +{%- endblock date_widget %} -{% block time_widget %} -{% spaceless %} - {% if widget == 'single_text' %} +{% block time_widget -%} + {% if widget == 'single_text' -%} {{ block('form_widget_simple') }} - {% else %} - {% set vars = widget == 'text' ? { 'attr': { 'size': 1 }} : {} %} + {%- else -%} + {% set vars = widget == 'text' ? { 'attr': { 'size': 1 }} : {} -%}
    {{ form_widget(form.hour, vars) }}{% if with_minutes %}:{{ form_widget(form.minute, vars) }}{% endif %}{% if with_seconds %}:{{ form_widget(form.second, vars) }}{% endif %}
    - {% endif %} -{% endspaceless %} -{% endblock time_widget %} + {%- endif %} +{%- endblock time_widget %} -{% block number_widget %} -{% spaceless %} +{% block number_widget -%} {# type="number" doesn't work with floats #} - {% set type = type|default('text') %} + {%- set type = type|default('text') -%} {{ block('form_widget_simple') }} -{% endspaceless %} -{% endblock number_widget %} +{%- endblock number_widget %} -{% block integer_widget %} -{% spaceless %} +{% block integer_widget -%} {% set type = type|default('number') %} - {{ block('form_widget_simple') }} -{% endspaceless %} -{% endblock integer_widget %} + {{- block('form_widget_simple') -}} +{%- endblock integer_widget %} -{% block money_widget %} -{% spaceless %} +{% block money_widget -%} {{ money_pattern|replace({ '{{ widget }}': block('form_widget_simple') })|raw }} -{% endspaceless %} -{% endblock money_widget %} +{%- endblock money_widget %} -{% block url_widget %} -{% spaceless %} - {% set type = type|default('url') %} +{% block url_widget -%} + {% set type = type|default('url') -%} {{ block('form_widget_simple') }} -{% endspaceless %} -{% endblock url_widget %} +{%- endblock url_widget %} -{% block search_widget %} -{% spaceless %} - {% set type = type|default('search') %} +{% block search_widget -%} + {% set type = type|default('search') -%} {{ block('form_widget_simple') }} -{% endspaceless %} -{% endblock search_widget %} +{%- endblock search_widget %} -{% block percent_widget %} -{% spaceless %} - {% set type = type|default('text') %} +{% block percent_widget -%} + {% set type = type|default('text') -%} {{ block('form_widget_simple') }} % -{% endspaceless %} -{% endblock percent_widget %} +{%- endblock percent_widget %} -{% block password_widget %} -{% spaceless %} - {% set type = type|default('password') %} +{% block password_widget -%} + {% set type = type|default('password') -%} {{ block('form_widget_simple') }} -{% endspaceless %} -{% endblock password_widget %} +{%- endblock password_widget %} -{% block hidden_widget %} -{% spaceless %} - {% set type = type|default('hidden') %} +{% block hidden_widget -%} + {% set type = type|default('hidden') -%} {{ block('form_widget_simple') }} -{% endspaceless %} -{% endblock hidden_widget %} +{%- endblock hidden_widget %} -{% block email_widget %} -{% spaceless %} - {% set type = type|default('email') %} +{% block email_widget -%} + {% set type = type|default('email') -%} {{ block('form_widget_simple') }} -{% endspaceless %} -{% endblock email_widget %} +{%- endblock email_widget %} -{% block button_widget %} -{% spaceless %} - {% if label is empty %} +{% block button_widget -%} + {% if label is empty -%} {% set label = name|humanize %} - {% endif %} + {%- endif -%} -{% endspaceless %} -{% endblock button_widget %} +{%- endblock button_widget %} -{% block submit_widget %} -{% spaceless %} - {% set type = type|default('submit') %} +{% block submit_widget -%} + {% set type = type|default('submit') -%} {{ block('button_widget') }} -{% endspaceless %} -{% endblock submit_widget %} +{%- endblock submit_widget %} -{% block reset_widget %} -{% spaceless %} - {% set type = type|default('reset') %} +{% block reset_widget -%} + {% set type = type|default('reset') -%} {{ block('button_widget') }} -{% endspaceless %} -{% endblock reset_widget %} +{%- endblock reset_widget %} {# Labels #} -{% block form_label %} -{% spaceless %} +{% block form_label -%} {% if label is not sameas(false) %} - {% if not compound %} + {%- if not compound -%} {% set label_attr = label_attr|merge({'for': id}) %} - {% endif %} - {% if required %} + {%- endif -%} + {%- if required -%} {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %} - {% endif %} - {% if label is empty %} + {%- endif -%} + {%- if label is empty -%} {% set label = name|humanize %} - {% endif %} + {%- endif -%} {{ label|trans({}, translation_domain) }} - {% endif %} -{% endspaceless %} -{% endblock form_label %} + {%- endif %} +{%- endblock form_label %} -{% block button_label %}{% endblock %} +{% block button_label -%}{%- endblock %} {# Rows #} -{% block repeated_row %} -{% spaceless %} +{% block repeated_row -%} {# No need to render the errors here, as all errors are mapped to the first child (see RepeatedTypeValidatorExtension). #} - {{ block('form_rows') }} -{% endspaceless %} -{% endblock repeated_row %} + {{- block('form_rows') }} +{%- endblock repeated_row %} -{% block form_row %} -{% spaceless %} +{% block form_row -%}
    - {{ form_label(form) }} - {{ form_errors(form) }} - {{ form_widget(form) }} + {{- form_label(form) -}} + {{- form_errors(form) -}} + {{- form_widget(form) -}}
    -{% endspaceless %} -{% endblock form_row %} +{%- endblock form_row %} -{% block button_row %} -{% spaceless %} +{% block button_row -%}
    - {{ form_widget(form) }} + {{- form_widget(form) -}}
    -{% endspaceless %} -{% endblock button_row %} +{%- endblock button_row %} -{% block hidden_row %} +{% block hidden_row -%} {{ form_widget(form) }} -{% endblock hidden_row %} +{%- endblock hidden_row %} {# Misc #} -{% block form %} -{% spaceless %} +{% block form -%} {{ form_start(form) }} - {{ form_widget(form) }} + {{- form_widget(form) -}} {{ form_end(form) }} -{% endspaceless %} -{% endblock form %} +{%- endblock form %} -{% block form_start %} -{% spaceless %} +{% block form_start -%} {% set method = method|upper %} - {% if method in ["GET", "POST"] %} + {%- if method in ["GET", "POST"] -%} {% set form_method = method %} - {% else %} + {%- else -%} {% set form_method = "POST" %} - {% endif %} + {%- endif -%}
    - {% if form_method != method %} + {%- if form_method != method -%} - {% endif %} -{% endspaceless %} -{% endblock form_start %} + {%- endif %} +{%- endblock form_start %} -{% block form_end %} -{% spaceless %} - {% if not render_rest is defined or render_rest %} +{% block form_end -%} + {% if not render_rest is defined or render_rest -%} {{ form_rest(form) }} - {% endif %} + {%- endif -%}
    -{% endspaceless %} -{% endblock form_end %} +{%- endblock form_end %} -{% block form_enctype %} -{% spaceless %} +{% block form_enctype -%} {% if multipart %}enctype="multipart/form-data"{% endif %} -{% endspaceless %} -{% endblock form_enctype %} +{%- endblock form_enctype %} -{% block form_errors %} -{% spaceless %} - {% if errors|length > 0 %} +{% block form_errors -%} + {% if errors|length > 0 -%}
      - {% for error in errors %} + {%- for error in errors -%}
    • {{ error.message }}
    • - {% endfor %} + {%- endfor -%}
    - {% endif %} -{% endspaceless %} -{% endblock form_errors %} + {%- endif %} +{%- endblock form_errors %} -{% block form_rest %} -{% spaceless %} - {% for child in form %} - {% if not child.rendered %} +{% block form_rest -%} + {% for child in form -%} + {% if not child.rendered -%} {{ form_row(child) }} - {% endif %} - {% endfor %} -{% endspaceless %} -{% endblock form_rest %} + {%- endif %} + {%- endfor %} +{%- endblock form_rest %} {# Support #} -{% block form_rows %} -{% spaceless %} - {% for child in form %} +{% block form_rows -%} + {% for child in form -%} {{ form_row(child) }} - {% endfor %} -{% endspaceless %} -{% endblock form_rows %} + {%- endfor %} +{%- endblock form_rows %} -{% block widget_attributes %} -{% spaceless %} +{% block widget_attributes -%} id="{{ id }}" name="{{ full_name }}"{% if read_only %} readonly="readonly"{% endif %}{% if disabled %} disabled="disabled"{% endif %}{% if required %} required="required"{% endif %}{% if max_length %} maxlength="{{ max_length }}"{% endif %}{% if pattern %} pattern="{{ pattern }}"{% endif %} {% for attrname, attrvalue in attr %}{% if attrname in ['placeholder', 'title'] %}{{ attrname }}="{{ attrvalue|trans({}, translation_domain) }}" {% else %}{{ attrname }}="{{ attrvalue }}" {% endif %}{% endfor %} -{% endspaceless %} -{% endblock widget_attributes %} +{%- endblock widget_attributes %} -{% block widget_container_attributes %} -{% spaceless %} +{% block widget_container_attributes -%} {% if id is not empty %}id="{{ id }}" {% endif %} - {% for attrname, attrvalue in attr %}{{ attrname }}="{{ attrvalue }}" {% endfor %} -{% endspaceless %} -{% endblock widget_container_attributes %} + {%- for attrname, attrvalue in attr %}{{ attrname }}="{{ attrvalue }}" {% endfor %} +{%- endblock widget_container_attributes %} -{% block button_attributes %} -{% spaceless %} +{% block button_attributes -%} id="{{ id }}" name="{{ full_name }}"{% if disabled %} disabled="disabled"{% endif %} - {% for attrname, attrvalue in attr %}{{ attrname }}="{{ attrvalue }}" {% endfor %} -{% endspaceless %} -{% endblock button_attributes %} + {%- for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %} +{%- endblock button_attributes %} diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/form_table_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/form_table_layout.html.twig index aed4f8d77042d..d3d7a34f40ddc 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/form_table_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/form_table_layout.html.twig @@ -1,52 +1,44 @@ {% use "form_div_layout.html.twig" %} -{% block form_row %} -{% spaceless %} +{% block form_row -%} - {{ form_label(form) }} + {{- form_label(form) -}} - {{ form_errors(form) }} - {{ form_widget(form) }} + {{- form_errors(form) -}} + {{- form_widget(form) -}} -{% endspaceless %} -{% endblock form_row %} +{%- endblock form_row %} -{% block button_row %} -{% spaceless %} +{% block button_row -%} - {{ form_widget(form) }} + {{- form_widget(form) -}} -{% endspaceless %} -{% endblock button_row %} +{%- endblock button_row %} -{% block hidden_row %} -{% spaceless %} +{% block hidden_row -%} - {{ form_widget(form) }} + {{- form_widget(form) -}} -{% endspaceless %} -{% endblock hidden_row %} +{%- endblock hidden_row %} -{% block form_widget_compound %} -{% spaceless %} +{% block form_widget_compound -%} - {% if form.parent is empty and errors|length > 0 %} + {% if form.parent is empty and errors|length > 0 -%} - {% endif %} - {{ block('form_rows') }} - {{ form_rest(form) }} + {%- endif %} + {{- block('form_rows') -}} + {{- form_rest(form) -}}
    - {{ form_errors(form) }} + {{- form_errors(form) -}}
    -{% endspaceless %} -{% endblock form_widget_compound %} +{%- endblock form_widget_compound %} From 73d50edc17928d8bf3fb99dc8d964d675d2c240c Mon Sep 17 00:00:00 2001 From: redstar504 Date: Sun, 13 Jul 2014 22:59:18 -0700 Subject: [PATCH 1141/1305] Fix UserPassword validator translation --- .../Validator/Resources/translations/validators.en.xlf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.en.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.en.xlf index 3b8b5d97a8bd7..756b80b37f962 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.en.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.en.xlf @@ -176,7 +176,7 @@ This value should be the user current password. - This value should be the user current password. + This value should be the user's current password. This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters. From 06a80fbdbe744ad6f3010479ba64ef5cf35dd9af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Fri, 4 Jul 2014 19:20:43 +0200 Subject: [PATCH 1142/1305] Validate locales sets intos translator --- .../Tests/Translation/TranslatorTest.php | 17 +- .../Translation/Translator.php | 6 +- .../Translation/Tests/TranslatorTest.php | 175 ++++++++++++++++++ .../Component/Translation/Translator.php | 35 +++- .../Translation/TranslatorInterface.php | 6 + 5 files changed, 233 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php index 614f6dbc2d2c7..715c44fade207 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php @@ -45,7 +45,7 @@ public function testTransWithoutCaching() { $translator = $this->getTranslator($this->getLoader()); $translator->setLocale('fr'); - $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR')); + $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8')); $this->assertEquals('foo (FR)', $translator->trans('foo')); $this->assertEquals('bar (EN)', $translator->trans('bar')); @@ -54,6 +54,7 @@ public function testTransWithoutCaching() $this->assertEquals('no translation', $translator->trans('no translation')); $this->assertEquals('foobarfoo (PT-PT)', $translator->trans('foobarfoo')); $this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1)); + $this->assertEquals('foobarbaz (fr.UTF-8)', $translator->trans('foobarbaz')); } public function testTransWithCaching() @@ -61,7 +62,7 @@ public function testTransWithCaching() // prime the cache $translator = $this->getTranslator($this->getLoader(), array('cache_dir' => $this->tmpDir)); $translator->setLocale('fr'); - $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR')); + $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8')); $this->assertEquals('foo (FR)', $translator->trans('foo')); $this->assertEquals('bar (EN)', $translator->trans('bar')); @@ -70,12 +71,13 @@ public function testTransWithCaching() $this->assertEquals('no translation', $translator->trans('no translation')); $this->assertEquals('foobarfoo (PT-PT)', $translator->trans('foobarfoo')); $this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1)); + $this->assertEquals('foobarbaz (fr.UTF-8)', $translator->trans('foobarbaz')); // do it another time as the cache is primed now $loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface'); $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir)); $translator->setLocale('fr'); - $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR')); + $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8')); $this->assertEquals('foo (FR)', $translator->trans('foo')); $this->assertEquals('bar (EN)', $translator->trans('bar')); @@ -84,6 +86,7 @@ public function testTransWithCaching() $this->assertEquals('no translation', $translator->trans('no translation')); $this->assertEquals('foobarfoo (PT-PT)', $translator->trans('foobarfoo')); $this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1)); + $this->assertEquals('foobarbaz (fr.UTF-8)', $translator->trans('foobarbaz')); } public function testGetLocale() @@ -175,6 +178,13 @@ protected function getLoader() 'other choice' => '{0} other choice 0 (PT-BR)|{1} other choice 1 (PT-BR)|]1,Inf] other choice inf (PT-BR)', )))) ; + $loader + ->expects($this->at(5)) + ->method('load') + ->will($this->returnValue($this->getCatalogue('fr.UTF-8', array( + 'foobarbaz' => 'foobarbaz (fr.UTF-8)', + )))) + ; return $loader; } @@ -205,6 +215,7 @@ public function getTranslator($loader, $options = array()) $translator->addResource('loader', 'foo', 'es'); $translator->addResource('loader', 'foo', 'pt-PT'); // European Portuguese $translator->addResource('loader', 'foo', 'pt_BR'); // Brazilian Portuguese + $translator->addResource('loader', 'foo', 'fr.UTF-8'); return $translator; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php index 1705c1ac06c18..0f99f6428e84e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php @@ -97,8 +97,10 @@ protected function loadCatalogue($locale) $fallbackContent = ''; $current = ''; + $replacementPattern = '/[^a-z0-9_]/i'; foreach ($this->computeFallbackLocales($locale) as $fallback) { - $fallbackSuffix = ucfirst(str_replace('-', '_', $fallback)); + $fallbackSuffix = ucfirst(preg_replace($replacementPattern, '_', $fallback)); + $currentSuffix = ucfirst(preg_replace($replacementPattern, '_', $current)); $fallbackContent .= sprintf(<<catalogues[$fallback]->all(), true), - ucfirst(str_replace('-', '_', $current)), + $currentSuffix, $fallbackSuffix ); $current = $fallback; diff --git a/src/Symfony/Component/Translation/Tests/TranslatorTest.php b/src/Symfony/Component/Translation/Tests/TranslatorTest.php index e45ab3b4819fb..40a0b1d0d9021 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorTest.php @@ -17,6 +17,33 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase { + + /** + * @dataProvider getInvalidLocalesTests + * @expectedException \InvalidArgumentException + */ + public function testConstructorInvalidLocale($locale) + { + $translator = new Translator($locale, new MessageSelector()); + } + + /** + * @dataProvider getValidLocalesTests + */ + public function testConstructorValidLocale($locale) + { + $translator = new Translator($locale, new MessageSelector()); + + $this->assertEquals($locale, $translator->getLocale()); + } + + public function testConstructorWithoutLocale() + { + $translator = new Translator(null, new MessageSelector()); + + $this->assertNull($translator->getLocale()); + } + public function testSetGetLocale() { $translator = new Translator('en', new MessageSelector()); @@ -27,6 +54,27 @@ public function testSetGetLocale() $this->assertEquals('fr', $translator->getLocale()); } + /** + * @dataProvider getInvalidLocalesTests + * @expectedException \InvalidArgumentException + */ + public function testSetInvalidLocale($locale) + { + $translator = new Translator('fr', new MessageSelector()); + $translator->setLocale($locale); + } + + /** + * @dataProvider getValidLocalesTests + */ + public function testSetValidLocale($locale) + { + $translator = new Translator($locale, new MessageSelector()); + $translator->setLocale($locale); + + $this->assertEquals($locale, $translator->getLocale()); + } + public function testSetFallbackLocales() { $translator = new Translator('en', new MessageSelector()); @@ -55,6 +103,27 @@ public function testSetFallbackLocalesMultiple() $this->assertEquals('bar (fr)', $translator->trans('bar')); } + + /** + * @dataProvider getInvalidLocalesTests + * @expectedException \InvalidArgumentException + */ + public function testSetFallbackInvalidLocales($locale) + { + $translator = new Translator('fr', new MessageSelector()); + $translator->setFallbackLocales(array('fr', $locale)); + } + + /** + * @dataProvider getValidLocalesTests + */ + public function testSetFallbackValidLocales($locale) + { + $translator = new Translator($locale, new MessageSelector()); + $translator->setFallbackLocales(array('fr', $locale)); + // no assertion. this method just asserts that no exception is thrown + } + public function testTransWithFallbackLocale() { $translator = new Translator('fr_FR', new MessageSelector()); @@ -67,6 +136,26 @@ public function testTransWithFallbackLocale() $this->assertEquals('foobar', $translator->trans('bar')); } + /** + * @dataProvider getInvalidLocalesTests + * @expectedException \InvalidArgumentException + */ + public function testAddResourceInvalidLocales($locale) + { + $translator = new Translator('fr', new MessageSelector()); + $translator->addResource('array', array('foo' => 'foofoo'), $locale); + } + + /** + * @dataProvider getValidLocalesTests + */ + public function testAddResourceValidLocales($locale) + { + $translator = new Translator('fr', new MessageSelector()); + $translator->addResource('array', array('foo' => 'foofoo'), $locale); + // no assertion. this method just asserts that no exception is thrown + } + public function testAddResourceAfterTrans() { $translator = new Translator('fr', new MessageSelector()); @@ -164,6 +253,32 @@ public function testTrans($expected, $id, $translation, $parameters, $locale, $d $this->assertEquals($expected, $translator->trans($id, $parameters, $domain, $locale)); } + /** + * @dataProvider getInvalidLocalesTests + * @expectedException \InvalidArgumentException + */ + public function testTransInvalidLocale($locale) + { + $translator = new Translator('en', new MessageSelector()); + $translator->addLoader('array', new ArrayLoader()); + $translator->addResource('array', array('foo' => 'foofoo'), 'en'); + + $translator->trans('foo', array(), '', $locale); + } + + /** + * @dataProvider getValidLocalesTests + */ + public function testTransValidLocale($locale) + { + $translator = new Translator('en', new MessageSelector()); + $translator->addLoader('array', new ArrayLoader()); + $translator->addResource('array', array('foo' => 'foofoo'), 'en'); + + $translator->trans('foo', array(), '', $locale); + // no assertion. this method just asserts that no exception is thrown + } + /** * @dataProvider getFlattenedTransTests */ @@ -188,6 +303,33 @@ public function testTransChoice($expected, $id, $translation, $number, $paramete $this->assertEquals($expected, $translator->transChoice($id, $number, $parameters, $domain, $locale)); } + /** + * @dataProvider getInvalidLocalesTests + * @expectedException \InvalidArgumentException + */ + public function testTransChoiceInvalidLocale($locale) + { + $translator = new Translator('en', new MessageSelector()); + $translator->addLoader('array', new ArrayLoader()); + $translator->addResource('array', array('foo' => 'foofoo'), 'en'); + + $translator->transChoice('foo', 1, array(), '', $locale); + } + + /** + * @dataProvider getValidLocalesTests + */ + public function testTransChoiceValidLocale($locale) + { + $translator = new Translator('en', new MessageSelector()); + $translator->addLoader('array', new ArrayLoader()); + $translator->addResource('array', array('foo' => 'foofoo'), 'en'); + + $translator->transChoice('foo', 1, array(), '', $locale); + // no assertion. this method just asserts that no exception is thrown + } + + public function getTransFileTests() { return array( @@ -257,6 +399,39 @@ public function getTransChoiceTests() ); } + public function getInvalidLocalesTests() + { + return array( + array('fr FR'), + array('français'), + array('fr+en'), + array('utf#8'), + array('fr&en'), + array('fr~FR'), + array(' fr'), + array('fr '), + array('fr*'), + array('fr/FR'), + array('fr\\FR'), + ); + } + + public function getValidLocalesTests() + { + return array( + array(''), + array(null), + array('fr'), + array('francais'), + array('FR'), + array('frFR'), + array('fr-FR'), + array('fr_FR'), + array('fr.FR'), + array('fr-FR.UTF8'), + ); + } + public function testTransChoiceFallback() { $translator = new Translator('ru', new MessageSelector()); diff --git a/src/Symfony/Component/Translation/Translator.php b/src/Symfony/Component/Translation/Translator.php index 8e74b79f60836..e54b300ffd5d3 100644 --- a/src/Symfony/Component/Translation/Translator.php +++ b/src/Symfony/Component/Translation/Translator.php @@ -59,11 +59,13 @@ class Translator implements TranslatorInterface * @param string $locale The locale * @param MessageSelector|null $selector The message selector for pluralization * + * @throws \InvalidArgumentException If a locale contains invalid characters + * * @api */ public function __construct($locale, MessageSelector $selector = null) { - $this->locale = $locale; + $this->setLocale($locale); $this->selector = $selector ?: new MessageSelector(); } @@ -88,6 +90,8 @@ public function addLoader($format, LoaderInterface $loader) * @param string $locale The locale * @param string $domain The domain * + * @throws \InvalidArgumentException If the locale contains invalid characters + * * @api */ public function addResource($format, $resource, $locale, $domain = null) @@ -96,6 +100,8 @@ public function addResource($format, $resource, $locale, $domain = null) $domain = 'messages'; } + $this->assertValidLocale($locale); + $this->resources[$locale][] = array($format, $resource, $domain); if (in_array($locale, $this->fallbackLocales)) { @@ -112,6 +118,7 @@ public function addResource($format, $resource, $locale, $domain = null) */ public function setLocale($locale) { + $this->assertValidLocale($locale); $this->locale = $locale; } @@ -130,6 +137,8 @@ public function getLocale() * * @param string|array $locales The fallback locale(s) * + * @throws \InvalidArgumentException If a locale contains invalid characters + * * @deprecated since 2.3, to be removed in 3.0. Use setFallbackLocales() instead. * * @api @@ -144,6 +153,8 @@ public function setFallbackLocale($locales) * * @param array $locales The fallback locales * + * @throws \InvalidArgumentException If a locale contains invalid characters + * * @api */ public function setFallbackLocales(array $locales) @@ -151,6 +162,10 @@ public function setFallbackLocales(array $locales) // needed as the fallback locales are linked to the already loaded catalogues $this->catalogues = array(); + foreach ($locales as $locale) { + $this->assertValidLocale($locale); + } + $this->fallbackLocales = $locales; } @@ -175,6 +190,8 @@ public function trans($id, array $parameters = array(), $domain = null, $locale { if (null === $locale) { $locale = $this->getLocale(); + } else { + $this->assertValidLocale($locale); } if (null === $domain) { @@ -197,6 +214,8 @@ public function transChoice($id, $number, array $parameters = array(), $domain = { if (null === $locale) { $locale = $this->getLocale(); + } else { + $this->assertValidLocale($locale); } if (null === $domain) { @@ -279,4 +298,18 @@ protected function computeFallbackLocales($locale) return array_unique($locales); } + + /** + * Asserts that the locale is valid, throws an Exception if not. + * + * @param string $locale Locale to tests + * + * @throws \InvalidArgumentException If the locale contains invalid characters + */ + private function assertValidLocale($locale) + { + if (0 !== preg_match('/[^a-z0-9_\\.\\-]+/i', $locale, $match)) { + throw new \InvalidArgumentException(sprintf('Invalid locale: %s.', $locale)); + } + } } diff --git a/src/Symfony/Component/Translation/TranslatorInterface.php b/src/Symfony/Component/Translation/TranslatorInterface.php index a97fd10b8a4be..436d48872eba5 100644 --- a/src/Symfony/Component/Translation/TranslatorInterface.php +++ b/src/Symfony/Component/Translation/TranslatorInterface.php @@ -28,6 +28,8 @@ interface TranslatorInterface * @param string $domain The domain for the message * @param string $locale The locale * + * @throws \InvalidArgumentException If the locale contains invalid characters + * * @return string The translated string * * @api @@ -43,6 +45,8 @@ public function trans($id, array $parameters = array(), $domain = null, $locale * @param string $domain The domain for the message * @param string $locale The locale * + * @throws \InvalidArgumentException If the locale contains invalid characters + * * @return string The translated string * * @api @@ -54,6 +58,8 @@ public function transChoice($id, $number, array $parameters = array(), $domain = * * @param string $locale The locale * + * @throws \InvalidArgumentException If the locale contains invalid characters + * * @api */ public function setLocale($locale); From 98b891d27127333d10df0893f281f6055518bf27 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 15 Jul 2014 16:18:51 +0200 Subject: [PATCH 1143/1305] updated CHANGELOG for 2.3.18 --- CHANGELOG-2.3.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG-2.3.md b/CHANGELOG-2.3.md index 9b0b1f994e1d4..c132013aa0e72 100644 --- a/CHANGELOG-2.3.md +++ b/CHANGELOG-2.3.md @@ -7,6 +7,14 @@ in 2.3 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.3.0...v2.3.1 +* 2.3.18 (2014-07-15) + + * [Security] Forced validate of locales passed to the translator + * feature #11367 [HttpFoundation] Fix to prevent magic bytes injection in JSONP responses... (CVE-2014-4671) (Andrew Moore) + * bug #11386 Remove Spaceless Blocks from Twig Form Templates (chrisguitarguy) + * bug #9719 [TwigBundle] fix configuration tree for paths (mdavis1982, cordoval) + * bug #11244 [HttpFoundation] Remove body-related headers when sending the response, if body is empty (SimonSimCity) + * 2.3.17 (2014-07-07) * bug #11238 [Translation] Added unescaping of ids in PoFileLoader (JustBlackBird) From 4a12f4d0f2552d877bab448745b07c9a842b791a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 15 Jul 2014 16:20:27 +0200 Subject: [PATCH 1144/1305] update CONTRIBUTORS for 2.3.18 --- CONTRIBUTORS.md | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 007ceffdf4759..ca9e441c93143 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -19,8 +19,8 @@ Symfony2 is the result of the work of many people who made the code better - Ryan Weaver (weaverryan) - Lukas Kahwe Smith (lsmith) - Jeremy Mikola (jmikola) - - Jean-François Simon (jfsimon) - Romain Neutron (romain) + - Jean-François Simon (jfsimon) - Benjamin Eberlei (beberlei) - Igor Wiedler (igorw) - Hugo Hamon (hhamon) @@ -44,18 +44,18 @@ Symfony2 is the result of the work of many people who made the code better - Wouter De Jong (wouterj) - Eric Clemmons (ericclemmons) - Nicolas Grekas (nicolas-grekas) + - Andrej Hudec (pulzarraider) - Deni - Henrik Westphal (snc) - Dariusz Górecki (canni) - - Andrej Hudec (pulzarraider) - Arnout Boks (aboks) + - Christian Raue - Michel Weimerskirch (mweimerskirch) - Lee McDermott - Brandon Turner - Douglas Greenshields (shieldo) - Daniel Holmes (dholmes) - Jordan Alliot (jalliot) - - Christian Raue - John Wards (johnwards) - Fran Moreno (franmomu) - Bart van den Burg (burgov) @@ -75,21 +75,21 @@ Symfony2 is the result of the work of many people who made the code better - Fabien Pennequin (fabienpennequin) - Jacob Dreesen (jdreesen) - Gábor Egyed (1ed) + - Ait Boudad Abdellatif (aitboudad) - Adrien Brault (adrienbrault) - Michal Piotrowski (eventhorizon) - - Ait Boudad Abdellatif (aitboudad) - Robert Schönthal (digitalkaoz) - Juti Noppornpitak (shiroyuki) - Sebastian Hörl (blogsh) - Daniel Gomes (danielcsgomes) - Hidenori Goto (hidenorigoto) - Peter Kokot (maastermedia) + - Christian Flothmann (xabbuh) - Jérémie Augustin (jaugustin) - David Buchmann (dbu) - Jérôme Tamarelle (gromnan) - Tigran Azatyan (tigranazatyan) - Javier Eguiluz (javier.eguiluz) - - Christian Flothmann (xabbuh) - Rafael Dohms (rdohms) - Richard Shank (iampersistent) - Gordon Franke (gimler) @@ -146,6 +146,7 @@ Symfony2 is the result of the work of many people who made the code better - Manuel Reinhard (sprain) - Danny Berger (dpb587) - Xavier Montaña Carreras (xmontana) + - Michele Orselli (orso) - Xavier Perez - Arjen Brouwer (arjenjb) - Katsuhiro OGAWA @@ -168,7 +169,6 @@ Symfony2 is the result of the work of many people who made the code better - Robert Kiss (kepten) - Kim Hemsø Rasmussen (kimhemsoe) - Wouter Van Hecke - - Michele Orselli (orso) - Michael Holm (hollo) - Marc Weistroff (futurecat) - Pierre-Yves LEBECQ (pylebecq) @@ -231,6 +231,7 @@ Symfony2 is the result of the work of many people who made the code better - Ismael Ambrosi (iambrosi) - Shein Alexey - Issei Murasawa (issei_m) + - hacfi (hifi) - Joe Lencioni - Kai - Xavier HAUSHERR @@ -274,6 +275,7 @@ Symfony2 is the result of the work of many people who made the code better - François-Xavier de Guillebon (de-gui_f) - boombatower - Fabrice Bernhard (fabriceb) + - Clément Gautier (clementgautier) - Fabian Lange (codingfabian) - Yoshio HANAWA - Baptiste Clavié (talus) @@ -294,11 +296,11 @@ Symfony2 is the result of the work of many people who made the code better - Maks Slesarenko - Markus Lanthaler (lanthaler) - Vicent Soria Durá (vicentgodella) + - Chris Wilkinson (thewilkybarkid) - Ioan Negulescu - Andrew Udvare (audvare) - alexpods - Erik Trapman (eriktrapman) - - hacfi (hifi) - De Cock Xavier (xdecock) - Alex Pott - Norbert Orzechowicz (norzechowicz) @@ -365,6 +367,7 @@ Symfony2 is the result of the work of many people who made the code better - Arturs Vonda - Sascha Grossenbacher - Ben Davies (bendavies) + - Simon Schick (simonsimcity) - Hossein Bukhamsin - Paweł Wacławczyk (pwc) - Oleg Zinchenko (cystbear) @@ -372,6 +375,7 @@ Symfony2 is the result of the work of many people who made the code better - Johannes Klauss (cloppy) - Evan Villemez - fzerorubigd + - Benjamin Grandfond (benjamin) - Tiago Brito (blackmx) - Richard van den Brand (ricbra) - develop @@ -403,7 +407,6 @@ Symfony2 is the result of the work of many people who made the code better - Marek Štípek (maryo) - John Bohn (jbohn) - Jakub Škvára (jskvara) - - Chris Wilkinson (thewilkybarkid) - Andrew Hilobok (hilobok) - Christian Soronellas (theunic) - Jérôme Vieilledent (lolautruche) @@ -532,7 +535,6 @@ Symfony2 is the result of the work of many people who made the code better - jfcixmedia - Martijn Evers - Benjamin Paap (benjaminpaap) - - Simon Schick (simonsimcity) - Christian - Sergii Smertin (nfx) - Eddie Jaoude @@ -550,6 +552,7 @@ Symfony2 is the result of the work of many people who made the code better - Benoit Garret - DerManoMann - Asmir Mustafic (goetas) + - Julien Bianchi (jubianchi) - Marcin Chwedziak - Roland Franssen (ro0) - Maciej Malarz @@ -562,20 +565,22 @@ Symfony2 is the result of the work of many people who made the code better - kaiwa - Albert Ganiev (helios-ag) - Neil Katin + - David Otton - peter - Artem Kolesnikov (tyomo4ka) - Gustavo Adrian - - Clément Gautier (clementgautier) - Yannick - Luc Vieillescazes (iamluc) - Eduardo García Sanz (coma) - David de Boer (ddeboer) - Brooks Boyd - Roger Webb + - Dmitriy Simushev - Max Voloshin (maxvoloshin) - Nicolas Fabre (nfabre) - Raul Rodriguez (raul782) - Patrick Landolt (scube) + - WybrenKoelmans - Derek Lambert - Felicitus - Krzysztof Przybyszewski @@ -730,6 +735,7 @@ Symfony2 is the result of the work of many people who made the code better - catch - Alexandre Segura - Josef Cech + - Nate (frickenate) - Matthew Foster (mfoster) - Maximilian Reichel (phramz) - Paul Seiffert (seiffert) @@ -750,7 +756,6 @@ Symfony2 is the result of the work of many people who made the code better - Andrey Ryaguzov - Gunther Konig - František Bereň - - Benjamin Grandfond (benjamin) - Christoph Nissle (derstoffel) - Ionel Scutelnicu (ionelscutelnicu) - Johnny Peck (johnnypeck) @@ -875,6 +880,7 @@ Symfony2 is the result of the work of many people who made the code better - Yorkie Chadwick (yorkie76) - Yanick Witschi - Ondrej Mirtes + - akimsko - Youpie - srsbiz - Nicolas A. Bérard-Nault @@ -1010,6 +1016,7 @@ Symfony2 is the result of the work of many people who made the code better - Adam Monsen (meonkeys) - ollie harridge (ollietb) - Paweł Szczepanek (pauluz) + - Christian López Espínola (penyaskito) - Petr Jaroš (petajaros) - Philipp Hoffmann (philipphoffmann) - Alex Carol (picard89) From 75e07e6bde6391a6f49c8546a43740c80ac1b06b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 15 Jul 2014 16:20:44 +0200 Subject: [PATCH 1145/1305] updated VERSION for 2.3.18 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 3718155aded36..1143fe52ddac3 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.3.18-DEV'; + const VERSION = '2.3.18'; const VERSION_ID = '20318'; const MAJOR_VERSION = '2'; const MINOR_VERSION = '3'; const RELEASE_VERSION = '18'; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; /** * Constructor. From ace5a29867c218cb0bc4dc379a7aa549e7e1aea5 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 15 Jul 2014 21:58:41 +0200 Subject: [PATCH 1146/1305] bumped Symfony version to 2.3.19 --- 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 1143fe52ddac3..e14f57967b5bb 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.3.18'; - const VERSION_ID = '20318'; + const VERSION = '2.3.19-DEV'; + const VERSION_ID = '20319'; const MAJOR_VERSION = '2'; const MINOR_VERSION = '3'; - const RELEASE_VERSION = '18'; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = '19'; + const EXTRA_VERSION = 'DEV'; /** * Constructor. From ff0bb01a9180f39876c4d73c5ff7fc043e84eccf Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Sat, 14 Jun 2014 14:38:29 +0200 Subject: [PATCH 1147/1305] [Process] Reduce I/O load on Windows platform --- src/Symfony/Component/Process/ProcessPipes.php | 2 ++ .../Component/Process/Tests/AbstractProcessTest.php | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Process/ProcessPipes.php b/src/Symfony/Component/Process/ProcessPipes.php index f35d1c1287775..8b11a930fc530 100644 --- a/src/Symfony/Component/Process/ProcessPipes.php +++ b/src/Symfony/Component/Process/ProcessPipes.php @@ -284,6 +284,8 @@ private function readFileHandles($close = false) private function readStreams($blocking, $close = false) { if (empty($this->pipes)) { + usleep(Process::TIMEOUT_PRECISION * 1E4); + return array(); } diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index 91b8aca20d06a..d5bb967972195 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -583,7 +583,14 @@ public function testRunProcessWithTimeout() } $duration = microtime(true) - $start; - $this->assertLessThan($timeout + Process::TIMEOUT_PRECISION, $duration); + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + // Windows is a bit slower as it read file handles, then allow twice the precision + $maxDuration = $timeout + 2 * Process::TIMEOUT_PRECISION; + } else { + $maxDuration = $timeout + Process::TIMEOUT_PRECISION; + } + + $this->assertLessThan($maxDuration, $duration); } public function testCheckTimeoutOnNonStartedProcess() From d4189350c07ffaf1c02d37cf2c0a1a50b1a208a5 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Wed, 16 Jul 2014 11:55:07 +0200 Subject: [PATCH 1148/1305] [Process] Fix unit tests on Windows platform --- .../Process/Tests/ExecutableFinderTest.php | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php index abaa47d8ddd70..e728c0ee73d56 100644 --- a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php +++ b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php @@ -47,9 +47,9 @@ public function testFind() $this->setPath(dirname(PHP_BINARY)); $finder = new ExecutableFinder; - $result = $finder->find(basename(PHP_BINARY)); + $result = $finder->find($this->getPhpBinaryName()); - $this->assertEquals($result, PHP_BINARY); + $this->assertSamePath(PHP_BINARY, $result); } public function testFindWithDefault() @@ -83,9 +83,9 @@ public function testFindWithExtraDirs() $extraDirs = array(dirname(PHP_BINARY)); $finder = new ExecutableFinder; - $result = $finder->find(basename(PHP_BINARY), null, $extraDirs); + $result = $finder->find($this->getPhpBinaryName(), null, $extraDirs); - $this->assertEquals(PHP_BINARY, $result); + $this->assertSamePath(PHP_BINARY, $result); } public function testFindWithOpenBaseDir() @@ -105,8 +105,22 @@ public function testFindWithOpenBaseDir() ini_set('open_basedir', dirname(PHP_BINARY).PATH_SEPARATOR.'/'); $finder = new ExecutableFinder; - $result = $finder->find(basename(PHP_BINARY)); + $result = $finder->find($this->getPhpBinaryName()); - $this->assertEquals(PHP_BINARY, $result); + $this->assertSamePath(PHP_BINARY, $result); + } + + private function assertSamePath($expected, $tested) + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->assertEquals(strtolower($expected), strtolower($tested)); + } else { + $this->assertEquals($expected, $tested); + } + } + + private function getPhpBinaryName() + { + return basename(PHP_BINARY, defined('PHP_WINDOWS_VERSION_BUILD') ? '.exe' : ''); } } From cec0a45ff5951403965d79e085e43538988f2625 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Sat, 12 Jul 2014 16:27:05 +0200 Subject: [PATCH 1149/1305] [Process] Adjust PR #11264, make it Windows compatible and fix CS --- .../Component/Process/Tests/AbstractProcessTest.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index 307487474348d..fb3435116908a 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -287,8 +287,15 @@ public function testGetIncrementalOutput() } } - public function testZeroAsOutput(){ - $p = $this->getProcess('printf 0'); + public function testZeroAsOutput() + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + // see http://stackoverflow.com/questions/7105433/windows-batch-echo-without-new-line + $p = $this->getProcess('echo | set /p dummyName=0'); + } else { + $p = $this->getProcess('printf 0'); + } + $p->run(); $this->assertSame('0', $p->getOutput()); } From 3176f8bb98c9634be77d4b5b50df054a47f2079c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Muszy=C5=84ski?= Date: Wed, 16 Jul 2014 21:26:05 +0200 Subject: [PATCH 1150/1305] [Translator][FrameworkBundle] Added @ to the list of allowed chars in Translator --- .../Tests/Translation/TranslatorTest.php | 17 ++++++++++++++--- .../Translation/Tests/TranslatorTest.php | 3 +-- .../Component/Translation/Translator.php | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php index 715c44fade207..9f2012816a682 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php @@ -45,7 +45,7 @@ public function testTransWithoutCaching() { $translator = $this->getTranslator($this->getLoader()); $translator->setLocale('fr'); - $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8')); + $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin')); $this->assertEquals('foo (FR)', $translator->trans('foo')); $this->assertEquals('bar (EN)', $translator->trans('bar')); @@ -55,6 +55,7 @@ public function testTransWithoutCaching() $this->assertEquals('foobarfoo (PT-PT)', $translator->trans('foobarfoo')); $this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1)); $this->assertEquals('foobarbaz (fr.UTF-8)', $translator->trans('foobarbaz')); + $this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax')); } public function testTransWithCaching() @@ -62,7 +63,7 @@ public function testTransWithCaching() // prime the cache $translator = $this->getTranslator($this->getLoader(), array('cache_dir' => $this->tmpDir)); $translator->setLocale('fr'); - $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8')); + $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin')); $this->assertEquals('foo (FR)', $translator->trans('foo')); $this->assertEquals('bar (EN)', $translator->trans('bar')); @@ -72,12 +73,13 @@ public function testTransWithCaching() $this->assertEquals('foobarfoo (PT-PT)', $translator->trans('foobarfoo')); $this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1)); $this->assertEquals('foobarbaz (fr.UTF-8)', $translator->trans('foobarbaz')); + $this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax')); // do it another time as the cache is primed now $loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface'); $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir)); $translator->setLocale('fr'); - $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8')); + $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin')); $this->assertEquals('foo (FR)', $translator->trans('foo')); $this->assertEquals('bar (EN)', $translator->trans('bar')); @@ -87,6 +89,7 @@ public function testTransWithCaching() $this->assertEquals('foobarfoo (PT-PT)', $translator->trans('foobarfoo')); $this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1)); $this->assertEquals('foobarbaz (fr.UTF-8)', $translator->trans('foobarbaz')); + $this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax')); } public function testGetLocale() @@ -185,6 +188,13 @@ protected function getLoader() 'foobarbaz' => 'foobarbaz (fr.UTF-8)', )))) ; + $loader + ->expects($this->at(6)) + ->method('load') + ->will($this->returnValue($this->getCatalogue('sr@latin', array( + 'foobarbax' => 'foobarbax (sr@latin)', + )))) + ; return $loader; } @@ -216,6 +226,7 @@ public function getTranslator($loader, $options = array()) $translator->addResource('loader', 'foo', 'pt-PT'); // European Portuguese $translator->addResource('loader', 'foo', 'pt_BR'); // Brazilian Portuguese $translator->addResource('loader', 'foo', 'fr.UTF-8'); + $translator->addResource('loader', 'foo', 'sr@latin'); // Latin Serbian return $translator; } diff --git a/src/Symfony/Component/Translation/Tests/TranslatorTest.php b/src/Symfony/Component/Translation/Tests/TranslatorTest.php index 40a0b1d0d9021..cf9c8df659f7f 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorTest.php @@ -103,7 +103,6 @@ public function testSetFallbackLocalesMultiple() $this->assertEquals('bar (fr)', $translator->trans('bar')); } - /** * @dataProvider getInvalidLocalesTests * @expectedException \InvalidArgumentException @@ -329,7 +328,6 @@ public function testTransChoiceValidLocale($locale) // no assertion. this method just asserts that no exception is thrown } - public function getTransFileTests() { return array( @@ -429,6 +427,7 @@ public function getValidLocalesTests() array('fr_FR'), array('fr.FR'), array('fr-FR.UTF8'), + array('sr@latin'), ); } diff --git a/src/Symfony/Component/Translation/Translator.php b/src/Symfony/Component/Translation/Translator.php index e54b300ffd5d3..8e3cda857c0d6 100644 --- a/src/Symfony/Component/Translation/Translator.php +++ b/src/Symfony/Component/Translation/Translator.php @@ -308,7 +308,7 @@ protected function computeFallbackLocales($locale) */ private function assertValidLocale($locale) { - if (0 !== preg_match('/[^a-z0-9_\\.\\-]+/i', $locale, $match)) { + if (0 !== preg_match('/[^a-z0-9@_\\.\\-]+/i', $locale, $match)) { throw new \InvalidArgumentException(sprintf('Invalid locale: %s.', $locale)); } } From 291cbf9efa14460a2c77a6d6ca9bbcc2603db639 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Thu, 17 Jul 2014 16:48:59 +0200 Subject: [PATCH 1151/1305] [Validator] Backported #11410 to 2.3: Object initializers are called only once per object --- .../Validator/Tests/Fixtures/Entity.php | 1 + .../Validator/Tests/ValidationVisitorTest.php | 48 +++++++++++++++++++ .../Component/Validator/ValidationVisitor.php | 17 ++++--- 3 files changed, 59 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/Entity.php b/src/Symfony/Component/Validator/Tests/Fixtures/Entity.php index e1cb3e04902ce..f9e9e7ff3b500 100644 --- a/src/Symfony/Component/Validator/Tests/Fixtures/Entity.php +++ b/src/Symfony/Component/Validator/Tests/Fixtures/Entity.php @@ -35,6 +35,7 @@ class Entity extends EntityParent implements EntityInterface public $reference; private $internal; public $data = 'Overridden data'; + public $initialized = false; public function __construct($internal = null) { diff --git a/src/Symfony/Component/Validator/Tests/ValidationVisitorTest.php b/src/Symfony/Component/Validator/Tests/ValidationVisitorTest.php index 2868f57a82cd6..f2838737a2e1c 100644 --- a/src/Symfony/Component/Validator/Tests/ValidationVisitorTest.php +++ b/src/Symfony/Component/Validator/Tests/ValidationVisitorTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Validator\Tests; +use Symfony\Component\Validator\Constraints\Callback; +use Symfony\Component\Validator\ExecutionContextInterface; use Symfony\Component\Validator\Tests\Fixtures\FakeMetadataFactory; use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\Tests\Fixtures\Reference; @@ -561,4 +563,50 @@ public function testValidateCascadedPropertyRequiresObjectOrArray() $this->visitor->validate($entity, 'Default', ''); } + + public function testInitializeObjectsOnFirstValidation() + { + $test = $this; + $entity = new Entity(); + $entity->initialized = false; + + // prepare initializers that set "initialized" to true + $initializer1 = $this->getMock('Symfony\\Component\\Validator\\ObjectInitializerInterface'); + $initializer2 = $this->getMock('Symfony\\Component\\Validator\\ObjectInitializerInterface'); + + $initializer1->expects($this->once()) + ->method('initialize') + ->with($entity) + ->will($this->returnCallback(function ($object) { + $object->initialized = true; + })); + + $initializer2->expects($this->once()) + ->method('initialize') + ->with($entity); + + $this->visitor = new ValidationVisitor('Root', $this->metadataFactory, new ConstraintValidatorFactory(), new DefaultTranslator(), null, array( + $initializer1, + $initializer2 + )); + + // prepare constraint which + // * checks that "initialized" is set to true + // * validates the object again + $callback = function ($object, ExecutionContextInterface $context) use ($test) { + $test->assertTrue($object->initialized); + + // validate again in same group + $context->validate($object); + + // validate again in other group + $context->validate($object, '', 'SomeGroup'); + }; + + $this->metadata->addConstraint(new Callback(array($callback))); + + $this->visitor->validate($entity, 'Default', ''); + + $this->assertTrue($entity->initialized); + } } diff --git a/src/Symfony/Component/Validator/ValidationVisitor.php b/src/Symfony/Component/Validator/ValidationVisitor.php index ddff8adc60382..510c61e2eb453 100644 --- a/src/Symfony/Component/Validator/ValidationVisitor.php +++ b/src/Symfony/Component/Validator/ValidationVisitor.php @@ -127,16 +127,19 @@ public function validate($value, $group, $propertyPath, $traverse = false, $deep return; } + // Initialize if the object wasn't initialized before + if (!isset($this->validatedObjects[$hash])) { + foreach ($this->objectInitializers as $initializer) { + if (!$initializer instanceof ObjectInitializerInterface) { + throw new \LogicException('Validator initializers must implement ObjectInitializerInterface.'); + } + $initializer->initialize($value); + } + } + // Remember validating this object before starting and possibly // traversing the object graph $this->validatedObjects[$hash][$group] = true; - - foreach ($this->objectInitializers as $initializer) { - if (!$initializer instanceof ObjectInitializerInterface) { - throw new \LogicException('Validator initializers must implement ObjectInitializerInterface.'); - } - $initializer->initialize($value); - } } // Validate arrays recursively by default, otherwise every driver needs From 678766900be69d7533ee1e74d0d86cf355d57756 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Sat, 19 Jul 2014 21:31:34 +0100 Subject: [PATCH 1152/1305] [DependencyInjection] Pass a Scope instance instead of a scope name. --- .../DependencyInjection/Dumper/GraphvizDumper.php | 5 +++-- .../Tests/Dumper/GraphvizDumperTest.php | 7 +++++++ .../Tests/Fixtures/containers/container18.php | 14 ++++++++++++++ .../Tests/Fixtures/graphviz/services18.dot | 8 ++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container18.php create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services18.dot diff --git a/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php index 5ee1b7eea0fa1..1ffe142af490b 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php @@ -17,6 +17,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; +use Symfony\Component\DependencyInjection\Scope; /** * GraphvizDumper dumps a service container as a graphviz file. @@ -193,8 +194,8 @@ private function cloneContainer() $container->setDefinitions($this->container->getDefinitions()); $container->setAliases($this->container->getAliases()); $container->setResources($this->container->getResources()); - foreach ($this->container->getScopes() as $scope) { - $container->addScope($scope); + foreach ($this->container->getScopes() as $scope => $parentScope) { + $container->addScope(new Scope($scope, $parentScope)); } foreach ($this->container->getExtensions() as $extension) { $container->registerExtension($extension); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/GraphvizDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/GraphvizDumperTest.php index 0dc1ce8de150d..3db11504adebd 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/GraphvizDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/GraphvizDumperTest.php @@ -62,4 +62,11 @@ public function testDumpWithFrozenCustomClassContainer() $dumper = new GraphvizDumper($container); $this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services14.dot')), $dumper->dump(), '->dump() dumps services'); } + + public function testDumpWithScopes() + { + $container = include self::$fixturesPath.'/containers/container18.php'; + $dumper = new GraphvizDumper($container); + $this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services18.dot')), $dumper->dump(), '->dump() dumps services'); + } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container18.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container18.php new file mode 100644 index 0000000000000..0248ed462722e --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container18.php @@ -0,0 +1,14 @@ +addScope(new Scope('request')); +$container-> + register('foo', 'FooClass')-> + setScope('request') +; +$container->compile(); + +return $container; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services18.dot b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services18.dot new file mode 100644 index 0000000000000..4fbcceef3614d --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services18.dot @@ -0,0 +1,8 @@ +digraph sc { + ratio="compress" + node [fontsize="11" fontname="Arial" shape="record"]; + edge [fontsize="9" fontname="Arial" color="grey" arrowhead="open" arrowsize="0.5"]; + + node_foo [label="foo\nFooClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; + node_service_container [label="service_container\nSymfony\\Component\\DependencyInjection\\ContainerBuilder\n", shape=record, fillcolor="#9999ff", style="filled"]; +} From 02eb765a9c45fef7a925401381500d680d35d9af Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 19 Jul 2014 17:29:08 -0600 Subject: [PATCH 1153/1305] [Process] Fixes issue #11421 --- src/Symfony/Component/Process/ExecutableFinder.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Symfony/Component/Process/ExecutableFinder.php b/src/Symfony/Component/Process/ExecutableFinder.php index 44f1605fa956b..6ae74dca174b9 100644 --- a/src/Symfony/Component/Process/ExecutableFinder.php +++ b/src/Symfony/Component/Process/ExecutableFinder.php @@ -59,8 +59,7 @@ public function find($name, $default = null, array $extraDirs = array()) if (is_dir($path)) { $dirs[] = $path; } else { - $file = str_replace(dirname($path), '', $path); - if ($file == $name && is_executable($path)) { + if (basename($path) == $name && is_executable($path)) { return $path; } } From 9f4313cf6f550d829e761e1add5ee8f74f5861a6 Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 19 Jul 2014 17:48:53 -0600 Subject: [PATCH 1154/1305] [Process] Add test to verify fix for issue #11421 --- .../Process/Tests/ExecutableFinderTest.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php index e728c0ee73d56..0a905e946cb74 100644 --- a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php +++ b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php @@ -110,6 +110,27 @@ public function testFindWithOpenBaseDir() $this->assertSamePath(PHP_BINARY, $result); } + public function testFindProcessInOpenBasedir() + { + if (ini_get('open_basedir')) { + $this->markTestSkipped('Cannot test when open_basedir is set'); + } + + if (!defined('PHP_BINARY')) { + $this->markTestSkipped('Requires the PHP_BINARY constant'); + } + + $execPath = __DIR__.DIRECTORY_SEPARATOR.'SignalListener.php'; + + $this->setPath(''); + ini_set('open_basedir', PHP_BINARY.PATH_SEPARATOR.'/'); + + $finder = new ExecutableFinder; + $result = $finder->find($this->getPhpBinaryName(), false); + + $this->assertSamePath(PHP_BINARY, $result); + } + private function assertSamePath($expected, $tested) { if (defined('PHP_WINDOWS_VERSION_BUILD')) { From 4cf50e8d3036664d51efb7709e770d209358cd2b Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 20 Jul 2014 22:50:55 -0600 Subject: [PATCH 1155/1305] Bring code into standard --- src/Symfony/Component/Process/Tests/ExecutableFinderTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php index 0a905e946cb74..3b5bff26e999e 100644 --- a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php +++ b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php @@ -120,12 +120,12 @@ public function testFindProcessInOpenBasedir() $this->markTestSkipped('Requires the PHP_BINARY constant'); } - $execPath = __DIR__.DIRECTORY_SEPARATOR.'SignalListener.php'; + $execPath = __DIR__.'/SignalListener.php'; $this->setPath(''); ini_set('open_basedir', PHP_BINARY.PATH_SEPARATOR.'/'); - $finder = new ExecutableFinder; + $finder = new ExecutableFinder(); $result = $finder->find($this->getPhpBinaryName(), false); $this->assertSamePath(PHP_BINARY, $result); From 537c39b11ec808ca5c29a50e3367472449a87aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Tue, 22 Jul 2014 23:54:07 +0200 Subject: [PATCH 1156/1305] Optimize assertLocale regexp --- src/Symfony/Component/Translation/Translator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Translation/Translator.php b/src/Symfony/Component/Translation/Translator.php index 8e3cda857c0d6..d13adc07c6e09 100644 --- a/src/Symfony/Component/Translation/Translator.php +++ b/src/Symfony/Component/Translation/Translator.php @@ -308,7 +308,7 @@ protected function computeFallbackLocales($locale) */ private function assertValidLocale($locale) { - if (0 !== preg_match('/[^a-z0-9@_\\.\\-]+/i', $locale, $match)) { + if (1 !== preg_match('/^[a-z0-9@_\\.\\-]*$/i', $locale)) { throw new \InvalidArgumentException(sprintf('Invalid locale: %s.', $locale)); } } From c64a75f7bbf08a2fe4e403ff4c8ea484db7c307e Mon Sep 17 00:00:00 2001 From: Andrew Moore Date: Wed, 23 Jul 2014 22:02:17 -0400 Subject: [PATCH 1157/1305] [Form][Validator] All index items after children are to be considered grand-children when resolving ViolationPath (fixes #11458) --- .../Validator/ViolationMapper/ViolationPath.php | 14 +++++++++++--- .../ViolationMapper/ViolationMapperTest.php | 16 ++++++++-------- .../ViolationMapper/ViolationPathTest.php | 3 ++- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php index 662443ed72860..1cb1baf025ec2 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php +++ b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php @@ -70,9 +70,17 @@ public function __construct($violationPath) break; } - $this->elements[] = $elements[$i]; - $this->isIndex[] = true; - $this->mapsForm[] = true; + // All the following index items (regardless if .children is + // explicitly used) are children and grand-children + for (; $i < $l && $path->isIndex($i); ++$i) { + $this->elements[] = $elements[$i]; + $this->isIndex[] = true; + $this->mapsForm[] = true; + } + + // Rewind the pointer as the last element above didn't match + // (even if the pointer was moved forward) + --$i; } elseif ('data' === $elements[$i] && $path->isProperty($i)) { // Skip element "data" ++$i; 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 c802ea7e8055d..73607bff9611d 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php @@ -712,14 +712,14 @@ public function provideDefaultTests() array(self::LEVEL_2, 'address', '[address]', 'street', '[office][street]', 'data[address][office][street].prop'), // Edge cases which must not occur - array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'children[address][street]'), - array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'children[address][street].prop'), - array(self::LEVEL_1, 'address', 'address', 'street', '[street]', 'children[address][street]'), - array(self::LEVEL_1, 'address', 'address', 'street', '[street]', 'children[address][street].prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'street', 'children[address][street]'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'street', 'children[address][street].prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[street]', 'children[address][street]'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[street]', 'children[address][street].prop'), + array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address][street]'), + array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address][street].prop'), + array(self::LEVEL_2, 'address', 'address', 'street', '[street]', 'children[address][street]'), + array(self::LEVEL_2, 'address', 'address', 'street', '[street]', 'children[address][street].prop'), + array(self::LEVEL_2, 'address', '[address]', 'street', 'street', 'children[address][street]'), + array(self::LEVEL_2, 'address', '[address]', 'street', 'street', 'children[address][street].prop'), + array(self::LEVEL_2, 'address', '[address]', 'street', '[street]', 'children[address][street]'), + array(self::LEVEL_2, 'address', '[address]', 'street', '[street]', 'children[address][street].prop'), array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'children[person].children[address].children[street]'), array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'children[person].children[address].data.street'), diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php index 02df8f43eb6b3..0b750de733a9e 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php @@ -30,7 +30,8 @@ public function providePaths() )), array('children[address][street]', array( array('address', true, true), - ), 'children[address]'), + array('street', true, true), + ), 'children[address].children[street]'), array('children[address].data', array( array('address', true, true), ), 'children[address]'), From 75e881556638a3e928c8a0260da2a87df7886bf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Nohales?= Date: Wed, 9 Apr 2014 19:09:58 -0300 Subject: [PATCH 1158/1305] [Validator] Fix constraint violation message parameterization --- .../Validator/Constraints/AbstractComparisonValidator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php b/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php index 6d80c45027341..a561ddc759a99 100644 --- a/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php +++ b/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php @@ -32,7 +32,7 @@ public function validate($value, Constraint $constraint) if (!$this->compareValues($value, $constraint->value)) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $this->valueToString($constraint->value), + '{{ value }}' => $this->valueToString($value), '{{ compared_value }}' => $this->valueToString($constraint->value), '{{ compared_value_type }}' => $this->valueToType($constraint->value) )); From 97243bcd024bbfa458d66a4263a50ee7f16bbe74 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Thu, 10 Apr 2014 17:39:39 +0200 Subject: [PATCH 1159/1305] [Validator] Fixed value-to-string conversion in constraint violations --- .../Validator/ConstraintValidator.php | 63 +++++++++++++++++++ .../Validator/ConstraintViolation.php | 4 +- .../AbstractComparisonValidator.php | 28 --------- .../Validator/Constraints/BlankValidator.php | 4 +- .../Constraints/CardSchemeValidator.php | 8 ++- .../Validator/Constraints/ChoiceValidator.php | 16 +++-- .../Constraints/CountryValidator.php | 4 +- .../Constraints/CurrencyValidator.php | 4 +- .../Validator/Constraints/DateValidator.php | 4 +- .../Validator/Constraints/EmailValidator.php | 4 +- .../Validator/Constraints/FileValidator.php | 14 ++--- .../Validator/Constraints/IpValidator.php | 4 +- .../Constraints/LanguageValidator.php | 4 +- .../Validator/Constraints/LocaleValidator.php | 4 +- .../Validator/Constraints/NullValidator.php | 4 +- .../Validator/Constraints/RangeValidator.php | 2 +- .../Validator/Constraints/RegexValidator.php | 4 +- .../Validator/Constraints/TimeValidator.php | 4 +- .../Validator/Constraints/TypeValidator.php | 2 +- .../Validator/Constraints/UrlValidator.php | 4 +- .../AbstractComparisonValidatorTestCase.php | 6 +- .../Tests/Constraints/BlankValidatorTest.php | 12 ++-- .../Tests/Constraints/ChoiceValidatorTest.php | 8 +-- .../Constraints/EqualToValidatorTest.php | 6 +- .../GreaterThanOrEqualValidatorTest.php | 6 +- .../Constraints/GreaterThanValidatorTest.php | 12 ++-- .../Constraints/IdenticalToValidatorTest.php | 10 +-- .../LessThanOrEqualValidatorTest.php | 6 +- .../Constraints/LessThanValidatorTest.php | 10 +-- .../Constraints/NotEqualToValidatorTest.php | 8 +-- .../NotIdenticalToValidatorTest.php | 6 +- .../Tests/Constraints/TypeValidatorTest.php | 55 ++++++++-------- 32 files changed, 202 insertions(+), 128 deletions(-) diff --git a/src/Symfony/Component/Validator/ConstraintValidator.php b/src/Symfony/Component/Validator/ConstraintValidator.php index 201db0f2308eb..fe3758f65bfa2 100644 --- a/src/Symfony/Component/Validator/ConstraintValidator.php +++ b/src/Symfony/Component/Validator/ConstraintValidator.php @@ -32,4 +32,67 @@ public function initialize(ExecutionContextInterface $context) { $this->context = $context; } + + /** + * Returns a string representation of the type of the value. + * + * @param mixed $value + * + * @return string + */ + protected function valueToType($value) + { + return is_object($value) ? get_class($value) : gettype($value); + } + + /** + * Returns a string representation of the value. + * + * @param mixed $value + * + * @return string + */ + protected function valueToString($value) + { + if ($value instanceof \DateTime) { + if (class_exists('IntlDateFormatter')) { + $locale = \Locale::getDefault(); + $formatter = new \IntlDateFormatter($locale, \IntlDateFormatter::MEDIUM, \IntlDateFormatter::SHORT); + + return $formatter->format($value); + } + + return $value->format('Y-m-d H:i:s'); + } + + if (is_object($value)) { + return 'Object('.get_class($value).')'; + } + + if (is_array($value)) { + return 'Array'; + } + + if (is_string($value)) { + return '"'.$value.'"'; + } + + if (is_resource($value)) { + return sprintf('Resource(%s#%d)', get_resource_type($value), $value); + } + + if (null === $value) { + return 'null'; + } + + if (false === $value) { + return 'false'; + } + + if (true === $value) { + return 'true'; + } + + return (string) $value; + } } diff --git a/src/Symfony/Component/Validator/ConstraintViolation.php b/src/Symfony/Component/Validator/ConstraintViolation.php index ddd14dbdc090a..02b77be0bf05b 100644 --- a/src/Symfony/Component/Validator/ConstraintViolation.php +++ b/src/Symfony/Component/Validator/ConstraintViolation.php @@ -96,9 +96,9 @@ public function __construct($message, $messageTemplate, array $messageParameters public function __toString() { if (is_object($this->root)) { - $class = get_class($this->root); + $class = 'Object('.get_class($this->root).')'; } elseif (is_array($this->root)) { - $class = "Array"; + $class = 'Array'; } else { $class = (string) $this->root; } diff --git a/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php b/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php index a561ddc759a99..351ce73491322 100644 --- a/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php +++ b/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php @@ -39,34 +39,6 @@ public function validate($value, Constraint $constraint) } } - /** - * Returns a string representation of the type of the value. - * - * @param mixed $value - * - * @return string - */ - private function valueToType($value) - { - return is_object($value) ? get_class($value) : gettype($value); - } - - /** - * Returns a string representation of the value. - * - * @param mixed $value - * - * @return string - */ - private function valueToString($value) - { - if ($value instanceof \DateTime) { - return $value->format('Y-m-d H:i:s'); - } - - return var_export($value, true); - } - /** * Compares the two given values to find if their relationship is valid * diff --git a/src/Symfony/Component/Validator/Constraints/BlankValidator.php b/src/Symfony/Component/Validator/Constraints/BlankValidator.php index 06064620f16e0..7bb57ddd0e422 100644 --- a/src/Symfony/Component/Validator/Constraints/BlankValidator.php +++ b/src/Symfony/Component/Validator/Constraints/BlankValidator.php @@ -27,7 +27,9 @@ class BlankValidator extends ConstraintValidator public function validate($value, Constraint $constraint) { if ('' !== $value && null !== $value) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $this->valueToString($value) + )); } } } diff --git a/src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php b/src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php index 1ece3fdd65275..eae71a92d4502 100644 --- a/src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php @@ -108,7 +108,9 @@ public function validate($value, Constraint $constraint) } if (!is_numeric($value)) { - $this->context->addViolation($constraint->message); + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $this->valueToString($value), + )); return; } @@ -124,6 +126,8 @@ public function validate($value, Constraint $constraint) } } - $this->context->addViolation($constraint->message); + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $value, + )); } } diff --git a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php index ef9ae6e3ad041..c4f3b56c8b81b 100644 --- a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php @@ -59,25 +59,33 @@ public function validate($value, Constraint $constraint) if ($constraint->multiple) { foreach ($value as $_value) { if (!in_array($_value, $choices, $constraint->strict)) { - $this->context->addViolation($constraint->multipleMessage, array('{{ value }}' => $_value)); + $this->context->addViolation($constraint->multipleMessage, array( + '{{ value }}' => $this->valueToString($_value), + )); } } $count = count($value); if ($constraint->min !== null && $count < $constraint->min) { - $this->context->addViolation($constraint->minMessage, array('{{ limit }}' => $constraint->min), null, (int) $constraint->min); + $this->context->addViolation($constraint->minMessage, array( + '{{ limit }}' => $constraint->min + ), null, (int) $constraint->min); return; } if ($constraint->max !== null && $count > $constraint->max) { - $this->context->addViolation($constraint->maxMessage, array('{{ limit }}' => $constraint->max), null, (int) $constraint->max); + $this->context->addViolation($constraint->maxMessage, array( + '{{ limit }}' => $constraint->max + ), null, (int) $constraint->max); return; } } elseif (!in_array($value, $choices, $constraint->strict)) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $this->valueToString($value) + )); } } } diff --git a/src/Symfony/Component/Validator/Constraints/CountryValidator.php b/src/Symfony/Component/Validator/Constraints/CountryValidator.php index 6a8d1d64469a1..c912a650a6929 100644 --- a/src/Symfony/Component/Validator/Constraints/CountryValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CountryValidator.php @@ -42,7 +42,9 @@ public function validate($value, Constraint $constraint) $countries = Intl::getRegionBundle()->getCountryNames(); if (!isset($countries[$value])) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $value, + )); } } } diff --git a/src/Symfony/Component/Validator/Constraints/CurrencyValidator.php b/src/Symfony/Component/Validator/Constraints/CurrencyValidator.php index 4451047cdd630..d12952fc81a9d 100644 --- a/src/Symfony/Component/Validator/Constraints/CurrencyValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CurrencyValidator.php @@ -42,7 +42,9 @@ public function validate($value, Constraint $constraint) $currencies = Intl::getCurrencyBundle()->getCurrencyNames(); if (!isset($currencies[$value])) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $value, + )); } } } diff --git a/src/Symfony/Component/Validator/Constraints/DateValidator.php b/src/Symfony/Component/Validator/Constraints/DateValidator.php index 733a3b7f5e8b1..1170314a70b64 100644 --- a/src/Symfony/Component/Validator/Constraints/DateValidator.php +++ b/src/Symfony/Component/Validator/Constraints/DateValidator.php @@ -40,7 +40,9 @@ public function validate($value, Constraint $constraint) $value = (string) $value; if (!preg_match(static::PATTERN, $value, $matches) || !checkdate($matches[2], $matches[3], $matches[1])) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $value, + )); } } } diff --git a/src/Symfony/Component/Validator/Constraints/EmailValidator.php b/src/Symfony/Component/Validator/Constraints/EmailValidator.php index e14546ce822ef..5b433a768f045 100644 --- a/src/Symfony/Component/Validator/Constraints/EmailValidator.php +++ b/src/Symfony/Component/Validator/Constraints/EmailValidator.php @@ -50,7 +50,9 @@ public function validate($value, Constraint $constraint) } if (!$valid) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $value, + )); } } diff --git a/src/Symfony/Component/Validator/Constraints/FileValidator.php b/src/Symfony/Component/Validator/Constraints/FileValidator.php index 5f499810e6517..dce0480a0ee0f 100644 --- a/src/Symfony/Component/Validator/Constraints/FileValidator.php +++ b/src/Symfony/Component/Validator/Constraints/FileValidator.php @@ -126,10 +126,10 @@ public function validate($value, Constraint $constraint) if ($size > $limit) { $this->context->addViolation($constraint->maxSizeMessage, array( - '{{ size }}' => $size, - '{{ limit }}' => $limit, - '{{ suffix }}' => $suffix, - '{{ file }}' => $path, + '{{ size }}' => $size, + '{{ limit }}' => $limit, + '{{ suffix }}' => $suffix, + '{{ file }}' => $path, )); return; @@ -161,9 +161,9 @@ public function validate($value, Constraint $constraint) if (false === $valid) { $this->context->addViolation($constraint->mimeTypesMessage, array( - '{{ type }}' => '"'.$mime.'"', - '{{ types }}' => '"'.implode('", "', $mimeTypes) .'"', - '{{ file }}' => $path, + '{{ type }}' => '"'.$mime.'"', + '{{ types }}' => '"'.implode('", "', $mimeTypes) .'"', + '{{ file }}' => $path, )); } } diff --git a/src/Symfony/Component/Validator/Constraints/IpValidator.php b/src/Symfony/Component/Validator/Constraints/IpValidator.php index 69afe61b71c00..ad5d9e2466370 100644 --- a/src/Symfony/Component/Validator/Constraints/IpValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IpValidator.php @@ -91,7 +91,9 @@ public function validate($value, Constraint $constraint) } if (!filter_var($value, FILTER_VALIDATE_IP, $flag)) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $value, + )); } } } diff --git a/src/Symfony/Component/Validator/Constraints/LanguageValidator.php b/src/Symfony/Component/Validator/Constraints/LanguageValidator.php index 87019705db919..02edb963f1a7a 100644 --- a/src/Symfony/Component/Validator/Constraints/LanguageValidator.php +++ b/src/Symfony/Component/Validator/Constraints/LanguageValidator.php @@ -42,7 +42,9 @@ public function validate($value, Constraint $constraint) $languages = Intl::getLanguageBundle()->getLanguageNames(); if (!isset($languages[$value])) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $value, + )); } } } diff --git a/src/Symfony/Component/Validator/Constraints/LocaleValidator.php b/src/Symfony/Component/Validator/Constraints/LocaleValidator.php index daf594800bfdd..cfd2105e90444 100644 --- a/src/Symfony/Component/Validator/Constraints/LocaleValidator.php +++ b/src/Symfony/Component/Validator/Constraints/LocaleValidator.php @@ -42,7 +42,9 @@ public function validate($value, Constraint $constraint) $locales = Intl::getLocaleBundle()->getLocaleNames(); if (!isset($locales[$value])) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $value, + )); } } } diff --git a/src/Symfony/Component/Validator/Constraints/NullValidator.php b/src/Symfony/Component/Validator/Constraints/NullValidator.php index f0f09c492f54c..bc9bf4f38ce2a 100644 --- a/src/Symfony/Component/Validator/Constraints/NullValidator.php +++ b/src/Symfony/Component/Validator/Constraints/NullValidator.php @@ -33,7 +33,9 @@ public function validate($value, Constraint $constraint) $value = 'Array'; } - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $value, + )); } } } diff --git a/src/Symfony/Component/Validator/Constraints/RangeValidator.php b/src/Symfony/Component/Validator/Constraints/RangeValidator.php index 6f0ad51dba5ea..fe79f5422260a 100644 --- a/src/Symfony/Component/Validator/Constraints/RangeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/RangeValidator.php @@ -30,7 +30,7 @@ public function validate($value, Constraint $constraint) if (!is_numeric($value)) { $this->context->addViolation($constraint->invalidMessage, array( - '{{ value }}' => $value, + '{{ value }}' => $this->valueToString($value), )); return; diff --git a/src/Symfony/Component/Validator/Constraints/RegexValidator.php b/src/Symfony/Component/Validator/Constraints/RegexValidator.php index 1f2febbbca0bd..f59d6a4e25b6f 100644 --- a/src/Symfony/Component/Validator/Constraints/RegexValidator.php +++ b/src/Symfony/Component/Validator/Constraints/RegexValidator.php @@ -41,7 +41,9 @@ public function validate($value, Constraint $constraint) $value = (string) $value; if ($constraint->match xor preg_match($constraint->pattern, $value)) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $value, + )); } } } diff --git a/src/Symfony/Component/Validator/Constraints/TimeValidator.php b/src/Symfony/Component/Validator/Constraints/TimeValidator.php index cbaa816d1ace0..36260e67d1d84 100644 --- a/src/Symfony/Component/Validator/Constraints/TimeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/TimeValidator.php @@ -40,7 +40,9 @@ public function validate($value, Constraint $constraint) $value = (string) $value; if (!preg_match(static::PATTERN, $value)) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $value, + )); } } } diff --git a/src/Symfony/Component/Validator/Constraints/TypeValidator.php b/src/Symfony/Component/Validator/Constraints/TypeValidator.php index f75bb0fd8bc96..ff713ffeef2d9 100644 --- a/src/Symfony/Component/Validator/Constraints/TypeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/TypeValidator.php @@ -44,7 +44,7 @@ public function validate($value, Constraint $constraint) } $this->context->addViolation($constraint->message, array( - '{{ value }}' => is_object($value) ? get_class($value) : (is_array($value) ? 'Array' : (string) $value), + '{{ value }}' => $this->valueToString($value), '{{ type }}' => $constraint->type, )); } diff --git a/src/Symfony/Component/Validator/Constraints/UrlValidator.php b/src/Symfony/Component/Validator/Constraints/UrlValidator.php index d743c3807f0e8..4aeab117af1dc 100644 --- a/src/Symfony/Component/Validator/Constraints/UrlValidator.php +++ b/src/Symfony/Component/Validator/Constraints/UrlValidator.php @@ -55,7 +55,9 @@ public function validate($value, Constraint $constraint) $pattern = sprintf(static::PATTERN, implode('|', $constraint->protocols)); if (!preg_match($pattern, $value)) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $value, + )); } } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php index d72eaf23fabd3..c0ab0f7a53adf 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php @@ -29,6 +29,8 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); $this->validator->initialize($this->context); + + \Locale::setDefault('en'); } /** @@ -75,7 +77,7 @@ abstract public function provideValidComparisons(); * @param mixed $comparedValueString * @param string $comparedValueType */ - public function testInvalidComparisonToValue($dirtyValue, $comparedValue, $comparedValueString, $comparedValueType) + public function testInvalidComparisonToValue($dirtyValue, $dirtyValueAsString, $comparedValue, $comparedValueString, $comparedValueType) { $constraint = $this->createConstraint(array('value' => $comparedValue)); $constraint->message = 'Constraint Message'; @@ -87,7 +89,7 @@ public function testInvalidComparisonToValue($dirtyValue, $comparedValue, $compa $this->context->expects($this->once()) ->method('addViolation') ->with('Constraint Message', array( - '{{ value }}' => $comparedValueString, + '{{ value }}' => $dirtyValueAsString, '{{ compared_value }}' => $comparedValueString, '{{ compared_value_type }}' => $comparedValueType )); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php index 0fbe5e6fbb0d0..fe4a30b6389a0 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php @@ -51,7 +51,7 @@ public function testBlankIsValid() /** * @dataProvider getInvalidValues */ - public function testInvalidValues($value) + public function testInvalidValues($value, $valueAsString) { $constraint = new Blank(array( 'message' => 'myMessage' @@ -60,7 +60,7 @@ public function testInvalidValues($value) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => $value, + '{{ value }}' => $valueAsString, )); $this->validator->validate($value, $constraint); @@ -69,10 +69,10 @@ public function testInvalidValues($value) public function getInvalidValues() { return array( - array('foobar'), - array(0), - array(false), - array(1234), + array('foobar', '"foobar"'), + array(0, '0'), + array(false, 'false'), + array(1234, '1234'), ); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php index 9267fdb872692..ad524b87ea2b9 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php @@ -158,7 +158,7 @@ public function testInvalidChoice() $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => 'baz', + '{{ value }}' => '"baz"', ), null, null); $this->validator->validate('baz', $constraint); @@ -175,7 +175,7 @@ public function testInvalidChoiceMultiple() $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => 'baz', + '{{ value }}' => '"baz"', )); $this->validator->validate(array('foo', 'baz'), $constraint); @@ -255,7 +255,7 @@ public function testStrictDisallowsDifferentType() $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => '2', + '{{ value }}' => '"2"', )); $this->validator->validate('2', $constraint); @@ -287,7 +287,7 @@ public function testStrictWithMultipleChoices() $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => '3', + '{{ value }}' => '"3"', )); $this->validator->validate(array(2, '3'), $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php index 45c9bd1deeaa8..2cc624e7f3c77 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php @@ -49,9 +49,9 @@ public function provideValidComparisons() public function provideInvalidComparisons() { return array( - array(1, 2, '2', 'integer'), - array('22', '333', "'333'", 'string'), - array(new \DateTime('2001-01-01'), new \DateTime('2000-01-01'), '2000-01-01 00:00:00', 'DateTime') + array(1, '1', 2, '2', 'integer'), + array('22', '"22"', '333', '"333"', 'string'), + array(new \DateTime('2001-01-01'), 'Jan 1, 2001 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000 12:00 AM', 'DateTime') ); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php index 9393bec619663..8dd27f7f4b229 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php @@ -51,9 +51,9 @@ public function provideValidComparisons() public function provideInvalidComparisons() { return array( - array(1, 2, '2', 'integer'), - array(new \DateTime('2000/01/01'), new \DateTime('2005/01/01'), '2005-01-01 00:00:00', 'DateTime'), - array('b', 'c', "'c'", 'string') + array(1, '1', 2, '2', 'integer'), + array(new \DateTime('2000/01/01'), 'Jan 1, 2000 12:00 AM', new \DateTime('2005/01/01'), 'Jan 1, 2005 12:00 AM', 'DateTime'), + array('b', '"b"', 'c', '"c"', 'string') ); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php index 49c31727ff8bf..e261c42c8b5a4 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php @@ -48,12 +48,12 @@ public function provideValidComparisons() public function provideInvalidComparisons() { return array( - array(1, 2, '2', 'integer'), - array(2, 2, '2', 'integer'), - array(new \DateTime('2000/01/01'), new \DateTime('2005/01/01'), '2005-01-01 00:00:00', 'DateTime'), - array(new \DateTime('2000/01/01'), new \DateTime('2000/01/01'), '2000-01-01 00:00:00', 'DateTime'), - array('22', '333', "'333'", 'string'), - array('22', '22', "'22'", 'string') + array(1, '1', 2, '2', 'integer'), + array(2, '2', 2, '2', 'integer'), + array(new \DateTime('2000/01/01'), 'Jan 1, 2000 12:00 AM', new \DateTime('2005/01/01'), 'Jan 1, 2005 12:00 AM', 'DateTime'), + array(new \DateTime('2000/01/01'), 'Jan 1, 2000 12:00 AM', new \DateTime('2000/01/01'), 'Jan 1, 2000 12:00 AM', 'DateTime'), + array('22', '"22"', '333', '"333"', 'string'), + array('22', '"22"', '22', '"22"', 'string') ); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php index ede2e43e7e9ec..02f166c7cbcff 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php @@ -50,11 +50,11 @@ public function provideValidComparisons() public function provideInvalidComparisons() { return array( - array(1, 2, '2', 'integer'), - array(2, '2', "'2'", 'string'), - array('22', '333', "'333'", 'string'), - array(new \DateTime('2001-01-01'), new \DateTime('2001-01-01'), '2001-01-01 00:00:00', 'DateTime'), - array(new \DateTime('2001-01-01'), new \DateTime('1999-01-01'), '1999-01-01 00:00:00', 'DateTime') + array(1, '1', 2, '2', 'integer'), + array(2, '2', '2', '"2"', 'string'), + array('22', '"22"', '333', '"333"', 'string'), + array(new \DateTime('2001-01-01'), 'Jan 1, 2001 12:00 AM', new \DateTime('2001-01-01'), 'Jan 1, 2001 12:00 AM', 'DateTime'), + array(new \DateTime('2001-01-01'), 'Jan 1, 2001 12:00 AM', new \DateTime('1999-01-01'), 'Jan 1, 1999 12:00 AM', 'DateTime') ); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php index 9eca353e48616..e2ce1bcbc181e 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php @@ -51,9 +51,9 @@ public function provideValidComparisons() public function provideInvalidComparisons() { return array( - array(2, 1, '1', 'integer'), - array(new \DateTime('2010-01-01'), new \DateTime('2000-01-01'), '2000-01-01 00:00:00', 'DateTime'), - array('c', 'b', "'b'", 'string') + array(2, '2', 1, '1', 'integer'), + array(new \DateTime('2010-01-01'), 'Jan 1, 2010 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000 12:00 AM', 'DateTime'), + array('c', '"c"', 'b', '"b"', 'string') ); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php index daee66725462f..9e88ac1e2b32d 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php @@ -48,11 +48,11 @@ public function provideValidComparisons() public function provideInvalidComparisons() { return array( - array(3, 2, '2', 'integer'), - array(2, 2, '2', 'integer'), - array(new \DateTime('2010-01-01'), new \DateTime('2000-01-01'), '2000-01-01 00:00:00', 'DateTime'), - array(new \DateTime('2000-01-01'), new \DateTime('2000-01-01'), '2000-01-01 00:00:00', 'DateTime'), - array('333', '22', "'22'", 'string'), + array(3, '3', 2, '2', 'integer'), + array(2, '2', 2, '2', 'integer'), + array(new \DateTime('2010-01-01'), 'Jan 1, 2010 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000 12:00 AM', 'DateTime'), + array(new \DateTime('2000-01-01'), 'Jan 1, 2000 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000 12:00 AM', 'DateTime'), + array('333', '"333"', '22', '"22"', 'string'), ); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php index ecf89d79de0fa..334aeb219a599 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php @@ -48,10 +48,10 @@ public function provideValidComparisons() public function provideInvalidComparisons() { return array( - array(3, 3, '3', 'integer'), - array('2', 2, '2', 'integer'), - array('a', 'a', "'a'", 'string'), - array(new \DateTime('2000-01-01'), new \DateTime('2000-01-01'), '2000-01-01 00:00:00', 'DateTime') + array(3, '3', 3, '3', 'integer'), + array('2', '"2"', 2, '2', 'integer'), + array('a', '"a"', 'a', '"a"', 'string'), + array(new \DateTime('2000-01-01'), 'Jan 1, 2000 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000 12:00 AM', 'DateTime') ); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php index 6b518c92a9ab3..406a10163fb3f 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php @@ -52,9 +52,9 @@ public function provideInvalidComparisons() $date = new \DateTime('2000-01-01'); return array( - array(3, 3, '3', 'integer'), - array('a', 'a', "'a'", 'string'), - array($date, $date, '2000-01-01 00:00:00', 'DateTime') + array(3, '3', 3, '3', 'integer'), + array('a', '"a"', 'a', '"a"', 'string'), + array($date, 'Jan 1, 2000 12:00 AM', $date, 'Jan 1, 2000 12:00 AM', 'DateTime') ); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php index e5e6d0bf025e7..57d7f5c4c4736 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php @@ -132,36 +132,37 @@ public function getInvalidValues() { $object = new \stdClass(); $file = $this->createFile(); + $fileAsString = 'Resource(stream#'.intval($file).')'; return array( - array('foobar', 'numeric', 'foobar'), - array('foobar', 'boolean', 'foobar'), - array('0', 'integer', '0'), - array('1.5', 'float', '1.5'), + array('foobar', 'numeric', '"foobar"'), + array('foobar', 'boolean', '"foobar"'), + array('0', 'integer', '"0"'), + array('1.5', 'float', '"1.5"'), array(12345, 'string', '12345'), - array($object, 'boolean', 'stdClass'), - array($object, 'numeric', 'stdClass'), - array($object, 'integer', 'stdClass'), - array($object, 'float', 'stdClass'), - array($object, 'string', 'stdClass'), - array($object, 'resource', 'stdClass'), - array($file, 'boolean', (string) $file), - array($file, 'numeric', (string) $file), - array($file, 'integer', (string) $file), - array($file, 'float', (string) $file), - array($file, 'string', (string) $file), - array($file, 'object', (string) $file), - array('12a34', 'digit', '12a34'), - array('1a#23', 'alnum', '1a#23'), - array('abcd1', 'alpha', 'abcd1'), - array("\nabc", 'cntrl', "\nabc"), - array("abc\n", 'graph', "abc\n"), - array('abCDE', 'lower', 'abCDE'), - array('ABcde', 'upper', 'ABcde'), - array("\nabc", 'print', "\nabc"), - array('abc&$!', 'punct', 'abc&$!'), - array("\nabc", 'space', "\nabc"), - array('AR1012', 'xdigit', 'AR1012'), + array($object, 'boolean', 'Object(stdClass)'), + array($object, 'numeric', 'Object(stdClass)'), + array($object, 'integer', 'Object(stdClass)'), + array($object, 'float', 'Object(stdClass)'), + array($object, 'string', 'Object(stdClass)'), + array($object, 'resource', 'Object(stdClass)'), + array($file, 'boolean', $fileAsString), + array($file, 'numeric', $fileAsString), + array($file, 'integer', $fileAsString), + array($file, 'float', $fileAsString), + array($file, 'string', $fileAsString), + array($file, 'object', $fileAsString), + array('12a34', 'digit', '"12a34"'), + array('1a#23', 'alnum', '"1a#23"'), + array('abcd1', 'alpha', '"abcd1"'), + array("\nabc", 'cntrl', "\"\nabc\""), + array("abc\n", 'graph', "\"abc\n\""), + array('abCDE', 'lower', '"abCDE"'), + array('ABcde', 'upper', '"ABcde"'), + array("\nabc", 'print', "\"\nabc\""), + array('abc&$!', 'punct', '"abc&$!"'), + array("\nabc", 'space', "\"\nabc\""), + array('AR1012', 'xdigit', '"AR1012"'), ); } From fd58870ac03aa2f0ca258164a876c43af4a43f61 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Thu, 10 Apr 2014 18:24:43 +0200 Subject: [PATCH 1160/1305] [Validator] Simplified IBAN validation algorithm --- .../Validator/Constraints/IbanValidator.php | 101 ++++++++++++++---- .../Tests/Constraints/IbanValidatorTest.php | 2 + 2 files changed, 82 insertions(+), 21 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/IbanValidator.php b/src/Symfony/Component/Validator/Constraints/IbanValidator.php index 640da3c702ecc..615518883bce1 100644 --- a/src/Symfony/Component/Validator/Constraints/IbanValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IbanValidator.php @@ -13,10 +13,12 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** * @author Manuel Reinhard * @author Michael Schummel + * @author Bernhard Schussek * @link http://www.michael-schummel.de/2007/10/05/iban-prufung-mit-php/ */ class IbanValidator extends ConstraintValidator @@ -30,41 +32,98 @@ public function validate($value, Constraint $constraint) return; } - // An IBAN without a country code is not an IBAN. - if (0 === preg_match('/[A-Z]/', $value)) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { + throw new UnexpectedTypeException($value, 'string'); + } + + // Remove spaces + $canonicalized = str_replace(' ', '', $value); + + if (strlen($canonicalized) < 4) { + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $value, + )); return; } - $teststring = preg_replace('/\s+/', '', $value); - - if (strlen($teststring) < 4) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + // The IBAN must have at least 4 characters, start with a country + // code and contain only digits and (uppercase) characters + if (strlen($canonicalized) < 4 || !ctype_upper($canonicalized{0}) + || !ctype_upper($canonicalized{1}) || !ctype_alnum($canonicalized)) { + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $value, + )); return; } - $teststring = substr($teststring, 4) - .strval(ord($teststring{0}) - 55) - .strval(ord($teststring{1}) - 55) - .substr($teststring, 2, 2); + // Move the first four characters to the end + // e.g. CH93 0076 2011 6238 5295 7 + // -> 0076 2011 6238 5295 7 CH93 + $canonicalized = substr($canonicalized, 4).substr($canonicalized, 0, 4); - $teststring = preg_replace_callback('/[A-Z]/', function ($letter) { - return intval(ord(strtolower($letter[0])) - 87); - }, $teststring); + // Convert all remaining letters to their ordinals + // The result is an integer, which is too large for PHP's int + // data type, so we store it in a string instead. + // e.g. 0076 2011 6238 5295 7 CH93 + // -> 0076 2011 6238 5295 7 121893 + $checkSum = $this->toBigInt($canonicalized); - $rest = 0; - $strlen = strlen($teststring); - for ($pos = 0; $pos < $strlen; $pos += 7) { - $part = strval($rest).substr($teststring, $pos, 7); - $rest = intval($part) % 97; + if (false === $checkSum) { + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $value, + )); + + return; } - if ($rest != 1) { - $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); + // Do a modulo-97 operation on the large integer + // We cannot use PHP's modulo operator, so we calculate the + // modulo step-wisely instead + if (1 !== $this->bigModulo97($checkSum)) { + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $value, + )); return; } } + + private function toBigInt($string) + { + $chars = str_split($string); + $bigInt = ''; + + foreach ($chars as $char) { + // Convert uppercase characters to ordinals, starting with 10 for "A" + if (ctype_upper($char)) { + $bigInt .= (ord($char) - 55); + + continue; + } + + // Disallow lowercase characters + if (ctype_lower($char)) { + return false; + } + + // Simply append digits + $bigInt .= $char; + } + + return $bigInt; + } + + private function bigModulo97($bigInt) + { + $parts = str_split($bigInt, 7); + $rest = 0; + + foreach ($parts as $part) { + $rest = ($rest.$part) % 97; + } + + return $rest; + } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php index 60ba94c32c241..cf0802fed2e73 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php @@ -54,6 +54,7 @@ public function getValidIbans() { return array( array('CH9300762011623852957'), // Switzerland without spaces + array('CH93 0076 2011 6238 5295 7'), // Switzerland with multiple spaces //Country list //http://www.rbs.co.uk/corporate/international/g0/guide-to-international-business/regulatory-information/iban/iban-example.ashx @@ -182,6 +183,7 @@ public function getInvalidIbans() array('foo'), array('123'), array('0750447346'), + array('CH930076201162385295]'), //Ibans with lower case values are invalid array('Ae260211000000230064016'), From 224e70f709a449138b1f99e23a3f699cff950052 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Thu, 10 Apr 2014 18:57:38 +0200 Subject: [PATCH 1161/1305] [Validator] Fixed and simplified IsbnValidator --- .../Component/Validator/Constraints/Isbn.php | 3 + .../Validator/Constraints/IsbnValidator.php | 101 +++++++++++------- .../Tests/Constraints/IsbnValidatorTest.php | 8 ++ 3 files changed, 71 insertions(+), 41 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/Isbn.php b/src/Symfony/Component/Validator/Constraints/Isbn.php index 6c978cf3b80af..bd61f4b539c51 100644 --- a/src/Symfony/Component/Validator/Constraints/Isbn.php +++ b/src/Symfony/Component/Validator/Constraints/Isbn.php @@ -42,5 +42,8 @@ public function __construct($options = null) if (null === $this->isbn10 && null === $this->isbn13) { throw new MissingOptionsException(sprintf('Either option "isbn10" or "isbn13" must be given for constraint "%s".', __CLASS__), array('isbn10', 'isbn13')); } + + $this->isbn10 = (bool) $this->isbn10; + $this->isbn13 = (bool) $this->isbn13; } } diff --git a/src/Symfony/Component/Validator/Constraints/IsbnValidator.php b/src/Symfony/Component/Validator/Constraints/IsbnValidator.php index a000e382edf5a..0e79c3289a733 100644 --- a/src/Symfony/Component/Validator/Constraints/IsbnValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IsbnValidator.php @@ -19,6 +19,7 @@ * Validates whether the value is a valid ISBN-10 or ISBN-13. * * @author The Whole Life To Learn + * @author Bernhard Schussek * * @see https://en.wikipedia.org/wiki/Isbn */ @@ -37,53 +38,71 @@ public function validate($value, Constraint $constraint) throw new UnexpectedTypeException($value, 'string'); } - if (!is_numeric($value)) { - $value = str_replace('-', '', $value); - } + $value = (string) $value; + $canonical = strtoupper(str_replace('-', '', $value)); - $validation = 0; - $value = strtoupper($value); - $valueLength = strlen($value); - - if (10 === $valueLength && null !== $constraint->isbn10) { - for ($i = 0; $i < 10; $i++) { - if ($value[$i] == 'X') { - $validation += 10 * intval(10 - $i); - } else { - $validation += intval($value[$i]) * intval(10 - $i); - } - } + if ($constraint->isbn10 && $this->isValidIsbn10($canonical)) { + return; + } - if ($validation % 11 != 0) { - if (null !== $constraint->isbn13) { - $this->context->addViolation($constraint->bothIsbnMessage); - } else { - $this->context->addViolation($constraint->isbn10Message); - } - } - } elseif (13 === $valueLength && null !== $constraint->isbn13) { - for ($i = 0; $i < 13; $i += 2) { - $validation += intval($value[$i]); - } - for ($i = 1; $i < 12; $i += 2) { - $validation += intval($value[$i]) * 3; - } + if ($constraint->isbn13 && $this->isValidIsbn13($canonical)) { + return; + } - if ($validation % 10 != 0) { - if (null !== $constraint->isbn10) { - $this->context->addViolation($constraint->bothIsbnMessage); - } else { - $this->context->addViolation($constraint->isbn13Message); - } - } + if ($constraint->isbn10 && $constraint->isbn13) { + $this->context->addViolation($constraint->bothIsbnMessage, array( + '{{ value }}' => $value, + )); + } elseif ($constraint->isbn10) { + $this->context->addViolation($constraint->isbn10Message, array( + '{{ value }}' => $value, + )); } else { - if (null !== $constraint->isbn10 && null !== $constraint->isbn13) { - $this->context->addViolation($constraint->bothIsbnMessage); - } elseif (null !== $constraint->isbn10) { - $this->context->addViolation($constraint->isbn10Message); + $this->context->addViolation($constraint->isbn13Message, array( + '{{ value }}' => $value, + )); + } + } + + private function isValidIsbn10($isbn) + { + if (10 !== strlen($isbn)) { + return false; + } + + $checkSum = 0; + + for ($i = 0; $i < 10; ++$i) { + if ('X' === $isbn{$i}) { + $digit = 10; + } elseif (ctype_digit($isbn{$i})) { + $digit = $isbn{$i}; } else { - $this->context->addViolation($constraint->isbn13Message); + return false; } + + $checkSum += $digit * intval(10 - $i); + } + + return 0 === $checkSum % 11; + } + + private function isValidIsbn13($isbn) + { + if (13 !== strlen($isbn) || !ctype_digit($isbn)) { + return false; + } + + $checkSum = 0; + + for ($i = 0; $i < 13; $i += 2) { + $checkSum += $isbn{$i}; } + + for ($i = 1; $i < 12; $i += 2) { + $checkSum += $isbn{$i} * 3; + } + + return 0 === $checkSum % 10; } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php index 7f0859b999e08..049a9ac3eebc2 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php @@ -58,6 +58,10 @@ public function getInvalidIsbn10() array('0-4X19-92611'), array('0_45122_5244'), array('2870#971#648'), + array('1A34567890'), + // chr(1) evaluates to 0 + // 2070546810 is valid + array('2'.chr(1).'70546810'), ); } @@ -92,6 +96,10 @@ public function getInvalidIsbn13() array('980-0474292319'), array('978_0451225245'), array('978#0471292319'), + array('978-272C442282'), + // chr(1) evaluates to 0 + // 978-2070546817 is valid + array('978-2'.chr(1).'70546817'), ); } From bff09f210b65f1916a6402ac280db2f5d373c84f Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Thu, 10 Apr 2014 19:05:39 +0200 Subject: [PATCH 1162/1305] [Validator] Simplified IssnValidator --- .../Validator/Constraints/IssnValidator.php | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/IssnValidator.php b/src/Symfony/Component/Validator/Constraints/IssnValidator.php index 0e580ea96c8ef..2ae70ec2f3318 100644 --- a/src/Symfony/Component/Validator/Constraints/IssnValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IssnValidator.php @@ -37,26 +37,35 @@ public function validate($value, Constraint $constraint) throw new UnexpectedTypeException($value, 'string'); } + $value = (string) $value; + // Compose regex pattern $digitsPattern = $constraint->requireHyphen ? '\d{4}-\d{3}' : '\d{4}-?\d{3}'; - $checksumPattern = $constraint->caseSensitive ? '[\d|X]' : '[\d|X|x]'; - $pattern = "/^".$digitsPattern.$checksumPattern."$/"; + $checkSumPattern = $constraint->caseSensitive ? '[\d|X]' : '[\d|X|x]'; + $pattern = "/^".$digitsPattern.$checkSumPattern."$/"; if (!preg_match($pattern, $value)) { - $this->context->addViolation($constraint->message); - } else { - $digits = str_split(strtoupper(str_replace('-', '', $value))); + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $value, + )); + + return; + } + + $canonical = strtoupper(str_replace('-', '', $value)); - $sum = 0; - for ($i = 8; $i > 1; $i--) { - $sum += $i * (int) array_shift($digits); - } + // Calculate a checksum. "X" equals 10. + $checkSum = 'X' === $canonical{7} ? 10 : $canonical{7}; - $checksum = 'X' == reset($digits) ? 10 : (int) reset($digits); + for ($i = 0; $i < 7; ++$i) { + // Multiply the first digit by 8, the second by 7, etc. + $checkSum += (8-$i) * $canonical{$i}; + } - if (0 != ($sum + $checksum) % 11) { - $this->context->addViolation($constraint->message); - } + if (0 !== $checkSum % 11) { + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $value, + )); } } } From f3295522efcd5d0bd43eff48e16592051bf2c915 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Thu, 10 Apr 2014 19:30:28 +0200 Subject: [PATCH 1163/1305] [Validator] Simplified and explained the LuhnValidator --- .../Validator/Constraints/LuhnValidator.php | 44 ++++++++++++++----- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/LuhnValidator.php b/src/Symfony/Component/Validator/Constraints/LuhnValidator.php index d3802fe99ae11..444696994fc35 100644 --- a/src/Symfony/Component/Validator/Constraints/LuhnValidator.php +++ b/src/Symfony/Component/Validator/Constraints/LuhnValidator.php @@ -39,28 +39,48 @@ public function validate($value, Constraint $constraint) return; } - /** - * need to work with strings only because long numbers are treated as floats and don't work with strlen - */ - if (!is_string($value)) { + // Work with strings only, because long numbers are represented as floats + // internally and don't work with strlen() + if (!is_string($value) && !(is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedTypeException($value, 'string'); } - if (!is_numeric($value)) { - $this->context->addViolation($constraint->message); + $value = (string) $value; + + if (!ctype_digit($value)) { + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $value, + )); return; } + $checkSum = 0; $length = strlen($value); - $oddLength = $length % 2; - for ($sum = 0, $i = $length - 1; $i >= 0; $i--) { - $digit = (int) $value[$i]; - $sum += (($i % 2) === $oddLength) ? array_sum(str_split($digit * 2)) : $digit; + + // Starting with the last digit and walking left, add every second + // digit to the check sum + // e.g. 7 9 9 2 7 3 9 8 7 1 3 + // ^ ^ ^ ^ ^ ^ + // = 7 + 9 + 7 + 9 + 7 + 3 + for ($i = $length - 1; $i >= 0; $i -= 2) { + $checkSum += $value{$i}; + } + + // Starting with the second last digit and walking left, double every + // second digit and add it to the check sum + // For doubles greater than 9, sum the individual digits + // e.g. 7 9 9 2 7 3 9 8 7 1 3 + // ^ ^ ^ ^ ^ + // = 1+8 + 4 + 6 + 1+6 + 2 + for ($i = $length - 2; $i >= 0; $i -= 2) { + $checkSum += array_sum(str_split($value{$i} * 2)); } - if ($sum === 0 || ($sum % 10) !== 0) { - $this->context->addViolation($constraint->message); + if (0 === $checkSum || 0 !== $checkSum % 10) { + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $value, + )); } } } From 5aa7e6dbe0d27c9cfcfb4cb8d44da1b061c2280d Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Thu, 10 Apr 2014 19:37:34 +0200 Subject: [PATCH 1164/1305] [Validator] Added "{{ value }}" parameters where they were missing --- .../Component/Validator/ConstraintValidator.php | 7 ++++--- .../Constraints/AbstractComparisonValidator.php | 4 ++-- .../Validator/Constraints/FalseValidator.php | 4 +++- .../Validator/Constraints/LuhnValidator.php | 3 ++- .../Validator/Constraints/NotBlankValidator.php | 4 +++- .../Validator/Constraints/NullValidator.php | 8 +------- .../Validator/Constraints/TrueValidator.php | 4 +++- .../Tests/Constraints/FalseValidatorTest.php | 2 +- .../Tests/Constraints/NullValidatorTest.php | 17 +++++++++-------- .../Tests/Constraints/TrueValidatorTest.php | 1 + 10 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/Symfony/Component/Validator/ConstraintValidator.php b/src/Symfony/Component/Validator/ConstraintValidator.php index fe3758f65bfa2..3aaf806cc2a47 100644 --- a/src/Symfony/Component/Validator/ConstraintValidator.php +++ b/src/Symfony/Component/Validator/ConstraintValidator.php @@ -48,13 +48,14 @@ protected function valueToType($value) /** * Returns a string representation of the value. * - * @param mixed $value + * @param mixed $value + * @param Boolean $formatDates * * @return string */ - protected function valueToString($value) + protected function valueToString($value, $formatDates = false) { - if ($value instanceof \DateTime) { + if ($formatDates && $value instanceof \DateTime) { if (class_exists('IntlDateFormatter')) { $locale = \Locale::getDefault(); $formatter = new \IntlDateFormatter($locale, \IntlDateFormatter::MEDIUM, \IntlDateFormatter::SHORT); diff --git a/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php b/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php index 351ce73491322..7beebf703cd8a 100644 --- a/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php +++ b/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php @@ -32,8 +32,8 @@ public function validate($value, Constraint $constraint) if (!$this->compareValues($value, $constraint->value)) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $this->valueToString($value), - '{{ compared_value }}' => $this->valueToString($constraint->value), + '{{ value }}' => $this->valueToString($value, true), + '{{ compared_value }}' => $this->valueToString($constraint->value, true), '{{ compared_value_type }}' => $this->valueToType($constraint->value) )); } diff --git a/src/Symfony/Component/Validator/Constraints/FalseValidator.php b/src/Symfony/Component/Validator/Constraints/FalseValidator.php index 4e8c4df26907a..76e370f348f2e 100644 --- a/src/Symfony/Component/Validator/Constraints/FalseValidator.php +++ b/src/Symfony/Component/Validator/Constraints/FalseValidator.php @@ -30,6 +30,8 @@ public function validate($value, Constraint $constraint) return; } - $this->context->addViolation($constraint->message); + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $this->valueToString($value), + )); } } diff --git a/src/Symfony/Component/Validator/Constraints/LuhnValidator.php b/src/Symfony/Component/Validator/Constraints/LuhnValidator.php index 444696994fc35..4a59e9559dffb 100644 --- a/src/Symfony/Component/Validator/Constraints/LuhnValidator.php +++ b/src/Symfony/Component/Validator/Constraints/LuhnValidator.php @@ -24,11 +24,12 @@ * @see http://en.wikipedia.org/wiki/Luhn_algorithm * @author Tim Nagel * @author Greg Knapp http://gregk.me/2011/php-implementation-of-bank-card-luhn-algorithm/ + * @author Bernhard Schussek */ class LuhnValidator extends ConstraintValidator { /** - * Validates a creditcard number with the Luhn algorithm. + * Validates a credit card number with the Luhn algorithm. * * @param mixed $value * @param Constraint $constraint diff --git a/src/Symfony/Component/Validator/Constraints/NotBlankValidator.php b/src/Symfony/Component/Validator/Constraints/NotBlankValidator.php index 98c2730fe8ccf..20675a8da9634 100644 --- a/src/Symfony/Component/Validator/Constraints/NotBlankValidator.php +++ b/src/Symfony/Component/Validator/Constraints/NotBlankValidator.php @@ -27,7 +27,9 @@ class NotBlankValidator extends ConstraintValidator public function validate($value, Constraint $constraint) { if (false === $value || (empty($value) && '0' != $value)) { - $this->context->addViolation($constraint->message); + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $this->valueToString($value), + )); } } } diff --git a/src/Symfony/Component/Validator/Constraints/NullValidator.php b/src/Symfony/Component/Validator/Constraints/NullValidator.php index bc9bf4f38ce2a..8698585ffdf24 100644 --- a/src/Symfony/Component/Validator/Constraints/NullValidator.php +++ b/src/Symfony/Component/Validator/Constraints/NullValidator.php @@ -27,14 +27,8 @@ class NullValidator extends ConstraintValidator public function validate($value, Constraint $constraint) { if (null !== $value) { - if (is_object($value)) { - $value = get_class($value); - } elseif (is_array($value)) { - $value = 'Array'; - } - $this->context->addViolation($constraint->message, array( - '{{ value }}' => $value, + '{{ value }}' => $this->valueToString($value), )); } } diff --git a/src/Symfony/Component/Validator/Constraints/TrueValidator.php b/src/Symfony/Component/Validator/Constraints/TrueValidator.php index 5ef74fd27454f..69495dd6a3c6a 100644 --- a/src/Symfony/Component/Validator/Constraints/TrueValidator.php +++ b/src/Symfony/Component/Validator/Constraints/TrueValidator.php @@ -31,7 +31,9 @@ public function validate($value, Constraint $constraint) } if (true !== $value && 1 !== $value && '1' !== $value) { - $this->context->addViolation($constraint->message); + $this->context->addViolation($constraint->message, array( + '{{ value }}' => $this->valueToString($value), + )); } } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php index 1bc16c20bd48a..22ab63a9e2def 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php @@ -56,7 +56,7 @@ public function testTrueIsInvalid() $this->context->expects($this->once()) ->method('addViolation') - ->with('myMessage', array()); + ->with('myMessage', array('{{ value }}' => 'true')); $this->validator->validate(true, $constraint); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php index d343c869fdf87..cbf8da1f385a1 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php @@ -43,7 +43,7 @@ public function testNullIsValid() /** * @dataProvider getInvalidValues */ - public function testInvalidValues($value, $readableValue) + public function testInvalidValues($value, $valueAsString) { $constraint = new Null(array( 'message' => 'myMessage' @@ -52,7 +52,7 @@ public function testInvalidValues($value, $readableValue) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => $readableValue, + '{{ value }}' => $valueAsString, )); $this->validator->validate($value, $constraint); @@ -61,12 +61,13 @@ public function testInvalidValues($value, $readableValue) public function getInvalidValues() { return array( - array(0, 0), - array(false, false), - array(true, true), - array('', ''), - array('foo bar', 'foo bar'), - array(new \DateTime(), 'DateTime'), + array(0, '0'), + array(false, 'false'), + array(true, 'true'), + array('', '""'), + array('foo bar', '"foo bar"'), + array(new \DateTime(), 'Object(DateTime)'), + array(new \stdClass(), 'Object(stdClass)'), array(array(), 'Array'), ); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php index 25901793a07bb..5a42912edfd90 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php @@ -57,6 +57,7 @@ public function testFalseIsInvalid() $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( + '{{ value }}' => 'false', )); $this->validator->validate(false, $constraint); From cea4155d3982c4f7842b4207230fbeae47b4843d Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Thu, 22 May 2014 10:30:24 +0200 Subject: [PATCH 1165/1305] [Validator] Fixed date-to-string conversion tests to match ICU 51 --- .../Component/Validator/ConstraintValidator.php | 17 +++++++++++++++++ .../Validator/Constraints/FileValidator.php | 4 ++-- .../AbstractComparisonValidatorTestCase.php | 8 ++++++++ .../Tests/Constraints/EqualToValidatorTest.php | 2 +- .../GreaterThanOrEqualValidatorTest.php | 2 +- .../Constraints/GreaterThanValidatorTest.php | 4 ++-- .../Constraints/IdenticalToValidatorTest.php | 4 ++-- .../LessThanOrEqualValidatorTest.php | 2 +- .../Tests/Constraints/LessThanValidatorTest.php | 4 ++-- .../Constraints/NotEqualToValidatorTest.php | 2 +- .../Constraints/NotIdenticalToValidatorTest.php | 2 +- 11 files changed, 38 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Component/Validator/ConstraintValidator.php b/src/Symfony/Component/Validator/ConstraintValidator.php index 3aaf806cc2a47..ac6a64dc37ecc 100644 --- a/src/Symfony/Component/Validator/ConstraintValidator.php +++ b/src/Symfony/Component/Validator/ConstraintValidator.php @@ -96,4 +96,21 @@ protected function valueToString($value, $formatDates = false) return (string) $value; } + + /** + * Returns a string representation of a list of values. + * + * @param array $values + * @param Boolean $formatDates + * + * @return string + */ + protected function valuesToString(array $values, $formatDates = false) + { + foreach ($values as $key => $value) { + $values[$key] = $this->valueToString($value, $formatDates); + } + + return implode(', ', $values); + } } diff --git a/src/Symfony/Component/Validator/Constraints/FileValidator.php b/src/Symfony/Component/Validator/Constraints/FileValidator.php index dce0480a0ee0f..24e64f9ee9d3c 100644 --- a/src/Symfony/Component/Validator/Constraints/FileValidator.php +++ b/src/Symfony/Component/Validator/Constraints/FileValidator.php @@ -161,8 +161,8 @@ public function validate($value, Constraint $constraint) if (false === $valid) { $this->context->addViolation($constraint->mimeTypesMessage, array( - '{{ type }}' => '"'.$mime.'"', - '{{ types }}' => '"'.implode('", "', $mimeTypes) .'"', + '{{ type }}' => $this->valueToString($mime), + '{{ types }}' => $this->valuesToString($mimeTypes), '{{ file }}' => $path, )); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php index c0ab0f7a53adf..80690d29e05dc 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\AbstractComparisonValidator; @@ -73,12 +74,19 @@ abstract public function provideValidComparisons(); /** * @dataProvider provideInvalidComparisons * @param mixed $dirtyValue + * @param mixed $dirtyValueAsString * @param mixed $comparedValue * @param mixed $comparedValueString * @param string $comparedValueType */ public function testInvalidComparisonToValue($dirtyValue, $dirtyValueAsString, $comparedValue, $comparedValueString, $comparedValueType) { + // Conversion of dates to string differs between ICU versions + // Make sure we have the correct version loaded + if ($dirtyValue instanceof \DateTime) { + IntlTestHelper::requireIntl($this); + } + $constraint = $this->createConstraint(array('value' => $comparedValue)); $constraint->message = 'Constraint Message'; diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php index 2cc624e7f3c77..783e5508d795f 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EqualToValidatorTest.php @@ -51,7 +51,7 @@ public function provideInvalidComparisons() return array( array(1, '1', 2, '2', 'integer'), array('22', '"22"', '333', '"333"', 'string'), - array(new \DateTime('2001-01-01'), 'Jan 1, 2001 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000 12:00 AM', 'DateTime') + array(new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime') ); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php index 8dd27f7f4b229..bb90f7c283307 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php @@ -52,7 +52,7 @@ public function provideInvalidComparisons() { return array( array(1, '1', 2, '2', 'integer'), - array(new \DateTime('2000/01/01'), 'Jan 1, 2000 12:00 AM', new \DateTime('2005/01/01'), 'Jan 1, 2005 12:00 AM', 'DateTime'), + array(new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2005/01/01'), 'Jan 1, 2005, 12:00 AM', 'DateTime'), array('b', '"b"', 'c', '"c"', 'string') ); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php index e261c42c8b5a4..14a7a6d16f539 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php @@ -50,8 +50,8 @@ public function provideInvalidComparisons() return array( array(1, '1', 2, '2', 'integer'), array(2, '2', 2, '2', 'integer'), - array(new \DateTime('2000/01/01'), 'Jan 1, 2000 12:00 AM', new \DateTime('2005/01/01'), 'Jan 1, 2005 12:00 AM', 'DateTime'), - array(new \DateTime('2000/01/01'), 'Jan 1, 2000 12:00 AM', new \DateTime('2000/01/01'), 'Jan 1, 2000 12:00 AM', 'DateTime'), + array(new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2005/01/01'), 'Jan 1, 2005, 12:00 AM', 'DateTime'), + array(new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'), array('22', '"22"', '333', '"333"', 'string'), array('22', '"22"', '22', '"22"', 'string') ); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php index 02f166c7cbcff..9c08523386612 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IdenticalToValidatorTest.php @@ -53,8 +53,8 @@ public function provideInvalidComparisons() array(1, '1', 2, '2', 'integer'), array(2, '2', '2', '"2"', 'string'), array('22', '"22"', '333', '"333"', 'string'), - array(new \DateTime('2001-01-01'), 'Jan 1, 2001 12:00 AM', new \DateTime('2001-01-01'), 'Jan 1, 2001 12:00 AM', 'DateTime'), - array(new \DateTime('2001-01-01'), 'Jan 1, 2001 12:00 AM', new \DateTime('1999-01-01'), 'Jan 1, 1999 12:00 AM', 'DateTime') + array(new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', 'DateTime'), + array(new \DateTime('2001-01-01'), 'Jan 1, 2001, 12:00 AM', new \DateTime('1999-01-01'), 'Jan 1, 1999, 12:00 AM', 'DateTime') ); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php index e2ce1bcbc181e..fc41811a76e47 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php @@ -52,7 +52,7 @@ public function provideInvalidComparisons() { return array( array(2, '2', 1, '1', 'integer'), - array(new \DateTime('2010-01-01'), 'Jan 1, 2010 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000 12:00 AM', 'DateTime'), + array(new \DateTime('2010-01-01'), 'Jan 1, 2010, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'), array('c', '"c"', 'b', '"b"', 'string') ); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php index 9e88ac1e2b32d..5cb5673c81655 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php @@ -50,8 +50,8 @@ public function provideInvalidComparisons() return array( array(3, '3', 2, '2', 'integer'), array(2, '2', 2, '2', 'integer'), - array(new \DateTime('2010-01-01'), 'Jan 1, 2010 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000 12:00 AM', 'DateTime'), - array(new \DateTime('2000-01-01'), 'Jan 1, 2000 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000 12:00 AM', 'DateTime'), + array(new \DateTime('2010-01-01'), 'Jan 1, 2010, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'), + array(new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'), array('333', '"333"', '22', '"22"', 'string'), ); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php index 334aeb219a599..e0db97a0e7920 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php @@ -51,7 +51,7 @@ public function provideInvalidComparisons() array(3, '3', 3, '3', 'integer'), array('2', '"2"', 2, '2', 'integer'), array('a', '"a"', 'a', '"a"', 'string'), - array(new \DateTime('2000-01-01'), 'Jan 1, 2000 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000 12:00 AM', 'DateTime') + array(new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime') ); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php index 406a10163fb3f..ad2865c457da9 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotIdenticalToValidatorTest.php @@ -54,7 +54,7 @@ public function provideInvalidComparisons() return array( array(3, '3', 3, '3', 'integer'), array('a', '"a"', 'a', '"a"', 'string'), - array($date, 'Jan 1, 2000 12:00 AM', $date, 'Jan 1, 2000 12:00 AM', 'DateTime') + array($date, 'Jan 1, 2000, 12:00 AM', $date, 'Jan 1, 2000, 12:00 AM', 'DateTime') ); } } From 71897d7e3591d4664204da17f50c8587ccd65582 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Thu, 22 May 2014 11:22:43 +0200 Subject: [PATCH 1166/1305] [Validator] Fixed CS --- src/Symfony/Component/Validator/ConstraintValidator.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Validator/ConstraintValidator.php b/src/Symfony/Component/Validator/ConstraintValidator.php index ac6a64dc37ecc..0cf50916dfcb9 100644 --- a/src/Symfony/Component/Validator/ConstraintValidator.php +++ b/src/Symfony/Component/Validator/ConstraintValidator.php @@ -48,8 +48,8 @@ protected function valueToType($value) /** * Returns a string representation of the value. * - * @param mixed $value - * @param Boolean $formatDates + * @param mixed $value + * @param bool $formatDates * * @return string */ @@ -100,8 +100,8 @@ protected function valueToString($value, $formatDates = false) /** * Returns a string representation of a list of values. * - * @param array $values - * @param Boolean $formatDates + * @param array $values + * @param bool $formatDates * * @return string */ From d6a783f989e76d844747ff4e024066b1fc423cbe Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Thu, 24 Jul 2014 14:14:19 +0200 Subject: [PATCH 1167/1305] [Validator] Renamed valueToString() to formatValue(); added missing formatValue() calls --- .../Validator/ConstraintValidator.php | 14 +++++------ .../AbstractComparisonValidator.php | 6 ++--- .../Validator/Constraints/BlankValidator.php | 2 +- .../Constraints/CardSchemeValidator.php | 4 ++-- .../Validator/Constraints/ChoiceValidator.php | 4 ++-- .../Constraints/CollectionValidator.php | 4 ++-- .../Constraints/CountryValidator.php | 2 +- .../Constraints/CurrencyValidator.php | 2 +- .../Validator/Constraints/DateValidator.php | 2 +- .../Validator/Constraints/EmailValidator.php | 2 +- .../Validator/Constraints/FalseValidator.php | 2 +- .../Validator/Constraints/FileValidator.php | 16 ++++++++----- .../Validator/Constraints/IbanValidator.php | 10 ++++---- .../Validator/Constraints/IpValidator.php | 2 +- .../Validator/Constraints/IsbnValidator.php | 6 ++--- .../Validator/Constraints/IssnValidator.php | 4 ++-- .../Constraints/LanguageValidator.php | 2 +- .../Validator/Constraints/LengthValidator.php | 6 ++--- .../Validator/Constraints/LocaleValidator.php | 2 +- .../Validator/Constraints/LuhnValidator.php | 4 ++-- .../Constraints/NotBlankValidator.php | 2 +- .../Validator/Constraints/NullValidator.php | 2 +- .../Validator/Constraints/RangeValidator.php | 2 +- .../Validator/Constraints/RegexValidator.php | 2 +- .../Validator/Constraints/TimeValidator.php | 2 +- .../Validator/Constraints/TrueValidator.php | 2 +- .../Validator/Constraints/TypeValidator.php | 2 +- .../Validator/Constraints/UrlValidator.php | 3 +-- .../Constraints/CollectionValidatorTest.php | 6 ++--- .../Constraints/DateTimeValidatorTest.php | 2 +- .../Tests/Constraints/DateValidatorTest.php | 2 +- .../Tests/Constraints/EmailValidatorTest.php | 2 +- .../Constraints/FileValidatorPathTest.php | 2 +- .../Tests/Constraints/FileValidatorTest.php | 10 ++++---- .../Tests/Constraints/IbanValidatorTest.php | 2 +- .../Tests/Constraints/IpValidatorTest.php | 24 +++++++++---------- .../Tests/Constraints/LengthValidatorTest.php | 6 ++--- .../Tests/Constraints/RangeValidatorTest.php | 15 ++++++++++++ .../Tests/Constraints/RegexValidatorTest.php | 2 +- .../Tests/Constraints/TimeValidatorTest.php | 2 +- .../Tests/Constraints/UrlValidatorTest.php | 2 +- 41 files changed, 105 insertions(+), 85 deletions(-) diff --git a/src/Symfony/Component/Validator/ConstraintValidator.php b/src/Symfony/Component/Validator/ConstraintValidator.php index 0cf50916dfcb9..bb3378cd93e10 100644 --- a/src/Symfony/Component/Validator/ConstraintValidator.php +++ b/src/Symfony/Component/Validator/ConstraintValidator.php @@ -40,7 +40,7 @@ public function initialize(ExecutionContextInterface $context) * * @return string */ - protected function valueToType($value) + protected function formatTypeOf($value) { return is_object($value) ? get_class($value) : gettype($value); } @@ -49,13 +49,13 @@ protected function valueToType($value) * Returns a string representation of the value. * * @param mixed $value - * @param bool $formatDates + * @param bool $prettyDateTime * * @return string */ - protected function valueToString($value, $formatDates = false) + protected function formatValue($value, $prettyDateTime = false) { - if ($formatDates && $value instanceof \DateTime) { + if ($prettyDateTime && $value instanceof \DateTime) { if (class_exists('IntlDateFormatter')) { $locale = \Locale::getDefault(); $formatter = new \IntlDateFormatter($locale, \IntlDateFormatter::MEDIUM, \IntlDateFormatter::SHORT); @@ -101,14 +101,14 @@ protected function valueToString($value, $formatDates = false) * Returns a string representation of a list of values. * * @param array $values - * @param bool $formatDates + * @param bool $prettyDateTime * * @return string */ - protected function valuesToString(array $values, $formatDates = false) + protected function formatValues(array $values, $prettyDateTime = false) { foreach ($values as $key => $value) { - $values[$key] = $this->valueToString($value, $formatDates); + $values[$key] = $this->formatValue($value, $prettyDateTime); } return implode(', ', $values); diff --git a/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php b/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php index 7beebf703cd8a..d2b15f21626b8 100644 --- a/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php +++ b/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php @@ -32,9 +32,9 @@ public function validate($value, Constraint $constraint) if (!$this->compareValues($value, $constraint->value)) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $this->valueToString($value, true), - '{{ compared_value }}' => $this->valueToString($constraint->value, true), - '{{ compared_value_type }}' => $this->valueToType($constraint->value) + '{{ value }}' => $this->formatValue($value, true), + '{{ compared_value }}' => $this->formatValue($constraint->value, true), + '{{ compared_value_type }}' => $this->formatTypeOf($constraint->value) )); } } diff --git a/src/Symfony/Component/Validator/Constraints/BlankValidator.php b/src/Symfony/Component/Validator/Constraints/BlankValidator.php index 7bb57ddd0e422..e8406a238efa8 100644 --- a/src/Symfony/Component/Validator/Constraints/BlankValidator.php +++ b/src/Symfony/Component/Validator/Constraints/BlankValidator.php @@ -28,7 +28,7 @@ public function validate($value, Constraint $constraint) { if ('' !== $value && null !== $value) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $this->valueToString($value) + '{{ value }}' => $this->formatValue($value) )); } } diff --git a/src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php b/src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php index eae71a92d4502..73f602adce4bc 100644 --- a/src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php @@ -109,7 +109,7 @@ public function validate($value, Constraint $constraint) if (!is_numeric($value)) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $this->valueToString($value), + '{{ value }}' => $this->formatValue($value), )); return; @@ -127,7 +127,7 @@ public function validate($value, Constraint $constraint) } $this->context->addViolation($constraint->message, array( - '{{ value }}' => $value, + '{{ value }}' => $this->formatValue($value), )); } } diff --git a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php index c4f3b56c8b81b..2e0658cfa6dac 100644 --- a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php @@ -60,7 +60,7 @@ public function validate($value, Constraint $constraint) foreach ($value as $_value) { if (!in_array($_value, $choices, $constraint->strict)) { $this->context->addViolation($constraint->multipleMessage, array( - '{{ value }}' => $this->valueToString($_value), + '{{ value }}' => $this->formatValue($_value), )); } } @@ -84,7 +84,7 @@ public function validate($value, Constraint $constraint) } } elseif (!in_array($value, $choices, $constraint->strict)) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $this->valueToString($value) + '{{ value }}' => $this->formatValue($value) )); } } diff --git a/src/Symfony/Component/Validator/Constraints/CollectionValidator.php b/src/Symfony/Component/Validator/Constraints/CollectionValidator.php index 538ff7e3460ea..a322ef49adc4f 100644 --- a/src/Symfony/Component/Validator/Constraints/CollectionValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CollectionValidator.php @@ -48,7 +48,7 @@ public function validate($value, Constraint $constraint) } } elseif (!$fieldConstraint instanceof Optional && !$constraint->allowMissingFields) { $this->context->addViolationAt('['.$field.']', $constraint->missingFieldsMessage, array( - '{{ field }}' => $field + '{{ field }}' => $this->formatValue($field) ), null); } } @@ -57,7 +57,7 @@ public function validate($value, Constraint $constraint) foreach ($value as $field => $fieldValue) { if (!isset($constraint->fields[$field])) { $this->context->addViolationAt('['.$field.']', $constraint->extraFieldsMessage, array( - '{{ field }}' => $field + '{{ field }}' => $this->formatValue($field) ), $fieldValue); } } diff --git a/src/Symfony/Component/Validator/Constraints/CountryValidator.php b/src/Symfony/Component/Validator/Constraints/CountryValidator.php index c912a650a6929..a094c1048183c 100644 --- a/src/Symfony/Component/Validator/Constraints/CountryValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CountryValidator.php @@ -43,7 +43,7 @@ public function validate($value, Constraint $constraint) if (!isset($countries[$value])) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $value, + '{{ value }}' => $this->formatValue($value), )); } } diff --git a/src/Symfony/Component/Validator/Constraints/CurrencyValidator.php b/src/Symfony/Component/Validator/Constraints/CurrencyValidator.php index d12952fc81a9d..d8c999af4d8be 100644 --- a/src/Symfony/Component/Validator/Constraints/CurrencyValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CurrencyValidator.php @@ -43,7 +43,7 @@ public function validate($value, Constraint $constraint) if (!isset($currencies[$value])) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $value, + '{{ value }}' => $this->formatValue($value), )); } } diff --git a/src/Symfony/Component/Validator/Constraints/DateValidator.php b/src/Symfony/Component/Validator/Constraints/DateValidator.php index 1170314a70b64..5e5250852fccf 100644 --- a/src/Symfony/Component/Validator/Constraints/DateValidator.php +++ b/src/Symfony/Component/Validator/Constraints/DateValidator.php @@ -41,7 +41,7 @@ public function validate($value, Constraint $constraint) if (!preg_match(static::PATTERN, $value, $matches) || !checkdate($matches[2], $matches[3], $matches[1])) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $value, + '{{ value }}' => $this->formatValue($value), )); } } diff --git a/src/Symfony/Component/Validator/Constraints/EmailValidator.php b/src/Symfony/Component/Validator/Constraints/EmailValidator.php index 5b433a768f045..b3789a130d75e 100644 --- a/src/Symfony/Component/Validator/Constraints/EmailValidator.php +++ b/src/Symfony/Component/Validator/Constraints/EmailValidator.php @@ -51,7 +51,7 @@ public function validate($value, Constraint $constraint) if (!$valid) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $value, + '{{ value }}' => $this->formatValue($value), )); } } diff --git a/src/Symfony/Component/Validator/Constraints/FalseValidator.php b/src/Symfony/Component/Validator/Constraints/FalseValidator.php index 76e370f348f2e..280deba3c922f 100644 --- a/src/Symfony/Component/Validator/Constraints/FalseValidator.php +++ b/src/Symfony/Component/Validator/Constraints/FalseValidator.php @@ -31,7 +31,7 @@ public function validate($value, Constraint $constraint) } $this->context->addViolation($constraint->message, array( - '{{ value }}' => $this->valueToString($value), + '{{ value }}' => $this->formatValue($value), )); } } diff --git a/src/Symfony/Component/Validator/Constraints/FileValidator.php b/src/Symfony/Component/Validator/Constraints/FileValidator.php index 24e64f9ee9d3c..006064594bef7 100644 --- a/src/Symfony/Component/Validator/Constraints/FileValidator.php +++ b/src/Symfony/Component/Validator/Constraints/FileValidator.php @@ -96,13 +96,17 @@ public function validate($value, Constraint $constraint) $path = $value instanceof FileObject ? $value->getPathname() : (string) $value; if (!is_file($path)) { - $this->context->addViolation($constraint->notFoundMessage, array('{{ file }}' => $path)); + $this->context->addViolation($constraint->notFoundMessage, array( + '{{ file }}' => $this->formatValue($path) + )); return; } if (!is_readable($path)) { - $this->context->addViolation($constraint->notReadableMessage, array('{{ file }}' => $path)); + $this->context->addViolation($constraint->notReadableMessage, array( + '{{ file }}' => $this->formatValue($path) + )); return; } @@ -129,7 +133,7 @@ public function validate($value, Constraint $constraint) '{{ size }}' => $size, '{{ limit }}' => $limit, '{{ suffix }}' => $suffix, - '{{ file }}' => $path, + '{{ file }}' => $this->formatValue($path), )); return; @@ -161,9 +165,9 @@ public function validate($value, Constraint $constraint) if (false === $valid) { $this->context->addViolation($constraint->mimeTypesMessage, array( - '{{ type }}' => $this->valueToString($mime), - '{{ types }}' => $this->valuesToString($mimeTypes), - '{{ file }}' => $path, + '{{ type }}' => $this->formatValue($mime), + '{{ types }}' => $this->formatValues($mimeTypes), + '{{ file }}' => $this->formatValue($path), )); } } diff --git a/src/Symfony/Component/Validator/Constraints/IbanValidator.php b/src/Symfony/Component/Validator/Constraints/IbanValidator.php index 615518883bce1..699db7ea7a67f 100644 --- a/src/Symfony/Component/Validator/Constraints/IbanValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IbanValidator.php @@ -36,12 +36,14 @@ public function validate($value, Constraint $constraint) throw new UnexpectedTypeException($value, 'string'); } + $value = (string) $value; + // Remove spaces $canonicalized = str_replace(' ', '', $value); if (strlen($canonicalized) < 4) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $value, + '{{ value }}' => $this->formatValue($value), )); return; @@ -52,7 +54,7 @@ public function validate($value, Constraint $constraint) if (strlen($canonicalized) < 4 || !ctype_upper($canonicalized{0}) || !ctype_upper($canonicalized{1}) || !ctype_alnum($canonicalized)) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $value, + '{{ value }}' => $this->formatValue($value), )); return; @@ -72,7 +74,7 @@ public function validate($value, Constraint $constraint) if (false === $checkSum) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $value, + '{{ value }}' => $this->formatValue($value), )); return; @@ -83,7 +85,7 @@ public function validate($value, Constraint $constraint) // modulo step-wisely instead if (1 !== $this->bigModulo97($checkSum)) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $value, + '{{ value }}' => $this->formatValue($value), )); return; diff --git a/src/Symfony/Component/Validator/Constraints/IpValidator.php b/src/Symfony/Component/Validator/Constraints/IpValidator.php index ad5d9e2466370..5ebda4e9e29b6 100644 --- a/src/Symfony/Component/Validator/Constraints/IpValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IpValidator.php @@ -92,7 +92,7 @@ public function validate($value, Constraint $constraint) if (!filter_var($value, FILTER_VALIDATE_IP, $flag)) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $value, + '{{ value }}' => $this->formatValue($value), )); } } diff --git a/src/Symfony/Component/Validator/Constraints/IsbnValidator.php b/src/Symfony/Component/Validator/Constraints/IsbnValidator.php index 0e79c3289a733..5fee10e718b86 100644 --- a/src/Symfony/Component/Validator/Constraints/IsbnValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IsbnValidator.php @@ -51,15 +51,15 @@ public function validate($value, Constraint $constraint) if ($constraint->isbn10 && $constraint->isbn13) { $this->context->addViolation($constraint->bothIsbnMessage, array( - '{{ value }}' => $value, + '{{ value }}' => $this->formatValue($value), )); } elseif ($constraint->isbn10) { $this->context->addViolation($constraint->isbn10Message, array( - '{{ value }}' => $value, + '{{ value }}' => $this->formatValue($value), )); } else { $this->context->addViolation($constraint->isbn13Message, array( - '{{ value }}' => $value, + '{{ value }}' => $this->formatValue($value), )); } } diff --git a/src/Symfony/Component/Validator/Constraints/IssnValidator.php b/src/Symfony/Component/Validator/Constraints/IssnValidator.php index 2ae70ec2f3318..301b40d2d97b2 100644 --- a/src/Symfony/Component/Validator/Constraints/IssnValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IssnValidator.php @@ -46,7 +46,7 @@ public function validate($value, Constraint $constraint) if (!preg_match($pattern, $value)) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $value, + '{{ value }}' => $this->formatValue($value), )); return; @@ -64,7 +64,7 @@ public function validate($value, Constraint $constraint) if (0 !== $checkSum % 11) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $value, + '{{ value }}' => $this->formatValue($value), )); } } diff --git a/src/Symfony/Component/Validator/Constraints/LanguageValidator.php b/src/Symfony/Component/Validator/Constraints/LanguageValidator.php index 02edb963f1a7a..8b048b8a48732 100644 --- a/src/Symfony/Component/Validator/Constraints/LanguageValidator.php +++ b/src/Symfony/Component/Validator/Constraints/LanguageValidator.php @@ -43,7 +43,7 @@ public function validate($value, Constraint $constraint) if (!isset($languages[$value])) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $value, + '{{ value }}' => $this->formatValue($value), )); } } diff --git a/src/Symfony/Component/Validator/Constraints/LengthValidator.php b/src/Symfony/Component/Validator/Constraints/LengthValidator.php index 8dc68483c8c64..ceccde5a61af4 100644 --- a/src/Symfony/Component/Validator/Constraints/LengthValidator.php +++ b/src/Symfony/Component/Validator/Constraints/LengthValidator.php @@ -45,7 +45,7 @@ public function validate($value, Constraint $constraint) if ($constraint->min == $constraint->max && $length != $constraint->min) { $this->context->addViolation($constraint->exactMessage, array( - '{{ value }}' => $stringValue, + '{{ value }}' => $this->formatValue($stringValue), '{{ limit }}' => $constraint->min, ), $value, (int) $constraint->min); @@ -54,7 +54,7 @@ public function validate($value, Constraint $constraint) if (null !== $constraint->max && $length > $constraint->max) { $this->context->addViolation($constraint->maxMessage, array( - '{{ value }}' => $stringValue, + '{{ value }}' => $this->formatValue($stringValue), '{{ limit }}' => $constraint->max, ), $value, (int) $constraint->max); @@ -63,7 +63,7 @@ public function validate($value, Constraint $constraint) if (null !== $constraint->min && $length < $constraint->min) { $this->context->addViolation($constraint->minMessage, array( - '{{ value }}' => $stringValue, + '{{ value }}' => $this->formatValue($stringValue), '{{ limit }}' => $constraint->min, ), $value, (int) $constraint->min); } diff --git a/src/Symfony/Component/Validator/Constraints/LocaleValidator.php b/src/Symfony/Component/Validator/Constraints/LocaleValidator.php index cfd2105e90444..1d887d58f09e0 100644 --- a/src/Symfony/Component/Validator/Constraints/LocaleValidator.php +++ b/src/Symfony/Component/Validator/Constraints/LocaleValidator.php @@ -43,7 +43,7 @@ public function validate($value, Constraint $constraint) if (!isset($locales[$value])) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $value, + '{{ value }}' => $this->formatValue($value), )); } } diff --git a/src/Symfony/Component/Validator/Constraints/LuhnValidator.php b/src/Symfony/Component/Validator/Constraints/LuhnValidator.php index 4a59e9559dffb..1cc7a7b22f2b7 100644 --- a/src/Symfony/Component/Validator/Constraints/LuhnValidator.php +++ b/src/Symfony/Component/Validator/Constraints/LuhnValidator.php @@ -50,7 +50,7 @@ public function validate($value, Constraint $constraint) if (!ctype_digit($value)) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $value, + '{{ value }}' => $this->formatValue($value), )); return; @@ -80,7 +80,7 @@ public function validate($value, Constraint $constraint) if (0 === $checkSum || 0 !== $checkSum % 10) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $value, + '{{ value }}' => $this->formatValue($value), )); } } diff --git a/src/Symfony/Component/Validator/Constraints/NotBlankValidator.php b/src/Symfony/Component/Validator/Constraints/NotBlankValidator.php index 20675a8da9634..945803348ba58 100644 --- a/src/Symfony/Component/Validator/Constraints/NotBlankValidator.php +++ b/src/Symfony/Component/Validator/Constraints/NotBlankValidator.php @@ -28,7 +28,7 @@ public function validate($value, Constraint $constraint) { if (false === $value || (empty($value) && '0' != $value)) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $this->valueToString($value), + '{{ value }}' => $this->formatValue($value), )); } } diff --git a/src/Symfony/Component/Validator/Constraints/NullValidator.php b/src/Symfony/Component/Validator/Constraints/NullValidator.php index 8698585ffdf24..9c5deb36e7401 100644 --- a/src/Symfony/Component/Validator/Constraints/NullValidator.php +++ b/src/Symfony/Component/Validator/Constraints/NullValidator.php @@ -28,7 +28,7 @@ public function validate($value, Constraint $constraint) { if (null !== $value) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $this->valueToString($value), + '{{ value }}' => $this->formatValue($value), )); } } diff --git a/src/Symfony/Component/Validator/Constraints/RangeValidator.php b/src/Symfony/Component/Validator/Constraints/RangeValidator.php index fe79f5422260a..c2df195b81e73 100644 --- a/src/Symfony/Component/Validator/Constraints/RangeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/RangeValidator.php @@ -30,7 +30,7 @@ public function validate($value, Constraint $constraint) if (!is_numeric($value)) { $this->context->addViolation($constraint->invalidMessage, array( - '{{ value }}' => $this->valueToString($value), + '{{ value }}' => $this->formatValue($value), )); return; diff --git a/src/Symfony/Component/Validator/Constraints/RegexValidator.php b/src/Symfony/Component/Validator/Constraints/RegexValidator.php index f59d6a4e25b6f..88ea8ae05b18f 100644 --- a/src/Symfony/Component/Validator/Constraints/RegexValidator.php +++ b/src/Symfony/Component/Validator/Constraints/RegexValidator.php @@ -42,7 +42,7 @@ public function validate($value, Constraint $constraint) if ($constraint->match xor preg_match($constraint->pattern, $value)) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $value, + '{{ value }}' => $this->formatValue($value), )); } } diff --git a/src/Symfony/Component/Validator/Constraints/TimeValidator.php b/src/Symfony/Component/Validator/Constraints/TimeValidator.php index 36260e67d1d84..a7c2b27ad0785 100644 --- a/src/Symfony/Component/Validator/Constraints/TimeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/TimeValidator.php @@ -41,7 +41,7 @@ public function validate($value, Constraint $constraint) if (!preg_match(static::PATTERN, $value)) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $value, + '{{ value }}' => $this->formatValue($value), )); } } diff --git a/src/Symfony/Component/Validator/Constraints/TrueValidator.php b/src/Symfony/Component/Validator/Constraints/TrueValidator.php index 69495dd6a3c6a..480230a9091b5 100644 --- a/src/Symfony/Component/Validator/Constraints/TrueValidator.php +++ b/src/Symfony/Component/Validator/Constraints/TrueValidator.php @@ -32,7 +32,7 @@ public function validate($value, Constraint $constraint) if (true !== $value && 1 !== $value && '1' !== $value) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $this->valueToString($value), + '{{ value }}' => $this->formatValue($value), )); } } diff --git a/src/Symfony/Component/Validator/Constraints/TypeValidator.php b/src/Symfony/Component/Validator/Constraints/TypeValidator.php index ff713ffeef2d9..237546a5b990e 100644 --- a/src/Symfony/Component/Validator/Constraints/TypeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/TypeValidator.php @@ -44,7 +44,7 @@ public function validate($value, Constraint $constraint) } $this->context->addViolation($constraint->message, array( - '{{ value }}' => $this->valueToString($value), + '{{ value }}' => $this->formatValue($value), '{{ type }}' => $constraint->type, )); } diff --git a/src/Symfony/Component/Validator/Constraints/UrlValidator.php b/src/Symfony/Component/Validator/Constraints/UrlValidator.php index 4aeab117af1dc..748f824894a0b 100644 --- a/src/Symfony/Component/Validator/Constraints/UrlValidator.php +++ b/src/Symfony/Component/Validator/Constraints/UrlValidator.php @@ -51,12 +51,11 @@ public function validate($value, Constraint $constraint) } $value = (string) $value; - $pattern = sprintf(static::PATTERN, implode('|', $constraint->protocols)); if (!preg_match($pattern, $value)) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $value, + '{{ value }}' => $this->formatValue($value), )); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php index 4a13234b69550..e966aadae7877 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php @@ -147,7 +147,7 @@ public function testExtraFieldsDisallowed() $this->context->expects($this->once()) ->method('addViolationAt') ->with('[baz]', 'myMessage', array( - '{{ field }}' => 'baz' + '{{ field }}' => '"baz"' )); $this->validator->validate($data, new Collection(array( @@ -211,7 +211,7 @@ public function testMissingFieldsDisallowed() $this->context->expects($this->once()) ->method('addViolationAt') ->with('[foo]', 'myMessage', array( - '{{ field }}' => 'foo', + '{{ field }}' => '"foo"', )); $this->validator->validate($data, $constraint); @@ -331,7 +331,7 @@ public function testRequiredFieldNotPresent() $this->context->expects($this->once()) ->method('addViolationAt') ->with('[foo]', 'myMessage', array( - '{{ field }}' => 'foo', + '{{ field }}' => '"foo"', )); $this->validator->validate($data, new Collection(array( diff --git a/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php index 0776848fdbd47..46079a8155020 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php @@ -96,7 +96,7 @@ public function testInvalidDateTimes($dateTime) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => $dateTime, + '{{ value }}' => '"'.$dateTime.'"', )); $this->validator->validate($dateTime, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php index b9cf8816b76a5..a62426ec8a58f 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php @@ -96,7 +96,7 @@ public function testInvalidDates($date) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => $date, + '{{ value }}' => '"'.$date.'"', )); $this->validator->validate($date, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php index 701ab1f556df2..4b7a8bd6c39b2 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php @@ -88,7 +88,7 @@ public function testInvalidEmails($email) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => $email, + '{{ value }}' => '"'.$email.'"', )); $this->validator->validate($email, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorPathTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorPathTest.php index c4b93cdcd3424..7701d7faf42ea 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorPathTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorPathTest.php @@ -29,7 +29,7 @@ public function testFileNotFound() $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ file }}' => 'foobar', + '{{ file }}' => '"foobar"', )); $this->validator->validate('foobar', $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php index fcbbb04b83915..47952f061cab0 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php @@ -101,7 +101,7 @@ public function testTooLargeBytes() '{{ limit }}' => '10', '{{ size }}' => '11', '{{ suffix }}' => 'bytes', - '{{ file }}' => $this->path, + '{{ file }}' => '"'.$this->path.'"', )); $this->validator->validate($this->getFile($this->path), $constraint); @@ -122,7 +122,7 @@ public function testTooLargeKiloBytes() '{{ limit }}' => '1', '{{ size }}' => '1.4', '{{ suffix }}' => 'kB', - '{{ file }}' => $this->path, + '{{ file }}' => '"'.$this->path.'"', )); $this->validator->validate($this->getFile($this->path), $constraint); @@ -143,7 +143,7 @@ public function testTooLargeMegaBytes() '{{ limit }}' => '1', '{{ size }}' => '1.4', '{{ suffix }}' => 'MB', - '{{ file }}' => $this->path, + '{{ file }}' => '"'.$this->path.'"', )); $this->validator->validate($this->getFile($this->path), $constraint); @@ -245,7 +245,7 @@ public function testInvalidMimeType() ->with('myMessage', array( '{{ type }}' => '"application/pdf"', '{{ types }}' => '"image/png", "image/jpg"', - '{{ file }}' => $this->path, + '{{ file }}' => '"'.$this->path.'"', )); $this->validator->validate($file, $constraint); @@ -279,7 +279,7 @@ public function testInvalidWildcardMimeType() ->with('myMessage', array( '{{ type }}' => '"application/pdf"', '{{ types }}' => '"image/*", "image/jpg"', - '{{ file }}' => $this->path, + '{{ file }}' => '"'.$this->path.'"', )); $this->validator->validate($file, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php index cf0802fed2e73..49b39430178d8 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php @@ -164,7 +164,7 @@ public function testInvalidIbans($iban) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => $iban, + '{{ value }}' => '"'.$iban.'"', )); $this->validator->validate($iban, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php index bdf61928802f2..25cd5d44f840a 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php @@ -162,7 +162,7 @@ public function testInvalidIpsV4($ip) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => $ip, + '{{ value }}' => '"'.$ip.'"', )); $this->validator->validate($ip, $constraint); @@ -196,7 +196,7 @@ public function testInvalidPrivateIpsV4($ip) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => $ip, + '{{ value }}' => '"'.$ip.'"', )); $this->validator->validate($ip, $constraint); @@ -224,7 +224,7 @@ public function testInvalidReservedIpsV4($ip) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => $ip, + '{{ value }}' => '"'.$ip.'"', )); $this->validator->validate($ip, $constraint); @@ -252,7 +252,7 @@ public function testInvalidPublicIpsV4($ip) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => $ip, + '{{ value }}' => '"'.$ip.'"', )); $this->validator->validate($ip, $constraint); @@ -276,7 +276,7 @@ public function testInvalidIpsV6($ip) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => $ip, + '{{ value }}' => '"'.$ip.'"', )); $this->validator->validate($ip, $constraint); @@ -314,7 +314,7 @@ public function testInvalidPrivateIpsV6($ip) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => $ip, + '{{ value }}' => '"'.$ip.'"', )); $this->validator->validate($ip, $constraint); @@ -342,7 +342,7 @@ public function testInvalidReservedIpsV6($ip) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => $ip, + '{{ value }}' => '"'.$ip.'"', )); $this->validator->validate($ip, $constraint); @@ -369,7 +369,7 @@ public function testInvalidPublicIpsV6($ip) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => $ip, + '{{ value }}' => '"'.$ip.'"', )); $this->validator->validate($ip, $constraint); @@ -393,7 +393,7 @@ public function testInvalidIpsAll($ip) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => $ip, + '{{ value }}' => '"'.$ip.'"', )); $this->validator->validate($ip, $constraint); @@ -417,7 +417,7 @@ public function testInvalidPrivateIpsAll($ip) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => $ip, + '{{ value }}' => '"'.$ip.'"', )); $this->validator->validate($ip, $constraint); @@ -441,7 +441,7 @@ public function testInvalidReservedIpsAll($ip) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => $ip, + '{{ value }}' => '"'.$ip.'"', )); $this->validator->validate($ip, $constraint); @@ -465,7 +465,7 @@ public function testInvalidPublicIpsAll($ip) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => $ip, + '{{ value }}' => '"'.$ip.'"', )); $this->validator->validate($ip, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php index db6339449d90e..267f05b1b6059 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php @@ -167,7 +167,7 @@ public function testInvalidValuesMin($value, $mbOnly = false) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', $this->identicalTo(array( - '{{ value }}' => (string) $value, + '{{ value }}' => '"'.$value.'"', '{{ limit }}' => 4, )), $this->identicalTo($value), 4); @@ -191,7 +191,7 @@ public function testInvalidValuesMax($value, $mbOnly = false) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', $this->identicalTo(array( - '{{ value }}' => (string) $value, + '{{ value }}' => '"'.$value.'"', '{{ limit }}' => 4, )), $this->identicalTo($value), 4); @@ -216,7 +216,7 @@ public function testInvalidValuesExact($value, $mbOnly = false) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', $this->identicalTo(array( - '{{ value }}' => (string) $value, + '{{ value }}' => '"'.$value.'"', '{{ limit }}' => 4, )), $this->identicalTo($value), 4); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php index c44b0ea6ce439..f7601de797baf 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php @@ -234,4 +234,19 @@ public function testMaxMessageIsSet() $this->validator->validate(21, $constraint); } + + public function testNonNumeric() + { + $this->context->expects($this->once()) + ->method('addViolation') + ->with('myMessage', array( + '{{ value }}' => '"abcd"', + )); + + $this->validator->validate('abcd', new Range(array( + 'min' => 10, + 'max' => 20, + 'invalidMessage' => 'myMessage', + ))); + } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php index 1ea79fb8e29b1..25b5006c33e27 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php @@ -91,7 +91,7 @@ public function testInvalidValues($value) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => $value, + '{{ value }}' => '"'.$value.'"', )); $this->validator->validate($value, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php index ba398ab373b16..cfa24b80c7462 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php @@ -96,7 +96,7 @@ public function testInvalidTimes($time) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => $time, + '{{ value }}' => '"'.$time.'"', )); $this->validator->validate($time, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php index 1cf4bb4d222c6..ac2cf9e3608bf 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php @@ -131,7 +131,7 @@ public function testInvalidUrls($url) $this->context->expects($this->once()) ->method('addViolation') ->with('myMessage', array( - '{{ value }}' => $url, + '{{ value }}' => '"'.$url.'"', )); $this->validator->validate($url, $constraint); From c9742efe991732b22ec9fedf83ae2a926af99b15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Thu, 24 Jul 2014 17:02:45 +0200 Subject: [PATCH 1168/1305] [Translator] Use quote to surround invalid locale --- src/Symfony/Component/Translation/Translator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Translation/Translator.php b/src/Symfony/Component/Translation/Translator.php index d13adc07c6e09..0ed30526d2b43 100644 --- a/src/Symfony/Component/Translation/Translator.php +++ b/src/Symfony/Component/Translation/Translator.php @@ -309,7 +309,7 @@ protected function computeFallbackLocales($locale) private function assertValidLocale($locale) { if (1 !== preg_match('/^[a-z0-9@_\\.\\-]*$/i', $locale)) { - throw new \InvalidArgumentException(sprintf('Invalid locale: %s.', $locale)); + throw new \InvalidArgumentException(sprintf('Invalid "%s" locale.', $locale)); } } } From 123fc62652ec712fcf15216e5fca78fbf398d787 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 20 Jul 2014 16:43:00 +0200 Subject: [PATCH 1169/1305] properly handle null data when denormalizing If null is passed to denormalize(), no property values can be set on the denormalized object. Additionally, this fixes passing values to the denormalized object's constructor if the incoming data is an object. --- .../Normalizer/GetSetMethodNormalizer.php | 20 +++++++++--- .../Normalizer/GetSetMethodNormalizerTest.php | 32 +++++++++++++++++++ 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php index e4e3d82291b7d..122ab0e5dcdce 100644 --- a/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php @@ -114,6 +114,18 @@ public function normalize($object, $format = null, array $context = array()) */ public function denormalize($data, $class, $format = null, array $context = array()) { + if (is_array($data) || is_object($data) && $data instanceof \ArrayAccess) { + $normalizedData = $data; + } elseif (is_object($data)) { + $normalizedData = array(); + + foreach ($data as $attribute => $value) { + $normalizedData[$attribute] = $value; + } + } else { + $normalizedData = array(); + } + $reflectionClass = new \ReflectionClass($class); $constructor = $reflectionClass->getConstructor(); @@ -124,10 +136,10 @@ public function denormalize($data, $class, $format = null, array $context = arra foreach ($constructorParameters as $constructorParameter) { $paramName = lcfirst($this->formatAttribute($constructorParameter->name)); - if (isset($data[$paramName])) { - $params[] = $data[$paramName]; + if (isset($normalizedData[$paramName])) { + $params[] = $normalizedData[$paramName]; // don't run set for a parameter passed to the constructor - unset($data[$paramName]); + unset($normalizedData[$paramName]); } elseif ($constructorParameter->isOptional()) { $params[] = $constructorParameter->getDefaultValue(); } else { @@ -144,7 +156,7 @@ public function denormalize($data, $class, $format = null, array $context = arra $object = new $class; } - foreach ($data as $attribute => $value) { + foreach ($normalizedData as $attribute => $value) { $setter = 'set'.$this->formatAttribute($attribute); if (method_exists($object, $setter)) { diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php index e4f1b5c656cbb..1cbceece04458 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -15,6 +15,11 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase { + /** + * @var GetSetMethodNormalizer + */ + private $normalizer; + protected function setUp() { $this->normalizer = new GetSetMethodNormalizer(); @@ -44,6 +49,17 @@ public function testDenormalize() $this->assertEquals('bar', $obj->getBar()); } + public function testDenormalizeWithObject() + { + $data = new \stdClass(); + $data->foo = 'foo'; + $data->bar = 'bar'; + $data->fooBar = 'foobar'; + $obj = $this->normalizer->denormalize($data, __NAMESPACE__.'\GetSetDummy', 'any'); + $this->assertEquals('foo', $obj->getFoo()); + $this->assertEquals('bar', $obj->getBar()); + } + public function testDenormalizeOnCamelCaseFormat() { $this->normalizer->setCamelizedAttributes(array('camel_case')); @@ -54,6 +70,11 @@ public function testDenormalizeOnCamelCaseFormat() $this->assertEquals('camelCase', $obj->getCamelCase()); } + public function testDenormalizeNull() + { + $this->assertEquals(new GetSetDummy(), $this->normalizer->denormalize(null, __NAMESPACE__.'\GetSetDummy')); + } + /** * @dataProvider attributeProvider */ @@ -96,6 +117,17 @@ public function testConstructorDenormalizeWithMissingOptionalArgument() $this->assertEquals(array(1, 2, 3), $obj->getBaz()); } + public function testConstructorWithObjectDenormalize() + { + $data = new \stdClass(); + $data->foo = 'foo'; + $data->bar = 'bar'; + $data->fooBar = 'foobar'; + $obj = $this->normalizer->denormalize($data, __NAMESPACE__.'\GetConstructorDummy', 'any'); + $this->assertEquals('foo', $obj->getFoo()); + $this->assertEquals('bar', $obj->getBar()); + } + /** * @dataProvider provideCallbacks */ From f401ab9032378884e9e5bb9d6727b15c3e55e690 Mon Sep 17 00:00:00 2001 From: Benjamin Cremer Date: Wed, 9 Jul 2014 09:53:11 +0200 Subject: [PATCH 1170/1305] Fixed server HTTP_HOST port uri conversion --- src/Symfony/Component/BrowserKit/Client.php | 6 +++++- .../Component/BrowserKit/Tests/ClientTest.php | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/BrowserKit/Client.php b/src/Symfony/Component/BrowserKit/Client.php index a69e1625c0819..befc0371f4300 100644 --- a/src/Symfony/Component/BrowserKit/Client.php +++ b/src/Symfony/Component/BrowserKit/Client.php @@ -304,7 +304,11 @@ public function request($method, $uri, array $parameters = array(), array $files $uri = $this->getAbsoluteUri($uri); if (isset($server['HTTP_HOST'])) { - $uri = preg_replace('{^(https?\://)'.parse_url($uri, PHP_URL_HOST).'}', '${1}'.$server['HTTP_HOST'], $uri); + if ($port = parse_url($uri, PHP_URL_PORT)) { + $port = ':'.$port; + } + + $uri = preg_replace('{^(https?\://)'.parse_url($uri, PHP_URL_HOST).$port.'}', '${1}'.$server['HTTP_HOST'], $uri); } if (isset($server['HTTPS'])) { diff --git a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php index 2612bb26c4d2d..a5eade2a58121 100644 --- a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php @@ -210,6 +210,24 @@ public function testRequestURIConversion() $this->assertEquals('http://www.example.com/foo/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); } + public function testRequestURIConversionByServerHost() + { + $client = new TestClient(); + + $server = array('HTTP_HOST' => 'www.example.com:8000'); + $parameters = array(); + $files = array(); + + $client->request('GET', 'http://example.com', $parameters, $files, $server); + $this->assertEquals('http://www.example.com:8000', $client->getRequest()->getUri(), '->request() uses HTTP_HOST to add port'); + + $client->request('GET', 'http://example.com:8888', $parameters, $files, $server); + $this->assertEquals('http://www.example.com:8000', $client->getRequest()->getUri(), '->request() uses HTTP_HOST to modify existing port'); + + $client->request('GET', 'http://example.com:8000', $parameters, $files, $server); + $this->assertEquals('http://www.example.com:8000', $client->getRequest()->getUri(), '->request() uses HTTP_HOST respects correct set port'); + } + public function testRequestReferer() { $client = new TestClient(); From 103fd88b403f0ff5ddec5284344ffb64fc0183df Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 25 Jul 2014 07:47:26 +0200 Subject: [PATCH 1171/1305] [BrowserKit] refactor code and fix unquoted regex --- src/Symfony/Component/BrowserKit/Client.php | 24 ++++++++++--------- .../Component/BrowserKit/Tests/ClientTest.php | 14 +++++------ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/Symfony/Component/BrowserKit/Client.php b/src/Symfony/Component/BrowserKit/Client.php index befc0371f4300..6e91305a74d78 100644 --- a/src/Symfony/Component/BrowserKit/Client.php +++ b/src/Symfony/Component/BrowserKit/Client.php @@ -304,11 +304,7 @@ public function request($method, $uri, array $parameters = array(), array $files $uri = $this->getAbsoluteUri($uri); if (isset($server['HTTP_HOST'])) { - if ($port = parse_url($uri, PHP_URL_PORT)) { - $port = ':'.$port; - } - - $uri = preg_replace('{^(https?\://)'.parse_url($uri, PHP_URL_HOST).$port.'}', '${1}'.$server['HTTP_HOST'], $uri); + $uri = preg_replace('{^(https?\://)'.preg_quote($this->extractHost($uri)).'}', '${1}'.$server['HTTP_HOST'], $uri); } if (isset($server['HTTPS'])) { @@ -321,12 +317,7 @@ public function request($method, $uri, array $parameters = array(), array $files $server['HTTP_REFERER'] = $this->history->current()->getUri(); } - $server['HTTP_HOST'] = parse_url($uri, PHP_URL_HOST); - - if ($port = parse_url($uri, PHP_URL_PORT)) { - $server['HTTP_HOST'] .= ':'.$port; - } - + $server['HTTP_HOST'] = $this->extractHost($uri); $server['HTTPS'] = 'https' == parse_url($uri, PHP_URL_SCHEME); $this->internalRequest = new Request($uri, $method, $parameters, $files, $this->cookieJar->allValues($uri), $server, $content); @@ -623,4 +614,15 @@ private function updateServerFromUri($server, $uri) return $server; } + + private function extractHost($uri) + { + $host = parse_url($uri, PHP_URL_HOST); + + if ($port = parse_url($uri, PHP_URL_PORT)) { + return $host.':'.$port; + } + + return $host; + } } diff --git a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php index a5eade2a58121..cd37fcf76ae1f 100644 --- a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php @@ -214,18 +214,18 @@ public function testRequestURIConversionByServerHost() { $client = new TestClient(); - $server = array('HTTP_HOST' => 'www.example.com:8000'); + $server = array('HTTP_HOST' => 'www.exampl+e.com:8000'); $parameters = array(); $files = array(); - $client->request('GET', 'http://example.com', $parameters, $files, $server); - $this->assertEquals('http://www.example.com:8000', $client->getRequest()->getUri(), '->request() uses HTTP_HOST to add port'); + $client->request('GET', 'http://exampl+e.com', $parameters, $files, $server); + $this->assertEquals('http://www.exampl+e.com:8000', $client->getRequest()->getUri(), '->request() uses HTTP_HOST to add port'); - $client->request('GET', 'http://example.com:8888', $parameters, $files, $server); - $this->assertEquals('http://www.example.com:8000', $client->getRequest()->getUri(), '->request() uses HTTP_HOST to modify existing port'); + $client->request('GET', 'http://exampl+e.com:8888', $parameters, $files, $server); + $this->assertEquals('http://www.exampl+e.com:8000', $client->getRequest()->getUri(), '->request() uses HTTP_HOST to modify existing port'); - $client->request('GET', 'http://example.com:8000', $parameters, $files, $server); - $this->assertEquals('http://www.example.com:8000', $client->getRequest()->getUri(), '->request() uses HTTP_HOST respects correct set port'); + $client->request('GET', 'http://exampl+e.com:8000', $parameters, $files, $server); + $this->assertEquals('http://www.exampl+e.com:8000', $client->getRequest()->getUri(), '->request() uses HTTP_HOST respects correct set port'); } public function testRequestReferer() From eb68662360d584f2063788c6dcfaee52b6cc7803 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 22 Jul 2014 18:04:22 +0200 Subject: [PATCH 1172/1305] [Process] fix signal handling in wait() wait() throws an exception when the process was terminated by a signal. This should not happen when the termination was requested by calling either the stop() or the signal() method (for example, inside a callback which is passed to wait()). --- src/Symfony/Component/Process/Process.php | 10 ++++- .../Process/Tests/SimpleProcessTest.php | 44 +++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 2ccad53d775c8..3185633fbfd25 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -64,6 +64,8 @@ class Process /** @var ProcessPipes */ private $processPipes; + private $latestSignal; + private static $sigchild; /** @@ -321,7 +323,7 @@ public function wait($callback = null) usleep(1000); } - if ($this->processInformation['signaled']) { + if ($this->processInformation['signaled'] && $this->processInformation['termsig'] !== $this->latestSignal) { throw new RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->processInformation['termsig'])); } @@ -661,7 +663,8 @@ public function stop($timeout = 10, $signal = null) throw new RuntimeException('Unable to kill the process'); } } - proc_terminate($this->process); + // given `SIGTERM` may not be defined and that `proc_terminate` uses the constant value and not the constant itself, we use the same here + $this->doSignal(15, false); do { usleep(1000); } while ($this->isRunning() && microtime(true) < $timeoutMicro); @@ -1158,6 +1161,7 @@ private function resetProcessData() $this->stdout = null; $this->stderr = null; $this->process = null; + $this->latestSignal = null; $this->status = self::STATUS_READY; $this->incrementalOutputOffset = 0; $this->incrementalErrorOutputOffset = 0; @@ -1201,6 +1205,8 @@ private function doSignal($signal, $throwException) return false; } + $this->latestSignal = $signal; + return true; } diff --git a/src/Symfony/Component/Process/Tests/SimpleProcessTest.php b/src/Symfony/Component/Process/Tests/SimpleProcessTest.php index 69ad3d5b09f1d..cb06f289682f5 100644 --- a/src/Symfony/Component/Process/Tests/SimpleProcessTest.php +++ b/src/Symfony/Component/Process/Tests/SimpleProcessTest.php @@ -147,6 +147,50 @@ public function testSignalWithWrongNonIntSignal() parent::testSignalWithWrongNonIntSignal(); } + public function testStopTerminatesProcessCleanly() + { + try { + $process = $this->getProcess('php -r "echo \'foo\'; sleep(1); echo \'bar\';"'); + $process->run(function () use ($process) { + $process->stop(); + }); + } catch (RuntimeException $e) { + $this->fail('A call to stop() is not expected to cause wait() to throw a RuntimeException'); + } + } + + public function testKillSignalTerminatesProcessCleanly() + { + $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.'); + + try { + $process = $this->getProcess('php -r "echo \'foo\'; sleep(1); echo \'bar\';"'); + $process->run(function () use ($process) { + if ($process->isRunning()) { + $process->signal(SIGKILL); + } + }); + } catch (RuntimeException $e) { + $this->fail('A call to signal() is not expected to cause wait() to throw a RuntimeException'); + } + } + + public function testTermSignalTerminatesProcessCleanly() + { + $this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.'); + + try { + $process = $this->getProcess('php -r "echo \'foo\'; sleep(1); echo \'bar\';"'); + $process->run(function () use ($process) { + if ($process->isRunning()) { + $process->signal(SIGTERM); + } + }); + } catch (RuntimeException $e) { + $this->fail('A call to signal() is not expected to cause wait() to throw a RuntimeException'); + } + } + /** * {@inheritdoc} */ From 5939d34c17350684a0c5004591df7021d2f5ec9b Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 25 Jul 2014 09:46:51 +0200 Subject: [PATCH 1173/1305] [Process] Fix unit tests in sigchild environment --- .../Process/Tests/SigchildDisabledProcessTest.php | 5 +++++ .../Process/Tests/SigchildEnabledProcessTest.php | 15 +++++++++++++++ .../Component/Process/Tests/SimpleProcessTest.php | 7 +++++++ 3 files changed, 27 insertions(+) diff --git a/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php b/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php index 798e66a57193f..383a532203142 100644 --- a/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php +++ b/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php @@ -211,6 +211,11 @@ public function testExitCodeIsAvailableAfterSignal() $this->markTestSkipped('Signal is not supported in sigchild environment'); } + public function testRunProcessWithTimeout() + { + $this->markTestSkipped('Signal (required for timeout) is not supported in sigchild environment'); + } + /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php b/src/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php index 65dd4bb57364e..37a064188f7d0 100644 --- a/src/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php +++ b/src/Symfony/Component/Process/Tests/SigchildEnabledProcessTest.php @@ -120,6 +120,21 @@ public function testStartAfterATimeout() parent::testStartAfterATimeout(); } + public function testStopWithTimeoutIsActuallyWorking() + { + $this->markTestSkipped('Stopping with signal is not supported in sigchild environment'); + } + + public function testRunProcessWithTimeout() + { + $this->markTestSkipped('Signal (required for timeout) is not supported in sigchild environment'); + } + + public function testCheckTimeoutOnStartedProcess() + { + $this->markTestSkipped('Signal (required for timeout) is not supported in sigchild environment'); + } + /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Process/Tests/SimpleProcessTest.php b/src/Symfony/Component/Process/Tests/SimpleProcessTest.php index cb06f289682f5..ccaa78df24599 100644 --- a/src/Symfony/Component/Process/Tests/SimpleProcessTest.php +++ b/src/Symfony/Component/Process/Tests/SimpleProcessTest.php @@ -191,6 +191,13 @@ public function testTermSignalTerminatesProcessCleanly() } } + public function testStopWithTimeoutIsActuallyWorking() + { + $this->skipIfPHPSigchild(); + + parent::testStopWithTimeoutIsActuallyWorking(); + } + /** * {@inheritdoc} */ From fdbb04a6aca2dd11cc8bb1418a5d0156dd8a650e Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 25 Jul 2014 15:59:30 +0200 Subject: [PATCH 1174/1305] [EventDispatcher] don't count empty listeners When event listeners for certain events are removed from the event dispatcher, empty arrays are not being removed. Therefore, counting on empty arrays leads to wrong results of the hasListeners() method. --- .../EventDispatcher/EventDispatcher.php | 2 +- .../Tests/EventDispatcherTest.php | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/EventDispatcher/EventDispatcher.php b/src/Symfony/Component/EventDispatcher/EventDispatcher.php index 6d2f683a7d172..e189a57e42bfb 100644 --- a/src/Symfony/Component/EventDispatcher/EventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/EventDispatcher.php @@ -74,7 +74,7 @@ public function getListeners($eventName = null) } } - return $this->sorted; + return array_filter($this->sorted); } /** diff --git a/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php index f1053cfe1d89d..1053c290ee694 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php @@ -23,6 +23,9 @@ class EventDispatcherTest extends \PHPUnit_Framework_TestCase const preBar = 'pre.bar'; const postBar = 'post.bar'; + /** + * @var \Symfony\Component\EventDispatcher\EventDispatcher + */ private $dispatcher; private $listener; @@ -261,6 +264,28 @@ public function testWorkaroundForPhpBug62976() $dispatcher->removeListener('bug.62976', function () {}); $this->assertTrue($dispatcher->hasListeners('bug.62976')); } + + public function testHasListenersWhenAddedCallbackListenerIsRemoved() + { + $listener = function () {}; + $this->dispatcher->addListener('foo', $listener); + $this->dispatcher->removeListener('foo', $listener); + $this->assertFalse($this->dispatcher->hasListeners()); + } + + public function testGetListenersWhenAddedCallbackListenerIsRemoved() + { + $listener = function () {}; + $this->dispatcher->addListener('foo', $listener); + $this->dispatcher->removeListener('foo', $listener); + $this->assertSame(array(), $this->dispatcher->getListeners()); + } + + public function testHasListenersWithoutEventsReturnsFalseAfterHasListenersWithEventHasBeenCalled() + { + $this->assertFalse($this->dispatcher->hasListeners('foo')); + $this->assertFalse($this->dispatcher->hasListeners()); + } } class CallableClass From be04c5000c1bc7865530228a25b4c57276b550b5 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sat, 26 Jul 2014 11:54:23 +0200 Subject: [PATCH 1175/1305] Unify null comparisons --- .../Doctrine/ContainerAwareEventManager.php | 2 +- .../DependencyInjection/Configuration.php | 2 +- .../views/Form/choice_widget_collapsed.html.php | 2 +- .../Bundle/FrameworkBundle/Test/WebTestCase.php | 4 ++-- .../Resources/views/Collector/time.html.twig | 2 +- .../Resources/views/Profiler/layout.html.twig | 16 ++++++++-------- .../Tests/Definition/Builder/ExprBuilderTest.php | 2 +- .../Finder/Tests/Iterator/MockSplFileInfo.php | 6 +++--- .../ViolationMapper/ViolationPathTest.php | 2 +- .../RememberMe/AbstractRememberMeServices.php | 2 +- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php b/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php index ac21ece6e0a98..5f6902d4a4b39 100644 --- a/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php +++ b/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php @@ -49,7 +49,7 @@ public function __construct(ContainerInterface $container) public function dispatchEvent($eventName, EventArgs $eventArgs = null) { if (isset($this->listeners[$eventName])) { - $eventArgs = $eventArgs === null ? EventArgs::getEmptyInstance() : $eventArgs; + $eventArgs = null === $eventArgs ? EventArgs::getEmptyInstance() : $eventArgs; $initialized = isset($this->initialized[$eventName]); diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 852f8ba4246c4..fc6a6ade56d37 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -41,7 +41,7 @@ public function getConfigTreeBuilder() ->end() ->arrayNode('trusted_proxies') ->beforeNormalization() - ->ifTrue(function ($v) { return !is_array($v) && !is_null($v); }) + ->ifTrue(function ($v) { return !is_array($v) && null !== $v; }) ->then(function ($v) { return is_bool($v) ? array() : preg_split('/\s*,\s*/', $v); }) ->end() ->prototype('scalar') diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_collapsed.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_collapsed.html.php index 345be23b03f93..be78e46e8cc66 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_collapsed.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_collapsed.html.php @@ -1,5 +1,5 @@ {% if empty_value is not none -%} From 39973de230a210410dbc86b40a89c089015c0a18 Mon Sep 17 00:00:00 2001 From: Walther Lalk Date: Wed, 30 Jul 2014 13:48:48 +0200 Subject: [PATCH 1201/1305] [BrowserKit] Fix browser kit redirect with ports --- src/Symfony/Component/BrowserKit/Client.php | 2 +- src/Symfony/Component/BrowserKit/Tests/ClientTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/BrowserKit/Client.php b/src/Symfony/Component/BrowserKit/Client.php index 6e91305a74d78..08979f65a3b14 100644 --- a/src/Symfony/Component/BrowserKit/Client.php +++ b/src/Symfony/Component/BrowserKit/Client.php @@ -607,7 +607,7 @@ protected function requestFromRequest(Request $request, $changeHistory = true) private function updateServerFromUri($server, $uri) { - $server['HTTP_HOST'] = parse_url($uri, PHP_URL_HOST); + $server['HTTP_HOST'] = $this->extractHost($uri); $scheme = parse_url($uri, PHP_URL_SCHEME); $server['HTTPS'] = null === $scheme ? $server['HTTPS'] : 'https' == $scheme; unset($server['HTTP_IF_NONE_MATCH'], $server['HTTP_IF_MODIFIED_SINCE']); diff --git a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php index cd37fcf76ae1f..97205bf91153e 100644 --- a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php @@ -484,11 +484,11 @@ public function testFollowRedirectWithPort() $headers = array( 'HTTP_HOST' => 'www.example.com:8080', 'HTTP_USER_AGENT' => 'Symfony2 BrowserKit', - 'HTTPS' => false + 'HTTPS' => false, + 'HTTP_REFERER' => 'http://www.example.com:8080/' ); $client = new TestClient(); - $client->followRedirects(false); $client->setNextResponse(new Response('', 302, array( 'Location' => 'http://www.example.com:8080/redirected', ))); From 5ecc4498987649a0539593217172be108ca6c447 Mon Sep 17 00:00:00 2001 From: Peter Kruithof Date: Mon, 28 Jul 2014 16:33:49 +0200 Subject: [PATCH 1202/1305] Fixed relative redirects for ambiguous paths --- src/Symfony/Component/BrowserKit/Client.php | 2 +- .../Component/BrowserKit/Tests/ClientTest.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/BrowserKit/Client.php b/src/Symfony/Component/BrowserKit/Client.php index 08979f65a3b14..898c9342960ab 100644 --- a/src/Symfony/Component/BrowserKit/Client.php +++ b/src/Symfony/Component/BrowserKit/Client.php @@ -303,7 +303,7 @@ public function request($method, $uri, array $parameters = array(), array $files $uri = $this->getAbsoluteUri($uri); - if (isset($server['HTTP_HOST'])) { + if (!empty($server['HTTP_HOST'])) { $uri = preg_replace('{^(https?\://)'.preg_quote($this->extractHost($uri)).'}', '${1}'.$server['HTTP_HOST'], $uri); } diff --git a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php index 97205bf91153e..39015d2cc5604 100644 --- a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php @@ -399,6 +399,19 @@ public function testFollowRedirect() } } + public function testFollowRelativeRedirect() + { + $client = new TestClient(); + $client->setNextResponse(new Response('', 302, array('Location' => '/redirected'))); + $client->request('GET', 'http://www.example.com/foo/foobar'); + $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); + + $client = new TestClient(); + $client->setNextResponse(new Response('', 302, array('Location' => '/redirected:1234'))); + $client->request('GET', 'http://www.example.com/foo/foobar'); + $this->assertEquals('http://www.example.com/redirected:1234', $client->getRequest()->getUri(), '->followRedirect() follows relative urls'); + } + public function testFollowRedirectWithMaxRedirects() { $client = new TestClient(); From 6dd3946a7e7433a1712199cec6243fe9366504b7 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Tue, 5 Aug 2014 11:52:34 +0200 Subject: [PATCH 1203/1305] [Process] Added process synchronization to the incremental output tests The tests currently fail from time to time if the executing machine is under heavy load. This leads to false negatives on Travis CI. A side effect of the change is that the tests are much faster now. --- .../Process/Tests/AbstractProcessTest.php | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index 25de48eb1407a..779fb5cca0bba 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -259,18 +259,28 @@ public function testGetErrorOutput() public function testGetIncrementalErrorOutput() { - $p = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { usleep(100000); file_put_contents(\'php://stderr\', \'ERROR\'); $n++; }'))); + // use a lock file to toggle between writing ("W") and reading ("R") the + // error stream + $lock = tempnam(sys_get_temp_dir(), get_class($this).'Lock'); + file_put_contents($lock, 'W'); + + $p = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { if (\'W\' === file_get_contents('.var_export($lock, true).')) { file_put_contents(\'php://stderr\', \'ERROR\'); $n++; file_put_contents('.var_export($lock, true).', \'R\'); } usleep(100); }'))); $p->start(); while ($p->isRunning()) { - $this->assertLessThanOrEqual(1, preg_match_all('/ERROR/', $p->getIncrementalErrorOutput(), $matches)); - usleep(20000); + if ('R' === file_get_contents($lock)) { + $this->assertLessThanOrEqual(1, preg_match_all('/ERROR/', $p->getIncrementalErrorOutput(), $matches)); + file_put_contents($lock, 'W'); + } + usleep(100); } + + unlink($lock); } public function testGetOutput() { - $p = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n=0;while ($n<3) {echo \' foo \';$n++; usleep(500); }'))); + $p = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { echo \' foo \'; $n++; }'))); $p->run(); $this->assertEquals(3, preg_match_all('/foo/', $p->getOutput(), $matches)); @@ -278,13 +288,23 @@ public function testGetOutput() public function testGetIncrementalOutput() { - $p = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n=0;while ($n<3) { echo \' foo \'; usleep(50000); $n++; }'))); + // use a lock file to toggle between writing ("W") and reading ("R") the + // output stream + $lock = tempnam(sys_get_temp_dir(), get_class($this).'Lock'); + file_put_contents($lock, 'W'); + + $p = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n = 0; while ($n < 3) { if (\'W\' === file_get_contents('.var_export($lock, true).')) { echo \' foo \'; $n++; file_put_contents('.var_export($lock, true).', \'R\'); } usleep(100); }'))); $p->start(); while ($p->isRunning()) { - $this->assertLessThanOrEqual(1, preg_match_all('/foo/', $p->getIncrementalOutput(), $matches)); - usleep(20000); + if ('R' === file_get_contents($lock)) { + $this->assertLessThanOrEqual(1, preg_match_all('/foo/', $p->getIncrementalOutput(), $matches)); + file_put_contents($lock, 'W'); + } + usleep(100); } + + unlink($lock); } public function testZeroAsOutput() From e77022ba6d15817f44f8cdb37b2e3e57dce79e37 Mon Sep 17 00:00:00 2001 From: "Issei.M" Date: Wed, 6 Aug 2014 12:51:22 +0900 Subject: [PATCH 1204/1305] [Form] allowed CallbackTransformer to use callable --- .../Component/Form/CallbackTransformer.php | 21 ++++++++--- .../Form/Tests/CallbackTransformerTest.php | 37 +++++++++++++++++++ 2 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 src/Symfony/Component/Form/Tests/CallbackTransformerTest.php diff --git a/src/Symfony/Component/Form/CallbackTransformer.php b/src/Symfony/Component/Form/CallbackTransformer.php index c53c6df78846c..03459d4e8a089 100644 --- a/src/Symfony/Component/Form/CallbackTransformer.php +++ b/src/Symfony/Component/Form/CallbackTransformer.php @@ -18,24 +18,33 @@ class CallbackTransformer implements DataTransformerInterface { /** * The callback used for forward transform - * @var \Closure + * @var callable */ private $transform; /** * The callback used for reverse transform - * @var \Closure + * @var callable */ private $reverseTransform; /** * Constructor. * - * @param \Closure $transform The forward transform callback - * @param \Closure $reverseTransform The reverse transform callback + * @param callable $transform The forward transform callback + * @param callable $reverseTransform The reverse transform callback + * + * @throws \InvalidArgumentException when the given callbacks is invalid */ - public function __construct(\Closure $transform, \Closure $reverseTransform) + public function __construct($transform, $reverseTransform) { + if (!is_callable($transform)) { + throw new \InvalidArgumentException('Argument 1 should be a callable'); + } + if (!is_callable($reverseTransform)) { + throw new \InvalidArgumentException('Argument 2 should be a callable'); + } + $this->transform = $transform; $this->reverseTransform = $reverseTransform; } @@ -47,7 +56,7 @@ public function __construct(\Closure $transform, \Closure $reverseTransform) * * @return mixed The value in the transformed representation * - * @throws UnexpectedTypeException when the argument is not a string + * @throws UnexpectedTypeException when the argument is not of the expected type * @throws TransformationFailedException when the transformation fails */ public function transform($data) diff --git a/src/Symfony/Component/Form/Tests/CallbackTransformerTest.php b/src/Symfony/Component/Form/Tests/CallbackTransformerTest.php new file mode 100644 index 0000000000000..706bc076ec2cb --- /dev/null +++ b/src/Symfony/Component/Form/Tests/CallbackTransformerTest.php @@ -0,0 +1,37 @@ +assertEquals('foo has been transformed', $transformer->transform('foo')); + $this->assertEquals('bar has reversely been transformed', $transformer->reverseTransform('bar')); + } + + /** + * @dataProvider invalidCallbacksProvider + * + * @expectedException \InvalidArgumentException + */ + public function testConstructorWithInvalidCallbacks($transformCallback, $reverseTransformCallback) + { + new CallbackTransformer($transformCallback, $reverseTransformCallback); + } + + public function invalidCallbacksProvider() + { + return array( + array( null, function(){} ), + array( function(){}, null ), + ); + } +} From 4fa9288fda838482a9fe8d594f9cfda5c1e7591e Mon Sep 17 00:00:00 2001 From: Gordon Franke Date: Thu, 7 Aug 2014 09:01:16 +0200 Subject: [PATCH 1205/1305] fix shell command injection --- src/Symfony/Component/Finder/Shell/Shell.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Symfony/Component/Finder/Shell/Shell.php b/src/Symfony/Component/Finder/Shell/Shell.php index 8586cbc3e5715..f65f16d372da7 100644 --- a/src/Symfony/Component/Finder/Shell/Shell.php +++ b/src/Symfony/Component/Finder/Shell/Shell.php @@ -59,6 +59,8 @@ public function testCommand($command) return false; } + $command = escapeshellcmd($command); + // todo: find a better way (command could not be available) exec('command -v '.$command, $output, $code); From 85e77b14f7a0c2c0e8ada500421b7a1bcf6f1836 Mon Sep 17 00:00:00 2001 From: Gordon Franke Date: Thu, 7 Aug 2014 09:02:32 +0200 Subject: [PATCH 1206/1305] add way to test command under windows --- src/Symfony/Component/Finder/Shell/Shell.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Finder/Shell/Shell.php b/src/Symfony/Component/Finder/Shell/Shell.php index f65f16d372da7..7c57e7b7f9fe3 100644 --- a/src/Symfony/Component/Finder/Shell/Shell.php +++ b/src/Symfony/Component/Finder/Shell/Shell.php @@ -50,19 +50,19 @@ public function getType() */ public function testCommand($command) { - if (self::TYPE_WINDOWS === $this->type) { - // todo: find a way to test if Windows command exists + if (!function_exists('exec')) { return false; } - if (!function_exists('exec')) { - return false; + // todo: find a better way (command could not be available) + $testCommand = 'command -v '; + if (self::TYPE_WINDOWS === $this->type) { + $testCommand = 'where '; } $command = escapeshellcmd($command); - // todo: find a better way (command could not be available) - exec('command -v '.$command, $output, $code); + exec($testCommand . $command, $output, $code); return 0 === $code && count($output) > 0; } From c70a2261210ab6f2d17a6582842e9f22f6360f3b Mon Sep 17 00:00:00 2001 From: Gordon Franke Date: Thu, 7 Aug 2014 13:29:58 +0200 Subject: [PATCH 1207/1305] change command to which available under most unix systems agree i will change it which is available under suse, ubuntu, debian, fedora, bsd --- src/Symfony/Component/Finder/Shell/Shell.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Finder/Shell/Shell.php b/src/Symfony/Component/Finder/Shell/Shell.php index 7c57e7b7f9fe3..d17f2fac35d04 100644 --- a/src/Symfony/Component/Finder/Shell/Shell.php +++ b/src/Symfony/Component/Finder/Shell/Shell.php @@ -55,14 +55,14 @@ public function testCommand($command) } // todo: find a better way (command could not be available) - $testCommand = 'command -v '; + $testCommand = 'which '; if (self::TYPE_WINDOWS === $this->type) { $testCommand = 'where '; } $command = escapeshellcmd($command); - exec($testCommand . $command, $output, $code); + exec($testCommand.$command, $output, $code); return 0 === $code && count($output) > 0; } From 88149209aec51c0dab633d250e70c0708213acf5 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 7 Aug 2014 17:53:10 +0200 Subject: [PATCH 1208/1305] [Console] fixed style creation when providing an unknown tag option --- src/Symfony/Component/Console/Formatter/OutputFormatter.php | 6 +++++- .../Console/Tests/Formatter/OutputFormatterTest.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatter.php b/src/Symfony/Component/Console/Formatter/OutputFormatter.php index ca5f28731e33a..3813b542d45dc 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatter.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatter.php @@ -215,7 +215,11 @@ private function createStyleFromString($string) } elseif ('bg' == $match[0]) { $style->setBackground($match[1]); } else { - $style->setOption($match[1]); + try { + $style->setOption($match[1]); + } catch (\InvalidArgumentException $e) { + return false; + } } } diff --git a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php index c8f0b987afd14..bdaf36caef9ce 100644 --- a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php +++ b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php @@ -151,7 +151,7 @@ public function testNonStyleTag() { $formatter = new OutputFormatter(true); - $this->assertEquals("\033[32msome \033[0m\033[32m\033[0m\033[32m styled \033[0m\033[32m

    \033[0m\033[32msingle-char tag\033[0m\033[32m

    \033[0m", $formatter->format('some styled

    single-char tag

    ')); + $this->assertEquals("\033[32msome \033[0m\033[32m\033[0m\033[32m \033[0m\033[32m\033[0m\033[32m styled \033[0m\033[32m

    \033[0m\033[32msingle-char tag\033[0m\033[32m

    \033[0m", $formatter->format('some styled

    single-char tag

    ')); } public function testFormatLongString() From 24fb66ddf386f247fc47234dacb74ec0d03e35b5 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 7 Aug 2014 16:04:04 +0200 Subject: [PATCH 1209/1305] remove volatile tests Some tests relying on timings and external network resources were not reliable and occasionally made builds on Travis fail. --- .../Component/Finder/Tests/FinderTest.php | 21 ------------------- .../Stopwatch/Tests/StopwatchEventTest.php | 19 ----------------- .../Stopwatch/Tests/StopwatchTest.php | 13 ------------ 3 files changed, 53 deletions(-) diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index 9f9e47b6469af..da593a7a71799 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -820,25 +820,4 @@ public function testMultipleLocationsWithSubDirectories() $this->assertIterator($expected, $finder); $this->assertIteratorInForeach($expected, $finder); } - - public function testNonSeekableStream() - { - if (!in_array('ftp', stream_get_wrappers())) { - $this->markTestSkipped(sprintf('Unavailable stream "%s".', 'ftp')); - } - - try { - $i = Finder::create()->in('ftp://ftp.mozilla.org/')->depth(0)->getIterator(); - } catch (\UnexpectedValueException $e) { - $this->markTestSkipped(sprintf('Unsupported stream "%s".', 'ftp')); - } - - $contains = array( - 'ftp://ftp.mozilla.org'.DIRECTORY_SEPARATOR.'README', - 'ftp://ftp.mozilla.org'.DIRECTORY_SEPARATOR.'index.html', - 'ftp://ftp.mozilla.org'.DIRECTORY_SEPARATOR.'pub', - ); - - $this->assertIteratorInForeach($contains, $i); - } } diff --git a/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php b/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php index af63153382af5..825520850af27 100644 --- a/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php +++ b/src/Symfony/Component/Stopwatch/Tests/StopwatchEventTest.php @@ -133,25 +133,6 @@ public function testStartTime() $this->assertEquals(0, $event->getStartTime(), null, self::DELTA); } - public function testEndTime() - { - $event = new StopwatchEvent(microtime(true) * 1000); - $this->assertEquals(0, $event->getEndTime()); - - $event = new StopwatchEvent(microtime(true) * 1000); - $event->start(); - $this->assertEquals(0, $event->getEndTime()); - - $event = new StopwatchEvent(microtime(true) * 1000); - $event->start(); - usleep(100000); - $event->stop(); - $event->start(); - usleep(100000); - $event->stop(); - $this->assertEquals(200, $event->getEndTime(), null, self::DELTA); - } - /** * @expectedException \InvalidArgumentException */ diff --git a/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php b/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php index a8c11424fa917..6805effb48925 100644 --- a/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php +++ b/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php @@ -79,19 +79,6 @@ public function testStop() $this->assertEquals(200, $event->getDuration(), null, self::DELTA); } - public function testLap() - { - $stopwatch = new Stopwatch(); - $stopwatch->start('foo', 'cat'); - usleep(100000); - $event = $stopwatch->lap('foo'); - usleep(100000); - $stopwatch->stop('foo'); - - $this->assertInstanceof('Symfony\Component\Stopwatch\StopwatchEvent', $event); - $this->assertEquals(200, $event->getDuration(), null, self::DELTA); - } - /** * @expectedException \LogicException */ From f5bc18d6483202f2405787db997e1a494c427220 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 8 Aug 2014 10:52:31 +0200 Subject: [PATCH 1210/1305] return empty metadata collection if none do exist The PropertyMetadataContainerInterface defines that the method getPropertyMetadata() has to return an empty collection if no metadata have been configured for the given property. Though, its implementation in the ClassMetadata class didn't check for existence of such metadata. This behavior led to unexpected PHP notices when validating a property or a property value of a property without any configured constraints (only affects the new 2.5 API). Additionally, the getMemberMetadatas() didn't check for existing array keys as well which has also been fixed. --- .../Validator/Mapping/ClassMetadata.php | 8 ++++++++ .../Tests/Mapping/ClassMetadataTest.php | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php index 553d7806ad6a2..792d8e51409f3 100644 --- a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php @@ -298,6 +298,10 @@ public function hasMemberMetadatas($property) */ public function getMemberMetadatas($property) { + if (!isset($this->members[$property])) { + return array(); + } + return $this->members[$property]; } @@ -314,6 +318,10 @@ public function hasPropertyMetadata($property) */ public function getPropertyMetadata($property) { + if (!isset($this->members[$property])) { + return array(); + } + return $this->members[$property]; } diff --git a/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php b/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php index 9ead7d134eb60..08ae9600cea24 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php @@ -222,4 +222,20 @@ public function testGroupSequenceProvider() $metadata->setGroupSequenceProvider(true); $this->assertTrue($metadata->isGroupSequenceProvider()); } + + /** + * https://github.com/symfony/symfony/issues/11604 + */ + public function testGetMemberMetadatasReturnsEmptyArrayWithoutConfiguredMetadata() + { + $this->assertCount(0, $this->metadata->getMemberMetadatas('foo'), '->getMemberMetadatas() returns an empty collection if no metadata is configured for the given property'); + } + + /** + * https://github.com/symfony/symfony/issues/11604 + */ + public function testGetPropertyMetadataReturnsEmptyArrayWithoutConfiguredMetadata() + { + $this->assertCount(0, $this->metadata->getPropertyMetadata('foo'), '->getPropertyMetadata() returns an empty collection if no metadata is configured for the given property'); + } } From 696b978742ea2de1adc1a6f7846228c66ca8817c Mon Sep 17 00:00:00 2001 From: Morgan Auchede Date: Fri, 8 Aug 2014 13:32:47 +0200 Subject: [PATCH 1211/1305] [HttpKernel] added an analyze of environment parameters for built-in server. --- .../Bundle/FrameworkBundle/Resources/config/router_dev.php | 1 + .../Bundle/FrameworkBundle/Resources/config/router_prod.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/router_dev.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/router_dev.php index 64c90b4bd20c4..9e70bf7acd47e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/router_dev.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/router_dev.php @@ -25,6 +25,7 @@ return false; } +$_SERVER = array_merge($_SERVER, $_ENV); $_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'app_dev.php'; require 'app_dev.php'; diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/router_prod.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/router_prod.php index 4278b4bba15be..a3ef29d8db954 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/router_prod.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/router_prod.php @@ -25,6 +25,7 @@ return false; } +$_SERVER = array_merge($_SERVER, $_ENV); $_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'app.php'; require 'app.php'; From d26040f356f91927294fc2682ac1d41cd3b8ffc0 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 8 Aug 2014 00:47:19 +0200 Subject: [PATCH 1212/1305] [DomCrawler] fix the axes handling in a bc way The previous fix in #11548 for handling XPath axes was not backward compatible. In previous Symfony versions the Crawler handled nodes by holding a "fake root node". This must be taken into account when evaluating (relativizing) XPath expressions. --- src/Symfony/Component/DomCrawler/Crawler.php | 25 +++++--- .../DomCrawler/Tests/CrawlerTest.php | 59 +++++++++++++++---- 2 files changed, 63 insertions(+), 21 deletions(-) diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 5dd4dba3cd304..50f00c1ff7b7a 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -245,7 +245,9 @@ public function addDocument(\DOMDocument $dom) public function addNodeList(\DOMNodeList $nodes) { foreach ($nodes as $node) { - $this->addNode($node); + if ($node instanceof \DOMNode) { + $this->addNode($node); + } } } @@ -834,18 +836,22 @@ private function relativize($xpath) // BC for Symfony 2.4 and lower were elements were adding in a fake _root parent if (0 === strpos($expression, '/_root/')) { $expression = './'.substr($expression, 7); + } elseif (0 === strpos($expression, 'self::*/')) { + $expression = './'.substr($expression, 8); } // add prefix before absolute element selector if (empty($expression)) { $expression = $nonMatchingExpression; } elseif (0 === strpos($expression, '//')) { - $expression = 'descendant-or-self::' . substr($expression, 2); + $expression = 'descendant-or-self::'.substr($expression, 2); } elseif (0 === strpos($expression, './/')) { - $expression = 'descendant-or-self::' . substr($expression, 3); + $expression = 'descendant-or-self::'.substr($expression, 3); } elseif (0 === strpos($expression, './')) { - $expression = 'self::' . substr($expression, 2); - } elseif ('/' === $expression[0]) { + $expression = 'self::'.substr($expression, 2); + } elseif (0 === strpos($expression, 'child::')) { + $expression = 'self::'.substr($expression, 7); + } elseif ('/' === $expression[0] || 0 === strpos($expression, 'self::')) { // the only direct child in Symfony 2.4 and lower is _root, which is already handled previously // so let's drop the expression entirely $expression = $nonMatchingExpression; @@ -853,9 +859,12 @@ private function relativize($xpath) // '.' is the fake root element in Symfony 2.4 and lower, which is excluded from results $expression = $nonMatchingExpression; } elseif (0 === strpos($expression, 'descendant::')) { - $expression = 'descendant-or-self::' . substr($expression, strlen('descendant::')); - } elseif (!preg_match('/^(ancestor|ancestor-or-self|attribute|child|descendant-or-self|following|following-sibling|parent|preceding|preceding-sibling|self)::/', $expression)) { - $expression = 'self::' .$expression; + $expression = 'descendant-or-self::'.substr($expression, strlen('descendant::')); + } elseif (preg_match('/^(ancestor|ancestor-or-self|attribute|following|following-sibling|namespace|parent|preceding|preceding-sibling)::/', $expression)) { + // the fake root has no parent, preceding or following nodes and also no attributes (even no namespace attributes) + $expression = $nonMatchingExpression; + } elseif (0 !== strpos($expression, 'descendant-or-self::')) { + $expression = 'self::'.$expression; } $expressions[] = $parenthesis.$expression; } diff --git a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php index 4c9a4bcecff14..4d4c5ac2a157a 100644 --- a/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php @@ -388,8 +388,8 @@ public function testFilterXpathComplexQueries() $this->assertCount(1, $crawler->filterXPath('//body')); $this->assertCount(1, $crawler->filterXPath('descendant-or-self::body')); $this->assertCount(1, $crawler->filterXPath('//div[@id="parent"]')->filterXPath('./div'), 'A child selection finds only the current div'); - $this->assertCount(2, $crawler->filterXPath('//div[@id="parent"]')->filterXPath('descendant::div'), 'A descendant selector matches the current div and its child'); - $this->assertCount(2, $crawler->filterXPath('//div[@id="parent"]')->filterXPath('//div'), 'A descendant selector matches the current div and its child'); + $this->assertCount(3, $crawler->filterXPath('//div[@id="parent"]')->filterXPath('descendant::div'), 'A descendant selector matches the current div and its child'); + $this->assertCount(3, $crawler->filterXPath('//div[@id="parent"]')->filterXPath('//div'), 'A descendant selector matches the current div and its child'); $this->assertCount(5, $crawler->filterXPath('(//a | //div)//img')); $this->assertCount(7, $crawler->filterXPath('((//a | //div)//img | //ul)')); $this->assertCount(7, $crawler->filterXPath('( ( //a | //div )//img | //ul )')); @@ -411,72 +411,104 @@ public function testFilterXPath() $this->assertCount(3, $crawler->filterXPath('//body')->filterXPath('//button')->parents(), '->filterXpath() preserves parents when chained'); } + public function testFilterXPathWithFakeRoot() + { + $crawler = $this->createTestCrawler(); + $this->assertCount(0, $crawler->filterXPath('.'), '->filterXPath() returns an empty result if the XPath references the fake root node'); + $this->assertCount(0, $crawler->filterXPath('/_root'), '->filterXPath() returns an empty result if the XPath references the fake root node'); + $this->assertCount(0, $crawler->filterXPath('self::*'), '->filterXPath() returns an empty result if the XPath references the fake root node'); + $this->assertCount(0, $crawler->filterXPath('self::_root'), '->filterXPath() returns an empty result if the XPath references the fake root node'); + } + public function testFilterXPathWithAncestorAxis() { $crawler = $this->createTestCrawler()->filterXPath('//form'); - $this->assertCount(2, $crawler->filterXPath('ancestor::*')); + $this->assertCount(0, $crawler->filterXPath('ancestor::*'), 'The fake root node has no ancestor nodes'); } public function testFilterXPathWithAncestorOrSelfAxis() { $crawler = $this->createTestCrawler()->filterXPath('//form'); - $this->assertCount(3, $crawler->filterXPath('ancestor-or-self::*')); + $this->assertCount(0, $crawler->filterXPath('ancestor-or-self::*'), 'The fake root node has no ancestor nodes'); } public function testFilterXPathWithAttributeAxis() { $crawler = $this->createTestCrawler()->filterXPath('//form'); - $this->assertCount(2, $crawler->filterXPath('attribute::*')); + $this->assertCount(0, $crawler->filterXPath('attribute::*'), 'The fake root node has no attribute nodes'); + } + + public function testFilterXPathWithAttributeAxisAfterElementAxis() + { + $this->assertCount(3, $this->createTestCrawler()->filterXPath('//form/button/attribute::*'), '->filterXPath() handles attribute axes properly when they are preceded by an element filtering axis'); } public function testFilterXPathWithChildAxis() { - $crawler = $this->createTestCrawler()->filterXPath('//body'); + $crawler = $this->createTestCrawler()->filterXPath('//div[@id="parent"]'); - $this->assertCount(2, $crawler->filterXPath('child::input')); + $this->assertCount(1, $crawler->filterXPath('child::div'), 'A child selection finds only the current div'); } public function testFilterXPathWithFollowingAxis() { $crawler = $this->createTestCrawler()->filterXPath('//a'); - $this->assertCount(3, $crawler->filterXPath('following::div')); + $this->assertCount(0, $crawler->filterXPath('following::div'), 'The fake root node has no following nodes'); } public function testFilterXPathWithFollowingSiblingAxis() { $crawler = $this->createTestCrawler()->filterXPath('//a'); - $this->assertCount(2, $crawler->filterXPath('following-sibling::div')); + $this->assertCount(0, $crawler->filterXPath('following-sibling::div'), 'The fake root node has no following nodes'); + } + + public function testFilterXPathWithNamespaceAxis() + { + $crawler = $this->createTestCrawler()->filterXPath('//button'); + + $this->assertCount(0, $crawler->filterXPath('namespace::*'), 'The fake root node has no namespace nodes'); + } + + public function testFilterXPathWithNamespaceAxisAfterElementAxis() + { + $crawler = $this->createTestCrawler()->filterXPath('//div[@id="parent"]/namespace::*'); + + $this->assertCount(0, $crawler->filterXPath('namespace::*'), 'Namespace axes cannot be requested'); } public function testFilterXPathWithParentAxis() { $crawler = $this->createTestCrawler()->filterXPath('//button'); - $this->assertEquals('foo', $crawler->filterXPath('parent::*')->attr('action')); + $this->assertCount(0, $crawler->filterXPath('parent::*'), 'The fake root node has no parent nodes'); } public function testFilterXPathWithPrecedingAxis() { $crawler = $this->createTestCrawler()->filterXPath('//form'); - $this->assertCount(13, $crawler->filterXPath('preceding::*')); + $this->assertCount(0, $crawler->filterXPath('preceding::*'), 'The fake root node has no preceding nodes'); } public function testFilterXPathWithPrecedingSiblingAxis() { $crawler = $this->createTestCrawler()->filterXPath('//form'); - $this->assertCount(9, $crawler->filterXPath('preceding-sibling::*')); + $this->assertCount(0, $crawler->filterXPath('preceding-sibling::*'), 'The fake root node has no preceding nodes'); } public function testFilterXPathWithSelfAxes() { - $this->assertCount(1, $this->createTestCrawler()->filterXPath('self::*')); + $crawler = $this->createTestCrawler()->filterXPath('//a'); + + $this->assertCount(0, $crawler->filterXPath('self::a'), 'The fake root node has no "real" element name'); + $this->assertCount(0, $crawler->filterXPath('self::a/img'), 'The fake root node has no "real" element name'); + $this->assertCount(9, $crawler->filterXPath('self::*/a')); } /** @@ -844,6 +876,7 @@ public function createTestCrawler($uri = null)
    +
    From be03b7552a515a914becbdee3a94f4d8acf33330 Mon Sep 17 00:00:00 2001 From: Pablo Godel Date: Thu, 7 Aug 2014 10:14:53 -0400 Subject: [PATCH 1213/1305] fix typos and syntax in Profiler controller method comments --- .../WebProfilerBundle/Controller/ProfilerController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php index a106feae990f7..8542f2865f666 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -310,7 +310,7 @@ public function searchBarAction(Request $request) } /** - * Search results. + * Renders the search results. * * @param Request $request The current HTTP Request * @param string $token The token @@ -351,7 +351,7 @@ public function searchResultsAction(Request $request, $token) } /** - * Narrow the search bar. + * Narrows the search bar. * * @param Request $request The current HTTP Request * From f1ea987f35432f2e343d7e7040ed1db7b42c3e13 Mon Sep 17 00:00:00 2001 From: Benjamin Laugueux Date: Thu, 7 Aug 2014 11:43:44 +0200 Subject: [PATCH 1214/1305] Allow basic auth in url. Improve regex. Add tests. --- .../Component/Validator/Constraints/UrlValidator.php | 1 + .../Validator/Tests/Constraints/UrlValidatorTest.php | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/Symfony/Component/Validator/Constraints/UrlValidator.php b/src/Symfony/Component/Validator/Constraints/UrlValidator.php index 748f824894a0b..1ba47ffd1d91b 100644 --- a/src/Symfony/Component/Validator/Constraints/UrlValidator.php +++ b/src/Symfony/Component/Validator/Constraints/UrlValidator.php @@ -24,6 +24,7 @@ class UrlValidator extends ConstraintValidator { const PATTERN = '~^ (%s):// # protocol + (([\pL\pN-]+:)?([\pL\pN-]+)@)? # basic auth ( ([\pL\pN\pS-\.])+(\.?([\pL]|xn\-\-[\pL\pN-]+)+\.?) # a domain name | # or diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php index ac2cf9e3608bf..4c95e5bbb0a42 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php @@ -116,6 +116,8 @@ public function getValidUrls() array('http://xn--espaa-rta.xn--ca-ol-fsay5a/'), array('http://xn--d1abbgf6aiiy.xn--p1ai/'), array('http://☎.com/'), + array('http://username:password@symfony.com'), + array('http://user-name@symfony.com'), ); } @@ -155,6 +157,10 @@ public function getInvalidUrls() array('ftp://[::1]/'), array('http://[::1'), array('http://hello.☎/'), + array('http://:password@symfony.com'), + array('http://:password@@symfony.com'), + array('http://username:passwordsymfony.com'), + array('http://usern@me:password@symfony.com'), ); } From 8a2b423b53322e66c65eae81ee6e49114ab452ab Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 10 Aug 2014 14:44:20 +0200 Subject: [PATCH 1215/1305] [FrameworkBundle] add missing attribute to XSD The hinclude_default_template configuration option couldn't have been set in XML configurations since it wasn't defined in the XML schema definition. --- .../FrameworkBundle/Resources/config/schema/symfony-1.0.xsd | 1 + .../Tests/DependencyInjection/Fixtures/php/full.php | 1 + .../Tests/DependencyInjection/Fixtures/xml/full.xml | 2 +- .../Tests/DependencyInjection/Fixtures/yml/full.yml | 1 + .../Tests/DependencyInjection/FrameworkExtensionTest.php | 1 + 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd index 4b235051f82d5..17b817c325303 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd @@ -105,6 +105,7 @@ + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php index c4eff9349228e..0bc94f2e73778 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php @@ -56,6 +56,7 @@ 'form' => array( 'resources' => array('theme1', 'theme2') ), + 'hinclude_default_template' => 'global_hinclude_template', ), 'translator' => array( 'enabled' => true, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml index 8fd3e9b6528a0..bfdaabc71f31f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml @@ -13,7 +13,7 @@ - + loader.foo loader.bar php 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 d013063916c38..0a159ddc34c2d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml @@ -44,6 +44,7 @@ framework: base_urls: ["http://images1.example.com", "http://images2.example.com"] form: resources: [theme1, theme2] + hinclude_default_template: global_hinclude_template translator: enabled: true fallback: fr diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 346962e2ac02f..f1adb72976e44 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -158,6 +158,7 @@ public function testTemplating() $this->assertEquals(array('php', 'twig'), $container->getParameter('templating.engines'), '->registerTemplatingConfiguration() sets a templating.engines parameter'); $this->assertEquals(array('FrameworkBundle:Form', 'theme1', 'theme2'), $container->getParameter('templating.helper.form.resources'), '->registerTemplatingConfiguration() registers the theme and adds the base theme'); + $this->assertEquals('global_hinclude_template', $container->getParameter('fragment.renderer.hinclude.global_template'), '->registerTemplatingConfiguration() registers the global hinclude.js template'); } public function testTemplatingAssetsHelperScopeDependsOnPackageArgumentScopes() From b56b7409409ddc96b08b39382042bd01e1614382 Mon Sep 17 00:00:00 2001 From: Chris Sedlmayr Date: Tue, 29 Jul 2014 14:36:07 +0100 Subject: [PATCH 1216/1305] [HttpFoundation] MongoDbSessionHandler supports auto expiry via configurable expiry_field --- .../Storage/Handler/MongoDbSessionHandler.php | 33 +++++++-- .../Handler/MongoDbSessionHandlerTest.php | 71 ++++++++++++++++++- 2 files changed, 94 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php index 87aa7fb4f77a9..b151c8e33d4e3 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php @@ -62,9 +62,10 @@ public function __construct($mongo, array $options) $this->mongo = $mongo; $this->options = array_merge(array( - 'id_field' => '_id', - 'data_field' => 'data', - 'time_field' => 'time', + 'id_field' => '_id', + 'data_field' => 'data', + 'time_field' => 'time', + 'expiry_field' => false, ), $options); } @@ -109,6 +110,9 @@ public function gc($maxlifetime) * * See: http://docs.mongodb.org/manual/tutorial/expire-data/ */ + if (false !== $this->options['expiry_field']) { + return true; + } $time = new \MongoDate(time() - $maxlifetime); $this->getCollection()->remove(array( @@ -123,12 +127,27 @@ public function gc($maxlifetime) */ public function write($sessionId, $data) { + $fields = array( + $this->options['data_field'] => new \MongoBinData($data, \MongoBinData::BYTE_ARRAY), + $this->options['time_field'] => new \MongoDate(), + ); + + /* Note: As discussed in the gc method of this class. You can utilise + * TTL collections in MongoDB 2.2+ + * We are setting the "expiry_field" as part of the write operation here + * You will need to create the index on your collection that expires documents + * at that time + * e.g. + * db.MySessionCollection.ensureIndex( { "expireAt": 1 }, { expireAfterSeconds: 0 } ) + */ + if (false !== $this->options['expiry_field']) { + $expiry = new \MongoDate(time() + (int) ini_get('session.gc_maxlifetime')); + $fields[$this->options['expiry_field']] = $expiry; + } + $this->getCollection()->update( array($this->options['id_field'] => $sessionId), - array('$set' => array( - $this->options['data_field'] => new \MongoBinData($data, \MongoBinData::BYTE_ARRAY), - $this->options['time_field'] => new \MongoDate(), - )), + array('$set' => $fields), array('upsert' => true, 'multiple' => false) ); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php index 9577d5247886a..19170bbbf02ec 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php @@ -41,7 +41,7 @@ protected function setUp() 'data_field' => 'data', 'time_field' => 'time', 'database' => 'sf2-test', - 'collection' => 'session-test' + 'collection' => 'session-test', ); $this->storage = new MongoDbSessionHandler($this->mongo, $this->options); @@ -100,6 +100,45 @@ public function testWrite() $that->assertInstanceOf('MongoDate', $data[$this->options['time_field']]); } + public function testWriteWhenUsingExpiresField() + { + $this->options = array( + 'id_field' => '_id', + 'data_field' => 'data', + 'time_field' => 'time', + 'database' => 'sf2-test', + 'collection' => 'session-test', + 'expiry_field' => 'expiresAt' + ); + + $this->storage = new MongoDbSessionHandler($this->mongo, $this->options); + + $collection = $this->createMongoCollectionMock(); + + $this->mongo->expects($this->once()) + ->method('selectCollection') + ->with($this->options['database'], $this->options['collection']) + ->will($this->returnValue($collection)); + + $that = $this; + $data = array(); + + $collection->expects($this->once()) + ->method('update') + ->will($this->returnCallback(function ($criteria, $updateData, $options) use ($that, &$data) { + $that->assertEquals(array($that->options['id_field'] => 'foo'), $criteria); + $that->assertEquals(array('upsert' => true, 'multiple' => false), $options); + + $data = $updateData['$set']; + })); + + $this->assertTrue($this->storage->write('foo', 'bar')); + + $this->assertEquals('bar', $data[$this->options['data_field']]->bin); + $that->assertInstanceOf('MongoDate', $data[$this->options['time_field']]); + $that->assertInstanceOf('MongoDate', $data[$this->options['expiry_field']]); + } + public function testReplaceSessionData() { $collection = $this->createMongoCollectionMock(); @@ -154,10 +193,36 @@ public function testGc() ->method('remove') ->will($this->returnCallback(function ($criteria) use ($that) { $that->assertInstanceOf('MongoDate', $criteria[$that->options['time_field']]['$lt']); - $that->assertGreaterThanOrEqual(time() - -1, $criteria[$that->options['time_field']]['$lt']->sec); + $that->assertGreaterThanOrEqual(time() - 1, $criteria[$that->options['time_field']]['$lt']->sec); })); - $this->assertTrue($this->storage->gc(-1)); + $this->assertTrue($this->storage->gc(1)); + } + + public function testGcWhenUsingExpiresField() + { + $this->options = array( + 'id_field' => '_id', + 'data_field' => 'data', + 'time_field' => 'time', + 'database' => 'sf2-test', + 'collection' => 'session-test', + 'expiry_field' => 'expiresAt' + ); + + $this->storage = new MongoDbSessionHandler($this->mongo, $this->options); + + $collection = $this->createMongoCollectionMock(); + + $this->mongo->expects($this->never()) + ->method('selectCollection'); + + $that = $this; + + $collection->expects($this->never()) + ->method('remove'); + + $this->assertTrue($this->storage->gc(1)); } private function createMongoCollectionMock() From 65220e77b431fdb7422b55e26b0d3b5dc924d659 Mon Sep 17 00:00:00 2001 From: Benjamin Laugueux Date: Mon, 11 Aug 2014 12:07:40 +0200 Subject: [PATCH 1217/1305] Fix toolbar vertical alignment. --- .../WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig index 8e780c3155a0d..85b30948ed41c 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig @@ -22,6 +22,7 @@ -webkit-box-sizing: content-box; -moz-box-sizing: content-box; box-sizing: content-box; + vertical-align: baseline; } .sf-toolbarreset { From fb120c7827a97d497f3690fd50be31e1052b85d0 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 14 Aug 2014 10:11:24 +0200 Subject: [PATCH 1218/1305] revert #11510, moved to 2.6 --- .../Storage/Handler/MongoDbSessionHandler.php | 33 ++------- .../Handler/MongoDbSessionHandlerTest.php | 71 +------------------ 2 files changed, 10 insertions(+), 94 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php index b151c8e33d4e3..87aa7fb4f77a9 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php @@ -62,10 +62,9 @@ public function __construct($mongo, array $options) $this->mongo = $mongo; $this->options = array_merge(array( - 'id_field' => '_id', - 'data_field' => 'data', - 'time_field' => 'time', - 'expiry_field' => false, + 'id_field' => '_id', + 'data_field' => 'data', + 'time_field' => 'time', ), $options); } @@ -110,9 +109,6 @@ public function gc($maxlifetime) * * See: http://docs.mongodb.org/manual/tutorial/expire-data/ */ - if (false !== $this->options['expiry_field']) { - return true; - } $time = new \MongoDate(time() - $maxlifetime); $this->getCollection()->remove(array( @@ -127,27 +123,12 @@ public function gc($maxlifetime) */ public function write($sessionId, $data) { - $fields = array( - $this->options['data_field'] => new \MongoBinData($data, \MongoBinData::BYTE_ARRAY), - $this->options['time_field'] => new \MongoDate(), - ); - - /* Note: As discussed in the gc method of this class. You can utilise - * TTL collections in MongoDB 2.2+ - * We are setting the "expiry_field" as part of the write operation here - * You will need to create the index on your collection that expires documents - * at that time - * e.g. - * db.MySessionCollection.ensureIndex( { "expireAt": 1 }, { expireAfterSeconds: 0 } ) - */ - if (false !== $this->options['expiry_field']) { - $expiry = new \MongoDate(time() + (int) ini_get('session.gc_maxlifetime')); - $fields[$this->options['expiry_field']] = $expiry; - } - $this->getCollection()->update( array($this->options['id_field'] => $sessionId), - array('$set' => $fields), + array('$set' => array( + $this->options['data_field'] => new \MongoBinData($data, \MongoBinData::BYTE_ARRAY), + $this->options['time_field'] => new \MongoDate(), + )), array('upsert' => true, 'multiple' => false) ); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php index 19170bbbf02ec..9577d5247886a 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php @@ -41,7 +41,7 @@ protected function setUp() 'data_field' => 'data', 'time_field' => 'time', 'database' => 'sf2-test', - 'collection' => 'session-test', + 'collection' => 'session-test' ); $this->storage = new MongoDbSessionHandler($this->mongo, $this->options); @@ -100,45 +100,6 @@ public function testWrite() $that->assertInstanceOf('MongoDate', $data[$this->options['time_field']]); } - public function testWriteWhenUsingExpiresField() - { - $this->options = array( - 'id_field' => '_id', - 'data_field' => 'data', - 'time_field' => 'time', - 'database' => 'sf2-test', - 'collection' => 'session-test', - 'expiry_field' => 'expiresAt' - ); - - $this->storage = new MongoDbSessionHandler($this->mongo, $this->options); - - $collection = $this->createMongoCollectionMock(); - - $this->mongo->expects($this->once()) - ->method('selectCollection') - ->with($this->options['database'], $this->options['collection']) - ->will($this->returnValue($collection)); - - $that = $this; - $data = array(); - - $collection->expects($this->once()) - ->method('update') - ->will($this->returnCallback(function ($criteria, $updateData, $options) use ($that, &$data) { - $that->assertEquals(array($that->options['id_field'] => 'foo'), $criteria); - $that->assertEquals(array('upsert' => true, 'multiple' => false), $options); - - $data = $updateData['$set']; - })); - - $this->assertTrue($this->storage->write('foo', 'bar')); - - $this->assertEquals('bar', $data[$this->options['data_field']]->bin); - $that->assertInstanceOf('MongoDate', $data[$this->options['time_field']]); - $that->assertInstanceOf('MongoDate', $data[$this->options['expiry_field']]); - } - public function testReplaceSessionData() { $collection = $this->createMongoCollectionMock(); @@ -193,36 +154,10 @@ public function testGc() ->method('remove') ->will($this->returnCallback(function ($criteria) use ($that) { $that->assertInstanceOf('MongoDate', $criteria[$that->options['time_field']]['$lt']); - $that->assertGreaterThanOrEqual(time() - 1, $criteria[$that->options['time_field']]['$lt']->sec); + $that->assertGreaterThanOrEqual(time() - -1, $criteria[$that->options['time_field']]['$lt']->sec); })); - $this->assertTrue($this->storage->gc(1)); - } - - public function testGcWhenUsingExpiresField() - { - $this->options = array( - 'id_field' => '_id', - 'data_field' => 'data', - 'time_field' => 'time', - 'database' => 'sf2-test', - 'collection' => 'session-test', - 'expiry_field' => 'expiresAt' - ); - - $this->storage = new MongoDbSessionHandler($this->mongo, $this->options); - - $collection = $this->createMongoCollectionMock(); - - $this->mongo->expects($this->never()) - ->method('selectCollection'); - - $that = $this; - - $collection->expects($this->never()) - ->method('remove'); - - $this->assertTrue($this->storage->gc(1)); + $this->assertTrue($this->storage->gc(-1)); } private function createMongoCollectionMock() From 000bd0d863e4eb68f72d422981379472977f9e83 Mon Sep 17 00:00:00 2001 From: Yosmany Garcia Date: Tue, 5 Aug 2014 20:01:06 -0400 Subject: [PATCH 1219/1305] Made optimization deprecating modulus operator --- .../Component/Security/Core/Util/StringUtils.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/Security/Core/Util/StringUtils.php b/src/Symfony/Component/Security/Core/Util/StringUtils.php index d47bd4bb37702..eaeed84779c26 100644 --- a/src/Symfony/Component/Security/Core/Util/StringUtils.php +++ b/src/Symfony/Component/Security/Core/Util/StringUtils.php @@ -35,23 +35,19 @@ private function __construct() {} */ public static function equals($knownString, $userInput) { - // Prevent issues if string length is 0 - $knownString .= chr(0); - $userInput .= chr(0); - $knownLen = strlen($knownString); $userLen = strlen($userInput); + // Extend know string to avoid uninitialized string offsets + $knownString .= $userInput; + // Set the result to the difference between the lengths $result = $knownLen - $userLen; // Note that we ALWAYS iterate over the user-supplied length // This is to prevent leaking length information for ($i = 0; $i < $userLen; $i++) { - // Using % here is a trick to prevent notices - // It's safe, since if the lengths are different - // $result is already non-0 - $result |= (ord($knownString[$i % $knownLen]) ^ ord($userInput[$i])); + $result |= (ord($knownString[$i]) ^ ord($userInput[$i])); } // They are only identical strings if $result is exactly 0... From 87a47eadc9967ac0f6a7abcc95c2e28dbda66e9d Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Fri, 8 Aug 2014 10:10:43 +0200 Subject: [PATCH 1220/1305] [Validator] Backported constraint validator tests from 2.5 --- .../Constraints/UniqueEntityValidatorTest.php | 414 +++++++++++++++++ .../Constraints/UniqueValidatorTest.php | 437 ------------------ .../Constraints/FormValidatorTest.php | 294 +++++------- .../Constraints/UserPasswordValidatorTest.php | 168 +++++++ .../Validator/Constraints/AllValidator.php | 4 +- .../Validator/Constraints/ChoiceValidator.php | 4 +- .../Constraints/CollectionValidator.php | 4 +- .../AbstractComparisonValidatorTestCase.php | 51 +- .../AbstractConstraintValidatorTest.php | 194 ++++++++ .../Tests/Constraints/AllValidatorTest.php | 57 +-- .../Tests/Constraints/BlankValidatorTest.php | 38 +- .../Constraints/CallbackValidatorTest.php | 156 ++++--- .../Constraints/CardSchemeValidatorTest.php | 44 +- .../Tests/Constraints/ChoiceValidatorTest.php | 146 +++--- .../Tests/Constraints/CollectionTest.php | 4 +- ...llectionValidatorCustomArrayObjectTest.php | 58 +-- .../Constraints/CollectionValidatorTest.php | 219 ++++----- .../CountValidatorCountableTest.php | 17 +- .../Tests/Constraints/CountValidatorTest.php | 71 +-- .../Constraints/CountryValidatorTest.php | 45 +- .../Constraints/CurrencyValidatorTest.php | 45 +- .../Constraints/DateTimeValidatorTest.php | 47 +- .../Tests/Constraints/DateValidatorTest.php | 47 +- .../Tests/Constraints/EmailValidatorTest.php | 43 +- .../Tests/Constraints/FalseValidatorTest.php | 35 +- .../Constraints/FileValidatorPathTest.php | 10 +- .../Tests/Constraints/FileValidatorTest.php | 243 ++++++---- .../Constraints/Fixtures/test_landscape.gif | Bin 0 -> 43 bytes .../Constraints/Fixtures/test_portrait.gif | Bin 0 -> 43 bytes .../Tests/Constraints/GroupSequenceTest.php | 27 ++ .../Tests/Constraints/IbanValidatorTest.php | 34 +- .../Tests/Constraints/ImageValidatorTest.php | 125 ++--- .../Tests/Constraints/IpValidatorTest.php | 165 +++---- .../Tests/Constraints/IsbnValidatorTest.php | 91 ++-- .../Tests/Constraints/IssnValidatorTest.php | 88 ++-- .../Constraints/LanguageValidatorTest.php | 50 +- .../Tests/Constraints/LengthValidatorTest.php | 79 ++-- .../Tests/Constraints/LocaleValidatorTest.php | 44 +- .../Tests/Constraints/LuhnValidatorTest.php | 45 +- .../Constraints/NotBlankValidatorTest.php | 55 +-- .../Constraints/NotNullValidatorTest.php | 30 +- .../Tests/Constraints/NullValidatorTest.php | 33 +- .../Tests/Constraints/RangeValidatorTest.php | 112 ++--- .../Tests/Constraints/RegexValidatorTest.php | 43 +- .../Tests/Constraints/TimeValidatorTest.php | 48 +- .../Tests/Constraints/TrueValidatorTest.php | 38 +- .../Tests/Constraints/TypeValidatorTest.php | 73 ++- .../Tests/Constraints/UrlValidatorTest.php | 52 +-- .../Validator/Tests/Fixtures/Countable.php | 27 ++ .../Tests/Fixtures/CustomArrayObject.php | 70 +++ .../Fixtures/StubGlobalExecutionContext.php | 69 +++ 51 files changed, 2134 insertions(+), 2159 deletions(-) create mode 100644 src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php delete mode 100644 src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueValidatorTest.php create mode 100644 src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php create mode 100644 src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php create mode 100644 src/Symfony/Component/Validator/Tests/Constraints/Fixtures/test_landscape.gif create mode 100644 src/Symfony/Component/Validator/Tests/Constraints/Fixtures/test_portrait.gif create mode 100644 src/Symfony/Component/Validator/Tests/Constraints/GroupSequenceTest.php create mode 100644 src/Symfony/Component/Validator/Tests/Fixtures/Countable.php create mode 100644 src/Symfony/Component/Validator/Tests/Fixtures/CustomArrayObject.php create mode 100644 src/Symfony/Component/Validator/Tests/Fixtures/StubGlobalExecutionContext.php diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php new file mode 100644 index 0000000000000..44dfc853dfe56 --- /dev/null +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php @@ -0,0 +1,414 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\Doctrine\Tests\Validator\Constraints; + +use Doctrine\Common\Persistence\ManagerRegistry; +use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Common\Persistence\ObjectRepository; +use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper; +use Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity; +use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest; +use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity; +use Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity; +use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity; +use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; +use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator; +use Symfony\Component\Validator\Validator; +use Doctrine\ORM\Tools\SchemaTool; + +/** + * @author Bernhard Schussek + */ +class UniqueEntityValidatorTest extends AbstractConstraintValidatorTest +{ + const EM_NAME = 'foo'; + + /** + * @var ObjectManager + */ + protected $em; + + /** + * @var ManagerRegistry + */ + protected $registry; + + /** + * @var ObjectRepository + */ + protected $repository; + + protected function setUp() + { + $this->em = DoctrineTestHelper::createTestEntityManager(); + $this->registry = $this->createRegistryMock($this->em); + $this->createSchema($this->em); + + parent::setUp(); + } + + protected function createRegistryMock(ObjectManager $em = null) + { + $registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry'); + $registry->expects($this->any()) + ->method('getManager') + ->with($this->equalTo(self::EM_NAME)) + ->will($this->returnValue($em)); + + return $registry; + } + + protected function createRepositoryMock() + { + $repository = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository') + ->setMethods(array('findByCustom', 'find', 'findAll', 'findOneBy', 'findBy', 'getClassName')) + ->getMock() + ; + + return $repository; + } + + protected function createEntityManagerMock($repositoryMock) + { + $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager') + ->getMock() + ; + $em->expects($this->any()) + ->method('getRepository') + ->will($this->returnValue($repositoryMock)) + ; + + $classMetadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); + $classMetadata + ->expects($this->any()) + ->method('hasField') + ->will($this->returnValue(true)) + ; + $reflParser = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionParser') + ->disableOriginalConstructor() + ->getMock() + ; + $refl = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionProperty') + ->setConstructorArgs(array($reflParser, 'property-name')) + ->setMethods(array('getValue')) + ->getMock() + ; + $refl + ->expects($this->any()) + ->method('getValue') + ->will($this->returnValue(true)) + ; + $classMetadata->reflFields = array('name' => $refl); + $em->expects($this->any()) + ->method('getClassMetadata') + ->will($this->returnValue($classMetadata)) + ; + + return $em; + } + + protected function createValidator() + { + return new UniqueEntityValidator($this->registry); + } + + private function createSchema(ObjectManager $em) + { + $schemaTool = new SchemaTool($em); + $schemaTool->createSchema(array( + $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity'), + $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity'), + $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity'), + $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity'), + )); + } + + /** + * This is a functional test as there is a large integration necessary to get the validator working. + */ + public function testValidateUniqueness() + { + $constraint = new UniqueEntity(array( + 'message' => 'myMessage', + 'fields' => array('name'), + 'em' => self::EM_NAME, + )); + + $entity1 = new SingleIntIdEntity(1, 'Foo'); + $entity2 = new SingleIntIdEntity(2, 'Foo'); + + $this->validator->validate($entity1, $constraint); + + $this->assertNoViolation(); + + $this->em->persist($entity1); + $this->em->flush(); + + $this->validator->validate($entity1, $constraint); + + $this->assertNoViolation(); + + $this->validator->validate($entity2, $constraint); + + $this->assertViolation('myMessage', array(), 'property.path.name', 'Foo'); + } + + public function testValidateCustomErrorPath() + { + $constraint = new UniqueEntity(array( + 'message' => 'myMessage', + 'fields' => array('name'), + 'em' => self::EM_NAME, + 'errorPath' => 'bar', + )); + + $entity1 = new SingleIntIdEntity(1, 'Foo'); + $entity2 = new SingleIntIdEntity(2, 'Foo'); + + $this->em->persist($entity1); + $this->em->flush(); + + $this->validator->validate($entity2, $constraint); + + $this->assertViolation('myMessage', array(), 'property.path.bar', 'Foo'); + } + + public function testValidateUniquenessWithNull() + { + $constraint = new UniqueEntity(array( + 'message' => 'myMessage', + 'fields' => array('name'), + 'em' => self::EM_NAME, + )); + + $entity1 = new SingleIntIdEntity(1, null); + $entity2 = new SingleIntIdEntity(2, null); + + $this->em->persist($entity1); + $this->em->persist($entity2); + $this->em->flush(); + + $this->validator->validate($entity1, $constraint); + + $this->assertNoViolation(); + } + + public function testValidateUniquenessWithIgnoreNull() + { + $constraint = new UniqueEntity(array( + 'message' => 'myMessage', + 'fields' => array('name', 'name2'), + 'em' => self::EM_NAME, + 'ignoreNull' => false, + )); + + $entity1 = new DoubleNameEntity(1, 'Foo', null); + $entity2 = new DoubleNameEntity(2, 'Foo', null); + + $this->validator->validate($entity1, $constraint); + + $this->assertNoViolation(); + + $this->em->persist($entity1); + $this->em->flush(); + + $this->validator->validate($entity1, $constraint); + + $this->assertNoViolation(); + + $this->validator->validate($entity2, $constraint); + + $this->assertViolation('myMessage', array(), 'property.path.name', 'Foo'); + } + + public function testValidateUniquenessUsingCustomRepositoryMethod() + { + $constraint = new UniqueEntity(array( + 'message' => 'myMessage', + 'fields' => array('name'), + 'em' => self::EM_NAME, + 'repositoryMethod' => 'findByCustom', + )); + + $repository = $this->createRepositoryMock(); + $repository->expects($this->once()) + ->method('findByCustom') + ->will($this->returnValue(array())) + ; + $this->em = $this->createEntityManagerMock($repository); + $this->registry = $this->createRegistryMock($this->em); + $this->validator = $this->createValidator(); + $this->validator->initialize($this->context); + + $entity1 = new SingleIntIdEntity(1, 'foo'); + + $this->validator->validate($entity1, $constraint); + + $this->assertNoViolation(); + } + + public function testValidateUniquenessWithUnrewoundArray() + { + $constraint = new UniqueEntity(array( + 'message' => 'myMessage', + 'fields' => array('name'), + 'em' => self::EM_NAME, + 'repositoryMethod' => 'findByCustom', + )); + + $entity = new SingleIntIdEntity(1, 'foo'); + + $repository = $this->createRepositoryMock(); + $repository->expects($this->once()) + ->method('findByCustom') + ->will( + $this->returnCallback(function () use ($entity) { + $returnValue = array( + $entity, + ); + next($returnValue); + + return $returnValue; + }) + ) + ; + $this->em = $this->createEntityManagerMock($repository); + $this->registry = $this->createRegistryMock($this->em); + $this->validator = $this->createValidator(); + $this->validator->initialize($this->context); + + $this->validator->validate($entity, $constraint); + + $this->assertNoViolation(); + } + + /** + * @group GH-1635 + */ + public function testAssociatedEntity() + { + $constraint = new UniqueEntity(array( + 'message' => 'myMessage', + 'fields' => array('single'), + 'em' => self::EM_NAME, + )); + + $entity1 = new SingleIntIdEntity(1, 'foo'); + $associated = new AssociationEntity(); + $associated->single = $entity1; + $associated2 = new AssociationEntity(); + $associated2->single = $entity1; + + $this->em->persist($entity1); + $this->em->persist($associated); + $this->em->flush(); + + $this->validator->validate($associated, $constraint); + + $this->assertNoViolation(); + + $this->em->persist($associated2); + $this->em->flush(); + + $this->validator->validate($associated2, $constraint); + + $this->assertViolation('myMessage', array(), 'property.path.single', 1); + } + + public function testAssociatedEntityWithNull() + { + $constraint = new UniqueEntity(array( + 'message' => 'myMessage', + 'fields' => array('single'), + 'em' => self::EM_NAME, + 'ignoreNull' => false, + )); + + $associated = new AssociationEntity(); + $associated->single = null; + + $this->em->persist($associated); + $this->em->flush(); + + $this->validator->validate($associated, $constraint); + + $this->assertNoViolation(); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException + * @expectedExceptionMessage Associated entities are not allowed to have more than one identifier field + * @group GH-1635 + */ + public function testAssociatedCompositeEntity() + { + $constraint = new UniqueEntity(array( + 'message' => 'myMessage', + 'fields' => array('composite'), + 'em' => self::EM_NAME, + )); + + $composite = new CompositeIntIdEntity(1, 1, "test"); + $associated = new AssociationEntity(); + $associated->composite = $composite; + + $this->em->persist($composite); + $this->em->persist($associated); + $this->em->flush(); + + $this->validator->validate($associated, $constraint); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException + * @expectedExceptionMessage Object manager "foo" does not exist. + */ + public function testDedicatedEntityManagerNullObject() + { + $constraint = new UniqueEntity(array( + 'message' => 'myMessage', + 'fields' => array('name'), + 'em' => self::EM_NAME, + )); + + $this->em = null; + $this->registry = $this->createRegistryMock($this->em); + $this->validator = $this->createValidator(); + $this->validator->initialize($this->context); + + $entity = new SingleIntIdEntity(1, null); + + $this->validator->validate($entity, $constraint); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException + * @expectedExceptionMessage Unable to find the object manager associated with an entity of class "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity" + */ + public function testEntityManagerNullObject() + { + $constraint = new UniqueEntity(array( + 'message' => 'myMessage', + 'fields' => array('name'), + // no "em" option set + )); + + $this->em = null; + $this->registry = $this->createRegistryMock($this->em); + $this->validator = $this->createValidator(); + $this->validator->initialize($this->context); + + $entity = new SingleIntIdEntity(1, null); + + $this->validator->validate($entity, $constraint); + } +} diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueValidatorTest.php deleted file mode 100644 index 9980802642007..0000000000000 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueValidatorTest.php +++ /dev/null @@ -1,437 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\Doctrine\Tests\Validator\Constraints; - -use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper; -use Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity; -use Symfony\Component\Validator\DefaultTranslator; -use Symfony\Component\Validator\Tests\Fixtures\FakeMetadataFactory; -use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity; -use Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity; -use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity; -use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; -use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator; -use Symfony\Component\Validator\Mapping\ClassMetadata; -use Symfony\Component\Validator\Validator; -use Doctrine\ORM\Tools\SchemaTool; - -class UniqueValidatorTest extends \PHPUnit_Framework_TestCase -{ - protected function setUp() - { - parent::setUp(); - - if (!class_exists('Symfony\Component\Security\Core\SecurityContext')) { - $this->markTestSkipped('The "Security" component is not available'); - } - - if (!class_exists('Symfony\Component\Validator\Constraint')) { - $this->markTestSkipped('The "Validator" component is not available'); - } - } - - protected function createRegistryMock($entityManagerName, $em) - { - $registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry'); - $registry->expects($this->any()) - ->method('getManager') - ->with($this->equalTo($entityManagerName)) - ->will($this->returnValue($em)); - - return $registry; - } - - protected function createRepositoryMock() - { - $repository = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository') - ->setMethods(array('findByCustom', 'find', 'findAll', 'findOneBy', 'findBy', 'getClassName')) - ->getMock() - ; - - return $repository; - } - - protected function createEntityManagerMock($repositoryMock) - { - $em = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager') - ->getMock() - ; - $em->expects($this->any()) - ->method('getRepository') - ->will($this->returnValue($repositoryMock)) - ; - - $classMetadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); - $classMetadata - ->expects($this->any()) - ->method('hasField') - ->will($this->returnValue(true)) - ; - $reflParser = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionParser') - ->disableOriginalConstructor() - ->getMock() - ; - $refl = $this->getMockBuilder('Doctrine\Common\Reflection\StaticReflectionProperty') - ->setConstructorArgs(array($reflParser, 'property-name')) - ->setMethods(array('getValue')) - ->getMock() - ; - $refl - ->expects($this->any()) - ->method('getValue') - ->will($this->returnValue(true)) - ; - $classMetadata->reflFields = array('name' => $refl); - $em->expects($this->any()) - ->method('getClassMetadata') - ->will($this->returnValue($classMetadata)) - ; - - return $em; - } - - protected function createValidatorFactory($uniqueValidator) - { - $validatorFactory = $this->getMock('Symfony\Component\Validator\ConstraintValidatorFactoryInterface'); - $validatorFactory->expects($this->any()) - ->method('getInstance') - ->with($this->isInstanceOf('Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity')) - ->will($this->returnValue($uniqueValidator)); - - return $validatorFactory; - } - - public function createValidator($entityManagerName, $em, $validateClass = null, $uniqueFields = null, $errorPath = null, $repositoryMethod = 'findBy', $ignoreNull = true) - { - if (!$validateClass) { - $validateClass = 'Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity'; - } - if (!$uniqueFields) { - $uniqueFields = array('name'); - } - - $registry = $this->createRegistryMock($entityManagerName, $em); - - $uniqueValidator = new UniqueEntityValidator($registry); - - $metadata = new ClassMetadata($validateClass); - $constraint = new UniqueEntity(array( - 'fields' => $uniqueFields, - 'em' => $entityManagerName, - 'errorPath' => $errorPath, - 'repositoryMethod' => $repositoryMethod, - 'ignoreNull' => $ignoreNull - )); - $metadata->addConstraint($constraint); - - $metadataFactory = new FakeMetadataFactory(); - $metadataFactory->addMetadata($metadata); - $validatorFactory = $this->createValidatorFactory($uniqueValidator); - - return new Validator($metadataFactory, $validatorFactory, new DefaultTranslator()); - } - - private function createSchema($em) - { - $schemaTool = new SchemaTool($em); - $schemaTool->createSchema(array( - $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity'), - $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity'), - $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity'), - $em->getClassMetadata('Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity'), - )); - } - - /** - * This is a functional test as there is a large integration necessary to get the validator working. - */ - public function testValidateUniqueness() - { - $entityManagerName = "foo"; - $em = DoctrineTestHelper::createTestEntityManager(); - $this->createSchema($em); - $validator = $this->createValidator($entityManagerName, $em); - - $entity1 = new SingleIntIdEntity(1, 'Foo'); - $violationsList = $validator->validate($entity1); - $this->assertEquals(0, $violationsList->count(), "No violations found on entity before it is saved to the database."); - - $em->persist($entity1); - $em->flush(); - - $violationsList = $validator->validate($entity1); - $this->assertEquals(0, $violationsList->count(), "No violations found on entity after it was saved to the database."); - - $entity2 = new SingleIntIdEntity(2, 'Foo'); - - $violationsList = $validator->validate($entity2); - $this->assertEquals(1, $violationsList->count(), "Violation found on entity with conflicting entity existing in the database."); - - $violation = $violationsList[0]; - $this->assertEquals('This value is already used.', $violation->getMessage()); - $this->assertEquals('name', $violation->getPropertyPath()); - $this->assertEquals('Foo', $violation->getInvalidValue()); - } - - public function testValidateCustomErrorPath() - { - $entityManagerName = "foo"; - $em = DoctrineTestHelper::createTestEntityManager(); - $this->createSchema($em); - $validator = $this->createValidator($entityManagerName, $em, null, null, 'bar'); - - $entity1 = new SingleIntIdEntity(1, 'Foo'); - - $em->persist($entity1); - $em->flush(); - - $entity2 = new SingleIntIdEntity(2, 'Foo'); - - $violationsList = $validator->validate($entity2); - $this->assertEquals(1, $violationsList->count(), "Violation found on entity with conflicting entity existing in the database."); - - $violation = $violationsList[0]; - $this->assertEquals('This value is already used.', $violation->getMessage()); - $this->assertEquals('bar', $violation->getPropertyPath()); - $this->assertEquals('Foo', $violation->getInvalidValue()); - } - - public function testValidateUniquenessWithNull() - { - $entityManagerName = "foo"; - $em = DoctrineTestHelper::createTestEntityManager(); - $this->createSchema($em); - $validator = $this->createValidator($entityManagerName, $em); - - $entity1 = new SingleIntIdEntity(1, null); - $entity2 = new SingleIntIdEntity(2, null); - - $em->persist($entity1); - $em->persist($entity2); - $em->flush(); - - $violationsList = $validator->validate($entity1); - $this->assertEquals(0, $violationsList->count(), "No violations found on entity having a null value."); - } - - public function testValidateUniquenessWithIgnoreNull() - { - $entityManagerName = "foo"; - $validateClass = 'Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity'; - $em = DoctrineTestHelper::createTestEntityManager(); - $this->createSchema($em); - $validator = $this->createValidator($entityManagerName, $em, $validateClass, array('name', 'name2'), 'bar', 'findby', false); - - $entity1 = new DoubleNameEntity(1, 'Foo', null); - $violationsList = $validator->validate($entity1); - $this->assertEquals(0, $violationsList->count(), "No violations found on entity before it is saved to the database."); - - $em->persist($entity1); - $em->flush(); - - $violationsList = $validator->validate($entity1); - $this->assertEquals(0, $violationsList->count(), "No violations found on entity after it was saved to the database."); - - $entity2 = new DoubleNameEntity(2, 'Foo', null); - - $violationsList = $validator->validate($entity2); - $this->assertEquals(1, $violationsList->count(), "Violation found on entity with conflicting entity existing in the database."); - - $violation = $violationsList[0]; - $this->assertEquals('This value is already used.', $violation->getMessage()); - $this->assertEquals('bar', $violation->getPropertyPath()); - $this->assertEquals('Foo', $violation->getInvalidValue()); - } - - public function testValidateUniquenessAfterConsideringMultipleQueryResults() - { - $entityManagerName = "foo"; - $em = DoctrineTestHelper::createTestEntityManager(); - $this->createSchema($em); - $validator = $this->createValidator($entityManagerName, $em); - - $entity1 = new SingleIntIdEntity(1, 'foo'); - $entity2 = new SingleIntIdEntity(2, 'foo'); - - $em->persist($entity1); - $em->persist($entity2); - $em->flush(); - - $violationsList = $validator->validate($entity1); - $this->assertEquals(1, $violationsList->count(), 'Violation found on entity with conflicting entity existing in the database.'); - - $violationsList = $validator->validate($entity2); - $this->assertEquals(1, $violationsList->count(), 'Violation found on entity with conflicting entity existing in the database.'); - } - - public function testValidateUniquenessUsingCustomRepositoryMethod() - { - $entityManagerName = 'foo'; - $repository = $this->createRepositoryMock(); - $repository->expects($this->once()) - ->method('findByCustom') - ->will($this->returnValue(array())) - ; - $em = $this->createEntityManagerMock($repository); - $validator = $this->createValidator($entityManagerName, $em, null, array(), null, 'findByCustom'); - - $entity1 = new SingleIntIdEntity(1, 'foo'); - - $violationsList = $validator->validate($entity1); - $this->assertEquals(0, $violationsList->count(), 'Violation is using custom repository method.'); - } - - public function testValidateUniquenessWithUnrewoundArray() - { - $entity = new SingleIntIdEntity(1, 'foo'); - - $entityManagerName = 'foo'; - $repository = $this->createRepositoryMock(); - $repository->expects($this->once()) - ->method('findByCustom') - ->will( - $this->returnCallback(function () use ($entity) { - $returnValue = array( - $entity, - ); - next($returnValue); - - return $returnValue; - }) - ) - ; - $em = $this->createEntityManagerMock($repository); - $validator = $this->createValidator($entityManagerName, $em, null, array(), null, 'findByCustom'); - - $violationsList = $validator->validate($entity); - $this->assertCount(0, $violationsList, 'Violation is using unrewound array as return value in the repository method.'); - } - - /** - * @group GH-1635 - */ - public function testAssociatedEntity() - { - $entityManagerName = "foo"; - $em = DoctrineTestHelper::createTestEntityManager(); - $this->createSchema($em); - $validator = $this->createValidator($entityManagerName, $em, 'Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity', array('single')); - - $entity1 = new SingleIntIdEntity(1, 'foo'); - $associated = new AssociationEntity(); - $associated->single = $entity1; - - $em->persist($entity1); - $em->persist($associated); - $em->flush(); - - $violationsList = $validator->validate($associated); - $this->assertEquals(0, $violationsList->count()); - - $associated2 = new AssociationEntity(); - $associated2->single = $entity1; - - $em->persist($associated2); - $em->flush(); - - $violationsList = $validator->validate($associated2); - $this->assertEquals(1, $violationsList->count()); - } - - public function testAssociatedEntityWithNull() - { - $entityManagerName = "foo"; - $em = DoctrineTestHelper::createTestEntityManager(); - $this->createSchema($em); - $validator = $this->createValidator($entityManagerName, $em, 'Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity', array('single'), null, 'findBy', false); - - $associated = new AssociationEntity(); - $associated->single = null; - - $em->persist($associated); - $em->flush(); - - $violationsList = $validator->validate($associated); - $this->assertEquals(0, $violationsList->count()); - } - - /** - * @group GH-1635 - */ - public function testAssociatedCompositeEntity() - { - $entityManagerName = "foo"; - $em = DoctrineTestHelper::createTestEntityManager(); - $this->createSchema($em); - $validator = $this->createValidator($entityManagerName, $em, 'Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity', array('composite')); - - $composite = new CompositeIntIdEntity(1, 1, "test"); - $associated = new AssociationEntity(); - $associated->composite = $composite; - - $em->persist($composite); - $em->persist($associated); - $em->flush(); - - $this->setExpectedException( - 'Symfony\Component\Validator\Exception\ConstraintDefinitionException', - 'Associated entities are not allowed to have more than one identifier field' - ); - $violationsList = $validator->validate($associated); - } - - public function testDedicatedEntityManagerNullObject() - { - $uniqueFields = array('name'); - $entityManagerName = 'foo'; - - $registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry'); - - $constraint = new UniqueEntity(array( - 'fields' => $uniqueFields, - 'em' => $entityManagerName, - )); - - $uniqueValidator = new UniqueEntityValidator($registry); - - $entity = new SingleIntIdEntity(1, null); - - $this->setExpectedException( - 'Symfony\Component\Validator\Exception\ConstraintDefinitionException', - 'Object manager "foo" does not exist.' - ); - - $uniqueValidator->validate($entity, $constraint); - } - - public function testEntityManagerNullObject() - { - $uniqueFields = array('name'); - - $registry = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry'); - - $constraint = new UniqueEntity(array( - 'fields' => $uniqueFields, - )); - - $uniqueValidator = new UniqueEntityValidator($registry); - - $entity = new SingleIntIdEntity(1, null); - - $this->setExpectedException( - 'Symfony\Component\Validator\Exception\ConstraintDefinitionException', - 'Unable to find the object manager associated with an entity of class "Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity"' - ); - - $uniqueValidator->validate($entity, $constraint); - } -} diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php index dc504172a0a61..bfb84a15f84b6 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php @@ -21,11 +21,12 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\NotBlank; +use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest; /** * @author Bernhard Schussek */ -class FormValidatorTest extends \PHPUnit_Framework_TestCase +class FormValidatorTest extends AbstractConstraintValidatorTest { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -40,51 +41,43 @@ class FormValidatorTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - private $serverParams; - - /** - * @var FormValidator - */ - private $validator; + protected $serverParams; protected function setUp() { - if (!class_exists('Symfony\Component\EventDispatcher\Event')) { - $this->markTestSkipped('The "EventDispatcher" component is not available'); - } - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); $this->serverParams = $this->getMock( 'Symfony\Component\Form\Extension\Validator\Util\ServerParams', array('getNormalizedIniPostMaxSize', 'getContentLength') ); - $this->validator = new FormValidator($this->serverParams); + + parent::setUp(); + } + + protected function createValidator() + { + return new FormValidator($this->serverParams); } public function testValidate() { - $context = $this->getMockExecutionContext(); $object = $this->getMock('\stdClass'); $options = array('validation_groups' => array('group1', 'group2')); $form = $this->getBuilder('name', '\stdClass', $options) ->setData($object) ->getForm(); - $context->expects($this->at(0)) - ->method('validate') - ->with($object, 'data', 'group1', true); - $context->expects($this->at(1)) - ->method('validate') - ->with($object, 'data', 'group2', true); + $this->expectValidateAt(0, 'data', $object, 'group1'); + $this->expectValidateAt(1, 'data', $object, 'group2'); - $this->validator->initialize($context); $this->validator->validate($form, new Form()); + + $this->assertNoViolation(); } public function testValidateConstraints() { - $context = $this->getMockExecutionContext(); $object = $this->getMock('\stdClass'); $constraint1 = new NotNull(array('groups' => array('group1', 'group2'))); $constraint2 = new NotBlank(array('groups' => 'group2')); @@ -98,28 +91,20 @@ public function testValidateConstraints() ->getForm(); // First default constraints - $context->expects($this->at(0)) - ->method('validate') - ->with($object, 'data', 'group1', true); - $context->expects($this->at(1)) - ->method('validate') - ->with($object, 'data', 'group2', true); + $this->expectValidateAt(0, 'data', $object, 'group1'); + $this->expectValidateAt(1, 'data', $object, 'group2'); // Then custom constraints - $context->expects($this->at(2)) - ->method('validateValue') - ->with($object, $constraint1, 'data', 'group1'); - $context->expects($this->at(3)) - ->method('validateValue') - ->with($object, $constraint2, 'data', 'group2'); - - $this->validator->initialize($context); + $this->expectValidateValueAt(2, 'data', $object, $constraint1, 'group1'); + $this->expectValidateValueAt(3, 'data', $object, $constraint2, 'group2'); + $this->validator->validate($form, new Form()); + + $this->assertNoViolation(); } public function testDontValidateIfParentWithoutCascadeValidation() { - $context = $this->getMockExecutionContext(); $object = $this->getMock('\stdClass'); $parent = $this->getBuilder('parent', null, array('cascade_validation' => false)) @@ -132,16 +117,15 @@ public function testDontValidateIfParentWithoutCascadeValidation() $form->setData($object); - $context->expects($this->never()) - ->method('validate'); + $this->expectNoValidate(); - $this->validator->initialize($context); $this->validator->validate($form, new Form()); + + $this->assertNoViolation(); } public function testValidateConstraintsEvenIfNoCascadeValidation() { - $context = $this->getMockExecutionContext(); $object = $this->getMock('\stdClass'); $constraint1 = new NotNull(array('groups' => array('group1', 'group2'))); $constraint2 = new NotBlank(array('groups' => 'group2')); @@ -159,20 +143,16 @@ public function testValidateConstraintsEvenIfNoCascadeValidation() ->getForm(); $parent->add($form); - $context->expects($this->at(0)) - ->method('validateValue') - ->with($object, $constraint1, 'data', 'group1'); - $context->expects($this->at(1)) - ->method('validateValue') - ->with($object, $constraint2, 'data', 'group2'); + $this->expectValidateValueAt(0, 'data', $object, $constraint1, 'group1'); + $this->expectValidateValueAt(1, 'data', $object, $constraint2, 'group2'); - $this->validator->initialize($context); $this->validator->validate($form, new Form()); + + $this->assertNoViolation(); } public function testDontValidateIfNoValidationGroups() { - $context = $this->getMockExecutionContext(); $object = $this->getMock('\stdClass'); $form = $this->getBuilder('name', '\stdClass', array( @@ -183,16 +163,15 @@ public function testDontValidateIfNoValidationGroups() $form->setData($object); - $context->expects($this->never()) - ->method('validate'); + $this->expectNoValidate(); - $this->validator->initialize($context); $this->validator->validate($form, new Form()); + + $this->assertNoViolation(); } public function testDontValidateConstraintsIfNoValidationGroups() { - $context = $this->getMockExecutionContext(); $object = $this->getMock('\stdClass'); $constraint1 = $this->getMock('Symfony\Component\Validator\Constraint'); $constraint2 = $this->getMock('Symfony\Component\Validator\Constraint'); @@ -208,16 +187,15 @@ public function testDontValidateConstraintsIfNoValidationGroups() // Launch transformer $form->submit(array()); - $context->expects($this->never()) - ->method('validate'); + $this->expectNoValidate(); - $this->validator->initialize($context); $this->validator->validate($form, new Form()); + + $this->assertNoViolation(); } public function testDontValidateIfNotSynchronized() { - $context = $this->getMockExecutionContext(); $object = $this->getMock('\stdClass'); $form = $this->getBuilder('name', '\stdClass', array( @@ -237,26 +215,18 @@ function () { throw new TransformationFailedException(); } // Launch transformer $form->submit('foo'); - $context->expects($this->never()) - ->method('validate'); - - $context->expects($this->once()) - ->method('addViolation') - ->with( - 'invalid_message_key', - array('{{ value }}' => 'foo', '{{ foo }}' => 'bar'), - 'foo' - ); - $context->expects($this->never()) - ->method('addViolationAt'); + $this->expectNoValidate(); - $this->validator->initialize($context); $this->validator->validate($form, new Form()); + + $this->assertViolation('invalid_message_key', array( + '{{ value }}' => 'foo', + '{{ foo }}' => 'bar' + ), 'property.path', 'foo', null, Form::ERR_INVALID); } public function testAddInvalidErrorEvenIfNoValidationGroups() { - $context = $this->getMockExecutionContext(); $object = $this->getMock('\stdClass'); $form = $this->getBuilder('name', '\stdClass', array( @@ -277,31 +247,24 @@ function () { throw new TransformationFailedException(); } // Launch transformer $form->submit('foo'); - $context->expects($this->never()) - ->method('validate'); - - $context->expects($this->once()) - ->method('addViolation') - ->with( - 'invalid_message_key', - array('{{ value }}' => 'foo', '{{ foo }}' => 'bar'), - 'foo' - ); - $context->expects($this->never()) - ->method('addViolationAt'); + $this->expectNoValidate(); - $this->validator->initialize($context); $this->validator->validate($form, new Form()); + + $this->assertViolation('invalid_message_key', array( + '{{ value }}' => 'foo', + '{{ foo }}' => 'bar' + ), 'property.path', 'foo', null, Form::ERR_INVALID); } public function testDontValidateConstraintsIfNotSynchronized() { - $context = $this->getMockExecutionContext(); $object = $this->getMock('\stdClass'); $constraint1 = $this->getMock('Symfony\Component\Validator\Constraint'); $constraint2 = $this->getMock('Symfony\Component\Validator\Constraint'); $options = array( + 'invalid_message' => 'invalid_message_key', 'validation_groups' => array('group1', 'group2'), 'constraints' => array($constraint1, $constraint2), ); @@ -314,19 +277,20 @@ function () { throw new TransformationFailedException(); } ->getForm(); // Launch transformer - $form->submit(array()); + $form->submit('foo'); - $context->expects($this->never()) - ->method('validate'); + $this->expectNoValidate(); - $this->validator->initialize($context); $this->validator->validate($form, new Form()); + + $this->assertViolation('invalid_message_key', array( + '{{ value }}' => 'foo', + ), 'property.path','foo', null, Form::ERR_INVALID); } // https://github.com/symfony/symfony/issues/4359 public function testDontMarkInvalidIfAnyChildIsNotSynchronized() { - $context = $this->getMockExecutionContext(); $object = $this->getMock('\stdClass'); $failingTransformer = new CallbackTransformer( @@ -348,55 +312,46 @@ function () { throw new TransformationFailedException(); } // Launch transformer $form->submit(array('child' => 'foo')); - $context->expects($this->never()) - ->method('addViolation'); - $context->expects($this->never()) - ->method('addViolationAt'); + $this->expectNoValidate(); - $this->validator->initialize($context); $this->validator->validate($form, new Form()); + + $this->assertNoViolation(); } public function testHandleCallbackValidationGroups() { - $context = $this->getMockExecutionContext(); $object = $this->getMock('\stdClass'); $options = array('validation_groups' => array($this, 'getValidationGroups')); $form = $this->getBuilder('name', '\stdClass', $options) ->setData($object) ->getForm(); - $context->expects($this->at(0)) - ->method('validate') - ->with($object, 'data', 'group1', true); - $context->expects($this->at(1)) - ->method('validate') - ->with($object, 'data', 'group2', true); + $this->expectValidateAt(0, 'data', $object, 'group1'); + $this->expectValidateAt(1, 'data', $object, 'group2'); - $this->validator->initialize($context); $this->validator->validate($form, new Form()); + + $this->assertNoViolation(); } public function testDontExecuteFunctionNames() { - $context = $this->getMockExecutionContext(); $object = $this->getMock('\stdClass'); $options = array('validation_groups' => 'header'); $form = $this->getBuilder('name', '\stdClass', $options) ->setData($object) ->getForm(); - $context->expects($this->once()) - ->method('validate') - ->with($object, 'data', 'header', true); + $this->expectValidateAt(0, 'data', $object, 'header'); - $this->validator->initialize($context); $this->validator->validate($form, new Form()); + + $this->assertNoViolation(); } public function testHandleClosureValidationGroups() { - $context = $this->getMockExecutionContext(); $object = $this->getMock('\stdClass'); $options = array('validation_groups' => function (FormInterface $form) { return array('group1', 'group2'); @@ -405,20 +360,16 @@ public function testHandleClosureValidationGroups() ->setData($object) ->getForm(); - $context->expects($this->at(0)) - ->method('validate') - ->with($object, 'data', 'group1', true); - $context->expects($this->at(1)) - ->method('validate') - ->with($object, 'data', 'group2', true); + $this->expectValidateAt(0, 'data', $object, 'group1'); + $this->expectValidateAt(1, 'data', $object, 'group2'); - $this->validator->initialize($context); $this->validator->validate($form, new Form()); + + $this->assertNoViolation(); } public function testUseValidationGroupOfClickedButton() { - $context = $this->getMockExecutionContext(); $object = $this->getMock('\stdClass'); $parent = $this->getBuilder('parent', null, array('cascade_validation' => true)) @@ -436,17 +387,15 @@ public function testUseValidationGroupOfClickedButton() $parent->submit(array('name' => $object, 'submit' => '')); - $context->expects($this->once()) - ->method('validate') - ->with($object, 'data', 'button_group', true); + $this->expectValidateAt(0, 'data', $object, 'button_group'); - $this->validator->initialize($context); $this->validator->validate($form, new Form()); + + $this->assertNoViolation(); } public function testDontUseValidationGroupOfUnclickedButton() { - $context = $this->getMockExecutionContext(); $object = $this->getMock('\stdClass'); $parent = $this->getBuilder('parent', null, array('cascade_validation' => true)) @@ -464,17 +413,15 @@ public function testDontUseValidationGroupOfUnclickedButton() $form->setData($object); - $context->expects($this->once()) - ->method('validate') - ->with($object, 'data', 'form_group', true); + $this->expectValidateAt(0, 'data', $object, 'form_group'); - $this->validator->initialize($context); $this->validator->validate($form, new Form()); + + $this->assertNoViolation(); } public function testUseInheritedValidationGroup() { - $context = $this->getMockExecutionContext(); $object = $this->getMock('\stdClass'); $parentOptions = array( @@ -490,17 +437,15 @@ public function testUseInheritedValidationGroup() $form->setData($object); - $context->expects($this->once()) - ->method('validate') - ->with($object, 'data', 'group', true); + $this->expectValidateAt(0, 'data', $object, 'group'); - $this->validator->initialize($context); $this->validator->validate($form, new Form()); + + $this->assertNoViolation(); } public function testUseInheritedCallbackValidationGroup() { - $context = $this->getMockExecutionContext(); $object = $this->getMock('\stdClass'); $parentOptions = array( @@ -516,20 +461,16 @@ public function testUseInheritedCallbackValidationGroup() $form->setData($object); - $context->expects($this->at(0)) - ->method('validate') - ->with($object, 'data', 'group1', true); - $context->expects($this->at(1)) - ->method('validate') - ->with($object, 'data', 'group2', true); + $this->expectValidateAt(0, 'data', $object, 'group1'); + $this->expectValidateAt(1, 'data', $object, 'group2'); - $this->validator->initialize($context); $this->validator->validate($form, new Form()); + + $this->assertNoViolation(); } public function testUseInheritedClosureValidationGroup() { - $context = $this->getMockExecutionContext(); $object = $this->getMock('\stdClass'); $parentOptions = array( @@ -547,52 +488,43 @@ public function testUseInheritedClosureValidationGroup() $form->setData($object); - $context->expects($this->at(0)) - ->method('validate') - ->with($object, 'data', 'group1', true); - $context->expects($this->at(1)) - ->method('validate') - ->with($object, 'data', 'group2', true); + $this->expectValidateAt(0, 'data', $object, 'group1'); + $this->expectValidateAt(1, 'data', $object, 'group2'); - $this->validator->initialize($context); $this->validator->validate($form, new Form()); + + $this->assertNoViolation(); } public function testAppendPropertyPath() { - $context = $this->getMockExecutionContext(); $object = $this->getMock('\stdClass'); $form = $this->getBuilder('name', '\stdClass') ->setData($object) ->getForm(); - $context->expects($this->once()) - ->method('validate') - ->with($object, 'data', 'Default', true); + $this->expectValidateAt(0, 'data', $object, 'Default'); - $this->validator->initialize($context); $this->validator->validate($form, new Form()); + + $this->assertNoViolation(); } public function testDontWalkScalars() { - $context = $this->getMockExecutionContext(); - $form = $this->getBuilder() ->setData('scalar') ->getForm(); - $context->expects($this->never()) - ->method('validate'); + $this->expectNoValidate(); - $this->validator->initialize($context); $this->validator->validate($form, new Form()); + + $this->assertNoViolation(); } public function testViolationIfExtraData() { - $context = $this->getMockExecutionContext(); - $form = $this->getBuilder('parent', null, array('extra_fields_message' => 'Extra!')) ->setCompound(true) ->setDataMapper($this->getDataMapper()) @@ -601,18 +533,13 @@ public function testViolationIfExtraData() $form->submit(array('foo' => 'bar')); - $context->expects($this->once()) - ->method('addViolation') - ->with( - 'Extra!', - array('{{ extra_fields }}' => 'foo'), - array('foo' => 'bar') - ); - $context->expects($this->never()) - ->method('addViolationAt'); - - $this->validator->initialize($context); + $this->expectNoValidate(); + $this->validator->validate($form, new Form()); + + $this->assertViolation('Extra!', array( + '{{ extra_fields }}' => 'foo' + ), 'property.path', array('foo' => 'bar')); } /** @@ -627,26 +554,18 @@ public function testPostMaxSizeViolation($contentLength, $iniMax, $nbViolation, ->method('getNormalizedIniPostMaxSize') ->will($this->returnValue($iniMax)); - $context = $this->getMockExecutionContext(); $options = array('post_max_size_message' => 'Max {{ max }}!'); $form = $this->getBuilder('name', null, $options)->getForm(); + $this->validator->validate($form, new Form()); + + $violations = array(); + for ($i = 0; $i < $nbViolation; ++$i) { - if (0 === $i && count($params) > 0) { - $context->expects($this->at($i)) - ->method('addViolation') - ->with($options['post_max_size_message'], $params); - } else { - $context->expects($this->at($i)) - ->method('addViolation'); - } + $violations[] = $this->createViolation($options['post_max_size_message'], $params, 'property.path', $contentLength); } - $context->expects($this->never()) - ->method('addViolationAt'); - - $this->validator->initialize($context); - $this->validator->validate($form, new Form()); + $this->assertViolations($violations); } public function getPostMaxSizeFixtures() @@ -672,7 +591,6 @@ public function testNoViolationIfNotRoot() $this->serverParams->expects($this->never()) ->method('getNormalizedIniPostMaxSize'); - $context = $this->getMockExecutionContext(); $parent = $this->getBuilder() ->setCompound(true) ->setDataMapper($this->getDataMapper()) @@ -680,13 +598,11 @@ public function testNoViolationIfNotRoot() $form = $this->getForm(); $parent->add($form); - $context->expects($this->never()) - ->method('addViolation'); - $context->expects($this->never()) - ->method('addViolationAt'); + $this->expectNoValidate(); - $this->validator->initialize($context); $this->validator->validate($form, new Form()); + + $this->assertNoViolation(); } /** diff --git a/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php new file mode 100644 index 0000000000000..8b3eb53a2c150 --- /dev/null +++ b/src/Symfony/Component/Security/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php @@ -0,0 +1,168 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Security\Core\Tests\Validator\Constraints; + +use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface; +use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface; +use Symfony\Component\Security\Core\SecurityContextInterface; +use Symfony\Component\Security\Core\Validator\Constraints\UserPassword; +use Symfony\Component\Security\Core\Validator\Constraints\UserPasswordValidator; +use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest; + +/** + * @author Bernhard Schussek + */ +class UserPasswordValidatorTest extends AbstractConstraintValidatorTest +{ + const PASSWORD = 's3Cr3t'; + + const SALT = '^S4lt$'; + + /** + * @var SecurityContextInterface + */ + protected $securityContext; + + /** + * @var PasswordEncoderInterface + */ + protected $encoder; + + /** + * @var EncoderFactoryInterface + */ + protected $encoderFactory; + + protected function createValidator() + { + return new UserPasswordValidator($this->securityContext, $this->encoderFactory); + } + + protected function setUp() + { + $user = $this->createUser(); + $this->securityContext = $this->createSecurityContext($user); + $this->encoder = $this->createPasswordEncoder(); + $this->encoderFactory = $this->createEncoderFactory($this->encoder); + + parent::setUp(); + } + + public function testPasswordIsValid() + { + $constraint = new UserPassword(array( + 'message' => 'myMessage', + )); + + $this->encoder->expects($this->once()) + ->method('isPasswordValid') + ->with(static::PASSWORD, 'secret', static::SALT) + ->will($this->returnValue(true)); + + $this->validator->validate('secret', $constraint); + + $this->assertNoViolation(); + } + + public function testPasswordIsNotValid() + { + $constraint = new UserPassword(array( + 'message' => 'myMessage', + )); + + $this->encoder->expects($this->once()) + ->method('isPasswordValid') + ->with(static::PASSWORD, 'secret', static::SALT) + ->will($this->returnValue(false)); + + $this->validator->validate('secret', $constraint); + + $this->assertViolation('myMessage'); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException + */ + public function testUserIsNotValid() + { + $user = $this->getMock('Foo\Bar\User'); + + $this->securityContext = $this->createSecurityContext($user); + $this->validator = $this->createValidator(); + $this->validator->initialize($this->context); + + $this->validator->validate('secret', new UserPassword()); + } + + protected function createUser() + { + $mock = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); + + $mock + ->expects($this->any()) + ->method('getPassword') + ->will($this->returnValue(static::PASSWORD)) + ; + + $mock + ->expects($this->any()) + ->method('getSalt') + ->will($this->returnValue(static::SALT)) + ; + + return $mock; + } + + protected function createPasswordEncoder($isPasswordValid = true) + { + return $this->getMock('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface'); + } + + protected function createEncoderFactory($encoder = null) + { + $mock = $this->getMock('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface'); + + $mock + ->expects($this->any()) + ->method('getEncoder') + ->will($this->returnValue($encoder)) + ; + + return $mock; + } + + protected function createSecurityContext($user = null) + { + $token = $this->createAuthenticationToken($user); + + $mock = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'); + $mock + ->expects($this->any()) + ->method('getToken') + ->will($this->returnValue($token)) + ; + + return $mock; + } + + protected function createAuthenticationToken($user = null) + { + $mock = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + $mock + ->expects($this->any()) + ->method('getUser') + ->will($this->returnValue($user)) + ; + + return $mock; + } +} diff --git a/src/Symfony/Component/Validator/Constraints/AllValidator.php b/src/Symfony/Component/Validator/Constraints/AllValidator.php index 2ffb8bf16fb96..469d2a42148a3 100644 --- a/src/Symfony/Component/Validator/Constraints/AllValidator.php +++ b/src/Symfony/Component/Validator/Constraints/AllValidator.php @@ -38,9 +38,7 @@ public function validate($value, Constraint $constraint) $group = $this->context->getGroup(); foreach ($value as $key => $element) { - foreach ($constraint->constraints as $constr) { - $this->context->validateValue($element, $constr, '['.$key.']', $group); - } + $this->context->validateValue($element, $constraint->constraints, '['.$key.']', $group); } } } diff --git a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php index 2e0658cfa6dac..79081fee49cea 100644 --- a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php @@ -70,7 +70,7 @@ public function validate($value, Constraint $constraint) if ($constraint->min !== null && $count < $constraint->min) { $this->context->addViolation($constraint->minMessage, array( '{{ limit }}' => $constraint->min - ), null, (int) $constraint->min); + ), $value, (int) $constraint->min); return; } @@ -78,7 +78,7 @@ public function validate($value, Constraint $constraint) if ($constraint->max !== null && $count > $constraint->max) { $this->context->addViolation($constraint->maxMessage, array( '{{ limit }}' => $constraint->max - ), null, (int) $constraint->max); + ), $value, (int) $constraint->max); return; } diff --git a/src/Symfony/Component/Validator/Constraints/CollectionValidator.php b/src/Symfony/Component/Validator/Constraints/CollectionValidator.php index a322ef49adc4f..33f839d3b9498 100644 --- a/src/Symfony/Component/Validator/Constraints/CollectionValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CollectionValidator.php @@ -43,9 +43,7 @@ public function validate($value, Constraint $constraint) (is_array($value) && array_key_exists($field, $value)) || ($value instanceof \ArrayAccess && $value->offsetExists($field)) ) { - foreach ($fieldConstraint->constraints as $constr) { - $this->context->validateValue($value[$field], $constr, '['.$field.']', $group); - } + $this->context->validateValue($value[$field], $fieldConstraint->constraints, '['.$field.']', $group); } elseif (!$fieldConstraint instanceof Optional && !$constraint->allowMissingFields) { $this->context->addViolationAt('['.$field.']', $constraint->missingFieldsMessage, array( '{{ field }}' => $this->formatValue($field) diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php index a1c573baa4e1c..a56f734554fd1 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php @@ -13,7 +13,6 @@ use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\Constraints\AbstractComparisonValidator; class ComparisonTest_Class { @@ -33,32 +32,15 @@ public function __toString() /** * @author Daniel Holmes */ -abstract class AbstractComparisonValidatorTestCase extends \PHPUnit_Framework_TestCase +abstract class AbstractComparisonValidatorTestCase extends AbstractConstraintValidatorTest { - private $validator; - private $context; - - protected function setUp() - { - $this->validator = $this->createValidator(); - $this->context = $this->getMockBuilder('Symfony\Component\Validator\ExecutionContext') - ->disableOriginalConstructor() - ->getMock(); - $this->validator->initialize($this->context); - - \Locale::setDefault('en'); - } - /** - * @return AbstractComparisonValidator + * @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException */ - abstract protected function createValidator(); - public function testThrowsConstraintExceptionIfNoValueOrProperty() { - $this->setExpectedException('Symfony\Component\Validator\Exception\ConstraintDefinitionException'); - $comparison = $this->createConstraint(array()); + $this->validator->validate('some value', $comparison); } @@ -69,16 +51,11 @@ public function testThrowsConstraintExceptionIfNoValueOrProperty() */ public function testValidComparisonToValue($dirtyValue, $comparisonValue) { - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = $this->createConstraint(array('value' => $comparisonValue)); - $this->context->expects($this->any()) - ->method('getPropertyPath') - ->will($this->returnValue('property1')); - $this->validator->validate($dirtyValue, $constraint); + + $this->assertNoViolation(); } /** @@ -105,19 +82,13 @@ public function testInvalidComparisonToValue($dirtyValue, $dirtyValueAsString, $ $constraint = $this->createConstraint(array('value' => $comparedValue)); $constraint->message = 'Constraint Message'; - $this->context->expects($this->any()) - ->method('getPropertyPath') - ->will($this->returnValue('property1')); - - $this->context->expects($this->once()) - ->method('addViolation') - ->with('Constraint Message', array( - '{{ value }}' => $dirtyValueAsString, - '{{ compared_value }}' => $comparedValueString, - '{{ compared_value_type }}' => $comparedValueType - )); - $this->validator->validate($dirtyValue, $constraint); + + $this->assertViolation('Constraint Message', array( + '{{ value }}' => $dirtyValueAsString, + '{{ compared_value }}' => $comparedValueString, + '{{ compared_value_type }}' => $comparedValueType + )); } /** diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php new file mode 100644 index 0000000000000..bc4e1c214a02c --- /dev/null +++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php @@ -0,0 +1,194 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\ConstraintValidatorInterface; +use Symfony\Component\Validator\ConstraintViolation; +use Symfony\Component\Validator\Context\ExecutionContext; +use Symfony\Component\Validator\Context\ExecutionContextInterface; +use Symfony\Component\Validator\Mapping\ClassMetadata; +use Symfony\Component\Validator\Mapping\PropertyMetadata; +use Symfony\Component\Validator\Tests\Fixtures\StubGlobalExecutionContext; + +/** + * @since 2.5.3 + * @author Bernhard Schussek + */ +abstract class AbstractConstraintValidatorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ExecutionContextInterface + */ + protected $context; + + /** + * @var ConstraintValidatorInterface + */ + protected $validator; + + protected $group; + + protected $metadata; + + protected $object; + + protected $value; + + protected $root; + + protected $propertyPath; + + protected function setUp() + { + $this->group = 'MyGroup'; + $this->metadata = null; + $this->object = null; + $this->value = 'InvalidValue'; + $this->root = 'root'; + $this->propertyPath = 'property.path'; + $this->context = $this->createContext(); + $this->validator = $this->createValidator(); + $this->validator->initialize($this->context); + + \Locale::setDefault('en'); + } + + protected function createContext() + { + $translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface'); + + return $this->getMockBuilder('Symfony\Component\Validator\ExecutionContext') + ->setConstructorArgs(array( + new StubGlobalExecutionContext($this->root), + $translator, + null, + $this->metadata, + $this->value, + $this->group, + $this->propertyPath + )) + ->setMethods(array('validate', 'validateValue')) + ->getMock(); + } + + protected function createViolation($message, array $parameters = array(), $propertyPath = 'property.path', $invalidValue = 'InvalidValue', $plural = null, $code = null) + { + return new ConstraintViolation( + null, + $message, + $parameters, + $this->root, + $propertyPath, + $invalidValue, + $plural, + $code + ); + } + + protected function setGroup($group) + { + $this->group = $group; + $this->context = $this->createContext(); + $this->validator->initialize($this->context); + } + + protected function setObject($object) + { + $this->object = $object; + $this->metadata = is_object($object) + ? new ClassMetadata(get_class($object)) + : null; + $this->context = $this->createContext(); + $this->validator->initialize($this->context); + } + + protected function setProperty($object, $property) + { + $this->object = $object; + $this->metadata = is_object($object) + ? new PropertyMetadata(get_class($object), $property) + : null; + $this->context = $this->createContext(); + $this->validator->initialize($this->context); + } + + protected function setValue($value) + { + $this->value = $value; + $this->context = $this->createContext(); + $this->validator->initialize($this->context); + } + + protected function setRoot($root) + { + $this->root = $root; + $this->context = $this->createContext(); + $this->validator->initialize($this->context); + } + + protected function setPropertyPath($propertyPath) + { + $this->propertyPath = $propertyPath; + $this->context = $this->createContext(); + $this->validator->initialize($this->context); + } + + protected function expectNoValidate() + { + $this->context->expects($this->never()) + ->method('validate'); + $this->context->expects($this->never()) + ->method('validateValue'); + } + + protected function expectValidateAt($i, $propertyPath, $value, $group) + { + $this->context->expects($this->at($i)) + ->method('validate') + ->with($value, $propertyPath, $group); + } + + protected function expectValidateValueAt($i, $propertyPath, $value, $constraints, $group) + { + $this->context->expects($this->at($i)) + ->method('validateValue') + ->with($value, $constraints, $propertyPath, $group); + } + + protected function assertNoViolation() + { + $this->assertCount(0, $this->context->getViolations()); + } + + protected function assertViolation($message, array $parameters = array(), $propertyPath = 'property.path', $invalidValue = 'InvalidValue', $plural = null, $code = null) + { + $violations = $this->context->getViolations(); + + $this->assertCount(1, $violations); + $this->assertEquals($this->createViolation($message, $parameters, $propertyPath, $invalidValue, $plural, $code), $violations[0]); + } + + protected function assertViolations(array $expected) + { + $violations = $this->context->getViolations(); + + $this->assertCount(count($expected), $violations); + + $i = 0; + + foreach ($expected as $violation) { + $this->assertEquals($violation, $violations[$i++]); + } + } + + abstract protected function createValidator(); +} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php index eaa9044e9ef52..d9ffd9814c2b7 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AllValidatorTest.php @@ -11,40 +11,23 @@ namespace Symfony\Component\Validator\Tests\Constraints; -use Symfony\Component\Validator\ExecutionContext; -use Symfony\Component\Validator\Constraints\Range; -use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\All; use Symfony\Component\Validator\Constraints\AllValidator; +use Symfony\Component\Validator\Constraints\NotNull; +use Symfony\Component\Validator\Constraints\Range; -class AllValidatorTest extends \PHPUnit_Framework_TestCase +class AllValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() - { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new AllValidator(); - $this->validator->initialize($this->context); - - $this->context->expects($this->any()) - ->method('getGroup') - ->will($this->returnValue('MyGroup')); - } - - protected function tearDown() + protected function createValidator() { - $this->validator = null; - $this->context = null; + return new AllValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new All(new Range(array('min' => 4)))); + + $this->assertNoViolation(); } /** @@ -62,18 +45,15 @@ public function testWalkSingleConstraint($array) { $constraint = new Range(array('min' => 4)); - $i = 1; + $i = 0; foreach ($array as $key => $value) { - $this->context->expects($this->at($i++)) - ->method('validateValue') - ->with($value, $constraint, '['.$key.']', 'MyGroup'); + $this->expectValidateValueAt($i++, '['.$key.']', $value, array($constraint), 'MyGroup'); } - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($array, new All($constraint)); + + $this->assertNoViolation(); } /** @@ -85,21 +65,16 @@ public function testWalkMultipleConstraints($array) $constraint2 = new NotNull(); $constraints = array($constraint1, $constraint2); - $i = 1; + + $i = 0; foreach ($array as $key => $value) { - $this->context->expects($this->at($i++)) - ->method('validateValue') - ->with($value, $constraint1, '['.$key.']', 'MyGroup'); - $this->context->expects($this->at($i++)) - ->method('validateValue') - ->with($value, $constraint2, '['.$key.']', 'MyGroup'); + $this->expectValidateValueAt($i++, '['.$key.']', $value, array($constraint1, $constraint2), 'MyGroup'); } - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($array, new All($constraints)); + + $this->assertNoViolation(); } public function getValidArguments() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php index fe4a30b6389a0..1d83d10b0f2ad 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php @@ -14,38 +14,25 @@ use Symfony\Component\Validator\Constraints\Blank; use Symfony\Component\Validator\Constraints\BlankValidator; -class BlankValidatorTest extends \PHPUnit_Framework_TestCase +class BlankValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() - { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new BlankValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new BlankValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Blank()); + + $this->assertNoViolation(); } public function testBlankIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Blank()); + + $this->assertNoViolation(); } /** @@ -57,13 +44,12 @@ public function testInvalidValues($value, $valueAsString) 'message' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $valueAsString, - )); - $this->validator->validate($value, $constraint); + + $this->assertViolation( + 'myMessage', + array('{{ value }}' => $valueAsString) + ); } public function getInvalidValues() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php index 4d248c13c8409..038f1a39111bd 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php @@ -11,15 +11,16 @@ namespace Symfony\Component\Validator\Tests\Constraints; -use Symfony\Component\Validator\ExecutionContext; +use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Constraints\CallbackValidator; +use Symfony\Component\Validator\ExecutionContextInterface; class CallbackValidatorTest_Class { - public static function validateStatic($object, ExecutionContext $context) + public static function validateCallback($object, ExecutionContextInterface $context) { - $context->addViolation('Static message', array('{{ value }}' => 'foobar'), 'invalidValue'); + $context->addViolation('Callback message', array('{{ value }}' => 'foobar')); return false; } @@ -27,104 +28,121 @@ public static function validateStatic($object, ExecutionContext $context) class CallbackValidatorTest_Object { - public function validateOne(ExecutionContext $context) + public function validate(ExecutionContextInterface $context) { - $context->addViolation('My message', array('{{ value }}' => 'foobar'), 'invalidValue'); + $context->addViolation('My message', array('{{ value }}' => 'foobar')); return false; } - public function validateTwo(ExecutionContext $context) + public static function validateStatic(ExecutionContextInterface $context) { - $context->addViolation('Other message', array('{{ value }}' => 'baz'), 'otherInvalidValue'); + $context->addViolation('Static message', array('{{ value }}' => 'baz')); return false; } } -class CallbackValidatorTest extends \PHPUnit_Framework_TestCase +class CallbackValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function createValidator() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new CallbackValidator(); - $this->validator->initialize($this->context); + return new CallbackValidator(); } - protected function tearDown() + public function testNullIsValid() { - $this->context = null; - $this->validator = null; + $this->validator->validate(null, new Callback(array('foo'))); + + $this->assertNoViolation(); } - public function testNullIsValid() + public function testSingleMethod() { - $this->context->expects($this->never()) - ->method('addViolation'); + $object = new CallbackValidatorTest_Object(); + $constraint = new Callback(array('validate')); - $this->validator->validate(null, new Callback(array('foo'))); + $this->validator->validate($object, $constraint); + + $this->assertViolation('My message', array( + '{{ value }}' => 'foobar', + )); } - public function testCallbackSingleMethod() + public function testSingleMethodExplicitName() { $object = new CallbackValidatorTest_Object(); - $constraint = new Callback(array('validateOne')); + $constraint = new Callback(array('methods' => array('validate'))); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('My message', array( - '{{ value }}' => 'foobar', - )); + $this->validator->validate($object, $constraint); + + $this->assertViolation('My message', array( + '{{ value }}' => 'foobar', + )); + } + + public function testMultipleMethods() + { + $object = new CallbackValidatorTest_Object(); + $constraint = new Callback(array('validate', 'validateStatic')); $this->validator->validate($object, $constraint); + + $this->assertViolations(array( + $this->createViolation('My message', array( + '{{ value }}' => 'foobar', + )), + $this->createViolation('Static message', array( + '{{ value }}' => 'baz', + )), + )); } - public function testCallbackSingleStaticMethod() + public function testMultipleMethodsExplicitName() { $object = new CallbackValidatorTest_Object(); + $constraint = new Callback(array( + 'methods' => array('validate', 'validateStatic'), + )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('Static message', array( - '{{ value }}' => 'foobar', - )); + $this->validator->validate($object, $constraint); - $this->validator->validate($object, new Callback(array( - array(__CLASS__.'_Class', 'validateStatic') - ))); + $this->assertViolations(array( + $this->createViolation('My message', array( + '{{ value }}' => 'foobar', + )), + $this->createViolation('Static message', array( + '{{ value }}' => 'baz', + )), + )); } - public function testCallbackMultipleMethods() + public function testSingleStaticMethod() { $object = new CallbackValidatorTest_Object(); + $constraint = new Callback(array( + array(__CLASS__.'_Class', 'validateCallback') + )); - $this->context->expects($this->at(0)) - ->method('addViolation') - ->with('My message', array( - '{{ value }}' => 'foobar', - )); - $this->context->expects($this->at(1)) - ->method('addViolation') - ->with('Other message', array( - '{{ value }}' => 'baz', - )); + $this->validator->validate($object, $constraint); - $this->validator->validate($object, new Callback(array( - 'validateOne', 'validateTwo' - ))); + $this->assertViolation('Callback message', array( + '{{ value }}' => 'foobar', + )); } - /** - * @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException - */ - public function testExpectCallbackArray() + public function testSingleStaticMethodExplicitName() { $object = new CallbackValidatorTest_Object(); + $constraint = new Callback(array( + 'methods' => array(array(__CLASS__.'_Class', 'validateCallback')), + )); - $this->validator->validate($object, new Callback('foobar')); + $this->validator->validate($object, $constraint); + + $this->assertViolation('Callback message', array( + '{{ value }}' => 'foobar', + )); } /** @@ -151,6 +169,28 @@ public function testConstraintGetTargets() { $constraint = new Callback(array('foo')); - $this->assertEquals('class', $constraint->getTargets()); + $this->assertEquals(Constraint::CLASS_CONSTRAINT, $constraint->getTargets()); + } + + /** + * @expectedException \Symfony\Component\Validator\Exception\MissingOptionsException + */ + public function testNoConstructorArguments() + { + new Callback(); + } + + public function testAnnotationInvocationSingleValued() + { + $constraint = new Callback(array('value' => 'validateStatic')); + + $this->assertEquals(new Callback('validateStatic'), $constraint); + } + + public function testAnnotationInvocationMultiValued() + { + $constraint = new Callback(array('value' => array(__CLASS__.'_Class', 'validateCallback'))); + + $this->assertEquals(new Callback(array(__CLASS__.'_Class', 'validateCallback')), $constraint); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php index ee7cc7a60a381..0b3b04e067cd6 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php @@ -14,38 +14,25 @@ use Symfony\Component\Validator\Constraints\CardScheme; use Symfony\Component\Validator\Constraints\CardSchemeValidator; -class CardSchemeValidatorTest extends \PHPUnit_Framework_TestCase +class CardSchemeValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() - { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new CardSchemeValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new CardSchemeValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new CardScheme(array('schemes' => array()))); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new CardScheme(array('schemes' => array()))); + + $this->assertNoViolation(); } /** @@ -53,10 +40,9 @@ public function testEmptyStringIsValid() */ public function testValidNumbers($scheme, $number) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($number, new CardScheme(array('schemes' => $scheme))); + + $this->assertNoViolation(); } /** @@ -64,10 +50,16 @@ public function testValidNumbers($scheme, $number) */ public function testInvalidNumbers($scheme, $number) { - $this->context->expects($this->once()) - ->method('addViolation'); + $constraint = new CardScheme(array( + 'schemes' => $scheme, + 'message' => 'myMessage', + )); - $this->validator->validate($number, new CardScheme(array('schemes' => $scheme))); + $this->validator->validate($number, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => is_string($number) ? '"'.$number.'"' : $number, + )); } public function getValidNumbers() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php index ad524b87ea2b9..113a31e3cfc06 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php @@ -19,31 +19,16 @@ function choice_callback() return array('foo', 'bar'); } -class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase +class ChoiceValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - public static function staticCallback() - { - return array('foo', 'bar'); - } - - protected function setUp() + protected function createValidator() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new ChoiceValidator(); - $this->validator->initialize($this->context); - - $this->context->expects($this->any()) - ->method('getClassName') - ->will($this->returnValue(__CLASS__)); + return new ChoiceValidator(); } - protected function tearDown() + public static function staticCallback() { - $this->context = null; - $this->validator = null; + return array('foo', 'bar'); } /** @@ -61,10 +46,9 @@ public function testExpectArrayIfMultipleIsTrue() public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Choice(array('choices' => array('foo', 'bar')))); + + $this->assertNoViolation(); } /** @@ -87,20 +71,18 @@ public function testValidChoiceArray() { $constraint = new Choice(array('choices' => array('foo', 'bar'))); - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('bar', $constraint); + + $this->assertNoViolation(); } public function testValidChoiceCallbackFunction() { $constraint = new Choice(array('callback' => __NAMESPACE__.'\choice_callback')); - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('bar', $constraint); + + $this->assertNoViolation(); } public function testValidChoiceCallbackClosure() @@ -109,30 +91,30 @@ public function testValidChoiceCallbackClosure() return array('foo', 'bar'); })); - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('bar', $constraint); + + $this->assertNoViolation(); } public function testValidChoiceCallbackStaticMethod() { $constraint = new Choice(array('callback' => array(__CLASS__, 'staticCallback'))); - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('bar', $constraint); + + $this->assertNoViolation(); } public function testValidChoiceCallbackContextMethod() { - $constraint = new Choice(array('callback' => 'staticCallback')); + // search $this for "staticCallback" + $this->setObject($this); - $this->context->expects($this->never()) - ->method('addViolation'); + $constraint = new Choice(array('callback' => 'staticCallback')); $this->validator->validate('bar', $constraint); + + $this->assertNoViolation(); } public function testMultipleChoices() @@ -142,10 +124,9 @@ public function testMultipleChoices() 'multiple' => true, )); - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(array('baz', 'bar'), $constraint); + + $this->assertNoViolation(); } public function testInvalidChoice() @@ -155,13 +136,11 @@ public function testInvalidChoice() 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"baz"', - ), null, null); - $this->validator->validate('baz', $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"baz"', + )); } public function testInvalidChoiceMultiple() @@ -172,13 +151,11 @@ public function testInvalidChoiceMultiple() 'multiple' => true, )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"baz"', - )); - $this->validator->validate(array('foo', 'baz'), $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"baz"', + )); } public function testTooFewChoices() @@ -190,13 +167,15 @@ public function testTooFewChoices() 'minMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ limit }}' => 2, - ), null, 2); + $value = array('foo'); + + $this->setValue($value); + + $this->validator->validate($value, $constraint); - $this->validator->validate(array('foo'), $constraint); + $this->assertViolation('myMessage', array( + '{{ limit }}' => 2, + ), 'property.path', $value, 2); } public function testTooManyChoices() @@ -208,13 +187,15 @@ public function testTooManyChoices() 'maxMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ limit }}' => 2, - ), null, 2); + $value = array('foo', 'bar', 'moo'); - $this->validator->validate(array('foo', 'bar', 'moo'), $constraint); + $this->setValue($value); + + $this->validator->validate($value, $constraint); + + $this->assertViolation('myMessage', array( + '{{ limit }}' => 2, + ), 'property.path', $value, 2); } public function testNonStrict() @@ -224,11 +205,10 @@ public function testNonStrict() 'strict' => false, )); - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('2', $constraint); $this->validator->validate(2, $constraint); + + $this->assertNoViolation(); } public function testStrictAllowsExactValue() @@ -238,10 +218,9 @@ public function testStrictAllowsExactValue() 'strict' => true, )); - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(2, $constraint); + + $this->assertNoViolation(); } public function testStrictDisallowsDifferentType() @@ -252,13 +231,11 @@ public function testStrictDisallowsDifferentType() 'message' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"2"', - )); - $this->validator->validate('2', $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"2"', + )); } public function testNonStrictWithMultipleChoices() @@ -269,10 +246,9 @@ public function testNonStrictWithMultipleChoices() 'strict' => false )); - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(array('2', 3), $constraint); + + $this->assertNoViolation(); } public function testStrictWithMultipleChoices() @@ -284,12 +260,10 @@ public function testStrictWithMultipleChoices() 'multipleMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"3"', - )); - $this->validator->validate(array(2, '3'), $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"3"', + )); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php index da868d3cfdd1f..4b485a9b108b7 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CollectionTest.php @@ -12,9 +12,9 @@ namespace Symfony\Component\Validator\Tests\Constraints; use Symfony\Component\Validator\Constraints\Collection; -use Symfony\Component\Validator\Constraints\Required; -use Symfony\Component\Validator\Constraints\Optional; use Symfony\Component\Validator\Constraints\Email; +use Symfony\Component\Validator\Constraints\Optional; +use Symfony\Component\Validator\Constraints\Required; use Symfony\Component\Validator\Constraints\Valid; /** diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorCustomArrayObjectTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorCustomArrayObjectTest.php index ebad849b8b3c3..3d4c29681bf47 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorCustomArrayObjectTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorCustomArrayObjectTest.php @@ -11,63 +11,7 @@ namespace Symfony\Component\Validator\Tests\Constraints; -/** - * This class is a hand written simplified version of PHP native `ArrayObject` - * class, to show that it behaves differently than the PHP native implementation. - */ -class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable, \Serializable -{ - private $array; - - public function __construct(array $array = null) - { - $this->array = $array ?: array(); - } - - public function offsetExists($offset) - { - return array_key_exists($offset, $this->array); - } - - public function offsetGet($offset) - { - return $this->array[$offset]; - } - - public function offsetSet($offset, $value) - { - if (null === $offset) { - $this->array[] = $value; - } else { - $this->array[$offset] = $value; - } - } - - public function offsetUnset($offset) - { - unset($this->array[$offset]); - } - - public function getIterator() - { - return new \ArrayIterator($this->array); - } - - public function count() - { - return count($this->array); - } - - public function serialize() - { - return serialize($this->array); - } - - public function unserialize($serialized) - { - $this->array = (array) unserialize((string) $serialized); - } -} +use Symfony\Component\Validator\Tests\Fixtures\CustomArrayObject; class CollectionValidatorCustomArrayObjectTest extends CollectionValidatorTest { diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php index e966aadae7877..8c26957e6f412 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php @@ -11,57 +11,44 @@ namespace Symfony\Component\Validator\Tests\Constraints; -use Symfony\Component\Validator\Constraints\Range; -use Symfony\Component\Validator\Constraints\NotNull; -use Symfony\Component\Validator\Constraints\Required; -use Symfony\Component\Validator\Constraints\Optional; use Symfony\Component\Validator\Constraints\Collection; use Symfony\Component\Validator\Constraints\CollectionValidator; +use Symfony\Component\Validator\Constraints\NotNull; +use Symfony\Component\Validator\Constraints\Optional; +use Symfony\Component\Validator\Constraints\Range; +use Symfony\Component\Validator\Constraints\Required; -abstract class CollectionValidatorTest extends \PHPUnit_Framework_TestCase +abstract class CollectionValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function createValidator() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new CollectionValidator(); - $this->validator->initialize($this->context); - - $this->context->expects($this->any()) - ->method('getGroup') - ->will($this->returnValue('MyGroup')); - } - - protected function tearDown() - { - $this->context = null; - $this->validator = null; + return new CollectionValidator(); } abstract protected function prepareTestData(array $contents); public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolationAt'); - $this->validator->validate(null, new Collection(array('fields' => array( 'foo' => new Range(array('min' => 4)), )))); + + $this->assertNoViolation(); } public function testFieldsAsDefaultOption() { + $constraint = new Range(array('min' => 4)); + $data = $this->prepareTestData(array('foo' => 'foobar')); - $this->context->expects($this->never()) - ->method('addViolationAt'); + $this->expectValidateValueAt(0, '[foo]', $data['foo'], array($constraint), 'MyGroup'); $this->validator->validate($data, new Collection(array( - 'foo' => new Range(array('min' => 4)), + 'foo' => $constraint, ))); + + $this->assertNoViolation(); } /** @@ -82,25 +69,23 @@ public function testWalkSingleConstraint() 'foo' => 3, 'bar' => 5, ); - $i = 1; + + $i = 0; foreach ($array as $key => $value) { - $this->context->expects($this->at($i++)) - ->method('validateValue') - ->with($value, $constraint, '['.$key.']', 'MyGroup'); + $this->expectValidateValueAt($i++, '['.$key.']', $value, array($constraint), 'MyGroup'); } $data = $this->prepareTestData($array); - $this->context->expects($this->never()) - ->method('addViolationAt'); - $this->validator->validate($data, new Collection(array( 'fields' => array( 'foo' => $constraint, 'bar' => $constraint, ), ))); + + $this->assertNoViolation(); } public function testWalkMultipleConstraints() @@ -114,48 +99,46 @@ public function testWalkMultipleConstraints() 'foo' => 3, 'bar' => 5, ); - $i = 1; + + $i = 0; foreach ($array as $key => $value) { - foreach ($constraints as $constraint) { - $this->context->expects($this->at($i++)) - ->method('validateValue') - ->with($value, $constraint, '['.$key.']', 'MyGroup'); - } + $this->expectValidateValueAt($i++, '['.$key.']', $value, $constraints, 'MyGroup'); } $data = $this->prepareTestData($array); - $this->context->expects($this->never()) - ->method('addViolationAt'); - $this->validator->validate($data, new Collection(array( 'fields' => array( 'foo' => $constraints, 'bar' => $constraints, ) ))); + + $this->assertNoViolation(); } public function testExtraFieldsDisallowed() { + $constraint = new Range(array('min' => 4)); + $data = $this->prepareTestData(array( 'foo' => 5, 'baz' => 6, )); - $this->context->expects($this->once()) - ->method('addViolationAt') - ->with('[baz]', 'myMessage', array( - '{{ field }}' => '"baz"' - )); + $this->expectValidateValueAt(0, '[foo]', $data['foo'], array($constraint), 'MyGroup'); $this->validator->validate($data, new Collection(array( 'fields' => array( - 'foo' => new Range(array('min' => 4)), + 'foo' => $constraint, ), 'extraFieldsMessage' => 'myMessage', ))); + + $this->assertViolation('myMessage', array( + '{{ field }}' => '"baz"' + ), 'property.path[baz]', 6); } // bug fix @@ -165,16 +148,17 @@ public function testNullNotConsideredExtraField() 'foo' => null, )); - $constraint = new Collection(array( + $constraint = new Range(array('min' => 4)); + + $this->expectValidateValueAt(0, '[foo]', $data['foo'], array($constraint), 'MyGroup'); + + $this->validator->validate($data, new Collection(array( 'fields' => array( - 'foo' => new Range(array('min' => 4)), + 'foo' => $constraint, ), - )); - - $this->context->expects($this->never()) - ->method('addViolationAt'); + ))); - $this->validator->validate($data, $constraint); + $this->assertNoViolation(); } public function testExtraFieldsAllowed() @@ -184,54 +168,52 @@ public function testExtraFieldsAllowed() 'bar' => 6, )); - $constraint = new Collection(array( + $constraint = new Range(array('min' => 4)); + + $this->expectValidateValueAt(0, '[foo]', $data['foo'], array($constraint), 'MyGroup'); + + $this->validator->validate($data, new Collection(array( 'fields' => array( - 'foo' => new Range(array('min' => 4)), + 'foo' => $constraint, ), 'allowExtraFields' => true, - )); - - $this->context->expects($this->never()) - ->method('addViolationAt'); + ))); - $this->validator->validate($data, $constraint); + $this->assertNoViolation(); } public function testMissingFieldsDisallowed() { $data = $this->prepareTestData(array()); - $constraint = new Collection(array( + $constraint = new Range(array('min' => 4)); + + $this->validator->validate($data, new Collection(array( 'fields' => array( - 'foo' => new Range(array('min' => 4)), + 'foo' => $constraint, ), 'missingFieldsMessage' => 'myMessage', - )); - - $this->context->expects($this->once()) - ->method('addViolationAt') - ->with('[foo]', 'myMessage', array( - '{{ field }}' => '"foo"', - )); + ))); - $this->validator->validate($data, $constraint); + $this->assertViolation('myMessage', array( + '{{ field }}' => '"foo"' + ), 'property.path[foo]', null); } public function testMissingFieldsAllowed() { $data = $this->prepareTestData(array()); - $constraint = new Collection(array( + $constraint = new Range(array('min' => 4)); + + $this->validator->validate($data, new Collection(array( 'fields' => array( - 'foo' => new Range(array('min' => 4)), + 'foo' => $constraint, ), 'allowMissingFields' => true, - )); - - $this->context->expects($this->never()) - ->method('addViolationAt'); + ))); - $this->validator->validate($data, $constraint); + $this->assertNoViolation(); } public function testOptionalFieldPresent() @@ -240,24 +222,22 @@ public function testOptionalFieldPresent() 'foo' => null, )); - $this->context->expects($this->never()) - ->method('addViolationAt'); - $this->validator->validate($data, new Collection(array( 'foo' => new Optional(), ))); + + $this->assertNoViolation(); } public function testOptionalFieldNotPresent() { $data = $this->prepareTestData(array()); - $this->context->expects($this->never()) - ->method('addViolationAt'); - $this->validator->validate($data, new Collection(array( 'foo' => new Optional(), ))); + + $this->assertNoViolation(); } public function testOptionalFieldSingleConstraint() @@ -268,18 +248,15 @@ public function testOptionalFieldSingleConstraint() $constraint = new Range(array('min' => 4)); - $this->context->expects($this->once()) - ->method('validateValue') - ->with($array['foo'], $constraint, '[foo]', 'MyGroup'); - - $this->context->expects($this->never()) - ->method('addViolationAt'); + $this->expectValidateValueAt(0, '[foo]', $array['foo'], array($constraint), 'MyGroup'); $data = $this->prepareTestData($array); $this->validator->validate($data, new Collection(array( 'foo' => new Optional($constraint), ))); + + $this->assertNoViolation(); } public function testOptionalFieldMultipleConstraints() @@ -292,22 +269,16 @@ public function testOptionalFieldMultipleConstraints() new NotNull(), new Range(array('min' => 4)), ); - $i = 1; - - foreach ($constraints as $constraint) { - $this->context->expects($this->at($i++)) - ->method('validateValue') - ->with($array['foo'], $constraint, '[foo]', 'MyGroup'); - } - $this->context->expects($this->never()) - ->method('addViolationAt'); + $this->expectValidateValueAt(0, '[foo]', $array['foo'], $constraints, 'MyGroup'); $data = $this->prepareTestData($array); $this->validator->validate($data, new Collection(array( 'foo' => new Optional($constraints), ))); + + $this->assertNoViolation(); } public function testRequiredFieldPresent() @@ -316,30 +287,27 @@ public function testRequiredFieldPresent() 'foo' => null, )); - $this->context->expects($this->never()) - ->method('addViolationAt'); - $this->validator->validate($data, new Collection(array( 'foo' => new Required(), ))); + + $this->assertNoViolation(); } public function testRequiredFieldNotPresent() { $data = $this->prepareTestData(array()); - $this->context->expects($this->once()) - ->method('addViolationAt') - ->with('[foo]', 'myMessage', array( - '{{ field }}' => '"foo"', - )); - $this->validator->validate($data, new Collection(array( 'fields' => array( 'foo' => new Required(), ), 'missingFieldsMessage' => 'myMessage', ))); + + $this->assertViolation('myMessage', array( + '{{ field }}' => '"foo"' + ), 'property.path[foo]', null); } public function testRequiredFieldSingleConstraint() @@ -350,18 +318,15 @@ public function testRequiredFieldSingleConstraint() $constraint = new Range(array('min' => 4)); - $this->context->expects($this->once()) - ->method('validateValue') - ->with($array['foo'], $constraint, '[foo]', 'MyGroup'); - - $this->context->expects($this->never()) - ->method('addViolationAt'); + $this->expectValidateValueAt(0, '[foo]', $array['foo'], array($constraint), 'MyGroup'); $data = $this->prepareTestData($array); $this->validator->validate($data, new Collection(array( 'foo' => new Required($constraint), ))); + + $this->assertNoViolation(); } public function testRequiredFieldMultipleConstraints() @@ -374,22 +339,16 @@ public function testRequiredFieldMultipleConstraints() new NotNull(), new Range(array('min' => 4)), ); - $i = 1; - - foreach ($constraints as $constraint) { - $this->context->expects($this->at($i++)) - ->method('validateValue') - ->with($array['foo'], $constraint, '[foo]', 'MyGroup'); - } - $this->context->expects($this->never()) - ->method('addViolationAt'); + $this->expectValidateValueAt(0, '[foo]', $array['foo'], $constraints, 'MyGroup'); $data = $this->prepareTestData($array); - $this->validator->validate($array, new Collection(array( + $this->validator->validate($data, new Collection(array( 'foo' => new Required($constraints), ))); + + $this->assertNoViolation(); } public function testObjectShouldBeLeftUnchanged() @@ -398,9 +357,13 @@ public function testObjectShouldBeLeftUnchanged() 'foo' => 3 )); + $constraint = new Range(array('min' => 2)); + + $this->expectValidateValueAt(0, '[foo]', $value['foo'], array($constraint), 'MyGroup'); + $this->validator->validate($value, new Collection(array( 'fields' => array( - 'foo' => new Range(array('min' => 2)), + 'foo' => $constraint, ) ))); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorCountableTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorCountableTest.php index ec4d8dec7112c..7d46967bde483 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorCountableTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorCountableTest.php @@ -11,20 +11,7 @@ namespace Symfony\Component\Validator\Tests\Constraints; -class CountValidatorCountableTest_Countable implements \Countable -{ - private $content; - - public function __construct(array $content) - { - $this->content = $content; - } - - public function count() - { - return count($this->content); - } -} +use Symfony\Component\Validator\Tests\Fixtures\Countable; /** * @author Bernhard Schussek @@ -33,6 +20,6 @@ class CountValidatorCountableTest extends CountValidatorTest { protected function createCollection(array $content) { - return new CountValidatorCountableTest_Countable($content); + return new Countable($content); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php index 9c4a38d56c7e3..c910c1156ccc2 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php @@ -17,32 +17,20 @@ /** * @author Bernhard Schussek */ -abstract class CountValidatorTest extends \PHPUnit_Framework_TestCase +abstract class CountValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() - { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new CountValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new CountValidator(); } abstract protected function createCollection(array $content); public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Count(6)); + + $this->assertNoViolation(); } /** @@ -93,11 +81,10 @@ public function getFiveOrMoreElements() */ public function testValidValuesMax($value) { - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Count(array('max' => 3)); $this->validator->validate($value, $constraint); + + $this->assertNoViolation(); } /** @@ -105,11 +92,10 @@ public function testValidValuesMax($value) */ public function testValidValuesMin($value) { - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Count(array('min' => 5)); $this->validator->validate($value, $constraint); + + $this->assertNoViolation(); } /** @@ -117,11 +103,10 @@ public function testValidValuesMin($value) */ public function testValidValuesExact($value) { - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Count(4); $this->validator->validate($value, $constraint); + + $this->assertNoViolation(); } /** @@ -134,14 +119,12 @@ public function testInvalidValuesMax($value) 'maxMessage' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', $this->identicalTo(array( - '{{ count }}' => count($value), - '{{ limit }}' => 4, - )), $value, 4); - $this->validator->validate($value, $constraint); + + $this->assertViolation('myMessage', array( + '{{ count }}' => count($value), + '{{ limit }}' => 4, + ), 'property.path', $value, 4); } /** @@ -154,14 +137,12 @@ public function testInvalidValuesMin($value) 'minMessage' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', $this->identicalTo(array( - '{{ count }}' => count($value), - '{{ limit }}' => 4, - )), $value, 4); - $this->validator->validate($value, $constraint); + + $this->assertViolation('myMessage', array( + '{{ count }}' => count($value), + '{{ limit }}' => 4, + ), 'property.path', $value, 4); } /** @@ -175,14 +156,12 @@ public function testInvalidValuesExact($value) 'exactMessage' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', $this->identicalTo(array( + $this->validator->validate($value, $constraint); + + $this->assertViolation('myMessage', array( '{{ count }}' => count($value), '{{ limit }}' => 4, - )), $value, 4); - - $this->validator->validate($value, $constraint); + ), 'property.path', $value, 4); } public function testDefaultOption() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php index 5fabee67fb399..a080852c2acd1 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php @@ -15,40 +15,32 @@ use Symfony\Component\Validator\Constraints\Country; use Symfony\Component\Validator\Constraints\CountryValidator; -class CountryValidatorTest extends \PHPUnit_Framework_TestCase +class CountryValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - protected function setUp() { - IntlTestHelper::requireIntl($this); + IntlTestHelper::requireFullIntl($this); - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new CountryValidator(); - $this->validator->initialize($this->context); + parent::setUp(); } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new CountryValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Country()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Country()); + + $this->assertNoViolation(); } /** @@ -64,10 +56,9 @@ public function testExpectsStringCompatibleType() */ public function testValidCountries($country) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($country, new Country()); + + $this->assertNoViolation(); } public function getValidCountries() @@ -88,13 +79,11 @@ public function testInvalidCountries($country) 'message' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $country, - )); - $this->validator->validate($country, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => $country, + )); } public function getInvalidCountries() @@ -113,9 +102,9 @@ public function testValidateUsingCountrySpecificLocale() \Locale::setDefault('en_GB'); $existingCountry = 'GB'; - $this->context->expects($this->never()) - ->method('addViolation'); $this->validator->validate($existingCountry, new Country()); + + $this->assertNoViolation(); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php index ea6c2eb43ac02..99636e6ca4f06 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php @@ -15,40 +15,32 @@ use Symfony\Component\Validator\Constraints\Currency; use Symfony\Component\Validator\Constraints\CurrencyValidator; -class CurrencyValidatorTest extends \PHPUnit_Framework_TestCase +class CurrencyValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - protected function setUp() { - IntlTestHelper::requireIntl($this); + IntlTestHelper::requireFullIntl($this); - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new CurrencyValidator(); - $this->validator->initialize($this->context); + parent::setUp(); } - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new CurrencyValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Currency()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Currency()); + + $this->assertNoViolation(); } /** @@ -64,10 +56,9 @@ public function testExpectsStringCompatibleType() */ public function testValidCurrencies($currency) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($currency, new Currency()); + + $this->assertNoViolation(); } /** @@ -76,10 +67,10 @@ public function testValidCurrencies($currency) public function testValidCurrenciesWithCountrySpecificLocale($currency) { \Locale::setDefault('en_GB'); - $this->context->expects($this->never()) - ->method('addViolation'); $this->validator->validate($currency, new Currency()); + + $this->assertNoViolation(); } public function getValidCurrencies() @@ -102,13 +93,11 @@ public function testInvalidCurrencies($currency) 'message' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $currency, - )); - $this->validator->validate($currency, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => $currency, + )); } public function getInvalidCurrencies() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php index 46079a8155020..5addbf34de874 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php @@ -14,46 +14,32 @@ use Symfony\Component\Validator\Constraints\DateTime; use Symfony\Component\Validator\Constraints\DateTimeValidator; -class DateTimeValidatorTest extends \PHPUnit_Framework_TestCase +class DateTimeValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() - { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new DateTimeValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new DateTimeValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new DateTime()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new DateTime()); + + $this->assertNoViolation(); } public function testDateTimeClassIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(new \DateTime(), new DateTime()); + + $this->assertNoViolation(); } /** @@ -69,10 +55,9 @@ public function testExpectsStringCompatibleType() */ public function testValidDateTimes($dateTime) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($dateTime, new DateTime()); + + $this->assertNoViolation(); } public function getValidDateTimes() @@ -93,13 +78,11 @@ public function testInvalidDateTimes($dateTime) 'message' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"'.$dateTime.'"', - )); - $this->validator->validate($dateTime, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$dateTime.'"', + )); } public function getInvalidDateTimes() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php index a62426ec8a58f..8fdacee94d490 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php @@ -14,46 +14,32 @@ use Symfony\Component\Validator\Constraints\Date; use Symfony\Component\Validator\Constraints\DateValidator; -class DateValidatorTest extends \PHPUnit_Framework_TestCase +class DateValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() - { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new DateValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new DateValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Date()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Date()); + + $this->assertNoViolation(); } public function testDateTimeClassIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(new \DateTime(), new Date()); + + $this->assertNoViolation(); } /** @@ -69,10 +55,9 @@ public function testExpectsStringCompatibleType() */ public function testValidDates($date) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($date, new Date()); + + $this->assertNoViolation(); } public function getValidDates() @@ -93,13 +78,11 @@ public function testInvalidDates($date) 'message' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"'.$date.'"', - )); - $this->validator->validate($date, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$date.'"', + )); } public function getInvalidDates() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php index 4b7a8bd6c39b2..e4722e159e5b3 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php @@ -14,38 +14,25 @@ use Symfony\Component\Validator\Constraints\Email; use Symfony\Component\Validator\Constraints\EmailValidator; -class EmailValidatorTest extends \PHPUnit_Framework_TestCase +class EmailValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() - { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new EmailValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new EmailValidator(false); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Email()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Email()); + + $this->assertNoViolation(); } /** @@ -61,10 +48,9 @@ public function testExpectsStringCompatibleType() */ public function testValidEmails($email) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($email, new Email()); + + $this->assertNoViolation(); } public function getValidEmails() @@ -85,13 +71,11 @@ public function testInvalidEmails($email) 'message' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"'.$email.'"', - )); - $this->validator->validate($email, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$email.'"', + )); } public function getInvalidEmails() @@ -100,7 +84,6 @@ public function getInvalidEmails() array('example'), array('example@'), array('example@localhost'), - array('example@example.com@example.com'), ); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php index 22ab63a9e2def..e9abbb9a386cc 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php @@ -14,38 +14,25 @@ use Symfony\Component\Validator\Constraints\False; use Symfony\Component\Validator\Constraints\FalseValidator; -class FalseValidatorTest extends \PHPUnit_Framework_TestCase +class FalseValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() - { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new FalseValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new FalseValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new False()); + + $this->assertNoViolation(); } public function testFalseIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(false, new False()); + + $this->assertNoViolation(); } public function testTrueIsInvalid() @@ -54,10 +41,10 @@ public function testTrueIsInvalid() 'message' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array('{{ value }}' => 'true')); - $this->validator->validate(true, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => 'true' + )); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorPathTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorPathTest.php index 7701d7faf42ea..f1f8db692a60a 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorPathTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorPathTest.php @@ -26,12 +26,10 @@ public function testFileNotFound() 'notFoundMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ file }}' => '"foobar"', - )); - $this->validator->validate('foobar', $constraint); + + $this->assertViolation('myMessage', array( + '{{ file }}' => '"foobar"', + )); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php index 47952f061cab0..6c8cb8abbb26a 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php @@ -11,54 +11,63 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\Validator\Constraints\File; use Symfony\Component\Validator\Constraints\FileValidator; -use Symfony\Component\HttpFoundation\File\UploadedFile; +use Symfony\Component\Validator\Validation; -abstract class FileValidatorTest extends \PHPUnit_Framework_TestCase +abstract class FileValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; protected $path; + protected $file; + protected function getApiVersion() + { + return Validation::API_VERSION_2_5; + } + + protected function createValidator() + { + return new FileValidator(); + } + protected function setUp() { - if (!class_exists('Symfony\Component\HttpFoundation\File\UploadedFile')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } + parent::setUp(); - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new FileValidator(); - $this->validator->initialize($this->context); $this->path = sys_get_temp_dir().DIRECTORY_SEPARATOR.'FileValidatorTest'; $this->file = fopen($this->path, 'w'); } protected function tearDown() { - fclose($this->file); + parent::tearDown(); + + if (is_resource($this->file)) { + fclose($this->file); + } + + if (file_exists($this->path)) { + unlink($this->path); + } - $this->context = null; - $this->validator = null; $this->path = null; $this->file = null; } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new File()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new File()); + + $this->assertNoViolation(); } /** @@ -71,82 +80,138 @@ public function testExpectsStringCompatibleTypeOrFile() public function testValidFile() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($this->path, new File()); + + $this->assertNoViolation(); } public function testValidUploadedfile() { - $this->context->expects($this->never()) - ->method('addViolation'); - $file = new UploadedFile($this->path, 'originalName', null, null, null, true); $this->validator->validate($file, new File()); + + $this->assertNoViolation(); } - public function testTooLargeBytes() + public function provideMaxSizeExceededTests() { - fwrite($this->file, str_repeat('0', 11)); - - $constraint = new File(array( - 'maxSize' => 10, - 'maxSizeMessage' => 'myMessage', - )); - - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ limit }}' => '10', - '{{ size }}' => '11', - '{{ suffix }}' => 'bytes', - '{{ file }}' => '"'.$this->path.'"', - )); - - $this->validator->validate($this->getFile($this->path), $constraint); + // We have various interesting limit - size combinations to test. + // Assume a limit of 1000 bytes (1 kB). Then the following table + // lists the violation messages for different file sizes: + + // -----------+-------------------------------------------------------- + // Size | Violation Message + // -----------+-------------------------------------------------------- + // 1000 bytes | No violation + // 1001 bytes | "Size of 1001 bytes exceeded limit of 1000 bytes" + // 1004 bytes | "Size of 1004 bytes exceeded limit of 1000 bytes" + // | NOT: "Size of 1 kB exceeded limit of 1 kB" + // 1005 bytes | "Size of 1.01 kB exceeded limit of 1 kB" + // -----------+-------------------------------------------------------- + + // As you see, we have two interesting borders: + + // 1000/1001 - The border as of which a violation occurs + // 1004/1005 - The border as of which the message can be rounded to kB + + // Analogous for kB/MB. + + // Prior to Symfony 2.5, violation messages are always displayed in the + // same unit used to specify the limit. + + // As of Symfony 2.5, the above logic is implemented. + return array( + // limit in bytes + array(1001, 1000, '1001', '1000', 'bytes'), + array(1004, 1000, '1004', '1000', 'bytes'), + array(1005, 1000, '1005', '1000', 'bytes'), + + array(1000001, 1000000, '1000001', '1000000', 'bytes'), + array(1004999, 1000000, '1004999', '1000000', 'bytes'), + array(1005000, 1000000, '1005000', '1000000', 'bytes'), + + // limit in kB + //array(1001, '1k') OK in 2.4, not in 2.5 + //array(1004, '1k') OK in 2.4, not in 2.5 + array(1005, '1k', '1.01', '1', 'kB'), + + //array(1000001, '1000k') OK in 2.4, not in 2.5 + array(1004999, '1000k', '1005', '1000', 'kB'), + array(1005000, '1000k', '1005', '1000', 'kB'), + + // limit in MB + //array(1000001, '1M') OK in 2.4, not in 2.5 + //array(1004999, '1M') OK in 2.4, not in 2.5 + array(1005000, '1M', '1.01', '1', 'MB'), + ); } - public function testTooLargeKiloBytes() + /** + * @dataProvider provideMaxSizeExceededTests + */ + public function testMaxSizeExceeded($bytesWritten, $limit, $sizeAsString, $limitAsString, $suffix) { - fwrite($this->file, str_repeat('0', 1400)); + fseek($this->file, $bytesWritten-1, SEEK_SET); + fwrite($this->file, '0'); + fclose($this->file); $constraint = new File(array( - 'maxSize' => '1k', + 'maxSize' => $limit, 'maxSizeMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ limit }}' => '1', - '{{ size }}' => '1.4', - '{{ suffix }}' => 'kB', - '{{ file }}' => '"'.$this->path.'"', - )); - $this->validator->validate($this->getFile($this->path), $constraint); + + $this->assertViolation('myMessage', array( + '{{ limit }}' => $limitAsString, + '{{ size }}' => $sizeAsString, + '{{ suffix }}' => $suffix, + '{{ file }}' => '"'.$this->path.'"', + )); + } + + public function provideMaxSizeNotExceededTests() + { + return array( + // limit in bytes + array(1000, 1000), + array(1000000, 1000000), + + // limit in kB + array(1000, '1k'), + array(1000000, '1000k'), + + // as of Symfony 2.5, the following are not accepted anymore + array(1001, '1k'), + array(1004, '1k'), + array(1000001, '1000k'), + + // limit in MB + array(1000000, '1M'), + + // as of Symfony 2.5, the following are not accepted anymore + array(1000001, '1M'), + array(1004999, '1M'), + ); } - public function testTooLargeMegaBytes() + /** + * @dataProvider provideMaxSizeNotExceededTests + */ + public function testMaxSizeNotExceeded($bytesWritten, $limit) { - fwrite($this->file, str_repeat('0', 1400000)); + fseek($this->file, $bytesWritten-1, SEEK_SET); + fwrite($this->file, '0'); + fclose($this->file); $constraint = new File(array( - 'maxSize' => '1M', + 'maxSize' => $limit, 'maxSizeMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ limit }}' => '1', - '{{ size }}' => '1.4', - '{{ suffix }}' => 'MB', - '{{ file }}' => '"'.$this->path.'"', - )); - $this->validator->validate($this->getFile($this->path), $constraint); + + $this->assertNoViolation(); } /** @@ -179,14 +244,13 @@ public function testValidMimeType() ->will($this->returnValue('image/jpg')) ; - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new File(array( 'mimeTypes' => array('image/png', 'image/jpg'), )); $this->validator->validate($file, $constraint); + + $this->assertNoViolation(); } public function testValidWildcardMimeType() @@ -207,14 +271,13 @@ public function testValidWildcardMimeType() ->will($this->returnValue('image/jpg')) ; - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new File(array( 'mimeTypes' => array('image/*'), )); $this->validator->validate($file, $constraint); + + $this->assertNoViolation(); } public function testInvalidMimeType() @@ -240,15 +303,13 @@ public function testInvalidMimeType() 'mimeTypesMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ type }}' => '"application/pdf"', - '{{ types }}' => '"image/png", "image/jpg"', - '{{ file }}' => '"'.$this->path.'"', - )); - $this->validator->validate($file, $constraint); + + $this->assertViolation('myMessage', array( + '{{ type }}' => '"application/pdf"', + '{{ types }}' => '"image/png", "image/jpg"', + '{{ file }}' => '"'.$this->path.'"', + )); } public function testInvalidWildcardMimeType() @@ -274,15 +335,13 @@ public function testInvalidWildcardMimeType() 'mimeTypesMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ type }}' => '"application/pdf"', - '{{ types }}' => '"image/*", "image/jpg"', - '{{ file }}' => '"'.$this->path.'"', - )); - $this->validator->validate($file, $constraint); + + $this->assertViolation('myMessage', array( + '{{ type }}' => '"application/pdf"', + '{{ types }}' => '"image/*", "image/jpg"', + '{{ file }}' => '"'.$this->path.'"', + )); } /** @@ -297,12 +356,10 @@ public function testUploadedFileError($error, $message, array $params = array(), 'maxSize' => $maxSize )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', $params); - $this->validator->validate($file, $constraint); + $this->assertViolation('myMessage', $params); + } public function uploadedFileErrorProvider() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/Fixtures/test_landscape.gif b/src/Symfony/Component/Validator/Tests/Constraints/Fixtures/test_landscape.gif new file mode 100644 index 0000000000000000000000000000000000000000..870123532c3b97be8e2ab75452eca7060fb474c4 GIT binary patch literal 43 qcmZ?wbhEHbWMW`sXkcLY4+e@qSs1y10y+#p0Fq%~V)Ef)um%7ZunH6a literal 0 HcmV?d00001 diff --git a/src/Symfony/Component/Validator/Tests/Constraints/Fixtures/test_portrait.gif b/src/Symfony/Component/Validator/Tests/Constraints/Fixtures/test_portrait.gif new file mode 100644 index 0000000000000000000000000000000000000000..cc480ca88ed7fa80ff8e3907ba14d692e3e9d3d4 GIT binary patch literal 43 rcmZ?wbhEHbWMp7sXkcLY4+e@qSs1w(7#VaJfB+=Jz{KRk#b6Bp7pw{t literal 0 HcmV?d00001 diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GroupSequenceTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GroupSequenceTest.php new file mode 100644 index 0000000000000..b3e8ec219169a --- /dev/null +++ b/src/Symfony/Component/Validator/Tests/Constraints/GroupSequenceTest.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Constraints; + +use Symfony\Component\Validator\Constraints\GroupSequence; + +/** + * @author Bernhard Schussek + */ +class GroupSequenceTest extends \PHPUnit_Framework_TestCase +{ + public function testCreateDoctrineStyle() + { + $sequence = new GroupSequence(array('value' => array('Group 1', 'Group 2'))); + + $this->assertSame(array('Group 1', 'Group 2'), $sequence->groups); + } +} diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php index 49b39430178d8..8cf7f5ae53c59 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php @@ -13,31 +13,27 @@ use Symfony\Component\Validator\Constraints\Iban; use Symfony\Component\Validator\Constraints\IbanValidator; +use Symfony\Component\Validator\Validation; -class IbanValidatorTest extends \PHPUnit_Framework_TestCase +class IbanValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function createValidator() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new IbanValidator(); - $this->validator->initialize($this->context); + return new IbanValidator(); } public function testNullIsValid() { - $this->context->expects($this->never())->method('addViolation'); - $this->validator->validate(null, new Iban()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never())->method('addViolation'); - $this->validator->validate('', new Iban()); + + $this->assertNoViolation(); } /** @@ -45,9 +41,9 @@ public function testEmptyStringIsValid() */ public function testValidIbans($iban) { - $this->context->expects($this->never())->method('addViolation'); - $this->validator->validate($iban, new Iban()); + + $this->assertNoViolation(); } public function getValidIbans() @@ -161,13 +157,11 @@ public function testInvalidIbans($iban) 'message' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"'.$iban.'"', - )); - $this->validator->validate($iban, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$iban.'"', + )); } public function getInvalidIbans() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php index 88545016243d1..01f1a06199c46 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php @@ -13,59 +13,54 @@ use Symfony\Component\Validator\Constraints\Image; use Symfony\Component\Validator\Constraints\ImageValidator; +use Symfony\Component\Validator\Validation; -class ImageValidatorTest extends \PHPUnit_Framework_TestCase +class ImageValidatorTest extends AbstractConstraintValidatorTest { protected $context; protected $validator; protected $path; protected $image; + protected $imageLandscape; + protected $imagePortrait; + + protected function createValidator() + { + return new ImageValidator(); + } protected function setUp() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new ImageValidator(); - $this->validator->initialize($this->context); + parent::setUp(); + $this->image = __DIR__.'/Fixtures/test.gif'; + $this->imageLandscape = __DIR__.'/Fixtures/test_landscape.gif'; + $this->imagePortrait = __DIR__.'/Fixtures/test_portrait.gif'; } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Image()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Image()); + + $this->assertNoViolation(); } public function testValidImage() { - if (!class_exists('Symfony\Component\HttpFoundation\File\File')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($this->image, new Image()); + + $this->assertNoViolation(); } public function testValidSize() { - if (!class_exists('Symfony\Component\HttpFoundation\File\File')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Image(array( 'minWidth' => 1, 'maxWidth' => 2, @@ -74,90 +69,68 @@ public function testValidSize() )); $this->validator->validate($this->image, $constraint); + + $this->assertNoViolation(); } public function testWidthTooSmall() { - if (!class_exists('Symfony\Component\HttpFoundation\File\File')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - $constraint = new Image(array( 'minWidth' => 3, 'minWidthMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ width }}' => '2', - '{{ min_width }}' => '3', - )); - $this->validator->validate($this->image, $constraint); + + $this->assertViolation('myMessage', array( + '{{ width }}' => '2', + '{{ min_width }}' => '3', + )); } public function testWidthTooBig() { - if (!class_exists('Symfony\Component\HttpFoundation\File\File')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - $constraint = new Image(array( 'maxWidth' => 1, 'maxWidthMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ width }}' => '2', - '{{ max_width }}' => '1', - )); - $this->validator->validate($this->image, $constraint); + + $this->assertViolation('myMessage', array( + '{{ width }}' => '2', + '{{ max_width }}' => '1', + )); } public function testHeightTooSmall() { - if (!class_exists('Symfony\Component\HttpFoundation\File\File')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - $constraint = new Image(array( 'minHeight' => 3, 'minHeightMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ height }}' => '2', - '{{ min_height }}' => '3', - )); - $this->validator->validate($this->image, $constraint); + + $this->assertViolation('myMessage', array( + '{{ height }}' => '2', + '{{ min_height }}' => '3', + )); } public function testHeightTooBig() { - if (!class_exists('Symfony\Component\HttpFoundation\File\File')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - $constraint = new Image(array( 'maxHeight' => 1, 'maxHeightMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ height }}' => '2', - '{{ max_height }}' => '1', - )); - $this->validator->validate($this->image, $constraint); + + $this->assertViolation('myMessage', array( + '{{ height }}' => '2', + '{{ max_height }}' => '1', + )); } /** @@ -165,10 +138,6 @@ public function testHeightTooBig() */ public function testInvalidMinWidth() { - if (!class_exists('Symfony\Component\HttpFoundation\File\File')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - $constraint = new Image(array( 'minWidth' => '1abc', )); @@ -181,10 +150,6 @@ public function testInvalidMinWidth() */ public function testInvalidMaxWidth() { - if (!class_exists('Symfony\Component\HttpFoundation\File\File')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - $constraint = new Image(array( 'maxWidth' => '1abc', )); @@ -197,10 +162,6 @@ public function testInvalidMaxWidth() */ public function testInvalidMinHeight() { - if (!class_exists('Symfony\Component\HttpFoundation\File\File')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - $constraint = new Image(array( 'minHeight' => '1abc', )); @@ -213,10 +174,6 @@ public function testInvalidMinHeight() */ public function testInvalidMaxHeight() { - if (!class_exists('Symfony\Component\HttpFoundation\File\File')) { - $this->markTestSkipped('The "HttpFoundation" component is not available'); - } - $constraint = new Image(array( 'maxHeight' => '1abc', )); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php index 25cd5d44f840a..bc849278de59f 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php @@ -13,39 +13,27 @@ use Symfony\Component\Validator\Constraints\Ip; use Symfony\Component\Validator\Constraints\IpValidator; +use Symfony\Component\Validator\Validation; -class IpValidatorTest extends \PHPUnit_Framework_TestCase +class IpValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() - { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new IpValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new IpValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Ip()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Ip()); + + $this->assertNoViolation(); } /** @@ -61,7 +49,7 @@ public function testExpectsStringCompatibleType() */ public function testInvalidValidatorVersion() { - $ip = new Ip(array( + new Ip(array( 'version' => 666, )); } @@ -71,12 +59,11 @@ public function testInvalidValidatorVersion() */ public function testValidIpsV4($ip) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($ip, new Ip(array( 'version' => Ip::V4, ))); + + $this->assertNoViolation(); } public function getValidIpsV4() @@ -98,12 +85,11 @@ public function getValidIpsV4() */ public function testValidIpsV6($ip) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($ip, new Ip(array( 'version' => Ip::V6, ))); + + $this->assertNoViolation(); } public function getValidIpsV6() @@ -136,12 +122,11 @@ public function getValidIpsV6() */ public function testValidIpsAll($ip) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($ip, new Ip(array( 'version' => Ip::ALL, ))); + + $this->assertNoViolation(); } public function getValidIpsAll() @@ -159,13 +144,11 @@ public function testInvalidIpsV4($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"'.$ip.'"', - )); - $this->validator->validate($ip, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$ip.'"', + )); } public function getInvalidIpsV4() @@ -193,13 +176,11 @@ public function testInvalidPrivateIpsV4($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"'.$ip.'"', - )); - $this->validator->validate($ip, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$ip.'"', + )); } public function getInvalidPrivateIpsV4() @@ -221,13 +202,11 @@ public function testInvalidReservedIpsV4($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"'.$ip.'"', - )); - $this->validator->validate($ip, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$ip.'"', + )); } public function getInvalidReservedIpsV4() @@ -249,13 +228,11 @@ public function testInvalidPublicIpsV4($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"'.$ip.'"', - )); - $this->validator->validate($ip, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$ip.'"', + )); } public function getInvalidPublicIpsV4() @@ -273,13 +250,11 @@ public function testInvalidIpsV6($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"'.$ip.'"', - )); - $this->validator->validate($ip, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$ip.'"', + )); } public function getInvalidIpsV6() @@ -311,13 +286,11 @@ public function testInvalidPrivateIpsV6($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"'.$ip.'"', - )); - $this->validator->validate($ip, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$ip.'"', + )); } public function getInvalidPrivateIpsV6() @@ -339,13 +312,11 @@ public function testInvalidReservedIpsV6($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"'.$ip.'"', - )); - $this->validator->validate($ip, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$ip.'"', + )); } public function getInvalidReservedIpsV6() @@ -366,13 +337,11 @@ public function testInvalidPublicIpsV6($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"'.$ip.'"', - )); - $this->validator->validate($ip, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$ip.'"', + )); } public function getInvalidPublicIpsV6() @@ -390,13 +359,11 @@ public function testInvalidIpsAll($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"'.$ip.'"', - )); - $this->validator->validate($ip, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$ip.'"', + )); } public function getInvalidIpsAll() @@ -414,13 +381,11 @@ public function testInvalidPrivateIpsAll($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"'.$ip.'"', - )); - $this->validator->validate($ip, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$ip.'"', + )); } public function getInvalidPrivateIpsAll() @@ -438,13 +403,11 @@ public function testInvalidReservedIpsAll($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"'.$ip.'"', - )); - $this->validator->validate($ip, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$ip.'"', + )); } public function getInvalidReservedIpsAll() @@ -462,13 +425,11 @@ public function testInvalidPublicIpsAll($ip) 'message' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"'.$ip.'"', - )); - $this->validator->validate($ip, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$ip.'"', + )); } public function getInvalidPublicIpsAll() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php index 049a9ac3eebc2..bb49937dfdbf2 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php @@ -13,20 +13,16 @@ use Symfony\Component\Validator\Constraints\Isbn; use Symfony\Component\Validator\Constraints\IsbnValidator; +use Symfony\Component\Validator\Validation; /** * @see https://en.wikipedia.org/wiki/Isbn */ -class IsbnValidatorTest extends \PHPUnit_Framework_TestCase +class IsbnValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - public function setUp() + protected function createValidator() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new IsbnValidator(); - $this->validator->initialize($this->context); + return new IsbnValidator(); } public function getValidIsbn10() @@ -44,6 +40,7 @@ public function getValidIsbn10() array('0321812700'), array('0-45122-5244'), array('0-4712-92311'), + array('0-9752298-0-X') ); } @@ -58,6 +55,7 @@ public function getInvalidIsbn10() array('0-4X19-92611'), array('0_45122_5244'), array('2870#971#648'), + //array('0-9752298-0-x'), array('1A34567890'), // chr(1) evaluates to 0 // 2070546810 is valid @@ -122,21 +120,19 @@ public function getInvalidIsbn() public function testNullIsValid() { $constraint = new Isbn(true); - $this->context - ->expects($this->never()) - ->method('addViolation'); $this->validator->validate(null, $constraint); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { $constraint = new Isbn(true); - $this->context - ->expects($this->never()) - ->method('addViolation'); $this->validator->validate('', $constraint); + + $this->assertNoViolation(); } /** @@ -145,6 +141,7 @@ public function testEmptyStringIsValid() public function testExpectsStringCompatibleType() { $constraint = new Isbn(true); + $this->validator->validate(new \stdClass(), $constraint); } @@ -153,12 +150,13 @@ public function testExpectsStringCompatibleType() */ public function testValidIsbn10($isbn) { - $constraint = new Isbn(array('isbn10' => true)); - $this->context - ->expects($this->never()) - ->method('addViolation'); + $constraint = new Isbn(array( + 'isbn10' => true, + )); $this->validator->validate($isbn, $constraint); + + $this->assertNoViolation(); } /** @@ -166,13 +164,16 @@ public function testValidIsbn10($isbn) */ public function testInvalidIsbn10($isbn) { - $constraint = new Isbn(array('isbn10' => true)); - $this->context - ->expects($this->once()) - ->method('addViolation') - ->with($constraint->isbn10Message); + $constraint = new Isbn(array( + 'isbn10' => true, + 'isbn10Message' => 'myMessage', + )); $this->validator->validate($isbn, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$isbn.'"', + )); } /** @@ -180,12 +181,11 @@ public function testInvalidIsbn10($isbn) */ public function testValidIsbn13($isbn) { - $constraint = new Isbn(array('isbn13' => true)); - $this->context - ->expects($this->never()) - ->method('addViolation'); + $constraint = new Isbn(array('isbn13' => true,)); $this->validator->validate($isbn, $constraint); + + $this->assertNoViolation(); } /** @@ -193,13 +193,16 @@ public function testValidIsbn13($isbn) */ public function testInvalidIsbn13($isbn) { - $constraint = new Isbn(array('isbn13' => true)); - $this->context - ->expects($this->once()) - ->method('addViolation') - ->with($constraint->isbn13Message); + $constraint = new Isbn(array( + 'isbn13' => true, + 'isbn13Message' => 'myMessage', + )); $this->validator->validate($isbn, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$isbn.'"', + )); } /** @@ -207,12 +210,14 @@ public function testInvalidIsbn13($isbn) */ public function testValidIsbn($isbn) { - $constraint = new Isbn(array('isbn10' => true, 'isbn13' => true)); - $this->context - ->expects($this->never()) - ->method('addViolation'); + $constraint = new Isbn(array( + 'isbn10' => true, + 'isbn13' => true, + )); $this->validator->validate($isbn, $constraint); + + $this->assertNoViolation(); } /** @@ -220,12 +225,16 @@ public function testValidIsbn($isbn) */ public function testInvalidIsbn($isbn) { - $constraint = new Isbn(array('isbn10' => true, 'isbn13' => true)); - $this->context - ->expects($this->once()) - ->method('addViolation') - ->with($constraint->bothIsbnMessage); + $constraint = new Isbn(array( + 'isbn10' => true, + 'isbn13' => true, + 'bothIsbnMessage' => 'myMessage', + )); $this->validator->validate($isbn, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$isbn.'"', + )); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php index 3f53e738b3bf7..b48357a880cd2 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php @@ -13,20 +13,16 @@ use Symfony\Component\Validator\Constraints\Issn; use Symfony\Component\Validator\Constraints\IssnValidator; +use Symfony\Component\Validator\Validation; /** * @see https://en.wikipedia.org/wiki/Issn */ -class IssnValidatorTest extends \PHPUnit_Framework_TestCase +class IssnValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - public function setUp() + protected function createValidator() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new IssnValidator(); - $this->validator->initialize($this->context); + return new IssnValidator(); } public function getValidLowerCasedIssn() @@ -110,21 +106,19 @@ public function getInvalidIssn() public function testNullIsValid() { $constraint = new Issn(); - $this->context - ->expects($this->never()) - ->method('addViolation'); $this->validator->validate(null, $constraint); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { $constraint = new Issn(); - $this->context - ->expects($this->never()) - ->method('addViolation'); $this->validator->validate('', $constraint); + + $this->assertNoViolation(); } /** @@ -141,13 +135,16 @@ public function testExpectsStringCompatibleType() */ public function testCaseSensitiveIssns($issn) { - $constraint = new Issn(array('caseSensitive' => true)); - $this->context - ->expects($this->once()) - ->method('addViolation') - ->with($constraint->message); + $constraint = new Issn(array( + 'caseSensitive' => true, + 'message' => 'myMessage', + )); $this->validator->validate($issn, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$issn.'"', + )); } /** @@ -155,13 +152,16 @@ public function testCaseSensitiveIssns($issn) */ public function testRequireHyphenIssns($issn) { - $constraint = new Issn(array('requireHyphen' => true)); - $this->context - ->expects($this->once()) - ->method('addViolation') - ->with($constraint->message); + $constraint = new Issn(array( + 'requireHyphen' => true, + 'message' => 'myMessage', + )); $this->validator->validate($issn, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$issn.'"', + )); } /** @@ -170,11 +170,10 @@ public function testRequireHyphenIssns($issn) public function testValidIssn($issn) { $constraint = new Issn(); - $this->context - ->expects($this->never()) - ->method('addViolation'); $this->validator->validate($issn, $constraint); + + $this->assertNoViolation(); } /** @@ -182,13 +181,15 @@ public function testValidIssn($issn) */ public function testInvalidFormatIssn($issn) { - $constraint = new Issn(); - $this->context - ->expects($this->once()) - ->method('addViolation') - ->with($constraint->message); + $constraint = new Issn(array( + 'message' => 'myMessage', + )); $this->validator->validate($issn, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$issn.'"', + )); } /** @@ -196,13 +197,15 @@ public function testInvalidFormatIssn($issn) */ public function testInvalidValueIssn($issn) { - $constraint = new Issn(); - $this->context - ->expects($this->once()) - ->method('addViolation') - ->with($constraint->message); + $constraint = new Issn(array( + 'message' => 'myMessage', + )); $this->validator->validate($issn, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$issn.'"', + )); } /** @@ -210,11 +213,14 @@ public function testInvalidValueIssn($issn) */ public function testInvalidIssn($issn) { - $constraint = new Issn(); - $this->context - ->expects($this->once()) - ->method('addViolation'); + $constraint = new Issn(array( + 'message' => 'myMessage', + )); $this->validator->validate($issn, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$issn.'"', + )); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php index 3588887d74998..98f7533cb8a58 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php @@ -14,41 +14,34 @@ use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Validator\Constraints\Language; use Symfony\Component\Validator\Constraints\LanguageValidator; +use Symfony\Component\Validator\Validation; -class LanguageValidatorTest extends \PHPUnit_Framework_TestCase +class LanguageValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function createValidator() { - IntlTestHelper::requireIntl($this); - - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new LanguageValidator(); - $this->validator->initialize($this->context); + return new LanguageValidator(); } - protected function tearDown() + protected function setUp() { - $this->context = null; - $this->validator = null; + IntlTestHelper::requireFullIntl($this); + + parent::setUp(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Language()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Language()); + + $this->assertNoViolation(); } /** @@ -64,10 +57,9 @@ public function testExpectsStringCompatibleType() */ public function testValidLanguages($language) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($language, new Language()); + + $this->assertNoViolation(); } public function getValidLanguages() @@ -88,13 +80,11 @@ public function testInvalidLanguages($language) 'message' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $language, - )); - $this->validator->validate($language, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => $language, + )); } public function getInvalidLanguages() @@ -109,11 +99,11 @@ public function testValidateUsingCountrySpecificLocale() { \Locale::setDefault('fr_FR'); $existingLanguage = 'en'; - $this->context->expects($this->never()) - ->method('addViolation'); $this->validator->validate($existingLanguage, new Language(array( 'message' => 'aMessage' ))); + + $this->assertNoViolation(); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php index 267f05b1b6059..31039c08ae040 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php @@ -13,39 +13,27 @@ use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\LengthValidator; +use Symfony\Component\Validator\Validation; -class LengthValidatorTest extends \PHPUnit_Framework_TestCase +class LengthValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function createValidator() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new LengthValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() - { - $this->context = null; - $this->validator = null; + return new LengthValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Length(6)); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Length(6)); + + $this->assertNoViolation(); } /** @@ -111,11 +99,10 @@ public function testValidValuesMin($value, $mbOnly = false) $this->markTestSkipped('mb_strlen does not exist'); } - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Length(array('min' => 5)); $this->validator->validate($value, $constraint); + + $this->assertNoViolation(); } /** @@ -127,11 +114,10 @@ public function testValidValuesMax($value, $mbOnly = false) $this->markTestSkipped('mb_strlen does not exist'); } - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Length(array('max' => 3)); $this->validator->validate($value, $constraint); + + $this->assertNoViolation(); } /** @@ -143,11 +129,10 @@ public function testValidValuesExact($value, $mbOnly = false) $this->markTestSkipped('mb_strlen does not exist'); } - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Length(4); $this->validator->validate($value, $constraint); + + $this->assertNoViolation(); } /** @@ -164,14 +149,12 @@ public function testInvalidValuesMin($value, $mbOnly = false) 'minMessage' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', $this->identicalTo(array( - '{{ value }}' => '"'.$value.'"', - '{{ limit }}' => 4, - )), $this->identicalTo($value), 4); - $this->validator->validate($value, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$value.'"', + '{{ limit }}' => 4, + ), 'property.path', $value, 4); } /** @@ -188,14 +171,12 @@ public function testInvalidValuesMax($value, $mbOnly = false) 'maxMessage' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', $this->identicalTo(array( - '{{ value }}' => '"'.$value.'"', - '{{ limit }}' => 4, - )), $this->identicalTo($value), 4); - $this->validator->validate($value, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$value.'"', + '{{ limit }}' => 4, + ), 'property.path', $value, 4); } /** @@ -213,14 +194,12 @@ public function testInvalidValuesExact($value, $mbOnly = false) 'exactMessage' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', $this->identicalTo(array( - '{{ value }}' => '"'.$value.'"', - '{{ limit }}' => 4, - )), $this->identicalTo($value), 4); - $this->validator->validate($value, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$value.'"', + '{{ limit }}' => 4, + ), 'property.path', $value, 4); } public function testConstraintGetDefaultOption() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php index 41feba0c7123a..5d40dd20bd3ae 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php @@ -14,41 +14,34 @@ use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Validator\Constraints\Locale; use Symfony\Component\Validator\Constraints\LocaleValidator; +use Symfony\Component\Validator\Validation; -class LocaleValidatorTest extends \PHPUnit_Framework_TestCase +class LocaleValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; + protected function createValidator() + { + return new LocaleValidator(); + } protected function setUp() { IntlTestHelper::requireIntl($this); - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new LocaleValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() - { - $this->context = null; - $this->validator = null; + parent::setUp(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Locale()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Locale()); + + $this->assertNoViolation(); } /** @@ -64,10 +57,9 @@ public function testExpectsStringCompatibleType() */ public function testValidLocales($locale) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($locale, new Locale()); + + $this->assertNoViolation(); } public function getValidLocales() @@ -90,13 +82,11 @@ public function testInvalidLocales($locale) 'message' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $locale, - )); - $this->validator->validate($locale, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => $locale, + )); } public function getInvalidLocales() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php index 11c6a7cad5294..9b02bf6492237 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php @@ -13,39 +13,27 @@ use Symfony\Component\Validator\Constraints\Luhn; use Symfony\Component\Validator\Constraints\LuhnValidator; +use Symfony\Component\Validator\Validation; -class LuhnValidatorTest extends \PHPUnit_Framework_TestCase +class LuhnValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() - { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new LuhnValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new LuhnValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Luhn()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Luhn()); + + $this->assertNoViolation(); } /** @@ -53,10 +41,9 @@ public function testEmptyStringIsValid() */ public function testValidNumbers($number) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($number, new Luhn()); + + $this->assertNoViolation(); } public function getValidNumbers() @@ -88,13 +75,15 @@ public function getValidNumbers() */ public function testInvalidNumbers($number) { - $constraint = new Luhn(); - - $this->context->expects($this->once()) - ->method('addViolation') - ->with($constraint->message); + $constraint = new Luhn(array( + 'message' => 'myMessage', + )); $this->validator->validate($number, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$number.'"', + )); } public function getInvalidNumbers() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php index 7273986a87505..fe289514665cf 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php @@ -13,23 +13,13 @@ use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotBlankValidator; +use Symfony\Component\Validator\Validation; -class NotBlankValidatorTest extends \PHPUnit_Framework_TestCase +class NotBlankValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function createValidator() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new NotBlankValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() - { - $this->context = null; - $this->validator = null; + return new NotBlankValidator(); } /** @@ -37,10 +27,9 @@ protected function tearDown() */ public function testValidValues($value) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($value, new NotBlank()); + + $this->assertNoViolation(); } public function getValidValues() @@ -60,11 +49,11 @@ public function testNullIsInvalid() 'message' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage'); - $this->validator->validate(null, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => 'null', + )); } public function testBlankIsInvalid() @@ -73,11 +62,11 @@ public function testBlankIsInvalid() 'message' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage'); - $this->validator->validate('', $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '""', + )); } public function testFalseIsInvalid() @@ -86,11 +75,11 @@ public function testFalseIsInvalid() 'message' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage'); - $this->validator->validate(false, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => 'false', + )); } public function testEmptyArrayIsInvalid() @@ -99,10 +88,10 @@ public function testEmptyArrayIsInvalid() 'message' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage'); - $this->validator->validate(array(), $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => 'array', + )); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php index 96f74a1ba02ac..8224423e9bf02 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php @@ -13,23 +13,13 @@ use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\NotNullValidator; +use Symfony\Component\Validator\Validation; -class NotNullValidatorTest extends \PHPUnit_Framework_TestCase +class NotNullValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() - { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new NotNullValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new NotNullValidator(); } /** @@ -37,10 +27,9 @@ protected function tearDown() */ public function testValidValues($value) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($value, new NotNull()); + + $this->assertNoViolation(); } public function getValidValues() @@ -59,11 +48,8 @@ public function testNullIsInvalid() 'message' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - )); - $this->validator->validate(null, $constraint); + + $this->assertViolation('myMessage'); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php index 4ca50c1087d52..b659bc029a46f 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php @@ -13,31 +13,20 @@ use Symfony\Component\Validator\Constraints\Null; use Symfony\Component\Validator\Constraints\NullValidator; +use Symfony\Component\Validator\Validation; -class NullValidatorTest extends \PHPUnit_Framework_TestCase +class NullValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function createValidator() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new NullValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() - { - $this->context = null; - $this->validator = null; + return new NullValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Null()); + + $this->assertNoViolation(); } /** @@ -49,13 +38,11 @@ public function testInvalidValues($value, $valueAsString) 'message' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $valueAsString, - )); - $this->validator->validate($value, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => $valueAsString, + )); } public function getInvalidValues() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php index f7601de797baf..9c043a6d56098 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php @@ -13,25 +13,20 @@ use Symfony\Component\Validator\Constraints\Range; use Symfony\Component\Validator\Constraints\RangeValidator; +use Symfony\Component\Validator\Validation; -class RangeValidatorTest extends \PHPUnit_Framework_TestCase +class RangeValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() + protected function createValidator() { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new RangeValidator(); - $this->validator->initialize($this->context); + return new RangeValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Range(array('min' => 10, 'max' => 20))); + + $this->assertNoViolation(); } public function getTenToTwenty() @@ -73,11 +68,10 @@ public function getMoreThanTwenty() */ public function testValidValuesMin($value) { - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Range(array('min' => 10)); $this->validator->validate($value, $constraint); + + $this->assertNoViolation(); } /** @@ -85,11 +79,10 @@ public function testValidValuesMin($value) */ public function testValidValuesMax($value) { - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Range(array('max' => 20)); $this->validator->validate($value, $constraint); + + $this->assertNoViolation(); } /** @@ -97,11 +90,10 @@ public function testValidValuesMax($value) */ public function testValidValuesMinMax($value) { - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Range(array('min' => 10, 'max' => 20)); $this->validator->validate($value, $constraint); + + $this->assertNoViolation(); } /** @@ -114,14 +106,12 @@ public function testInvalidValuesMin($value) 'minMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', $this->identicalTo(array( - '{{ value }}' => $value, - '{{ limit }}' => 10, - ))); - $this->validator->validate($value, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => $value, + '{{ limit }}' => 10, + )); } /** @@ -134,14 +124,12 @@ public function testInvalidValuesMax($value) 'maxMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', $this->identicalTo(array( - '{{ value }}' => $value, - '{{ limit }}' => 20, - ))); - $this->validator->validate($value, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => $value, + '{{ limit }}' => 20, + )); } /** @@ -156,14 +144,12 @@ public function testInvalidValuesCombinedMax($value) 'maxMessage' => 'myMaxMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMaxMessage', $this->identicalTo(array( - '{{ value }}' => $value, - '{{ limit }}' => 20, - ))); - $this->validator->validate($value, $constraint); + + $this->assertViolation('myMaxMessage', array( + '{{ value }}' => $value, + '{{ limit }}' => 20, + )); } /** @@ -178,14 +164,12 @@ public function testInvalidValuesCombinedMin($value) 'maxMessage' => 'myMaxMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMinMessage', $this->identicalTo(array( + $this->validator->validate($value, $constraint); + + $this->assertViolation('myMinMessage', array( '{{ value }}' => $value, '{{ limit }}' => 10, - ))); - - $this->validator->validate($value, $constraint); + )); } public function getInvalidValues() @@ -207,14 +191,12 @@ public function testMinMessageIsSet() 'minMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => 9, - '{{ limit }}' => 10, - )); - $this->validator->validate(9, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => 9, + '{{ limit }}' => 10, + )); } public function testMaxMessageIsSet() @@ -225,28 +207,24 @@ public function testMaxMessageIsSet() 'maxMessage' => 'myMessage', )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => 21, - '{{ limit }}' => 20, - )); - $this->validator->validate(21, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => 21, + '{{ limit }}' => 20, + )); } public function testNonNumeric() { - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"abcd"', - )); - $this->validator->validate('abcd', new Range(array( 'min' => 10, 'max' => 20, 'invalidMessage' => 'myMessage', ))); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"abcd"', + )); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php index 25b5006c33e27..91f0c0532fce6 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php @@ -13,39 +13,27 @@ use Symfony\Component\Validator\Constraints\Regex; use Symfony\Component\Validator\Constraints\RegexValidator; +use Symfony\Component\Validator\Validation; -class RegexValidatorTest extends \PHPUnit_Framework_TestCase +class RegexValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() - { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new RegexValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new RegexValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Regex(array('pattern' => '/^[0-9]+$/'))); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Regex(array('pattern' => '/^[0-9]+$/'))); + + $this->assertNoViolation(); } /** @@ -61,11 +49,10 @@ public function testExpectsStringCompatibleType() */ public function testValidValues($value) { - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Regex(array('pattern' => '/^[0-9]+$/')); $this->validator->validate($value, $constraint); + + $this->assertNoViolation(); } public function getValidValues() @@ -88,13 +75,11 @@ public function testInvalidValues($value) 'message' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"'.$value.'"', - )); - $this->validator->validate($value, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$value.'"', + )); } public function getInvalidValues() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php index cfa24b80c7462..4cc5f028b43b1 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php @@ -13,47 +13,34 @@ use Symfony\Component\Validator\Constraints\Time; use Symfony\Component\Validator\Constraints\TimeValidator; +use Symfony\Component\Validator\Validation; -class TimeValidatorTest extends \PHPUnit_Framework_TestCase +class TimeValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() - { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new TimeValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new TimeValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Time()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Time()); + + $this->assertNoViolation(); } public function testDateTimeClassIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(new \DateTime(), new Time()); + + $this->assertNoViolation(); } /** @@ -69,10 +56,9 @@ public function testExpectsStringCompatibleType() */ public function testValidTimes($time) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($time, new Time()); + + $this->assertNoViolation(); } public function getValidTimes() @@ -93,13 +79,11 @@ public function testInvalidTimes($time) 'message' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"'.$time.'"', - )); - $this->validator->validate($time, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$time.'"', + )); } public function getInvalidTimes() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php index 5a42912edfd90..e401b8702214d 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php @@ -13,39 +13,27 @@ use Symfony\Component\Validator\Constraints\True; use Symfony\Component\Validator\Constraints\TrueValidator; +use Symfony\Component\Validator\Validation; -class TrueValidatorTest extends \PHPUnit_Framework_TestCase +class TrueValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() - { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new TrueValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new TrueValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new True()); + + $this->assertNoViolation(); } public function testTrueIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(true, new True()); + + $this->assertNoViolation(); } public function testFalseIsInvalid() @@ -54,12 +42,10 @@ public function testFalseIsInvalid() 'message' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => 'false', - )); - $this->validator->validate(false, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => 'false', + )); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php index db008ce3cef98..139184638737c 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php @@ -13,49 +13,48 @@ use Symfony\Component\Validator\Constraints\Type; use Symfony\Component\Validator\Constraints\TypeValidator; +use Symfony\Component\Validator\Validation; -class TypeValidatorTest extends \PHPUnit_Framework_TestCase +class TypeValidatorTest extends AbstractConstraintValidatorTest { protected static $file; - protected $context; - protected $validator; - - protected function setUp() - { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new TypeValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new TypeValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); + $constraint = new Type(array('type' => 'integer')); - $this->validator->validate(null, new Type(array('type' => 'integer'))); + $this->validator->validate(null, $constraint); + + $this->assertNoViolation(); } public function testEmptyIsValidIfString() { - $this->context->expects($this->never()) - ->method('addViolation'); + $constraint = new Type(array('type' => 'string')); + + $this->validator->validate('', $constraint); - $this->validator->validate('', new Type(array('type' => 'string'))); + $this->assertNoViolation(); } public function testEmptyIsInvalidIfNoString() { - $this->context->expects($this->once()) - ->method('addViolation'); + $constraint = new Type(array( + 'type' => 'integer', + 'message' => 'myMessage', + )); - $this->validator->validate('', new Type(array('type' => 'integer'))); + $this->validator->validate('', $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '""', + '{{ type }}' => 'integer', + )); } /** @@ -63,12 +62,11 @@ public function testEmptyIsInvalidIfNoString() */ public function testValidValues($value, $type) { - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Type(array('type' => $type)); $this->validator->validate($value, $constraint); + + $this->assertNoViolation(); } public function getValidValues() @@ -118,14 +116,12 @@ public function testInvalidValues($value, $type, $valueAsString) 'message' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => $valueAsString, - '{{ type }}' => $type, - )); - $this->validator->validate($value, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => $valueAsString, + '{{ type }}' => $type, + )); } public function getInvalidValues() @@ -167,17 +163,18 @@ public function getInvalidValues() protected function createFile() { - if (!self::$file) { - self::$file = fopen(__FILE__, 'r'); + if (!static::$file) { + static::$file = fopen(__FILE__, 'r'); } - return self::$file; + return static::$file; } public static function tearDownAfterClass() { - if (self::$file) { - fclose(self::$file); + if (static::$file) { + fclose(static::$file); + static::$file = null; } } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php index 4c95e5bbb0a42..0d4e8e3394e31 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php @@ -13,39 +13,27 @@ use Symfony\Component\Validator\Constraints\Url; use Symfony\Component\Validator\Constraints\UrlValidator; +use Symfony\Component\Validator\Validation; -class UrlValidatorTest extends \PHPUnit_Framework_TestCase +class UrlValidatorTest extends AbstractConstraintValidatorTest { - protected $context; - protected $validator; - - protected function setUp() - { - $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); - $this->validator = new UrlValidator(); - $this->validator->initialize($this->context); - } - - protected function tearDown() + protected function createValidator() { - $this->context = null; - $this->validator = null; + return new UrlValidator(); } public function testNullIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate(null, new Url()); + + $this->assertNoViolation(); } public function testEmptyStringIsValid() { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate('', new Url()); + + $this->assertNoViolation(); } /** @@ -61,10 +49,9 @@ public function testExpectsStringCompatibleType() */ public function testValidUrls($url) { - $this->context->expects($this->never()) - ->method('addViolation'); - $this->validator->validate($url, new Url()); + + $this->assertNoViolation(); } public function getValidUrls() @@ -72,7 +59,7 @@ public function getValidUrls() return array( array('http://a.pl'), array('http://www.google.com'), - array('http://www.google.com.'), + //array('http://www.google.com.') OK as of 2.5 array('http://www.google.museum'), array('https://google.com/'), array('https://google.com:80/'), @@ -86,7 +73,7 @@ public function getValidUrls() array('http://symfony.com/#?'), array('http://www.symfony.com/doc/current/book/validation.html#supported-constraints'), array('http://very.long.domain.name.com/'), - array('http://localhost/'), + //array('http://localhost/') OK as of 2.5 array('http://127.0.0.1/'), array('http://127.0.0.1:80/'), array('http://[::1]/'), @@ -130,13 +117,11 @@ public function testInvalidUrls($url) 'message' => 'myMessage' )); - $this->context->expects($this->once()) - ->method('addViolation') - ->with('myMessage', array( - '{{ value }}' => '"'.$url.'"', - )); - $this->validator->validate($url, $constraint); + + $this->assertViolation('myMessage', array( + '{{ value }}' => '"'.$url.'"', + )); } public function getInvalidUrls() @@ -169,14 +154,13 @@ public function getInvalidUrls() */ public function testCustomProtocolIsValid($url) { - $this->context->expects($this->never()) - ->method('addViolation'); - $constraint = new Url(array( 'protocols' => array('ftp', 'file', 'git') )); $this->validator->validate($url, $constraint); + + $this->assertNoViolation(); } public function getValidCustomUrls() diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/Countable.php b/src/Symfony/Component/Validator/Tests/Fixtures/Countable.php new file mode 100644 index 0000000000000..282d78d45a672 --- /dev/null +++ b/src/Symfony/Component/Validator/Tests/Fixtures/Countable.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Fixtures; + +class Countable implements \Countable +{ + private $content; + + public function __construct(array $content) + { + $this->content = $content; + } + + public function count() + { + return count($this->content); + } +} diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/CustomArrayObject.php b/src/Symfony/Component/Validator/Tests/Fixtures/CustomArrayObject.php new file mode 100644 index 0000000000000..41eac961acf91 --- /dev/null +++ b/src/Symfony/Component/Validator/Tests/Fixtures/CustomArrayObject.php @@ -0,0 +1,70 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Fixtures; + +/** + * This class is a hand written simplified version of PHP native `ArrayObject` + * class, to show that it behaves differently than the PHP native implementation. + */ +class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable, \Serializable +{ + private $array; + + public function __construct(array $array = null) + { + $this->array = $array ?: array(); + } + + public function offsetExists($offset) + { + return array_key_exists($offset, $this->array); + } + + public function offsetGet($offset) + { + return $this->array[$offset]; + } + + public function offsetSet($offset, $value) + { + if (null === $offset) { + $this->array[] = $value; + } else { + $this->array[$offset] = $value; + } + } + + public function offsetUnset($offset) + { + unset($this->array[$offset]); + } + + public function getIterator() + { + return new \ArrayIterator($this->array); + } + + public function count() + { + return count($this->array); + } + + public function serialize() + { + return serialize($this->array); + } + + public function unserialize($serialized) + { + $this->array = (array) unserialize((string) $serialized); + } +} diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/StubGlobalExecutionContext.php b/src/Symfony/Component/Validator/Tests/Fixtures/StubGlobalExecutionContext.php new file mode 100644 index 0000000000000..bfe096a86dad7 --- /dev/null +++ b/src/Symfony/Component/Validator/Tests/Fixtures/StubGlobalExecutionContext.php @@ -0,0 +1,69 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Tests\Fixtures; + +use Symfony\Component\Validator\ConstraintViolationList; +use Symfony\Component\Validator\GlobalExecutionContextInterface; +use Symfony\Component\Validator\ValidationVisitorInterface; + +/** + * @since 2.3.19 + * @author Bernhard Schussek + */ +class StubGlobalExecutionContext implements GlobalExecutionContextInterface +{ + private $violations; + + private $root; + + private $visitor; + + function __construct($root = null, ValidationVisitorInterface $visitor = null) + { + $this->violations = new ConstraintViolationList(); + $this->root = $root; + $this->visitor = $visitor; + } + + public function getViolations() + { + return $this->violations; + } + + public function setRoot($root) + { + $this->root = $root; + } + + public function getRoot() + { + return $this->root; + } + + public function setVisitor(ValidationVisitorInterface $visitor) + { + $this->visitor = $visitor; + } + + public function getVisitor() + { + return $this->visitor; + } + + public function getValidatorFactory() + { + } + + public function getMetadataFactory() + { + } +} From 7b4d4b63ebe90637139a94ce2f9a9ddc2422a8f7 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 14 Aug 2014 23:19:02 +0200 Subject: [PATCH 1221/1305] fix handling of nullable XML attributes As @Tobion pointed out in #11394, true and 1 are valid values in boolean XML attributes. The XmlFileLoader didn't handle 1 values properly. --- .../Component/Routing/Loader/XmlFileLoader.php | 13 ++++++++++++- .../Routing/Tests/Fixtures/null_values.xml | 12 ++++++++++++ .../Routing/Tests/Loader/XmlFileLoaderTest.php | 14 ++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Component/Routing/Tests/Fixtures/null_values.xml diff --git a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php index da7b33d856ff1..74593f3d849d1 100644 --- a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php @@ -215,7 +215,7 @@ private function parseConfigs(\DOMElement $node, $path) foreach ($node->getElementsByTagNameNS(self::NAMESPACE_URI, '*') as $n) { switch ($n->localName) { case 'default': - if ($n->hasAttribute('xsi:nil') && 'true' == $n->getAttribute('xsi:nil')) { + if ($this->isElementValueNull($n)) { $defaults[$n->getAttribute('key')] = null; } else { $defaults[$n->getAttribute('key')] = trim($n->textContent); @@ -235,4 +235,15 @@ private function parseConfigs(\DOMElement $node, $path) return array($defaults, $requirements, $options); } + + private function isElementValueNull(\DOMElement $element) + { + $namespaceUri = 'http://www.w3.org/2001/XMLSchema-instance'; + + if (!$element->hasAttributeNS($namespaceUri, 'nil')) { + return false; + } + + return 'true' === $element->getAttributeNS($namespaceUri, 'nil') || '1' === $element->getAttributeNS($namespaceUri, 'nil'); + } } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/null_values.xml b/src/Symfony/Component/Routing/Tests/Fixtures/null_values.xml new file mode 100644 index 0000000000000..f9e2aa24df804 --- /dev/null +++ b/src/Symfony/Component/Routing/Tests/Fixtures/null_values.xml @@ -0,0 +1,12 @@ + + + + + + + foo + bar + + diff --git a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php index ee1dc5ca90bcc..f29ead41d920d 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php @@ -124,4 +124,18 @@ public function testDocTypeIsNotAllowed() $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); $loader->load('withdoctype.xml'); } + + public function testNullValues() + { + $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); + $routeCollection = $loader->load('null_values.xml'); + $route = $routeCollection->get('blog_show'); + + $this->assertTrue($route->hasDefault('foo')); + $this->assertNull($route->getDefault('foo')); + $this->assertTrue($route->hasDefault('bar')); + $this->assertNull($route->getDefault('bar')); + $this->assertEquals('foo', $route->getDefault('foobar')); + $this->assertEquals('bar', $route->getDefault('baz')); + } } From 2d5ab91fe4ca17c6b6334ad8b6d85db176e91613 Mon Sep 17 00:00:00 2001 From: Seb Koelen Date: Fri, 15 Aug 2014 14:03:36 +0200 Subject: [PATCH 1222/1305] add missing options --- .../Validator/Resources/translations/validators.nl.xlf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf index 1caed4eef7f97..5b35f1d3019d5 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf @@ -180,7 +180,7 @@
    This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters. - Deze waarde moet exact {{ limit }} tekens lang zijn. + Deze waarde moet exact {{ limit }} teken lang zijn.|Deze waarde moet exact {{ limit }} tekens lang zijn. The file was only partially uploaded. From 45a5863508896df780cbe3f99136735e74032f9e Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 15 Aug 2014 14:16:41 +0200 Subject: [PATCH 1223/1305] [YAML] resolve variables in inlined YAML --- src/Symfony/Component/Yaml/Inline.php | 64 +++++++++++++------ src/Symfony/Component/Yaml/Parser.php | 6 +- .../Component/Yaml/Tests/InlineTest.php | 32 ++++++++++ .../Component/Yaml/Tests/ParserTest.php | 26 ++++++++ 4 files changed, 104 insertions(+), 24 deletions(-) diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 0db774fcd1484..1b34edebd28f8 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -32,12 +32,13 @@ class Inline * @param string $value A YAML string * @param bool $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise * @param bool $objectSupport true if object support is enabled, false otherwise + * @param array $references Mapping of variable names to values * * @return array A PHP array representing the YAML string * * @throws ParseException */ - public static function parse($value, $exceptionOnInvalidType = false, $objectSupport = false) + public static function parse($value, $exceptionOnInvalidType = false, $objectSupport = false, $references = array()) { self::$exceptionOnInvalidType = $exceptionOnInvalidType; self::$objectSupport = $objectSupport; @@ -56,15 +57,15 @@ public static function parse($value, $exceptionOnInvalidType = false, $objectSup $i = 0; switch ($value[0]) { case '[': - $result = self::parseSequence($value, $i); + $result = self::parseSequence($value, $i, $references); ++$i; break; case '{': - $result = self::parseMapping($value, $i); + $result = self::parseMapping($value, $i, $references); ++$i; break; default: - $result = self::parseScalar($value, null, array('"', "'"), $i); + $result = self::parseScalar($value, null, array('"', "'"), $i, true, $references); } // some comments are allowed at the end @@ -184,14 +185,15 @@ private static function dumpArray($value, $exceptionOnInvalidType, $objectSuppor * @param scalar $scalar * @param string $delimiters * @param array $stringDelimiters - * @param int &$i - * @param bool $evaluate + * @param int &$i + * @param bool $evaluate + * @param array $references * * @return string A YAML string * * @throws ParseException When malformed inline YAML string is parsed */ - public static function parseScalar($scalar, $delimiters = null, $stringDelimiters = array('"', "'"), &$i = 0, $evaluate = true) + public static function parseScalar($scalar, $delimiters = null, $stringDelimiters = array('"', "'"), &$i = 0, $evaluate = true, $references = array()) { if (in_array($scalar[$i], $stringDelimiters)) { // quoted scalar @@ -221,7 +223,7 @@ public static function parseScalar($scalar, $delimiters = null, $stringDelimiter } if ($evaluate) { - $output = self::evaluateScalar($output); + $output = self::evaluateScalar($output, $references); } } @@ -262,13 +264,14 @@ private static function parseQuotedScalar($scalar, &$i) * Parses a sequence to a YAML string. * * @param string $sequence - * @param int &$i + * @param int &$i + * @param array $references * * @return string A YAML string * * @throws ParseException When malformed inline YAML string is parsed */ - private static function parseSequence($sequence, &$i = 0) + private static function parseSequence($sequence, &$i = 0, $references = array()) { $output = array(); $len = strlen($sequence); @@ -279,11 +282,11 @@ private static function parseSequence($sequence, &$i = 0) switch ($sequence[$i]) { case '[': // nested sequence - $output[] = self::parseSequence($sequence, $i); + $output[] = self::parseSequence($sequence, $i, $references); break; case '{': // nested mapping - $output[] = self::parseMapping($sequence, $i); + $output[] = self::parseMapping($sequence, $i, $references); break; case ']': return $output; @@ -292,12 +295,14 @@ private static function parseSequence($sequence, &$i = 0) break; default: $isQuoted = in_array($sequence[$i], array('"', "'")); - $value = self::parseScalar($sequence, array(',', ']'), array('"', "'"), $i); + $value = self::parseScalar($sequence, array(',', ']'), array('"', "'"), $i, true, $references); - if (!$isQuoted && false !== strpos($value, ': ')) { + // the value can be an array if a reference has been resolved to an array var + if (!is_array($value) && !$isQuoted && false !== strpos($value, ': ')) { // embedded mapping? try { - $value = self::parseMapping('{'.$value.'}'); + $pos = 0; + $value = self::parseMapping('{'.$value.'}', $pos, $references); } catch (\InvalidArgumentException $e) { // no, it's not } @@ -318,13 +323,14 @@ private static function parseSequence($sequence, &$i = 0) * Parses a mapping to a YAML string. * * @param string $mapping - * @param int &$i + * @param int &$i + * @param array $references * * @return string A YAML string * * @throws ParseException When malformed inline YAML string is parsed */ - private static function parseMapping($mapping, &$i = 0) + private static function parseMapping($mapping, &$i = 0, $references = array()) { $output = array(); $len = strlen($mapping); @@ -350,19 +356,19 @@ private static function parseMapping($mapping, &$i = 0) switch ($mapping[$i]) { case '[': // nested sequence - $output[$key] = self::parseSequence($mapping, $i); + $output[$key] = self::parseSequence($mapping, $i, $references); $done = true; break; case '{': // nested mapping - $output[$key] = self::parseMapping($mapping, $i); + $output[$key] = self::parseMapping($mapping, $i, $references); $done = true; break; case ':': case ' ': break; default: - $output[$key] = self::parseScalar($mapping, array(',', '}'), array('"', "'"), $i); + $output[$key] = self::parseScalar($mapping, array(',', '}'), array('"', "'"), $i, true, $references); $done = true; --$i; } @@ -382,15 +388,31 @@ private static function parseMapping($mapping, &$i = 0) * Evaluates scalars and replaces magic values. * * @param string $scalar + * @param array $references * * @return string A YAML string * * @throws ParseException when object parsing support was disabled and the parser detected a PHP object */ - private static function evaluateScalar($scalar) + private static function evaluateScalar($scalar, $references = array()) { $scalar = trim($scalar); $scalarLower = strtolower($scalar); + + if (0 === strpos($scalar, '*')) { + if (false !== $pos = strpos($scalar, '#')) { + $value = substr($scalar, 1, $pos - 2); + } else { + $value = substr($scalar, 1); + } + + if (!array_key_exists($value, $references)) { + throw new ParseException(sprintf('Reference "%s" does not exist.', $value)); + } + + return $references[$value]; + } + switch (true) { case 'null' === $scalarLower: case '' === $scalar: diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 9bde67b57b548..d0aae87ab978e 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -121,7 +121,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = $context = 'mapping'; // force correct settings - Inline::parse(null, $exceptionOnInvalidType, $objectSupport); + Inline::parse(null, $exceptionOnInvalidType, $objectSupport, $this->refs); try { $key = Inline::parseScalar($values['key']); } catch (ParseException $e) { @@ -197,7 +197,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = $lineCount = count($this->lines); if (1 === $lineCount || (2 === $lineCount && empty($this->lines[1]))) { try { - $value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport); + $value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport, $this->refs); } catch (ParseException $e) { $e->setParsedLine($this->getRealCurrentLineNb() + 1); $e->setSnippet($this->currentLine); @@ -404,7 +404,7 @@ private function parseValue($value, $exceptionOnInvalidType, $objectSupport) } try { - return Inline::parse($value, $exceptionOnInvalidType, $objectSupport); + return Inline::parse($value, $exceptionOnInvalidType, $objectSupport, $this->refs); } catch (ParseException $e) { $e->setParsedLine($this->getRealCurrentLineNb() + 1); $e->setSnippet($this->currentLine); diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index af5018f2026f9..96a118d073eda 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -115,6 +115,38 @@ public function testParseScalarWithCorrectlyQuotedStringShouldReturnString() $this->assertSame($expect, Inline::parseScalar($value)); } + /** + * @dataProvider getDataForParseReferences + */ + public function testParseReferences($yaml, $expected) + { + $this->assertSame($expected, Inline::parse($yaml, false, false, array('var' => 'var-value'))); + } + + public function getDataForParseReferences() + { + return array( + 'scalar' => array('*var', 'var-value'), + 'list' => array('[ *var ]', array('var-value')), + 'list-in-list' => array('[[ *var ]]', array(array('var-value'))), + 'map-in-list' => array('[ { key: *var } ]', array(array('key' => 'var-value'))), + 'embedded-mapping-in-list' => array('[ key: *var ]', array(array('key' => 'var-value'))), + 'map' => array('{ key: *var }', array('key' => 'var-value')), + 'list-in-map' => array('{ key: [*var] }', array('key' => array('var-value'))), + 'map-in-map' => array('{ foo: { bar: *var } }', array('foo' => array('bar' => 'var-value'))), + ); + } + + public function testParseMapReferenceInSequence() + { + $foo = array( + 'a' => 'Steve', + 'b' => 'Clark', + 'c' => 'Brian', + ); + $this->assertSame(array($foo), Inline::parse('[*foo]', false, false, array('foo' => $foo))); + } + protected function getTestsForParse() { return array( diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 2335efc55990f..01c7b5399511f 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -602,6 +602,32 @@ public function testNestedFoldedStringBlockWithComments() footer # comment3 +EOF + )); + } + + public function testReferenceResolvingInInlineStrings() + { + $this->assertEquals(array( + 'var' => 'var-value', + 'scalar' => 'var-value', + 'list' => array('var-value'), + 'list_in_list' => array(array('var-value')), + 'map_in_list' => array(array('key' => 'var-value')), + 'embedded_mapping' => array(array('key' => 'var-value')), + 'map' => array('key' => 'var-value'), + 'list_in_map' => array('key' => array('var-value')), + 'map_in_map' => array('foo' => array('bar' => 'var-value')), + ), Yaml::parse(<< Date: Mon, 18 Aug 2014 11:20:23 +0200 Subject: [PATCH 1224/1305] check for the correct field type HTML allow to define different form fields with the same name. Imagine the following form:
    Since the `FormFieldRegistry` can only handle one field per name, the hidden field option is registered first before the radio field with the same name is evaluated. Thus, the `FormFieldRegistry` returns an `InputFormField` instance on which the `addChoices()` method can not be called. --- src/Symfony/Component/DomCrawler/Form.php | 5 ++++- .../Component/DomCrawler/Tests/FormTest.php | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php index 0a60fac5efccf..0ca20ee903a11 100644 --- a/src/Symfony/Component/DomCrawler/Form.php +++ b/src/Symfony/Component/DomCrawler/Form.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DomCrawler; +use Symfony\Component\DomCrawler\Field\ChoiceFormField; use Symfony\Component\DomCrawler\Field\FormField; /** @@ -444,7 +445,9 @@ private function addField(\DOMNode $node) if ('select' == $nodeName || 'input' == $nodeName && 'checkbox' == strtolower($node->getAttribute('type'))) { $this->set(new Field\ChoiceFormField($node)); } elseif ('input' == $nodeName && 'radio' == strtolower($node->getAttribute('type'))) { - if ($this->has($node->getAttribute('name'))) { + // there may be other fields with the same name that are no choice + // fields already registered (see https://github.com/symfony/symfony/issues/11689) + if ($this->has($node->getAttribute('name')) && $this->get($node->getAttribute('name')) instanceof ChoiceFormField) { $this->get($node->getAttribute('name'))->addChoice($node); } else { $this->set(new Field\ChoiceFormField($node)); diff --git a/src/Symfony/Component/DomCrawler/Tests/FormTest.php b/src/Symfony/Component/DomCrawler/Tests/FormTest.php index 092db68561aef..019581385837a 100644 --- a/src/Symfony/Component/DomCrawler/Tests/FormTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/FormTest.php @@ -782,6 +782,28 @@ public function testFormRegistrySetValues() )); } + public function testDifferentFieldTypesWithSameName() + { + $dom = new \DOMDocument(); + $dom->loadHTML(' + + +
    + + + + + + +
    + + + '); + $form = new Form($dom->getElementsByTagName('form')->item(0), 'http://example.com'); + + $this->assertInstanceOf('Symfony\Component\DomCrawler\Field\ChoiceFormField', $form->get('option')); + } + protected function getFormFieldMock($name, $value = null) { $field = $this From 5440ed5c38eb82a3b38873d54b8986357157c7c4 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Mon, 18 Aug 2014 18:29:10 +0200 Subject: [PATCH 1225/1305] [Validators] Fixed failing tests requiring ICU 52.1 which are skipped otherwise --- .../Validator/Tests/Constraints/CountryValidatorTest.php | 2 +- .../Validator/Tests/Constraints/CurrencyValidatorTest.php | 2 +- .../Validator/Tests/Constraints/LanguageValidatorTest.php | 3 +-- .../Validator/Tests/Constraints/LocaleValidatorTest.php | 3 +-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php index a080852c2acd1..c6693020f83ae 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php @@ -82,7 +82,7 @@ public function testInvalidCountries($country) $this->validator->validate($country, $constraint); $this->assertViolation('myMessage', array( - '{{ value }}' => $country, + '{{ value }}' => '"'.$country.'"', )); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php index 99636e6ca4f06..0480b60ed7078 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php @@ -96,7 +96,7 @@ public function testInvalidCurrencies($currency) $this->validator->validate($currency, $constraint); $this->assertViolation('myMessage', array( - '{{ value }}' => $currency, + '{{ value }}' => '"'.$currency.'"', )); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php index 98f7533cb8a58..ad2b1e89715cb 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php @@ -14,7 +14,6 @@ use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Validator\Constraints\Language; use Symfony\Component\Validator\Constraints\LanguageValidator; -use Symfony\Component\Validator\Validation; class LanguageValidatorTest extends AbstractConstraintValidatorTest { @@ -83,7 +82,7 @@ public function testInvalidLanguages($language) $this->validator->validate($language, $constraint); $this->assertViolation('myMessage', array( - '{{ value }}' => $language, + '{{ value }}' => '"'.$language.'"', )); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php index 5d40dd20bd3ae..8c76485e53343 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php @@ -14,7 +14,6 @@ use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Validator\Constraints\Locale; use Symfony\Component\Validator\Constraints\LocaleValidator; -use Symfony\Component\Validator\Validation; class LocaleValidatorTest extends AbstractConstraintValidatorTest { @@ -85,7 +84,7 @@ public function testInvalidLocales($locale) $this->validator->validate($locale, $constraint); $this->assertViolation('myMessage', array( - '{{ value }}' => $locale, + '{{ value }}' => '"'.$locale.'"', )); } From 31d48ab91f2182ebd65b6e02c32b2b931aea32f3 Mon Sep 17 00:00:00 2001 From: "Nek (Maxime Veber)" Date: Fri, 15 Aug 2014 14:15:04 +0200 Subject: [PATCH 1226/1305] Fixed #11675 ValueToDuplicatesTransformer accept "0" value Fixed wrong return null syntax Added transformation to null on empty arrays Removed useless statement in condition and switched to yoda condition --- .../ValueToDuplicatesTransformer.php | 2 +- .../ValueToDuplicatesTransformerTest.php | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ValueToDuplicatesTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ValueToDuplicatesTransformer.php index 618fc6b4a4025..ffc9915fa409f 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ValueToDuplicatesTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ValueToDuplicatesTransformer.php @@ -64,7 +64,7 @@ public function reverseTransform($array) $emptyKeys = array(); foreach ($this->keys as $key) { - if (!empty($array[$key])) { + if (isset($array[$key]) && '' !== $array[$key] && false !== $array[$key] && array() !== $array[$key]) { if ($array[$key] !== $result) { throw new TransformationFailedException( 'All values in the array should be the same' diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php index 2c5298da509b9..a8a088a95a074 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php @@ -82,6 +82,29 @@ public function testReverseTransformCompletelyNull() $this->assertNull($this->transformer->reverseTransform($input)); } + public function testReverseTransformEmptyArray() + { + $input = array( + 'a' => array(), + 'b' => array(), + 'c' => array(), + ); + + $this->assertNull($this->transformer->reverseTransform($input)); + } + + + public function testReverseTransformZeroString() + { + $input = array( + 'a' => '0', + 'b' => '0', + 'c' => '0' + ); + + $this->assertSame('0', $this->transformer->reverseTransform($input)); + } + /** * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ From 0deb505e649976c6b9b28b67e12c7c41df4e8814 Mon Sep 17 00:00:00 2001 From: "Issei.M" Date: Wed, 20 Aug 2014 19:06:28 +0900 Subject: [PATCH 1227/1305] [Form] FormBuilder::getIterator() now deals with resolved children --- src/Symfony/Component/Form/FormBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/FormBuilder.php b/src/Symfony/Component/Form/FormBuilder.php index 434afa861a5e4..e73c03fd7aa04 100644 --- a/src/Symfony/Component/Form/FormBuilder.php +++ b/src/Symfony/Component/Form/FormBuilder.php @@ -242,7 +242,7 @@ public function getIterator() throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); } - return new \ArrayIterator($this->children); + return new \ArrayIterator($this->all()); } /** From 5506ee8f6601288a171f229bff88d38dcd6ebdf3 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 11 Aug 2014 10:25:24 +0200 Subject: [PATCH 1228/1305] Fix potential DoS when parsing HOST --- .../Component/HttpFoundation/Request.php | 3 +- .../HttpFoundation/Tests/RequestTest.php | 39 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index d7053339bdaf5..93767f4aad1d3 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -1147,7 +1147,8 @@ public function getHost() // as the host can come from the user (HTTP_HOST and depending on the configuration, SERVER_NAME too can come from the user) // check that it does not contain forbidden characters (see RFC 952 and RFC 2181) - if ($host && !preg_match('/^\[?(?:[a-zA-Z0-9-:\]_]+\.?)+$/', $host)) { + // use preg_replace() instead of preg_match() to prevent DoS attacks with long host names + if ($host && '' !== preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $host)) { throw new \UnexpectedValueException('Invalid Host "'.$host.'"'); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index 688f3094b9df8..e0cc1dcfd0f36 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -1594,6 +1594,45 @@ public function testTrustedHosts() // reset request for following tests Request::setTrustedHosts(array()); } + + public function testVeryLongHost() + { + $host = 'a'.str_repeat('.a', 40000); + $start = microtime(true); + + $request = Request::create('/'); + $request->headers->set('host', $host); + $this->assertEquals($host, $request->getHost()); + $this->assertLessThan(1, microtime(true) - $start); + } + + /** + * @dataProvider getHostValidities + */ + public function testHostValidity($host, $isValid) + { + $request = Request::create('/'); + $request->headers->set('host', $host); + + if ($isValid) { + $this->assertSame($host, $request->getHost()); + } + } else { + $this->setExpectedException('UnexpectedValueException', 'Invalid Host'); + $request->getHost(); + } + } + + public function getHostValidities() + { + return array( + array('.a', false), + array('a..', false), + array('a.', true), + array("\xE9", false), + array('[::1]', true), + ); + } } class RequestContentProxy extends Request From 1ee96a8b1b0987ffe2a62dca7ad268bf9edfa9b8 Mon Sep 17 00:00:00 2001 From: Lee Rowlands Date: Fri, 22 Aug 2014 11:11:38 +1000 Subject: [PATCH 1229/1305] Test examples from Drupal SA-CORE-2014-003 --- .../HttpFoundation/Tests/RequestTest.php | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index e0cc1dcfd0f36..88e0afbc8f34c 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -1595,9 +1595,11 @@ public function testTrustedHosts() Request::setTrustedHosts(array()); } - public function testVeryLongHost() + /** + * @dataProvider getLongHostNames + */ + public function testVeryLongHosts($host) { - $host = 'a'.str_repeat('.a', 40000); $start = microtime(true); $request = Request::create('/'); @@ -1609,13 +1611,15 @@ public function testVeryLongHost() /** * @dataProvider getHostValidities */ - public function testHostValidity($host, $isValid) + public function testHostValidity($host, $isValid, $expectedHost = null, $expectedPort = null) { $request = Request::create('/'); $request->headers->set('host', $host); if ($isValid) { - $this->assertSame($host, $request->getHost()); + $this->assertSame($expectedHost ?: $host, $request->getHost()); + if ($expectedPort) { + $this->assertSame($expectedPort, $request->getPort()); } } else { $this->setExpectedException('UnexpectedValueException', 'Invalid Host'); @@ -1631,6 +1635,16 @@ public function getHostValidities() array('a.', true), array("\xE9", false), array('[::1]', true), + array('[::1]:80', true, '[::1]', 80), + array(str_repeat('.', 101), false), + ); + } + + public function getLongHostNames() + { + return array( + array('a'.str_repeat('.a', 40000)), + array(str_repeat(':', 101)), ); } } From ef23f02415c7a4292d51fe26588288d07f4e8a79 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Tue, 19 Aug 2014 21:49:16 +0100 Subject: [PATCH 1230/1305] [DoctrineBridge] Fix empty parameter logging in the dbal logger --- src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php | 8 ++++---- .../Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php b/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php index 3d103e215c076..617dd5c3faad5 100644 --- a/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php +++ b/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php @@ -56,15 +56,15 @@ public function startQuery($sql, array $params = null, array $types = null) } // non utf-8 strings break json encoding - if (!preg_match('#[\p{L}\p{N} ]#u', $params[$index])) { + if (!preg_match('//u', $params[$index])) { $params[$index] = self::BINARY_DATA_VALUE; continue; } // detect if the too long string must be shorten - if (function_exists('mb_detect_encoding') && false !== $encoding = mb_detect_encoding($params[$index])) { - if (self::MAX_STRING_LENGTH < mb_strlen($params[$index], $encoding)) { - $params[$index] = mb_substr($params[$index], 0, self::MAX_STRING_LENGTH - 6, $encoding).' [...]'; + if (function_exists('mb_strlen')) { + if (self::MAX_STRING_LENGTH < mb_strlen($params[$index], 'UTF-8')) { + $params[$index] = mb_substr($params[$index], 0, self::MAX_STRING_LENGTH - 6, 'UTF-8').' [...]'; continue; } } else { diff --git a/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php b/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php index 741c894e333a5..0c39008d49959 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php @@ -43,7 +43,10 @@ public function getLogFixtures() return array( array('SQL', null, array()), array('SQL', array(), array()), - array('SQL', array('foo' => 'bar'), array('foo' => 'bar')) + array('SQL', array('foo' => 'bar'), array('foo' => 'bar')), + array('SQL', array('foo' => "\x7F\xFF"), array('foo' => DbalLogger::BINARY_DATA_VALUE)), + array('SQL', array('foo' => "bar\x7F\xFF"), array('foo' => DbalLogger::BINARY_DATA_VALUE)), + array('SQL', array('foo' => ''), array('foo' => '')), ); } From cefe237c6f2c903b4c38d139808b883291260a18 Mon Sep 17 00:00:00 2001 From: Damien Tournoud Date: Fri, 22 Aug 2014 18:41:26 +0200 Subject: [PATCH 1231/1305] fix parsing of Authorization header --- .../Component/HttpFoundation/ServerBag.php | 6 +++--- .../HttpFoundation/Tests/ServerBagTest.php | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/ServerBag.php b/src/Symfony/Component/HttpFoundation/ServerBag.php index de6dbc9fb533b..6a4f2c2b167e0 100644 --- a/src/Symfony/Component/HttpFoundation/ServerBag.php +++ b/src/Symfony/Component/HttpFoundation/ServerBag.php @@ -65,13 +65,13 @@ public function getHeaders() } if (null !== $authorizationHeader) { - if (0 === stripos($authorizationHeader, 'basic')) { + if (0 === stripos($authorizationHeader, 'basic ')) { // Decode AUTHORIZATION header into PHP_AUTH_USER and PHP_AUTH_PW when authorization header is basic - $exploded = explode(':', base64_decode(substr($authorizationHeader, 6))); + $exploded = explode(':', base64_decode(substr($authorizationHeader, 6)), 2); if (count($exploded) == 2) { list($headers['PHP_AUTH_USER'], $headers['PHP_AUTH_PW']) = $exploded; } - } elseif (empty($this->parameters['PHP_AUTH_DIGEST']) && (0 === stripos($authorizationHeader, 'digest'))) { + } elseif (empty($this->parameters['PHP_AUTH_DIGEST']) && (0 === stripos($authorizationHeader, 'digest '))) { // In some circumstances PHP_AUTH_DIGEST needs to be set $headers['PHP_AUTH_DIGEST'] = $authorizationHeader; $this->parameters['PHP_AUTH_DIGEST'] = $authorizationHeader; diff --git a/src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php index 89920f1fbc546..2fef317978e0e 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php @@ -67,6 +67,15 @@ public function testHttpBasicAuthWithPhpCgi() ), $bag->getHeaders()); } + public function testHttpBasicAuthWithPhpCgiBogus() + { + $bag = new ServerBag(array('HTTP_AUTHORIZATION' => 'Basic_'.base64_encode('foo:bar'))); + + $this->assertEquals(array( + 'AUTHORIZATION' => 'Basic_'.base64_encode('foo:bar'), + ), $bag->getHeaders()); + } + public function testHttpBasicAuthWithPhpCgiRedirect() { $bag = new ServerBag(array('REDIRECT_HTTP_AUTHORIZATION' => 'Basic '.base64_encode('foo:bar'))); @@ -100,6 +109,16 @@ public function testHttpDigestAuthWithPhpCgi() ), $bag->getHeaders()); } + public function testHttpDigestAuthWithPhpCgiBogus() + { + $digest = 'Digest_username="foo", realm="acme", nonce="'.md5('secret').'", uri="/protected, qop="auth"'; + $bag = new ServerBag(array('HTTP_AUTHORIZATION' => $digest)); + + $this->assertEquals(array( + 'AUTHORIZATION' => $digest, + ), $bag->getHeaders()); + } + public function testHttpDigestAuthWithPhpCgiRedirect() { $digest = 'Digest username="foo", realm="acme", nonce="'.md5('secret').'", uri="/protected, qop="auth"'; From b591404bee6582a92ddf80e6cae7852082426913 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Mon, 25 Aug 2014 10:05:09 +0200 Subject: [PATCH 1232/1305] Fixed the phpdoc of the VoterInterface --- .../Security/Core/Authorization/Voter/VoterInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Core/Authorization/Voter/VoterInterface.php b/src/Symfony/Component/Security/Core/Authorization/Voter/VoterInterface.php index abc18b438b0f9..79fa69f8a9c77 100644 --- a/src/Symfony/Component/Security/Core/Authorization/Voter/VoterInterface.php +++ b/src/Symfony/Component/Security/Core/Authorization/Voter/VoterInterface.php @@ -49,7 +49,7 @@ public function supportsClass($class); * ACCESS_GRANTED, ACCESS_DENIED, or ACCESS_ABSTAIN. * * @param TokenInterface $token A TokenInterface instance - * @param object $object The object to secure + * @param object|null $object The object to secure * @param array $attributes An array of attributes associated with the method being invoked * * @return int either ACCESS_GRANTED, ACCESS_ABSTAIN, or ACCESS_DENIED From 39c4cc387d899c534675b875acd85eda13dfd4c1 Mon Sep 17 00:00:00 2001 From: Jakub Kulhan Date: Sun, 24 Aug 2014 23:36:12 +0200 Subject: [PATCH 1233/1305] [DependencyInjection] fix @return anno created by PhpDumper --- .../DependencyInjection/Dumper/PhpDumper.php | 2 +- .../Tests/Fixtures/php/services10.php | 2 +- .../Tests/Fixtures/php/services11.php | 2 +- .../Tests/Fixtures/php/services9.php | 16 ++++++++-------- .../Tests/Fixtures/php/services9_compiled.php | 18 +++++++++--------- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index ddcfe2a8f8485..7e18a52022db7 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -508,7 +508,7 @@ private function addService($id, $definition) if ($definition->isSynthetic()) { $return[] = '@throws RuntimeException always since this service is expected to be injected dynamically'; } elseif ($class = $definition->getClass()) { - $return[] = sprintf("@return %s A %s instance.", 0 === strpos($class, '%') ? 'object' : $class, $class); + $return[] = sprintf("@return %s A %s instance.", 0 === strpos($class, '%') ? 'object' : "\\".$class, $class); } elseif ($definition->getFactoryClass()) { $return[] = sprintf('@return object An instance returned by %s::%s().', $definition->getFactoryClass(), $definition->getFactoryMethod()); } elseif ($definition->getFactoryService()) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php index ca9695adca9f5..37927a6e7021b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php @@ -44,7 +44,7 @@ public function __construct() * This service is shared. * This method always returns the same instance of the service. * - * @return stdClass A stdClass instance. + * @return \stdClass A stdClass instance. */ protected function getTestService() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services11.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services11.php index 58697423f6961..0dcd83845a58e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services11.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services11.php @@ -42,7 +42,7 @@ public function __construct() * This service is shared. * This method always returns the same instance of the service. * - * @return stdClass A stdClass instance. + * @return \stdClass A stdClass instance. */ protected function getFooService() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php index 8bbea0e012190..a4b42d78adc85 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php @@ -47,7 +47,7 @@ public function __construct() * This service is shared. * This method always returns the same instance of the service. * - * @return FooClass A FooClass instance. + * @return \FooClass A FooClass instance. */ protected function getBarService() { @@ -64,7 +64,7 @@ protected function getBarService() * This service is shared. * This method always returns the same instance of the service. * - * @return Baz A Baz instance. + * @return \Baz A Baz instance. */ protected function getBazService() { @@ -81,7 +81,7 @@ protected function getBazService() * This service is shared. * This method always returns the same instance of the service. * - * @return stdClass A stdClass instance. + * @return \stdClass A stdClass instance. */ protected function getDependsOnRequestService() { @@ -98,7 +98,7 @@ protected function getDependsOnRequestService() * This service is shared. * This method always returns the same instance of the service. * - * @return Bar A Bar instance. + * @return \Bar A Bar instance. */ protected function getFactoryServiceService() { @@ -111,7 +111,7 @@ protected function getFactoryServiceService() * This service is shared. * This method always returns the same instance of the service. * - * @return FooClass A FooClass instance. + * @return \FooClass A FooClass instance. */ protected function getFooService() { @@ -164,7 +164,7 @@ protected function getFooBarService() * This service is shared. * This method always returns the same instance of the service. * - * @return Foo A Foo instance. + * @return \Foo A Foo instance. */ protected function getFooWithInlineService() { @@ -181,7 +181,7 @@ protected function getFooWithInlineService() * This service is shared. * This method always returns the same instance of the service. * - * @return FooClass A FooClass instance. + * @return \FooClass A FooClass instance. */ protected function getMethodCall1Service() { @@ -234,7 +234,7 @@ protected function synchronizeRequestService() * If you want to be able to request this service from the container directly, * make it public, otherwise you might end up with broken code. * - * @return Bar A Bar instance. + * @return \Bar A Bar instance. */ protected function getInlinedService() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php index 629499a608240..b881b5e3004a3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php @@ -55,7 +55,7 @@ public function __construct() * This service is shared. * This method always returns the same instance of the service. * - * @return FooClass A FooClass instance. + * @return \FooClass A FooClass instance. */ protected function getBarService() { @@ -72,7 +72,7 @@ protected function getBarService() * This service is shared. * This method always returns the same instance of the service. * - * @return Baz A Baz instance. + * @return \Baz A Baz instance. */ protected function getBazService() { @@ -89,7 +89,7 @@ protected function getBazService() * This service is shared. * This method always returns the same instance of the service. * - * @return stdClass A stdClass instance. + * @return \stdClass A stdClass instance. */ protected function getDependsOnRequestService() { @@ -106,7 +106,7 @@ protected function getDependsOnRequestService() * This service is shared. * This method always returns the same instance of the service. * - * @return Bar A Bar instance. + * @return \Bar A Bar instance. */ protected function getFactoryServiceService() { @@ -119,7 +119,7 @@ protected function getFactoryServiceService() * This service is shared. * This method always returns the same instance of the service. * - * @return FooClass A FooClass instance. + * @return \FooClass A FooClass instance. */ protected function getFooService() { @@ -143,7 +143,7 @@ protected function getFooService() * This service is shared. * This method always returns the same instance of the service. * - * @return BazClass A BazClass instance. + * @return \BazClass A BazClass instance. */ protected function getFoo_BazService() { @@ -157,7 +157,7 @@ protected function getFoo_BazService() /** * Gets the 'foo_bar' service. * - * @return FooClass A FooClass instance. + * @return \FooClass A FooClass instance. */ protected function getFooBarService() { @@ -170,7 +170,7 @@ protected function getFooBarService() * This service is shared. * This method always returns the same instance of the service. * - * @return Foo A Foo instance. + * @return \Foo A Foo instance. */ protected function getFooWithInlineService() { @@ -192,7 +192,7 @@ protected function getFooWithInlineService() * This service is shared. * This method always returns the same instance of the service. * - * @return FooClass A FooClass instance. + * @return \FooClass A FooClass instance. */ protected function getMethodCall1Service() { From 808de2b284b6bb173bc25e009f0b5a873b6e5f7f Mon Sep 17 00:00:00 2001 From: Sam Malone Date: Wed, 27 Aug 2014 03:57:26 +0100 Subject: [PATCH 1234/1305] [Validator] Fixed wrong translation keys/messages for Collection constraint. The error messages for a missing field and an unexpected field did not match the Contraint class --- .../Validator/Resources/translations/validators.af.xlf | 8 ++++---- .../Validator/Resources/translations/validators.ar.xlf | 8 ++++---- .../Validator/Resources/translations/validators.bg.xlf | 8 ++++---- .../Validator/Resources/translations/validators.ca.xlf | 8 ++++---- .../Validator/Resources/translations/validators.cs.xlf | 8 ++++---- .../Validator/Resources/translations/validators.cy.xlf | 8 ++++---- .../Validator/Resources/translations/validators.da.xlf | 8 ++++---- .../Validator/Resources/translations/validators.de.xlf | 8 ++++---- .../Validator/Resources/translations/validators.el.xlf | 8 ++++---- .../Validator/Resources/translations/validators.en.xlf | 8 ++++---- .../Validator/Resources/translations/validators.es.xlf | 8 ++++---- .../Validator/Resources/translations/validators.et.xlf | 8 ++++---- .../Validator/Resources/translations/validators.eu.xlf | 8 ++++---- .../Validator/Resources/translations/validators.fa.xlf | 0 .../Validator/Resources/translations/validators.fi.xlf | 8 ++++---- .../Validator/Resources/translations/validators.fr.xlf | 8 ++++---- .../Validator/Resources/translations/validators.gl.xlf | 8 ++++---- .../Validator/Resources/translations/validators.he.xlf | 8 ++++---- .../Validator/Resources/translations/validators.hr.xlf | 8 ++++---- .../Validator/Resources/translations/validators.hu.xlf | 8 ++++---- .../Validator/Resources/translations/validators.hy.xlf | 8 ++++---- .../Validator/Resources/translations/validators.id.xlf | 8 ++++---- .../Validator/Resources/translations/validators.it.xlf | 8 ++++---- .../Validator/Resources/translations/validators.ja.xlf | 8 ++++---- .../Validator/Resources/translations/validators.lb.xlf | 0 .../Validator/Resources/translations/validators.lt.xlf | 8 ++++---- .../Validator/Resources/translations/validators.mn.xlf | 8 ++++---- .../Validator/Resources/translations/validators.nb.xlf | 8 ++++---- .../Validator/Resources/translations/validators.nl.xlf | 8 ++++---- .../Validator/Resources/translations/validators.no.xlf | 8 ++++---- .../Validator/Resources/translations/validators.pl.xlf | 8 ++++---- .../Validator/Resources/translations/validators.pt.xlf | 8 ++++---- .../Validator/Resources/translations/validators.pt_BR.xlf | 8 ++++---- .../Validator/Resources/translations/validators.ro.xlf | 8 ++++---- .../Validator/Resources/translations/validators.ru.xlf | 8 ++++---- .../Validator/Resources/translations/validators.sk.xlf | 8 ++++---- .../Validator/Resources/translations/validators.sl.xlf | 8 ++++---- .../Validator/Resources/translations/validators.sq.xlf | 8 ++++---- .../Resources/translations/validators.sr_Cyrl.xlf | 8 ++++---- .../Resources/translations/validators.sr_Latn.xlf | 8 ++++---- .../Validator/Resources/translations/validators.sv.xlf | 8 ++++---- .../Validator/Resources/translations/validators.th.xlf | 8 ++++---- .../Validator/Resources/translations/validators.tr.xlf | 8 ++++---- .../Validator/Resources/translations/validators.uk.xlf | 8 ++++---- .../Validator/Resources/translations/validators.vi.xlf | 8 ++++---- .../Validator/Resources/translations/validators.zh_CN.xlf | 8 ++++---- .../Validator/Resources/translations/validators.zh_TW.xlf | 8 ++++---- 47 files changed, 180 insertions(+), 180 deletions(-) mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.af.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.ar.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.bg.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.ca.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.cs.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.cy.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.da.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.de.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.el.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.en.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.es.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.et.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.eu.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.fa.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.fi.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.gl.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.he.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.hu.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.hy.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.id.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.it.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.ja.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.lb.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.mn.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.no.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.pt.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.pt_BR.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.ro.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.ru.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.sk.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.sl.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.sq.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.sr_Cyrl.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.sr_Latn.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.sv.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.th.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.tr.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.uk.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.zh_CN.xlf mode change 100644 => 100755 src/Symfony/Component/Validator/Resources/translations/validators.zh_TW.xlf diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.af.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.af.xlf old mode 100644 new mode 100755 index 6100400159013..8cb8bf4ddbceb --- a/src/Symfony/Component/Validator/Resources/translations/validators.af.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.af.xlf @@ -35,12 +35,12 @@ Een of meer van die gegewe waardes is ongeldig.
    - The fields {{ fields }} were not expected. - Die velde {{ fields }} is nie verwag nie. + This field was not expected. + Die veld is nie verwag nie. - The fields {{ fields }} are missing. - Die velde {{ fields }} ontbreek. + This field is missing. + Hierdie veld ontbreek. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.ar.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.ar.xlf old mode 100644 new mode 100755 index 2fbc304106bfd..2c83daf09e258 --- a/src/Symfony/Component/Validator/Resources/translations/validators.ar.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.ar.xlf @@ -35,12 +35,12 @@ واحد أو أكثر من القيم المعطاه خاطئ. - The fields {{ fields }} were not expected. - القيم {{ fields }} لم تكن متوقعة. + This field was not expected. + لم يكن من المتوقع هذا المجال. - The fields {{ fields }} are missing. - القيم {{ fields }} مفقودة. + This field is missing. + هذا المجال مفقود. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.bg.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.bg.xlf old mode 100644 new mode 100755 index 4f96dbb5b867b..d1c2b1f785216 --- a/src/Symfony/Component/Validator/Resources/translations/validators.bg.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.bg.xlf @@ -35,12 +35,12 @@ Една или повече от зададените стойности е невалидна. - The fields {{ fields }} were not expected. - Полетата {{ fields }} не бяха очаквани. + This field was not expected. + Това поле не се е очаквало. - The fields {{ fields }} are missing. - Полетата {{ fields }} липсват. + This field is missing. + Това поле липсва. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.ca.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.ca.xlf old mode 100644 new mode 100755 index 4b42b819b9a1a..56223aaa428c6 --- a/src/Symfony/Component/Validator/Resources/translations/validators.ca.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.ca.xlf @@ -35,12 +35,12 @@ Un o més dels valors facilitats són incorrectes. - The fields {{ fields }} were not expected. - No s'esperaven els camps {{ fields }}. + This field was not expected. + Aquest camp no s'esperava. - The fields {{ fields }} are missing. - Falten els camps {{ fields }}. + This field is missing. + Aquest camp està desaparegut. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.cs.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.cs.xlf old mode 100644 new mode 100755 index 6310279caef54..ba6853be90dfe --- a/src/Symfony/Component/Validator/Resources/translations/validators.cs.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.cs.xlf @@ -35,12 +35,12 @@ Některé z uvedených hodnot jsou neplatné. - The fields {{ fields }} were not expected. - Neočekávaná pole {{ fields }}. + This field was not expected. + Toto pole nebyla očekávána. - The fields {{ fields }} are missing. - Chybí následující pole {{ fields }}. + This field is missing. + Toto pole chybí. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.cy.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.cy.xlf old mode 100644 new mode 100755 index b9f5f82d0cc01..fd62ba2f27bb0 --- a/src/Symfony/Component/Validator/Resources/translations/validators.cy.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.cy.xlf @@ -35,12 +35,12 @@ Mae un neu fwy o'r gwerthoedd a roddwyd yn annilys. - The fields {{ fields }} were not expected. - Roedd y maesydd {{ fields }} yn anisgwyl. + This field was not expected. + Nid oedd disgwyl y maes hwn. - The fields {{ fields }} are missing. - Roedd y maesydd {{ fields }} ar goll. + This field is missing. + Mae'r maes hwn ar goll. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.da.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.da.xlf old mode 100644 new mode 100755 index 8b355145cf8e6..ccc6bfb01686c --- a/src/Symfony/Component/Validator/Resources/translations/validators.da.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.da.xlf @@ -35,12 +35,12 @@ En eller flere af de oplyste værdier er ugyldige. - The fields {{ fields }} were not expected. - Felterne {{ fields }} var ikke forventet. + This field was not expected. + Feltet blev ikke forventet. - The fields {{ fields }} are missing. - Felterne {{ fields }} mangler. + This field is missing. + Dette felt er mangler. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.de.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.de.xlf old mode 100644 new mode 100755 index b3d9944b78e3a..3d84e70b7bc70 --- a/src/Symfony/Component/Validator/Resources/translations/validators.de.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.de.xlf @@ -35,12 +35,12 @@ Einer oder mehrere der angegebenen Werte sind ungültig. - The fields {{ fields }} were not expected. - Die Felder {{ fields }} wurden nicht erwartet. + This field was not expected. + Dieses Feld wurde nicht erwartet. - The fields {{ fields }} are missing. - Die erwarteten Felder {{ fields }} fehlen. + This field is missing. + Dieses Feld fehlt. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.el.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.el.xlf old mode 100644 new mode 100755 index 6bf3c146e9a1a..3e90c3cd2c6d1 --- a/src/Symfony/Component/Validator/Resources/translations/validators.el.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.el.xlf @@ -35,12 +35,12 @@ Μια ή περισσότερες τιμές δεν είναι έγκυρες. - The fields {{ fields }} were not expected. - Τα πεδία {{ fields }} δεν ήταν αναμενόμενα. + This field was not expected. + Αυτό το πεδίο δεν ήταν αναμενόμενο. - The fields {{ fields }} are missing. - Τα πεδία {{ fields }} απουσιάζουν. + This field is missing. + Λείπει αυτό το πεδίο. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.en.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.en.xlf old mode 100644 new mode 100755 index 756b80b37f962..b4c8b60bd48b6 --- a/src/Symfony/Component/Validator/Resources/translations/validators.en.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.en.xlf @@ -35,12 +35,12 @@ One or more of the given values is invalid. - The fields {{ fields }} were not expected. - The fields {{ fields }} were not expected. + This field was not expected. + This field was not expected. - The fields {{ fields }} are missing. - The fields {{ fields }} are missing. + This field is missing. + This field is missing. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.es.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.es.xlf old mode 100644 new mode 100755 index 07848aae5f40b..1815e62eaceef --- a/src/Symfony/Component/Validator/Resources/translations/validators.es.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.es.xlf @@ -35,12 +35,12 @@ Uno o más de los valores indicados no son válidos. - The fields {{ fields }} were not expected. - No se esperaban los campos {{ fields }}. + This field was not expected. + Este campo no se esperaba. - The fields {{ fields }} are missing. - Faltan los campos {{ fields }}. + This field is missing. + Este campo está desaparecido. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.et.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.et.xlf old mode 100644 new mode 100755 index b296b6b82bc85..7208670e4334e --- a/src/Symfony/Component/Validator/Resources/translations/validators.et.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.et.xlf @@ -35,12 +35,12 @@ One or more of the given values is invalid. - The fields {{ fields }} were not expected. - Väljad {{ fields }} olid ootamatud. + This field was not expected. + See väli ei oodatud. - The fields {{ fields }} are missing. - Väljad {{ fields }} on puudu. + This field is missing. + See väli on puudu. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.eu.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.eu.xlf old mode 100644 new mode 100755 index 62801cce83e25..298dd4625449f --- a/src/Symfony/Component/Validator/Resources/translations/validators.eu.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.eu.xlf @@ -35,12 +35,12 @@ Emandako balioetatik gutxienez bat ez da egokia. - The fields {{ fields }} were not expected. - {{ fields }} eremuak ez ziren espero. + This field was not expected. + Eremu hau ez zen espero. - The fields {{ fields }} are missing. - {{ fields }} eremuak falta dira. + This field is missing. + Eremu hau falta da. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.fa.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.fa.xlf old mode 100644 new mode 100755 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.fi.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.fi.xlf old mode 100644 new mode 100755 index 99f90b09f1641..26f0177148803 --- a/src/Symfony/Component/Validator/Resources/translations/validators.fi.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.fi.xlf @@ -35,12 +35,12 @@ Yksi tai useampi annetuista arvoista on virheellinen. - The fields {{ fields }} were not expected. - Odottamattomia kenttiä {{ fields }}. + This field was not expected. + Tässä kentässä ei odotettu. - The fields {{ fields }} are missing. - Kentät {{ fields }} puuttuvat. + This field is missing. + Tämä kenttä puuttuu. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf old mode 100644 new mode 100755 index caa457823df42..0ad0592079202 --- a/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf @@ -35,12 +35,12 @@ Une ou plusieurs des valeurs soumises sont invalides. - The fields {{ fields }} were not expected. - Les champs {{ fields }} n'ont pas été prévus. + This field was not expected. + Ce champ n'a pas été prévu. - The fields {{ fields }} are missing. - Les champs {{ fields }} sont manquants. + This field is missing. + Ce champ est manquant. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.gl.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.gl.xlf old mode 100644 new mode 100755 index 7d9f34cceeb71..13c7ffe0d29b2 --- a/src/Symfony/Component/Validator/Resources/translations/validators.gl.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.gl.xlf @@ -35,12 +35,12 @@ Un ou máis dos valores indicados non son válidos. - The fields {{ fields }} were not expected. - Non se esperaban os campos {{ fields }}. + This field was not expected. + Este campo non era esperado. - The fields {{ fields }} are missing. - Faltan os campos {{ fields }}. + This field is missing. + Este campo falta. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.he.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.he.xlf old mode 100644 new mode 100755 index 520e5bae72a82..fb8c7c6cc51c7 --- a/src/Symfony/Component/Validator/Resources/translations/validators.he.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.he.xlf @@ -35,12 +35,12 @@ אחד או יותר מהערכים אינו חוקי. - The fields {{ fields }} were not expected. - השדות {{ fields }} לא היו צפויים. + This field was not expected. + שדה זה לא היה צפוי - The fields {{ fields }} are missing. - השדות {{ fields }} חסרים. + This field is missing. + שדה זה חסר. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf old mode 100644 new mode 100755 index bfe76e6e8cfbb..53f914b25f3f6 --- a/src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf @@ -35,12 +35,12 @@ Jedna ili više danih vrijednosti nije ispravna. - The fields {{ fields }} were not expected. - Polja {{ fields }} nisu bila očekivana. + This field was not expected. + Ovo polje nije očekivalo. - The fields {{ fields }} are missing. - Polja {{ fields }} nedostaju. + This field is missing. + Ovo polje nedostaje. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.hu.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.hu.xlf old mode 100644 new mode 100755 index b2263dadc829b..3f9bc42337443 --- a/src/Symfony/Component/Validator/Resources/translations/validators.hu.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.hu.xlf @@ -35,12 +35,12 @@ A megadott értékek közül legalább egy érvénytelen. - The fields {{ fields }} were not expected. - Váratlan mezők: {{ fields }}. + This field was not expected. + Ez a mező nem számítottak. - The fields {{ fields }} are missing. - A következő mezők hiányoznak: {{ fields }}. + This field is missing. + Ez a mező hiányzik. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.hy.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.hy.xlf old mode 100644 new mode 100755 index 262b93b8bc960..3c1404975f2db --- a/src/Symfony/Component/Validator/Resources/translations/validators.hy.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.hy.xlf @@ -35,12 +35,12 @@ Մեկ կամ ավելի տրված արժեքները անթույլատրելի են. - The fields {{ fields }} were not expected. - {{ fields }} տողերը չէին սպասվում. + This field was not expected. + Այս դաշտը չի սպասվում. - The fields {{ fields }} are missing. - {{ fields }} տողերը բացակայում են. + This field is missing. + Այս դաշտը բացակայում է. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.id.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.id.xlf old mode 100644 new mode 100755 index 92d9c93788f3f..f4e24d21cac8f --- a/src/Symfony/Component/Validator/Resources/translations/validators.id.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.id.xlf @@ -35,12 +35,12 @@ Satu atau lebih nilai yang diberikan tidak sah. - The fields {{ fields }} were not expected. - Kolom {{ fields }} tidak seperti yang diharapkan. + This field was not expected. + Bidang ini tidak diharapkan. - The fields {{ fields }} are missing. - Kolom {{ fields }} hilang. + This field is missing. + Bidang ini hilang. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf old mode 100644 new mode 100755 index 11db4d8743f1c..8b765bf6426ca --- a/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf @@ -35,12 +35,12 @@ Uno o più valori inseriti non sono validi. - The fields {{ fields }} were not expected. - I campi {{ fields }} non sono validi. + This field was not expected. + Questo campo non è stato previsto. - The fields {{ fields }} are missing. - I campi {{ fields }} sono mancanti. + This field is missing. + Questo campo è manca. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.ja.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.ja.xlf old mode 100644 new mode 100755 index 81463a6f79d5b..62f4c90439b4a --- a/src/Symfony/Component/Validator/Resources/translations/validators.ja.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.ja.xlf @@ -35,12 +35,12 @@ 無効な選択肢が含まれています。 - The fields {{ fields }} were not expected. - フィールド{{ fields }}は無効です。 + This field was not expected. + このフィールドは予期されていませんでした。 - The fields {{ fields }} are missing. - フィールド{{ fields }}は必須です。 + This field is missing. + このフィールドは、欠落しています。 This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.lb.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.lb.xlf old mode 100644 new mode 100755 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf old mode 100644 new mode 100755 index 41b0e3b19a1dd..fd33059f21228 --- a/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf @@ -35,12 +35,12 @@ Viena ar daugiau įvestų reikšmių yra netinkamos. - The fields {{ fields }} were not expected. - Laukai {{ fields }} yra nenumatyti. + This field was not expected. + Nebuvo tikimasi Šis laukas. - The fields {{ fields }} are missing. - Trūkstami laukai {{ fields }}. + This field is missing. + Šiame lauke yra dingęs. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.mn.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.mn.xlf old mode 100644 new mode 100755 index e238061338636..dfe7eebf6d53e --- a/src/Symfony/Component/Validator/Resources/translations/validators.mn.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.mn.xlf @@ -35,12 +35,12 @@ Өгөгдсөн нэг эсвэл нэгээс олон утга буруу байна. - Талбарууд {{ fields }} зөвшөөрөгдөөгүй байна. - {{ fields }}. + This field was not expected. + Энэ талбар нь хүлээгдэж байсан юм. - The fields {{ fields }} are missing. - {{ fields }} талбарууд дутуу байна. + This field is missing. + Энэ талбар нь алга болсон байна. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf old mode 100644 new mode 100755 index 086b8b0b08737..a8b790c7d8640 --- a/src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf @@ -35,12 +35,12 @@ En eller flere av de oppgitte verdier er ugyldige. - The fields {{ fields }} were not expected. - Feltene {{ fields }} var ikke forventet. + This field was not expected. + Dette feltet ikke var forventet. - The fields {{ fields }} are missing. - Feltene {{ fields }} mangler. + This field is missing. + Dette feltet mangler. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf old mode 100644 new mode 100755 index 5b35f1d3019d5..9189706ae0f93 --- a/src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf @@ -35,12 +35,12 @@ Eén of meer van de ingegeven waarden zijn ongeldig. - The fields {{ fields }} were not expected. - De velden {{ fields }} werden niet verwacht. + This field was not expected. + Dit veld was niet verwacht. - The fields {{ fields }} are missing. - De velden {{ fields }} ontbreken. + This field is missing. + Dit veld ontbreekt. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf old mode 100644 new mode 100755 index eeebabab24fa5..566b82e947aed --- a/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf @@ -35,12 +35,12 @@ Ein eller fleire av dei opplyste verdiane er ugyldige. - The fields {{ fields }} were not expected. - Felta {{ fields }} var ikkje forventa. + This field was not expected. + Dette feltet var ikke forventet. - The fields {{ fields }} are missing. - Felta {{ fields }} manglar. + This field is missing. + Dette feltet mangler. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf old mode 100644 new mode 100755 index 4f435ce1fa674..30888dc4d3205 --- a/src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf @@ -35,12 +35,12 @@ Jedna lub więcej z podanych wartości jest nieprawidłowa. - The fields {{ fields }} were not expected. - Pola {{ fields }} nie były oczekiwane. + This field was not expected. + To pole nie spodziewano. - The fields {{ fields }} are missing. - Brakuje pól {{ fields }}. + This field is missing. + To pole jest chybianie. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.pt.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.pt.xlf old mode 100644 new mode 100755 index 354ecc6cc9ba2..ed1685338f78a --- a/src/Symfony/Component/Validator/Resources/translations/validators.pt.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.pt.xlf @@ -35,12 +35,12 @@ Um ou mais dos valores introduzidos não são válidos. - The fields {{ fields }} were not expected. - Os campos {{ fields }} não eram esperados. + This field was not expected. + Este campo não era esperado. - The fields {{ fields }} are missing. - Os campos {{ fields }} estão ausentes. + This field is missing. + Este campo está faltando. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.pt_BR.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.pt_BR.xlf old mode 100644 new mode 100755 index f8b0d9b248a5b..70f5ba47bb3f3 --- a/src/Symfony/Component/Validator/Resources/translations/validators.pt_BR.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.pt_BR.xlf @@ -35,12 +35,12 @@ Um ou mais valores informados são inválidos. - The fields {{ fields }} were not expected. - Os campos {{ fields }} não são esperados. + This field was not expected. + Este campo não era esperado. - The fields {{ fields }} are missing. - Os campos {{ fields }} estão ausentes. + This field is missing. + Este campo está ausente. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.ro.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.ro.xlf old mode 100644 new mode 100755 index 58f3d535d14b8..fa6e38e85a06c --- a/src/Symfony/Component/Validator/Resources/translations/validators.ro.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.ro.xlf @@ -35,12 +35,12 @@ Una sau mai multe dintre valorile furnizate sunt invalide. - The fields {{ fields }} were not expected. - Câmpurile {{ fields }} nu erau așteptate. + This field was not expected. + Acest câmp nu era de aşteptat. - The fields {{ fields }} are missing. - Câmpurile {{ fields }} lipsesc. + This field is missing. + Acest câmp este lipsă. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.ru.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.ru.xlf old mode 100644 new mode 100755 index 6205891ce3003..8e701c3a48870 --- a/src/Symfony/Component/Validator/Resources/translations/validators.ru.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.ru.xlf @@ -35,12 +35,12 @@ Одно или несколько заданных значений недопустимо. - The fields {{ fields }} were not expected. - Поля {{ fields }} не ожидались. + This field was not expected. + Это поле не ожидалось. - The fields {{ fields }} are missing. - Поля {{ fields }} отсутствуют. + This field is missing. + Это поле отсутствует. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.sk.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.sk.xlf old mode 100644 new mode 100755 index 5286002d5d053..c3a699ee80cda --- a/src/Symfony/Component/Validator/Resources/translations/validators.sk.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.sk.xlf @@ -35,12 +35,12 @@ Niektoré z uvedených hodnôt sú neplatné. - The fields {{ fields }} were not expected. - Polia {{ fields }} neboli očakávané. + This field was not expected. + Toto pole sa neočakáva. - The fields {{ fields }} are missing. - Chýbajú polia {{ fields }} . + This field is missing. + Toto pole chýba. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.sl.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.sl.xlf old mode 100644 new mode 100755 index 2542788f348bf..644b88e6a57c0 --- a/src/Symfony/Component/Validator/Resources/translations/validators.sl.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.sl.xlf @@ -35,12 +35,12 @@ Ena ali več podanih vrednosti ni veljavnih. - The fields {{ fields }} were not expected. - Polja {{ fields }} niso bila pričakovana. + This field was not expected. + To polje ni bilo pričakovati. - The fields {{ fields }} are missing. - Polja {{ fields }} manjkajo. + This field is missing. + To polje manjka. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.sq.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.sq.xlf old mode 100644 new mode 100755 index e6190fca11568..f54ad56a22ae3 --- a/src/Symfony/Component/Validator/Resources/translations/validators.sq.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.sq.xlf @@ -35,12 +35,12 @@ Një apo më shumë nga vlerat e dhëna nuk janë të sakta. - The fields {{ fields }} were not expected. - Fushat {{ fields }} nuk ishin të pritura. + This field was not expected. + Kjo fushë nuk pritej. - The fields {{ fields }} are missing. - Fushat {{ fields }} mungojnë. + This field is missing. + Kjo fushë është zhdukur. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.sr_Cyrl.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.sr_Cyrl.xlf old mode 100644 new mode 100755 index c4e8a887591be..c1fbbced8321a --- a/src/Symfony/Component/Validator/Resources/translations/validators.sr_Cyrl.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.sr_Cyrl.xlf @@ -35,12 +35,12 @@ Једна или више вредности је невалидна. - The fields {{ fields }} were not expected. - Поља {{ fields }} нису била очекивана. + This field was not expected. + Ово поље не очекује. - The fields {{ fields }} are missing. - Поља {{ fields }} недостају. + This field is missing. + Ово поље недостаје. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.sr_Latn.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.sr_Latn.xlf old mode 100644 new mode 100755 index 28d23dbbb5228..47f86cd637a27 --- a/src/Symfony/Component/Validator/Resources/translations/validators.sr_Latn.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.sr_Latn.xlf @@ -35,12 +35,12 @@ Jedna ili više vrednosti je nevalidna. - The fields {{ fields }} were not expected. - Polja {{ fields }} nisu bila očekivana. + This field was not expected. + Ovo polje ne očekuje. - The fields {{ fields }} are missing. - Polja {{ fields }} nedostaju. + This field is missing. + Ovo polje nedostaje. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.sv.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.sv.xlf old mode 100644 new mode 100755 index c9d7b37b9ab1a..68eac7d0c60b3 --- a/src/Symfony/Component/Validator/Resources/translations/validators.sv.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.sv.xlf @@ -35,12 +35,12 @@ Ett eller fler av de angivna värdena är ogiltigt. - The fields {{ fields }} were not expected. - Fälten {{ fields }} var oväntade. + This field was not expected. + Det här fältet förväntades inte. - The fields {{ fields }} are missing. - Fälten {{ fields }} saknas. + This field is missing. + Det här fältet saknas. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.th.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.th.xlf old mode 100644 new mode 100755 index 467b39dfc0d6e..0237a308acd5f --- a/src/Symfony/Component/Validator/Resources/translations/validators.th.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.th.xlf @@ -35,12 +35,12 @@ มีบางค่าที่ส่งมาไม่ถูกต้อง - The fields {{ fields }} were not expected. - {{ fields }} ฟิลด์เหล่านี้ไม่ใช่ฟิลด์ที่ถูกต้อง + This field was not expected. + ฟิลด์นี้ที่ไม่ได้คาดหวัง - The fields {{ fields }} are missing. - {{ fields }} ฟิลด์เหล่านี้หายไป + This field is missing. + ฟิลด์นี้จะหายไป This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.tr.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.tr.xlf old mode 100644 new mode 100755 index 331abd40b0242..02b5db2c9826a --- a/src/Symfony/Component/Validator/Resources/translations/validators.tr.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.tr.xlf @@ -35,12 +35,12 @@ Verilen değerlerden bir veya daha fazlası geçersiz. - The fields {{ fields }} were not expected. - {{ fields }} alanları kabul edilmedi. + This field was not expected. + Bu alan beklenen olmadı. - The fields {{ fields }} are missing. - {{ fields }} alanları eksik. + This field is missing. + Bu alan, eksik This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.uk.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.uk.xlf old mode 100644 new mode 100755 index 1832b34a0126d..54118b6001703 --- a/src/Symfony/Component/Validator/Resources/translations/validators.uk.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.uk.xlf @@ -35,12 +35,12 @@ Одне або кілька заданих значень є недопустимі. - The fields {{ fields }} were not expected. - Поля {{ fields }} не очікувалися. + This field was not expected. + Це поле не очікується. - The fields {{ fields }} are missing. - Поля {{ fields }} відсутні. + This field is missing. + Це поле не вистачає. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf old mode 100644 new mode 100755 index 9c952e85aad82..71a44e908baa7 --- a/src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf @@ -35,12 +35,12 @@ Một hoặc nhiều giá trị được chọn không hợp lệ. - The fields {{ fields }} were not expected. - Trường có tên {{ fields }} không được chấp nhận. + This field was not expected. + Lĩnh vực này không được dự kiến. - The fields {{ fields }} are missing. - Trường có tên {{ fields }} không tìm thấy. + This field is missing. + Lĩnh vực này là mất tích. This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.zh_CN.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.zh_CN.xlf old mode 100644 new mode 100755 index ff6efdd135b99..3d529116e66e8 --- a/src/Symfony/Component/Validator/Resources/translations/validators.zh_CN.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.zh_CN.xlf @@ -35,12 +35,12 @@ 一个或者多个给定的值无效。 - The fields {{ fields }} were not expected. - 非预期字段 {{ fields }} 。 + This field was not expected. + 此字段是没有预料到。 - The fields {{ fields }} are missing. - 遗漏字段 {{ fields }} 。 + This field is missing. + 此字段是失踪。 This value is not a valid date. diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.zh_TW.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.zh_TW.xlf old mode 100644 new mode 100755 index e39d32876f157..ae6931c88489e --- a/src/Symfony/Component/Validator/Resources/translations/validators.zh_TW.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.zh_TW.xlf @@ -35,12 +35,12 @@ 一個或者多個給定的值無效。 - The fields {{ fields }} were not expected. - 非預期的欄位 {{ fields }} 。 + This field was not expected. + 此字段是沒有預料到。 - The fields {{ fields }} are missing. - 缺少的欄位 {{ fields }} 。 + This field is missing. + 此字段缺失。 This value is not a valid date. From b9a237c00b908fef24c60ce7740d1f83fbc0c761 Mon Sep 17 00:00:00 2001 From: Johnson Page Date: Wed, 27 Aug 2014 13:52:19 +1000 Subject: [PATCH 1235/1305] [CssSelector] Fix URL to SimonSapin/cssselect repo --- src/Symfony/Component/CssSelector/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/CssSelector/README.md b/src/Symfony/Component/CssSelector/README.md index 623649bedbb23..fae1d4bc9a453 100644 --- a/src/Symfony/Component/CssSelector/README.md +++ b/src/Symfony/Component/CssSelector/README.md @@ -35,7 +35,7 @@ Resources This component is a port of the Python lxml library, which is copyright Infrae and distributed under the BSD license. -Current code is a port of https://github.com/SimonSapin/cssselect@v0.7.1 +Current code is a port of https://github.com/SimonSapin/cssselect/releases/tag/v0.7.1 You can run the unit tests with the following command: From e992f8e3d15d81dffd5776f05c904361434049bf Mon Sep 17 00:00:00 2001 From: Warnar Boekkooi Date: Mon, 11 Aug 2014 17:11:49 +0800 Subject: [PATCH 1236/1305] Fixed Factory services not within the ServiceReferenceGraph. --- .../Compiler/AnalyzeServiceReferencesPass.php | 4 ++ .../AnalyzeServiceReferencesPassTest.php | 20 ++++++++++ .../CheckCircularReferencesPassTest.php | 39 +++++++++++++++++++ .../RemoveUnusedDefinitionsPassTest.php | 27 +++++++++++++ 4 files changed, 90 insertions(+) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php index 4a907ece296cf..f488052596a90 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php @@ -69,7 +69,11 @@ public function process(ContainerBuilder $container) $this->currentId = $id; $this->currentDefinition = $definition; + $this->processArguments($definition->getArguments()); + if ($definition->getFactoryService()) { + $this->processArguments(array(new Reference($definition->getFactoryService()))); + } if (!$this->onlyConstructorArguments) { $this->processArguments($definition->getMethodCalls()); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AnalyzeServiceReferencesPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AnalyzeServiceReferencesPassTest.php index c99659e5a67f6..00322a22d0037 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AnalyzeServiceReferencesPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AnalyzeServiceReferencesPassTest.php @@ -97,6 +97,26 @@ public function testProcessDoesNotSaveDuplicateReferences() $this->assertCount(2, $graph->getNode('a')->getInEdges()); } + public function testProcessDetectsFactoryReferences() + { + $container = new ContainerBuilder(); + + $container + ->register('foo', 'stdClass') + ->setFactoryClass('stdClass') + ->setFactoryMethod('getInstance'); + + $container + ->register('bar', 'stdClass') + ->setFactoryService('foo') + ->setFactoryMethod('getInstance'); + + $graph = $this->process($container); + + $this->assertTrue($graph->hasNode('foo')); + $this->assertCount(1, $graph->getNode('foo')->getInEdges()); + } + protected function process(ContainerBuilder $container) { $pass = new RepeatedPass(array(new AnalyzeServiceReferencesPass())); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php index 085bc519b73eb..8183014c5b0e5 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckCircularReferencesPassTest.php @@ -48,6 +48,26 @@ public function testProcessWithAliases() $this->process($container); } + /** + * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException + */ + public function testProcessWithFactory() + { + $container = new ContainerBuilder(); + + $container + ->register('a', 'stdClass') + ->setFactoryService('b') + ->setFactoryMethod('getInstance'); + + $container + ->register('b', 'stdClass') + ->setFactoryService('a') + ->setFactoryMethod('getInstance'); + + $this->process($container); + } + /** * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException */ @@ -61,6 +81,25 @@ public function testProcessDetectsIndirectCircularReference() $this->process($container); } + /** + * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException + */ + public function testProcessDetectsIndirectCircularReferenceWithFactory() + { + $container = new ContainerBuilder(); + + $container->register('a')->addArgument(new Reference('b')); + + $container + ->register('b', 'stdClass') + ->setFactoryService('c') + ->setFactoryMethod('getInstance'); + + $container->register('c')->addArgument(new Reference('a')); + + $this->process($container); + } + /** * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException */ diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/RemoveUnusedDefinitionsPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/RemoveUnusedDefinitionsPassTest.php index d7e55214a9366..b3e451c551c43 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/RemoveUnusedDefinitionsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/RemoveUnusedDefinitionsPassTest.php @@ -81,6 +81,33 @@ public function testProcessWorksWithInlinedDefinitions() $this->assertTrue($container->hasDefinition('bar')); } + public function testProcessWontRemovePrivateFactory() + { + $container = new ContainerBuilder(); + + $container + ->register('foo', 'stdClass') + ->setFactoryClass('stdClass') + ->setFactoryMethod('getInstance') + ->setPublic(false); + + $container + ->register('bar', 'stdClass') + ->setFactoryService('foo') + ->setFactoryMethod('getInstance') + ->setPublic(false); + + $container + ->register('foobar') + ->addArgument(new Reference('bar')); + + $this->process($container); + + $this->assertTrue($container->hasDefinition('foo')); + $this->assertTrue($container->hasDefinition('bar')); + $this->assertTrue($container->hasDefinition('foobar')); + } + protected function process(ContainerBuilder $container) { $repeatedPass = new RepeatedPass(array(new AnalyzeServiceReferencesPass(), new RemoveUnusedDefinitionsPass())); From 7510d0648e02f17aa9318889bf5b70e31af2ce11 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 27 Aug 2014 10:38:16 +0200 Subject: [PATCH 1237/1305] [Validator] reverted permissions change on translation files --- .../Component/Validator/Resources/translations/validators.af.xlf | 0 .../Component/Validator/Resources/translations/validators.ar.xlf | 0 .../Component/Validator/Resources/translations/validators.bg.xlf | 0 .../Component/Validator/Resources/translations/validators.ca.xlf | 0 .../Component/Validator/Resources/translations/validators.cs.xlf | 0 .../Component/Validator/Resources/translations/validators.cy.xlf | 0 .../Component/Validator/Resources/translations/validators.da.xlf | 0 .../Component/Validator/Resources/translations/validators.de.xlf | 0 .../Component/Validator/Resources/translations/validators.el.xlf | 0 .../Component/Validator/Resources/translations/validators.en.xlf | 0 .../Component/Validator/Resources/translations/validators.es.xlf | 0 .../Component/Validator/Resources/translations/validators.et.xlf | 0 .../Component/Validator/Resources/translations/validators.eu.xlf | 0 .../Component/Validator/Resources/translations/validators.fa.xlf | 0 .../Component/Validator/Resources/translations/validators.fi.xlf | 0 .../Component/Validator/Resources/translations/validators.fr.xlf | 0 .../Component/Validator/Resources/translations/validators.gl.xlf | 0 .../Component/Validator/Resources/translations/validators.he.xlf | 0 .../Component/Validator/Resources/translations/validators.hr.xlf | 0 .../Component/Validator/Resources/translations/validators.hu.xlf | 0 .../Component/Validator/Resources/translations/validators.hy.xlf | 0 .../Component/Validator/Resources/translations/validators.id.xlf | 0 .../Component/Validator/Resources/translations/validators.it.xlf | 0 .../Component/Validator/Resources/translations/validators.ja.xlf | 0 .../Component/Validator/Resources/translations/validators.lb.xlf | 0 .../Component/Validator/Resources/translations/validators.lt.xlf | 0 .../Component/Validator/Resources/translations/validators.mn.xlf | 0 .../Component/Validator/Resources/translations/validators.nb.xlf | 0 .../Component/Validator/Resources/translations/validators.nl.xlf | 0 .../Component/Validator/Resources/translations/validators.no.xlf | 0 .../Component/Validator/Resources/translations/validators.pl.xlf | 0 .../Component/Validator/Resources/translations/validators.pt.xlf | 0 .../Validator/Resources/translations/validators.pt_BR.xlf | 0 .../Component/Validator/Resources/translations/validators.ro.xlf | 0 .../Component/Validator/Resources/translations/validators.ru.xlf | 0 .../Component/Validator/Resources/translations/validators.sk.xlf | 0 .../Component/Validator/Resources/translations/validators.sl.xlf | 0 .../Component/Validator/Resources/translations/validators.sq.xlf | 0 .../Validator/Resources/translations/validators.sr_Cyrl.xlf | 0 .../Validator/Resources/translations/validators.sr_Latn.xlf | 0 .../Component/Validator/Resources/translations/validators.sv.xlf | 0 .../Component/Validator/Resources/translations/validators.th.xlf | 0 .../Component/Validator/Resources/translations/validators.tr.xlf | 0 .../Component/Validator/Resources/translations/validators.uk.xlf | 0 .../Component/Validator/Resources/translations/validators.vi.xlf | 0 .../Validator/Resources/translations/validators.zh_CN.xlf | 0 .../Validator/Resources/translations/validators.zh_TW.xlf | 0 47 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.af.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.ar.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.bg.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.ca.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.cs.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.cy.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.da.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.de.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.el.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.en.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.es.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.et.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.eu.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.fa.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.fi.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.gl.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.he.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.hu.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.hy.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.id.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.it.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.ja.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.lb.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.mn.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.no.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.pt.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.pt_BR.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.ro.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.ru.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.sk.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.sl.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.sq.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.sr_Cyrl.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.sr_Latn.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.sv.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.th.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.tr.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.uk.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.zh_CN.xlf mode change 100755 => 100644 src/Symfony/Component/Validator/Resources/translations/validators.zh_TW.xlf diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.af.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.af.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.ar.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.ar.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.bg.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.bg.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.ca.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.ca.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.cs.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.cs.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.cy.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.cy.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.da.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.da.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.de.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.de.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.el.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.el.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.en.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.en.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.es.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.es.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.et.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.et.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.eu.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.eu.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.fa.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.fa.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.fi.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.fi.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.fr.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.gl.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.gl.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.he.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.he.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.hu.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.hu.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.hy.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.hy.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.id.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.id.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.it.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.ja.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.ja.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.lb.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.lb.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.lt.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.mn.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.mn.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.nb.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.nl.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.no.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.pl.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.pt.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.pt.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.pt_BR.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.pt_BR.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.ro.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.ro.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.ru.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.ru.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.sk.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.sk.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.sl.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.sl.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.sq.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.sq.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.sr_Cyrl.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.sr_Cyrl.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.sr_Latn.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.sr_Latn.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.sv.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.sv.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.th.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.th.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.tr.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.tr.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.uk.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.uk.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.zh_CN.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.zh_CN.xlf old mode 100755 new mode 100644 diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.zh_TW.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.zh_TW.xlf old mode 100755 new mode 100644 From 04834521f1298c8fee2704b1c4b1df43b655eb60 Mon Sep 17 00:00:00 2001 From: Ka Date: Tue, 19 Aug 2014 10:20:36 +0200 Subject: [PATCH 1238/1305] [Filesystem Component] mkdir race condition fix #11626 --- src/Symfony/Component/Filesystem/Filesystem.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index b9dc231f6a0b2..f1a7cfba65998 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -78,7 +78,14 @@ public function mkdir($dirs, $mode = 0777) } if (true !== @mkdir($dir, $mode, true)) { - throw new IOException(sprintf('Failed to create %s', $dir)); + $error = error_get_last(); + if (!is_dir($dir)) { + // The directory was not created by a concurrent process. Let's throw an exception with a developer friendly error message if we have one + if ($error) { + throw new IOException(sprintf('Failed to create "%s": %s.', $dir, $error['message'])); + } + throw new IOException(sprintf('Failed to create "%s"', $dir)); + } } } } From 8ba3b289fe4d21b474cb7b0a346aa697d565bf97 Mon Sep 17 00:00:00 2001 From: Harm van Tilborg Date: Tue, 19 Aug 2014 14:37:53 +0200 Subject: [PATCH 1239/1305] Added fixture to test parsing of hash keys ending with a space and # --- src/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml b/src/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml index 46addfcd3da04..6a7ffeca46f3b 100644 --- a/src/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml +++ b/src/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml @@ -63,3 +63,11 @@ brief: > yaml: 'foo#bar: baz' php: | array('foo#bar' => 'baz') +--- +test: 'Hash key ending with a space and a #' +brief: > + 'Hash key ending with a space and a #' +yaml: | + 'foo #': baz +php: | + array('foo #' => 'baz') From 110f999d05e2bedaf7ed3ec8dd03046f5c0de7de Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 28 Aug 2014 03:42:35 +0200 Subject: [PATCH 1240/1305] [Yaml] fixed mapping keys containing a quoted # --- src/Symfony/Component/Yaml/Parser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index d0aae87ab978e..addb387a48a2f 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -114,7 +114,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = $data[] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport); } } - } elseif (preg_match('#^(?P'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P.+?))?\s*$#u', $this->currentLine, $values) && false === strpos($values['key'],' #')) { + } elseif (preg_match('#^(?P'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P.+?))?\s*$#u', $this->currentLine, $values) && (false === strpos($values['key'],' #') || in_array($values['key'][0], array('"', "'")))) { if ($context && 'sequence' == $context) { throw new ParseException('You cannot define a mapping item when in a sequence'); } From 24d2c9a5f0132c91207222eadca2d96f5b41ac88 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 28 Aug 2014 11:02:24 +0200 Subject: [PATCH 1241/1305] fix some minor typos in tests --- .../Component/Process/Tests/AbstractProcessTest.php | 2 +- .../Process/Tests/SigchildDisabledProcessTest.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index 779fb5cca0bba..6341d3c6d82a1 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -592,7 +592,7 @@ public function testRestart() public function testPhpDeadlock() { - $this->markTestSkipped('Can course PHP to hang'); + $this->markTestSkipped('Can cause PHP to hang'); // Sleep doesn't work as it will allow the process to handle signals and close // file handles from the other end. diff --git a/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php b/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php index 383a532203142..f0adb1faa493d 100644 --- a/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php +++ b/src/Symfony/Component/Process/Tests/SigchildDisabledProcessTest.php @@ -51,7 +51,7 @@ public function testExitCodeCommandFailed() /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException - * @expectedExceptionMessage his PHP has been compiled with --enable-sigchild. Term signal can not be retrieved. + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved. */ public function testProcessIsSignaledIfStopped() { @@ -60,7 +60,7 @@ public function testProcessIsSignaledIfStopped() /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException - * @expectedExceptionMessage his PHP has been compiled with --enable-sigchild. Term signal can not be retrieved. + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved. */ public function testProcessWithTermSignal() { @@ -69,7 +69,7 @@ public function testProcessWithTermSignal() /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException - * @expectedExceptionMessage his PHP has been compiled with --enable-sigchild. Term signal can not be retrieved. + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved. */ public function testProcessIsNotSignaled() { @@ -78,7 +78,7 @@ public function testProcessIsNotSignaled() /** * @expectedException \Symfony\Component\Process\Exception\RuntimeException - * @expectedExceptionMessage his PHP has been compiled with --enable-sigchild. Term signal can not be retrieved. + * @expectedExceptionMessage This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved. */ public function testProcessWithoutTermSignal() { From dd0d6afc2168934972d7e8b33f7094089b2b0ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20St=C3=B6ckler?= Date: Fri, 22 Aug 2014 02:43:44 +0200 Subject: [PATCH 1242/1305] [ClassLoader] Add a __call() method to XcacheClassLoader --- .../Component/ClassLoader/ApcClassLoader.php | 5 ++- .../ClassLoader/XcacheClassLoader.php | 35 +++++++++++++------ 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Component/ClassLoader/ApcClassLoader.php b/src/Symfony/Component/ClassLoader/ApcClassLoader.php index 8ee49fb45d343..513362a50301e 100644 --- a/src/Symfony/Component/ClassLoader/ApcClassLoader.php +++ b/src/Symfony/Component/ClassLoader/ApcClassLoader.php @@ -15,7 +15,7 @@ * ApcClassLoader implements a wrapping autoloader cached in APC for PHP 5.3. * * It expects an object implementing a findFile method to find the file. This - * allow using it as a wrapper around the other loaders of the component (the + * allows using it as a wrapper around the other loaders of the component (the * ClassLoader and the UniversalClassLoader for instance) but also around any * other autoloader following this convention (the Composer one for instance) * @@ -46,7 +46,7 @@ class ApcClassLoader /** * The class loader object being decorated. * - * @var \Symfony\Component\ClassLoader\ClassLoader + * @var object * A class loader object that implements the findFile() method. */ protected $decorated; @@ -133,5 +133,4 @@ public function __call($method, $args) { return call_user_func_array(array($this->decorated, $method), $args); } - } diff --git a/src/Symfony/Component/ClassLoader/XcacheClassLoader.php b/src/Symfony/Component/ClassLoader/XcacheClassLoader.php index 299a79af93283..04a1bf420fe4a 100644 --- a/src/Symfony/Component/ClassLoader/XcacheClassLoader.php +++ b/src/Symfony/Component/ClassLoader/XcacheClassLoader.php @@ -12,7 +12,7 @@ namespace Symfony\Component\ClassLoader; /** - * XcacheClassLoader implements a wrapping autoloader cached in Xcache for PHP 5.3. + * XcacheClassLoader implements a wrapping autoloader cached in XCache for PHP 5.3. * * It expects an object implementing a findFile method to find the file. This * allows using it as a wrapper around the other loaders of the component (the @@ -43,31 +43,38 @@ class XcacheClassLoader { private $prefix; - private $classFinder; + + /** + * The class loader object being decorated. + * + * @var object + * A class loader object that implements the findFile() method. + */ + private $decorated; /** * Constructor. * - * @param string $prefix A prefix to create a namespace in Xcache - * @param object $classFinder An object that implements findFile() method. + * @param string $prefix The XCache namespace prefix to use. + * @param object $decorated A class loader object that implements the findFile() method. * * @throws \RuntimeException * @throws \InvalidArgumentException * * @api */ - public function __construct($prefix, $classFinder) + public function __construct($prefix, $decorated) { - if (!extension_loaded('Xcache')) { - throw new \RuntimeException('Unable to use XcacheClassLoader as Xcache is not enabled.'); + if (!extension_loaded('xcache')) { + throw new \RuntimeException('Unable to use XcacheClassLoader as XCache is not enabled.'); } - if (!method_exists($classFinder, 'findFile')) { + if (!method_exists($decorated, 'findFile')) { throw new \InvalidArgumentException('The class finder must implement a "findFile" method.'); } $this->prefix = $prefix; - $this->classFinder = $classFinder; + $this->decorated = $decorated; } /** @@ -116,10 +123,18 @@ public function findFile($class) if (xcache_isset($this->prefix.$class)) { $file = xcache_get($this->prefix.$class); } else { - $file = $this->classFinder->findFile($class); + $file = $this->decorated->findFile($class); xcache_set($this->prefix.$class, $file); } return $file; } + + /** + * Passes through all unknown calls onto the decorated object. + */ + public function __call($method, $args) + { + return call_user_func_array(array($this->decorated, $method), $args); + } } From 8605c4244136d509abf412d55702ee88423cdb6e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 28 Aug 2014 16:35:12 +0200 Subject: [PATCH 1243/1305] [ClassLoader] simplified phpdoc --- src/Symfony/Component/ClassLoader/XcacheClassLoader.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Symfony/Component/ClassLoader/XcacheClassLoader.php b/src/Symfony/Component/ClassLoader/XcacheClassLoader.php index 04a1bf420fe4a..30096bc83f140 100644 --- a/src/Symfony/Component/ClassLoader/XcacheClassLoader.php +++ b/src/Symfony/Component/ClassLoader/XcacheClassLoader.php @@ -45,10 +45,7 @@ class XcacheClassLoader private $prefix; /** - * The class loader object being decorated. - * - * @var object - * A class loader object that implements the findFile() method. + * @var object A class loader object that implements the findFile() method */ private $decorated; From 0fca35276a27172be055190b6d2010b7827fd02e Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Thu, 28 Aug 2014 22:43:41 +0200 Subject: [PATCH 1244/1305] Disabled the PHPUnit self-update on Travis The 4.2.2 release available on Travis currently ships with a broken self-update command. Given that it is new enough to contain the fixes for the other bugs affecting the build, it is fine to keep using the available phar without updating it. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 00e07241bced4..7b8fb71348d0c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ before_script: - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - sudo locale-gen fr_FR.UTF-8 && sudo update-locale - COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev install - - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "5.3.3" ]; then phpunit --self-update; fi;' +# - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "5.3.3" ]; then phpunit --self-update; fi;' script: - ls -d src/Symfony/*/* | parallel --gnu --keep-order 'echo "Running {} tests"; phpunit --exclude-group tty,benchmark {};' From fc854359159c6e040bbaea7507978bdaec1c8766 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 29 Aug 2014 13:30:22 +0200 Subject: [PATCH 1245/1305] fix handling of empty sequence items When a line contains only a dash it cannot safely be assumed that it contains a nested list or an embedded mapping. If the next line starts with a dash at the same indentation, the current line's item is to be treated as `null`. --- src/Symfony/Component/Yaml/Parser.php | 21 ++++++++++++---- .../Yaml/Tests/Fixtures/YtsBasicTests.yml | 24 +++++++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index addb387a48a2f..5c578e35d3249 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -93,7 +93,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = $c = $this->getRealCurrentLineNb() + 1; $parser = new Parser($c); $parser->refs =& $this->refs; - $data[] = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport); + $data[] = $parser->parse($this->getNextEmbedBlock(null, true), $exceptionOnInvalidType, $objectSupport); } else { if (isset($values['leadspaces']) && ' ' == $values['leadspaces'] @@ -281,15 +281,20 @@ private function getCurrentLineIndentation() /** * Returns the next embed block of YAML. * - * @param int $indentation The indent level at which the block is to be read, or null for default + * @param int $indentation The indent level at which the block is to be read, or null for default + * @param bool $inSequence True if the enclosing data structure is a sequence * * @return string A YAML string * * @throws ParseException When indentation problem are detected */ - private function getNextEmbedBlock($indentation = null) + private function getNextEmbedBlock($indentation = null, $inSequence = false) { - $this->moveToNextLine(); + $oldLineIndentation = $this->getCurrentLineIndentation(); + + if (!$this->moveToNextLine()) { + return; + } if (null === $indentation) { $newIndent = $this->getCurrentLineIndentation(); @@ -305,6 +310,14 @@ private function getNextEmbedBlock($indentation = null) $data = array(substr($this->currentLine, $newIndent)); + if ($inSequence && $oldLineIndentation === $newIndent && '-' === $data[0][0]) { + // the previous line contained a dash but no item content, this line is a sequence item with the same indentation + // and therefore no nested list or mapping + $this->moveToPreviousLine(); + + return; + } + $isItUnindentedCollection = $this->isStringUnIndentedCollectionItem($this->currentLine); // Comments must not be removed inside a string block (ie. after a line ending with "|") diff --git a/src/Symfony/Component/Yaml/Tests/Fixtures/YtsBasicTests.yml b/src/Symfony/Component/Yaml/Tests/Fixtures/YtsBasicTests.yml index ac0efa88d1a1b..dfd93021d18ce 100644 --- a/src/Symfony/Component/Yaml/Tests/Fixtures/YtsBasicTests.yml +++ b/src/Symfony/Component/Yaml/Tests/Fixtures/YtsBasicTests.yml @@ -11,6 +11,30 @@ yaml: | php: | array('apple', 'banana', 'carrot') --- +test: Sequence With Item Being Null In The Middle +brief: | + You can specify a list in YAML by placing each + member of the list on a new line with an opening + dash. These lists are called sequences. +yaml: | + - apple + - + - carrot +php: | + array('apple', null, 'carrot') +--- +test: Sequence With Last Item Being Null +brief: | + You can specify a list in YAML by placing each + member of the list on a new line with an opening + dash. These lists are called sequences. +yaml: | + - apple + - banana + - +php: | + array('apple', 'banana', null) +--- test: Nested Sequences brief: | You can include a sequence within another From 0010fba8b1639a6f6593bad5ee37dbbba4b1d320 Mon Sep 17 00:00:00 2001 From: Miliooo Date: Fri, 29 Aug 2014 21:52:58 +0200 Subject: [PATCH 1246/1305] [HttpKernel] add use statement for phpdoc --- .../Bundle/FrameworkBundle/EventListener/SessionListener.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/EventListener/SessionListener.php b/src/Symfony/Bundle/FrameworkBundle/EventListener/SessionListener.php index 7b5ce51db997d..816eef2aed228 100644 --- a/src/Symfony/Bundle/FrameworkBundle/EventListener/SessionListener.php +++ b/src/Symfony/Bundle/FrameworkBundle/EventListener/SessionListener.php @@ -17,6 +17,7 @@ use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\HttpFoundation\Session\SessionInterface; /** * Sets the session in the request. From c056a9c426af43920e543eaedc66fe919f0ae838 Mon Sep 17 00:00:00 2001 From: Damian Sromek Date: Tue, 26 Aug 2014 13:48:14 +0200 Subject: [PATCH 1247/1305] [Filesystem] Add FTP stream wrapper context option to enable overwrite (override) --- src/Symfony/Component/Filesystem/Filesystem.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index f1a7cfba65998..7de9507e262a5 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -50,7 +50,8 @@ public function copy($originFile, $targetFile, $override = false) if ($doCopy) { // https://bugs.php.net/bug.php?id=64634 $source = fopen($originFile, 'r'); - $target = fopen($targetFile, 'w'); + // Stream context created to allow files overwrite when using FTP stream wrapper - disabled by default + $target = fopen($targetFile, 'w', null, stream_context_create(array('ftp' => array('overwrite' => true)))); stream_copy_to_stream($source, $target); fclose($source); fclose($target); From 8a47b62bd3cd2852ca4618fa7a8bc5334460de10 Mon Sep 17 00:00:00 2001 From: 1emming Date: Sun, 10 Aug 2014 18:59:30 +0200 Subject: [PATCH 1248/1305] [Finder] Fix findertest readability --- .../Component/Finder/Tests/FinderTest.php | 43 ++++++++++++++----- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index da593a7a71799..598821d24f521 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -728,17 +728,30 @@ public function testAccessDeniedException(Adapter\AdapterInterface $adapter) $finder->files()->in(self::$tmpDir); // make 'foo' directory non-readable - chmod(self::$tmpDir.DIRECTORY_SEPARATOR.'foo', 0333); - - try { - $this->assertIterator($this->toAbsolute(array('foo bar', 'test.php', 'test.py')), $finder->getIterator()); - $this->fail('Finder should throw an exception when opening a non-readable directory.'); - } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\\Component\\Finder\\Exception\\AccessDeniedException', $e); + $testDir = self::$tmpDir.DIRECTORY_SEPARATOR.'foo'; + chmod($testDir, 0333); + + if (false === $couldRead = is_readable($testDir)) { + try { + $this->assertIterator($this->toAbsolute(array('foo bar', 'test.php', 'test.py')), $finder->getIterator()); + $this->fail('Finder should throw an exception when opening a non-readable directory.'); + } catch (\Exception $e) { + $expectedExceptionClass = 'Symfony\\Component\\Finder\\Exception\\AccessDeniedException'; + if ($e instanceof \PHPUnit_Framework_ExpectationFailedException) { + $this->fail(sprintf("Expected exception:\n%s\nGot:\n%s\nWith comparison failure:\n%s", $expectedExceptionClass, 'PHPUnit_Framework_ExpectationFailedException', $e->getComparisonFailure()->getExpectedAsString())); + } + + $this->assertInstanceOf($expectedExceptionClass, $e); + } } // restore original permissions - chmod(self::$tmpDir.DIRECTORY_SEPARATOR.'foo', 0777); + chmod($testDir, 0777); + clearstatcache($testDir); + + if ($couldRead) { + $this->markTestSkipped('could read test files while test requires unreadable'); + } } /** @@ -754,12 +767,20 @@ public function testIgnoredAccessDeniedException(Adapter\AdapterInterface $adapt $finder->files()->ignoreUnreadableDirs()->in(self::$tmpDir); // make 'foo' directory non-readable - chmod(self::$tmpDir.DIRECTORY_SEPARATOR.'foo', 0333); + $testDir = self::$tmpDir.DIRECTORY_SEPARATOR.'foo'; + chmod($testDir, 0333); - $this->assertIterator($this->toAbsolute(array('foo bar', 'test.php', 'test.py')), $finder->getIterator()); + if (false === ($couldRead = is_readable($testDir))) { + $this->assertIterator($this->toAbsolute(array('foo bar', 'test.php', 'test.py')), $finder->getIterator()); + } // restore original permissions - chmod(self::$tmpDir.DIRECTORY_SEPARATOR.'foo', 0777); + chmod($testDir, 0777); + clearstatcache($testDir); + + if ($couldRead) { + $this->markTestSkipped('could read test files while test requires unreadable'); + } } private function buildTestData(array $tests) From a8a40fcb9edcd514206526cecf951cae95453a97 Mon Sep 17 00:00:00 2001 From: Michael Tibben Date: Tue, 4 Feb 2014 19:26:21 +1100 Subject: [PATCH 1249/1305] [FrameworkBundle] PhpExtractor bugfix and improvements --- .../Resources/views/translation.html.php | 30 ++++ .../Tests/Translation/PhpExtractorTest.php | 25 ++- .../Translation/PhpExtractor.php | 87 +++++++++-- .../Translation/PhpStringTokenParser.php | 142 ++++++++++++++++++ 4 files changed, 265 insertions(+), 19 deletions(-) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php index 23631b99435e3..2167138a1e312 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php @@ -1,3 +1,33 @@ This template is used for translation message extraction tests trans('single-quoted key') ?> trans("double-quoted key") ?> +trans(<< +trans(<<<'EOF' +nowdoc key +EOF +) ?> +trans( + "double-quoted key with whitespace and escaped \$\n\" sequences" +) ?> +trans( + 'single-quoted key with whitespace and nonescaped \$\n\' sequences' +) ?> +trans( << +trans( <<<'EOF' +nowdoc key with whitespace and nonescaped \$\n sequences +EOF +) ?> + +trans('single-quoted key with "quote mark at the end"') ?> + +transChoice( + '{0} There is no apples|{1} There is one apple|]1,Inf[ There are %count% apples', + 10, + array('%count%' => 10) +) ?> diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/PhpExtractorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/PhpExtractorTest.php index d639f01806a25..52e20b874e8de 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/PhpExtractorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/PhpExtractorTest.php @@ -27,10 +27,27 @@ public function testExtraction() // Act $extractor->extract(__DIR__.'/../Fixtures/Resources/views/', $catalogue); + $expectedHeredoc = <<assertCount(2, $catalogue->all('messages'), '->extract() should find 1 translation'); - $this->assertTrue($catalogue->has('single-quoted key'), '->extract() should find the "single-quoted key" message'); - $this->assertTrue($catalogue->has('double-quoted key'), '->extract() should find the "double-quoted key" message'); - $this->assertEquals('prefixsingle-quoted key', $catalogue->get('single-quoted key'), '->extract() should apply "prefix" as prefix'); + $expectedCatalogue = array('messages' => array( + 'single-quoted key' => 'prefixsingle-quoted key', + 'double-quoted key' => 'prefixdouble-quoted key', + 'heredoc key' => 'prefixheredoc key', + 'nowdoc key' => 'prefixnowdoc key', + "double-quoted key with whitespace and escaped \$\n\" sequences" => "prefixdouble-quoted key with whitespace and escaped \$\n\" sequences", + 'single-quoted key with whitespace and nonescaped \$\n\' sequences' => 'prefixsingle-quoted key with whitespace and nonescaped \$\n\' sequences', + 'single-quoted key with "quote mark at the end"' => 'prefixsingle-quoted key with "quote mark at the end"', + $expectedHeredoc => "prefix".$expectedHeredoc, + $expectedNowdoc => "prefix".$expectedNowdoc, + '{0} There is no apples|{1} There is one apple|]1,Inf[ There are %count% apples' => 'prefix{0} There is no apples|{1} There is one apple|]1,Inf[ There are %count% apples', + )); + $actualCatalogue = $catalogue->all(); + + $this->assertEquals($expectedCatalogue, $actualCatalogue); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php index 1b12c8ca9ee55..99a62fdc6b48d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php @@ -23,7 +23,6 @@ class PhpExtractor implements ExtractorInterface { const MESSAGE_TOKEN = 300; - const IGNORE_TOKEN = 400; /** * Prefix for new found message. @@ -39,15 +38,16 @@ class PhpExtractor implements ExtractorInterface */ protected $sequences = array( array( - '$view', - '[', - '\'translator\'', - ']', '->', 'trans', '(', self::MESSAGE_TOKEN, - ')', + ), + array( + '->', + 'transChoice', + '(', + self::MESSAGE_TOKEN, ), ); @@ -75,7 +75,7 @@ public function setPrefix($prefix) /** * Normalizes a token. * - * @param mixed $token + * @param mixed $token * @return string */ protected function normalizeToken($token) @@ -87,6 +87,60 @@ protected function normalizeToken($token) return $token; } + /** + * Seeks to a non-whitespace token + * + * @param \ArrayIterator $tokenIterator + */ + protected function seekToNextRelaventToken($tokenIterator) + { + for ( ; $tokenIterator->valid(); $tokenIterator->next()) { + $t = $tokenIterator->current(); + if (!is_array($t) || ($t[0] !== T_WHITESPACE)) { + break; + } + } + } + + /** + * Extracts the message from the iterator while the tokens + * match allowed message tokens + * + * @param \ArrayIterator $tokenIterator + */ + protected function getMessage($tokenIterator) + { + $message = ''; + $docToken = ''; + + for ( ; $tokenIterator->valid(); $tokenIterator->next()) { + $t = $tokenIterator->current(); + if (!is_array($t)) { + break; + } + + switch ($t[0]) { + case T_START_HEREDOC: + $docToken = $t[1]; + break; + case T_ENCAPSED_AND_WHITESPACE: + case T_CONSTANT_ENCAPSED_STRING: + $message .= $t[1]; + break; + case T_END_HEREDOC: + return PhpStringTokenParser::parseDocString($docToken, $message); + default: + break 2; + } + } + + if ($message) { + $message = PhpStringTokenParser::parse($message); + } + + return $message; + } + /** * Extracts trans message from PHP tokens. * @@ -95,24 +149,27 @@ protected function normalizeToken($token) */ protected function parseTokens($tokens, MessageCatalogue $catalog) { - foreach ($tokens as $key => $token) { + $tokenIterator = new \ArrayIterator($tokens); + + for ($key = 0; $key < $tokenIterator->count(); $key++) { foreach ($this->sequences as $sequence) { $message = ''; + $tokenIterator->seek($key); - foreach ($sequence as $id => $item) { - if ($this->normalizeToken($tokens[$key + $id]) == $item) { + foreach ($sequence as $item) { + $this->seekToNextRelaventToken($tokenIterator); + + if ($this->normalizeToken($tokenIterator->current()) == $item) { + $tokenIterator->next(); continue; } elseif (self::MESSAGE_TOKEN == $item) { - $message = $this->normalizeToken($tokens[$key + $id]); - } elseif (self::IGNORE_TOKEN == $item) { - continue; + $message = $this->getMessage($tokenIterator); + break; } else { break; } } - $message = trim($message, '\'"'); - if ($message) { $catalog->set($message, $this->prefix.$message); break; diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php new file mode 100644 index 0000000000000..0b29792e52f7c --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php @@ -0,0 +1,142 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Translation; + +/* + * The following is derived from code at http://github.com/nikic/PHP-Parser + * + * Copyright (c) 2011 by Nikita Popov + * + * Some rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * * The names of the contributors may not be used to endorse or + * promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +class PhpStringTokenParser +{ + protected static $replacements = array( + '\\' => '\\', + '$' => '$', + 'n' => "\n", + 'r' => "\r", + 't' => "\t", + 'f' => "\f", + 'v' => "\v", + 'e' => "\x1B", + ); + + /** + * Parses a string token. + * + * @param string $str String token content + * + * @return string The parsed string + */ + public static function parse($str) + { + $bLength = 0; + if ('b' === $str[0]) { + $bLength = 1; + } + + if ('\'' === $str[$bLength]) { + return str_replace( + array('\\\\', '\\\''), + array( '\\', '\''), + substr($str, $bLength + 1, -1) + ); + } else { + return self::parseEscapeSequences(substr($str, $bLength + 1, -1), '"'); + } + } + + /** + * Parses escape sequences in strings (all string types apart from single quoted). + * + * @param string $str String without quotes + * @param null|string $quote Quote type + * + * @return string String with escape sequences parsed + */ + public static function parseEscapeSequences($str, $quote) + { + if (null !== $quote) { + $str = str_replace('\\' . $quote, $quote, $str); + } + + return preg_replace_callback( + '~\\\\([\\\\$nrtfve]|[xX][0-9a-fA-F]{1,2}|[0-7]{1,3})~', + array(__CLASS__, 'parseCallback'), + $str + ); + } + + public static function parseCallback($matches) + { + $str = $matches[1]; + + if (isset(self::$replacements[$str])) { + return self::$replacements[$str]; + } elseif ('x' === $str[0] || 'X' === $str[0]) { + return chr(hexdec($str)); + } else { + return chr(octdec($str)); + } + } + + /** + * Parses a constant doc string. + * + * @param string $startToken Doc string start token content (<< Date: Sun, 31 Aug 2014 06:17:40 +0200 Subject: [PATCH 1250/1305] [FrameworkBundle] fixed CS --- .../Translation/PhpExtractor.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php index 99a62fdc6b48d..67de7da719d9a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpExtractor.php @@ -75,7 +75,8 @@ public function setPrefix($prefix) /** * Normalizes a token. * - * @param mixed $token + * @param mixed $token + * * @return string */ protected function normalizeToken($token) @@ -88,13 +89,11 @@ protected function normalizeToken($token) } /** - * Seeks to a non-whitespace token - * - * @param \ArrayIterator $tokenIterator + * Seeks to a non-whitespace token. */ - protected function seekToNextRelaventToken($tokenIterator) + private function seekToNextReleventToken(\Iterator $tokenIterator) { - for ( ; $tokenIterator->valid(); $tokenIterator->next()) { + for (; $tokenIterator->valid(); $tokenIterator->next()) { $t = $tokenIterator->current(); if (!is_array($t) || ($t[0] !== T_WHITESPACE)) { break; @@ -105,15 +104,13 @@ protected function seekToNextRelaventToken($tokenIterator) /** * Extracts the message from the iterator while the tokens * match allowed message tokens - * - * @param \ArrayIterator $tokenIterator */ - protected function getMessage($tokenIterator) + private function getMessage(\Iterator $tokenIterator) { $message = ''; $docToken = ''; - for ( ; $tokenIterator->valid(); $tokenIterator->next()) { + for (; $tokenIterator->valid(); $tokenIterator->next()) { $t = $tokenIterator->current(); if (!is_array($t)) { break; @@ -157,7 +154,7 @@ protected function parseTokens($tokens, MessageCatalogue $catalog) $tokenIterator->seek($key); foreach ($sequence as $item) { - $this->seekToNextRelaventToken($tokenIterator); + $this->seekToNextReleventToken($tokenIterator); if ($this->normalizeToken($tokenIterator->current()) == $item) { $tokenIterator->next(); From faefd66b10ff4a14c329a3c6f379b7984579d579 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 1 Sep 2014 09:40:12 +0200 Subject: [PATCH 1251/1305] fixing typo in a comment --- src/Symfony/Component/Security/Core/Util/StringUtils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Core/Util/StringUtils.php b/src/Symfony/Component/Security/Core/Util/StringUtils.php index eaeed84779c26..5e130375b725b 100644 --- a/src/Symfony/Component/Security/Core/Util/StringUtils.php +++ b/src/Symfony/Component/Security/Core/Util/StringUtils.php @@ -38,7 +38,7 @@ public static function equals($knownString, $userInput) $knownLen = strlen($knownString); $userLen = strlen($userInput); - // Extend know string to avoid uninitialized string offsets + // Extend the known string to avoid uninitialized string offsets $knownString .= $userInput; // Set the result to the difference between the lengths From 42841e845b5a1a949e7f7ba12d1da40cba7a01d0 Mon Sep 17 00:00:00 2001 From: DQNEO Date: Mon, 1 Sep 2014 02:38:52 +0900 Subject: [PATCH 1252/1305] fix comment: not fourth but sixth argument --- src/Symfony/Component/HttpFoundation/Tests/RequestTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index c2719ac9ab2cd..b32db52edf5a7 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -42,7 +42,7 @@ public function testInitialize() $this->assertEquals('bar', $request->attributes->get('foo'), '->initialize() takes an array of attributes as its third argument'); $request->initialize(array(), array(), array(), array(), array(), array('HTTP_FOO' => 'bar')); - $this->assertEquals('bar', $request->headers->get('FOO'), '->initialize() takes an array of HTTP headers as its fourth argument'); + $this->assertEquals('bar', $request->headers->get('FOO'), '->initialize() takes an array of HTTP headers as its sixth argument'); } public function testGetLocale() From 05f5860c566ecf0e07de45bf9fd3f113b48bbb0d Mon Sep 17 00:00:00 2001 From: DQNEO Date: Mon, 1 Sep 2014 03:06:56 +0900 Subject: [PATCH 1253/1305] [HttpFoundation] Improve string values in test codes --- .../Component/HttpFoundation/Tests/RequestTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index b32db52edf5a7..9eca9171469d4 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -200,23 +200,23 @@ public function testCreate() $this->assertEquals('test.com:90', $request->getHttpHost()); $this->assertFalse($request->isSecure()); - $request = Request::create('http://test:test@test.com'); + $request = Request::create('http://username:password@test.com'); $this->assertEquals('http://test.com/', $request->getUri()); $this->assertEquals('/', $request->getPathInfo()); $this->assertEquals('', $request->getQueryString()); $this->assertEquals(80, $request->getPort()); $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertEquals('test', $request->getUser()); - $this->assertEquals('test', $request->getPassword()); + $this->assertEquals('username', $request->getUser()); + $this->assertEquals('password', $request->getPassword()); $this->assertFalse($request->isSecure()); - $request = Request::create('http://testnopass@test.com'); + $request = Request::create('http://username@test.com'); $this->assertEquals('http://test.com/', $request->getUri()); $this->assertEquals('/', $request->getPathInfo()); $this->assertEquals('', $request->getQueryString()); $this->assertEquals(80, $request->getPort()); $this->assertEquals('test.com', $request->getHttpHost()); - $this->assertEquals('testnopass', $request->getUser()); + $this->assertEquals('username', $request->getUser()); $this->assertSame('',$request->getPassword()); $this->assertFalse($request->isSecure()); From 3b4046e89467dc1fb5e079e377c2cfd4c239f904 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 1 Sep 2014 23:14:11 +0200 Subject: [PATCH 1254/1305] [HttpFoundation] added some missing tests --- .../HttpFoundation/Tests/ServerBagTest.php | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php index 2fef317978e0e..662c5880b170c 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php @@ -71,19 +71,20 @@ public function testHttpBasicAuthWithPhpCgiBogus() { $bag = new ServerBag(array('HTTP_AUTHORIZATION' => 'Basic_'.base64_encode('foo:bar'))); - $this->assertEquals(array( - 'AUTHORIZATION' => 'Basic_'.base64_encode('foo:bar'), - ), $bag->getHeaders()); + // Username and passwords should not be set as the header is bogus + $headers = $bag->getHeaders(); + $this->assertFalse(isset($headers['PHP_AUTH_USER'])); + $this->assertFalse(isset($headers['PHP_AUTH_PW'])); } public function testHttpBasicAuthWithPhpCgiRedirect() { - $bag = new ServerBag(array('REDIRECT_HTTP_AUTHORIZATION' => 'Basic '.base64_encode('foo:bar'))); + $bag = new ServerBag(array('REDIRECT_HTTP_AUTHORIZATION' => 'Basic '.base64_encode('username:pass:word'))); $this->assertEquals(array( - 'AUTHORIZATION' => 'Basic '.base64_encode('foo:bar'), - 'PHP_AUTH_USER' => 'foo', - 'PHP_AUTH_PW' => 'bar' + 'AUTHORIZATION' => 'Basic '.base64_encode('username:pass:word'), + 'PHP_AUTH_USER' => 'username', + 'PHP_AUTH_PW' => 'pass:word' ), $bag->getHeaders()); } @@ -114,9 +115,10 @@ public function testHttpDigestAuthWithPhpCgiBogus() $digest = 'Digest_username="foo", realm="acme", nonce="'.md5('secret').'", uri="/protected, qop="auth"'; $bag = new ServerBag(array('HTTP_AUTHORIZATION' => $digest)); - $this->assertEquals(array( - 'AUTHORIZATION' => $digest, - ), $bag->getHeaders()); + // Username and passwords should not be set as the header is bogus + $headers = $bag->getHeaders(); + $this->assertFalse(isset($headers['PHP_AUTH_USER'])); + $this->assertFalse(isset($headers['PHP_AUTH_PW'])); } public function testHttpDigestAuthWithPhpCgiRedirect() From 101a3b7b501b65838faad49fe51076011f0b72a9 Mon Sep 17 00:00:00 2001 From: Abdellatif Ait boudad Date: Tue, 22 Jul 2014 07:11:06 +0000 Subject: [PATCH 1255/1305] [FrameworkBundle][Translator] Validate locales. --- src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php index 0f99f6428e84e..8bf5353723d1d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php @@ -68,7 +68,7 @@ public function __construct(ContainerInterface $container, MessageSelector $sele public function getLocale() { if (null === $this->locale && $this->container->isScopeActive('request') && $this->container->has('request')) { - $this->locale = $this->container->get('request')->getLocale(); + $this->setLocale($this->container->get('request')->getLocale()); } return $this->locale; From 9e1bc22388d393d320d56f63dfbe006c267582c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Fri, 25 Jul 2014 22:18:02 +0200 Subject: [PATCH 1256/1305] Add tests and more assertions --- .../Tests/Translation/TranslatorTest.php | 68 ++++++++++++++++++- .../Translation/Translator.php | 8 ++- .../Component/HttpFoundation/Request.php | 10 +++ .../Component/Translation/Translator.php | 2 +- 4 files changed, 84 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php index 9f2012816a682..a93dd5e845144 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php @@ -92,6 +92,16 @@ public function testTransWithCaching() $this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax')); } + public function testTransWithCachingWithInvalidLocale() + { + $loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface'); + $translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir), '\Symfony\Bundle\FrameworkBundle\Tests\Translation\TranslatorWithInvalidLocale'); + $translator->setLocale('invalid locale'); + + $this->setExpectedException('\InvalidArgumentException'); + $translator->trans('foo'); + } + public function testGetLocale() { $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); @@ -131,6 +141,49 @@ public function testGetLocale() $this->assertSame('en', $translator->getLocale()); } + public function testGetLocaleWithInvalidLocale() + { + $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); + + $request + ->expects($this->once()) + ->method('getLocale') + ->will($this->returnValue('foo bar')) + ; + $request + ->expects($this->once()) + ->method('getDefaultLocale') + ->will($this->returnValue('en-US')) + ; + + $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + + $container + ->expects($this->once()) + ->method('isScopeActive') + ->with('request') + ->will($this->returnValue(true)) + ; + + $container + ->expects($this->once()) + ->method('has') + ->with('request') + ->will($this->returnValue(true)) + ; + + $container + ->expects($this->any()) + ->method('get') + ->with('request') + ->will($this->returnValue($request)) + ; + + $translator = new Translator($container, new MessageSelector()); + $this->assertSame('en-US', $translator->getLocale()); + } + + protected function getCatalogue($locale, $messages) { $catalogue = new MessageCatalogue($locale); @@ -211,9 +264,9 @@ protected function getContainer($loader) return $container; } - public function getTranslator($loader, $options = array()) + public function getTranslator($loader, $options = array(), $translatorClass = '\Symfony\Bundle\FrameworkBundle\Translation\Translator') { - $translator = new Translator( + $translator = new $translatorClass( $this->getContainer($loader), new MessageSelector(), array('loader' => array('loader')), @@ -231,3 +284,14 @@ public function getTranslator($loader, $options = array()) return $translator; } } + +class TranslatorWithInvalidLocale extends Translator +{ + /** + * {@inheritdoc} + */ + public function setLocale($locale) + { + $this->locale = $locale; + } +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php index 8bf5353723d1d..92f90d4ff5c2b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php @@ -68,7 +68,11 @@ public function __construct(ContainerInterface $container, MessageSelector $sele public function getLocale() { if (null === $this->locale && $this->container->isScopeActive('request') && $this->container->has('request')) { - $this->setLocale($this->container->get('request')->getLocale()); + try { + $this->setLocale($this->container->get('request')->getLocale()); + } catch (\InvalidArgumentException $e) { + $this->setLocale($this->container->get('request')->getDefaultLocale()); + } } return $this->locale; @@ -89,6 +93,8 @@ protected function loadCatalogue($locale) return parent::loadCatalogue($locale); } + $this->assertValidLocale($locale); + $cache = new ConfigCache($this->options['cache_dir'].'/catalogue.'.$locale.'.php', $this->options['debug']); if (!$cache->isFresh()) { $this->initialize(); diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index f50219deae8cf..f180b3e6197f5 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -1358,6 +1358,16 @@ public function setDefaultLocale($locale) } } + /** + * Get the default locale. + * + * @return string + */ + public function getDefaultLocale() + { + return $this->defaultLocale; + } + /** * Sets the locale. * diff --git a/src/Symfony/Component/Translation/Translator.php b/src/Symfony/Component/Translation/Translator.php index 0ed30526d2b43..88178f8a83f17 100644 --- a/src/Symfony/Component/Translation/Translator.php +++ b/src/Symfony/Component/Translation/Translator.php @@ -306,7 +306,7 @@ protected function computeFallbackLocales($locale) * * @throws \InvalidArgumentException If the locale contains invalid characters */ - private function assertValidLocale($locale) + protected function assertValidLocale($locale) { if (1 !== preg_match('/^[a-z0-9@_\\.\\-]*$/i', $locale)) { throw new \InvalidArgumentException(sprintf('Invalid "%s" locale.', $locale)); From 5183501e0b3c9ea2b8e155e247113a0af9cbe53e Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Fri, 11 Jul 2014 13:56:54 +0200 Subject: [PATCH 1257/1305] [DI] Added safeguards against invalid config in the YamlFileLoader Exceptions explaining the mistake are better than fatal errors or weird notices appearing when trying to deal with such invalid data. Closes #11333 --- .../Loader/YamlFileLoader.php | 44 ++++++++++++++++--- .../Tests/Fixtures/yaml/bad_calls.yml | 4 ++ .../Tests/Fixtures/yaml/bad_import.yml | 2 + .../Tests/Fixtures/yaml/bad_imports.yml | 2 + .../Tests/Fixtures/yaml/bad_parameters.yml | 2 + .../Tests/Fixtures/yaml/bad_service.yml | 2 + .../Tests/Fixtures/yaml/bad_services.yml | 1 + .../Tests/Fixtures/yaml/badtag4.yml | 6 +++ .../Tests/Loader/YamlFileLoaderTest.php | 36 ++++++++++++++- 9 files changed, 90 insertions(+), 9 deletions(-) create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_calls.yml create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_import.yml create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_imports.yml create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_parameters.yml create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_service.yml create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_services.yml create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/badtag4.yml diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index cf4cfc75bd510..8fee1bfefadc2 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -55,6 +55,10 @@ public function load($file, $type = null) // parameters if (isset($content['parameters'])) { + if (!is_array($content['parameters'])) { + throw new InvalidArgumentException(sprintf('The "parameters" key should contain an array in %s. Check your YAML syntax.', $file)); + } + foreach ($content['parameters'] as $key => $value) { $this->container->setParameter($key, $this->resolveServices($value)); } @@ -92,7 +96,15 @@ private function parseImports($content, $file) return; } + if (!is_array($content['imports'])) { + throw new InvalidArgumentException(sprintf('The "imports" key should contain an array in %s. Check your YAML syntax.', $file)); + } + foreach ($content['imports'] as $import) { + if (!is_array($import)) { + throw new InvalidArgumentException(sprintf('The values in the "imports" key should be arrays in %s. Check your YAML syntax.', $file)); + } + $this->setCurrentDir(dirname($file)); $this->import($import['resource'], null, isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false, $file); } @@ -110,6 +122,10 @@ private function parseDefinitions($content, $file) return; } + if (!is_array($content['services'])) { + throw new InvalidArgumentException(sprintf('The "services" key should contain an array in %s. Check your YAML syntax.', $file)); + } + foreach ($content['services'] as $id => $service) { $this->parseDefinition($id, $service, $file); } @@ -130,7 +146,13 @@ private function parseDefinition($id, $service, $file) $this->container->setAlias($id, substr($service, 1)); return; - } elseif (isset($service['alias'])) { + } + + if (!is_array($service)) { + throw new InvalidArgumentException(sprintf('A service definition must be an array or a string starting with "@" but %s found for service "%s" in %s. Check your YAML syntax.', gettype($service), $id, $file)); + } + + if (isset($service['alias'])) { $public = !array_key_exists('public', $service) || (bool) $service['public']; $this->container->setAlias($id, new Alias($service['alias'], $public)); @@ -204,6 +226,10 @@ private function parseDefinition($id, $service, $file) } if (isset($service['calls'])) { + if (!is_array($service['calls'])) { + throw new InvalidArgumentException(sprintf('Parameter "calls" must be an array for service "%s" in %s. Check your YAML syntax.', $id, $file)); + } + foreach ($service['calls'] as $call) { $args = isset($call[1]) ? $this->resolveServices($call[1]) : array(); $definition->addMethodCall($call[0], $args); @@ -212,10 +238,14 @@ private function parseDefinition($id, $service, $file) if (isset($service['tags'])) { if (!is_array($service['tags'])) { - throw new InvalidArgumentException(sprintf('Parameter "tags" must be an array for service "%s" in %s.', $id, $file)); + throw new InvalidArgumentException(sprintf('Parameter "tags" must be an array for service "%s" in %s. Check your YAML syntax.', $id, $file)); } foreach ($service['tags'] as $tag) { + if (!is_array($tag)) { + throw new InvalidArgumentException(sprintf('A "tags" entry must be an array for service "%s" in %s. Check your YAML syntax.', $id, $file)); + } + if (!isset($tag['name'])) { throw new InvalidArgumentException(sprintf('A "tags" entry is missing a "name" key for service "%s" in %s.', $id, $file)); } @@ -223,9 +253,9 @@ private function parseDefinition($id, $service, $file) $name = $tag['name']; unset($tag['name']); - foreach ($tag as $attribute => $value) { + foreach ($tag as $value) { if (!is_scalar($value)) { - throw new InvalidArgumentException(sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s" in %s.', $id, $name, $file)); + throw new InvalidArgumentException(sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s" in %s. Check your YAML syntax.', $id, $name, $file)); } } @@ -279,7 +309,7 @@ private function validate($content, $file) } if (!is_array($content)) { - throw new InvalidArgumentException(sprintf('The service file "%s" is not valid.', $file)); + throw new InvalidArgumentException(sprintf('The service file "%s" is not valid. It should contain an array. Check your YAML syntax.', $file)); } foreach (array_keys($content) as $namespace) { @@ -305,9 +335,9 @@ private function validate($content, $file) /** * Resolves services. * - * @param string $value + * @param string|array $value * - * @return Reference + * @return array|string|Reference */ private function resolveServices($value) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_calls.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_calls.yml new file mode 100644 index 0000000000000..3f34b07eb0eaa --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_calls.yml @@ -0,0 +1,4 @@ +services: + method_call1: + class: FooClass + calls: foo diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_import.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_import.yml new file mode 100644 index 0000000000000..0765dc8dd0856 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_import.yml @@ -0,0 +1,2 @@ +imports: + - foo.yml diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_imports.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_imports.yml new file mode 100644 index 0000000000000..1ce9d57c6c728 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_imports.yml @@ -0,0 +1,2 @@ +imports: + foo:bar diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_parameters.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_parameters.yml new file mode 100644 index 0000000000000..bbd13ac0b349a --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_parameters.yml @@ -0,0 +1,2 @@ +parameters: + foo:bar diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_service.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_service.yml new file mode 100644 index 0000000000000..811af3c0efd79 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_service.yml @@ -0,0 +1,2 @@ +services: + foo: bar diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_services.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_services.yml new file mode 100644 index 0000000000000..cfbf17ce5f8c6 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/bad_services.yml @@ -0,0 +1 @@ +services: foo diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/badtag4.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/badtag4.yml new file mode 100644 index 0000000000000..e8e99395b1fdf --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/badtag4.yml @@ -0,0 +1,6 @@ +services: + foo_service: + class: FooClass + tags: + # tag is not an array + - foo diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index 008a6c591fade..e7887fa922765 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -13,7 +13,6 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\Config\Loader\Loader; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; @@ -80,6 +79,29 @@ public function testLoadFile() } } + /** + * @dataProvider provideInvalidFiles + * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException + */ + public function testLoadInvalidFile($file) + { + $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); + + $loader->load($file.'.yml'); + } + + public function provideInvalidFiles() + { + return array( + array('bad_parameters'), + array('bad_imports'), + array('bad_import'), + array('bad_services'), + array('bad_service'), + array('bad_calls'), + ); + } + public function testLoadParameters() { $container = new ContainerBuilder(); @@ -179,7 +201,7 @@ public function testSupports() $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable'); } - public function testNonArrayTagThrowsException() + public function testNonArrayTagsThrowsException() { $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); try { @@ -191,6 +213,16 @@ public function testNonArrayTagThrowsException() } } + /** + * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException + * @expectedExceptionMessage A "tags" entry must be an array for service + */ + public function testNonArrayTagThrowsException() + { + $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); + $loader->load('badtag4.yml'); + } + public function testTagWithoutNameThrowsException() { $loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator(self::$fixturesPath.'/yaml')); From 654b1f281e09dd96ffbbd3da815411700423ecf5 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Tue, 2 Sep 2014 02:43:20 +0200 Subject: [PATCH 1258/1305] Forced all fragment uris to be signed, even for ESI --- .../FrameworkBundle/Resources/config/esi.xml | 1 + .../EventListener/FragmentListener.php | 13 ++--- .../Fragment/EsiFragmentRenderer.php | 22 +++++++-- .../EventListener/FragmentListenerTest.php | 13 ----- .../Fragment/EsiFragmentRendererTest.php | 48 ++++++++++++++++++- 5 files changed, 72 insertions(+), 25 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/esi.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/esi.xml index dd8e80107525a..c0202e1516a7c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/esi.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/esi.xml @@ -22,6 +22,7 @@ + %fragment.path% diff --git a/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php b/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php index ef3fad3d4cfe4..3b0e3a9425e63 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php @@ -12,7 +12,6 @@ namespace Symfony\Component\HttpKernel\EventListener; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\IpUtils; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; @@ -77,13 +76,6 @@ protected function validateRequest(Request $request) throw new AccessDeniedHttpException(); } - // does the Request come from a trusted IP? - $trustedIps = array_merge($this->getLocalIpAddresses(), $request->getTrustedProxies()); - $remoteAddress = $request->server->get('REMOTE_ADDR'); - if (IpUtils::checkIp($remoteAddress, $trustedIps)) { - return; - } - // is the Request signed? // we cannot use $request->getUri() here as we want to work with the original URI (no query string reordering) if ($this->signer->check($request->getSchemeAndHttpHost().$request->getBaseUrl().$request->getPathInfo().(null !== ($qs = $request->server->get('QUERY_STRING')) ? '?'.$qs : ''))) { @@ -93,6 +85,11 @@ protected function validateRequest(Request $request) throw new AccessDeniedHttpException(); } + /** + * @deprecated Deprecated since 2.3.19, to be removed in 3.0. + * + * @return string[] + */ protected function getLocalIpAddresses() { return array('127.0.0.1', 'fe80::1', '::1'); diff --git a/src/Symfony/Component/HttpKernel/Fragment/EsiFragmentRenderer.php b/src/Symfony/Component/HttpKernel/Fragment/EsiFragmentRenderer.php index e36e459506a14..8ff0e6ad44902 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/EsiFragmentRenderer.php +++ b/src/Symfony/Component/HttpKernel/Fragment/EsiFragmentRenderer.php @@ -15,6 +15,7 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Controller\ControllerReference; use Symfony\Component\HttpKernel\HttpCache\Esi; +use Symfony\Component\HttpKernel\UriSigner; /** * Implements the ESI rendering strategy. @@ -25,6 +26,7 @@ class EsiFragmentRenderer extends RoutableFragmentRenderer { private $esi; private $inlineStrategy; + private $signer; /** * Constructor. @@ -34,11 +36,13 @@ class EsiFragmentRenderer extends RoutableFragmentRenderer * * @param Esi $esi An Esi instance * @param FragmentRendererInterface $inlineStrategy The inline strategy to use when ESI is not supported + * @param UriSigner $signer */ - public function __construct(Esi $esi, FragmentRendererInterface $inlineStrategy) + public function __construct(Esi $esi, FragmentRendererInterface $inlineStrategy, UriSigner $signer = null) { $this->esi = $esi; $this->inlineStrategy = $inlineStrategy; + $this->signer = $signer; } /** @@ -61,12 +65,12 @@ public function render($uri, Request $request, array $options = array()) } if ($uri instanceof ControllerReference) { - $uri = $this->generateFragmentUri($uri, $request); + $uri = $this->generateSignedFragmentUri($uri, $request); } $alt = isset($options['alt']) ? $options['alt'] : null; if ($alt instanceof ControllerReference) { - $alt = $this->generateFragmentUri($alt, $request); + $alt = $this->generateSignedFragmentUri($alt, $request); } $tag = $this->esi->renderIncludeTag($uri, $alt, isset($options['ignore_errors']) ? $options['ignore_errors'] : false, isset($options['comment']) ? $options['comment'] : ''); @@ -81,4 +85,16 @@ public function getName() { return 'esi'; } + + private function generateSignedFragmentUri($uri, Request $request) + { + if (null === $this->signer) { + throw new \LogicException('You must use a URI when using the ESI rendering strategy or set a URL signer.'); + } + + // we need to sign the absolute URI, but want to return the path only. + $fragmentUri = $this->signer->sign($this->generateFragmentUri($uri, $request, true)); + + return substr($fragmentUri, strlen($request->getSchemeAndHttpHost())); + } } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php index 153d8a44ff9cc..75562f7098233 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/FragmentListenerTest.php @@ -54,19 +54,6 @@ public function testAccessDeniedWithNonSafeMethods() $listener->onKernelRequest($event); } - /** - * @expectedException \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException - */ - public function testAccessDeniedWithNonLocalIps() - { - $request = Request::create('http://example.com/_fragment', 'GET', array(), array(), array(), array('REMOTE_ADDR' => '10.0.0.1')); - - $listener = new FragmentListener(new UriSigner('foo')); - $event = $this->createGetResponseEvent($request); - - $listener->onKernelRequest($event); - } - /** * @expectedException \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException */ diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php index 1a63c4df6fa10..0c3ed8a2fb5a9 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/EsiFragmentRendererTest.php @@ -15,6 +15,7 @@ use Symfony\Component\HttpKernel\Fragment\EsiFragmentRenderer; use Symfony\Component\HttpKernel\HttpCache\Esi; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\UriSigner; class EsiFragmentRendererTest extends \PHPUnit_Framework_TestCase { @@ -48,7 +49,52 @@ public function testRender() $this->assertEquals('', $strategy->render('/', $request)->getContent()); $this->assertEquals("\n", $strategy->render('/', $request, array('comment' => 'This is a comment'))->getContent()); $this->assertEquals('', $strategy->render('/', $request, array('alt' => 'foo'))->getContent()); - $this->assertEquals('', $strategy->render(new ControllerReference('main_controller', array(), array()), $request, array('alt' => new ControllerReference('alt_controller', array(), array())))->getContent()); + } + + public function testRenderControllerReference() + { + $signer = new UriSigner('foo'); + $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy(), $signer); + + $request = Request::create('/'); + $request->setLocale('fr'); + $request->headers->set('Surrogate-Capability', 'ESI/1.0'); + + $reference = new ControllerReference('main_controller', array(), array()); + $altReference = new ControllerReference('alt_controller', array(), array()); + + $this->assertEquals( + '', + $strategy->render($reference, $request, array('alt' => $altReference))->getContent() + ); + } + + /** + * @expectedException \LogicException + */ + public function testRenderControllerReferenceWithoutSignerThrowsException() + { + $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy()); + + $request = Request::create('/'); + $request->setLocale('fr'); + $request->headers->set('Surrogate-Capability', 'ESI/1.0'); + + $strategy->render(new ControllerReference('main_controller'), $request); + } + + /** + * @expectedException \LogicException + */ + public function testRenderAltControllerReferenceWithoutSignerThrowsException() + { + $strategy = new EsiFragmentRenderer(new Esi(), $this->getInlineStrategy()); + + $request = Request::create('/'); + $request->setLocale('fr'); + $request->headers->set('Surrogate-Capability', 'ESI/1.0'); + + $strategy->render('/', $request, array('alt' => new ControllerReference('alt_controller'))); } private function getInlineStrategy($called = false) From f38536ab79058f6a934426c41170256ba9623a02 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 2 Sep 2014 07:46:06 +0200 Subject: [PATCH 1259/1305] [WebProfiler] replaced the import/export feature from the web interface to a CLI tool --- .../Command/ExportCommand.php | 75 ++++++++++++++++ .../Command/ImportCommand.php | 90 +++++++++++++++++++ .../Controller/ProfilerController.php | 57 ------------ .../Resources/config/commands.xml | 23 +++++ .../Resources/views/Profiler/admin.html.twig | 35 ++------ .../Tests/Command/ExportCommandTest.php | 53 +++++++++++ .../Tests/Command/ImportCommandTest.php | 36 ++++++++ .../Tests/Fixtures/profile.data | 1 + 8 files changed, 287 insertions(+), 83 deletions(-) create mode 100644 src/Symfony/Bundle/WebProfilerBundle/Command/ExportCommand.php create mode 100644 src/Symfony/Bundle/WebProfilerBundle/Command/ImportCommand.php create mode 100644 src/Symfony/Bundle/WebProfilerBundle/Resources/config/commands.xml create mode 100644 src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ExportCommandTest.php create mode 100644 src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ImportCommandTest.php create mode 100644 src/Symfony/Bundle/WebProfilerBundle/Tests/Fixtures/profile.data diff --git a/src/Symfony/Bundle/WebProfilerBundle/Command/ExportCommand.php b/src/Symfony/Bundle/WebProfilerBundle/Command/ExportCommand.php new file mode 100644 index 0000000000000..b140e302b1040 --- /dev/null +++ b/src/Symfony/Bundle/WebProfilerBundle/Command/ExportCommand.php @@ -0,0 +1,75 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\WebProfilerBundle\Command; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\HttpKernel\Profiler\Profiler; + +/** + * Exports a profile. + * + * @author Fabien Potencier + */ +class ExportCommand extends Command +{ + private $profiler; + + public function __construct(Profiler $profiler = null) + { + $this->profiler = $profiler; + + parent::__construct(); + } + + /** + * {@inheritdoc} + */ + public function isEnabled() + { + if (null === $this->profiler) { + return false; + } + + return parent::isEnabled(); + } + + protected function configure() + { + $this + ->setName('profiler:export') + ->setDescription('Exports a profile') + ->setDefinition(array( + new InputArgument('token', InputArgument::REQUIRED, 'The profile token'), + )) + ->setHelp(<<%command.name% command exports a profile to the standard output: + +php %command.full_name% profile_token +EOF + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $token = $input->getArgument('token'); + + if (!$profile = $this->profiler->loadProfile($token)) { + throw new \LogicException(sprintf('Profile with token "%s" does not exist.', $token)); + } + + $output->writeln($this->profiler->export($profile), OutputInterface::OUTPUT_RAW); + } +} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Command/ImportCommand.php b/src/Symfony/Bundle/WebProfilerBundle/Command/ImportCommand.php new file mode 100644 index 0000000000000..70fecd45ea0a3 --- /dev/null +++ b/src/Symfony/Bundle/WebProfilerBundle/Command/ImportCommand.php @@ -0,0 +1,90 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\WebProfilerBundle\Command; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\HttpKernel\Profiler\Profiler; + +/** + * Imports a profile. + * + * @author Fabien Potencier + */ +class ImportCommand extends Command +{ + private $profiler; + + public function __construct(Profiler $profiler = null) + { + $this->profiler = $profiler; + + parent::__construct(); + } + + /** + * {@inheritdoc} + */ + public function isEnabled() + { + if (null === $this->profiler) { + return false; + } + + return parent::isEnabled(); + } + + protected function configure() + { + $this + ->setName('profiler:import') + ->setDescription('Imports a profile') + ->setDefinition(array( + new InputArgument('filename', InputArgument::OPTIONAL, 'The profile path'), + )) + ->setHelp(<<%command.name% command imports a profile: + +php %command.full_name% profile_filepath + +You can also pipe the profile via STDIN: + +cat profile_file | php %command.full_name% +EOF + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $data = ''; + if ($input->getArgument('filename')) { + $data = file_get_contents($input->getArgument('filename')); + } else { + if (0 !== ftell(STDIN)) { + throw new \RuntimeException('Please provide a filename or pipe the profile to STDIN.'); + } + + while (!feof(STDIN)) { + $data .= fread(STDIN, 1024); + } + } + + if (!$profile = $this->profiler->import($data)) { + throw new \LogicException('The profile already exists in the database.'); + } + + $output->writeln(sprintf('Profile "%s" has been successfully imported.', $profile->getToken())); + } +} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php index 8542f2865f666..dea4f8883f8dc 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -111,33 +111,6 @@ public function panelAction(Request $request, $token) )), 200, array('Content-Type' => 'text/html')); } - /** - * Exports data for a given token. - * - * @param string $token The profiler token - * - * @return Response A Response instance - * - * @throws NotFoundHttpException - */ - public function exportAction($token) - { - if (null === $this->profiler) { - throw new NotFoundHttpException('The profiler must be enabled.'); - } - - $this->profiler->disable(); - - if (!$profile = $this->profiler->loadProfile($token)) { - throw new NotFoundHttpException(sprintf('Token "%s" does not exist.', $token)); - } - - return new Response($this->profiler->export($profile), 200, array( - 'Content-Type' => 'text/plain', - 'Content-Disposition' => 'attachment; filename= '.$token.'.txt', - )); - } - /** * Purges all tokens. * @@ -157,36 +130,6 @@ public function purgeAction() return new RedirectResponse($this->generator->generate('_profiler_info', array('about' => 'purge')), 302, array('Content-Type' => 'text/html')); } - /** - * Imports token data. - * - * @param Request $request The current HTTP Request - * - * @return Response A Response instance - * - * @throws NotFoundHttpException - */ - public function importAction(Request $request) - { - if (null === $this->profiler) { - throw new NotFoundHttpException('The profiler must be enabled.'); - } - - $this->profiler->disable(); - - $file = $request->files->get('file'); - - if (empty($file) || !$file->isValid()) { - return new RedirectResponse($this->generator->generate('_profiler_info', array('about' => 'upload_error')), 302, array('Content-Type' => 'text/html')); - } - - if (!$profile = $this->profiler->import(file_get_contents($file->getPathname()))) { - return new RedirectResponse($this->generator->generate('_profiler_info', array('about' => 'already_exists')), 302, array('Content-Type' => 'text/html')); - } - - return new RedirectResponse($this->generator->generate('_profiler', array('token' => $profile->getToken())), 302, array('Content-Type' => 'text/html')); - } - /** * Displays information page. * diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/commands.xml b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/commands.xml new file mode 100644 index 0000000000000..d85b54d38db70 --- /dev/null +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/commands.xml @@ -0,0 +1,23 @@ + + + + + + Symfony\Bundle\WebProfilerBundle\Command\ImportCommand + Symfony\Bundle\WebProfilerBundle\Command\ExportCommand + + + + + + + + + + + + + + diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/admin.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/admin.html.twig index 3ca28ff1629c0..a47b254a7716c 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/admin.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/admin.html.twig @@ -1,27 +1,10 @@ - +{% endif %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ExportCommandTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ExportCommandTest.php new file mode 100644 index 0000000000000..572e9b3978864 --- /dev/null +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ExportCommandTest.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\WebProfilerBundle\Tests\Command; + +use Symfony\Bundle\WebProfilerBundle\Command\ExportCommand; +use Symfony\Component\Console\Tester\CommandTester; +use Symfony\Component\Console\Application; +use Symfony\Component\HttpKernel\Profiler\Profile; + +class ExportCommandTest extends \PHPUnit_Framework_TestCase +{ + /** + * @expectedException \LogicException + */ + public function testExecuteWithUnknownToken() + { + $profiler = $this + ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') + ->disableOriginalConstructor() + ->getMock() + ; + + $command = new ExportCommand($profiler); + $commandTester = new CommandTester($command); + $commandTester->execute(array('token' => 'TOKEN')); + } + + public function testExecuteWithToken() + { + $profiler = $this + ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') + ->disableOriginalConstructor() + ->getMock() + ; + + $profile = new Profile('TOKEN'); + $profiler->expects($this->once())->method('loadProfile')->with('TOKEN')->will($this->returnValue($profile)); + + $command = new ExportCommand($profiler); + $commandTester = new CommandTester($command); + $commandTester->execute(array('token' => 'TOKEN')); + $this->assertEquals($profiler->export($profile), $commandTester->getDisplay()); + } +} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ImportCommandTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ImportCommandTest.php new file mode 100644 index 0000000000000..f5121c12d6fe2 --- /dev/null +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ImportCommandTest.php @@ -0,0 +1,36 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\WebProfilerBundle\Tests\Command; + +use Symfony\Bundle\WebProfilerBundle\Command\ImportCommand; +use Symfony\Component\Console\Tester\CommandTester; +use Symfony\Component\Console\Application; +use Symfony\Component\HttpKernel\Profiler\Profile; + +class ImportCommandTest extends \PHPUnit_Framework_TestCase +{ + public function testExecute() + { + $profiler = $this + ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') + ->disableOriginalConstructor() + ->getMock() + ; + + $profiler->expects($this->once())->method('import')->will($this->returnValue(new Profile('TOKEN'))); + + $command = new ImportCommand($profiler); + $commandTester = new CommandTester($command); + $commandTester->execute(array('filename' => __DIR__.'/../Fixtures/profile.data')); + $this->assertRegExp('/Profile "TOKEN" has been successfully imported\./', $commandTester->getDisplay()); + } +} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Fixtures/profile.data b/src/Symfony/Bundle/WebProfilerBundle/Tests/Fixtures/profile.data new file mode 100644 index 0000000000000..ab76cea63de6d --- /dev/null +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Fixtures/profile.data @@ -0,0 +1 @@ +Tzo0NToiU3ltZm9ueVxDb21wb25lbnRcSHR0cEtlcm5lbFxQcm9maWxlclxQcm9maWxlIjo4OntzOjUyOiIAU3ltZm9ueVxDb21wb25lbnRcSHR0cEtlcm5lbFxQcm9maWxlclxQcm9maWxlAHRva2VuIjtzOjU6IlRPS0VOIjtzOjUzOiIAU3ltZm9ueVxDb21wb25lbnRcSHR0cEtlcm5lbFxQcm9maWxlclxQcm9maWxlAHBhcmVudCI7TjtzOjU1OiIAU3ltZm9ueVxDb21wb25lbnRcSHR0cEtlcm5lbFxQcm9maWxlclxQcm9maWxlAGNoaWxkcmVuIjthOjA6e31zOjU3OiIAU3ltZm9ueVxDb21wb25lbnRcSHR0cEtlcm5lbFxQcm9maWxlclxQcm9maWxlAGNvbGxlY3RvcnMiO2E6MDp7fXM6NDk6IgBTeW1mb255XENvbXBvbmVudFxIdHRwS2VybmVsXFByb2ZpbGVyXFByb2ZpbGUAaXAiO047czo1MzoiAFN5bWZvbnlcQ29tcG9uZW50XEh0dHBLZXJuZWxcUHJvZmlsZXJcUHJvZmlsZQBtZXRob2QiO047czo1MDoiAFN5bWZvbnlcQ29tcG9uZW50XEh0dHBLZXJuZWxcUHJvZmlsZXJcUHJvZmlsZQB1cmwiO047czo1MToiAFN5bWZvbnlcQ29tcG9uZW50XEh0dHBLZXJuZWxcUHJvZmlsZXJcUHJvZmlsZQB0aW1lIjtOO30= \ No newline at end of file From 3bba329775181da73d2a00d257eab95b6d005698 Mon Sep 17 00:00:00 2001 From: Luis Cordova Date: Tue, 2 Sep 2014 09:14:20 -0500 Subject: [PATCH 1260/1305] fixing yaml indentation --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7b8fb71348d0c..c14543b5d3e6b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,12 @@ language: php php: - - 5.3.3 - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - hhvm-nightly + - 5.3.3 + - 5.3 + - 5.4 + - 5.5 + - 5.6 + - hhvm-nightly matrix: allow_failures: From 23eb033abbb4025b5b380b6d187a9ce12ca5889f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 3 Sep 2014 10:09:50 +0200 Subject: [PATCH 1261/1305] [HttpKernel] fixed internal fragment handling --- .../HttpKernel/EventListener/FragmentListener.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php b/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php index 3b0e3a9425e63..6f45c3b129634 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/FragmentListener.php @@ -16,6 +16,7 @@ use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\UriSigner; +use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** @@ -24,8 +25,8 @@ * All URL paths starting with /_fragment are handled as * content fragments by this listener. * - * If the request does not come from a trusted IP, it throws an - * AccessDeniedHttpException exception. + * If throws an AccessDeniedHttpException exception if the request + * is not signed or if it is not an internal sub-request. * * @author Fabien Potencier */ @@ -61,7 +62,9 @@ public function onKernelRequest(GetResponseEvent $event) return; } - $this->validateRequest($request); + if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) { + $this->validateRequest($request); + } parse_str($request->query->get('_path', ''), $attributes); $request->attributes->add($attributes); From 78752a66b9358c4f1b5bdde597097c14b1722be5 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 3 Sep 2014 11:41:23 +0200 Subject: [PATCH 1262/1305] updated CHANGELOG for 2.3.19 --- CHANGELOG-2.3.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/CHANGELOG-2.3.md b/CHANGELOG-2.3.md index c132013aa0e72..833ded80522e7 100644 --- a/CHANGELOG-2.3.md +++ b/CHANGELOG-2.3.md @@ -7,6 +7,59 @@ in 2.3 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.3.0...v2.3.1 +* 2.3.19 (2014-09-03) + + * security #11832 CVE-2014-6072 (fabpot) + * security #11831 CVE-2014-5245 (stof) + * security #11830 CVE-2014-4931 (aitboudad, Jérémy Derussé) + * security #11829 CVE-2014-6061 (damz, fabpot) + * security #11828 CVE-2014-5244 (nicolas-grekas, larowlan) + * bug #10197 [FrameworkBundle] PhpExtractor bugfix and improvements (mtibben) + * bug #11772 [Filesystem] Add FTP stream wrapper context option to enable overwrite (Damian Sromek) + * bug #11788 [Yaml] fixed mapping keys containing a quoted # (hvt, fabpot) + * bug #11160 [DoctrineBridge] Abstract Doctrine Subscribers with tags (merk) + * bug #11768 [ClassLoader] Add a __call() method to XcacheClassLoader (tstoeckler) + * bug #11726 [Filesystem Component] mkdir race condition fix #11626 (kcassam) + * bug #11677 [YAML] resolve variables in inlined YAML (xabbuh) + * bug #11639 [DependencyInjection] Fixed factory service not within the ServiceReferenceGraph. (boekkooi) + * bug #11778 [Validator] Fixed wrong translations for Collection constraints (samicemalone) + * bug #11756 [DependencyInjection] fix @return anno created by PhpDumper (jakubkulhan) + * bug #11711 [DoctrineBridge] Fix empty parameter logging in the dbal logger (jakzal) + * bug #11692 [DomCrawler] check for the correct field type (xabbuh) + * bug #11672 [Routing] fix handling of nullable XML attributes (xabbuh) + * bug #11624 [DomCrawler] fix the axes handling in a bc way (xabbuh) + * bug #11676 [Form] Fixed #11675 ValueToDuplicatesTransformer accept "0" value (Nek-) + * bug #11695 [Validators] Fixed failing tests requiring ICU 52.1 which are skipped otherwise (webmozart) + * bug #11529 [WebProfilerBundle] Fixed double height of canvas (hason) + * bug #11641 [WebProfilerBundle ] Fix toolbar vertical alignment (blaugueux) + * bug #11559 [Validator] Convert objects to string in comparison validators (webmozart) + * feature #11510 [HttpFoundation] MongoDbSessionHandler supports auto expiry via configurable expiry_field (catchamonkey) + * bug #11408 [HttpFoundation] Update QUERY_STRING when overrideGlobals (yguedidi) + * bug #11633 [FrameworkBundle] add missing attribute to XSD (xabbuh) + * bug #11601 [Validator] Allow basic auth in url when using UrlValidator. (blaugueux) + * bug #11609 [Console] fixed style creation when providing an unknown tag option (fabpot) + * bug #10914 [HttpKernel] added an analyze of environment parameters for built-in server (mauchede) + * bug #11598 [Finder] Shell escape and windows support (Gordon Franke, gimler) + * bug #11499 [BrowserKit] Fixed relative redirects for ambiguous paths (pkruithof) + * bug #11516 [BrowserKit] Fix browser kit redirect with ports (dakota) + * bug #11545 [Bundle][FrameworkBundle] built-in server: exit when docroot does not exist (xabbuh) + * bug #11560 Plural fix (1emming) + * bug #11558 [DependencyInjection] Fixed missing 'factory-class' attribute in XmlDumper output (kerdany) + * bug #11548 [Component][DomCrawler] fix axes handling in Crawler::filterXPath() (xabbuh) + * bug #11422 [DependencyInjection] Self-referenced 'service_container' service breaks garbage collection (sun) + * bug #11428 [Serializer] properly handle null data when denormalizing (xabbuh) + * bug #10687 [Validator] Fixed string conversion in constraint violations (eagleoneraptor, webmozart) + * bug #11475 [EventDispatcher] don't count empty listeners (xabbuh) + * bug #11436 fix signal handling in wait() on calls to stop() (xabbuh, romainneutron) + * bug #11469 [BrowserKit] Fixed server HTTP_HOST port uri conversion (bcremer, fabpot) + * bug #11425 Fix issue described in #11421 (Ben, ben-rosio) + * bug #11423 Pass a Scope instance instead of a scope name when cloning a container in the GrahpvizDumper (jakzal) + * bug #11120 [Process] Reduce I/O load on Windows platform (romainneutron) + * bug #11342 [Form] Check if IntlDateFormatter constructor returned a valid object before using it (romainneutron) + * bug #11411 [Validator] Backported #11410 to 2.3: Object initializers are called only once per object (webmozart) + * bug #11403 [Translator][FrameworkBundle] Added @ to the list of allowed chars in Translator (takeit) + * bug #11381 [Process] Use correct test for empty string in UnixPipes (whs, romainneutron) + * 2.3.18 (2014-07-15) * [Security] Forced validate of locales passed to the translator From 2651c1a6a353d059b1642cb5754f593354130a45 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 3 Sep 2014 11:45:14 +0200 Subject: [PATCH 1263/1305] update CONTRIBUTORS for 2.3.19 --- CONTRIBUTORS.md | 116 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 80 insertions(+), 36 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index ca9e441c93143..a9526431c1983 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -18,38 +18,39 @@ Symfony2 is the result of the work of many people who made the code better - Joseph Bielawski (stloyd) - Ryan Weaver (weaverryan) - Lukas Kahwe Smith (lsmith) - - Jeremy Mikola (jmikola) - Romain Neutron (romain) + - Jeremy Mikola (jmikola) - Jean-François Simon (jfsimon) - Benjamin Eberlei (beberlei) - Igor Wiedler (igorw) - Hugo Hamon (hhamon) - - Eriksen Costa (eriksencosta) - Martin Hasoň (hason) + - Eriksen Costa (eriksencosta) - Jonathan Wage (jwage) - Alexandre Salomé (alexandresalome) - William Durand (couac) - ornicar - stealth35 ‏ (stealth35) + - Grégoire Pineau (lyrixx) - Alexander Mols (asm89) - Bulat Shakirzyanov (avalanche123) - - Grégoire Pineau (lyrixx) + - Nicolas Grekas (nicolas-grekas) - Francis Besset (francisbesset) - Saša Stamenković (umpirsky) - Miha Vrhovnik - Henrik Bjørnskov (henrikbjorn) - Konstantin Kudryashov (everzet) + - Wouter De Jong (wouterj) + - Christian Flothmann (xabbuh) - Bilal Amarni (bamarni) - Florin Patan (florinpatan) - - Wouter De Jong (wouterj) - Eric Clemmons (ericclemmons) - - Nicolas Grekas (nicolas-grekas) - Andrej Hudec (pulzarraider) - Deni - Henrik Westphal (snc) - Dariusz Górecki (canni) - - Arnout Boks (aboks) - Christian Raue + - Arnout Boks (aboks) - Michel Weimerskirch (mweimerskirch) - Lee McDermott - Brandon Turner @@ -61,11 +62,11 @@ Symfony2 is the result of the work of many people who made the code better - Bart van den Burg (burgov) - Antoine Hérault (herzult) - Toni Uebernickel (havvg) - - Arnaud Le Blanc (arnaud-lb) - Luis Cordova (cordoval) + - Arnaud Le Blanc (arnaud-lb) + - Tim Nagel (merk) - Kevin Bond (kbond) - Brice BERNARD (brikou) - - Tim Nagel (merk) - marc.weistroff - lenar - Włodzimierz Gajda (gajdaw) @@ -74,25 +75,25 @@ Symfony2 is the result of the work of many people who made the code better - Florian Voutzinos (florianv) - Fabien Pennequin (fabienpennequin) - Jacob Dreesen (jdreesen) + - Adrien Brault (adrienbrault) - Gábor Egyed (1ed) - Ait Boudad Abdellatif (aitboudad) - - Adrien Brault (adrienbrault) - Michal Piotrowski (eventhorizon) + - Gordon Franke (gimler) - Robert Schönthal (digitalkaoz) - Juti Noppornpitak (shiroyuki) - Sebastian Hörl (blogsh) - Daniel Gomes (danielcsgomes) - Hidenori Goto (hidenorigoto) - Peter Kokot (maastermedia) - - Christian Flothmann (xabbuh) - - Jérémie Augustin (jaugustin) - David Buchmann (dbu) + - Pablo Godel (pgodel) + - Jérémie Augustin (jaugustin) + - Rafael Dohms (rdohms) - Jérôme Tamarelle (gromnan) - Tigran Azatyan (tigranazatyan) - Javier Eguiluz (javier.eguiluz) - - Rafael Dohms (rdohms) - Richard Shank (iampersistent) - - Gordon Franke (gimler) - Eric GELOEN (gelo) - Helmer Aaviksoo - Sebastiaan Stok (sstok) @@ -103,7 +104,6 @@ Symfony2 is the result of the work of many people who made the code better - Jonathan Ingram (jonathaningram) - Artur Kotyrba - Guilherme Blanco (guilhermeblanco) - - Pablo Godel (pgodel) - Clemens Tolboom - Dmitrii Chekaliuk (lazyhammer) - Clément JOBEILI (dator) @@ -114,10 +114,13 @@ Symfony2 is the result of the work of many people who made the code better - Dennis Benkert (denderello) - Rouven Weßling (realityking) - Benjamin Dulau (dbenjamin) + - Stefano Sala (stefano.sala) - Andreas Hucks (meandmymonkey) + - Andréia Bohner (andreia) - Noel Guilbert (noel) - Charles Sarrazin (csarrazi) - bronze1man + - sun (sun) - Larry Garfield (crell) - Martin Schuhfuß (usefulthink) - Thomas Rabaix (rande) @@ -131,10 +134,9 @@ Symfony2 is the result of the work of many people who made the code better - jeff - Justin Hileman (bobthecow) - Sven Paulus (subsven) - - Andréia Bohner (andreia) + - Lars Strojny (lstrojny) - Joel Wurtz (brouznouf) - Rui Marinho (ruimarinho) - - sun (sun) - Julien Brochet (mewt) - Tugdual Saunier (tucksaun) - Sergey Linnik (linniksa) @@ -152,12 +154,11 @@ Symfony2 is the result of the work of many people who made the code better - Katsuhiro OGAWA - Peter Rehm (rpet) - Alif Rachmawadi + - Pierre-Yves LEBECQ (pylebecq) - Matthias Pigulla (mpdude) - - Stefano Sala (stefano.sala) - Joseph Rouff (rouffj) - Félix Labrecque (woodspire) - GordonsLondon - - Lars Strojny (lstrojny) - Jan Sorgalla (jsor) - Ray - Chekote @@ -168,14 +169,17 @@ Symfony2 is the result of the work of many people who made the code better - Beau Simensen (simensen) - Robert Kiss (kepten) - Kim Hemsø Rasmussen (kimhemsoe) + - Tom Van Looy (tvlooy) - Wouter Van Hecke + - Peter Kruithof (pkruithof) - Michael Holm (hollo) - Marc Weistroff (futurecat) - - Pierre-Yves LEBECQ (pylebecq) - Roman Marintšenko (inori) - Chris Smith (cs278) - Florian Klein (docteurklein) - Manuel Kiessling (manuelkiessling) + - Atsuhiro KUBO (iteman) + - Issei Murasawa (issei_m) - Bertrand Zuchuat (garfield-fr) - Gabor Toth (tgabi333) - realmfoo @@ -184,6 +188,7 @@ Symfony2 is the result of the work of many people who made the code better - Grégoire Passault (gregwar) - Uwe Jäger (uwej711) - Aurelijus Valeiša (aurelijus) + - Jan Decavele (jandc) - Gustavo Piltcher - Stepan Tanasiychuk (stfalcon) - Tiago Ribeiro (fixe) @@ -191,10 +196,12 @@ Symfony2 is the result of the work of many people who made the code better - Adrian Rudnik (kreischweide) - Francesc Rosàs (frosas) - Julien Galenski (ruian) + - Eugene Leonovich (rybakit) - Bongiraud Dominique - janschoenherr - Marco Pivetta (ocramius) - Ricard Clau (ricardclau) + - Jérémy DERUSSÉ (jderusse) - Kévin Dunglas (dunglas) - Erin Millard - Matthew Lewinski (lewinski) @@ -204,8 +211,6 @@ Symfony2 is the result of the work of many people who made the code better - Gyula Sallai (salla) - Inal DJAFAR (inalgnu) - Christian Gärtner (dagardner) - - Tom Van Looy (tvlooy) - - Peter Kruithof (pkruithof) - Felix Labrecque - Yaroslav Kiliba - Sébastien Lavoie (lavoiesl) @@ -219,18 +224,17 @@ Symfony2 is the result of the work of many people who made the code better - Philipp Kräutli (pkraeutli) - Kirill chEbba Chebunin (chebba) - Greg Thornton (xdissent) - - Atsuhiro KUBO (iteman) - Grégoire Paris (greg0ire) - julien pauli (jpauli) - Costin Bereveanu (schniper) - Loïc Chardonnet (gnusat) - Marek Kalnik (marekkalnik) + - Andrew Moore (finewolf) - Tamas Szijarto - Pavel Volokitin (pvolok) - Tobias Naumann (tna) - Ismael Ambrosi (iambrosi) - Shein Alexey - - Issei Murasawa (issei_m) - hacfi (hifi) - Joe Lencioni - Kai @@ -240,7 +244,6 @@ Symfony2 is the result of the work of many people who made the code better - Miha Vrhovnik - Alessandro Desantis - hubert lecorche (hlecorche) - - Eugene Leonovich (rybakit) - Oscar Cubo Medina (ocubom) - Karel Souffriau - Christophe L. (christophelau) @@ -264,6 +267,8 @@ Symfony2 is the result of the work of many people who made the code better - Tobias Sjösten (tobiassjosten) - vagrant - Asier Illarramendi (doup) + - Chris Sedlmayr (catchamonkey) + - Seb Koelen - Christoph Mewes (xrstf) - Vitaliy Tverdokhlib (vitaliytv) - Dirk Pahl (dirkaholic) @@ -289,15 +294,17 @@ Symfony2 is the result of the work of many people who made the code better - Iker Ibarguren (ikerib) - Ricardo Oliveira (ricardolotr) - ondrowan - - Andrew Moore (finewolf) - Vyacheslav Salakhutdinov (megazoll) + - Daniel Wehner - Evan S Kaufman (evanskaufman) - mcben - Maks Slesarenko + - mmoreram - Markus Lanthaler (lanthaler) - Vicent Soria Durá (vicentgodella) - Chris Wilkinson (thewilkybarkid) - Ioan Negulescu + - Jakub Škvára (jskvara) - Andrew Udvare (audvare) - alexpods - Erik Trapman (eriktrapman) @@ -326,11 +333,13 @@ Symfony2 is the result of the work of many people who made the code better - Pavel Campr (pcampr) - Geoffrey Tran (geoff) - Jan Behrens + - Sebastian Krebs + - Christopher Davis (chrisguitarguy) - Thomas Lallement (raziel057) - alcaeus - vitaliytv - Markus Bachmann (baachi) - - Jérémy DERUSSÉ (jderusse) + - Sebastian Blum - aubx - Ricky Su (ricky) - Gildas Quéméner (gquemener) @@ -342,6 +351,7 @@ Symfony2 is the result of the work of many people who made the code better - Chris Boden (cboden) - Pierre du Plessis (pierredup) - Josip Kruslin + - Hany el-Kerdany - Wang Jingyu - Åsmund Garfors - Javier López (loalf) @@ -368,6 +378,7 @@ Symfony2 is the result of the work of many people who made the code better - Sascha Grossenbacher - Ben Davies (bendavies) - Simon Schick (simonsimcity) + - redstar504 - Hossein Bukhamsin - Paweł Wacławczyk (pwc) - Oleg Zinchenko (cystbear) @@ -375,10 +386,12 @@ Symfony2 is the result of the work of many people who made the code better - Johannes Klauss (cloppy) - Evan Villemez - fzerorubigd + - Thomas Ploch - Benjamin Grandfond (benjamin) - Tiago Brito (blackmx) - Richard van den Brand (ricbra) - develop + - Vincent AUBERT (vincent) - Tomasz Kowalczyk (thunderer) - Mark Sonnabaum - Mathieu Lemoine @@ -390,8 +403,8 @@ Symfony2 is the result of the work of many people who made the code better - yclian - Pascal Helfenstein - Baldur Rensch (brensch) + - Barry vd. Heuvel (barryvdh) - Alex Xandra Albert Sim - - Daniel Wehner - Yuen-Chi Lian - Besnik Br - Joshua Nye @@ -406,8 +419,8 @@ Symfony2 is the result of the work of many people who made the code better - Josiah (josiah) - Marek Štípek (maryo) - John Bohn (jbohn) - - Jakub Škvára (jskvara) - Andrew Hilobok (hilobok) + - Matthieu Auger (matthieuauger) - Christian Soronellas (theunic) - Jérôme Vieilledent (lolautruche) - Degory Valentine @@ -418,8 +431,11 @@ Symfony2 is the result of the work of many people who made the code better - Olivier Maisonneuve (olineuve) - Francis Turmel (fturmel) - cgonzalez + - Ben - Jayson Xu (superjavason) + - Tobias Nyholm (tobias) - Jaik Dean (jaikdean) + - Harm van Tilborg - Jan Prieser - James Michael DuPont - Tom Klingenberg @@ -436,6 +452,7 @@ Symfony2 is the result of the work of many people who made the code better - Maksim Kotlyar (makasim) - Neil Ferreira - Dmitry Parnas (parnas) + - Emanuele Iannone - Tony Malzhacker - Cyril Quintin (cyqui) - Gerard van Helden (drm) @@ -454,6 +471,7 @@ Symfony2 is the result of the work of many people who made the code better - abdul malik ikhsan (samsonasik) - Sarah Khalil (saro0h) - Timothée Barray (tyx) + - Benjamin Laugueux (yzalis) - Christian Morgan - Alexander Miehe (engerim) - Titouan Galopin (tgalopin) @@ -468,6 +486,7 @@ Symfony2 is the result of the work of many people who made the code better - Michael Roterman (wtfzdotnet) - Arno Geurts - Adán Lobato (adanlobato) + - Matthew Davis (mdavis1982) - Maks - Gábor Tóth - Daniel Cestari @@ -486,6 +505,7 @@ Symfony2 is the result of the work of many people who made the code better - Christian Jul Jensen - The Whole Life to Learn - Liverbool (liverbool) + - Sam Malone - Phan Thanh Ha (haphan) - Chris Jones (leek) - Colin O'Dell (colinodell) @@ -499,11 +519,13 @@ Symfony2 is the result of the work of many people who made the code better - fabios - Sander Coolen (scoolen) - Nicolas Le Goff (nlegoff) + - Ariel Ferrandini (aferrandini) - Manuele Menozzi - Anton Babenko (antonbabenko) - Irmantas Šiupšinskas (irmantas) - Danilo Silva - Zachary Tong (polyfractal) + - Hryhorii Hrebiniuk - dantleech - Tero Alén (tero) - DerManoMann @@ -524,11 +546,14 @@ Symfony2 is the result of the work of many people who made the code better - Jeremy David (jeremy.david) - Troy McCabe - Ville Mattila + - Boris Vujicic (boris.vujicic) - Max Beutel - Catalin Dan + - Warnar Boekkooi - Piotr Antosik (antek88) - Artem Lopata - Marcos Quesada (marcos_quesada) + - Matthew Vickery (mattvick) - Dan Finnie - Ken Marfilla (marfillaster) - benatespina (benatespina) @@ -548,7 +573,6 @@ Symfony2 is the result of the work of many people who made the code better - Daniel Mecke (daniel_mecke) - Matteo Giachino (matteosister) - Alex Demchenko (pilot) - - Vincent AUBERT (vincent) - Benoit Garret - DerManoMann - Asmir Mustafic (goetas) @@ -573,6 +597,7 @@ Symfony2 is the result of the work of many people who made the code better - Luc Vieillescazes (iamluc) - Eduardo García Sanz (coma) - David de Boer (ddeboer) + - Gilles Doge (gido) - Brooks Boyd - Roger Webb - Dmitriy Simushev @@ -596,7 +621,9 @@ Symfony2 is the result of the work of many people who made the code better - heccjj - Alexandre Melard - Sergey Yuferev + - Tobias Stöckler - Mario Young + - Jakub Kulhan - Mo Di (modi) - Jeroen van den Enden (stoefke) - Quique Porta (quiqueporta) @@ -604,6 +631,7 @@ Symfony2 is the result of the work of many people who made the code better - ConneXNL - Aharon Perkel - Abdul.Mohsen B. A. A + - Benoît Burnichon - Malaney J. Hill - Cédric Girard (enk_) - Oriol Mangas Abellan (oriolman) @@ -640,12 +668,14 @@ Symfony2 is the result of the work of many people who made the code better - Ilya Biryukov - Jason Desrosiers - m.chwedziak + - Endre Fejes - Lance McNearney - Giorgio Premi - caponica - Matt Daum (daum) - Alberto Pirovano (geezmo) - Pete Mitchell (peterjmit) + - Tom Corrigan (tomcorrigan) - Martin Pärtel - Evgeniy (ewgraf) - Patrick Daley (padrig) @@ -653,9 +683,11 @@ Symfony2 is the result of the work of many people who made the code better - Max Summe - WedgeSama - Felds Liscia + - Maxime Veber (nek-) - Tadcka - Beth Binkovitz - Romain Geissler + - Benjamin Cremer (bcremer) - Marcus Stöhr (dafish) - Emmanuel Vella (emmanuel.vella) - Carsten Nielsen (phreaknerd) @@ -665,8 +697,8 @@ Symfony2 is the result of the work of many people who made the code better - Adrien Samson (adriensamson) - Samuel Gordalina (gordalina) - Max Romanovsky (maxromanovsky) + - Rafał Muszyński (rafmus90) - Timothy Anido (xanido) - - Sebastian Krebs - Rick Prent - Martin Eckhardt - Jon Gotlin (jongotlin) @@ -689,7 +721,6 @@ Symfony2 is the result of the work of many people who made the code better - Sebastian Ionescu - Thomas Ploch - Simon Neidhold - - Seb Koelen - Kevin Dew - James Cowgill - Jeremy Livingston (jeremylivingston) @@ -707,6 +738,7 @@ Symfony2 is the result of the work of many people who made the code better - Hoffmann András - Olivier - pscheit + - moldcraft - Ramon Kleiss (akathos) - Nicolas Badey (nico-b) - Shane Preece (shane) @@ -717,7 +749,6 @@ Symfony2 is the result of the work of many people who made the code better - Gunnar Lium (gunnarlium) - Tiago Garcia (tiagojsag) - Bouke Haarsma - - Harm van Tilborg - Martin Eckhardt - Denis Zunke - Jonathan Poston @@ -748,12 +779,15 @@ Symfony2 is the result of the work of many people who made the code better - Michal Gebauer - Gleb Sidora - David Stone + - Javier Spagnoletti (phansys) - Pablo Maria Martelletti (pmartelletti) + - Yassine Guedidi (yguedidi) - Luis Muñoz - Andreas - Strate - Thomas Chmielowiec - Andrey Ryaguzov + - Manatsawin Hanmongkolchai - Gunther Konig - František Bereň - Christoph Nissle (derstoffel) @@ -766,11 +800,13 @@ Symfony2 is the result of the work of many people who made the code better - Grayson Koonce (breerly) - Benjamin Zikarsky (bzikarsky) - Matt Robinson (inanimatt) + - Karim Cassam Chenaï (ka) - Nicolas Bastien (nicolas_bastien) - Andy Stanberry - Luiz “Felds” Liscia - Thomas Rothe - alefranz + - avi123 - alsar - Mike Meier - Warwick @@ -798,10 +834,10 @@ Symfony2 is the result of the work of many people who made the code better - Daan van Renterghem - Bram Van der Sype (brammm) - Julien Moulin (lizjulien) - - Matthieu Auger (matthieuauger) - Kevin Decherf - dened - Sam Ward + - Walther Lalk - devel - Trevor Suarez - gedrox @@ -858,6 +894,7 @@ Symfony2 is the result of the work of many people who made the code better - Klaas Naaijkens - Rafał - Adria Lopez (adlpz) + - Rosio (ben-rosio) - Masao Maeda (brtriver) - Darius Leskauskas (darles) - Dave Hulbert (dave1010) @@ -871,7 +908,6 @@ Symfony2 is the result of the work of many people who made the code better - Ian Jenkins (jenkoian) - Jorge Martin (jorgemartind) - Kevin Herrera (kherge) - - Matthew Davis (mdavis1982) - Muriel (metalmumu) - Michaël Perrin (michael.perrin) - Pablo Monterde Perez (plebs) @@ -904,6 +940,7 @@ Symfony2 is the result of the work of many people who made the code better - goohib - Xavier HAUSHERR - Cas + - Maxime Douailin - Myke79 - Brian Debuire - Sylvain Lorinet @@ -928,6 +965,7 @@ Symfony2 is the result of the work of many people who made the code better - cmfcmf - Drew Butler - Steve Müller + - Andras Ratz - andreabreu98 - Thomas Schulz - Michael Schneider @@ -939,12 +977,12 @@ Symfony2 is the result of the work of many people who made the code better - Ondrej Slinták - vlechemin - Brian Corrigan + - Brian Freytag - Skorney - mieszko4 - datibbaw - Markus Staab - Pierre-Louis LAUNAY - - Thomas Ploch - djama - Eduardo Conceição - Jon Cave @@ -960,6 +998,7 @@ Symfony2 is the result of the work of many people who made the code better - Sergiy Sokolenko - dinitrol - Penny Leach + - g123456789l - oscartv - DanSync - Peter Zwosta @@ -982,7 +1021,6 @@ Symfony2 is the result of the work of many people who made the code better - Daniel Basten (axhm3a) - Bill Hance (billhance) - Bernd Matzner (bmatzner) - - Chris Sedlmayr (catchamonkey) - Choong Wei Tjeng (choonge) - Kousuke Ebihara (co3k) - Loïc Vernet (coil) @@ -991,6 +1029,7 @@ Symfony2 is the result of the work of many people who made the code better - Damon Jones (damon__jones) - Daniel Londero (dlondero) - Adel ELHAIBA (eadel) + - Damián Nohales (eagleoneraptor) - Elliot Anderson (elliot) - Fabien D. (fabd) - Sorin Gitlan (forapathy) @@ -1006,11 +1045,14 @@ Symfony2 is the result of the work of many people who made the code better - Jorge Maiden (jorgemaiden) - Justin Rainbow (jrainbow) - JuntaTom (juntatom) + - Johnson Page (jwpage) - Sébastien Armand (khepin) - Krzysztof Menżyk (krymen) - samuel laulhau (lalop) - Laurent Bachelier (laurentb) + - Jérôme Parmentier (lctrs) - Matthieu Moquet (mattketmo) + - Morgan Auchede (mauchede) - Moritz Borgmann (mborgmann) - Matt Drollette (mdrollette) - Adam Monsen (meonkeys) @@ -1053,8 +1095,10 @@ Symfony2 is the result of the work of many people who made the code better - Philipp Scheit - max - Mohamed Karnichi (amiral) + - Jeroen De Dauw (jeroendedauw) - Muharrem Demirci (mdemirci) - Evgeny Z (meze) + - Michiel Boeckaert (milio) - Nicolas de Marqué (nicola) - Kevin (oxfouzer) - Pierre Geyer (ptheg) From 1fc05758044fa1cf54460d7d4aff5f55b0f1b0db Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 3 Sep 2014 11:45:27 +0200 Subject: [PATCH 1264/1305] updated VERSION for 2.3.19 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index e14f57967b5bb..00448bc870c98 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.3.19-DEV'; + const VERSION = '2.3.19'; const VERSION_ID = '20319'; const MAJOR_VERSION = '2'; const MINOR_VERSION = '3'; const RELEASE_VERSION = '19'; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; /** * Constructor. From 1033dc59cd094ec1751500f19e10c0f84a899eb2 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 3 Sep 2014 14:50:59 +0200 Subject: [PATCH 1265/1305] bumped Symfony version to 2.3.20 --- 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 00448bc870c98..4e9594203b203 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.3.19'; - const VERSION_ID = '20319'; + const VERSION = '2.3.20-DEV'; + const VERSION_ID = '20320'; const MAJOR_VERSION = '2'; const MINOR_VERSION = '3'; - const RELEASE_VERSION = '19'; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = '20'; + const EXTRA_VERSION = 'DEV'; /** * Constructor. From 854e07b1de3cfeefcc5afa50dfa1588bd44d758f Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 3 Sep 2014 19:52:14 +0200 Subject: [PATCH 1266/1305] improve error when detecting unquoted asterisks Asterisks in unquoted strings are used in YAML to reference variables. Before Symfony 2.3.19, Symfony 2.4.9 and Symfony 2.5.4, unquoted asterisks in inlined YAML code were treated as regular strings. This was fixed for the inline parser in #11677. However, an unquoted * character now led to an error message like this: ``` PHP Warning: array_key_exists(): The first argument should be either a string or an integer in vendor/symfony/symfony/src/Symfony/Component/Yaml/Inline.php on line 409 [Symfony\Component\Yaml\Exception\ParseException] Reference "" does not exist at line 171 (near "- { foo: * }"). ``` --- src/Symfony/Component/Yaml/Inline.php | 7 ++++++- .../Component/Yaml/Tests/InlineTest.php | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 1b34edebd28f8..fc00405a8b7ea 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -392,7 +392,7 @@ private static function parseMapping($mapping, &$i = 0, $references = array()) * * @return string A YAML string * - * @throws ParseException when object parsing support was disabled and the parser detected a PHP object + * @throws ParseException when object parsing support was disabled and the parser detected a PHP object or when a reference could not be resolved */ private static function evaluateScalar($scalar, $references = array()) { @@ -406,6 +406,11 @@ private static function evaluateScalar($scalar, $references = array()) $value = substr($scalar, 1); } + // an unquoted * + if (false === $value || '' === $value) { + throw new ParseException('A reference must contain at least one character.'); + } + if (!array_key_exists($value, $references)) { throw new ParseException(sprintf('Reference "%s" does not exist.', $value)); } diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index 96a118d073eda..6b5da8df39ae2 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -147,6 +147,24 @@ public function testParseMapReferenceInSequence() $this->assertSame(array($foo), Inline::parse('[*foo]', false, false, array('foo' => $foo))); } + /** + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + * @expectedExceptionMessage A reference must contain at least one character. + */ + public function testParseUnquotedAsterisk() + { + Inline::parse('{ foo: * }'); + } + + /** + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + * @expectedExceptionMessage A reference must contain at least one character. + */ + public function testParseUnquotedAsteriskFollowedByAComment() + { + Inline::parse('{ foo: * #foo }'); + } + protected function getTestsForParse() { return array( From 0a16cf21021bc85cccd743da84897d3abcbabfbe Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 3 Sep 2014 22:34:28 +0200 Subject: [PATCH 1267/1305] improve handling router script paths The `server:run` command switches the working directory before starting the built-in web server. Therefore, the path to a custom router script had to be specified based on the document root path and not based on the user's working directory. --- .../Bundle/FrameworkBundle/Command/ServerRunCommand.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php index 35351679103db..0e6972046d85f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php @@ -101,6 +101,14 @@ protected function execute(InputInterface $input, OutputInterface $output) ->locateResource(sprintf('@FrameworkBundle/Resources/config/router_%s.php', $env)) ; + if (!file_exists($router)) { + $output->writeln(sprintf('The given router script "%s" does not exist', $router)); + + return 1; + } + + $router = realpath($router); + $output->writeln(sprintf("Server running on http://%s\n", $input->getArgument('address'))); $builder = new ProcessBuilder(array(PHP_BINARY, '-S', $input->getArgument('address'), $router)); From b044c456798ac5f6d4ad9a8f73bc80857a433470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Wed, 3 Sep 2014 22:47:06 +0200 Subject: [PATCH 1268/1305] Escape parameter on generated response --- src/Symfony/Component/HttpKernel/HttpCache/Esi.php | 6 +++--- .../Component/HttpKernel/Tests/HttpCache/EsiTest.php | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/HttpCache/Esi.php b/src/Symfony/Component/HttpKernel/HttpCache/Esi.php index 3ba9ecd818ca3..9dd99d64cc491 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/Esi.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/Esi.php @@ -236,9 +236,9 @@ private function handleEsiIncludeTag($attributes) throw new \RuntimeException('Unable to process an ESI tag without a "src" attribute.'); } - return sprintf('esi->handle($this, \'%s\', \'%s\', %s) ?>'."\n", - $options['src'], - isset($options['alt']) ? $options['alt'] : null, + return sprintf('esi->handle($this, %s, %s, %s) ?>'."\n", + var_export($options['src'], true), + var_export(isset($options['alt']) ? $options['alt'] : '', true), isset($options['onerror']) && 'continue' == $options['onerror'] ? 'true' : 'false' ); } diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php index 328f855cd308f..23e256e85b8b5 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/EsiTest.php @@ -110,6 +110,11 @@ public function testProcess() $this->assertEquals('foo esi->handle($this, \'...\', \'alt\', true) ?>'."\n", $response->getContent()); $this->assertEquals('ESI', $response->headers->get('x-body-eval')); + $response = new Response('foo '); + $esi->process($request, $response); + + $this->assertEquals("foo esi->handle(\$this, 'foo\\'', 'bar\\'', true) ?>"."\n", $response->getContent()); + $response = new Response('foo '); $esi->process($request, $response); From a7d0cf207034df9abdd2ba36f1cfe3ddff7f4b53 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 29 Aug 2014 13:31:22 +0200 Subject: [PATCH 1269/1305] properly mask escape sequences in quoted strings --- src/Symfony/Component/Yaml/Escaper.php | 4 +-- .../Component/Yaml/Tests/DumperTest.php | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Yaml/Escaper.php b/src/Symfony/Component/Yaml/Escaper.php index 4a6b62161329c..15a121792f9d6 100644 --- a/src/Symfony/Component/Yaml/Escaper.php +++ b/src/Symfony/Component/Yaml/Escaper.php @@ -26,13 +26,13 @@ class Escaper // first to ensure proper escaping because str_replace operates iteratively // on the input arrays. This ordering of the characters avoids the use of strtr, // which performs more slowly. - private static $escapees = array('\\\\', '\\"', '"', + private static $escapees = array('\\', '\\\\', '\\"', '"', "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f", "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f", "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9"); - private static $escaped = array('\\"', '\\\\', '\\"', + private static $escaped = array('\\\\', '\\"', '\\\\', '\\"', "\\0", "\\x01", "\\x02", "\\x03", "\\x04", "\\x05", "\\x06", "\\a", "\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\x0e", "\\x0f", "\\x10", "\\x11", "\\x12", "\\x13", "\\x14", "\\x15", "\\x16", "\\x17", diff --git a/src/Symfony/Component/Yaml/Tests/DumperTest.php b/src/Symfony/Component/Yaml/Tests/DumperTest.php index ec2c65e3d0683..53d164c4ba55a 100644 --- a/src/Symfony/Component/Yaml/Tests/DumperTest.php +++ b/src/Symfony/Component/Yaml/Tests/DumperTest.php @@ -199,6 +199,37 @@ public function testObjectSupportDisabledWithExceptions() { $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, true, false); } + + /** + * @dataProvider getEscapeSequences + */ + public function testEscapedEscapeSequencesInQuotedScalar($input, $expected) + { + $this->assertEquals($expected, $this->dumper->dump($input)); + } + + public function getEscapeSequences() + { + return array( + 'null' => array("\t\\0", '"\t\\\\0"'), + 'bell' => array("\t\\a", '"\t\\\\a"'), + 'backspace' => array("\t\\b", '"\t\\\\b"'), + 'horizontal-tab' => array("\t\\t", '"\t\\\\t"'), + 'line-feed' => array("\t\\n", '"\t\\\\n"'), + 'vertical-tab' => array("\t\\v", '"\t\\\\v"'), + 'form-feed' => array("\t\\f", '"\t\\\\f"'), + 'carriage-return' => array("\t\\r", '"\t\\\\r"'), + 'escape' => array("\t\\e", '"\t\\\\e"'), + 'space' => array("\t\\ ", '"\t\\\\ "'), + 'double-quote' => array("\t\\\"", '"\t\\\\\\""'), + 'slash' => array("\t\\/", '"\t\\\\/"'), + 'backslash' => array("\t\\\\", '"\t\\\\\\\\"'), + 'next-line' => array("\t\\N", '"\t\\\\N"'), + 'non-breaking-space' => array("\t\\�", '"\t\\\\�"'), + 'line-separator' => array("\t\\L", '"\t\\\\L"'), + 'paragraph-separator' => array("\t\\P", '"\t\\\\P"'), + ); + } } class A From 03bd74bdeae5e686cb15e6ec2b3b629f58211419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Tue, 2 Sep 2014 00:40:13 +0200 Subject: [PATCH 1270/1305] [Security] Use hash_equals for constant-time string comparison --- .../Component/Security/Core/Util/StringUtils.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Core/Util/StringUtils.php b/src/Symfony/Component/Security/Core/Util/StringUtils.php index 5e130375b725b..acf8e9eed8af3 100644 --- a/src/Symfony/Component/Security/Core/Util/StringUtils.php +++ b/src/Symfony/Component/Security/Core/Util/StringUtils.php @@ -27,6 +27,7 @@ private function __construct() {} * Compares two strings. * * This method implements a constant-time algorithm to compare strings. + * Regardless of the used implementation, it will leak length information. * * @param string $knownString The string of known length to compare against * @param string $userInput The string that the user can control @@ -35,6 +36,13 @@ private function __construct() {} */ public static function equals($knownString, $userInput) { + $knownString = (string) $knownString; + $userInput = (string) $userInput; + + if (function_exists('hash_equals')) { + return hash_equals($knownString, $userInput); + } + $knownLen = strlen($knownString); $userLen = strlen($userInput); @@ -45,7 +53,7 @@ public static function equals($knownString, $userInput) $result = $knownLen - $userLen; // Note that we ALWAYS iterate over the user-supplied length - // This is to prevent leaking length information + // This is to mitigate leaking length information for ($i = 0; $i < $userLen; $i++) { $result |= (ord($knownString[$i]) ^ ord($userInput[$i])); } From 3071557ec84ee8012a4fb5d6324b75cf1f4d7b1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Sun, 31 Aug 2014 17:01:28 +0200 Subject: [PATCH 1271/1305] [Security] Add more tests for StringUtils::equals --- .../Tests/Core/Util/StringUtilsTest.php | 44 +++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Security/Tests/Core/Util/StringUtilsTest.php b/src/Symfony/Component/Security/Tests/Core/Util/StringUtilsTest.php index aac4139254a43..b16cbacc030fc 100644 --- a/src/Symfony/Component/Security/Tests/Core/Util/StringUtilsTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Util/StringUtilsTest.php @@ -13,11 +13,49 @@ use Symfony\Component\Security\Core\Util\StringUtils; +/** + * Data from PHP.net's hash_equals tests + */ class StringUtilsTest extends \PHPUnit_Framework_TestCase { - public function testEquals() + public function dataProviderTrue() + { + return array( + array('same', 'same'), + array('', ''), + array(123, 123), + array(null, ''), + array(null, null), + ); + } + + public function dataProviderFalse() + { + return array( + array('not1same', 'not2same'), + array('short', 'longer'), + array('longer', 'short'), + array('', 'notempty'), + array('notempty', ''), + array(123, 'NaN'), + array('NaN', 123), + array(null, 123), + ); + } + + /** + * @dataProvider dataProviderTrue + */ + public function testEqualsTrue($known, $user) + { + $this->assertTrue(StringUtils::equals($known, $user)); + } + + /** + * @dataProvider dataProviderFalse + */ + public function testEqualsFalse($known, $user) { - $this->assertTrue(StringUtils::equals('password', 'password')); - $this->assertFalse(StringUtils::equals('password', 'foo')); + $this->assertFalse(StringUtils::equals($known, $user)); } } From 87449e04f26a298915a283fdb35478968ab9c446 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 13 Jul 2014 13:34:23 +0200 Subject: [PATCH 1272/1305] backport more error information from 2.6 to 2.3 The commit on master was: server:run command: provide more error information The server:run command didn't provide many information when the executed command exited unexpectedly. Now, the process' exit code is passed through and an error message is displayed. --- .../FrameworkBundle/Command/ServerRunCommand.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php index 35351679103db..380e72fcf9478 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php @@ -106,10 +106,21 @@ protected function execute(InputInterface $input, OutputInterface $output) $builder = new ProcessBuilder(array(PHP_BINARY, '-S', $input->getArgument('address'), $router)); $builder->setWorkingDirectory($documentRoot); $builder->setTimeout(null); - $builder->getProcess()->run(function ($type, $buffer) use ($output) { + $process = $builder->getProcess(); + $process->run(function ($type, $buffer) use ($output) { if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { $output->write($buffer); } }); + + if (!$process->isSuccessful()) { + $output->writeln('Built-in server terminated unexpectedly'); + + if (OutputInterface::VERBOSITY_VERBOSE > $output->getVerbosity()) { + $output->writeln('Run the command again with -v option for more details'); + } + } + + return $process->getExitCode(); } } From 131abd816fa08b43f57448893acb58c4552a5cbc Mon Sep 17 00:00:00 2001 From: Morgan Auchede Date: Fri, 5 Sep 2014 14:27:29 +0200 Subject: [PATCH 1273/1305] [Security] Fix usage of unexistent method in DoctrineAclCache. --- .../Component/Security/Acl/Domain/DoctrineAclCache.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Acl/Domain/DoctrineAclCache.php b/src/Symfony/Component/Security/Acl/Domain/DoctrineAclCache.php index 9e14af5652c49..0c69773c4729f 100644 --- a/src/Symfony/Component/Security/Acl/Domain/DoctrineAclCache.php +++ b/src/Symfony/Component/Security/Acl/Domain/DoctrineAclCache.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Security\Acl\Domain; use Doctrine\Common\Cache\Cache; +use Doctrine\Common\Cache\CacheProvider; use Symfony\Component\Security\Acl\Model\AclCacheInterface; use Symfony\Component\Security\Acl\Model\AclInterface; use Symfony\Component\Security\Acl\Model\ObjectIdentityInterface; @@ -55,7 +56,9 @@ public function __construct(Cache $cache, PermissionGrantingStrategyInterface $p */ public function clearCache() { - $this->cache->deleteByPrefix($this->prefix); + if ($this->cache instanceof CacheProvider) { + $this->cache->deleteAll(); + } } /** From 1421449991fda6e5052d83566aec07316a0e5210 Mon Sep 17 00:00:00 2001 From: Milos Colakovic Date: Sat, 6 Sep 2014 16:17:45 +0200 Subject: [PATCH 1274/1305] Remove routes for removed WebProfiler actions The import/export functionality was moved to commands in f38536ab79058f6a934426c41170256ba9623a02, but the routes were not removed. --- .../Resources/config/routing/profiler.xml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/profiler.xml b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/profiler.xml index 1819e481c860d..69f934e53f661 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/profiler.xml +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/profiler.xml @@ -24,14 +24,6 @@ web_profiler.controller.profiler:infoAction - - web_profiler.controller.profiler:importAction - - - - web_profiler.controller.profiler:exportAction - - web_profiler.controller.profiler:phpinfoAction From 7fd5e8b2017c9b6ea77007157fff5678b6aa4168 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Tue, 9 Sep 2014 16:20:39 +0200 Subject: [PATCH 1275/1305] [Intl] Added "internal" tag to all classes under Symfony\Component\Intl\ResourceBundle We didn't have this tag yet when this component was first written. The code in that namespace is only used for resource bundle generation and was never meant for public use. --- src/Symfony/Component/Intl/ResourceBundle/AbstractBundle.php | 2 ++ .../Component/Intl/ResourceBundle/Compiler/BundleCompiler.php | 2 ++ .../Intl/ResourceBundle/Compiler/BundleCompilerInterface.php | 2 ++ src/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php | 2 ++ src/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php | 2 ++ src/Symfony/Component/Intl/ResourceBundle/LocaleBundle.php | 2 ++ .../Intl/ResourceBundle/Reader/AbstractBundleReader.php | 2 ++ .../Component/Intl/ResourceBundle/Reader/BinaryBundleReader.php | 2 ++ .../Intl/ResourceBundle/Reader/BufferedBundleReader.php | 2 ++ .../Intl/ResourceBundle/Reader/BundleReaderInterface.php | 2 ++ .../Component/Intl/ResourceBundle/Reader/PhpBundleReader.php | 2 ++ .../Intl/ResourceBundle/Reader/StructuredBundleReader.php | 2 ++ .../ResourceBundle/Reader/StructuredBundleReaderInterface.php | 2 ++ src/Symfony/Component/Intl/ResourceBundle/RegionBundle.php | 2 ++ .../Intl/ResourceBundle/Transformer/BundleTransformer.php | 2 ++ .../Intl/ResourceBundle/Transformer/CompilationContext.php | 2 ++ .../ResourceBundle/Transformer/CompilationContextInterface.php | 2 ++ .../Transformer/Rule/CurrencyBundleTransformationRule.php | 2 ++ .../Transformer/Rule/LanguageBundleTransformationRule.php | 2 ++ .../Transformer/Rule/LocaleBundleTransformationRule.php | 2 ++ .../Transformer/Rule/RegionBundleTransformationRule.php | 2 ++ .../Transformer/Rule/TransformationRuleInterface.php | 2 ++ .../Intl/ResourceBundle/Transformer/StubbingContext.php | 2 ++ .../ResourceBundle/Transformer/StubbingContextInterface.php | 2 ++ .../Intl/ResourceBundle/Util/ArrayAccessibleResourceBundle.php | 2 ++ .../Component/Intl/ResourceBundle/Util/RecursiveArrayAccess.php | 2 ++ src/Symfony/Component/Intl/ResourceBundle/Util/RingBuffer.php | 2 ++ .../Intl/ResourceBundle/Writer/BundleWriterInterface.php | 2 ++ .../Component/Intl/ResourceBundle/Writer/PhpBundleWriter.php | 2 ++ .../Component/Intl/ResourceBundle/Writer/TextBundleWriter.php | 2 ++ 30 files changed, 60 insertions(+) diff --git a/src/Symfony/Component/Intl/ResourceBundle/AbstractBundle.php b/src/Symfony/Component/Intl/ResourceBundle/AbstractBundle.php index 1aaadee20bf80..53be149d8d8b2 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/AbstractBundle.php +++ b/src/Symfony/Component/Intl/ResourceBundle/AbstractBundle.php @@ -17,6 +17,8 @@ * Base class for {@link ResourceBundleInterface} implementations. * * @author Bernhard Schussek + * + * @internal */ abstract class AbstractBundle implements ResourceBundleInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Compiler/BundleCompiler.php b/src/Symfony/Component/Intl/ResourceBundle/Compiler/BundleCompiler.php index 174aa179f4067..8249f66d0d686 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Compiler/BundleCompiler.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Compiler/BundleCompiler.php @@ -17,6 +17,8 @@ * Compiles .txt resource bundles to binary .res files. * * @author Bernhard Schussek + * + * @internal */ class BundleCompiler implements BundleCompilerInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Compiler/BundleCompilerInterface.php b/src/Symfony/Component/Intl/ResourceBundle/Compiler/BundleCompilerInterface.php index 6184ea3eb1c43..d9cde44d82f78 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Compiler/BundleCompilerInterface.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Compiler/BundleCompilerInterface.php @@ -15,6 +15,8 @@ * Compiles a resource bundle. * * @author Bernhard Schussek + * + * @internal */ interface BundleCompilerInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php b/src/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php index eec6710c4d20e..bcd486e996997 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php +++ b/src/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php @@ -15,6 +15,8 @@ * Default implementation of {@link CurrencyBundleInterface}. * * @author Bernhard Schussek + * + * @internal */ class CurrencyBundle extends AbstractBundle implements CurrencyBundleInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php b/src/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php index b09381fa3492a..060b214ae8673 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php +++ b/src/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php @@ -15,6 +15,8 @@ * Default implementation of {@link LanguageBundleInterface}. * * @author Bernhard Schussek + * + * @internal */ class LanguageBundle extends AbstractBundle implements LanguageBundleInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/LocaleBundle.php b/src/Symfony/Component/Intl/ResourceBundle/LocaleBundle.php index 6f6cdfcb189c2..f799f200d41cf 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/LocaleBundle.php +++ b/src/Symfony/Component/Intl/ResourceBundle/LocaleBundle.php @@ -15,6 +15,8 @@ * Default implementation of {@link LocaleBundleInterface}. * * @author Bernhard Schussek + * + * @internal */ class LocaleBundle extends AbstractBundle implements LocaleBundleInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Reader/AbstractBundleReader.php b/src/Symfony/Component/Intl/ResourceBundle/Reader/AbstractBundleReader.php index c30693ac57a20..02db55b4072c6 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Reader/AbstractBundleReader.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Reader/AbstractBundleReader.php @@ -15,6 +15,8 @@ * Base class for {@link BundleReaderInterface} implementations. * * @author Bernhard Schussek + * + * @internal */ abstract class AbstractBundleReader implements BundleReaderInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Reader/BinaryBundleReader.php b/src/Symfony/Component/Intl/ResourceBundle/Reader/BinaryBundleReader.php index 16ea1dd3aa801..75738dd8c8829 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Reader/BinaryBundleReader.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Reader/BinaryBundleReader.php @@ -18,6 +18,8 @@ * Reads binary .res resource bundles. * * @author Bernhard Schussek + * + * @internal */ class BinaryBundleReader extends AbstractBundleReader implements BundleReaderInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Reader/BufferedBundleReader.php b/src/Symfony/Component/Intl/ResourceBundle/Reader/BufferedBundleReader.php index f005eeb4ac699..19f6d672afbf7 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Reader/BufferedBundleReader.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Reader/BufferedBundleReader.php @@ -15,6 +15,8 @@ /** * @author Bernhard Schussek + * + * @internal */ class BufferedBundleReader implements BundleReaderInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Reader/BundleReaderInterface.php b/src/Symfony/Component/Intl/ResourceBundle/Reader/BundleReaderInterface.php index bc485cd5267b4..c11d90e046439 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Reader/BundleReaderInterface.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Reader/BundleReaderInterface.php @@ -15,6 +15,8 @@ * Reads resource bundle files. * * @author Bernhard Schussek + * + * @internal */ interface BundleReaderInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Reader/PhpBundleReader.php b/src/Symfony/Component/Intl/ResourceBundle/Reader/PhpBundleReader.php index 663bcc9d789d8..01dd00be51640 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Reader/PhpBundleReader.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Reader/PhpBundleReader.php @@ -18,6 +18,8 @@ * Reads .php resource bundles. * * @author Bernhard Schussek + * + * @internal */ class PhpBundleReader extends AbstractBundleReader implements BundleReaderInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReader.php b/src/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReader.php index 4b71c9bcb249b..689510bdd75f1 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReader.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReader.php @@ -19,6 +19,8 @@ * @author Bernhard Schussek * * @see StructuredResourceBundleBundleReaderInterface + * + * @internal */ class StructuredBundleReader implements StructuredBundleReaderInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReaderInterface.php b/src/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReaderInterface.php index 5d435c485c09c..408ee67ee03ef 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReaderInterface.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReaderInterface.php @@ -15,6 +15,8 @@ * Reads individual entries of a resource file. * * @author Bernhard Schussek + * + * @internal */ interface StructuredBundleReaderInterface extends BundleReaderInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/RegionBundle.php b/src/Symfony/Component/Intl/ResourceBundle/RegionBundle.php index bbfbedeed9ddf..0a4cce8a9729f 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/RegionBundle.php +++ b/src/Symfony/Component/Intl/ResourceBundle/RegionBundle.php @@ -15,6 +15,8 @@ * Default implementation of {@link RegionBundleInterface}. * * @author Bernhard Schussek + * + * @internal */ class RegionBundle extends AbstractBundle implements RegionBundleInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Transformer/BundleTransformer.php b/src/Symfony/Component/Intl/ResourceBundle/Transformer/BundleTransformer.php index 0692d6fe50a05..c613486f18f81 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Transformer/BundleTransformer.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Transformer/BundleTransformer.php @@ -19,6 +19,8 @@ * Compiles a number of resource bundles based on predefined compilation rules. * * @author Bernhard Schussek + * + * @internal */ class BundleTransformer { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContext.php b/src/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContext.php index cdc1951b96bcc..2b336e8138670 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContext.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContext.php @@ -18,6 +18,8 @@ * Default implementation of {@link CompilationContextInterface}. * * @author Bernhard Schussek + * + * @internal */ class CompilationContext implements CompilationContextInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContextInterface.php b/src/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContextInterface.php index f05c28079a211..cd13ace6f578c 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContextInterface.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContextInterface.php @@ -15,6 +15,8 @@ * Stores contextual information for resource bundle compilation. * * @author Bernhard Schussek + * + * @internal */ interface CompilationContextInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php b/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php index 95783b3b06a19..d38cfc7b700f7 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php @@ -21,6 +21,8 @@ * The rule for compiling the currency bundle. * * @author Bernhard Schussek + * + * @internal */ class CurrencyBundleTransformationRule implements TransformationRuleInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LanguageBundleTransformationRule.php b/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LanguageBundleTransformationRule.php index 5e6f901849dac..7d78d7488034c 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LanguageBundleTransformationRule.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LanguageBundleTransformationRule.php @@ -20,6 +20,8 @@ * The rule for compiling the language bundle. * * @author Bernhard Schussek + * + * @internal */ class LanguageBundleTransformationRule implements TransformationRuleInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LocaleBundleTransformationRule.php b/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LocaleBundleTransformationRule.php index af4dfea557086..22ec9113721a9 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LocaleBundleTransformationRule.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LocaleBundleTransformationRule.php @@ -21,6 +21,8 @@ * The rule for compiling the locale bundle. * * @author Bernhard Schussek + * + * @internal */ class LocaleBundleTransformationRule implements TransformationRuleInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/RegionBundleTransformationRule.php b/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/RegionBundleTransformationRule.php index 52fdbed8c3384..300ad02563acc 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/RegionBundleTransformationRule.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/RegionBundleTransformationRule.php @@ -20,6 +20,8 @@ * The rule for compiling the region bundle. * * @author Bernhard Schussek + * + * @internal */ class RegionBundleTransformationRule implements TransformationRuleInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/TransformationRuleInterface.php b/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/TransformationRuleInterface.php index 3965e0d2b7e04..f02bf285d9996 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/TransformationRuleInterface.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/TransformationRuleInterface.php @@ -18,6 +18,8 @@ * Contains instruction for compiling a resource bundle. * * @author Bernhard Schussek + * + * @internal */ interface TransformationRuleInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContext.php b/src/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContext.php index 25ab68dbfc9a2..de2604e0b77cf 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContext.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContext.php @@ -15,6 +15,8 @@ /** * @author Bernhard Schussek + * + * @internal */ class StubbingContext implements StubbingContextInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContextInterface.php b/src/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContextInterface.php index dc49255620fff..596ee1bb7e746 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContextInterface.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContextInterface.php @@ -13,6 +13,8 @@ /** * @author Bernhard Schussek + * + * @internal */ interface StubbingContextInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Util/ArrayAccessibleResourceBundle.php b/src/Symfony/Component/Intl/ResourceBundle/Util/ArrayAccessibleResourceBundle.php index 9a4cccb461145..fab8e93beda60 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Util/ArrayAccessibleResourceBundle.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Util/ArrayAccessibleResourceBundle.php @@ -20,6 +20,8 @@ * This class can be removed once that bug is fixed. * * @author Bernhard Schussek + * + * @internal */ class ArrayAccessibleResourceBundle implements \ArrayAccess, \IteratorAggregate, \Countable { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Util/RecursiveArrayAccess.php b/src/Symfony/Component/Intl/ResourceBundle/Util/RecursiveArrayAccess.php index 5257e9c1ca5c8..6e46790c6f75d 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Util/RecursiveArrayAccess.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Util/RecursiveArrayAccess.php @@ -13,6 +13,8 @@ /** * @author Bernhard Schussek + * + * @internal */ class RecursiveArrayAccess { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Util/RingBuffer.php b/src/Symfony/Component/Intl/ResourceBundle/Util/RingBuffer.php index 7ccbd1e702d0e..59cfdaac90696 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Util/RingBuffer.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Util/RingBuffer.php @@ -21,6 +21,8 @@ * then the second and so on. * * @author Bernhard Schussek + * + * @internal */ class RingBuffer implements \ArrayAccess { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Writer/BundleWriterInterface.php b/src/Symfony/Component/Intl/ResourceBundle/Writer/BundleWriterInterface.php index cc3b958657a21..f612aacae7d14 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Writer/BundleWriterInterface.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Writer/BundleWriterInterface.php @@ -15,6 +15,8 @@ * Writes resource bundle files. * * @author Bernhard Schussek + * + * @internal */ interface BundleWriterInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Writer/PhpBundleWriter.php b/src/Symfony/Component/Intl/ResourceBundle/Writer/PhpBundleWriter.php index d2688b49bceb9..d5a30b907dcf4 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Writer/PhpBundleWriter.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Writer/PhpBundleWriter.php @@ -15,6 +15,8 @@ * Writes .php resource bundles. * * @author Bernhard Schussek + * + * @internal */ class PhpBundleWriter implements BundleWriterInterface { diff --git a/src/Symfony/Component/Intl/ResourceBundle/Writer/TextBundleWriter.php b/src/Symfony/Component/Intl/ResourceBundle/Writer/TextBundleWriter.php index c2fff38c7b48d..c69bec62dc0bc 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Writer/TextBundleWriter.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Writer/TextBundleWriter.php @@ -20,6 +20,8 @@ * @author Bernhard Schussek * * @see http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt + * + * @internal */ class TextBundleWriter implements BundleWriterInterface { From 1fe8e315144dbd0ca0020c657f23f40cff48a2e4 Mon Sep 17 00:00:00 2001 From: flack Date: Tue, 9 Sep 2014 23:26:35 +0200 Subject: [PATCH 1276/1305] [FrameworkBundle] Remove invalid markup --- .../Resources/views/Form/form_widget_compound.html.php | 6 +----- .../views/FormTable/form_widget_compound.html.php | 8 ++++++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_widget_compound.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_widget_compound.html.php index 45a821032ed61..7a4f7cd51fb3a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_widget_compound.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/form_widget_compound.html.php @@ -1,10 +1,6 @@
    block($form, 'widget_container_attributes') ?>> parent && $errors): ?> - - - errors($form) ?> - - + errors($form) ?> block($form, 'form_rows') ?> rest($form) ?> diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/form_widget_compound.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/form_widget_compound.html.php index a4878e57dbd47..20b9668aa49c9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/form_widget_compound.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/form_widget_compound.html.php @@ -1,6 +1,10 @@ block($form, 'widget_container_attributes') ?>> - parent): ?> - errors($form) ?> + parent && $errors): ?> + + + block($form, 'form_rows') ?> rest($form) ?> From a5e3fc9e8a5eab8f858e0462c2f870eea2dc0c3b Mon Sep 17 00:00:00 2001 From: Daniel Beyer Date: Wed, 10 Sep 2014 18:06:23 +0200 Subject: [PATCH 1277/1305] [SwiftmailerBridge] Bump allowed versions of swiftmailer Current version of Swiftmailer is 5.2.1, while (previously to this commit) the version installed by composer was 5.0.3. This is rather important, since 5.2.1 closes a security issue that 5.0.3 is vulnarable to (https://github.com/swiftmailer/swiftmailer/issues/494). --- src/Symfony/Bridge/Swiftmailer/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Swiftmailer/composer.json b/src/Symfony/Bridge/Swiftmailer/composer.json index 9e6c90b7bdaf6..7ad93ab97e3a6 100644 --- a/src/Symfony/Bridge/Swiftmailer/composer.json +++ b/src/Symfony/Bridge/Swiftmailer/composer.json @@ -17,7 +17,7 @@ ], "require": { "php": ">=5.3.3", - "swiftmailer/swiftmailer": ">=4.2.0,<5.1-dev" + "swiftmailer/swiftmailer": ">=4.2.0,<6.0-dev" }, "suggest": { "symfony/http-kernel": "" From ee75af0c8993a3c28c653c036ac55ae5d6ab8c76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20JOURDIN?= Date: Mon, 28 Jul 2014 15:26:43 +0200 Subject: [PATCH 1278/1305] Use separated function to resolve command and related arguments --- .../Component/Process/PhpExecutableFinder.php | 23 +++++++++++-- .../Process/Tests/PhpExecutableFinderTest.php | 33 +++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Process/PhpExecutableFinder.php b/src/Symfony/Component/Process/PhpExecutableFinder.php index cda86995a481f..7854487a26b23 100644 --- a/src/Symfony/Component/Process/PhpExecutableFinder.php +++ b/src/Symfony/Component/Process/PhpExecutableFinder.php @@ -29,13 +29,15 @@ public function __construct() /** * Finds The PHP executable. * + * @param bool $includeArgs Whether or not include command arguments + * * @return string|false The PHP executable path or false if it cannot be found */ - public function find() + public function find($includeArgs = true) { // HHVM support if (defined('HHVM_VERSION')) { - return (false !== ($hhvm = getenv('PHP_BINARY')) ? $hhvm : PHP_BINARY).' --php'; + return (false !== ($hhvm = getenv('PHP_BINARY')) ? $hhvm : PHP_BINARY).($includeArgs ? ' '.implode(' ', $this->findArguments()) : ''); } // PHP_BINARY return the current sapi executable @@ -64,4 +66,21 @@ public function find() return $this->executableFinder->find('php', false, $dirs); } + + /** + * Finds the PHP executable arguments. + * + * @return array The PHP executable arguments + */ + public function findArguments() + { + $arguments = array(); + + // HHVM support + if (defined('HHVM_VERSION')) { + $arguments[] = '--php'; + } + + return $arguments; + } } diff --git a/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php b/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php index df48c4f556c2e..e16f3f8bed143 100644 --- a/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php +++ b/src/Symfony/Component/Process/Tests/PhpExecutableFinderTest.php @@ -34,10 +34,43 @@ public function testFindWithPhpPath() //not executable PHP_PATH putenv('PHP_PATH=/not/executable/php'); $this->assertFalse($f->find(), '::find() returns false for not executable PHP'); + $this->assertFalse($f->find(false), '::find() returns false for not executable PHP'); //executable PHP_PATH putenv('PHP_PATH='.$current); $this->assertEquals($f->find(), $current, '::find() returns the executable PHP'); + $this->assertEquals($f->find(false), $current, '::find() returns the executable PHP'); + } + + /** + * tests find() with the env var PHP_PATH + */ + public function testFindWithHHVM() + { + if (!defined('HHVM_VERSION')) { + $this->markTestSkipped('Should be executed in HHVM context.'); + } + + $f = new PhpExecutableFinder(); + + $current = $f->find(); + + $this->assertEquals($f->find(), $current.' --php', '::find() returns the executable PHP'); + $this->assertEquals($f->find(false), $current, '::find() returns the executable PHP'); + } + + /** + * tests find() with the env var PHP_PATH + */ + public function testFindArguments() + { + $f = new PhpExecutableFinder(); + + if (defined('HHVM_VERSION')) { + $this->assertEquals($f->findArguments(), array('--php'), '::findArguments() returns HHVM arguments'); + } else { + $this->assertEquals($f->findArguments(), array(), '::findArguments() returns no arguments'); + } } /** From 5feda5e9a6849f5b8091eeba756a18994dfcf758 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Thu, 11 Sep 2014 18:28:58 +0200 Subject: [PATCH 1279/1305] [Intl] Removed non-working $fallback argument from ArrayAccessibleResourceBundle --- .../ResourceBundle/Util/ArrayAccessibleResourceBundle.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Intl/ResourceBundle/Util/ArrayAccessibleResourceBundle.php b/src/Symfony/Component/Intl/ResourceBundle/Util/ArrayAccessibleResourceBundle.php index fab8e93beda60..44f1b2c580015 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Util/ArrayAccessibleResourceBundle.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Util/ArrayAccessibleResourceBundle.php @@ -32,16 +32,16 @@ public function __construct(\ResourceBundle $bundleImpl) $this->bundleImpl = $bundleImpl; } - public function get($offset, $fallback = null) + public function get($offset) { - $value = $this->bundleImpl->get($offset, $fallback); + $value = $this->bundleImpl->get($offset); return $value instanceof \ResourceBundle ? new static($value) : $value; } public function offsetExists($offset) { - return null !== $this->bundleImpl[$offset]; + return null !== $this->bundleImpl->get($offset); } public function offsetGet($offset) From 260e2fe17280330d85a45bf00ee526b57bcb46ef Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Fri, 12 Sep 2014 13:08:39 +0200 Subject: [PATCH 1280/1305] [Intl] Updated icu.ini up to ICU 53 --- src/Symfony/Component/Intl/Resources/bin/icu.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Symfony/Component/Intl/Resources/bin/icu.ini b/src/Symfony/Component/Intl/Resources/bin/icu.ini index 7f1ad90a6a94b..adfb71643d7d2 100644 --- a/src/Symfony/Component/Intl/Resources/bin/icu.ini +++ b/src/Symfony/Component/Intl/Resources/bin/icu.ini @@ -8,3 +8,5 @@ 49 = http://source.icu-project.org/repos/icu/icu/tags/release-49-1-2/source 50 = http://source.icu-project.org/repos/icu/icu/tags/release-50-1-2/source 51 = http://source.icu-project.org/repos/icu/icu/tags/release-51-2/source +52 = http://source.icu-project.org/repos/icu/icu/tags/release-52-1/source +53 = http://source.icu-project.org/repos/icu/icu/tags/release-53-1/source From 7b4a35a844b289db6051ed94e03da00787665e5b Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Thu, 11 Sep 2014 18:47:55 +0200 Subject: [PATCH 1281/1305] [Intl] Fixed a few bugs in TextBundleWriter --- .../Exception/UnexpectedTypeException.php | 25 ++++++++ .../Writer/TextBundleWriter.php | 61 ++++++++++++++----- .../ResourceBundle/Writer/Fixtures/en.txt | 16 +++++ .../Writer/Fixtures/en_nofallback.txt | 3 + .../Writer/Fixtures/escaped.txt | 4 ++ .../Writer/TextBundleWriterTest.php | 52 +++++++++++++++- 6 files changed, 145 insertions(+), 16 deletions(-) create mode 100644 src/Symfony/Component/Intl/Exception/UnexpectedTypeException.php create mode 100644 src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en_nofallback.txt create mode 100644 src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/escaped.txt diff --git a/src/Symfony/Component/Intl/Exception/UnexpectedTypeException.php b/src/Symfony/Component/Intl/Exception/UnexpectedTypeException.php new file mode 100644 index 0000000000000..645d4926dad15 --- /dev/null +++ b/src/Symfony/Component/Intl/Exception/UnexpectedTypeException.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Intl\Exception; + +/** + * Thrown when a method argument had an unexpected type. + * + * @author Bernhard Schussek + */ +class UnexpectedTypeException extends InvalidArgumentException +{ + public function __construct($value, $expectedType) + { + parent::__construct(sprintf('Expected argument of type "%s", "%s" given', $expectedType, is_object($value) ? get_class($value) : gettype($value))); + } +} diff --git a/src/Symfony/Component/Intl/ResourceBundle/Writer/TextBundleWriter.php b/src/Symfony/Component/Intl/ResourceBundle/Writer/TextBundleWriter.php index c69bec62dc0bc..2aa702089f1eb 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Writer/TextBundleWriter.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Writer/TextBundleWriter.php @@ -11,11 +11,14 @@ namespace Symfony\Component\Intl\ResourceBundle\Writer; +use Symfony\Component\Intl\Exception\UnexpectedTypeException; + /** * Writes .txt resource bundles. * - * The resulting files can be converted to binary .res files using the - * {@link \Symfony\Component\Intl\ResourceBundle\Transformer\BundleCompiler}. + * The resulting files can be converted to binary .res files using a + * {@link \Symfony\Component\Intl\ResourceBundle\Compiler\BundleCompilerInterface} + * implementation. * * @author Bernhard Schussek * @@ -28,11 +31,11 @@ class TextBundleWriter implements BundleWriterInterface /** * {@inheritdoc} */ - public function write($path, $locale, $data) + public function write($path, $locale, $data, $fallback = true) { $file = fopen($path.'/'.$locale.'.txt', 'w'); - $this->writeResourceBundle($file, $locale, $data); + $this->writeResourceBundle($file, $locale, $data, $fallback); fclose($file); } @@ -43,14 +46,16 @@ public function write($path, $locale, $data) * @param resource $file The file handle to write to. * @param string $bundleName The name of the bundle. * @param mixed $value The value of the node. + * @param bool $fallback Whether the resource bundle should be merged + * with the fallback locale. * * @see http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt */ - private function writeResourceBundle($file, $bundleName, $value) + private function writeResourceBundle($file, $bundleName, $value, $fallback) { fwrite($file, $bundleName); - $this->writeTable($file, $value, 0); + $this->writeTable($file, $value, 0, $fallback); fwrite($file, "\n"); } @@ -74,16 +79,25 @@ private function writeResource($file, $value, $indentation, $requireBraces = tru return; } + if ($value instanceof \Traversable) { + $value = iterator_to_array($value); + } + if (is_array($value)) { - if (count($value) === count(array_filter($value, 'is_int'))) { + $intValues = count($value) === count(array_filter($value, 'is_int')); + + $keys = array_keys($value); + + // check that the keys are 0-indexed and ascending + $intKeys = $keys === range(0, count($keys) - 1); + + if ($intValues && $intKeys) { $this->writeIntVector($file, $value, $indentation); return; } - $keys = array_keys($value); - - if (count($keys) === count(array_filter($keys, 'is_int'))) { + if ($intKeys) { $this->writeArray($file, $value, $indentation); return; @@ -182,16 +196,35 @@ private function writeArray($file, array $value, $indentation) /** * Writes a "table" node. * - * @param resource $file The file handle to write to. - * @param array $value The value of the node. - * @param int $indentation The number of levels to indent. + * @param resource $file The file handle to write to. + * @param array|\Traversable $value The value of the node. + * @param int $indentation The number of levels to indent. + * @param bool $fallback Whether the table should be merged + * with the fallback locale. + * + * @throws UnexpectedTypeException When $value is not an array and not a + * \Traversable instance. */ - private function writeTable($file, array $value, $indentation) + private function writeTable($file, $value, $indentation, $fallback = true) { + if (!is_array($value) && !$value instanceof \Traversable) { + throw new UnexpectedTypeException($value, 'array or \Traversable'); + } + + if (!$fallback) { + fwrite($file, ":table(nofallback)"); + } + fwrite($file, "{\n"); foreach ($value as $key => $entry) { fwrite($file, str_repeat(' ', $indentation + 1)); + + // escape colons, otherwise they are interpreted as resource types + if (false !== strpos($key, ':') || false !== strpos($key, ' ')) { + $key = '"'.$key.'"'; + } + fwrite($file, $key); $this->writeResource($file, $entry, $indentation + 1); diff --git a/src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.txt b/src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.txt index 0ee0d7f2f5a35..09c1275fa5421 100644 --- a/src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.txt +++ b/src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en.txt @@ -14,6 +14,22 @@ en{ 2, 3, } + NotAnIntVector{ + 0:int{0} + 2:int{1} + 1:int{2} + 3:int{3} + } + IntVectorWithStringKeys{ + a:int{0} + b:int{1} + c:int{2} + } + TableWithIntKeys{ + 0:int{0} + 1:int{1} + 3:int{3} + } FalseBoolean{"false"} TrueBoolean{"true"} Null{""} diff --git a/src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en_nofallback.txt b/src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en_nofallback.txt new file mode 100644 index 0000000000000..85386f2074dc2 --- /dev/null +++ b/src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/en_nofallback.txt @@ -0,0 +1,3 @@ +en_nofallback:table(nofallback){ + Entry{"Value"} +} diff --git a/src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/escaped.txt b/src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/escaped.txt new file mode 100644 index 0000000000000..6669bfdd8306e --- /dev/null +++ b/src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/Fixtures/escaped.txt @@ -0,0 +1,4 @@ +escaped{ + "EntryWith:Colon"{"Value"} + "Entry With Spaces"{"Value"} +} diff --git a/src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/TextBundleWriterTest.php b/src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/TextBundleWriterTest.php index cbe0c8d8bfc4b..f42b2738d797c 100644 --- a/src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/TextBundleWriterTest.php +++ b/src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/TextBundleWriterTest.php @@ -36,7 +36,7 @@ class TextBundleWriterTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->writer = new TextBundleWriter(); - $this->directory = sys_get_temp_dir() . '/TextBundleWriterTest/' . rand(1000, 9999); + $this->directory = sys_get_temp_dir().'/TextBundleWriterTest/'.rand(1000, 9999); $this->filesystem = new Filesystem(); $this->filesystem->mkdir($this->directory); @@ -54,6 +54,9 @@ public function testWrite() 'Array' => array('foo', 'bar', array('Key' => 'value')), 'Integer' => 5, 'IntVector' => array(0, 1, 2, 3), + 'NotAnIntVector' => array(0 => 0, 2 => 1, 1 => 2, 3 => 3), + 'IntVectorWithStringKeys' => array('a' => 0, 'b' => 1, 'c' => 2), + 'TableWithIntKeys' => array(0 => 0, 1 => 1, 3 => 3), 'FalseBoolean' => false, 'TrueBoolean' => true, 'Null' => null, @@ -62,6 +65,51 @@ public function testWrite() 'Entry2' => 'String', )); - $this->assertFileEquals(__DIR__ . '/Fixtures/en.txt', $this->directory . '/en.txt'); + $this->assertFileEquals(__DIR__.'/Fixtures/en.txt', $this->directory.'/en.txt'); + } + + public function testWriteTraversable() + { + $this->writer->write($this->directory, 'en', new \ArrayIterator(array( + 'Entry1' => new \ArrayIterator(array( + 'Array' => array('foo', 'bar', array('Key' => 'value')), + 'Integer' => 5, + 'IntVector' => array(0, 1, 2, 3), + 'NotAnIntVector' => array(0 => 0, 2 => 1, 1 => 2, 3 => 3), + 'IntVectorWithStringKeys' => array('a' => 0, 'b' => 1, 'c' => 2), + 'TableWithIntKeys' => array(0 => 0, 1 => 1, 3 => 3), + 'FalseBoolean' => false, + 'TrueBoolean' => true, + 'Null' => null, + 'Float' => 1.23, + )), + 'Entry2' => 'String', + ))); + + $this->assertFileEquals(__DIR__.'/Fixtures/en.txt', $this->directory.'/en.txt'); + } + + public function testWriteNoFallback() + { + $data = array( + 'Entry' => 'Value' + ); + + $this->writer->write($this->directory, 'en_nofallback', $data, $fallback = false); + + $this->assertFileEquals(__DIR__.'/Fixtures/en_nofallback.txt', $this->directory.'/en_nofallback.txt'); + } + + public function testEscapeKeysIfNecessary() + { + $this->writer->write($this->directory, 'escaped', array( + // Keys with colons must be escaped, otherwise the part after the + // colon is interpreted as resource type + 'EntryWith:Colon' => 'Value', + // Keys with spaces must be escaped + 'Entry With Spaces' => 'Value', + )); + + $this->assertFileEquals(__DIR__.'/Fixtures/escaped.txt', $this->directory.'/escaped.txt'); } } From 9052efc499c1d4739dddb84f19718aa9d33c8cf1 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Fri, 12 Sep 2014 13:09:09 +0200 Subject: [PATCH 1282/1305] [Intl] Added exception handler to command line scripts --- .../Component/Intl/Resources/bin/common.php | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Intl/Resources/bin/common.php b/src/Symfony/Component/Intl/Resources/bin/common.php index eb7643dfbdd9d..1e25265d57afd 100644 --- a/src/Symfony/Component/Intl/Resources/bin/common.php +++ b/src/Symfony/Component/Intl/Resources/bin/common.php @@ -11,11 +11,11 @@ define('LINE_WIDTH', 75); -define('LINE', str_repeat('-', LINE_WIDTH) . "\n"); +define('LINE', str_repeat('-', LINE_WIDTH)."\n"); function bailout($message) { - echo wordwrap($message, LINE_WIDTH) . " Aborting.\n"; + echo wordwrap($message, LINE_WIDTH)." Aborting.\n"; exit(1); } @@ -31,7 +31,7 @@ function centered($text) { $padding = (int) ((LINE_WIDTH - strlen($text))/2); - return str_repeat(' ', $padding) . $text; + return str_repeat(' ', $padding).$text; } function cd($dir) @@ -47,7 +47,7 @@ function run($command) if (0 !== $status) { $output = implode("\n", $output); - echo "Error while running:\n " . getcwd() . '$ ' . $command . "\nOutput:\n" . LINE . "$output\n" . LINE; + echo "Error while running:\n ".getcwd().'$ '.$command."\nOutput:\n".LINE."$output\n".LINE; bailout("\"$command\" failed."); } @@ -55,10 +55,10 @@ function run($command) function get_icu_version_from_genrb($genrb) { - exec($genrb . ' --version 2>&1', $output, $status); + exec($genrb.' --version 2>&1', $output, $status); if (0 !== $status) { - bailout($genrb . ' failed.'); + bailout($genrb.' failed.'); } if (!preg_match('/ICU version ([\d\.]+)/', implode('', $output), $matches)) { @@ -67,3 +67,27 @@ function get_icu_version_from_genrb($genrb) return $matches[1]; } + +set_exception_handler(function (\Exception $exception) { + echo "\n"; + + $cause = $exception; + $root = true; + + while (null !== $cause) { + if (!$root) { + echo "Caused by\n"; + } + + echo get_class($cause).": ".$cause->getMessage()."\n"; + echo "\n"; + echo $cause->getFile().":".$cause->getLine()."\n"; + foreach ($cause->getTrace() as $trace) { + echo $trace['file'].":".$trace['line']."\n"; + } + echo "\n"; + + $cause = $cause->getPrevious(); + $root = false; + } +}); From 7333c2d1cb59d12a972bf4accc7d67e8e3314327 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 13 Sep 2014 09:36:03 +0200 Subject: [PATCH 1283/1305] remove `service` parameter type from XSD Referencing a service in a parameter doesn't work and will lead to an error when the configuration is loaded. --- .../Loader/schema/dic/services/services-1.0.xsd | 1 - .../DependencyInjection/Tests/Fixtures/xml/services2.xml | 1 - .../DependencyInjection/Tests/Loader/XmlFileLoaderTest.php | 4 ++-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd b/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd index d221eb7ac7a1b..e62b475ba36d6 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd +++ b/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd @@ -156,7 +156,6 @@ - diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services2.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services2.xml index 6e8a6ce364dce..958d415f39e3d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services2.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services2.xml @@ -23,7 +23,6 @@ bar - value diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php index aac9a129edc89..71c644516b27f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -99,7 +99,7 @@ public function testLoadParameters() $loader->load('services2.xml'); $actual = $container->getParameterBag()->all(); - $expected = array('a string', 'foo' => 'bar', 'values' => array(0, 'integer' => 4, 100 => null, 'true', true, false, 'on', 'off', 'float' => 1.3, 1000.3, 'a string', array('foo', 'bar')), 'foo_bar' => new Reference('foo_bar'), 'mixedcase' => array('MixedCaseKey' => 'value')); + $expected = array('a string', 'foo' => 'bar', 'values' => array(0, 'integer' => 4, 100 => null, 'true', true, false, 'on', 'off', 'float' => 1.3, 1000.3, 'a string', array('foo', 'bar')), 'mixedcase' => array('MixedCaseKey' => 'value')); $this->assertEquals($expected, $actual, '->load() converts XML values to PHP ones'); } @@ -120,7 +120,7 @@ public function testLoadImports() $loader->load('services4.xml'); $actual = $container->getParameterBag()->all(); - $expected = array('a string', 'foo' => 'bar', 'values' => array(true, false), 'foo_bar' => new Reference('foo_bar'), 'mixedcase' => array('MixedCaseKey' => 'value'), 'bar' => '%foo%', 'imported_from_ini' => true, 'imported_from_yaml' => true); + $expected = array('a string', 'foo' => 'bar', 'values' => array(true, false), 'mixedcase' => array('MixedCaseKey' => 'value'), 'bar' => '%foo%', 'imported_from_ini' => true, 'imported_from_yaml' => true); $this->assertEquals(array_keys($expected), array_keys($actual), '->load() imports and merges imported files'); From 938ae4bf0d876996ac65ddfe9684ec588478f87e Mon Sep 17 00:00:00 2001 From: Marc Torres Date: Mon, 8 Sep 2014 16:52:38 +0200 Subject: [PATCH 1284/1305] [Security] Added more tests --- .../AccessDecisionManagerTest.php | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/Symfony/Component/Security/Tests/Core/Authorization/AccessDecisionManagerTest.php b/src/Symfony/Component/Security/Tests/Core/Authorization/AccessDecisionManagerTest.php index b99423f767ca8..0300cb42548b5 100644 --- a/src/Symfony/Component/Security/Tests/Core/Authorization/AccessDecisionManagerTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Authorization/AccessDecisionManagerTest.php @@ -65,6 +65,48 @@ public function testStrategies($strategy, $voters, $allowIfAllAbstainDecisions, $this->assertSame($expected, $manager->decide($token, array('ROLE_FOO'))); } + /** + * @dataProvider getStrategiesWith2RolesTests + */ + public function testStrategiesWith2Roles($token, $strategy, $voter, $expected) + { + $manager = new AccessDecisionManager(array($voter), $strategy); + + $this->assertSame($expected, $manager->decide($token, array('ROLE_FOO', 'ROLE_BAR'))); + } + + public function getStrategiesWith2RolesTests() + { + $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); + + return array( + array($token, 'affirmative', $this->getVoter(VoterInterface::ACCESS_DENIED), false), + array($token, 'affirmative', $this->getVoter(VoterInterface::ACCESS_GRANTED), true), + + array($token, 'consensus', $this->getVoter(VoterInterface::ACCESS_DENIED), false), + array($token, 'consensus', $this->getVoter(VoterInterface::ACCESS_GRANTED), true), + + array($token, 'unanimous', $this->getVoterFor2Roles($token, VoterInterface::ACCESS_DENIED, VoterInterface::ACCESS_DENIED), false), + array($token, 'unanimous', $this->getVoterFor2Roles($token, VoterInterface::ACCESS_DENIED, VoterInterface::ACCESS_GRANTED), false), + array($token, 'unanimous', $this->getVoterFor2Roles($token, VoterInterface::ACCESS_GRANTED, VoterInterface::ACCESS_DENIED), false), + array($token, 'unanimous', $this->getVoterFor2Roles($token, VoterInterface::ACCESS_GRANTED, VoterInterface::ACCESS_GRANTED), true), + ); + } + + protected function getVoterFor2Roles($token, $vote1, $vote2) + { + $voter = $this->getMock('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface'); + $voter->expects($this->exactly(2)) + ->method('vote') + ->will($this->returnValueMap(array( + array($token, null, array("ROLE_FOO"),$vote1), + array($token, null, array("ROLE_BAR"),$vote2), + ))) + ; + + return $voter; + } + public function getStrategyTests() { return array( From 59505714b3c32bce9ac421119a23e5f729f05af7 Mon Sep 17 00:00:00 2001 From: 1emming Date: Fri, 12 Sep 2014 11:07:07 +0200 Subject: [PATCH 1285/1305] [HttpFoundation] Request - URI - comment improvements --- src/Symfony/Component/HttpFoundation/Request.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index b27f9e8dad822..e65b62e5bbd65 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -1010,9 +1010,9 @@ public function getHttpHost() } /** - * Returns the requested URI. + * Returns the requested URI (path and query). * - * @return string The raw URI (i.e. not urldecoded) + * @return string The raw URI (i.e. not URI decoded) * * @api */ @@ -1039,9 +1039,9 @@ public function getSchemeAndHttpHost() } /** - * Generates a normalized URI for the Request. + * Generates a normalized URI (URL) for the Request. * - * @return string A normalized URI for the Request + * @return string A normalized URI (URL) for the Request * * @see getQueryString() * From 15aec880ab57bfd2d3501cc2bf7a99ad4b2b01bf Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 15 Sep 2014 20:08:07 +0200 Subject: [PATCH 1286/1305] fixed typo --- src/Symfony/Component/HttpFoundation/Request.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index e65b62e5bbd65..c6a784e1d0a3d 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -1010,7 +1010,7 @@ public function getHttpHost() } /** - * Returns the requested URI (path and query). + * Returns the requested URI (path and query string). * * @return string The raw URI (i.e. not URI decoded) * From e2ee13a2d93645537c3f5b439ec83cc718600fdc Mon Sep 17 00:00:00 2001 From: Luis Cordova Date: Tue, 2 Sep 2014 09:17:55 -0500 Subject: [PATCH 1287/1305] switch before_script to before_install and script to install --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c14543b5d3e6b..14c7704c4c7bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ matrix: services: mongodb -before_script: +before_install: - travis_retry sudo apt-get install parallel - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then echo "" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini; fi;' - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' @@ -22,9 +22,11 @@ before_script: - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;' - sudo locale-gen fr_FR.UTF-8 && sudo update-locale - - COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev install # - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "5.3.3" ]; then phpunit --self-update; fi;' +install: + - COMPOSER_ROOT_VERSION=dev-master composer --prefer-source install + script: - ls -d src/Symfony/*/* | parallel --gnu --keep-order 'echo "Running {} tests"; phpunit --exclude-group tty,benchmark {};' - echo "Running tests requiring tty"; phpunit --group tty From 908101413fb94f85111a24d881ca98be14dcc9fd Mon Sep 17 00:00:00 2001 From: Thierry Marianne Date: Sun, 7 Sep 2014 12:09:39 +0200 Subject: [PATCH 1288/1305] [Console] guarded against invalid aliases --- src/Symfony/Component/Console/Command/Command.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index ab0785ebe58ac..41f1bb3c89e10 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -494,11 +494,11 @@ public function getProcessedHelp() $placeholders = array( '%command.name%', - '%command.full_name%' + '%command.full_name%', ); $replacements = array( $name, - $_SERVER['PHP_SELF'].' '.$name + $_SERVER['PHP_SELF'].' '.$name, ); return str_replace($placeholders, $replacements, $this->getHelp()); @@ -507,7 +507,7 @@ public function getProcessedHelp() /** * Sets the aliases for the command. * - * @param array $aliases An array of aliases for the command + * @param string[] $aliases An array of aliases for the command * * @return Command The current instance * @@ -515,6 +515,10 @@ public function getProcessedHelp() */ public function setAliases($aliases) { + if (!is_array($aliases) && !$aliases instanceof \Traversable) { + throw new \InvalidArgumentException('$aliases must be an array or an instance of \Traversable'); + } + foreach ($aliases as $alias) { $this->validateName($alias); } From c3cce5c694b93d318231917d1d8c4469c52b2c1c Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Thu, 11 Sep 2014 18:57:52 +0200 Subject: [PATCH 1289/1305] [Intl] Improved bundle reader implementations --- .../Exception/MissingResourceException.php | 21 ++ .../ResourceBundleNotFoundException.php | 19 ++ src/Symfony/Component/Intl/Locale.php | 48 +++ .../Reader/AbstractBundleReader.php | 44 --- .../Reader/BinaryBundleReader.php | 25 +- .../ResourceBundle/Reader/PhpBundleReader.php | 22 +- .../Reader/StructuredBundleReader.php | 159 +++++++--- .../StructuredBundleReaderInterface.php | 7 +- .../Util/RecursiveArrayAccess.php | 22 +- .../Reader/AbstractBundleReaderTest.php | 64 ---- .../Reader/BinaryBundleReaderTest.php | 50 ++- .../ResourceBundle/Reader/Fixtures/build.sh | 17 ++ .../ResourceBundle/Reader/Fixtures/php/en.php | 14 + .../Reader/Fixtures/res/alias.res | Bin 0 -> 88 bytes .../ResourceBundle/Reader/Fixtures/res/mo.res | Bin 0 -> 92 bytes .../ResourceBundle/Reader/Fixtures/res/ro.res | Bin 0 -> 84 bytes .../Reader/Fixtures/res/ro_MD.res | Bin 0 -> 84 bytes .../Reader/Fixtures/res/root.res | Bin 0 -> 76 bytes .../Reader/Fixtures/txt/alias.txt | 3 + .../ResourceBundle/Reader/Fixtures/txt/mo.txt | 3 + .../ResourceBundle/Reader/Fixtures/txt/ro.txt | 3 + .../Reader/Fixtures/txt/ro_MD.txt | 3 + .../Reader/Fixtures/txt/root.txt | 6 + .../Reader/PhpBundleReaderTest.php | 12 +- .../Reader/StructuredBundleReaderTest.php | 284 +++++++++++++----- 25 files changed, 573 insertions(+), 253 deletions(-) create mode 100644 src/Symfony/Component/Intl/Exception/MissingResourceException.php create mode 100644 src/Symfony/Component/Intl/Exception/ResourceBundleNotFoundException.php create mode 100644 src/Symfony/Component/Intl/Locale.php delete mode 100644 src/Symfony/Component/Intl/ResourceBundle/Reader/AbstractBundleReader.php delete mode 100644 src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/AbstractBundleReaderTest.php create mode 100755 src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/build.sh create mode 100644 src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/php/en.php create mode 100644 src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/res/alias.res create mode 100644 src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/res/mo.res create mode 100644 src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/res/ro.res create mode 100644 src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/res/ro_MD.res create mode 100644 src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/res/root.res create mode 100644 src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/txt/alias.txt create mode 100644 src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/txt/mo.txt create mode 100644 src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/txt/ro.txt create mode 100644 src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/txt/ro_MD.txt create mode 100644 src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/txt/root.txt diff --git a/src/Symfony/Component/Intl/Exception/MissingResourceException.php b/src/Symfony/Component/Intl/Exception/MissingResourceException.php new file mode 100644 index 0000000000000..e2eb3f210e751 --- /dev/null +++ b/src/Symfony/Component/Intl/Exception/MissingResourceException.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Intl\Exception; + +/** + * Thrown when an invalid entry of a resource bundle was requested. + * + * @author Bernhard Schussek + */ +class MissingResourceException extends RuntimeException +{ +} diff --git a/src/Symfony/Component/Intl/Exception/ResourceBundleNotFoundException.php b/src/Symfony/Component/Intl/Exception/ResourceBundleNotFoundException.php new file mode 100644 index 0000000000000..59da5ec0d53d5 --- /dev/null +++ b/src/Symfony/Component/Intl/Exception/ResourceBundleNotFoundException.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Intl\Exception; + +/** + * @author Bernhard Schussek + */ +class ResourceBundleNotFoundException extends RuntimeException +{ +} diff --git a/src/Symfony/Component/Intl/Locale.php b/src/Symfony/Component/Intl/Locale.php new file mode 100644 index 0000000000000..d7e0d33e84070 --- /dev/null +++ b/src/Symfony/Component/Intl/Locale.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Intl; + +/** + * Provides access to locale-related data. + * + * @author Bernhard Schussek + * + * @internal + */ +final class Locale extends \Locale +{ + /** + * Returns the fallback locale for a given locale, if any + * + * @param string $locale The ICU locale code to find the fallback for. + * + * @return string|null The ICU locale code of the fallback locale, or null + * if no fallback exists + */ + public static function getFallback($locale) + { + if (false === $pos = strrpos($locale, '_')) { + if ('root' === $locale) { + return; + } + + return 'root'; + } + + return substr($locale, 0, $pos); + } + + /** + * This class must not be instantiated. + */ + private function __construct() {} +} diff --git a/src/Symfony/Component/Intl/ResourceBundle/Reader/AbstractBundleReader.php b/src/Symfony/Component/Intl/ResourceBundle/Reader/AbstractBundleReader.php deleted file mode 100644 index 02db55b4072c6..0000000000000 --- a/src/Symfony/Component/Intl/ResourceBundle/Reader/AbstractBundleReader.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\ResourceBundle\Reader; - -/** - * Base class for {@link BundleReaderInterface} implementations. - * - * @author Bernhard Schussek - * - * @internal - */ -abstract class AbstractBundleReader implements BundleReaderInterface -{ - /** - * {@inheritdoc} - */ - public function getLocales($path) - { - $extension = '.' . $this->getFileExtension(); - $locales = glob($path . '/*' . $extension); - - // Remove file extension and sort - array_walk($locales, function (&$locale) use ($extension) { $locale = basename($locale, $extension); }); - sort($locales); - - return $locales; - } - - /** - * Returns the extension of locale files in this bundle. - * - * @return string The file extension (without leading dot). - */ - abstract protected function getFileExtension(); -} diff --git a/src/Symfony/Component/Intl/ResourceBundle/Reader/BinaryBundleReader.php b/src/Symfony/Component/Intl/ResourceBundle/Reader/BinaryBundleReader.php index 75738dd8c8829..77b86aee42598 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Reader/BinaryBundleReader.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Reader/BinaryBundleReader.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Intl\ResourceBundle\Reader; -use Symfony\Component\Intl\Exception\RuntimeException; +use Symfony\Component\Intl\Exception\ResourceBundleNotFoundException; use Symfony\Component\Intl\ResourceBundle\Util\ArrayAccessibleResourceBundle; /** @@ -21,7 +21,7 @@ * * @internal */ -class BinaryBundleReader extends AbstractBundleReader implements BundleReaderInterface +class BinaryBundleReader implements BundleReaderInterface { /** * {@inheritdoc} @@ -31,28 +31,39 @@ public function read($path, $locale) // Point for future extension: Modify this class so that it works also // if the \ResourceBundle class is not available. try { - $bundle = new \ResourceBundle($locale, $path); + // Never enable fallback. We want to know if a bundle cannot be found + $bundle = new \ResourceBundle($locale, $path, false); } catch (\Exception $e) { // HHVM compatibility: constructor throws on invalid resource $bundle = null; } + // The bundle is NULL if the path does not look like a resource bundle + // (i.e. contain a bunch of *.res files) if (null === $bundle) { - throw new RuntimeException(sprintf( - 'Could not load the resource bundle "%s/%s.res".', + throw new ResourceBundleNotFoundException(sprintf( + 'The resource bundle "%s/%s.res" could not be found.', $path, $locale )); } + // Other possible errors are U_USING_FALLBACK_WARNING and U_ZERO_ERROR, + // which are OK for us. return new ArrayAccessibleResourceBundle($bundle); } /** * {@inheritdoc} */ - protected function getFileExtension() + public function getLocales($path) { - return 'res'; + $locales = glob($path.'/*.res'); + + // Remove file extension and sort + array_walk($locales, function (&$locale) { $locale = basename($locale, '.res'); }); + sort($locales); + + return $locales; } } diff --git a/src/Symfony/Component/Intl/ResourceBundle/Reader/PhpBundleReader.php b/src/Symfony/Component/Intl/ResourceBundle/Reader/PhpBundleReader.php index 01dd00be51640..2082916827bd0 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Reader/PhpBundleReader.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Reader/PhpBundleReader.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Intl\ResourceBundle\Reader; -use Symfony\Component\Intl\Exception\InvalidArgumentException; +use Symfony\Component\Intl\Exception\ResourceBundleNotFoundException; use Symfony\Component\Intl\Exception\RuntimeException; /** @@ -21,21 +21,17 @@ * * @internal */ -class PhpBundleReader extends AbstractBundleReader implements BundleReaderInterface +class PhpBundleReader implements BundleReaderInterface { /** * {@inheritdoc} */ public function read($path, $locale) { - if ('en' !== $locale) { - throw new InvalidArgumentException('Only the locale "en" is supported.'); - } - - $fileName = $path . '/' . $locale . '.php'; + $fileName = $path.'/'.$locale.'.php'; if (!file_exists($fileName)) { - throw new RuntimeException(sprintf( + throw new ResourceBundleNotFoundException(sprintf( 'The resource bundle "%s/%s.php" does not exist.', $path, $locale @@ -56,8 +52,14 @@ public function read($path, $locale) /** * {@inheritdoc} */ - protected function getFileExtension() + public function getLocales($path) { - return 'php'; + $locales = glob($path.'/*.php'); + + // Remove file extension and sort + array_walk($locales, function (&$locale) { $locale = basename($locale, '.php'); }); + sort($locales); + + return $locales; } } diff --git a/src/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReader.php b/src/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReader.php index 689510bdd75f1..01ec26190a349 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReader.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReader.php @@ -11,10 +11,14 @@ namespace Symfony\Component\Intl\ResourceBundle\Reader; +use Symfony\Component\Intl\Exception\MissingResourceException; +use Symfony\Component\Intl\Exception\OutOfBoundsException; +use Symfony\Component\Intl\Exception\ResourceBundleNotFoundException; +use Symfony\Component\Intl\Locale; use Symfony\Component\Intl\ResourceBundle\Util\RecursiveArrayAccess; /** - * A structured reader wrapping an existing resource bundle reader. + * Default implementation of {@link StructuredBundleReaderInterface}. * * @author Bernhard Schussek * @@ -29,6 +33,13 @@ class StructuredBundleReader implements StructuredBundleReaderInterface */ private $reader; + /** + * A mapping of locale aliases to locales + * + * @var array + */ + private $localeAliases = array(); + /** * Creates an entry reader based on the given resource bundle reader. * @@ -40,19 +51,26 @@ public function __construct(BundleReaderInterface $reader) } /** - * {@inheritdoc} + * Stores a mapping of locale aliases to locales. + * + * This mapping is used when reading entries and merging them with their + * fallback locales. If an entry is read for a locale alias (e.g. "mo") + * that points to a locale with a fallback locale ("ro_MD"), the reader + * can continue at the correct fallback locale ("ro"). + * + * @param array $localeAliases A mapping of locale aliases to locales */ - public function read($path, $locale) + public function setLocaleAliases($localeAliases) { - return $this->reader->read($path, $locale); + $this->localeAliases = $localeAliases; } /** * {@inheritdoc} */ - public function getLocales($path) + public function read($path, $locale) { - return $this->reader->getLocales($path); + return $this->reader->read($path, $locale); } /** @@ -60,56 +78,115 @@ public function getLocales($path) */ public function readEntry($path, $locale, array $indices, $fallback = true) { - $data = $this->reader->read($path, $locale); + $entry = null; + $isMultiValued = false; + $readSucceeded = false; + $exception = null; + $currentLocale = $locale; + $testedLocales = array(); + + while (null !== $currentLocale) { + // Resolve any aliases to their target locales + if (isset($this->localeAliases[$currentLocale])) { + $currentLocale = $this->localeAliases[$currentLocale]; + } - $entry = RecursiveArrayAccess::get($data, $indices); - $multivalued = is_array($entry) || $entry instanceof \Traversable; + try { + $data = $this->reader->read($path, $currentLocale); + $currentEntry = RecursiveArrayAccess::get($data, $indices); + $readSucceeded = true; - if (!($fallback && (null === $entry || $multivalued))) { - return $entry; - } + $isCurrentTraversable = $currentEntry instanceof \Traversable; + $isCurrentMultiValued = $isCurrentTraversable || is_array($currentEntry); - if (null !== ($fallbackLocale = $this->getFallbackLocale($locale))) { - $parentEntry = $this->readEntry($path, $fallbackLocale, $indices, true); + // Return immediately if fallback is disabled or we are dealing + // with a scalar non-null entry + if (!$fallback || (!$isCurrentMultiValued && null !== $currentEntry)) { + return $currentEntry; + } - if ($entry || $parentEntry) { - $multivalued = $multivalued || is_array($parentEntry) || $parentEntry instanceof \Traversable; + // ========================================================= + // Fallback is enabled, entry is either multi-valued or NULL + // ========================================================= - if ($multivalued) { - if ($entry instanceof \Traversable) { - $entry = iterator_to_array($entry); - } + // If entry is multi-valued, convert to array + if ($isCurrentTraversable) { + $currentEntry = iterator_to_array($currentEntry); + } - if ($parentEntry instanceof \Traversable) { - $parentEntry = iterator_to_array($parentEntry); - } + // If previously read entry was multi-valued too, merge them + if ($isCurrentMultiValued && $isMultiValued) { + $currentEntry = array_merge($currentEntry, $entry); + } - $entry = array_merge( - $parentEntry ?: array(), - $entry ?: array() - ); - } else { - $entry = null === $entry ? $parentEntry : $entry; + // Keep the previous entry if the current entry is NULL + if (null !== $currentEntry) { + $entry = $currentEntry; } + + // If this or the previous entry was multi-valued, we are dealing + // with a merged, multi-valued entry now + $isMultiValued = $isMultiValued || $isCurrentMultiValued; + } catch (ResourceBundleNotFoundException $e) { + // Continue if there is a fallback locale for the current + // locale + $exception = $e; + } catch (OutOfBoundsException $e) { + // Remember exception and rethrow if we cannot find anything in + // the fallback locales either + $exception = $e; } + + // Remember which locales we tried + $testedLocales[] = $currentLocale.'.res'; + + // Check whether fallback is allowed + if (!$fallback) { + break; + } + + // Then determine fallback locale + $currentLocale = Locale::getFallback($currentLocale); + } + + // Multi-valued entry was merged + if ($isMultiValued) { + return $entry; + } + + // Entry is still NULL, but no read error occurred + if ($readSucceeded) { + return $entry; } - return $entry; + // Entry is still NULL, read error occurred. Throw an exception + // containing the detailed path and locale + $errorMessage = sprintf( + 'Couldn\'t read the indices [%s] from "%s/%s.res".', + implode('][', $indices), + $path, + $locale + ); + + // Append fallback locales, if any + if (count($testedLocales) > 1) { + // Remove original locale + array_shift($testedLocales); + + $errorMessage .= sprintf( + ' The indices also couldn\'t be found in the fallback locale(s) "%s".', + implode('", "', $testedLocales) + ); + } + + throw new MissingResourceException($errorMessage, 0, $exception); } /** - * Returns the fallback locale for a given locale, if any - * - * @param string $locale The locale to find the fallback for. - * - * @return string|null The fallback locale, or null if no parent exists + * {@inheritdoc} */ - private function getFallbackLocale($locale) + public function getLocales($path) { - if (false === $pos = strrpos($locale, '_')) { - return; - } - - return substr($locale, 0, $pos); + return $this->reader->getLocales($path); } } diff --git a/src/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReaderInterface.php b/src/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReaderInterface.php index 408ee67ee03ef..19bb3fb49bdd2 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReaderInterface.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Reader/StructuredBundleReaderInterface.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Intl\ResourceBundle\Reader; +use Symfony\Component\Intl\Exception\MissingResourceException; + /** * Reads individual entries of a resource file. * @@ -45,8 +47,9 @@ interface StructuredBundleReaderInterface extends BundleReaderInterface * in the requested locale. * * @return mixed Returns an array or {@link \ArrayAccess} instance for - * complex data, a scalar value for simple data and NULL - * if the given path could not be accessed. + * complex data and a scalar value for simple data. + * + * @throws MissingResourceException If the indices cannot be accessed */ public function readEntry($path, $locale, array $indices, $fallback = true); } diff --git a/src/Symfony/Component/Intl/ResourceBundle/Util/RecursiveArrayAccess.php b/src/Symfony/Component/Intl/ResourceBundle/Util/RecursiveArrayAccess.php index 6e46790c6f75d..0c22550401cb2 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Util/RecursiveArrayAccess.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Util/RecursiveArrayAccess.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Intl\ResourceBundle\Util; +use Symfony\Component\Intl\Exception\OutOfBoundsException; + /** * @author Bernhard Schussek * @@ -21,11 +23,23 @@ class RecursiveArrayAccess public static function get($array, array $indices) { foreach ($indices as $index) { - if (!$array instanceof \ArrayAccess && !is_array($array)) { - return; + // Use array_key_exists() for arrays, isset() otherwise + if (is_array($array)) { + if (array_key_exists($index, $array)) { + $array = $array[$index]; + continue; + } + } elseif ($array instanceof \ArrayAccess) { + if (isset($array[$index])) { + $array = $array[$index]; + continue; + } } - - $array = $array[$index]; + + throw new OutOfBoundsException(sprintf( + 'The index %s does not exist.', + $index + )); } return $array; diff --git a/src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/AbstractBundleReaderTest.php b/src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/AbstractBundleReaderTest.php deleted file mode 100644 index 2da7f90de49e3..0000000000000 --- a/src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/AbstractBundleReaderTest.php +++ /dev/null @@ -1,64 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Tests\ResourceBundle\Reader; - -use Symfony\Component\Filesystem\Filesystem; - -/** - * @author Bernhard Schussek - */ -class AbstractBundleReaderTest extends \PHPUnit_Framework_TestCase -{ - private $directory; - - /** - * @var Filesystem - */ - private $filesystem; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $reader; - - protected function setUp() - { - $this->directory = sys_get_temp_dir() . '/AbstractBundleReaderTest/' . rand(1000, 9999); - $this->filesystem = new Filesystem(); - $this->reader = $this->getMockForAbstractClass('Symfony\Component\Intl\ResourceBundle\Reader\AbstractBundleReader'); - - $this->filesystem->mkdir($this->directory); - } - - protected function tearDown() - { - $this->filesystem->remove($this->directory); - } - - public function testGetLocales() - { - $this->filesystem->touch($this->directory . '/en.foo'); - $this->filesystem->touch($this->directory . '/de.foo'); - $this->filesystem->touch($this->directory . '/fr.foo'); - $this->filesystem->touch($this->directory . '/bo.txt'); - $this->filesystem->touch($this->directory . '/gu.bin'); - $this->filesystem->touch($this->directory . '/s.lol'); - - $this->reader->expects($this->any()) - ->method('getFileExtension') - ->will($this->returnValue('foo')); - - $sortedLocales = array('de', 'en', 'fr'); - - $this->assertSame($sortedLocales, $this->reader->getLocales($this->directory)); - } -} diff --git a/src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/BinaryBundleReaderTest.php b/src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/BinaryBundleReaderTest.php index 3aefbae7fd911..526424d1a3d19 100644 --- a/src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/BinaryBundleReaderTest.php +++ b/src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/BinaryBundleReaderTest.php @@ -33,19 +33,61 @@ protected function setUp() public function testReadReturnsArrayAccess() { - $data = $this->reader->read(__DIR__ . '/Fixtures', 'en'); + $data = $this->reader->read(__DIR__.'/Fixtures/res', 'ro'); $this->assertInstanceOf('\ArrayAccess', $data); $this->assertSame('Bar', $data['Foo']); $this->assertFalse(isset($data['ExistsNot'])); } + public function testReadFollowsAlias() + { + // "alias" = "ro" + $data = $this->reader->read(__DIR__.'/Fixtures/res', 'alias'); + + $this->assertInstanceOf('\ArrayAccess', $data); + $this->assertSame('Bar', $data['Foo']); + $this->assertFalse(isset($data['ExistsNot'])); + } + + public function testReadDoesNotFollowFallback() + { + // "ro_MD" -> "ro" + $data = $this->reader->read(__DIR__.'/Fixtures/res', 'ro_MD'); + + $this->assertInstanceOf('\ArrayAccess', $data); + $this->assertSame('Bam', $data['Baz']); + $this->assertFalse(isset($data['Foo'])); + $this->assertNull($data['Foo']); + $this->assertFalse(isset($data['ExistsNot'])); + } + + public function testReadDoesNotFollowFallbackAlias() + { + // "mo" = "ro_MD" -> "ro" + $data = $this->reader->read(__DIR__.'/Fixtures/res', 'mo'); + + $this->assertInstanceOf('\ArrayAccess', $data); + $this->assertSame('Bam', $data['Baz'], 'data from the aliased locale can be accessed'); + $this->assertFalse(isset($data['Foo'])); + $this->assertNull($data['Foo']); + $this->assertFalse(isset($data['ExistsNot'])); + } + /** - * @expectedException \Symfony\Component\Intl\Exception\RuntimeException + * @expectedException \Symfony\Component\Intl\Exception\ResourceBundleNotFoundException */ public function testReadFailsIfNonExistingLocale() { - $this->reader->read(__DIR__ . '/Fixtures', 'foo'); + $this->reader->read(__DIR__.'/Fixtures/res', 'foo'); + } + + /** + * @expectedException \Symfony\Component\Intl\Exception\ResourceBundleNotFoundException + */ + public function testReadFailsIfNonExistingFallbackLocale() + { + $this->reader->read(__DIR__.'/Fixtures/res', 'ro_AT'); } /** @@ -53,6 +95,6 @@ public function testReadFailsIfNonExistingLocale() */ public function testReadFailsIfNonExistingDirectory() { - $this->reader->read(__DIR__ . '/foo', 'en'); + $this->reader->read(__DIR__.'/foo', 'ro'); } } diff --git a/src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/build.sh b/src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/build.sh new file mode 100755 index 0000000000000..50513e7a946c3 --- /dev/null +++ b/src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/build.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +if [ -z "$ICU_BUILD_DIR" ]; then + echo "Please set the ICU_BUILD_DIR environment variable" + exit +fi + +if [ ! -d "$ICU_BUILD_DIR" ]; then + echo "The directory $ICU_BUILD_DIR pointed at by ICU_BUILD_DIR does not exist" + exit +fi + +DIR=`dirname $0` + +rm $DIR/res/*.res + +LD_LIBRARY_PATH=$ICU_BUILD_DIR/lib $ICU_BUILD_DIR/bin/genrb -d $DIR/res $DIR/txt/*.txt diff --git a/src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/php/en.php b/src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/php/en.php new file mode 100644 index 0000000000000..f2b06a91ad32e --- /dev/null +++ b/src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/php/en.php @@ -0,0 +1,14 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +return array( + 'Foo' => 'Bar', +); diff --git a/src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/res/alias.res b/src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/res/alias.res new file mode 100644 index 0000000000000000000000000000000000000000..4f0ab7eaa316685f0bf153446f37aeb0221fdd10 GIT binary patch literal 88 zcmY#jxTP+_00K-5L8-+~Oh6VR3s?Y50GR>oKo%De^Fc8qSO&sZRdw|7bPNWH6fxuj MNk#?*AYQc!03g)|MgRZ+ literal 0 HcmV?d00001 diff --git a/src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/res/mo.res b/src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/Fixtures/res/mo.res new file mode 100644 index 0000000000000000000000000000000000000000..3f8911a7317ed2f6e19b291c131ca68bb7f7cad1 GIT binary patch literal 92 zcmY#jxTP+_00K-5L8-+~Oh6VR3s?Y5urn|O05Jm>5c5MZBUlE)S5reader->read(__DIR__ . '/Fixtures', 'en'); + $data = $this->reader->read(__DIR__.'/Fixtures/php', 'en'); $this->assertTrue(is_array($data)); $this->assertSame('Bar', $data['Foo']); @@ -38,11 +38,11 @@ public function testReadReturnsArray() } /** - * @expectedException \Symfony\Component\Intl\Exception\InvalidArgumentException + * @expectedException \Symfony\Component\Intl\Exception\ResourceBundleNotFoundException */ - public function testReadFailsIfLocaleOtherThanEn() + public function testReadFailsIfNonExistingLocale() { - $this->reader->read(__DIR__ . '/Fixtures', 'foo'); + $this->reader->read(__DIR__.'/Fixtures/php', 'foo'); } /** @@ -50,7 +50,7 @@ public function testReadFailsIfLocaleOtherThanEn() */ public function testReadFailsIfNonExistingDirectory() { - $this->reader->read(__DIR__ . '/foo', 'en'); + $this->reader->read(__DIR__.'/foo', 'en'); } /** @@ -58,6 +58,6 @@ public function testReadFailsIfNonExistingDirectory() */ public function testReadFailsIfNotAFile() { - $this->reader->read(__DIR__ . '/Fixtures/NotAFile', 'en'); + $this->reader->read(__DIR__.'/Fixtures/NotAFile', 'en'); } } diff --git a/src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/StructuredBundleReaderTest.php b/src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/StructuredBundleReaderTest.php index 600236eb3ec56..e51e7ef2eeeeb 100644 --- a/src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/StructuredBundleReaderTest.php +++ b/src/Symfony/Component/Intl/Tests/ResourceBundle/Reader/StructuredBundleReaderTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Intl\Tests\ResourceBundle\Reader; +use Symfony\Component\Intl\Exception\ResourceBundleNotFoundException; use Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReader; /** @@ -30,73 +31,146 @@ class StructuredBundleReaderTest extends \PHPUnit_Framework_TestCase */ private $readerImpl; + private static $data = array( + 'Entries' => array( + 'Foo' => 'Bar', + 'Bar' => 'Baz', + ), + 'Foo' => 'Bar', + 'Version' => '2.0', + ); + + private static $fallbackData = array( + 'Entries' => array( + 'Foo' => 'Foo', + 'Bam' => 'Lah', + ), + 'Baz' => 'Foo', + 'Version' => '1.0', + ); + + private static $mergedData = array( + // no recursive merging -> too complicated + 'Entries' => array( + 'Foo' => 'Bar', + 'Bar' => 'Baz', + ), + 'Baz' => 'Foo', + 'Version' => '2.0', + 'Foo' => 'Bar', + ); + protected function setUp() { $this->readerImpl = $this->getMock('Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReaderInterface'); $this->reader = new StructuredBundleReader($this->readerImpl); } - public function testGetLocales() + public function testForwardCallToRead() { - $locales = array('en', 'de', 'fr'); - $this->readerImpl->expects($this->once()) - ->method('getLocales') - ->with(self::RES_DIR) - ->will($this->returnValue($locales)); + ->method('read') + ->with(self::RES_DIR, 'root') + ->will($this->returnValue(self::$data)); - $this->assertSame($locales, $this->reader->getLocales(self::RES_DIR)); + $this->assertSame(self::$data, $this->reader->read(self::RES_DIR, 'root')); } - public function testRead() + public function testReadEntireDataFileIfNoIndicesGiven() { - $data = array('foo', 'bar'); - - $this->readerImpl->expects($this->once()) + $this->readerImpl->expects($this->at(0)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue($data)); + ->will($this->returnValue(self::$data)); - $this->assertSame($data, $this->reader->read(self::RES_DIR, 'en')); + $this->readerImpl->expects($this->at(1)) + ->method('read') + ->with(self::RES_DIR, 'root') + ->will($this->returnValue(self::$fallbackData)); + + $this->assertSame(self::$mergedData, $this->reader->readEntry(self::RES_DIR, 'en', array())); } - public function testReadEntryNoParams() + public function testReadExistingEntry() { - $data = array('foo', 'bar'); + $this->readerImpl->expects($this->once()) + ->method('read') + ->with(self::RES_DIR, 'root') + ->will($this->returnValue(self::$data)); + $this->assertSame('Bar', $this->reader->readEntry(self::RES_DIR, 'root', array('Entries', 'Foo'))); + } + + /** + * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException + */ + public function testReadNonExistingEntry() + { $this->readerImpl->expects($this->once()) ->method('read') - ->with(self::RES_DIR, 'en') - ->will($this->returnValue($data)); + ->with(self::RES_DIR, 'root') + ->will($this->returnValue(self::$data)); - $this->assertSame($data, $this->reader->readEntry(self::RES_DIR, 'en', array())); + $this->reader->readEntry(self::RES_DIR, 'root', array('Entries', 'NonExisting')); } - public function testReadEntryWithParam() + public function testFallbackIfEntryDoesNotExist() { - $data = array('Foo' => array('Bar' => 'Baz')); + $this->readerImpl->expects($this->at(0)) + ->method('read') + ->with(self::RES_DIR, 'en_GB') + ->will($this->returnValue(self::$data)); - $this->readerImpl->expects($this->once()) + $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue($data)); + ->will($this->returnValue(self::$fallbackData)); - $this->assertSame('Baz', $this->reader->readEntry(self::RES_DIR, 'en', array('Foo', 'Bar'))); + $this->assertSame('Lah', $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Entries', 'Bam'))); } - public function testReadEntryWithUnresolvablePath() + /** + * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException + */ + public function testDontFallbackIfEntryDoesNotExistAndFallbackDisabled() { - $data = array('Foo' => 'Baz'); - $this->readerImpl->expects($this->once()) + ->method('read') + ->with(self::RES_DIR, 'en_GB') + ->will($this->returnValue(self::$data)); + + $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Entries', 'Bam'), false); + } + + public function testFallbackIfLocaleDoesNotExist() + { + $this->readerImpl->expects($this->at(0)) + ->method('read') + ->with(self::RES_DIR, 'en_GB') + ->will($this->throwException(new ResourceBundleNotFoundException())); + + $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue($data)); + ->will($this->returnValue(self::$fallbackData)); + + $this->assertSame('Lah', $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Entries', 'Bam'))); + } + + /** + * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException + */ + public function testDontFallbackIfLocaleDoesNotExistAndFallbackDisabled() + { + $this->readerImpl->expects($this->once()) + ->method('read') + ->with(self::RES_DIR, 'en_GB') + ->will($this->throwException(new ResourceBundleNotFoundException())); - $this->assertNull($this->reader->readEntry(self::RES_DIR, 'en', array('Foo', 'Bar'))); + $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Entries', 'Bam'), false); } - public function readMergedEntryProvider() + public function provideMergeableValues() { return array( array('foo', null, 'foo'), @@ -110,46 +184,72 @@ public function readMergedEntryProvider() } /** - * @dataProvider readMergedEntryProvider + * @dataProvider provideMergeableValues */ - public function testReadMergedEntryNoParams($childData, $parentData, $result) + public function testMergeDataWithFallbackData($childData, $parentData, $result) { - $this->readerImpl->expects($this->at(0)) - ->method('read') - ->with(self::RES_DIR, 'en_GB') - ->will($this->returnValue($childData)); - if (null === $childData || is_array($childData)) { - $this->readerImpl->expects($this->at(1)) + $this->readerImpl->expects($this->at(0)) ->method('read') ->with(self::RES_DIR, 'en') + ->will($this->returnValue($childData)); + + $this->readerImpl->expects($this->at(1)) + ->method('read') + ->with(self::RES_DIR, 'root') ->will($this->returnValue($parentData)); + } else { + $this->readerImpl->expects($this->once()) + ->method('read') + ->with(self::RES_DIR, 'en') + ->will($this->returnValue($childData)); } - $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', array(), true)); + $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en', array(), true)); } /** - * @dataProvider readMergedEntryProvider + * @dataProvider provideMergeableValues */ - public function testReadMergedEntryWithParams($childData, $parentData, $result) + public function testDontMergeDataIfFallbackDisabled($childData, $parentData, $result) { - $this->readerImpl->expects($this->at(0)) + $this->readerImpl->expects($this->once()) ->method('read') ->with(self::RES_DIR, 'en_GB') - ->will($this->returnValue(array('Foo' => array('Bar' => $childData)))); + ->will($this->returnValue($childData)); + $this->assertSame($childData, $this->reader->readEntry(self::RES_DIR, 'en_GB', array(), false)); + } + + /** + * @dataProvider provideMergeableValues + */ + public function testMergeExistingEntryWithExistingFallbackEntry($childData, $parentData, $result) + { if (null === $childData || is_array($childData)) { - $this->readerImpl->expects($this->at(1)) + $this->readerImpl->expects($this->at(0)) ->method('read') ->with(self::RES_DIR, 'en') + ->will($this->returnValue(array('Foo' => array('Bar' => $childData)))); + + $this->readerImpl->expects($this->at(1)) + ->method('read') + ->with(self::RES_DIR, 'root') ->will($this->returnValue(array('Foo' => array('Bar' => $parentData)))); + } else { + $this->readerImpl->expects($this->once()) + ->method('read') + ->with(self::RES_DIR, 'en') + ->will($this->returnValue(array('Foo' => array('Bar' => $childData)))); } - $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true)); + $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en', array('Foo', 'Bar'), true)); } - public function testReadMergedEntryWithUnresolvablePath() + /** + * @dataProvider provideMergeableValues + */ + public function testMergeNonExistingEntryWithExistingFallbackEntry($childData, $parentData, $result) { $this->readerImpl->expects($this->at(0)) ->method('read') @@ -159,29 +259,40 @@ public function testReadMergedEntryWithUnresolvablePath() $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue(array('Foo' => 'Bar'))); + ->will($this->returnValue(array('Foo' => array('Bar' => $parentData)))); - $this->assertNull($this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true)); + $this->assertSame($parentData, $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true)); } - public function testReadMergedEntryWithUnresolvablePathInParent() + /** + * @dataProvider provideMergeableValues + */ + public function testMergeExistingEntryWithNonExistingFallbackEntry($childData, $parentData, $result) { - $this->readerImpl->expects($this->at(0)) - ->method('read') - ->with(self::RES_DIR, 'en_GB') - ->will($this->returnValue(array('Foo' => array('Bar' => array('three'))))); - - $this->readerImpl->expects($this->at(1)) - ->method('read') - ->with(self::RES_DIR, 'en') - ->will($this->returnValue(array('Foo' => 'Bar'))); + if (null === $childData || is_array($childData)) { + $this->readerImpl->expects($this->at(0)) + ->method('read') + ->with(self::RES_DIR, 'en_GB') + ->will($this->returnValue(array('Foo' => array('Bar' => $childData)))); - $result = array('three'); + $this->readerImpl->expects($this->at(1)) + ->method('read') + ->with(self::RES_DIR, 'en') + ->will($this->returnValue(array('Foo' => 'Bar'))); + } else { + $this->readerImpl->expects($this->once()) + ->method('read') + ->with(self::RES_DIR, 'en_GB') + ->will($this->returnValue(array('Foo' => array('Bar' => $childData)))); + } - $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true)); + $this->assertSame($childData, $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true)); } - public function testReadMergedEntryWithUnresolvablePathInChild() + /** + * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException + */ + public function testFailIfEntryFoundNeitherInParentNorChild() { $this->readerImpl->expects($this->at(0)) ->method('read') @@ -191,33 +302,64 @@ public function testReadMergedEntryWithUnresolvablePathInChild() $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'en') - ->will($this->returnValue(array('Foo' => array('Bar' => array('one', 'two'))))); - - $result = array('one', 'two'); + ->will($this->returnValue(array('Foo' => 'Bar'))); - $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true)); + $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true); } /** - * @dataProvider readMergedEntryProvider + * @dataProvider provideMergeableValues */ - public function testReadMergedEntryWithTraversables($childData, $parentData, $result) + public function testMergeTraversables($childData, $parentData, $result) { $parentData = is_array($parentData) ? new \ArrayObject($parentData) : $parentData; $childData = is_array($childData) ? new \ArrayObject($childData) : $childData; - $this->readerImpl->expects($this->at(0)) - ->method('read') - ->with(self::RES_DIR, 'en_GB') - ->will($this->returnValue(array('Foo' => array('Bar' => $childData)))); - if (null === $childData || $childData instanceof \ArrayObject) { + $this->readerImpl->expects($this->at(0)) + ->method('read') + ->with(self::RES_DIR, 'en_GB') + ->will($this->returnValue(array('Foo' => array('Bar' => $childData)))); + $this->readerImpl->expects($this->at(1)) ->method('read') ->with(self::RES_DIR, 'en') ->will($this->returnValue(array('Foo' => array('Bar' => $parentData)))); + } else { + $this->readerImpl->expects($this->once()) + ->method('read') + ->with(self::RES_DIR, 'en_GB') + ->will($this->returnValue(array('Foo' => array('Bar' => $childData)))); } $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'en_GB', array('Foo', 'Bar'), true)); } + + /** + * @dataProvider provideMergeableValues + */ + public function testFollowLocaleAliases($childData, $parentData, $result) + { + $this->reader->setLocaleAliases(array('mo' => 'ro_MD')); + + if (null === $childData || is_array($childData)) { + $this->readerImpl->expects($this->at(0)) + ->method('read') + ->with(self::RES_DIR, 'ro_MD') + ->will($this->returnValue(array('Foo' => array('Bar' => $childData)))); + + // Read fallback locale of aliased locale ("ro_MD" -> "ro") + $this->readerImpl->expects($this->at(1)) + ->method('read') + ->with(self::RES_DIR, 'ro') + ->will($this->returnValue(array('Foo' => array('Bar' => $parentData)))); + } else { + $this->readerImpl->expects($this->once()) + ->method('read') + ->with(self::RES_DIR, 'ro_MD') + ->will($this->returnValue(array('Foo' => array('Bar' => $childData)))); + } + + $this->assertSame($result, $this->reader->readEntry(self::RES_DIR, 'mo', array('Foo', 'Bar'), true)); + } } From 4fd0cf39277afed57ed2b1f6c659ff6cf4d38f9e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 16 Sep 2014 07:12:27 +0200 Subject: [PATCH 1290/1305] fixed CS --- src/Symfony/Component/Translation/Dumper/XliffFileDumper.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Symfony/Component/Translation/Dumper/XliffFileDumper.php b/src/Symfony/Component/Translation/Dumper/XliffFileDumper.php index f192e4c7b56cb..9b3237fda16e0 100644 --- a/src/Symfony/Component/Translation/Dumper/XliffFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/XliffFileDumper.php @@ -48,9 +48,7 @@ protected function format(MessageCatalogue $messages, $domain) $s->appendChild($dom->createTextNode($source)); // Does the target contain characters requiring a CDATA section? - $text = (1 === preg_match('/[&<>]/', $target)) - ? $dom->createCDATASection($target) - : $dom->createTextNode($target); + $text = 1 === preg_match('/[&<>]/', $target) ? $dom->createCDATASection($target) : $dom->createTextNode($target); $t = $translation->appendChild($dom->createElement('target')); $t->appendChild($text); From c207d1dde2e8ab0eeb6b84469eb6e4881447309e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Ro=C3=9Fkamp?= Date: Tue, 16 Sep 2014 11:11:47 +0200 Subject: [PATCH 1291/1305] [Form] Fix PHPDoc for builder setData methods The underlying data variable is typed as mixed whereas the methods paramers where typed as array. --- src/Symfony/Component/Form/ButtonBuilder.php | 2 +- src/Symfony/Component/Form/FormConfigBuilderInterface.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Form/ButtonBuilder.php b/src/Symfony/Component/Form/ButtonBuilder.php index b02f8f5fe1070..bbddd9cfa2122 100644 --- a/src/Symfony/Component/Form/ButtonBuilder.php +++ b/src/Symfony/Component/Form/ButtonBuilder.php @@ -425,7 +425,7 @@ public function setType(ResolvedFormTypeInterface $type) * * This method should not be invoked. * - * @param array $data + * @param mixed $data * * @throws BadMethodCallException */ diff --git a/src/Symfony/Component/Form/FormConfigBuilderInterface.php b/src/Symfony/Component/Form/FormConfigBuilderInterface.php index da2da0b66895d..50793a2c49c07 100644 --- a/src/Symfony/Component/Form/FormConfigBuilderInterface.php +++ b/src/Symfony/Component/Form/FormConfigBuilderInterface.php @@ -212,7 +212,7 @@ public function setType(ResolvedFormTypeInterface $type); /** * Sets the initial data of the form. * - * @param array $data The data of the form in application format. + * @param mixed $data The data of the form in application format. * * @return self The configuration object. */ From ca65362b9be2839782557c6246c6b062d3bd654f Mon Sep 17 00:00:00 2001 From: thewilkybarkid Date: Tue, 16 Sep 2014 19:36:21 +0100 Subject: [PATCH 1292/1305] Make sure HttpCache is a trusted proxy --- .../HttpKernel/HttpCache/HttpCache.php | 6 +++++ .../Tests/HttpCache/HttpCacheTest.php | 22 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index 871b3a87fc900..4463db27b9a94 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -462,6 +462,12 @@ protected function forward(Request $request, $catch = false, Response $entry = n // is always called from the same process as the backend. $request->server->set('REMOTE_ADDR', '127.0.0.1'); + // make sure HttpCache is a trusted proxy + if (!in_array('127.0.0.1', $trustedProxies = Request::getTrustedProxies())) { + $trustedProxies[] = '127.0.0.1'; + Request::setTrustedProxies($trustedProxies); + } + // always a "master" request (as the real master request can be in cache) $response = $this->kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, $catch); // FIXME: we probably need to also catch exceptions if raw === true diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php index 71cdd37aa7d05..5b950ea3e7188 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php @@ -1155,6 +1155,28 @@ public function testClientIpIsAlwaysLocalhostForForwardedRequests() $this->assertEquals('127.0.0.1', $this->kernel->getBackendRequest()->server->get('REMOTE_ADDR')); } + /** + * @dataProvider getTrustedProxyData + */ + public function testHttpCacheIsSetAsATrustedProxy(array $existing, array $expected) + { + Request::setTrustedProxies($existing); + + $this->setNextResponse(); + $this->request('GET', '/', array('REMOTE_ADDR' => '10.0.0.1')); + + $this->assertEquals($expected, Request::getTrustedProxies()); + } + + public function getTrustedProxyData() + { + return array( + array(array(), array('127.0.0.1')), + array(array('10.0.0.2'), array('10.0.0.2', '127.0.0.1')), + array(array('10.0.0.2', '127.0.0.1'), array('10.0.0.2', '127.0.0.1')), + ); + } + /** * @dataProvider getXForwardedForData */ From e1eb788d2f7008a1773c428bfdc8ad0fdec202bf Mon Sep 17 00:00:00 2001 From: nervo Date: Wed, 3 Sep 2014 13:18:43 +0200 Subject: [PATCH 1293/1305] Use getPathname() instead of string casting to get BinaryFileReponse file path --- .../Component/HttpFoundation/BinaryFileResponse.php | 6 +++++- .../HttpFoundation/Tests/BinaryFileResponseTest.php | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index 88e2abefad2c0..99985779e8627 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -84,7 +84,11 @@ public static function create($file = null, $status = 200, $headers = array(), $ public function setFile($file, $contentDisposition = null, $autoEtag = false, $autoLastModified = true) { if (!$file instanceof File) { - $file = new File((string) $file); + if ($file instanceof \SplFileInfo) { + $file = new File($file->getPathname()); + } else { + $file = new File((string) $file); + } } if (!$file->isReadable()) { diff --git a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php index 397192b8853aa..74344f76b711c 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php @@ -193,6 +193,16 @@ public function testXAccelMapping($realpath, $mapping, $virtual) $this->assertEquals($virtual, $response->headers->get('X-Accel-Redirect')); } + public function testSplFileObject() + { + $filePath = __DIR__.'/File/Fixtures/test'; + $file = new \SplFileObject($filePath); + + $response = new BinaryFileResponse($file); + + $this->assertEquals(realpath($response->getFile()->getPathname()), realpath($filePath)); + } + public function getSampleXAccelMappings() { return array( From 6020c43191c3bb2781f52caf15f9218b8ffb62fb Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 20 Sep 2014 09:51:42 +0200 Subject: [PATCH 1294/1305] [HttpFoundation] fixed some volatile tests --- .../Component/HttpFoundation/Tests/ResponseTest.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index c94ace9af9775..f16cb4930a59e 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -132,8 +132,9 @@ public function testIsValidateable() public function testGetDate() { - $response = new Response('', 200, array('Date' => $this->createDateTimeOneHourAgo()->format(DATE_RFC2822))); - $this->assertEquals(0, $this->createDateTimeOneHourAgo()->diff($response->getDate())->format('%s'), '->getDate() returns the Date header if present'); + $oneHourAgo = $this->createDateTimeOneHourAgo(); + $response = new Response('', 200, array('Date' => $oneHourAgo->format(DATE_RFC2822))); + $this->assertEquals(0, $oneHourAgo->diff($response->getDate())->format('%s'), '->getDate() returns the Date header if present'); $response = new Response(); $date = $response->getDate(); @@ -142,7 +143,7 @@ public function testGetDate() $response = new Response('', 200, array('Date' => $this->createDateTimeOneHourAgo()->format(DATE_RFC2822))); $now = $this->createDateTimeNow(); $response->headers->set('Date', $now->format(DATE_RFC2822)); - $this->assertEquals(0, $now->diff($response->getDate())->format('%s'), '->getDate() returns the date when the header has been modified'); + $this->assertLessThanOrEqual(1, $now->diff($response->getDate())->format('%s'), '->getDate() returns the date when the header has been modified'); $response = new Response('', 200); $response->headers->remove('Date'); @@ -162,7 +163,7 @@ public function testGetMaxAge() $response = new Response(); $response->headers->set('Cache-Control', 'must-revalidate'); $response->headers->set('Expires', $this->createDateTimeOneHourLater()->format(DATE_RFC2822)); - $this->assertEquals(3600, $response->getMaxAge(), '->getMaxAge() falls back to Expires when no max-age or s-maxage directive present'); + $this->assertLessThanOrEqual(1, $response->getMaxAge() - 3600, '->getMaxAge() falls back to Expires when no max-age or s-maxage directive present'); $response = new Response(); $response->headers->set('Cache-Control', 'must-revalidate'); @@ -233,7 +234,7 @@ public function testGetTtl() $response = new Response(); $response->headers->set('Expires', $this->createDateTimeOneHourLater()->format(DATE_RFC2822)); - $this->assertLessThan(1, 3600 - $response->getTtl(), '->getTtl() uses the Expires header when no max-age is present'); + $this->assertLessThanOrEqual(1, 3600 - $response->getTtl(), '->getTtl() uses the Expires header when no max-age is present'); $response = new Response(); $response->headers->set('Expires', $this->createDateTimeOneHourAgo()->format(DATE_RFC2822)); From 974bf01eb398481856e2147bb54b303badaaac74 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 20 Sep 2014 09:56:12 +0200 Subject: [PATCH 1295/1305] [HttpKernel] fixed a volatile test --- .../Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php index 71cdd37aa7d05..8f54239c696dd 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php @@ -606,7 +606,7 @@ public function testAssignsDefaultTtlWhenResponseHasNoFreshnessInformationAndAft $this->assertTraceContains('miss'); $this->assertTraceContains('store'); $this->assertEquals('Hello World', $this->response->getContent()); - $this->assertRegExp('/s-maxage=2/', $this->response->headers->get('Cache-Control')); + $this->assertRegExp('/s-maxage=(?:2|3)/', $this->response->headers->get('Cache-Control')); $this->request('GET', '/'); $this->assertHttpKernelIsNotCalled(); From 00c1b759cd7eb9f8780f8cd1ab42dba4548439ab Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 20 Sep 2014 10:00:00 +0200 Subject: [PATCH 1296/1305] [Process] fixed some volatile tests --- src/Symfony/Component/Process/Tests/AbstractProcessTest.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index 6341d3c6d82a1..b78c4777bed46 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -77,9 +77,8 @@ public function testStopWithTimeoutIsActuallyWorking() while ($p->isRunning()) { usleep(1000); } - $duration = microtime(true) - $start; - $this->assertLessThan(1.8, $duration); + $this->assertLessThan(4, microtime(true) - $start); } public function testAllOutputIsActuallyReadOnTermination() @@ -396,7 +395,7 @@ public function testStartIsNonBlocking() $start = microtime(true); $process->start(); $end = microtime(true); - $this->assertLessThan(0.2, $end-$start); + $this->assertLessThan(1, $end - $start); $process->wait(); } From 369aebf431d0b007d06d206a782ebfeba79c136e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 21 Sep 2014 20:53:12 +0200 Subject: [PATCH 1297/1305] fixed CS --- .../AbstractDoctrineExtension.php | 10 +-- .../Form/ChoiceList/EntityChoiceList.php | 2 +- .../Doctrine/Form/Type/DoctrineType.php | 6 +- .../HttpFoundation/DbalSessionHandler.php | 10 +-- .../RememberMe/DoctrineTokenProvider.php | 16 ++--- .../Security/User/EntityUserProvider.php | 2 +- .../DoctrineDataCollectorTest.php | 10 +-- .../GenericEntityChoiceListTest.php | 6 +- .../Tests/Form/DoctrineOrmTypeGuesserTest.php | 5 +- .../Form/Type/EntityTypePerformanceTest.php | 2 +- .../Tests/Form/Type/EntityTypeTest.php | 8 +-- .../Doctrine/Tests/Logger/DbalLoggerTest.php | 1 - .../Constraints/UniqueEntityValidator.php | 4 +- .../Monolog/Handler/ChromePhpHandler.php | 1 - .../Bridge/Monolog/Handler/FirePHPHandler.php | 1 - .../Tests/Processor/WebProcessorTest.php | 2 +- .../TranslationCollectionFormListener.php | 1 - .../EventListener/TranslationFormListener.php | 2 +- .../Bridge/Propel1/Form/PropelExtension.php | 2 +- .../Form/Type/TranslationCollectionType.php | 6 +- .../Propel1/Form/Type/TranslationType.php | 2 +- .../DataCollector/PropelDataCollectorTest.php | 18 ++--- .../Propel1/Tests/Fixtures/ItemQuery.php | 2 +- .../Tests/Fixtures/TranslatableItemI18n.php | 3 - .../Form/ChoiceList/ModelChoiceListTest.php | 8 +-- .../CollectionToArrayTransformerTest.php | 4 +- .../Type/TranslationCollectionTypeTest.php | 30 ++++---- .../Tests/LazyProxy/ContainerBuilderTest.php | 2 +- .../LazyProxy/Fixtures/php/lazy_service.php | 2 - .../LazyProxy/PhpDumper/ProxyDumperTest.php | 12 ++-- .../Bridge/Twig/Node/FormThemeNode.php | 1 - .../Bridge/Twig/Node/RenderBlockNode.php | 2 +- .../Tests/Extension/CodeExtensionTest.php | 2 +- .../Extension/FormExtensionDivLayoutTest.php | 4 +- .../Extension/TranslationExtensionTest.php | 12 ++-- .../Bridge/Twig/Tests/Node/FormThemeTest.php | 4 +- .../TokenParser/FormThemeTokenParserTest.php | 14 ++-- .../Command/ConfigDumpReferenceCommand.php | 2 +- .../Command/ContainerDebugCommand.php | 2 +- .../Command/TranslationUpdateCommand.php | 2 +- .../EventListener/SessionListener.php | 1 - .../Bundle/FrameworkBundle/Routing/Router.php | 4 +- .../Tests/CacheWarmer/TemplateFinderTest.php | 1 - .../Controller/RedirectControllerTest.php | 2 +- .../Compiler/AddCacheWarmerPassTest.php | 4 +- .../Compiler/SerializerPassTest.php | 9 ++- .../Compiler/TranslatorPassTest.php | 2 - .../DependencyInjection/ConfigurationTest.php | 14 ++-- .../Fixtures/TestBundle/TestBundle.php | 1 - .../DependencyInjection/Fixtures/php/full.php | 4 +- .../FrameworkExtensionTest.php | 6 +- .../Controller/SessionController.php | 2 +- .../Tests/Routing/RouterTest.php | 2 +- .../Helper/FormHelperDivLayoutTest.php | 4 +- .../Tests/Translation/TranslatorTest.php | 1 - .../Translation/PhpStringTokenParser.php | 2 +- .../DependencyInjection/MainConfiguration.php | 10 +-- .../Security/Factory/RememberMeFactory.php | 2 +- .../DependencyInjection/SecurityExtension.php | 2 +- .../Fixtures/php/custom_acl_provider.php | 2 +- .../Fixtures/php/merge.php | 2 +- .../Fixtures/php/merge_import.php | 4 +- .../SecurityExtensionTest.php | 10 +-- .../DependencyInjection/TwigExtension.php | 2 +- .../DependencyInjection/Fixtures/php/full.php | 2 +- .../TokenParser/RenderTokenParserTest.php | 4 +- .../Controller/ProfilerController.php | 2 +- .../Tests/Command/ExportCommandTest.php | 1 - .../Tests/Command/ImportCommandTest.php | 1 - .../Tests/Profiler/TemplateManagerTest.php | 6 +- .../Component/BrowserKit/Tests/ClientTest.php | 4 +- .../BrowserKit/Tests/ResponseTest.php | 8 +-- .../ClassLoader/ClassMapGenerator.php | 1 - .../Tests/ApcUniversalClassLoaderTest.php | 32 ++++----- .../Tests/ClassMapGeneratorTest.php | 2 +- .../Tests/Fixtures/ClassesWithParents/A.php | 4 +- .../Tests/Fixtures/ClassesWithParents/B.php | 4 +- .../Tests/Fixtures/classmap/SomeClass.php | 1 - .../Tests/Fixtures/classmap/SomeInterface.php | 1 - .../Tests/Fixtures/classmap/SomeParent.php | 1 - .../Tests/Fixtures/classmap/multipleNs.php | 20 ++++-- .../classmap/sameNsMultipleClasses.php | 8 ++- .../Tests/Fixtures/deps/traits.php | 3 +- .../Tests/Fixtures/php5.4/traits.php | 3 +- .../ClassLoader/UniversalClassLoader.php | 1 - src/Symfony/Component/Config/ConfigCache.php | 1 - .../Builder/BooleanNodeDefinition.php | 1 - .../Config/Definition/Builder/NodeBuilder.php | 1 - .../Definition/Builder/NodeDefinition.php | 1 - .../Builder/VariableNodeDefinition.php | 1 - .../Config/Definition/PrototypedArrayNode.php | 2 +- .../Config/Definition/ReferenceDumper.php | 2 +- .../Config/Loader/LoaderInterface.php | 1 - .../Config/Tests/Definition/ArrayNodeTest.php | 2 +- .../Builder/ArrayNodeDefinitionTest.php | 2 +- .../Definition/Builder/ExprBuilderTest.php | 14 ++-- .../Config/Tests/Definition/FloatNodeTest.php | 2 +- .../Config/Tests/Definition/MergeTest.php | 12 ++-- .../Tests/Definition/NormalizationTest.php | 4 +- .../Tests/Definition/ReferenceDumperTest.php | 2 +- .../Tests/Resource/DirectoryResourceTest.php | 4 +- src/Symfony/Component/Console/Application.php | 2 +- .../Formatter/OutputFormatterStyle.php | 6 +- .../Component/Console/Helper/DialogHelper.php | 3 +- .../Component/Console/Input/ArgvInput.php | 4 +- .../Component/Console/Input/ArrayInput.php | 2 +- .../Console/Tests/ApplicationTest.php | 4 +- .../Console/Tests/Command/CommandTest.php | 2 +- .../Console/Tests/Command/ListCommandTest.php | 1 - .../Console/Tests/Helper/DialogHelperTest.php | 2 +- .../Tests/Helper/FormatterHelperTest.php | 18 ++--- .../Tests/Helper/ProgressHelperTest.php | 10 +-- .../Console/Tests/Input/ArgvInputTest.php | 50 +++++++------- .../Console/Tests/Input/ArrayInputTest.php | 20 +++--- .../Console/Tests/Input/InputArgumentTest.php | 2 +- .../Console/Tests/Input/InputOptionTest.php | 2 +- .../Component/CssSelector/Parser/Parser.php | 2 +- .../Parser/Shortcut/ClassParser.php | 2 +- .../Parser/Shortcut/HashParser.php | 2 +- .../Parser/Tokenizer/TokenizerEscaping.php | 4 +- .../Tests/Exception/FlattenExceptionTest.php | 25 ++++--- .../DependencyInjection/Dumper/PhpDumper.php | 6 +- .../IntrospectableContainerInterface.php | 1 - .../Tests/ContainerBuilderTest.php | 8 ++- .../Tests/ContainerTest.php | 1 - .../Tests/Dumper/PhpDumperTest.php | 2 +- .../Tests/Extension/ExtensionTest.php | 2 +- .../DomCrawler/FormFieldRegistry.php | 16 ++--- .../Tests/Field/FileFormFieldTest.php | 1 - .../Component/DomCrawler/Tests/FormTest.php | 38 +++++------ .../Tests/EventDispatcherTest.php | 2 +- .../Tests/GenericEventTest.php | 1 - .../Exception/ExceptionInterface.php | 1 - .../Filesystem/Exception/IOException.php | 1 - .../Filesystem/Tests/FilesystemTest.php | 20 +++--- .../Finder/Adapter/AbstractFindAdapter.php | 2 +- .../Finder/Adapter/GnuFindAdapter.php | 2 +- .../Finder/Comparator/DateComparator.php | 1 - .../Component/Finder/Expression/Regex.php | 2 +- src/Symfony/Component/Finder/Finder.php | 3 +- .../Iterator/FilenameFilterIterator.php | 1 - .../Finder/Iterator/PathFilterIterator.php | 1 - .../Tests/Comparator/DateComparatorTest.php | 1 - .../Tests/Comparator/NumberComparatorTest.php | 4 +- .../Component/Finder/Tests/FinderTest.php | 12 ++-- .../Iterator/DepthRangeFilterIteratorTest.php | 1 - .../ExcludeDirectoryFilterIteratorTest.php | 5 +- .../Tests/Iterator/FilePathsIteratorTest.php | 6 +- .../Iterator/FileTypeFilterIteratorTest.php | 2 +- .../FilecontentFilterIteratorTest.php | 9 ++- .../Tests/Iterator/PathFilterIteratorTest.php | 2 - .../Tests/Iterator/RealIteratorTestCase.php | 4 +- .../Iterator/SizeRangeFilterIteratorTest.php | 2 +- .../Tests/Iterator/SortableIteratorTest.php | 7 +- .../Core/DataMapper/PropertyPathMapper.php | 1 - .../BooleanToStringTransformer.php | 1 - .../DateTimeToStringTransformer.php | 20 +++--- .../MoneyToLocalizedStringTransformer.php | 1 - .../Form/Extension/Core/Type/ChoiceType.php | 2 +- .../Form/Extension/Core/Type/DateType.php | 2 +- .../Form/Extension/Core/Type/TimeType.php | 2 +- .../Templating/TemplatingExtension.php | 2 +- .../Extension/Validator/Util/ServerParams.php | 1 - .../Validator/ValidatorTypeGuesser.php | 2 +- src/Symfony/Component/Form/Form.php | 16 ++--- .../Component/Form/FormConfigBuilder.php | 2 +- .../Component/Form/NativeRequestHandler.php | 2 +- .../Form/Tests/AbstractDivLayoutTest.php | 6 +- .../Form/Tests/AbstractLayoutTest.php | 26 +++---- .../Form/Tests/AbstractTableLayoutTest.php | 6 +- .../Form/Tests/CallbackTransformerTest.php | 8 +-- .../Component/Form/Tests/CompoundFormTest.php | 2 +- .../Core/ChoiceList/ChoiceListTest.php | 10 +-- .../Core/ChoiceList/ObjectChoiceListTest.php | 6 +- .../Core/ChoiceList/SimpleChoiceListTest.php | 4 +- .../DateTimeToRfc3339TransformerTest.php | 2 +- ...NumberToLocalizedStringTransformerTest.php | 1 - .../ValueToDuplicatesTransformerTest.php | 3 +- .../Extension/Core/Type/ChoiceTypeTest.php | 4 +- .../Extension/Core/Type/CurrencyTypeTest.php | 1 - .../Extension/Core/Type/DateTimeTypeTest.php | 5 +- .../Extension/Core/Type/DateTypeTest.php | 6 +- .../Extension/Core/Type/FormTypeTest.php | 10 +-- .../Extension/Core/Type/RepeatedTypeTest.php | 4 +- .../Extension/Core/Type/TimeTypeTest.php | 8 +-- .../EventListener/BindRequestListenerTest.php | 2 +- .../Constraints/FormValidatorTest.php | 8 +-- .../Validator/ValidatorTypeGuesserTest.php | 2 +- .../Component/Form/Tests/Guess/GuessTest.php | 4 +- .../Form/Tests/NativeRequestHandlerTest.php | 2 +- .../Component/Form/Tests/SimpleFormTest.php | 2 +- src/Symfony/Component/Form/Util/FormUtil.php | 4 +- .../Component/Form/Util/OrderedHashMap.php | 2 +- .../HttpFoundation/File/UploadedFile.php | 2 +- .../Component/HttpFoundation/FileBag.php | 2 +- .../Component/HttpFoundation/IpUtils.php | 6 +- .../Component/HttpFoundation/ParameterBag.php | 2 +- .../Component/HttpFoundation/Request.php | 2 +- .../Component/HttpFoundation/Response.php | 4 +- .../HttpFoundation/Session/Flash/FlashBag.php | 2 +- .../Storage/Handler/MongoDbSessionHandler.php | 2 +- .../Storage/Handler/NativeSessionHandler.php | 8 ++- .../Storage/Handler/PdoSessionHandler.php | 10 +-- .../Tests/AcceptHeaderItemTest.php | 12 ++-- .../Tests/ApacheRequestTest.php | 2 +- .../Tests/BinaryFileResponseTest.php | 8 +-- .../HttpFoundation/Tests/FileBagTest.php | 18 ++--- .../HttpFoundation/Tests/ParameterBagTest.php | 5 +- .../Tests/RequestMatcherTest.php | 2 +- .../HttpFoundation/Tests/RequestTest.php | 40 +++++------ .../Tests/ResponseHeaderBagTest.php | 16 ++--- .../HttpFoundation/Tests/ResponseTest.php | 2 +- .../HttpFoundation/Tests/ServerBagTest.php | 8 +-- .../Session/Attribute/AttributeBagTest.php | 2 +- .../Attribute/NamespacedAttributeBagTest.php | 2 +- .../Tests/Session/Flash/FlashBagTest.php | 2 +- .../Handler/MongoDbSessionHandlerTest.php | 3 +- .../Tests/Session/Storage/MetadataBagTest.php | 1 - .../Storage/Proxy/AbstractProxyTest.php | 3 +- .../DataCollector/ConfigDataCollector.php | 2 +- .../DataCollector/LoggerDataCollector.php | 2 +- .../Debug/TraceableEventDispatcher.php | 8 ++- .../HttpKernel/HttpCache/HttpCache.php | 1 - src/Symfony/Component/HttpKernel/Kernel.php | 1 - .../Profiler/BaseMemcacheProfilerStorage.php | 5 +- .../Profiler/FileProfilerStorage.php | 2 +- .../Profiler/MemcacheProfilerStorage.php | 1 - .../Profiler/MongoDbProfilerStorage.php | 2 +- .../Profiler/RedisProfilerStorage.php | 1 - .../HttpKernel/Tests/Bundle/BundleTest.php | 1 - .../Component/HttpKernel/Tests/ClientTest.php | 2 +- .../ExceptionDataCollectorTest.php | 1 - .../DataCollector/LoggerDataCollectorTest.php | 10 +-- .../RequestDataCollectorTest.php | 13 ++-- .../Debug/TraceableEventDispatcherTest.php | 14 ++-- .../RegisterListenersPassTest.php | 4 +- .../EventListener/ExceptionListenerTest.php | 2 +- .../EventListener/ResponseListenerTest.php | 1 - .../Command/BarCommand.php | 1 - .../Command/FooCommand.php | 1 - .../Tests/Fixtures/KernelForOverrideName.php | 2 - .../Fragment/RoutableFragmentRendererTest.php | 8 ++- .../Component/HttpKernel/Tests/KernelTest.php | 6 +- .../Tests/Profiler/Mock/RedisMock.php | 1 - .../Profiler/MongoDbProfilerStorageTest.php | 10 +-- .../DateFormat/AmPmTransformer.php | 2 +- .../DateFormat/FullTransformer.php | 2 +- .../DateFormat/Hour1200Transformer.php | 2 +- .../DateFormat/Hour1201Transformer.php | 2 +- .../DateFormat/Hour2400Transformer.php | 2 +- .../DateFormat/Hour2401Transformer.php | 2 +- .../DateFormat/MonthTransformer.php | 2 +- .../DateFormat/TimeZoneTransformer.php | 2 +- src/Symfony/Component/Intl/Intl.php | 4 +- src/Symfony/Component/Intl/Locale.php | 4 +- .../Intl/NumberFormatter/NumberFormatter.php | 14 ++-- .../Compiler/BundleCompiler.php | 4 +- .../Reader/BufferedBundleReader.php | 2 +- .../Transformer/BundleTransformer.php | 8 +-- .../Rule/CurrencyBundleTransformationRule.php | 10 +-- .../Rule/LanguageBundleTransformationRule.php | 4 +- .../Rule/LocaleBundleTransformationRule.php | 14 ++-- .../Rule/RegionBundleTransformationRule.php | 4 +- .../Util/RecursiveArrayAccess.php | 6 +- .../Writer/TextBundleWriter.php | 2 +- .../Component/Intl/Resources/bin/autoload.php | 2 +- .../Resources/bin/copy-stubs-to-component.php | 8 +-- .../Intl/Resources/bin/create-stubs.php | 12 ++-- .../Intl/Resources/bin/icu-version.php | 6 +- .../Intl/Resources/bin/test-compat.php | 16 ++--- .../Resources/bin/update-icu-component.php | 42 ++++++------ .../Resources/bin/util/test-compat-helper.php | 12 ++-- .../Intl/Resources/stubs/functions.php | 2 - .../AbstractIntlDateFormatterTest.php | 3 +- .../DateFormatter/IntlDateFormatterTest.php | 2 +- .../Intl/Tests/Locale/LocaleTest.php | 4 +- .../AbstractNumberFormatterTest.php | 14 ++-- .../Writer/PhpBundleWriterTest.php | 4 +- .../Writer/TextBundleWriterTest.php | 2 +- .../Component/Intl/Util/IcuVersion.php | 4 +- .../Component/Intl/Util/IntlTestHelper.php | 12 ++-- .../Component/Intl/Util/SvnRepository.php | 6 +- src/Symfony/Component/Intl/Util/Version.php | 8 ++- .../Component/Locale/Stub/StubLocale.php | 2 +- .../Tests/OptionsResolverTest.php | 6 +- .../OptionsResolver/Tests/OptionsTest.php | 3 +- src/Symfony/Component/Process/Process.php | 2 +- .../Process/Tests/AbstractProcessTest.php | 11 ++- .../Process/Tests/NonStopableProcess.php | 4 +- .../PipeStdinInStdoutStdErrStreamSelect.php | 20 +++--- .../Process/Tests/SignalListener.php | 4 +- .../PropertyAccess/PropertyAccessor.php | 26 +++---- .../PropertyAccess/PropertyPathBuilder.php | 2 +- .../Component/PropertyAccess/StringUtil.php | 4 +- .../Tests/PropertyAccessorCollectionTest.php | 56 +++++++++++---- .../Tests/PropertyAccessorTest.php | 1 - .../Tests/PropertyPathBuilderTest.php | 2 +- .../PropertyAccess/Tests/StringUtilTest.php | 4 +- .../Component/Routing/CompiledRoute.php | 1 - .../Matcher/Dumper/ApacheMatcherDumper.php | 1 - .../Matcher/Dumper/DumperPrefixCollection.php | 1 - .../Matcher/Dumper/PhpMatcherDumper.php | 1 - .../Routing/Tests/Annotation/RouteTest.php | 2 +- .../Routing/Tests/Fixtures/validpattern.php | 2 +- .../Tests/Generator/UrlGeneratorTest.php | 68 +++++++++---------- .../Loader/AnnotationClassLoaderTest.php | 6 +- .../Tests/Matcher/ApacheUrlMatcherTest.php | 4 +- .../Matcher/Dumper/PhpMatcherDumperTest.php | 2 +- .../Routing/Tests/Matcher/UrlMatcherTest.php | 6 +- .../Routing/Tests/RouteCompilerTest.php | 32 ++++----- .../Component/Routing/Tests/RouteTest.php | 2 +- .../Component/Routing/Tests/RouterTest.php | 10 ++- .../Security/Acl/Dbal/AclProvider.php | 8 +-- .../Security/Acl/Dbal/MutableAclProvider.php | 21 +++--- .../Component/Security/Acl/Domain/Acl.php | 22 +++--- .../Security/Acl/Permission/MaskBuilder.php | 2 +- .../Component/Security/Acl/Voter/AclVoter.php | 4 +- ...PreAuthenticatedAuthenticationProvider.php | 16 ++--- .../Authentication/Token/AbstractToken.php | 2 +- .../Security/Core/Util/ClassUtils.php | 4 +- .../Security/Core/Util/StringUtils.php | 4 +- .../DefaultAuthenticationFailureHandler.php | 4 +- .../TokenBasedRememberMeServices.php | 2 +- .../Acl/Dbal/AclProviderBenchmarkTest.php | 8 +-- .../Tests/Acl/Dbal/MutableAclProviderTest.php | 11 +-- .../Security/Tests/Acl/Domain/AclTest.php | 4 +- .../Tests/Acl/Domain/AuditLoggerTest.php | 2 +- .../Domain/PermissionGrantingStrategyTest.php | 3 +- .../SecurityIdentityRetrievalStrategyTest.php | 2 +- .../Token/AbstractTokenTest.php | 14 ++-- .../AccessDecisionManagerTest.php | 5 +- .../Authorization/Voter/RoleVoterTest.php | 1 - .../Tests/Core/Encoder/EncoderFactoryTest.php | 20 ++++-- ...efaultAuthenticationSuccessHandlerTest.php | 2 +- .../RetryAuthenticationEntryPointTest.php | 10 +-- .../AbstractPreAuthenticatedListenerTest.php | 10 +-- .../BasicAuthenticationListenerTest.php | 6 +- .../Http/Firewall/ContextListenerTest.php | 2 +- .../Tests/Http/Firewall/DigestDataTest.php | 50 +++++++------- .../X509AuthenticationListenerTest.php | 2 +- .../Security/Tests/Http/FirewallTest.php | 2 +- .../Security/Tests/Http/HttpUtilsTest.php | 2 +- .../AbstractRememberMeServicesTest.php | 2 +- ...istentTokenBasedRememberMeServicesTest.php | 3 +- .../Http/RememberMe/ResponseListenerTest.php | 2 +- .../Serializer/Encoder/JsonDecode.php | 2 +- .../Serializer/Encoder/JsonEncode.php | 2 +- .../Serializer/Encoder/XmlEncoder.php | 1 - .../Tests/Encoder/XmlEncoderTest.php | 24 +++---- .../Tests/Fixtures/DenormalizableDummy.php | 3 - .../Normalizer/GetSetMethodNormalizerTest.php | 2 +- src/Symfony/Component/Stopwatch/Stopwatch.php | 1 - .../Stopwatch/Tests/StopwatchTest.php | 2 +- .../Translation/Dumper/PoFileDumper.php | 4 +- .../Translation/Dumper/YamlFileDumper.php | 2 +- .../Translation/Loader/ArrayLoader.php | 2 +- .../Translation/Loader/CsvFileLoader.php | 2 +- .../Translation/Loader/PoFileLoader.php | 3 +- .../Tests/Catalogue/DiffOperationTest.php | 2 +- .../Tests/Catalogue/MergeOperationTest.php | 2 +- .../Tests/Dumper/IcuResFileDumperTest.php | 2 +- .../Tests/PluralizationRulesTest.php | 7 +- .../Translation/Tests/TranslatorTest.php | 7 +- .../AbstractComparisonValidator.php | 2 +- .../Validator/Constraints/BlankValidator.php | 2 +- .../Constraints/CardSchemeValidator.php | 18 ++--- .../Validator/Constraints/ChoiceValidator.php | 6 +- .../Constraints/CollectionValidator.php | 4 +- .../Validator/Constraints/FileValidator.php | 4 +- .../Validator/Constraints/ImageValidator.php | 8 +-- .../Validator/Constraints/IsbnValidator.php | 3 +- .../Validator/Constraints/IssnValidator.php | 3 +- .../Validator/Mapping/ClassMetadata.php | 2 +- .../Validator/Tests/ConstraintTest.php | 2 +- .../AbstractComparisonValidatorTestCase.php | 2 +- .../AbstractConstraintValidatorTest.php | 2 +- .../Tests/Constraints/BlankValidatorTest.php | 2 +- .../Constraints/CallbackValidatorTest.php | 2 +- .../Tests/Constraints/ChoiceValidatorTest.php | 6 +- .../Constraints/CollectionValidatorTest.php | 14 ++-- .../Tests/Constraints/CountValidatorTest.php | 6 +- .../Constraints/CountryValidatorTest.php | 2 +- .../Constraints/CurrencyValidatorTest.php | 2 +- .../Constraints/DateTimeValidatorTest.php | 2 +- .../Tests/Constraints/DateValidatorTest.php | 2 +- .../Tests/Constraints/EmailValidatorTest.php | 2 +- .../Tests/Constraints/FalseValidatorTest.php | 4 +- .../Tests/Constraints/FileValidatorTest.php | 3 +- .../GreaterThanOrEqualValidatorTest.php | 2 +- .../Constraints/GreaterThanValidatorTest.php | 2 +- .../Tests/Constraints/IbanValidatorTest.php | 5 +- .../Tests/Constraints/ImageValidatorTest.php | 1 - .../Tests/Constraints/IpValidatorTest.php | 1 - .../Tests/Constraints/IsbnValidatorTest.php | 5 +- .../Tests/Constraints/IssnValidatorTest.php | 4 +- .../Constraints/LanguageValidatorTest.php | 4 +- .../Tests/Constraints/LengthValidatorTest.php | 7 +- .../LessThanOrEqualValidatorTest.php | 2 +- .../Tests/Constraints/LocaleValidatorTest.php | 2 +- .../Tests/Constraints/LuhnValidatorTest.php | 1 - .../Constraints/NotBlankValidatorTest.php | 9 ++- .../Constraints/NotNullValidatorTest.php | 3 +- .../Tests/Constraints/NullValidatorTest.php | 3 +- .../Tests/Constraints/RangeValidatorTest.php | 1 - .../Tests/Constraints/RegexValidatorTest.php | 5 +- .../Tests/Constraints/TimeValidatorTest.php | 3 +- .../Tests/Constraints/TrueValidatorTest.php | 3 +- .../Tests/Constraints/TypeValidatorTest.php | 3 +- .../Tests/Constraints/UrlValidatorTest.php | 4 +- .../Validator/Tests/ExecutionContextTest.php | 2 +- .../Fixtures/StubGlobalExecutionContext.php | 2 +- .../Tests/Mapping/ElementMetadataTest.php | 4 +- .../Validator/Tests/ValidationVisitorTest.php | 2 +- src/Symfony/Component/Validator/Validator.php | 3 +- src/Symfony/Component/Yaml/Escaper.php | 4 +- src/Symfony/Component/Yaml/Parser.php | 9 ++- .../Component/Yaml/Tests/DumperTest.php | 8 +-- .../Component/Yaml/Tests/InlineTest.php | 4 +- .../Component/Yaml/Tests/ParserTest.php | 6 +- src/Symfony/Component/Yaml/Unescaper.php | 6 +- 420 files changed, 1167 insertions(+), 1185 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php index 95decc6f31a1d..a11acfc45b833 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php @@ -207,11 +207,11 @@ protected function registerMappingDrivers($objectManager, ContainerBuilder $cont } elseif ($driverType == 'annotation') { $mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), array( new Reference($this->getObjectManagerElementName('metadata.annotation_reader')), - array_values($driverPaths) + array_values($driverPaths), )); } else { $mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), array( - array_values($driverPaths) + array_values($driverPaths), )); } $mappingDriverDef->setPublic(false); @@ -320,7 +320,7 @@ protected function loadObjectManagerCacheDriver(array $objectManager, ContainerB $cacheDef = new Definition($memcacheClass); $memcacheInstance = new Definition($memcacheInstanceClass); $memcacheInstance->addMethodCall('connect', array( - $memcacheHost, $memcachePort + $memcacheHost, $memcachePort, )); $container->setDefinition($this->getObjectManagerElementName(sprintf('%s_memcache_instance', $objectManager['name'])), $memcacheInstance); $cacheDef->addMethodCall('setMemcache', array(new Reference($this->getObjectManagerElementName(sprintf('%s_memcache_instance', $objectManager['name']))))); @@ -333,7 +333,7 @@ protected function loadObjectManagerCacheDriver(array $objectManager, ContainerB $cacheDef = new Definition($memcachedClass); $memcachedInstance = new Definition($memcachedInstanceClass); $memcachedInstance->addMethodCall('addServer', array( - $memcachedHost, $memcachedPort + $memcachedHost, $memcachedPort, )); $container->setDefinition($this->getObjectManagerElementName(sprintf('%s_memcached_instance', $objectManager['name'])), $memcachedInstance); $cacheDef->addMethodCall('setMemcached', array(new Reference($this->getObjectManagerElementName(sprintf('%s_memcached_instance', $objectManager['name']))))); @@ -346,7 +346,7 @@ protected function loadObjectManagerCacheDriver(array $objectManager, ContainerB $cacheDef = new Definition($redisClass); $redisInstance = new Definition($redisInstanceClass); $redisInstance->addMethodCall('connect', array( - $redisHost, $redisPort + $redisHost, $redisPort, )); $container->setDefinition($this->getObjectManagerElementName(sprintf('%s_redis_instance', $objectManager['name'])), $redisInstance); $cacheDef->addMethodCall('setRedis', array(new Reference($this->getObjectManagerElementName(sprintf('%s_redis_instance', $objectManager['name']))))); diff --git a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php index cc8ac9891a35d..ce9dce875f233 100644 --- a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php +++ b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php @@ -452,7 +452,7 @@ private function getIdentifierValues($entity) { if (!$this->em->contains($entity)) { throw new RuntimeException( - 'Entities passed to the choice field must be managed. Maybe ' . + 'Entities passed to the choice field must be managed. Maybe '. 'persist them in the entity manager?' ); } diff --git a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php index 83ce96f0fa9d8..7a027df1e73bd 100644 --- a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php +++ b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php @@ -60,7 +60,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) public function setDefaultOptions(OptionsResolverInterface $resolver) { - $choiceListCache =& $this->choiceListCache; + $choiceListCache = & $this->choiceListCache; $registry = $this->registry; $propertyAccessor = $this->propertyAccessor; $type = $this; @@ -121,7 +121,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver) $loaderHash, $choiceHashes, $preferredChoiceHashes, - $groupByHash + $groupByHash, ))); if (!isset($choiceListCache[$hash])) { @@ -150,7 +150,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver) if (null === $em) { throw new RuntimeException(sprintf( - 'Class "%s" seems not to be a managed Doctrine entity. ' . + 'Class "%s" seems not to be a managed Doctrine entity. '. 'Did you forget to map it?', $options['class'] )); diff --git a/src/Symfony/Bridge/Doctrine/HttpFoundation/DbalSessionHandler.php b/src/Symfony/Bridge/Doctrine/HttpFoundation/DbalSessionHandler.php index d0c0577becb07..88260a527041d 100644 --- a/src/Symfony/Bridge/Doctrine/HttpFoundation/DbalSessionHandler.php +++ b/src/Symfony/Bridge/Doctrine/HttpFoundation/DbalSessionHandler.php @@ -218,18 +218,18 @@ private function getMergeSql() switch ($platform) { case 'mysql': - return "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) " . + return "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". "ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->timeCol = VALUES($this->timeCol)"; case 'oracle': // DUAL is Oracle specific dummy table - return "MERGE INTO $this->table USING DUAL ON ($this->idCol = :id) " . - "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) " . + return "MERGE INTO $this->table USING DUAL ON ($this->idCol = :id) ". + "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". "WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->timeCol = :time"; case $this->con->getDatabasePlatform() instanceof SQLServer2008Platform: // MERGE is only available since SQL Server 2008 and must be terminated by semicolon // It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx - return "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = :id) " . - "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) " . + return "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = :id) ". + "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". "WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->timeCol = :time;"; case 'sqlite': return "INSERT OR REPLACE INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time)"; diff --git a/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php b/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php index c96201cd217d0..d2e4b0072663c 100644 --- a/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php +++ b/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php @@ -61,7 +61,7 @@ public function __construct(Connection $conn) public function loadTokenBySeries($series) { $sql = 'SELECT class, username, value, lastUsed' - . ' FROM rememberme_token WHERE series=:series'; + .' FROM rememberme_token WHERE series=:series'; $paramValues = array('series' => $series); $paramTypes = array('series' => \PDO::PARAM_STR); $stmt = $this->conn->executeQuery($sql, $paramValues, $paramTypes); @@ -95,13 +95,13 @@ public function deleteTokenBySeries($series) public function updateToken($series, $tokenValue, \DateTime $lastUsed) { $sql = 'UPDATE rememberme_token SET value=:value, lastUsed=:lastUsed' - . ' WHERE series=:series'; + .' WHERE series=:series'; $paramValues = array('value' => $tokenValue, 'lastUsed' => $lastUsed, - 'series' => $series); + 'series' => $series,); $paramTypes = array('value' => \PDO::PARAM_STR, 'lastUsed' => DoctrineType::DATETIME, - 'series' => \PDO::PARAM_STR); + 'series' => \PDO::PARAM_STR,); $updated = $this->conn->executeUpdate($sql, $paramValues, $paramTypes); if ($updated < 1) { throw new TokenNotFoundException('No token found.'); @@ -114,18 +114,18 @@ public function updateToken($series, $tokenValue, \DateTime $lastUsed) public function createNewToken(PersistentTokenInterface $token) { $sql = 'INSERT INTO rememberme_token' - . ' (class, username, series, value, lastUsed)' - . ' VALUES (:class, :username, :series, :value, :lastUsed)'; + .' (class, username, series, value, lastUsed)' + .' VALUES (:class, :username, :series, :value, :lastUsed)'; $paramValues = array('class' => $token->getClass(), 'username' => $token->getUsername(), 'series' => $token->getSeries(), 'value' => $token->getTokenValue(), - 'lastUsed' => $token->getLastUsed()); + 'lastUsed' => $token->getLastUsed(),); $paramTypes = array('class' => \PDO::PARAM_STR, 'username' => \PDO::PARAM_STR, 'series' => \PDO::PARAM_STR, 'value' => \PDO::PARAM_STR, - 'lastUsed' => DoctrineType::DATETIME); + 'lastUsed' => DoctrineType::DATETIME,); $this->conn->executeUpdate($sql, $paramValues, $paramTypes); } } diff --git a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php index 53b1a016752a1..0385a1dd7faed 100644 --- a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php +++ b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php @@ -87,7 +87,7 @@ public function refreshUser(UserInterface $user) if (!$id = $this->metadata->getIdentifierValues($user)) { throw new \InvalidArgumentException("You cannot refresh a user ". "from the EntityUserProvider that does not contain an identifier. ". - "The user object has to be serialized with its own identifier " . + "The user object has to be serialized with its own identifier ". "mapped by Doctrine." ); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php index 067935608e50d..175cc560b756e 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php @@ -50,7 +50,7 @@ public function testCollectQueryCount() $this->assertEquals(0, $c->getQueryCount()); $queries = array( - array('sql' => "SELECT * FROM table1", 'params' => array(), 'types' => array(), 'executionMS' => 0) + array('sql' => "SELECT * FROM table1", 'params' => array(), 'types' => array(), 'executionMS' => 0), ); $c = $this->createCollector($queries); $c->collect(new Request(), new Response()); @@ -64,7 +64,7 @@ public function testCollectTime() $this->assertEquals(0, $c->getTime()); $queries = array( - array('sql' => "SELECT * FROM table1", 'params' => array(), 'types' => array(), 'executionMS' => 1) + array('sql' => "SELECT * FROM table1", 'params' => array(), 'types' => array(), 'executionMS' => 1), ); $c = $this->createCollector($queries); $c->collect(new Request(), new Response()); @@ -72,7 +72,7 @@ public function testCollectTime() $queries = array( array('sql' => "SELECT * FROM table1", 'params' => array(), 'types' => array(), 'executionMS' => 1), - array('sql' => "SELECT * FROM table2", 'params' => array(), 'types' => array(), 'executionMS' => 2) + array('sql' => "SELECT * FROM table2", 'params' => array(), 'types' => array(), 'executionMS' => 2), ); $c = $this->createCollector($queries); $c->collect(new Request(), new Response()); @@ -85,7 +85,7 @@ public function testCollectTime() public function testCollectQueries($param, $types, $expected, $explainable) { $queries = array( - array('sql' => "SELECT * FROM table1 WHERE field1 = ?1", 'params' => array($param), 'types' => $types, 'executionMS' => 1) + array('sql' => "SELECT * FROM table1 WHERE field1 = ?1", 'params' => array($param), 'types' => $types, 'executionMS' => 1), ); $c = $this->createCollector($queries); $c->collect(new Request(), new Response()); @@ -101,7 +101,7 @@ public function testCollectQueries($param, $types, $expected, $explainable) public function testSerialization($param, $types, $expected, $explainable) { $queries = array( - array('sql' => "SELECT * FROM table1 WHERE field1 = ?1", 'params' => array($param), 'types' => $types, 'executionMS' => 1) + array('sql' => "SELECT * FROM table1 WHERE field1 = ?1", 'params' => array($param), 'types' => $types, 'executionMS' => 1), ); $c = $this->createCollector($queries); $c->collect(new Request(), new Response()); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/GenericEntityChoiceListTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/GenericEntityChoiceListTest.php index c5910195ca6c1..e54968ed0d15c 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/GenericEntityChoiceListTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/GenericEntityChoiceListTest.php @@ -201,7 +201,7 @@ public function testInitNestedChoices() $this->assertSame(array(1 => $entity1, 2 => $entity2), $choiceList->getChoices()); $this->assertEquals(array( 'group1' => array(1 => new ChoiceView($entity1, '1', 'Foo')), - 'group2' => array(2 => new ChoiceView($entity2, '2', 'Bar')) + 'group2' => array(2 => new ChoiceView($entity2, '2', 'Bar')), ), $choiceList->getRemainingViews()); } @@ -236,7 +236,7 @@ public function testGroupByPropertyPath() $this->assertEquals(array( 'Group1' => array(1 => new ChoiceView($item1, '1', 'Foo'), 2 => new ChoiceView($item2, '2', 'Bar')), 'Group2' => array(3 => new ChoiceView($item3, '3', 'Baz')), - 4 => new ChoiceView($item4, '4', 'Boo!') + 4 => new ChoiceView($item4, '4', 'Boo!'), ), $choiceList->getRemainingViews()); } @@ -263,7 +263,7 @@ public function testGroupByInvalidPropertyPathReturnsFlatChoices() $this->assertEquals(array( 1 => $item1, - 2 => $item2 + 2 => $item2, ), $choiceList->getChoices()); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php index 82c587aaffec1..0cb900f6d04c4 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/DoctrineOrmTypeGuesserTest.php @@ -59,7 +59,7 @@ public function requiredProvider() $classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(false)); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true)); - $mapping = array('joinColumns' => array(array('nullable'=>true))); + $mapping = array('joinColumns' => array(array('nullable' => true))); $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping)); $return[] = array($classMetadata, new ValueGuess(false, Guess::HIGH_CONFIDENCE)); @@ -69,7 +69,7 @@ public function requiredProvider() $classMetadata->expects($this->once())->method('hasField')->with('field')->will($this->returnValue(false)); $classMetadata->expects($this->once())->method('isAssociationWithSingleJoinColumn')->with('field')->will($this->returnValue(true)); - $mapping = array('joinColumns' => array(array('nullable'=>false))); + $mapping = array('joinColumns' => array(array('nullable' => false))); $classMetadata->expects($this->once())->method('getAssociationMapping')->with('field')->will($this->returnValue($mapping)); $return[] = array($classMetadata, new ValueGuess(true, Guess::HIGH_CONFIDENCE)); @@ -94,5 +94,4 @@ private function getGuesser(ClassMetadata $classMetadata) return new DoctrineOrmTypeGuesser($registry); } - } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php index bdb40134905d1..e7b3cfc96bfb9 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php @@ -44,7 +44,7 @@ protected function getExtensions() return array( new CoreExtension(), - new DoctrineOrmExtension($manager) + new DoctrineOrmExtension($manager), ); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php index 329fa0ed3efd7..e91409574b2e4 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php @@ -130,7 +130,7 @@ public function testSetDataToUninitializedEntityWithNonRequired() 'em' => 'default', 'class' => self::SINGLE_IDENT_CLASS, 'required' => false, - 'property' => 'name' + 'property' => 'name', )); $this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['choices']); @@ -165,7 +165,7 @@ public function testSetDataToUninitializedEntityWithNonRequiredQueryBuilder() 'class' => self::SINGLE_IDENT_CLASS, 'required' => false, 'property' => 'name', - 'query_builder' => $qb + 'query_builder' => $qb, )); $this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['choices']); @@ -541,7 +541,7 @@ public function testGroupByChoices() $this->assertEquals(array( 'Group1' => array(1 => new ChoiceView($item1, '1', 'Foo'), 2 => new ChoiceView($item2, '2', 'Bar')), 'Group2' => array(3 => new ChoiceView($item3, '3', 'Baz')), - '4' => new ChoiceView($item4, '4', 'Boo!') + '4' => new ChoiceView($item4, '4', 'Boo!'), ), $field->createView()->vars['choices']); } @@ -754,7 +754,7 @@ public function testGetManagerForClassIfNoEm() $this->factory->createNamed('name', 'entity', null, array( 'class' => self::SINGLE_IDENT_CLASS, 'required' => false, - 'property' => 'name' + 'property' => 'name', )); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php b/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php index 0c39008d49959..970a13e8279be 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php @@ -138,5 +138,4 @@ public function testLogUTF8LongString() 'long' => $longString, )); } - } diff --git a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php index 308d883b2e067..da66a4b9f6d41 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php +++ b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php @@ -64,7 +64,7 @@ public function validate($entity, Constraint $constraint) $em = $this->registry->getManager($constraint->em); if (!$em) { - throw new ConstraintDefinitionException(sprintf('Object manager "%s" does not exist.', $constraint->em)); + throw new ConstraintDefinitionException(sprintf('Object manager "%s" does not exist.', $constraint->em)); } } else { $em = $this->registry->getManagerForClass(get_class($entity)); @@ -101,7 +101,7 @@ public function validate($entity, Constraint $constraint) if (count($relatedId) > 1) { throw new ConstraintDefinitionException( - "Associated entities are not allowed to have more than one identifier field to be " . + "Associated entities are not allowed to have more than one identifier field to be ". "part of a unique constraint in: ".$class->getName()."#".$fieldName ); } diff --git a/src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php b/src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php index 4b3cc575af264..873632e696ddb 100644 --- a/src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/ChromePhpHandler.php @@ -43,7 +43,6 @@ public function onKernelResponse(FilterResponseEvent $event) } if (!preg_match('{\bChrome/\d+[\.\d+]*\b}', $event->getRequest()->headers->get('User-Agent'))) { - $this->sendHeaders = false; $this->headers = array(); diff --git a/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php b/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php index 6cc2c38e1cd2d..2d42235556ce5 100644 --- a/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php @@ -44,7 +44,6 @@ public function onKernelResponse(FilterResponseEvent $event) if (!preg_match('{\bFirePHP/\d+\.\d+\b}', $event->getRequest()->headers->get('User-Agent')) && !$event->getRequest()->headers->has('X-FirePHP-Version')) { - $this->sendHeaders = false; $this->headers = array(); diff --git a/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php b/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php index 115763412becf..bfe3e515a418c 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Processor/WebProcessorTest.php @@ -32,7 +32,7 @@ public function testUsesRequestServerData() 'REMOTE_ADDR' => 'B', 'REQUEST_METHOD' => 'C', 'SERVER_NAME' => 'D', - 'HTTP_REFERER' => 'E' + 'HTTP_REFERER' => 'E', ); $request = new Request(); diff --git a/src/Symfony/Bridge/Propel1/Form/EventListener/TranslationCollectionFormListener.php b/src/Symfony/Bridge/Propel1/Form/EventListener/TranslationCollectionFormListener.php index ae39700736f79..9829bb238d944 100644 --- a/src/Symfony/Bridge/Propel1/Form/EventListener/TranslationCollectionFormListener.php +++ b/src/Symfony/Bridge/Propel1/Form/EventListener/TranslationCollectionFormListener.php @@ -22,7 +22,6 @@ */ class TranslationCollectionFormListener implements EventSubscriberInterface { - private $i18nClass; private $languages; diff --git a/src/Symfony/Bridge/Propel1/Form/EventListener/TranslationFormListener.php b/src/Symfony/Bridge/Propel1/Form/EventListener/TranslationFormListener.php index 3f20102c7c382..083e0ac8864ad 100644 --- a/src/Symfony/Bridge/Propel1/Form/EventListener/TranslationFormListener.php +++ b/src/Symfony/Bridge/Propel1/Form/EventListener/TranslationFormListener.php @@ -70,7 +70,7 @@ public function preSetData(FormEvent $event) $customOptions = $options['options']; } $options = array( - 'label' => $label.' '.strtoupper($data->getLocale()) + 'label' => $label.' '.strtoupper($data->getLocale()), ); $options = array_merge($options, $customOptions); diff --git a/src/Symfony/Bridge/Propel1/Form/PropelExtension.php b/src/Symfony/Bridge/Propel1/Form/PropelExtension.php index 77e044b9c6a19..d333f79903786 100644 --- a/src/Symfony/Bridge/Propel1/Form/PropelExtension.php +++ b/src/Symfony/Bridge/Propel1/Form/PropelExtension.php @@ -26,7 +26,7 @@ protected function loadTypes() return array( new Type\ModelType(PropertyAccess::createPropertyAccessor()), new Type\TranslationCollectionType(), - new Type\TranslationType() + new Type\TranslationType(), ); } diff --git a/src/Symfony/Bridge/Propel1/Form/Type/TranslationCollectionType.php b/src/Symfony/Bridge/Propel1/Form/Type/TranslationCollectionType.php index 4ecf7e03be642..1ed78ae705d18 100644 --- a/src/Symfony/Bridge/Propel1/Form/Type/TranslationCollectionType.php +++ b/src/Symfony/Bridge/Propel1/Form/Type/TranslationCollectionType.php @@ -59,7 +59,7 @@ public function getName() public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setRequired(array( - 'languages' + 'languages', )); $resolver->setDefaults(array( @@ -68,8 +68,8 @@ public function setDefaultOptions(OptionsResolverInterface $resolver) 'allow_delete' => false, 'options' => array( 'data_class' => null, - 'columns' => null - ) + 'columns' => null, + ), )); } } diff --git a/src/Symfony/Bridge/Propel1/Form/Type/TranslationType.php b/src/Symfony/Bridge/Propel1/Form/Type/TranslationType.php index 1bd94a484ce3a..8315b4f347295 100644 --- a/src/Symfony/Bridge/Propel1/Form/Type/TranslationType.php +++ b/src/Symfony/Bridge/Propel1/Form/Type/TranslationType.php @@ -48,7 +48,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setRequired(array( 'data_class', - 'columns' + 'columns', )); } } diff --git a/src/Symfony/Bridge/Propel1/Tests/DataCollector/PropelDataCollectorTest.php b/src/Symfony/Bridge/Propel1/Tests/DataCollector/PropelDataCollectorTest.php index 23d6fc9fc6a5d..0d80b83c7afe4 100644 --- a/src/Symfony/Bridge/Propel1/Tests/DataCollector/PropelDataCollectorTest.php +++ b/src/Symfony/Bridge/Propel1/Tests/DataCollector/PropelDataCollectorTest.php @@ -47,9 +47,9 @@ public function testCollectWithData() array( 'sql' => "SET NAMES 'utf8'", 'time' => '0.000 sec', - 'connection'=> 'default', - 'memory' => '1.4 MB' - ) + 'connection' => 'default', + 'memory' => '1.4 MB', + ), ), $c->getQueries()); $this->assertEquals(1, $c->getQueryCount()); } @@ -69,20 +69,20 @@ public function testCollectWithMultipleData() array( 'sql' => "SET NAMES 'utf8'", 'time' => '0.000 sec', - 'connection'=> 'default', - 'memory' => '1.4 MB' + 'connection' => 'default', + 'memory' => '1.4 MB', ), array( 'sql' => "SELECT tags.NAME, image.FILENAME FROM tags LEFT JOIN image ON tags.IMAGEID = image.ID WHERE image.ID = 12", 'time' => '0.012 sec', - 'connection'=> 'default', - 'memory' => '2.4 MB' + 'connection' => 'default', + 'memory' => '2.4 MB', ), array( 'sql' => "INSERT INTO `table` (`some_array`) VALUES ('| 1 | 2 | 3 |')", 'time' => '0.012 sec', - 'connection'=> 'default', - 'memory' => '2.4 MB' + 'connection' => 'default', + 'memory' => '2.4 MB', ), ), $c->getQueries()); $this->assertEquals(3, $c->getQueryCount()); diff --git a/src/Symfony/Bridge/Propel1/Tests/Fixtures/ItemQuery.php b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ItemQuery.php index 47f769057e5b8..83955592a50e5 100644 --- a/src/Symfony/Bridge/Propel1/Tests/Fixtures/ItemQuery.php +++ b/src/Symfony/Bridge/Propel1/Tests/Fixtures/ItemQuery.php @@ -96,7 +96,7 @@ public function getRelations() return array( $mainAuthorRelation, $authorRelation, - $resellerRelation + $resellerRelation, ); } } diff --git a/src/Symfony/Bridge/Propel1/Tests/Fixtures/TranslatableItemI18n.php b/src/Symfony/Bridge/Propel1/Tests/Fixtures/TranslatableItemI18n.php index 1253b26c26c7e..1fa1741ab52fc 100644 --- a/src/Symfony/Bridge/Propel1/Tests/Fixtures/TranslatableItemI18n.php +++ b/src/Symfony/Bridge/Propel1/Tests/Fixtures/TranslatableItemI18n.php @@ -94,7 +94,6 @@ public function save(PropelPDO $con = null) public function setLocale($locale) { - $this->locale = $locale; } @@ -115,7 +114,6 @@ public function setItem($item) public function setValue($value) { - $this->value = $value; } @@ -126,7 +124,6 @@ public function getValue() public function setValue2($value2) { - $this->value2 = $value2; } diff --git a/src/Symfony/Bridge/Propel1/Tests/Form/ChoiceList/ModelChoiceListTest.php b/src/Symfony/Bridge/Propel1/Tests/Form/ChoiceList/ModelChoiceListTest.php index ef77b5edbbd77..9f9a69e3319b6 100644 --- a/src/Symfony/Bridge/Propel1/Tests/Form/ChoiceList/ModelChoiceListTest.php +++ b/src/Symfony/Bridge/Propel1/Tests/Form/ChoiceList/ModelChoiceListTest.php @@ -97,7 +97,7 @@ public function testFlattenedPreferredChoices() null, null, array( - $item1 + $item1, ) ); @@ -122,7 +122,7 @@ public function testNestedChoices() $this->assertSame(array(1 => $item1, 2 => $item2), $choiceList->getChoices()); $this->assertEquals(array( 'group1' => array(1 => new ChoiceView($item1, '1', 'Foo')), - 'group2' => array(2 => new ChoiceView($item2, '2', 'Bar')) + 'group2' => array(2 => new ChoiceView($item2, '2', 'Bar')), ), $choiceList->getRemainingViews()); } @@ -150,7 +150,7 @@ public function testGroupBySupportsString() $this->assertEquals(array( 'Group1' => array(1 => new ChoiceView($item1, '1', 'Foo'), 2 => new ChoiceView($item2, '2', 'Bar')), 'Group2' => array(3 => new ChoiceView($item3, '3', 'Baz')), - 4 => new ChoiceView($item4, '4', 'Boo!') + 4 => new ChoiceView($item4, '4', 'Boo!'), ), $choiceList->getRemainingViews()); } @@ -172,7 +172,7 @@ public function testGroupByInvalidPropertyPathReturnsFlatChoices() $this->assertEquals(array( 1 => $item1, - 2 => $item2 + 2 => $item2, ), $choiceList->getChoices()); } diff --git a/src/Symfony/Bridge/Propel1/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php b/src/Symfony/Bridge/Propel1/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php index b48652b82fd2d..32d18404f95d9 100644 --- a/src/Symfony/Bridge/Propel1/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php +++ b/src/Symfony/Bridge/Propel1/Tests/Form/DataTransformer/CollectionToArrayTransformerTest.php @@ -108,4 +108,6 @@ public function testReverseTransformWithData() } } -class DummyObject {} +class DummyObject +{ +} diff --git a/src/Symfony/Bridge/Propel1/Tests/Form/Type/TranslationCollectionTypeTest.php b/src/Symfony/Bridge/Propel1/Tests/Form/Type/TranslationCollectionTypeTest.php index e9fa8395e7e0a..0663020cc6f55 100644 --- a/src/Symfony/Bridge/Propel1/Tests/Form/Type/TranslationCollectionTypeTest.php +++ b/src/Symfony/Bridge/Propel1/Tests/Form/Type/TranslationCollectionTypeTest.php @@ -42,15 +42,15 @@ public function testTranslationsAdded() $item->addTranslatableItemI18n(new TranslatableItemI18n(2, 'en', 'val2')); $builder = $this->factory->createBuilder('form', null, array( - 'data_class' => self::TRANSLATION_CLASS + 'data_class' => self::TRANSLATION_CLASS, )); $builder->add('translatableItemI18ns', 'propel1_translation_collection', array( 'languages' => array('en', 'fr'), 'options' => array( 'data_class' => self::TRANSLATABLE_I18N_CLASS, - 'columns' => array('value', 'value2' => array('label' => 'Label', 'type' => 'textarea')) - ) + 'columns' => array('value', 'value2' => array('label' => 'Label', 'type' => 'textarea')), + ), )); $form = $builder->getForm(); $form->setData($item); @@ -79,14 +79,14 @@ public function testNotPresentTranslationsAdded() $this->assertCount(0, $item->getTranslatableItemI18ns()); $builder = $this->factory->createBuilder('form', null, array( - 'data_class' => self::TRANSLATION_CLASS + 'data_class' => self::TRANSLATION_CLASS, )); $builder->add('translatableItemI18ns', 'propel1_translation_collection', array( 'languages' => array('en', 'fr'), 'options' => array( 'data_class' => self::TRANSLATABLE_I18N_CLASS, - 'columns' => array('value', 'value2' => array('label' => 'Label', 'type' => 'textarea')) - ) + 'columns' => array('value', 'value2' => array('label' => 'Label', 'type' => 'textarea')), + ), )); $form = $builder->getForm(); @@ -103,14 +103,14 @@ public function testNoArrayGiven() $item = new Item(null, 'val'); $builder = $this->factory->createBuilder('form', null, array( - 'data_class' => self::NON_TRANSLATION_CLASS + 'data_class' => self::NON_TRANSLATION_CLASS, )); $builder->add('value', 'propel1_translation_collection', array( 'languages' => array('en', 'fr'), 'options' => array( 'data_class' => self::TRANSLATABLE_I18N_CLASS, - 'columns' => array('value', 'value2' => array('label' => 'Label', 'type' => 'textarea')) - ) + 'columns' => array('value', 'value2' => array('label' => 'Label', 'type' => 'textarea')), + ), )); $form = $builder->getForm(); @@ -125,8 +125,8 @@ public function testNoDataClassAdded() $this->factory->createNamed('itemI18ns', 'propel1_translation_collection', null, array( 'languages' => array('en', 'fr'), 'options' => array( - 'columns' => array('value', 'value2') - ) + 'columns' => array('value', 'value2'), + ), )); } @@ -138,8 +138,8 @@ public function testNoLanguagesAdded() $this->factory->createNamed('itemI18ns', 'propel1_translation_collection', null, array( 'options' => array( 'data_class' => self::TRANSLATABLE_I18N_CLASS, - 'columns' => array('value', 'value2') - ) + 'columns' => array('value', 'value2'), + ), )); } @@ -151,8 +151,8 @@ public function testNoColumnsAdded() $this->factory->createNamed('itemI18ns', 'propel1_translation_collection', null, array( 'languages' => array('en', 'fr'), 'options' => array( - 'data_class' => self::TRANSLATABLE_I18N_CLASS - ) + 'data_class' => self::TRANSLATABLE_I18N_CLASS, + ), )); } } diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/ContainerBuilderTest.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/ContainerBuilderTest.php index 804c9da9c658a..10faf8e12a86c 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/ContainerBuilderTest.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/ContainerBuilderTest.php @@ -11,7 +11,7 @@ namespace Symfony\Bridge\ProxyManager\Tests\LazyProxy; -require_once __DIR__ . '/Fixtures/includes/foo.php'; +require_once __DIR__.'/Fixtures/includes/foo.php'; use Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator; use Symfony\Component\DependencyInjection\ContainerBuilder; diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php index 1b06f07af04d6..630c8c59fe973 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php @@ -65,7 +65,6 @@ function (& $wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) u class stdClass_c1d194250ee2e2b7d2eab8b8212368a8 extends \stdClass implements \ProxyManager\Proxy\LazyLoadingInterface, \ProxyManager\Proxy\ValueHolderInterface { - /** * @var \Closure|null initializer responsible for generating the wrapped object */ @@ -193,5 +192,4 @@ public function getWrappedValueHolderValue() { return $this->valueHolder5157dd96e88c0; } - } diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php index adbd990a746fe..e3ef13d8e9a9f 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php @@ -57,7 +57,7 @@ public function testGetProxyCode() $this->assertStringMatchesFormat( '%Aclass SymfonyBridgeProxyManagerTestsLazyProxyPhpDumperProxyDumperTest%aextends%w' - . '\Symfony\Bridge\ProxyManager\Tests\LazyProxy\PhpDumper\ProxyDumperTest%a', + .'\Symfony\Bridge\ProxyManager\Tests\LazyProxy\PhpDumper\ProxyDumperTest%a', $code ); } @@ -72,10 +72,10 @@ public function testGetProxyFactoryCode() $this->assertStringMatchesFormat( '%wif ($lazyLoad) {%w$container = $this;%wreturn $this->services[\'foo\'] = new ' - . 'SymfonyBridgeProxyManagerTestsLazyProxyPhpDumperProxyDumperTest_%s(%wfunction ' - . '(&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) {' - . '%w$wrappedInstance = $container->getFooService(false);%w$proxy->setProxyInitializer(null);' - . '%wreturn true;%w}%w);%w}%w', + .'SymfonyBridgeProxyManagerTestsLazyProxyPhpDumperProxyDumperTest_%s(%wfunction ' + .'(&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) {' + .'%w$wrappedInstance = $container->getFooService(false);%w$proxy->setProxyInitializer(null);' + .'%wreturn true;%w}%w);%w}%w', $code ); } @@ -88,7 +88,7 @@ public function getProxyCandidates() $definitions = array( array(new Definition(__CLASS__), true), array(new Definition('stdClass'), true), - array(new Definition('foo' . uniqid()), false), + array(new Definition('foo'.uniqid()), false), array(new Definition(), false), ); diff --git a/src/Symfony/Bridge/Twig/Node/FormThemeNode.php b/src/Symfony/Bridge/Twig/Node/FormThemeNode.php index 329ab86fe089a..c3ebd51bbcd76 100644 --- a/src/Symfony/Bridge/Twig/Node/FormThemeNode.php +++ b/src/Symfony/Bridge/Twig/Node/FormThemeNode.php @@ -35,6 +35,5 @@ public function compile(\Twig_Compiler $compiler) ->raw(', ') ->subcompile($this->getNode('resources')) ->raw(");\n"); - ; } } diff --git a/src/Symfony/Bridge/Twig/Node/RenderBlockNode.php b/src/Symfony/Bridge/Twig/Node/RenderBlockNode.php index 822a27279fa79..457532ecd5d07 100644 --- a/src/Symfony/Bridge/Twig/Node/RenderBlockNode.php +++ b/src/Symfony/Bridge/Twig/Node/RenderBlockNode.php @@ -29,7 +29,7 @@ public function compile(\Twig_Compiler $compiler) if (isset($arguments[0])) { $compiler->subcompile($arguments[0]); - $compiler->raw(', \'' . $this->getAttribute('name') . '\''); + $compiler->raw(', \''.$this->getAttribute('name').'\''); if (isset($arguments[1])) { $compiler->raw(', '); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php index d93565143972c..5e4a9a307982d 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/CodeExtensionTest.php @@ -53,7 +53,7 @@ public function getMethodNameProvider() array('F\Q\N\Foo::Method', 'Foo::Method()'), array('Bare::Method', 'Bare::Method()'), array('Closure', 'Closure'), - array('Method', 'Method()') + array('Method', 'Method()'), ); } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php index 5eb67ea730182..f0e2cb3f884fd 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php @@ -210,14 +210,14 @@ protected function setTheme(FormView $view, array $themes) public static function themeBlockInheritanceProvider() { return array( - array(array('theme.html.twig')) + array(array('theme.html.twig')), ); } public static function themeInheritanceProvider() { return array( - array(array('parent_label.html.twig'), array('child_label.html.twig')) + array(array('parent_label.html.twig'), array('child_label.html.twig')), ); } } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php index 11c2d5ad7970a..a75f228860664 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php @@ -101,17 +101,17 @@ public function getTransTests() // transchoice array('{% transchoice count from "messages" %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}', - 'There is no apples', array('count' => 0)), + 'There is no apples', array('count' => 0),), array('{% transchoice count %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}', - 'There is 5 apples', array('count' => 5)), + 'There is 5 apples', array('count' => 5),), array('{% transchoice count %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%){% endtranschoice %}', - 'There is 5 apples (Symfony2)', array('count' => 5, 'name' => 'Symfony2')), + 'There is 5 apples (Symfony2)', array('count' => 5, 'name' => 'Symfony2'),), array('{% transchoice count with { \'%name%\': \'Symfony2\' } %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%){% endtranschoice %}', - 'There is 5 apples (Symfony2)', array('count' => 5)), + 'There is 5 apples (Symfony2)', array('count' => 5),), array('{% transchoice count into "fr"%}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}', - 'There is no apples', array('count' => 0)), + 'There is no apples', array('count' => 0),), array('{% transchoice 5 into "fr"%}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples{% endtranschoice %}', - 'There is 5 apples'), + 'There is 5 apples',), // trans filter array('{{ "Hello"|trans }}', 'Hello'), diff --git a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php index ffbec162d69a9..7b2cd4f9991d5 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php @@ -21,7 +21,7 @@ public function testConstructor() $form = new \Twig_Node_Expression_Name('form', 0); $resources = new \Twig_Node(array( new \Twig_Node_Expression_Constant('tpl1', 0), - new \Twig_Node_Expression_Constant('tpl2', 0) + new \Twig_Node_Expression_Constant('tpl2', 0), )); $node = new FormThemeNode($form, $resources, 0); @@ -37,7 +37,7 @@ public function testCompile() new \Twig_Node_Expression_Constant(0, 0), new \Twig_Node_Expression_Constant('tpl1', 0), new \Twig_Node_Expression_Constant(1, 0), - new \Twig_Node_Expression_Constant('tpl2', 0) + new \Twig_Node_Expression_Constant('tpl2', 0), ), 0); $node = new FormThemeNode($form, $resources, 0); diff --git a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php index 1559df1cc36fd..c844239e533a8 100644 --- a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php +++ b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php @@ -43,7 +43,7 @@ public function getTestsForFormTheme() ), 1), 1, 'form_theme' - ) + ), ), array( '{% form_theme form "tpl1" "tpl2" %}', @@ -53,11 +53,11 @@ public function getTestsForFormTheme() new \Twig_Node_Expression_Constant(0, 1), new \Twig_Node_Expression_Constant('tpl1', 1), new \Twig_Node_Expression_Constant(1, 1), - new \Twig_Node_Expression_Constant('tpl2', 1) + new \Twig_Node_Expression_Constant('tpl2', 1), ), 1), 1, 'form_theme' - ) + ), ), array( '{% form_theme form with "tpl1" %}', @@ -66,7 +66,7 @@ public function getTestsForFormTheme() new \Twig_Node_Expression_Constant('tpl1', 1), 1, 'form_theme' - ) + ), ), array( '{% form_theme form with ["tpl1"] %}', @@ -78,7 +78,7 @@ public function getTestsForFormTheme() ), 1), 1, 'form_theme' - ) + ), ), array( '{% form_theme form with ["tpl1", "tpl2"] %}', @@ -88,11 +88,11 @@ public function getTestsForFormTheme() new \Twig_Node_Expression_Constant(0, 1), new \Twig_Node_Expression_Constant('tpl1', 1), new \Twig_Node_Expression_Constant(1, 1), - new \Twig_Node_Expression_Constant('tpl2', 1) + new \Twig_Node_Expression_Constant('tpl2', 1), ), 1), 1, 'form_theme' - ) + ), ), ); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php index f9e2d403c3dfa..bf118407b0200 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php @@ -32,7 +32,7 @@ protected function configure() $this ->setName('config:dump-reference') ->setDefinition(array( - new InputArgument('name', InputArgument::OPTIONAL, 'The Bundle or extension alias') + new InputArgument('name', InputArgument::OPTIONAL, 'The Bundle or extension alias'), )) ->setDescription('Dumps default configuration for an extension') ->setHelp(<<setDescription('Displays current services for an application') ->setHelp(<<setDescription('Updates the translation file') ->setHelp(<<getRequirements() as $name => $value) { - $route->setRequirement($name, $this->resolve($value)); + $route->setRequirement($name, $this->resolve($value)); } $route->setPath($this->resolve($route->getPath())); @@ -138,7 +138,7 @@ private function resolve($value) } throw new RuntimeException(sprintf( - 'The container parameter "%s", used in the route configuration value "%s", ' . + 'The container parameter "%s", used in the route configuration value "%s", '. 'must be a string or numeric, but it is of type %s.', $match[1], $value, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php index 4b426f25621bd..59a7d1d9208e3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php @@ -53,5 +53,4 @@ function ($template) { return $template->getLogicalName(); }, $this->assertContains('::this.is.a.template.format.engine', $templates); $this->assertContains('::resource.format.engine', $templates); } - } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php index 34d1eeac282f5..a892c711a3208 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php @@ -60,7 +60,7 @@ public function testRoute($permanent, $ignoreAttributes, $expectedCode, $expecte 'route' => $route, 'permanent' => $permanent, 'additional-parameter' => 'value', - 'ignoreAttributes' => $ignoreAttributes + 'ignoreAttributes' => $ignoreAttributes, ), ); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php index 03eacc3636994..2f39190a8f414 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddCacheWarmerPassTest.php @@ -23,7 +23,7 @@ public function testThatCacheWarmersAreProcessedInPriorityOrder() $services = array( 'my_cache_warmer_service1' => array(0 => array('priority' => 100)), 'my_cache_warmer_service2' => array(0 => array('priority' => 200)), - 'my_cache_warmer_service3' => array() + 'my_cache_warmer_service3' => array(), ); $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); @@ -46,7 +46,7 @@ public function testThatCacheWarmersAreProcessedInPriorityOrder() ->with(0, array( new Reference('my_cache_warmer_service2'), new Reference('my_cache_warmer_service1'), - new Reference('my_cache_warmer_service3') + new Reference('my_cache_warmer_service3'), )); $addCacheWarmerPass = new AddCacheWarmerPass(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SerializerPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SerializerPassTest.php index aa276b1e044a8..021ecd0bbc634 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SerializerPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/SerializerPassTest.php @@ -22,7 +22,6 @@ */ class SerializerPassTest extends \PHPUnit_Framework_TestCase { - public function testThrowExceptionWhenNoNormalizers() { $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'); @@ -72,16 +71,16 @@ public function testThrowExceptionWhenNoEncoders() public function testServicesAreOrderedAccordingToPriority() { - $services = array( + $services = array( 'n3' => array('tag' => array()), 'n1' => array('tag' => array('priority' => 200)), - 'n2' => array('tag' => array('priority' => 100)) + 'n2' => array('tag' => array('priority' => 100)), ); - $expected = array( + $expected = array( new Reference('n1'), new Reference('n2'), - new Reference('n3') + new Reference('n3'), ); $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/TranslatorPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/TranslatorPassTest.php index 871acb252567f..b68ea4e0d0173 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/TranslatorPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/TranslatorPassTest.php @@ -40,8 +40,6 @@ public function testValidCollector() $container->expects($this->once()) ->method('findDefinition') ->will($this->returnValue($this->getMock('Symfony\Component\DependencyInjection\Definition'))); - ; - $pass = new TranslatorPass(); $pass->process($container); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php index 939703d8ab36f..1bcf1debf0bd8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -36,7 +36,7 @@ public function testValidTrustedProxies($trustedProxies, $processedProxies) $configuration = new Configuration(); $config = $processor->processConfiguration($configuration, array(array( 'secret' => 's3cr3t', - 'trusted_proxies' => $trustedProxies + 'trusted_proxies' => $trustedProxies, ))); $this->assertEquals($processedProxies, $config['trusted_proxies']); @@ -66,8 +66,8 @@ public function testInvalidTypeTrustedProxies() $processor->processConfiguration($configuration, array( array( 'secret' => 's3cr3t', - 'trusted_proxies' => 'Not an IP address' - ) + 'trusted_proxies' => 'Not an IP address', + ), )); } @@ -81,8 +81,8 @@ public function testInvalidValueTrustedProxies() $processor->processConfiguration($configuration, array( array( 'secret' => 's3cr3t', - 'trusted_proxies' => array('Not an IP address') - ) + 'trusted_proxies' => array('Not an IP address'), + ), )); } @@ -128,8 +128,8 @@ protected static function getBundleDefaultConfig() 'debug' => '%kernel.debug%', ), 'serializer' => array( - 'enabled' => false - ) + 'enabled' => false, + ), ); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/TestBundle.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/TestBundle.php index e936bfd98e7f7..b0c4548fa07de 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/TestBundle.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/TestBundle/TestBundle.php @@ -13,5 +13,4 @@ class TestBundle extends \Symfony\Component\HttpKernel\Bundle\Bundle { - } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php index 0bc94f2e73778..801f61b94e1a2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php @@ -54,7 +54,7 @@ ), ), 'form' => array( - 'resources' => array('theme1', 'theme2') + 'resources' => array('theme1', 'theme2'), ), 'hinclude_default_template' => 'global_hinclude_template', ), @@ -71,5 +71,5 @@ 'debug' => true, 'file_cache_dir' => '%kernel.cache_dir%/annotations', ), - 'ide' => 'file%%link%%format' + 'ide' => 'file%%link%%format', )); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index f1adb72976e44..df4983d7ffbfc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -185,19 +185,19 @@ public function testTranslator() $files = array_map(function ($resource) { return realpath($resource[1]); }, $resources); $ref = new \ReflectionClass('Symfony\Component\Validator\Validator'); $this->assertContains( - strtr(dirname($ref->getFileName()) . '/Resources/translations/validators.en.xlf', '/', DIRECTORY_SEPARATOR), + strtr(dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', DIRECTORY_SEPARATOR), $files, '->registerTranslatorConfiguration() finds Validator translation resources' ); $ref = new \ReflectionClass('Symfony\Component\Form\Form'); $this->assertContains( - strtr(dirname($ref->getFileName()) . '/Resources/translations/validators.en.xlf', '/', DIRECTORY_SEPARATOR), + strtr(dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', DIRECTORY_SEPARATOR), $files, '->registerTranslatorConfiguration() finds Form translation resources' ); $ref = new \ReflectionClass('Symfony\Component\Security\Core\SecurityContext'); $this->assertContains( - strtr(dirname(dirname($ref->getFileName())) . '/Resources/translations/security.en.xlf', '/', DIRECTORY_SEPARATOR), + strtr(dirname(dirname($ref->getFileName())).'/Resources/translations/security.en.xlf', '/', DIRECTORY_SEPARATOR), $files, '->registerTranslatorConfiguration() finds Security translation resources' ); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SessionController.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SessionController.php index 8d395760e80a8..96bc067fe5a8d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SessionController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/SessionController.php @@ -17,7 +17,7 @@ class SessionController extends ContainerAware { - public function welcomeAction($name=null) + public function welcomeAction($name = null) { $request = $this->container->get('request'); $session = $request->getSession(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php index 2cc57d1a7320a..bc44b78a183a6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php @@ -24,7 +24,7 @@ public function testGenerateWithServiceParam() $routes->add('foo', new Route( ' /{_locale}', array( - '_locale' => '%locale%' + '_locale' => '%locale%', ), array( '_locale' => 'en|es', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php index 9a960e3bea010..70df59acbeada 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php @@ -125,14 +125,14 @@ protected function setTheme(FormView $view, array $themes) public static function themeBlockInheritanceProvider() { return array( - array(array('TestBundle:Parent')) + array(array('TestBundle:Parent')), ); } public static function themeInheritanceProvider() { return array( - array(array('TestBundle:Parent'), array('TestBundle:Child')) + array(array('TestBundle:Parent'), array('TestBundle:Child')), ); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php index a93dd5e845144..68ad018a688ee 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php @@ -183,7 +183,6 @@ public function testGetLocaleWithInvalidLocale() $this->assertSame('en-US', $translator->getLocale()); } - protected function getCatalogue($locale, $messages) { $catalogue = new MessageCatalogue($locale); diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php index 0b29792e52f7c..34d079069bd15 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php +++ b/src/Symfony/Bundle/FrameworkBundle/Translation/PhpStringTokenParser.php @@ -96,7 +96,7 @@ public static function parse($str) public static function parseEscapeSequences($str, $quote) { if (null !== $quote) { - $str = str_replace('\\' . $quote, $quote, $str); + $str = str_replace('\\'.$quote, $quote, $str); } return preg_replace_callback( diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php index 95f1ced93d359..97d1d3d9624cb 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php @@ -309,11 +309,11 @@ private function addProvidersSection(ArrayNodeDefinition $rootNode) 'memory' => array( 'users' => array( 'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER'), - 'bar' => array('password' => 'bar', 'roles' => '[ROLE_USER, ROLE_ADMIN]') + 'bar' => array('password' => 'bar', 'roles' => '[ROLE_USER, ROLE_ADMIN]'), ), - ) + ), ), - 'my_entity_provider' => array('entity' => array('class' => 'SecurityBundle:User', 'property' => 'username')) + 'my_entity_provider' => array('entity' => array('class' => 'SecurityBundle:User', 'property' => 'username')), )) ->disallowNewKeysInSubsequentConfigs() ->isRequired() @@ -370,8 +370,8 @@ private function addEncodersSection(ArrayNodeDefinition $rootNode) 'Acme\DemoBundle\Entity\User2' => array( 'algorithm' => 'sha512', 'encode_as_base64' => 'true', - 'iterations'=> 5000 - ) + 'iterations' => 5000, + ), )) ->requiresAtLeastOneElement() ->useAttributeAsKey('class') diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php index 288ea1e82439f..e7fb75773ca41 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php @@ -61,7 +61,7 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider, if (isset($config['token_provider'])) { $rememberMeServices->addMethodCall('setTokenProvider', array( - new Reference($config['token_provider']) + new Reference($config['token_provider']), )); } diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index dce37e48b8a99..17f16c0293f3f 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php @@ -136,7 +136,7 @@ private function configureDbalAclProvider(array $config, ContainerBuilder $conta ->addTag('doctrine.event_listener', array( 'connection' => $config['connection'], 'event' => 'postGenerateSchema', - 'lazy' => true + 'lazy' => true, )) ; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/custom_acl_provider.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/custom_acl_provider.php index 4acf6cc960c21..351dc6c09e1a6 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/custom_acl_provider.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/custom_acl_provider.php @@ -5,5 +5,5 @@ $container->loadFromExtension('security', array( 'acl' => array( 'provider' => 'foo', - ) + ), )); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/merge.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/merge.php index 82966dccc2885..50ef504ea4d43 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/merge.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/merge.php @@ -16,5 +16,5 @@ 'role_hierarchy' => array( 'FOO' => array('MOO'), - ) + ), )); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/merge_import.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/merge_import.php index 1e29d40e283a1..912b9127ef369 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/merge_import.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/merge_import.php @@ -5,8 +5,8 @@ 'main' => array( 'form_login' => array( 'login_path' => '/login', - ) - ) + ), + ), ), 'role_hierarchy' => array( 'FOO' => 'BAR', diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php index 0605a1619ef9d..b91244d24ac0d 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php @@ -35,9 +35,9 @@ public function testInvalidCheckPath() 'pattern' => '/secured_area/.*', 'form_login' => array( 'check_path' => '/some_area/login_check', - ) - ) - ) + ), + ), + ), )); $container->compile(); @@ -59,8 +59,8 @@ public function testFirewallWithoutAuthenticationListener() 'firewalls' => array( 'some_firewall' => array( 'pattern' => '/.*', - ) - ) + ), + ), )); $container->compile(); diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php index e8fec8ddc43dc..3f1e0176b3511 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php @@ -42,7 +42,7 @@ public function load(array $configs, ContainerBuilder $container) if (is_array($value) && isset($value['key'])) { $config['globals'][$name] = array( 'key' => $name, - 'value' => $config['globals'][$name] + 'value' => $config['globals'][$name], ); } } diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php index 3d2a14d00d327..c6d506e86a47e 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/full.php @@ -4,7 +4,7 @@ 'form' => array( 'resources' => array( 'MyBundle::form.html.twig', - ) + ), ), 'globals' => array( 'foo' => '@bar', diff --git a/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/RenderTokenParserTest.php b/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/RenderTokenParserTest.php index 9823a98fcafcc..55ebcd2566c53 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/RenderTokenParserTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/RenderTokenParserTest.php @@ -40,7 +40,7 @@ public function getTestsForRender() new \Twig_Node_Expression_Array(array(), 1), 1, 'render' - ) + ), ), array( '{% render "foo", {foo: 1} %}', @@ -52,7 +52,7 @@ public function getTestsForRender() ), 1), 1, 'render' - ) + ), ), ); } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php index dea4f8883f8dc..2efb84a14da60 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -148,7 +148,7 @@ public function infoAction($about) $this->profiler->disable(); return new Response($this->twig->render('@WebProfiler/Profiler/info.html.twig', array( - 'about' => $about + 'about' => $about, )), 200, array('Content-Type' => 'text/html')); } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ExportCommandTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ExportCommandTest.php index 572e9b3978864..70267ecc9ea09 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ExportCommandTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ExportCommandTest.php @@ -13,7 +13,6 @@ use Symfony\Bundle\WebProfilerBundle\Command\ExportCommand; use Symfony\Component\Console\Tester\CommandTester; -use Symfony\Component\Console\Application; use Symfony\Component\HttpKernel\Profiler\Profile; class ExportCommandTest extends \PHPUnit_Framework_TestCase diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ImportCommandTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ImportCommandTest.php index f5121c12d6fe2..fe3ba421ad645 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ImportCommandTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ImportCommandTest.php @@ -13,7 +13,6 @@ use Symfony\Bundle\WebProfilerBundle\Command\ImportCommand; use Symfony\Component\Console\Tester\CommandTester; -use Symfony\Component\Console\Application; use Symfony\Component\HttpKernel\Profiler\Profile; class ImportCommandTest extends \PHPUnit_Framework_TestCase diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php index c46ca055a3176..54833e7717695 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php @@ -48,9 +48,9 @@ public function setUp() $profiler = $this->mockProfiler(); $twigEnvironment = $this->mockTwigEnvironment(); $templates = array( - 'data_collector.foo'=>array('foo','FooBundle:Collector:foo'), - 'data_collector.bar'=>array('bar','FooBundle:Collector:bar'), - 'data_collector.baz'=>array('baz','FooBundle:Collector:baz') + 'data_collector.foo' => array('foo','FooBundle:Collector:foo'), + 'data_collector.bar' => array('bar','FooBundle:Collector:bar'), + 'data_collector.baz' => array('baz','FooBundle:Collector:baz'), ); $this->templateManager = new TemplateManager($profiler, $twigEnvironment, $templates); diff --git a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php index 39015d2cc5604..c14bea0096322 100644 --- a/src/Symfony/Component/BrowserKit/Tests/ClientTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/ClientTest.php @@ -498,7 +498,7 @@ public function testFollowRedirectWithPort() 'HTTP_HOST' => 'www.example.com:8080', 'HTTP_USER_AGENT' => 'Symfony2 BrowserKit', 'HTTPS' => false, - 'HTTP_REFERER' => 'http://www.example.com:8080/' + 'HTTP_REFERER' => 'http://www.example.com:8080/', ); $client = new TestClient(); @@ -636,7 +636,7 @@ public function testSetServerParameterInRequest() 'HTTP_HOST' => 'testhost', 'HTTP_USER_AGENT' => 'testua', 'HTTPS' => false, - 'NEW_SERVER_KEY' => 'new-server-key-value' + 'NEW_SERVER_KEY' => 'new-server-key-value', )); $this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST')); diff --git a/src/Symfony/Component/BrowserKit/Tests/ResponseTest.php b/src/Symfony/Component/BrowserKit/Tests/ResponseTest.php index 878752c75ee75..23662dc54b9de 100644 --- a/src/Symfony/Component/BrowserKit/Tests/ResponseTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/ResponseTest.php @@ -61,13 +61,13 @@ public function testMagicToStringWithMultipleSetCookieHeader() { $headers = array( 'content-type' => 'text/html; charset=utf-8', - 'set-cookie' => array('foo=bar', 'bar=foo') + 'set-cookie' => array('foo=bar', 'bar=foo'), ); $expected = 'content-type: text/html; charset=utf-8'."\n"; - $expected.= 'set-cookie: foo=bar'."\n"; - $expected.= 'set-cookie: bar=foo'."\n\n"; - $expected.= 'foo'; + $expected .= 'set-cookie: foo=bar'."\n"; + $expected .= 'set-cookie: bar=foo'."\n\n"; + $expected .= 'foo'; $response = new Response('foo', 304, $headers); diff --git a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php index 7f83dbc5592d1..efc95ec8be94c 100644 --- a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php +++ b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php @@ -71,7 +71,6 @@ public static function createMap($dir) foreach ($classes as $class) { $map[$class] = $path; } - } return $map; diff --git a/src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php b/src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php index 38a17f284534b..9755256c79a4d 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ApcUniversalClassLoaderTest.php @@ -55,13 +55,13 @@ public function testLoadClass($className, $testClassName, $message) $this->assertTrue(class_exists($className), $message); } - public function getLoadClassTests() - { - return array( + public function getLoadClassTests() + { + return array( array('\\Apc\\Namespaced\\Foo', 'Apc\\Namespaced\\Foo', '->loadClass() loads Apc\Namespaced\Foo class'), array('Apc_Pearlike_Foo', 'Apc_Pearlike_Foo', '->loadClass() loads Apc_Pearlike_Foo class'), ); - } + } /** * @dataProvider getLoadClassFromFallbackTests @@ -77,15 +77,15 @@ public function testLoadClassFromFallback($className, $testClassName, $message) $this->assertTrue(class_exists($className), $message); } - public function getLoadClassFromFallbackTests() - { - return array( + public function getLoadClassFromFallbackTests() + { + return array( array('\\Apc\\Namespaced\\Baz', 'Apc\\Namespaced\\Baz', '->loadClass() loads Apc\Namespaced\Baz class'), array('Apc_Pearlike_Baz', 'Apc_Pearlike_Baz', '->loadClass() loads Apc_Pearlike_Baz class'), array('\\Apc\\Namespaced\\FooBar', 'Apc\\Namespaced\\FooBar', '->loadClass() loads Apc\Namespaced\Baz class from fallback dir'), array('Apc_Pearlike_FooBar', 'Apc_Pearlike_FooBar', '->loadClass() loads Apc_Pearlike_Baz class from fallback dir'), ); - } + } /** * @dataProvider getLoadClassNamespaceCollisionTests @@ -100,9 +100,9 @@ public function testLoadClassNamespaceCollision($namespaces, $className, $messag $this->assertTrue(class_exists($className), $message); } - public function getLoadClassNamespaceCollisionTests() - { - return array( + public function getLoadClassNamespaceCollisionTests() + { + return array( array( array( 'Apc\\NamespaceCollision\\A' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha', @@ -136,7 +136,7 @@ public function getLoadClassNamespaceCollisionTests() '->loadClass() loads NamespaceCollision\A\B\Bar from beta.', ), ); - } + } /** * @dataProvider getLoadClassPrefixCollisionTests @@ -150,9 +150,9 @@ public function testLoadClassPrefixCollision($prefixes, $className, $message) $this->assertTrue(class_exists($className), $message); } - public function getLoadClassPrefixCollisionTests() - { - return array( + public function getLoadClassPrefixCollisionTests() + { + return array( array( array( 'ApcPrefixCollision_A_' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/Apc/alpha/Apc', @@ -186,5 +186,5 @@ public function getLoadClassPrefixCollisionTests() '->loadClass() loads ApcPrefixCollision_A_B_Bar from beta.', ), ); - } + } } diff --git a/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php b/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php index 18f64f75887ef..596844d9c9183 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php @@ -76,7 +76,7 @@ public function getTestCreateMapTests() 'Namespaced\\Foo' => realpath(__DIR__).'/Fixtures/Namespaced/Foo.php', 'Namespaced\\Baz' => realpath(__DIR__).'/Fixtures/Namespaced/Baz.php', 'Namespaced\\WithComments' => realpath(__DIR__).'/Fixtures/Namespaced/WithComments.php', - ) + ), ), array(__DIR__.'/Fixtures/beta/NamespaceCollision', array( 'NamespaceCollision\\A\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Bar.php', diff --git a/src/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/A.php b/src/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/A.php index dff891dcb79a6..b0f9425950f44 100644 --- a/src/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/A.php +++ b/src/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/A.php @@ -2,4 +2,6 @@ namespace ClassesWithParents; -class A extends B {} +class A extends B +{ +} diff --git a/src/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/B.php b/src/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/B.php index 196bf7a2d31b4..22c751a7e5da4 100644 --- a/src/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/B.php +++ b/src/Symfony/Component/ClassLoader/Tests/Fixtures/ClassesWithParents/B.php @@ -2,4 +2,6 @@ namespace ClassesWithParents; -class B implements CInterface {} +class B implements CInterface +{ +} diff --git a/src/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeClass.php b/src/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeClass.php index 26fabbd96e2d2..c63cef9233eb1 100644 --- a/src/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeClass.php +++ b/src/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeClass.php @@ -13,5 +13,4 @@ class SomeClass extends SomeParent implements SomeInterface { - } diff --git a/src/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeInterface.php b/src/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeInterface.php index 09d7a8f35a436..1fe5e09aa1f50 100644 --- a/src/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeInterface.php +++ b/src/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeInterface.php @@ -13,5 +13,4 @@ interface SomeInterface { - } diff --git a/src/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeParent.php b/src/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeParent.php index 5a859a94607fb..ce2f9fc6c478c 100644 --- a/src/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeParent.php +++ b/src/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/SomeParent.php @@ -13,5 +13,4 @@ abstract class SomeParent { - } diff --git a/src/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/multipleNs.php b/src/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/multipleNs.php index d19e07fc11a5e..7db8cd3b67ccc 100644 --- a/src/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/multipleNs.php +++ b/src/Symfony/Component/ClassLoader/Tests/Fixtures/classmap/multipleNs.php @@ -1,14 +1,24 @@ file.'.meta'; } - } diff --git a/src/Symfony/Component/Config/Definition/Builder/BooleanNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/BooleanNodeDefinition.php index 3f8713bedbdbb..979f9bac6d7be 100644 --- a/src/Symfony/Component/Config/Definition/Builder/BooleanNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/BooleanNodeDefinition.php @@ -39,5 +39,4 @@ protected function instantiateNode() { return new BooleanNode($this->name, $this->parent); } - } diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php b/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php index 5ea1c0e86e14f..e140df70de11e 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php +++ b/src/Symfony/Component/Config/Definition/Builder/NodeBuilder.php @@ -243,5 +243,4 @@ protected function getNodeClass($type) return $class; } - } diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php index a1a251f7b7147..2efcd057cacae 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php @@ -343,5 +343,4 @@ protected function normalization() * @throws InvalidDefinitionException When the definition is invalid */ abstract protected function createNode(); - } diff --git a/src/Symfony/Component/Config/Definition/Builder/VariableNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/VariableNodeDefinition.php index aa148ffbcc89f..26196c8bc3d05 100644 --- a/src/Symfony/Component/Config/Definition/Builder/VariableNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/VariableNodeDefinition.php @@ -64,5 +64,4 @@ protected function createNode() return $node; } - } diff --git a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php index 80ad452696701..a05faecfb71cd 100644 --- a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php +++ b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php @@ -323,7 +323,7 @@ protected function mergeValues($leftSide, $rightSide) if (!array_key_exists($k, $leftSide)) { if (!$this->allowNewKeys) { $ex = new InvalidConfigurationException(sprintf( - 'You are not allowed to define new elements for path "%s". ' . + 'You are not allowed to define new elements for path "%s". '. 'Please define all elements for this path in one config file.', $this->getPath() )); diff --git a/src/Symfony/Component/Config/Definition/ReferenceDumper.php b/src/Symfony/Component/Config/Definition/ReferenceDumper.php index 26eea78e1a3d2..f1a0a7bb8c5bf 100644 --- a/src/Symfony/Component/Config/Definition/ReferenceDumper.php +++ b/src/Symfony/Component/Config/Definition/ReferenceDumper.php @@ -120,7 +120,7 @@ private function writeNode(NodeInterface $node, $depth = 0) if ($info = $node->getInfo()) { $this->writeLine(''); // indenting multi-line info - $info = str_replace("\n", sprintf("\n%".$depth * 4 . "s# ", ' '), $info); + $info = str_replace("\n", sprintf("\n%".($depth * 4)."s# ", ' '), $info); $this->writeLine('# '.$info, $depth * 4); } diff --git a/src/Symfony/Component/Config/Loader/LoaderInterface.php b/src/Symfony/Component/Config/Loader/LoaderInterface.php index f01f7709d2c2f..52d5981e8ea69 100644 --- a/src/Symfony/Component/Config/Loader/LoaderInterface.php +++ b/src/Symfony/Component/Config/Loader/LoaderInterface.php @@ -49,5 +49,4 @@ public function getResolver(); * @param LoaderResolverInterface $resolver A LoaderResolverInterface instance */ public function setResolver(LoaderResolverInterface $resolver); - } diff --git a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php index 4d193075805dc..d0d9e2e428303 100644 --- a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php @@ -77,7 +77,7 @@ public function getPreNormalizationTests() array( array('foo-bar' => null, 'foo_bar' => 'foo'), array('foo-bar' => null, 'foo_bar' => 'foo'), - ) + ), ); } diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php index 06dacf2ab8cbd..e75ed34f469a4 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/ArrayNodeDefinitionTest.php @@ -53,7 +53,7 @@ public function providePrototypeNodeSpecificCalls() array('defaultValue', array(array())), array('addDefaultChildrenIfNoneSet', array()), array('requiresAtLeastOneElement', array()), - array('useAttributeAsKey', array('foo')) + array('useAttributeAsKey', array('foo')), ); } diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php index c18c696c459a1..13a28afcbd556 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php @@ -15,7 +15,6 @@ class ExprBuilderTest extends \PHPUnit_Framework_TestCase { - public function testAlwaysExpression() { $test = $this->getTestBuilder() @@ -31,7 +30,7 @@ public function testIfTrueExpression() ->ifTrue() ->then($this->returnClosure('new_value')) ->end(); - $this->assertFinalizedValueIs('new_value', $test, array('key'=>true)); + $this->assertFinalizedValueIs('new_value', $test, array('key' => true)); $test = $this->getTestBuilder() ->ifTrue( function ($v) { return true; }) @@ -58,8 +57,7 @@ public function testIfStringExpression() ->ifString() ->then($this->returnClosure('new_value')) ->end(); - $this->assertFinalizedValueIs(45, $test, array('key'=>45)); - + $this->assertFinalizedValueIs(45, $test, array('key' => 45)); } public function testIfNullExpression() @@ -68,7 +66,7 @@ public function testIfNullExpression() ->ifNull() ->then($this->returnClosure('new_value')) ->end(); - $this->assertFinalizedValueIs('new_value', $test, array('key'=>null)); + $this->assertFinalizedValueIs('new_value', $test, array('key' => null)); $test = $this->getTestBuilder() ->ifNull() @@ -83,7 +81,7 @@ public function testIfArrayExpression() ->ifArray() ->then($this->returnClosure('new_value')) ->end(); - $this->assertFinalizedValueIs('new_value', $test, array('key'=>array())); + $this->assertFinalizedValueIs('new_value', $test, array('key' => array())); $test = $this->getTestBuilder() ->ifArray() @@ -182,7 +180,7 @@ protected function finalizeTestBuilder($testBuilder, $config = null) ->end() ->end() ->buildTree() - ->finalize(null === $config ? array('key'=>'value') : $config) + ->finalize(null === $config ? array('key' => 'value') : $config) ; } @@ -207,6 +205,6 @@ protected function returnClosure($val) */ protected function assertFinalizedValueIs($value, $treeBuilder, $config = null) { - $this->assertEquals(array('key'=>$value), $this->finalizeTestBuilder($treeBuilder, $config)); + $this->assertEquals(array('key' => $value), $this->finalizeTestBuilder($treeBuilder, $config)); } } diff --git a/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php index bdf79ecec9bfe..4f308ca76b77c 100644 --- a/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/FloatNodeTest.php @@ -34,7 +34,7 @@ public function getValidValues() // Integer are accepted too, they will be cast array(17), array(-10), - array(0) + array(0), ); } diff --git a/src/Symfony/Component/Config/Tests/Definition/MergeTest.php b/src/Symfony/Component/Config/Tests/Definition/MergeTest.php index d78027d05142e..08ddc3209e72e 100644 --- a/src/Symfony/Component/Config/Tests/Definition/MergeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/MergeTest.php @@ -115,14 +115,14 @@ public function testDoesNotAllowNewKeysInSubsequentConfigs() $a = array( 'test' => array( - 'a' => array('value' => 'foo') - ) + 'a' => array('value' => 'foo'), + ), ); $b = array( 'test' => array( - 'b' => array('value' => 'foo') - ) + 'b' => array('value' => 'foo'), + ), ); $tree->merge($a, $b); @@ -157,13 +157,13 @@ public function testPerformsNoDeepMerging() $b = array( 'no_deep_merging' => array( 'c' => 'd', - ) + ), ); $this->assertEquals(array( 'no_deep_merging' => array( 'c' => 'd', - ) + ), ), $tree->merge($a, $b)); } diff --git a/src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php b/src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php index 99f767bfda921..a896f96221484 100644 --- a/src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/NormalizationTest.php @@ -176,8 +176,8 @@ public function testNonAssociativeArrayThrowsExceptionIfAttributeNotSet() { $denormalized = array( 'thing' => array( - array('foo', 'bar'), array('baz', 'qux') - ) + array('foo', 'bar'), array('baz', 'qux'), + ), ); $this->assertNormalized($this->getNumericKeysTestTree(), $denormalized, array()); diff --git a/src/Symfony/Component/Config/Tests/Definition/ReferenceDumperTest.php b/src/Symfony/Component/Config/Tests/Definition/ReferenceDumperTest.php index 137caf8cbc37b..5b4aea9b39a6b 100644 --- a/src/Symfony/Component/Config/Tests/Definition/ReferenceDumperTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/ReferenceDumperTest.php @@ -26,7 +26,7 @@ public function testDumper() private function getConfigurationAsString() { - return <<isDir()) { - rmdir($path->__toString()); + rmdir($path->__toString()); } else { - unlink($path->__toString()); + unlink($path->__toString()); } } rmdir($directory); diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 029dc29e00678..4b682e706ad9e 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -532,7 +532,7 @@ public function findNamespace($namespace) throw new \InvalidArgumentException(sprintf('The namespace "%s" is ambiguous (%s).', $namespace, $this->getAbbreviationSuggestions($abbrevs[$part]))); } - $found .= $found ? ':' . $abbrevs[$part][0] : $abbrevs[$part][0]; + $found .= $found ? ':'.$abbrevs[$part][0] : $abbrevs[$part][0]; } return $found; diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php b/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php index f0bbd383727e2..0a3e69ef2705a 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php @@ -28,7 +28,7 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface 'blue' => 34, 'magenta' => 35, 'cyan' => 36, - 'white' => 37 + 'white' => 37, ); private static $availableBackgroundColors = array( 'black' => 40, @@ -38,14 +38,14 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface 'blue' => 44, 'magenta' => 45, 'cyan' => 46, - 'white' => 47 + 'white' => 47, ); private static $availableOptions = array( 'bold' => 1, 'underscore' => 4, 'blink' => 5, 'reverse' => 7, - 'conceal' => 8 + 'conceal' => 8, ); private $foreground; diff --git a/src/Symfony/Component/Console/Helper/DialogHelper.php b/src/Symfony/Component/Console/Helper/DialogHelper.php index 6605e8939da69..89c1587f43370 100644 --- a/src/Symfony/Component/Console/Helper/DialogHelper.php +++ b/src/Symfony/Component/Console/Helper/DialogHelper.php @@ -146,7 +146,8 @@ public function ask(OutputInterface $output, $question, $default = null, array $ // Pop the last character off the end of our string $ret = substr($ret, 0, $i); - } elseif ("\033" === $c) { // Did we read an escape sequence? + } elseif ("\033" === $c) { + // Did we read an escape sequence? $c .= fread($inputStream, 2); // A = Up Arrow. B = Down Arrow diff --git a/src/Symfony/Component/Console/Input/ArgvInput.php b/src/Symfony/Component/Console/Input/ArgvInput.php index 3a0f0a7193b53..1e02a1cba8bc7 100644 --- a/src/Symfony/Component/Console/Input/ArgvInput.php +++ b/src/Symfony/Component/Console/Input/ArgvInput.php @@ -169,7 +169,7 @@ private function parseArgument($token) // if input is expecting another argument, add it if ($this->definition->hasArgument($c)) { $arg = $this->definition->getArgument($c); - $this->arguments[$arg->getName()] = $arg->isArray()? array($token) : $token; + $this->arguments[$arg->getName()] = $arg->isArray() ? array($token) : $token; // if last argument isArray(), append token to last argument } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) { @@ -336,7 +336,7 @@ public function __toString() $self = $this; $tokens = array_map(function ($token) use ($self) { if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) { - return $match[1] . $self->escapeToken($match[2]); + return $match[1].$self->escapeToken($match[2]); } if ($token && $token[0] !== '-') { diff --git a/src/Symfony/Component/Console/Input/ArrayInput.php b/src/Symfony/Component/Console/Input/ArrayInput.php index 27d91323f3048..e723f75be0ab8 100644 --- a/src/Symfony/Component/Console/Input/ArrayInput.php +++ b/src/Symfony/Component/Console/Input/ArrayInput.php @@ -120,7 +120,7 @@ public function __toString() $params = array(); foreach ($this->parameters as $param => $val) { if ($param && '-' === $param[0]) { - $params[] = $param . ('' != $val ? '='.$this->escapeToken($val) : ''); + $params[] = $param.('' != $val ? '='.$this->escapeToken($val) : ''); } else { $params[] = $this->escapeToken($val); } diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index 2c27339a6ef1b..07411444f4983 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -240,7 +240,7 @@ public function provideAmbiguousAbbreviations() return array( array('f', 'Command "f" is not defined.'), array('a', 'Command "a" is ambiguous (afoobar, afoobar1 and 1 more).'), - array('foo:b', 'Command "foo:b" is ambiguous (foo:bar, foo:bar1).') + array('foo:b', 'Command "foo:b" is ambiguous (foo:bar, foo:bar1).'), ); } @@ -270,7 +270,7 @@ public function provideInvalidCommandNamesSingle() { return array( array('foo:baR'), - array('foO:bar') + array('foO:bar'), ); } diff --git a/src/Symfony/Component/Console/Tests/Command/CommandTest.php b/src/Symfony/Component/Console/Tests/Command/CommandTest.php index 872bb7fc42f4d..6505f0da807eb 100644 --- a/src/Symfony/Component/Console/Tests/Command/CommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/CommandTest.php @@ -111,7 +111,7 @@ public function provideInvalidCommandNames() { return array( array(''), - array('foo:') + array('foo:'), ); } diff --git a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php index ca5087491277f..fbb9feeb68731 100644 --- a/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php +++ b/src/Symfony/Component/Console/Tests/Command/ListCommandTest.php @@ -49,7 +49,6 @@ public function testExecuteListsCommandsWithRawOption() public function testExecuteListsCommandsWithNamespaceArgument() { - require_once realpath(__DIR__.'/../Fixtures/FooCommand.php'); $application = new Application(); $application->add(new \FooCommand()); diff --git a/src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php index 118cc44dbb8bc..7bd24ed039407 100644 --- a/src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php @@ -133,7 +133,7 @@ public function testAskAndValidate() $helperSet = new HelperSet(array(new FormatterHelper())); $dialog->setHelperSet($helperSet); - $question ='What color was the white horse of Henry IV?'; + $question = 'What color was the white horse of Henry IV?'; $error = 'This is not a color!'; $validator = function ($color) use ($error) { if (!in_array($color, array('white', 'black'))) { diff --git a/src/Symfony/Component/Console/Tests/Helper/FormatterHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/FormatterHelperTest.php index db61de4f61620..e33277475717f 100644 --- a/src/Symfony/Component/Console/Tests/Helper/FormatterHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/FormatterHelperTest.php @@ -37,15 +37,15 @@ public function testFormatBlock() ); $this->assertEquals( - ' Some text to display '."\n" . + ' Some text to display '."\n". ' foo bar ', $formatter->formatBlock(array('Some text to display', 'foo bar'), 'error'), '::formatBlock() formats a message in a block' ); $this->assertEquals( - ' '."\n" . - ' Some text to display '."\n" . + ' '."\n". + ' Some text to display '."\n". ' ', $formatter->formatBlock('Some text to display', 'error', true), '::formatBlock() formats a message in a block' @@ -61,8 +61,8 @@ public function testFormatBlockWithDiacriticLetters() $formatter = new FormatterHelper(); $this->assertEquals( - ' '."\n" . - ' Du texte à afficher '."\n" . + ' '."\n". + ' Du texte à afficher '."\n". ' ', $formatter->formatBlock('Du texte à afficher', 'error', true), '::formatBlock() formats a message in a block' @@ -76,8 +76,8 @@ public function testFormatBlockWithDoubleWidthDiacriticLetters() } $formatter = new FormatterHelper(); $this->assertEquals( - ' '."\n" . - ' 表示するテキスト '."\n" . + ' '."\n". + ' 表示するテキスト '."\n". ' ', $formatter->formatBlock('表示するテキスト', 'error', true), '::formatBlock() formats a message in a block' @@ -89,8 +89,8 @@ public function testFormatBlockLGEscaping() $formatter = new FormatterHelper(); $this->assertEquals( - ' '."\n" . - ' \some info\ '."\n" . + ' '."\n". + ' \some info\ '."\n". ' ', $formatter->formatBlock('some info', 'error', true), '::formatBlock() escapes \'<\' chars' diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php index 266cc3d1c380c..2d2ec82b121a4 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php @@ -88,8 +88,8 @@ public function testOverwriteWithShorterLine() rewind($output->getStream()); $this->assertEquals( - $this->generateOutput(' 0/50 [>---------------------------] 0%') . - $this->generateOutput(' 1/50 [>---------------------------] 2%') . + $this->generateOutput(' 0/50 [>---------------------------] 0%'). + $this->generateOutput(' 1/50 [>---------------------------] 2%'). $this->generateOutput(' 2/50 [=>--------------------------] '), stream_get_contents($output->getStream()) ); @@ -106,9 +106,9 @@ public function testSetCurrentProgress() rewind($output->getStream()); $this->assertEquals( - $this->generateOutput(' 0/50 [>---------------------------] 0%') . - $this->generateOutput(' 1/50 [>---------------------------] 2%') . - $this->generateOutput(' 15/50 [========>-------------------] 30%') . + $this->generateOutput(' 0/50 [>---------------------------] 0%'). + $this->generateOutput(' 1/50 [>---------------------------] 2%'). + $this->generateOutput(' 15/50 [========>-------------------] 30%'). $this->generateOutput(' 25/50 [==============>-------------] 50%'), stream_get_contents($output->getStream()) ); diff --git a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php index 507990d2cf667..451b108179a46 100644 --- a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php @@ -57,92 +57,92 @@ public function provideOptions() array('cli.php', '--foo'), array(new InputOption('foo')), array('foo' => true), - '->parse() parses long options without a value' + '->parse() parses long options without a value', ), array( array('cli.php', '--foo=bar'), array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)), array('foo' => 'bar'), - '->parse() parses long options with a required value (with a = separator)' + '->parse() parses long options with a required value (with a = separator)', ), array( array('cli.php', '--foo', 'bar'), array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)), array('foo' => 'bar'), - '->parse() parses long options with a required value (with a space separator)' + '->parse() parses long options with a required value (with a space separator)', ), array( array('cli.php', '-f'), array(new InputOption('foo', 'f')), array('foo' => true), - '->parse() parses short options without a value' + '->parse() parses short options without a value', ), array( array('cli.php', '-fbar'), array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)), array('foo' => 'bar'), - '->parse() parses short options with a required value (with no separator)' + '->parse() parses short options with a required value (with no separator)', ), array( array('cli.php', '-f', 'bar'), array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)), array('foo' => 'bar'), - '->parse() parses short options with a required value (with a space separator)' + '->parse() parses short options with a required value (with a space separator)', ), array( array('cli.php', '-f', ''), array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)), array('foo' => ''), - '->parse() parses short options with an optional empty value' + '->parse() parses short options with an optional empty value', ), array( array('cli.php', '-f', '', 'foo'), array(new InputArgument('name'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)), array('foo' => ''), - '->parse() parses short options with an optional empty value followed by an argument' + '->parse() parses short options with an optional empty value followed by an argument', ), array( array('cli.php', '-f', '', '-b'), array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b')), array('foo' => '', 'bar' => true), - '->parse() parses short options with an optional empty value followed by an option' + '->parse() parses short options with an optional empty value followed by an option', ), array( array('cli.php', '-f', '-b', 'foo'), array(new InputArgument('name'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b')), array('foo' => null, 'bar' => true), - '->parse() parses short options with an optional value which is not present' + '->parse() parses short options with an optional value which is not present', ), array( array('cli.php', '-fb'), array(new InputOption('foo', 'f'), new InputOption('bar', 'b')), array('foo' => true, 'bar' => true), - '->parse() parses short options when they are aggregated as a single one' + '->parse() parses short options when they are aggregated as a single one', ), array( array('cli.php', '-fb', 'bar'), array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::VALUE_REQUIRED)), array('foo' => true, 'bar' => 'bar'), - '->parse() parses short options when they are aggregated as a single one and the last one has a required value' + '->parse() parses short options when they are aggregated as a single one and the last one has a required value', ), array( array('cli.php', '-fb', 'bar'), array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL)), array('foo' => true, 'bar' => 'bar'), - '->parse() parses short options when they are aggregated as a single one and the last one has an optional value' + '->parse() parses short options when they are aggregated as a single one and the last one has an optional value', ), array( array('cli.php', '-fbbar'), array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL)), array('foo' => true, 'bar' => 'bar'), - '->parse() parses short options when they are aggregated as a single one and the last one has an optional value with no separator' + '->parse() parses short options when they are aggregated as a single one and the last one has an optional value with no separator', ), array( array('cli.php', '-fbbar'), array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL)), array('foo' => 'bbar', 'bar' => null), - '->parse() parses short options when they are aggregated as a single one and one of them takes a value' - ) + '->parse() parses short options when they are aggregated as a single one and one of them takes a value', + ), ); } @@ -163,43 +163,43 @@ public function provideInvalidInput() array( array('cli.php', '--foo'), new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED))), - 'The "--foo" option requires a value.' + 'The "--foo" option requires a value.', ), array( array('cli.php', '-f'), new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED))), - 'The "--foo" option requires a value.' + 'The "--foo" option requires a value.', ), array( array('cli.php', '-ffoo'), new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_NONE))), - 'The "-o" option does not exist.' + 'The "-o" option does not exist.', ), array( array('cli.php', '--foo=bar'), new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_NONE))), - 'The "--foo" option does not accept a value.' + 'The "--foo" option does not accept a value.', ), array( array('cli.php', 'foo', 'bar'), new InputDefinition(), - 'Too many arguments.' + 'Too many arguments.', ), array( array('cli.php', '--foo'), new InputDefinition(), - 'The "--foo" option does not exist.' + 'The "--foo" option does not exist.', ), array( array('cli.php', '-f'), new InputDefinition(), - 'The "-f" option does not exist.' + 'The "-f" option does not exist.', ), array( array('cli.php', '-1'), new InputDefinition(array(new InputArgument('number'))), - 'The "-1" option does not exist.' - ) + 'The "-1" option does not exist.', + ), ); } diff --git a/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php b/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php index 73f2e33e4ef13..7cf28e8f49694 100644 --- a/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/ArrayInputTest.php @@ -62,26 +62,26 @@ public function provideOptions() array('--foo' => 'bar'), array(new InputOption('foo')), array('foo' => 'bar'), - '->parse() parses long options' + '->parse() parses long options', ), array( array('--foo' => 'bar'), array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')), array('foo' => 'bar'), - '->parse() parses long options with a default value' + '->parse() parses long options with a default value', ), array( array('--foo' => null), array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')), array('foo' => 'default'), - '->parse() parses long options with a default value' + '->parse() parses long options with a default value', ), array( array('-f' => 'bar'), array(new InputOption('foo', 'f')), array('foo' => 'bar'), - '->parse() parses short options' - ) + '->parse() parses short options', + ), ); } @@ -101,23 +101,23 @@ public function provideInvalidInput() array( array('foo' => 'foo'), new InputDefinition(array(new InputArgument('name'))), - 'The "foo" argument does not exist.' + 'The "foo" argument does not exist.', ), array( array('--foo' => null), new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED))), - 'The "--foo" option requires a value.' + 'The "--foo" option requires a value.', ), array( array('--foo' => 'foo'), new InputDefinition(), - 'The "--foo" option does not exist.' + 'The "--foo" option does not exist.', ), array( array('-o' => 'foo'), new InputDefinition(), - 'The "-o" option does not exist.' - ) + 'The "-o" option does not exist.', + ), ); } diff --git a/src/Symfony/Component/Console/Tests/Input/InputArgumentTest.php b/src/Symfony/Component/Console/Tests/Input/InputArgumentTest.php index 3bfc796696a9a..cfb37cd41061f 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputArgumentTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputArgumentTest.php @@ -50,7 +50,7 @@ public function provideInvalidModes() { return array( array('ANOTHER_ONE'), - array(-1) + array(-1), ); } diff --git a/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php b/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php index 5817e8fb8eee7..53ce1df8cf3fb 100644 --- a/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php +++ b/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php @@ -86,7 +86,7 @@ public function provideInvalidModes() { return array( array('ANOTHER_ONE'), - array(-1) + array(-1), ); } diff --git a/src/Symfony/Component/CssSelector/Parser/Parser.php b/src/Symfony/Component/CssSelector/Parser/Parser.php index 6c7c3be583ba8..c622383e841a2 100644 --- a/src/Symfony/Component/CssSelector/Parser/Parser.php +++ b/src/Symfony/Component/CssSelector/Parser/Parser.php @@ -96,7 +96,7 @@ public static function parseSeries(array $tokens) return array( $first ? ('-' === $first || '+' === $first ? $int($first.'1') : $int($first)) : 1, - isset($split[1]) && $split[1] ? $int($split[1]) : 0 + isset($split[1]) && $split[1] ? $int($split[1]) : 0, ); } diff --git a/src/Symfony/Component/CssSelector/Parser/Shortcut/ClassParser.php b/src/Symfony/Component/CssSelector/Parser/Shortcut/ClassParser.php index db352334f0a24..bb9653ce01636 100644 --- a/src/Symfony/Component/CssSelector/Parser/Shortcut/ClassParser.php +++ b/src/Symfony/Component/CssSelector/Parser/Shortcut/ClassParser.php @@ -41,7 +41,7 @@ public function parse($source) // 4 => string 'ab6bd_field' (length=11) if (preg_match('/^(([a-z]+)\|)?([\w-]+|\*)?\.([\w-]+)$/i', trim($source), $matches)) { return array( - new SelectorNode(new ClassNode(new ElementNode($matches[2] ?: null, $matches[3] ?: null), $matches[4])) + new SelectorNode(new ClassNode(new ElementNode($matches[2] ?: null, $matches[3] ?: null), $matches[4])), ); } diff --git a/src/Symfony/Component/CssSelector/Parser/Shortcut/HashParser.php b/src/Symfony/Component/CssSelector/Parser/Shortcut/HashParser.php index 95d7d5f91174f..28c7d296f1b78 100644 --- a/src/Symfony/Component/CssSelector/Parser/Shortcut/HashParser.php +++ b/src/Symfony/Component/CssSelector/Parser/Shortcut/HashParser.php @@ -41,7 +41,7 @@ public function parse($source) // 4 => string 'ab6bd_field' (length=11) if (preg_match('/^(([a-z]+)\|)?([\w-]+|\*)?#([\w-]+)$/i', trim($source), $matches)) { return array( - new SelectorNode(new HashNode(new ElementNode($matches[2] ?: null, $matches[3] ?: null), $matches[4])) + new SelectorNode(new HashNode(new ElementNode($matches[2] ?: null, $matches[3] ?: null), $matches[4])), ); } diff --git a/src/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerEscaping.php b/src/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerEscaping.php index 921fc393a9231..76386c937141f 100644 --- a/src/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerEscaping.php +++ b/src/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerEscaping.php @@ -72,10 +72,10 @@ private function replaceUnicodeSequences($value) return chr($c); } if (0x800 > $c) { - return chr(0xC0 | $c>>6).chr(0x80 | $c & 0x3F); + return chr(0xC0 | $c >> 6).chr(0x80 | $c & 0x3F); } if (0x10000 > $c) { - return chr(0xE0 | $c>>12).chr(0x80 | $c>>6 & 0x3F).chr(0x80 | $c & 0x3F); + return chr(0xE0 | $c >> 12).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F); } }, $value); } diff --git a/src/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php b/src/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php index 4caa9ed3451f8..0c0f42d80b514 100644 --- a/src/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php +++ b/src/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php @@ -114,7 +114,6 @@ public function testFlattenHttpException(\Exception $exception, $statusCode) $this->assertEquals($exception->getMessage(), $flattened->getMessage(), 'The message is copied from the original exception.'); $this->assertEquals($exception->getCode(), $flattened->getCode(), 'The code is copied from the original exception.'); $this->assertInstanceOf($flattened->getClass(), $exception, 'The class is set to the class of the original exception'); - } /** @@ -160,13 +159,13 @@ public function testToArray(\Exception $exception, $statusCode) $this->assertEquals(array( array( - 'message'=> 'test', - 'class'=>'Exception', - 'trace'=>array(array( + 'message' => 'test', + 'class' => 'Exception', + 'trace' => array(array( 'namespace' => '', 'short_class' => '', 'class' => '','type' => '','function' => '', 'file' => 'foo.php', 'line' => 123, - 'args' => array() + 'args' => array(), )), - ) + ), ), $flattened->toArray()); } @@ -202,7 +201,7 @@ public function testSetTraceIncompleteClass() 'line' => 123, 'function' => 'test', 'args' => array( - unserialize('O:14:"BogusTestClass":0:{}') + unserialize('O:14:"BogusTestClass":0:{}'), ), ), ), @@ -211,9 +210,9 @@ public function testSetTraceIncompleteClass() $this->assertEquals(array( array( - 'message'=> 'test', - 'class'=>'Exception', - 'trace'=>array( + 'message' => 'test', + 'class' => 'Exception', + 'trace' => array( array( 'namespace' => '', 'short_class' => '', 'class' => '','type' => '','function' => '', 'file' => 'foo.php', 'line' => 123, @@ -224,12 +223,12 @@ public function testSetTraceIncompleteClass() 'file' => __FILE__, 'line' => 123, 'args' => array( array( - 'incomplete-object', 'BogusTestClass' + 'incomplete-object', 'BogusTestClass', ), ), - ) + ), ), - ) + ), ), $flattened->toArray()); } } diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 7e18a52022db7..b8addc10f5e5f 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -196,7 +196,7 @@ private function addProxyClasses() $code = ''; foreach ($definitions as $definition) { - $code .= "\n" . $this->getProxyDumper()->getProxyCode($definition); + $code .= "\n".$this->getProxyDumper()->getProxyCode($definition); } return $code; @@ -844,7 +844,7 @@ private function addMethodMap() $code .= ' '.var_export($id, true).' => '.var_export('get'.$this->camelize($id).'Service', true).",\n"; } - return $code . " );\n"; + return $code." );\n"; } /** @@ -872,7 +872,7 @@ private function addAliases() $code .= ' '.var_export($alias, true).' => '.var_export($id, true).",\n"; } - return $code . " );\n"; + return $code." );\n"; } /** diff --git a/src/Symfony/Component/DependencyInjection/IntrospectableContainerInterface.php b/src/Symfony/Component/DependencyInjection/IntrospectableContainerInterface.php index c2fe7745d2d5d..f0853fe01e571 100644 --- a/src/Symfony/Component/DependencyInjection/IntrospectableContainerInterface.php +++ b/src/Symfony/Component/DependencyInjection/IntrospectableContainerInterface.php @@ -29,5 +29,4 @@ interface IntrospectableContainerInterface extends ContainerInterface * */ public function initialized($id); - } diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index 5890ed84c1918..c42db5adebcae 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -477,7 +477,7 @@ public function testfindTaggedServiceIds() 'foo' => array( array('foo' => 'foo'), array('foofoo' => 'foofoo'), - ) + ), ), '->findTaggedServiceIds() returns an array of service ids and its tag attributes'); $this->assertEquals(array(), $builder->findTaggedServiceIds('foobar'), '->findTaggedServiceIds() returns an empty array if there is annotated services'); } @@ -659,7 +659,7 @@ public function testPrivateServiceUser() $container->addDefinitions(array( 'bar' => $fooDefinition, - 'bar_user' => $fooUserDefinition + 'bar_user' => $fooUserDefinition, )); $container->compile(); @@ -820,7 +820,9 @@ public function testLazyLoadedService() } } -class FooClass {} +class FooClass +{ +} class ProjectContainer extends ContainerBuilder { diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php index e145c7a10c1aa..314f3e61f1256 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php @@ -228,7 +228,6 @@ public function testGetThrowServiceNotFoundException() public function testGetCircularReference() { - $sc = new ProjectServiceContainer(); try { $sc->get('circular'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index 1a64508413c55..1900af1851619 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -62,7 +62,7 @@ public function testDumpOptimizationString() 'concatenation from the start value' => '\'\'.', '.' => 'dot as a key', '.\'\'.' => 'concatenation as a key', - '\'\'.' =>'concatenation from the start key', + '\'\'.' => 'concatenation from the start key', 'optimize concatenation' => "string1%some_string%string2", 'optimize concatenation with empty string' => "string1%empty_value%string2", 'optimize concatenation from the start' => '%empty_value%start', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php b/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php index e35bbd5d3c8ad..e7f19a6e94dc9 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php @@ -54,7 +54,7 @@ public function getResolvedEnabledFixtures() { return array( array(true), - array(false) + array(false), ); } diff --git a/src/Symfony/Component/DomCrawler/FormFieldRegistry.php b/src/Symfony/Component/DomCrawler/FormFieldRegistry.php index 150f94dfc6879..39d4774a08bff 100644 --- a/src/Symfony/Component/DomCrawler/FormFieldRegistry.php +++ b/src/Symfony/Component/DomCrawler/FormFieldRegistry.php @@ -33,16 +33,16 @@ public function add(FormField $field) { $segments = $this->getSegments($field->getName()); - $target =& $this->fields; + $target = & $this->fields; while ($segments) { if (!is_array($target)) { $target = array(); } $path = array_shift($segments); if ('' === $path) { - $target =& $target[]; + $target = & $target[]; } else { - $target =& $target[$path]; + $target = & $target[$path]; } } $target = $field; @@ -58,13 +58,13 @@ public function add(FormField $field) public function remove($name) { $segments = $this->getSegments($name); - $target =& $this->fields; + $target = & $this->fields; while (count($segments) > 1) { $path = array_shift($segments); if (!array_key_exists($path, $target)) { return; } - $target =& $target[$path]; + $target = & $target[$path]; } unset($target[array_shift($segments)]); } @@ -82,13 +82,13 @@ public function remove($name) public function &get($name) { $segments = $this->getSegments($name); - $target =& $this->fields; + $target = & $this->fields; while ($segments) { $path = array_shift($segments); if (!array_key_exists($path, $target)) { throw new \InvalidArgumentException(sprintf('Unreachable field "%s"', $path)); } - $target =& $target[$path]; + $target = & $target[$path]; } return $target; @@ -123,7 +123,7 @@ public function has($name) */ public function set($name, $value) { - $target =& $this->get($name); + $target = & $this->get($name); if (!is_array($value) || $target instanceof Field\ChoiceFormField) { $target->setValue($value); } else { diff --git a/src/Symfony/Component/DomCrawler/Tests/Field/FileFormFieldTest.php b/src/Symfony/Component/DomCrawler/Tests/Field/FileFormFieldTest.php index 066cdb0ef3258..3ce49a46ef732 100644 --- a/src/Symfony/Component/DomCrawler/Tests/Field/FileFormFieldTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/Field/FileFormFieldTest.php @@ -111,5 +111,4 @@ public function testSetRawFilePath() $this->assertEquals(__FILE__, $field->getValue()); } - } diff --git a/src/Symfony/Component/DomCrawler/Tests/FormTest.php b/src/Symfony/Component/DomCrawler/Tests/FormTest.php index 019581385837a..4a556c6eea4d2 100644 --- a/src/Symfony/Component/DomCrawler/Tests/FormTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/FormTest.php @@ -132,13 +132,13 @@ public function testConstructorHandlesFormValues() 'apples' => array('1', '2'), 'form_name' => 'form-1', 'button_1' => 'Capture fields', - 'outer_field' => 'success' + 'outer_field' => 'success', ); $values2 = array( 'oranges' => array('1', '2', '3'), 'form_name' => 'form_2', 'button_2' => '', - 'app_frontend_form_type_contact_form_type' => array('contactType' => '', 'firstName' => 'John') + 'app_frontend_form_type_contact_form_type' => array('contactType' => '', 'firstName' => 'John'), ); $this->assertEquals($values1, $form1->getPhpValues(), 'HTML5-compliant form attribute handled incorrectly'); @@ -178,7 +178,6 @@ public function testMultiValuedFields() $this->assertEquals($form->get('bar[foo][0]')->getValue(), 'bar'); $this->assertEquals($form->get('bar[foo][foobar]')->getValue(), 'foobar'); - } /** @@ -414,7 +413,6 @@ public function testGetPhpValues() $form = $this->createForm('
    '); $this->assertEquals(array('foo' => array('bar' => 'foo'), 'bar' => 'bar'), $form->getPhpValues(), "->getPhpValues() doesn't return empty values"); - } public function testGetFiles() @@ -480,7 +478,7 @@ public function testGetUriWithAnchor() public function testGetUriActionAbsolute() { - $formHtml='
    '; + $formHtml = '
    '; $form = $this->createForm($formHtml); $this->assertEquals('https://login.foo.com/login.php?login_attempt=1', $form->getUri(), '->getUri() returns absolute URIs set in the action form'); @@ -527,52 +525,52 @@ public function provideGetUriValues() 'returns the URI of the form', '
    ', array(), - '/foo' + '/foo', ), array( 'appends the form values if the method is get', '
    ', array(), - '/foo?foo=foo' + '/foo?foo=foo', ), array( 'appends the form values and merges the submitted values', '
    ', array('foo' => 'bar'), - '/foo?foo=bar' + '/foo?foo=bar', ), array( 'does not append values if the method is post', '
    ', array(), - '/foo' + '/foo', ), array( 'does not append values if the method is patch', '
    ', array(), '/foo', - 'PUT' + 'PUT', ), array( 'does not append values if the method is delete', '
    ', array(), '/foo', - 'DELETE' + 'DELETE', ), array( 'does not append values if the method is put', '
    ', array(), '/foo', - 'PATCH' + 'PATCH', ), array( 'appends the form values to an existing query string', '
    ', array(), - '/foo?bar=bar&foo=foo' + '/foo?bar=bar&foo=foo', ), array( 'returns an empty URI if the action is empty', @@ -777,8 +775,8 @@ public function testFormRegistrySetValues() 2 => 2, 3 => 3, 'bar' => array( - 'baz' => 'fbb' - ) + 'baz' => 'fbb', + ), )); } @@ -908,8 +906,8 @@ protected function createTestMultipleForm() public function testgetPhpValuesWithEmptyTextarea() { - $dom = new \DOMDocument(); - $dom->loadHTML(' + $dom = new \DOMDocument(); + $dom->loadHTML('
    @@ -917,8 +915,8 @@ public function testgetPhpValuesWithEmptyTextarea() '); - $nodes = $dom->getElementsByTagName('form'); - $form = new Form($nodes->item(0), 'http://example.com'); - $this->assertEquals($form->getPhpValues(), array('example' => '')); + $nodes = $dom->getElementsByTagName('form'); + $form = new Form($nodes->item(0), 'http://example.com'); + $this->assertEquals($form->getPhpValues(), array('example' => '')); } } diff --git a/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php index 1053c290ee694..375e0f1c3b6ad 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php @@ -340,7 +340,7 @@ public static function getSubscribedEvents() { return array('pre.foo' => array( array('preFoo1'), - array('preFoo2', 10) + array('preFoo2', 10), )); } } diff --git a/src/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php b/src/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php index 5dfda92f2af48..1090bcb29609e 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php @@ -18,7 +18,6 @@ */ class GenericEventTest extends \PHPUnit_Framework_TestCase { - /** * @var GenericEvent */ diff --git a/src/Symfony/Component/Filesystem/Exception/ExceptionInterface.php b/src/Symfony/Component/Filesystem/Exception/ExceptionInterface.php index bc9748d752e71..c212e664d487a 100644 --- a/src/Symfony/Component/Filesystem/Exception/ExceptionInterface.php +++ b/src/Symfony/Component/Filesystem/Exception/ExceptionInterface.php @@ -20,5 +20,4 @@ */ interface ExceptionInterface { - } diff --git a/src/Symfony/Component/Filesystem/Exception/IOException.php b/src/Symfony/Component/Filesystem/Exception/IOException.php index 5b27e661eee38..ae7e6ff9e5cfd 100644 --- a/src/Symfony/Component/Filesystem/Exception/IOException.php +++ b/src/Symfony/Component/Filesystem/Exception/IOException.php @@ -20,5 +20,4 @@ */ class IOException extends \RuntimeException implements ExceptionInterface { - } diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index 054ca7bbd4b69..76988d0e68691 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -195,7 +195,7 @@ public function testMkdirCreatesDirectoriesFromArray() { $basePath = $this->workspace.DIRECTORY_SEPARATOR; $directories = array( - $basePath.'1', $basePath.'2', $basePath.'3' + $basePath.'1', $basePath.'2', $basePath.'3', ); $this->filesystem->mkdir($directories); @@ -209,7 +209,7 @@ public function testMkdirCreatesDirectoriesFromTraversableObject() { $basePath = $this->workspace.DIRECTORY_SEPARATOR; $directories = new \ArrayObject(array( - $basePath.'1', $basePath.'2', $basePath.'3' + $basePath.'1', $basePath.'2', $basePath.'3', )); $this->filesystem->mkdir($directories); @@ -255,7 +255,7 @@ public function testTouchCreatesEmptyFilesFromArray() { $basePath = $this->workspace.DIRECTORY_SEPARATOR; $files = array( - $basePath.'1', $basePath.'2', $basePath.'3' + $basePath.'1', $basePath.'2', $basePath.'3', ); $this->filesystem->touch($files); @@ -269,7 +269,7 @@ public function testTouchCreatesEmptyFilesFromTraversableObject() { $basePath = $this->workspace.DIRECTORY_SEPARATOR; $files = new \ArrayObject(array( - $basePath.'1', $basePath.'2', $basePath.'3' + $basePath.'1', $basePath.'2', $basePath.'3', )); $this->filesystem->touch($files); @@ -300,7 +300,7 @@ public function testRemoveCleansArrayOfFilesAndDirectories() touch($basePath.'file'); $files = array( - $basePath.'dir', $basePath.'file' + $basePath.'dir', $basePath.'file', ); $this->filesystem->remove($files); @@ -317,7 +317,7 @@ public function testRemoveCleansTraversableObjectOfFilesAndDirectories() touch($basePath.'file'); $files = new \ArrayObject(array( - $basePath.'dir', $basePath.'file' + $basePath.'dir', $basePath.'file', )); $this->filesystem->remove($files); @@ -333,7 +333,7 @@ public function testRemoveIgnoresNonExistingFiles() mkdir($basePath.'dir'); $files = array( - $basePath.'dir', $basePath.'file' + $basePath.'dir', $basePath.'file', ); $this->filesystem->remove($files); @@ -377,7 +377,7 @@ public function testFilesExistsTraversableObjectOfFilesAndDirectories() touch($basePath.'file'); $files = new \ArrayObject(array( - $basePath.'dir', $basePath.'file' + $basePath.'dir', $basePath.'file', )); $this->assertTrue($this->filesystem->exists($files)); @@ -392,7 +392,7 @@ public function testFilesNotExistsTraversableObjectOfFilesAndDirectories() touch($basePath.'file2'); $files = new \ArrayObject(array( - $basePath.'dir', $basePath.'file', $basePath.'file2' + $basePath.'dir', $basePath.'file', $basePath.'file2', )); unlink($basePath.'file'); @@ -906,7 +906,7 @@ public function providePathsForIsAbsolutePath() array('var/lib', false), array('../var/lib', false), array('', false), - array(null, false) + array(null, false), ); } diff --git a/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php b/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php index 7f2a52fbcd810..7fdd94be7bf07 100644 --- a/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php +++ b/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php @@ -247,7 +247,7 @@ private function buildSizesFiltering(Command $command, array $sizes) $command->add('-size -'.($size->getTarget() + 1).'c'); break; case '>=': - $command->add('-size +'. ($size->getTarget() - 1).'c'); + $command->add('-size +'.($size->getTarget() - 1).'c'); break; case '>': $command->add('-size +'.$size->getTarget().'c'); diff --git a/src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php b/src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php index b72451ee182fc..0fbf48ffa40f4 100644 --- a/src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php +++ b/src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php @@ -80,7 +80,7 @@ protected function canBeUsed() */ protected function buildFindCommand(Command $command, $dir) { - return parent::buildFindCommand($command, $dir)->add('-regextype posix-extended'); + return parent::buildFindCommand($command, $dir)->add('-regextype posix-extended'); } /** diff --git a/src/Symfony/Component/Finder/Comparator/DateComparator.php b/src/Symfony/Component/Finder/Comparator/DateComparator.php index 9de444f0521d0..8b7746badbe99 100644 --- a/src/Symfony/Component/Finder/Comparator/DateComparator.php +++ b/src/Symfony/Component/Finder/Comparator/DateComparator.php @@ -18,7 +18,6 @@ */ class DateComparator extends Comparator { - /** * Constructor. * diff --git a/src/Symfony/Component/Finder/Expression/Regex.php b/src/Symfony/Component/Finder/Expression/Regex.php index 2e8f507b48f35..c019d4a1a247f 100644 --- a/src/Symfony/Component/Finder/Expression/Regex.php +++ b/src/Symfony/Component/Finder/Expression/Regex.php @@ -178,7 +178,7 @@ public function hasOption($option) public function addOption($option) { if (!$this->hasOption($option)) { - $this->options.= $option; + $this->options .= $option; } return $this; diff --git a/src/Symfony/Component/Finder/Finder.php b/src/Symfony/Component/Finder/Finder.php index db4d8517405df..9dccf6e655958 100644 --- a/src/Symfony/Component/Finder/Finder.php +++ b/src/Symfony/Component/Finder/Finder.php @@ -783,7 +783,8 @@ private function searchInDirectory($dir) return $this ->buildAdapter($adapter['adapter']) ->searchInDirectory($dir); - } catch (ExceptionInterface $e) {} + } catch (ExceptionInterface $e) { + } } } diff --git a/src/Symfony/Component/Finder/Iterator/FilenameFilterIterator.php b/src/Symfony/Component/Finder/Iterator/FilenameFilterIterator.php index c4e0ccd8e42da..886537c1554d2 100644 --- a/src/Symfony/Component/Finder/Iterator/FilenameFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/FilenameFilterIterator.php @@ -20,7 +20,6 @@ */ class FilenameFilterIterator extends MultiplePcreFilterIterator { - /** * Filters the iterator values. * diff --git a/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php b/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php index 828fa41876031..db86faa2c9ee5 100644 --- a/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php @@ -19,7 +19,6 @@ */ class PathFilterIterator extends MultiplePcreFilterIterator { - /** * Filters the iterator values. * diff --git a/src/Symfony/Component/Finder/Tests/Comparator/DateComparatorTest.php b/src/Symfony/Component/Finder/Tests/Comparator/DateComparatorTest.php index ac8256ab86012..273912635e33e 100644 --- a/src/Symfony/Component/Finder/Tests/Comparator/DateComparatorTest.php +++ b/src/Symfony/Component/Finder/Tests/Comparator/DateComparatorTest.php @@ -59,6 +59,5 @@ public function getTestData() array('since 2005-10-10', array(strtotime('2005-10-15')), array(strtotime('2005-10-09'))), array('!= 2005-10-10', array(strtotime('2005-10-11')), array(strtotime('2005-10-10'))), ); - } } diff --git a/src/Symfony/Component/Finder/Tests/Comparator/NumberComparatorTest.php b/src/Symfony/Component/Finder/Tests/Comparator/NumberComparatorTest.php index b07870ba81aa4..d8cef1b5b47dd 100644 --- a/src/Symfony/Component/Finder/Tests/Comparator/NumberComparatorTest.php +++ b/src/Symfony/Component/Finder/Tests/Comparator/NumberComparatorTest.php @@ -15,7 +15,6 @@ class NumberComparatorTest extends \PHPUnit_Framework_TestCase { - /** * @dataProvider getConstructorTestData */ @@ -101,9 +100,8 @@ public function getConstructorTestData() '=1', '===1', '0 . 1', '123 .45', '234. 567', '..', '.0.', '0.1.2', - ) + ), ), ); } - } diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index 598821d24f521..0711f7e7a31da 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -673,7 +673,7 @@ public function getTestPathData() $tests = array( array('', '', array()), array('/^A\/B\/C/', '/C$/', - array('A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat') + array('A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat'), ), array('/^A\/B/', 'foobar', array( @@ -681,7 +681,7 @@ public function getTestPathData() 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C', 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'ab.dat', 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat', - ) + ), ), array('A/B/C', 'foobar', array( @@ -689,7 +689,7 @@ public function getTestPathData() 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat', 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C', 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat.copy', - ) + ), ), array('A/B', 'foobar', array( @@ -703,12 +703,12 @@ public function getTestPathData() 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat', 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'ab.dat.copy', 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat.copy', - ) + ), ), array('/^with space\//', 'foobar', array( 'with space'.DIRECTORY_SEPARATOR.'foo.txt', - ) + ), ), ); @@ -808,7 +808,7 @@ private function getValidAdapters() array( new Adapter\BsdFindAdapter(), new Adapter\GnuFindAdapter(), - new Adapter\PhpAdapter() + new Adapter\PhpAdapter(), ), function (Adapter\AdapterInterface $adapter) { return $adapter->isSupported(); diff --git a/src/Symfony/Component/Finder/Tests/Iterator/DepthRangeFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/DepthRangeFilterIteratorTest.php index be06f1cdd34cd..5ec983247df94 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/DepthRangeFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/DepthRangeFilterIteratorTest.php @@ -77,5 +77,4 @@ public function getAcceptData() array(1, 1, $this->toAbsolute($equalTo1)), ); } - } diff --git a/src/Symfony/Component/Finder/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php index e299fe731f3b6..693b73319aa17 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php @@ -39,7 +39,7 @@ public function getAcceptData() 'test.py', 'test.php', 'toto', - 'foo bar' + 'foo bar', ); $fo = array( @@ -53,7 +53,7 @@ public function getAcceptData() 'foo/bar.tmp', 'test.php', 'toto', - 'foo bar' + 'foo bar', ); return array( @@ -61,5 +61,4 @@ public function getAcceptData() array(array('fo'), $this->toAbsolute($fo)), ); } - } diff --git a/src/Symfony/Component/Finder/Tests/Iterator/FilePathsIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/FilePathsIteratorTest.php index 61f0e9b22952a..d2f0e245f61b2 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/FilePathsIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/FilePathsIteratorTest.php @@ -42,7 +42,7 @@ public function getSubPathData() $tmpDir.DIRECTORY_SEPARATOR.'foo' => $tmpDir.DIRECTORY_SEPARATOR.'foo', $tmpDir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.tmp' => $tmpDir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.tmp', $tmpDir.DIRECTORY_SEPARATOR.'test.php' => $tmpDir.DIRECTORY_SEPARATOR.'test.php', - $tmpDir.DIRECTORY_SEPARATOR.'toto' => $tmpDir.DIRECTORY_SEPARATOR.'toto' + $tmpDir.DIRECTORY_SEPARATOR.'toto' => $tmpDir.DIRECTORY_SEPARATOR.'toto', ), array( // subPaths $tmpDir.DIRECTORY_SEPARATOR.'.git' => '', @@ -50,7 +50,7 @@ public function getSubPathData() $tmpDir.DIRECTORY_SEPARATOR.'foo' => '', $tmpDir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.tmp' => 'foo', $tmpDir.DIRECTORY_SEPARATOR.'test.php' => '', - $tmpDir.DIRECTORY_SEPARATOR.'toto' => '' + $tmpDir.DIRECTORY_SEPARATOR.'toto' => '', ), array( // subPathnames $tmpDir.DIRECTORY_SEPARATOR.'.git' => '.git', @@ -58,7 +58,7 @@ public function getSubPathData() $tmpDir.DIRECTORY_SEPARATOR.'foo' => 'foo', $tmpDir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.tmp' => 'foo'.DIRECTORY_SEPARATOR.'bar.tmp', $tmpDir.DIRECTORY_SEPARATOR.'test.php' => 'test.php', - $tmpDir.DIRECTORY_SEPARATOR.'toto' => 'toto' + $tmpDir.DIRECTORY_SEPARATOR.'toto' => 'toto', ), ), ); diff --git a/src/Symfony/Component/Finder/Tests/Iterator/FileTypeFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/FileTypeFilterIteratorTest.php index b2432ca3ff9fe..cfa8684fdf7df 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/FileTypeFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/FileTypeFilterIteratorTest.php @@ -55,7 +55,7 @@ public function getAcceptData() class InnerTypeIterator extends \ArrayIterator { - public function current() + public function current() { return new \SplFileInfo(parent::current()); } diff --git a/src/Symfony/Component/Finder/Tests/Iterator/FilecontentFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/FilecontentFilterIteratorTest.php index dbc05b5eceac2..d3be8c64893a5 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/FilecontentFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/FilecontentFilterIteratorTest.php @@ -15,7 +15,6 @@ class FilecontentFilterIteratorTest extends IteratorTestCase { - public function testAccept() { $inner = new MockFileListIterator(array('test.txt')); @@ -54,28 +53,28 @@ public function getTestFilterData() 'name' => 'a.txt', 'contents' => 'Lorem ipsum...', 'type' => 'file', - 'mode' => 'r+') + 'mode' => 'r+',) ); $inner[] = new MockSplFileInfo(array( 'name' => 'b.yml', 'contents' => 'dolor sit...', 'type' => 'file', - 'mode' => 'r+') + 'mode' => 'r+',) ); $inner[] = new MockSplFileInfo(array( 'name' => 'some/other/dir/third.php', 'contents' => 'amet...', 'type' => 'file', - 'mode' => 'r+') + 'mode' => 'r+',) ); $inner[] = new MockSplFileInfo(array( 'name' => 'unreadable-file.txt', 'contents' => false, 'type' => 'file', - 'mode' => 'r+') + 'mode' => 'r+',) ); return array( diff --git a/src/Symfony/Component/Finder/Tests/Iterator/PathFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/PathFilterIteratorTest.php index 6f83e44029fae..c64ec2b1f5fcd 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/PathFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/PathFilterIteratorTest.php @@ -15,7 +15,6 @@ class PathFilterIteratorTest extends IteratorTestCase { - /** * @dataProvider getTestFilterData */ @@ -81,5 +80,4 @@ public function getTestFilterData() ); } - } diff --git a/src/Symfony/Component/Finder/Tests/Iterator/RealIteratorTestCase.php b/src/Symfony/Component/Finder/Tests/Iterator/RealIteratorTestCase.php index 65edb1e46578f..8aa5c89d82fc2 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/RealIteratorTestCase.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/RealIteratorTestCase.php @@ -13,7 +13,6 @@ abstract class RealIteratorTestCase extends IteratorTestCase { - protected static $tmpDir; protected static $files; @@ -32,7 +31,7 @@ public static function setUpBeforeClass() 'foo/bar.tmp', 'test.php', 'toto/', - 'foo bar' + 'foo bar', ); self::$files = self::toAbsolute(self::$files); @@ -103,5 +102,4 @@ protected static function toAbsoluteFixtures($files) return $f; } - } diff --git a/src/Symfony/Component/Finder/Tests/Iterator/SizeRangeFilterIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/SizeRangeFilterIteratorTest.php index 726df9e3006d6..8780db4da1ca1 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/SizeRangeFilterIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/SizeRangeFilterIteratorTest.php @@ -46,7 +46,7 @@ public function getAcceptData() class InnerSizeIterator extends \ArrayIterator { - public function current() + public function current() { return new \SplFileInfo(parent::current()); } diff --git a/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php b/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php index a2ca6ef3768a1..f4def17a18376 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/SortableIteratorTest.php @@ -59,7 +59,6 @@ public function testAccept($mode, $expected) public function getAcceptData() { - $sortByName = array( '.bar', '.foo', @@ -113,7 +112,7 @@ public function getAcceptData() '.foo/.bar', '.foo/bar', '.git', - '.bar' + '.bar', ); $sortByChangedTime = array( @@ -127,7 +126,7 @@ public function getAcceptData() '.foo/.bar', '.foo/bar', 'test.php', - 'test.py' + 'test.py', ); $sortByModifiedTime = array( @@ -141,7 +140,7 @@ public function getAcceptData() '.foo/.bar', '.foo/bar', 'test.php', - 'test.py' + 'test.py', ); return array( diff --git a/src/Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php b/src/Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php index d07f3f15e64c1..2208f26d1e5d4 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php +++ b/src/Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php @@ -81,7 +81,6 @@ public function mapFormsToData($forms, &$data) // Write-back is disabled if the form is not synchronized (transformation failed), // if the form was not submitted and if the form is disabled (modification not allowed) if (null !== $propertyPath && $config->getMapped() && $form->isSubmitted() && $form->isSynchronized() && !$form->isDisabled()) { - // If the field is of type DateTime and the data is the same skip the update to // keep the original object hash if ($form->getData() instanceof \DateTime && $form->getData() == $this->propertyAccessor->getValue($data, $propertyPath)) { diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/BooleanToStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/BooleanToStringTransformer.php index d839427877c3e..38c9bb273bd3a 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/BooleanToStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/BooleanToStringTransformer.php @@ -81,5 +81,4 @@ public function reverseTransform($value) return true; } - } diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php index a9ea5e761f0a2..11ffd3791d4b9 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php @@ -161,16 +161,16 @@ public function reverseTransform($value) // Check which of the date parts are present in the pattern preg_match( - '/(' . - '(?P[djDl])|' . - '(?P[FMmn])|' . - '(?P[Yy])|' . - '(?P[ghGH])|' . - '(?Pi)|' . - '(?Ps)|' . - '(?Pz)|' . - '(?PU)|' . - '[^djDlFMmnYyghGHiszU]' . + '/('. + '(?P[djDl])|'. + '(?P[FMmn])|'. + '(?P[Yy])|'. + '(?P[ghGH])|'. + '(?Pi)|'. + '(?Ps)|'. + '(?Pz)|'. + '(?PU)|'. + '[^djDlFMmnYyghGHiszU]'. ')*/', $this->parseFormat, $matches diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php index d746961d2de08..d70c08a8aa84d 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php @@ -85,5 +85,4 @@ public function reverseTransform($value) return $value; } - } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index 712f5b6de8fe1..08504dea2bec1 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -159,7 +159,7 @@ public function finishView(FormView $view, FormInterface $form, array $options) */ public function setDefaultOptions(OptionsResolverInterface $resolver) { - $choiceListCache =& $this->choiceListCache; + $choiceListCache = & $this->choiceListCache; $choiceList = function (Options $options) use (&$choiceListCache) { // Harden against NULL values (like in EntityType and ModelType) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php index 1748d2e31f6bb..6d90e557146bd 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php @@ -187,7 +187,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver) return array( 'year' => $emptyValue, 'month' => $emptyValue, - 'day' => $emptyValue + 'day' => $emptyValue, ); }; diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php index 6bf41517ac0d7..3585b5bd3149f 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php @@ -177,7 +177,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver) return array( 'hour' => $emptyValue, 'minute' => $emptyValue, - 'second' => $emptyValue + 'second' => $emptyValue, ); }; diff --git a/src/Symfony/Component/Form/Extension/Templating/TemplatingExtension.php b/src/Symfony/Component/Form/Extension/Templating/TemplatingExtension.php index 573cb518d4c96..1e56f0c6b6b15 100644 --- a/src/Symfony/Component/Form/Extension/Templating/TemplatingExtension.php +++ b/src/Symfony/Component/Form/Extension/Templating/TemplatingExtension.php @@ -27,7 +27,7 @@ class TemplatingExtension extends AbstractExtension public function __construct(PhpEngine $engine, CsrfProviderInterface $csrfProvider = null, array $defaultThemes = array()) { $engine->addHelpers(array( - new FormHelper(new FormRenderer(new TemplatingRendererEngine($engine, $defaultThemes), $csrfProvider)) + new FormHelper(new FormRenderer(new TemplatingRendererEngine($engine, $defaultThemes), $csrfProvider)), )); } } diff --git a/src/Symfony/Component/Form/Extension/Validator/Util/ServerParams.php b/src/Symfony/Component/Form/Extension/Validator/Util/ServerParams.php index 93a1dd7d6fe2c..58fdc25e229c7 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Util/ServerParams.php +++ b/src/Symfony/Component/Form/Extension/Validator/Util/ServerParams.php @@ -69,5 +69,4 @@ public function getContentLength() ? (int) $_SERVER['CONTENT_LENGTH'] : null; } - } diff --git a/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php b/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php index 63d06dca71856..589fc12a36c8f 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php +++ b/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php @@ -196,7 +196,7 @@ public function guessMaxLengthForConstraint(Constraint $constraint) case 'Symfony\Component\Validator\Constraints\Type': if (in_array($constraint->type, array('double', 'float', 'numeric', 'real'))) { - return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE); + return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE); } break; diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index a94a679f9daf6..3f3fe88241bcf 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -351,20 +351,20 @@ public function setData($modelData) $expectedType = 'scalar, array or an instance of \ArrayAccess'; throw new LogicException( - 'The form\'s view data is expected to be of type '.$expectedType.', ' . - 'but is '.$actualType.'. You ' . - 'can avoid this error by setting the "data_class" option to ' . - '"'.get_class($viewData).'" or by adding a view transformer ' . + 'The form\'s view data is expected to be of type '.$expectedType.', '. + 'but is '.$actualType.'. You '. + 'can avoid this error by setting the "data_class" option to '. + '"'.get_class($viewData).'" or by adding a view transformer '. 'that transforms '.$actualType.' to '.$expectedType.'.' ); } if (null !== $dataClass && !$viewData instanceof $dataClass) { throw new LogicException( - 'The form\'s view data is expected to be an instance of class ' . - $dataClass.', but is '. $actualType.'. You can avoid this error ' . - 'by setting the "data_class" option to null or by adding a view ' . - 'transformer that transforms '.$actualType.' to an instance of ' . + 'The form\'s view data is expected to be an instance of class '. + $dataClass.', but is '.$actualType.'. You can avoid this error '. + 'by setting the "data_class" option to null or by adding a view '. + 'transformer that transforms '.$actualType.' to an instance of '. $dataClass.'.' ); } diff --git a/src/Symfony/Component/Form/FormConfigBuilder.php b/src/Symfony/Component/Form/FormConfigBuilder.php index 733b79dfdd3ff..1d70a49644568 100644 --- a/src/Symfony/Component/Form/FormConfigBuilder.php +++ b/src/Symfony/Component/Form/FormConfigBuilder.php @@ -44,7 +44,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface 'PUT', 'POST', 'DELETE', - 'PATCH' + 'PATCH', ); /** diff --git a/src/Symfony/Component/Form/NativeRequestHandler.php b/src/Symfony/Component/Form/NativeRequestHandler.php index c76534473cbb2..fefe546af8899 100644 --- a/src/Symfony/Component/Form/NativeRequestHandler.php +++ b/src/Symfony/Component/Form/NativeRequestHandler.php @@ -155,7 +155,7 @@ private static function fixPhpFilesArray($data) 'name' => $data['name'][$key], 'type' => $data['type'][$key], 'tmp_name' => $data['tmp_name'][$key], - 'size' => $data['size'][$key] + 'size' => $data['size'][$key], )); } diff --git a/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php index ee9ed8f2a6a77..21ea55833aa94 100644 --- a/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php @@ -525,7 +525,7 @@ public function testRepeatedWithCustomOptions() $form = $this->factory->createNamed('name', 'repeated', null, array( // the global required value cannot be overridden 'first_options' => array('label' => 'Test', 'required' => false), - 'second_options' => array('label' => 'Test2') + 'second_options' => array('label' => 'Test2'), )); $this->assertWidgetMatchesXpath($form->createView(), array(), @@ -587,7 +587,7 @@ public function testLabelHasNoId() public function testLabelIsNotRenderedWhenSetToFalse() { $form = $this->factory->createNamed('name', 'text', null, array( - 'label' => false + 'label' => false, )); $html = $this->renderRow($form->createView()); @@ -698,7 +698,7 @@ public function testFormEndWithRest() $html = $this->renderEnd($view); // Insert the start tag, the end tag should be rendered by the helper - $this->assertMatchesXpath('' . $html, + $this->assertMatchesXpath(''.$html, '/form [ ./div diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index 9e3647a2b24a3..5439bd096f73c 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -215,7 +215,7 @@ public function testLabelDoesNotRenderFieldAttributes() $form = $this->factory->createNamed('name', 'text'); $html = $this->renderLabel($form->createView(), null, array( 'attr' => array( - 'class' => 'my&class' + 'class' => 'my&class', ), )); @@ -232,7 +232,7 @@ public function testLabelWithCustomAttributesPassedDirectly() $form = $this->factory->createNamed('name', 'text'); $html = $this->renderLabel($form->createView(), null, array( 'label_attr' => array( - 'class' => 'my&class' + 'class' => 'my&class', ), )); @@ -249,7 +249,7 @@ public function testLabelWithCustomTextAndCustomAttributesPassedDirectly() $form = $this->factory->createNamed('name', 'text'); $html = $this->renderLabel($form->createView(), 'Custom label', array( 'label_attr' => array( - 'class' => 'my&class' + 'class' => 'my&class', ), )); @@ -270,7 +270,7 @@ public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly )); $html = $this->renderLabel($form->createView(), null, array( 'label_attr' => array( - 'class' => 'my&class' + 'class' => 'my&class', ), )); @@ -555,7 +555,7 @@ public function testSingleChoiceRequiredWithEmptyValue() 'required' => true, 'multiple' => false, 'expanded' => false, - 'empty_value' => 'Test&Me' + 'empty_value' => 'Test&Me', )); // The "disabled" attribute was removed again due to a bug in the @@ -660,7 +660,7 @@ public function testMultipleChoiceSkipsEmptyValue() 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'multiple' => true, 'expanded' => false, - 'empty_value' => 'Test&Me' + 'empty_value' => 'Test&Me', )); $this->assertWidgetMatchesXpath($form->createView(), array(), @@ -726,7 +726,7 @@ public function testSingleChoiceExpandedWithEmptyValue() 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), 'multiple' => false, 'expanded' => true, - 'empty_value' => 'Test&Me' + 'empty_value' => 'Test&Me', )); $this->assertWidgetMatchesXpath($form->createView(), array(), @@ -1825,7 +1825,7 @@ public function testStartTag() { $form = $this->factory->create('form', null, array( 'method' => 'get', - 'action' => 'http://example.com/directory' + 'action' => 'http://example.com/directory', )); $html = $this->renderStart($form->createView()); @@ -1837,12 +1837,12 @@ public function testStartTagForPutRequest() { $form = $this->factory->create('form', null, array( 'method' => 'put', - 'action' => 'http://example.com/directory' + 'action' => 'http://example.com/directory', )); $html = $this->renderStart($form->createView()); - $this->assertMatchesXpath($html . '', + $this->assertMatchesXpath($html.'', '/form [./input[@type="hidden"][@name="_method"][@value="PUT"]] [@method="post"] @@ -1859,7 +1859,7 @@ public function testStartTagWithOverriddenVars() $html = $this->renderStart($form->createView(), array( 'method' => 'post', - 'action' => 'http://foo.com/directory' + 'action' => 'http://foo.com/directory', )); $this->assertSame('
    ', $html); @@ -1869,7 +1869,7 @@ public function testStartTagForMultipartForm() { $form = $this->factory->createBuilder('form', null, array( 'method' => 'get', - 'action' => 'http://example.com/directory' + 'action' => 'http://example.com/directory', )) ->add('file', 'file') ->getForm(); @@ -1883,7 +1883,7 @@ public function testStartTagWithExtraAttributes() { $form = $this->factory->create('form', null, array( 'method' => 'get', - 'action' => 'http://example.com/directory' + 'action' => 'http://example.com/directory', )); $html = $this->renderStart($form->createView(), array( diff --git a/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php index 5c91195169951..25fa504a53f75 100644 --- a/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php @@ -42,7 +42,7 @@ public function testRow() public function testLabelIsNotRenderedWhenSetToFalse() { $form = $this->factory->createNamed('name', 'text', null, array( - 'label' => false + 'label' => false, )); $html = $this->renderRow($form->createView()); @@ -401,7 +401,7 @@ public function testRepeatedWithCustomOptions() $form = $this->factory->createNamed('name', 'repeated', 'foobar', array( 'type' => 'password', 'first_options' => array('label' => 'Test', 'required' => false), - 'second_options' => array('label' => 'Test2') + 'second_options' => array('label' => 'Test2'), )); $this->assertWidgetMatchesXpath($form->createView(), array(), @@ -471,7 +471,7 @@ public function testFormEndWithRest() // tag is missing. If someone renders a form with table layout // manually, she should call form_rest() explicitly within the
    + errors($form) ?> +
    // tag. - $this->assertMatchesXpath('' . $html, + $this->assertMatchesXpath(''.$html, '/form [ ./tr diff --git a/src/Symfony/Component/Form/Tests/CallbackTransformerTest.php b/src/Symfony/Component/Form/Tests/CallbackTransformerTest.php index 706bc076ec2cb..7f3b074e785d1 100644 --- a/src/Symfony/Component/Form/Tests/CallbackTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/CallbackTransformerTest.php @@ -9,8 +9,8 @@ class CallbackTransformerTest extends \PHPUnit_Framework_TestCase public function testTransform() { $transformer = new CallbackTransformer( - function($value) { return $value.' has been transformed'; }, - function($value) { return $value.' has reversely been transformed'; } + function ($value) { return $value.' has been transformed'; }, + function ($value) { return $value.' has reversely been transformed'; } ); $this->assertEquals('foo has been transformed', $transformer->transform('foo')); @@ -30,8 +30,8 @@ public function testConstructorWithInvalidCallbacks($transformCallback, $reverse public function invalidCallbacksProvider() { return array( - array( null, function(){} ), - array( function(){}, null ), + array( null, function () {} ), + array( function () {}, null ), ); } } diff --git a/src/Symfony/Component/Form/Tests/CompoundFormTest.php b/src/Symfony/Component/Form/Tests/CompoundFormTest.php index 565b6ce646d4b..17c4f3b0bf7ec 100644 --- a/src/Symfony/Component/Form/Tests/CompoundFormTest.php +++ b/src/Symfony/Component/Form/Tests/CompoundFormTest.php @@ -794,7 +794,7 @@ public function testSubmitGetRequestWithEmptyRootFormName() $values = array( 'firstName' => 'Bernhard', 'lastName' => 'Schussek', - 'extra' => 'data' + 'extra' => 'data', ); $request = new Request($values, array(), array(), array(), array(), array( diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ChoiceListTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ChoiceListTest.php index 59f002d8ccb00..538bbc1b3d3a4 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ChoiceListTest.php @@ -60,7 +60,7 @@ public function testInitNestedTraversable() $this->list = new ChoiceList( new \ArrayIterator(array( 'Group' => array($this->obj1, $this->obj2), - 'Not a Group' => $traversableChoice + 'Not a Group' => $traversableChoice, )), array( 'Group' => array('A', 'B'), @@ -72,11 +72,11 @@ public function testInitNestedTraversable() $this->assertSame(array($this->obj1, $this->obj2, $traversableChoice), $this->list->getChoices()); $this->assertSame(array('0', '1', '2'), $this->list->getValues()); $this->assertEquals(array( - 'Group' => array(1 => new ChoiceView($this->obj2, '1', 'B')) + 'Group' => array(1 => new ChoiceView($this->obj2, '1', 'B')), ), $this->list->getPreferredViews()); $this->assertEquals(array( 'Group' => array(0 => new ChoiceView($this->obj1, '0', 'A')), - 2 => new ChoiceView($traversableChoice, '2', 'C') + 2 => new ChoiceView($traversableChoice, '2', 'C'), ), $this->list->getRemainingViews()); } @@ -86,11 +86,11 @@ public function testInitNestedArray() $this->assertSame(array('0', '1', '2', '3'), $this->list->getValues()); $this->assertEquals(array( 'Group 1' => array(1 => new ChoiceView($this->obj2, '1', 'B')), - 'Group 2' => array(2 => new ChoiceView($this->obj3, '2', 'C')) + 'Group 2' => array(2 => new ChoiceView($this->obj3, '2', 'C')), ), $this->list->getPreferredViews()); $this->assertEquals(array( 'Group 1' => array(0 => new ChoiceView($this->obj1, '0', 'A')), - 'Group 2' => array(3 => new ChoiceView($this->obj4, '3', 'D')) + 'Group 2' => array(3 => new ChoiceView($this->obj4, '3', 'D')), ), $this->list->getRemainingViews()); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ObjectChoiceListTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ObjectChoiceListTest.php index 27effd9f5c2c0..2040dfd9e136d 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ObjectChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ObjectChoiceListTest.php @@ -69,11 +69,11 @@ public function testInitNestedArray() $this->assertSame(array('0', '1', '2', '3'), $this->list->getValues()); $this->assertEquals(array( 'Group 1' => array(1 => new ChoiceView($this->obj2, '1', 'B')), - 'Group 2' => array(2 => new ChoiceView($this->obj3, '2', 'C')) + 'Group 2' => array(2 => new ChoiceView($this->obj3, '2', 'C')), ), $this->list->getPreferredViews()); $this->assertEquals(array( 'Group 1' => array(0 => new ChoiceView($this->obj1, '0', 'A')), - 'Group 2' => array(3 => new ChoiceView($this->obj4, '3', 'D')) + 'Group 2' => array(3 => new ChoiceView($this->obj4, '3', 'D')), ), $this->list->getRemainingViews()); } @@ -102,7 +102,7 @@ public function testInitArrayWithGroupPath() $this->assertSame(array('0', '1', '2', '3', '4', '5'), $this->list->getValues()); $this->assertEquals(array( 'Group 1' => array(1 => new ChoiceView($this->obj2, '1', 'B')), - 'Group 2' => array(2 => new ChoiceView($this->obj3, '2', 'C')) + 'Group 2' => array(2 => new ChoiceView($this->obj3, '2', 'C')), ), $this->list->getPreferredViews()); $this->assertEquals(array( 'Group 1' => array(0 => new ChoiceView($this->obj1, '0', 'A')), diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/SimpleChoiceListTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/SimpleChoiceListTest.php index 838a8e0864e41..3a5804ef28e03 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/SimpleChoiceListTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/SimpleChoiceListTest.php @@ -33,11 +33,11 @@ public function testInitNestedArray() $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'), $this->list->getValues()); $this->assertEquals(array( 'Group 1' => array(1 => new ChoiceView('b', 'b', 'B')), - 'Group 2' => array(2 => new ChoiceView('c', 'c', 'C')) + 'Group 2' => array(2 => new ChoiceView('c', 'c', 'C')), ), $this->list->getPreferredViews()); $this->assertEquals(array( 'Group 1' => array(0 => new ChoiceView('a', 'a', 'A')), - 'Group 2' => array(3 => new ChoiceView('d', 'd', 'D')) + 'Group 2' => array(3 => new ChoiceView('d', 'd', 'D')), ), $this->list->getRemainingViews()); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php index 16a7a4ad814ef..a39f53aa70283 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php @@ -65,7 +65,7 @@ public function reverseTransformProvider() // format without seconds, as appears in some browsers array('UTC', 'UTC', '2010-02-03 04:05:00 UTC', '2010-02-03T04:05Z'), array('America/New_York', 'Asia/Hong_Kong', '2010-02-03 04:05:00 America/New_York', '2010-02-03T17:05+08:00'), - array('Europe/Amsterdam', 'Europe/Amsterdam', '2013-08-21 10:30:00 Europe/Amsterdam', '2013-08-21T08:30:00Z') + array('Europe/Amsterdam', 'Europe/Amsterdam', '2013-08-21 10:30:00 Europe/Amsterdam', '2013-08-21T08:30:00Z'), )); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php index 971dd0a738d6c..88115eaaaee43 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php @@ -89,7 +89,6 @@ public function testTransformWithRoundingMode() $transformer = new NumberToLocalizedStringTransformer(2, null, NumberToLocalizedStringTransformer::ROUND_DOWN); $this->assertEquals('1234,54', $transformer->transform(1234.547), '->transform() rounding-mode works'); - } /** diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php index a8a088a95a074..6dc9785c24dc6 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php @@ -93,13 +93,12 @@ public function testReverseTransformEmptyArray() $this->assertNull($this->transformer->reverseTransform($input)); } - public function testReverseTransformZeroString() { $input = array( 'a' => '0', 'b' => '0', - 'c' => '0' + 'c' => '0', ); $this->assertSame('0', $this->transformer->reverseTransform($input)); 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 b251da031c61a..0f100f24eafcc 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php @@ -43,7 +43,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase 'Doctrine' => array( 'd' => 'Jon', 'e' => 'Roman', - ) + ), ); protected function setUp() @@ -868,7 +868,7 @@ public function testSubmitMultipleExpandedWithEmptyChild() '' => 'Empty', 1 => 'Not Empty', 2 => 'Not Empty 2', - ) + ), )); $form->submit(array('', '2')); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php index b0eb6dc01ce2e..ec290e3019876 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php @@ -33,5 +33,4 @@ public function testCurrenciesAreSelectable() $this->assertContains(new ChoiceView('USD', 'USD', 'US Dollar'), $choices, '', false, false); $this->assertContains(new ChoiceView('SIT', 'SIT', 'Slovenian Tolar'), $choices, '', false, false); } - } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php index b9c1ebad38fbe..213bc9ce43a84 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php @@ -441,7 +441,7 @@ public function testDateTypeSingleTextErrorsBubbleUp() { $error = new FormError('Invalid!'); $form = $this->factory->create('datetime', null, array( - 'date_widget' => 'single_text' + 'date_widget' => 'single_text', )); $form['date']->addError($error); @@ -465,7 +465,7 @@ public function testTimeTypeSingleTextErrorsBubbleUp() { $error = new FormError('Invalid!'); $form = $this->factory->create('datetime', null, array( - 'time_widget' => 'single_text' + 'time_widget' => 'single_text', )); $form['time']->addError($error); @@ -473,5 +473,4 @@ public function testTimeTypeSingleTextErrorsBubbleUp() $this->assertSame(array(), $form['time']->getErrors()); $this->assertSame(array($error), $form->getErrors()); } - } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php index 508ab410b018f..f095f30354d54 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php @@ -412,7 +412,7 @@ public function testMonthsOptionShortFormat() $this->assertEquals(array( new ChoiceView('1', '1', 'Jän'), - new ChoiceView('4', '4', 'Apr.') + new ChoiceView('4', '4', 'Apr.'), ), $view['month']->vars['choices']); } @@ -554,7 +554,7 @@ public function testPassDatePatternToViewDifferentFormat() public function testPassDatePatternToViewDifferentPattern() { $form = $this->factory->create('date', null, array( - 'format' => 'MMyyyydd' + 'format' => 'MMyyyydd', )); $view = $form->createView(); @@ -565,7 +565,7 @@ public function testPassDatePatternToViewDifferentPattern() public function testPassDatePatternToViewDifferentPatternWithSeparators() { $form = $this->factory->create('date', null, array( - 'format' => 'MM*yyyy*dd' + 'format' => 'MM*yyyy*dd', )); $view = $form->createView(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php index e670e57389f05..35cc17c6aadc8 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php @@ -334,7 +334,7 @@ public function testSubformDoesntCallSetters() // reference has a getter, but not setter 'reference' => array( 'firstName' => 'Foo', - ) + ), )); $this->assertEquals('Foo', $author->getReference()->firstName); @@ -359,7 +359,7 @@ public function testSubformCallsSettersIfTheObjectChanged() // referenceCopy has a getter that returns a copy 'referenceCopy' => array( 'firstName' => 'Foo', - ) + ), )); $this->assertEquals('Foo', $author->getReferenceCopy()->firstName); @@ -372,7 +372,7 @@ public function testSubformCallsSettersIfByReferenceIsFalse() $builder = $this->factory->createBuilder('form', $author); $builder->add('referenceCopy', 'form', array( 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', - 'by_reference' => false + 'by_reference' => false, )); $builder->get('referenceCopy')->add('firstName', 'text'); $form = $builder->getForm(); @@ -381,7 +381,7 @@ public function testSubformCallsSettersIfByReferenceIsFalse() // referenceCopy has a getter that returns a copy 'referenceCopy' => array( 'firstName' => 'Foo', - ) + ), )); // firstName can only be updated if setReferenceCopy() was called @@ -576,7 +576,7 @@ public function testNormDataIsPassedToView() public function testPassZeroLabelToView() { $view = $this->factory->create('form', null, array( - 'label' => '0' + 'label' => '0', )) ->createView(); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php index 9e125d781b7fa..d506f5f5a6eef 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php @@ -52,7 +52,7 @@ public function testSetOptionsPerChild() // the global required value cannot be overridden 'type' => 'text', 'first_options' => array('label' => 'Test', 'required' => false), - 'second_options' => array('label' => 'Test2') + 'second_options' => array('label' => 'Test2'), )); $this->assertEquals('Test', $form['first']->getConfig()->getOption('label')); @@ -112,7 +112,7 @@ public function testSetOptionsPerChildAndOverwrite() $form = $this->factory->create('repeated', null, array( 'type' => 'text', 'options' => array('label' => 'Label'), - 'second_options' => array('label' => 'Second label') + 'second_options' => array('label' => 'Second label'), )); $this->assertEquals('Label', $form['first']->getConfig()->getOption('label')); diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php index ca186207ac29f..b4fb3b1572f77 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php @@ -276,7 +276,7 @@ public function testSetDataDifferentTimezones() $displayedData = array( 'hour' => (int) $outputTime->format('H'), 'minute' => (int) $outputTime->format('i'), - 'second' => (int) $outputTime->format('s') + 'second' => (int) $outputTime->format('s'), ); $this->assertEquals($displayedData, $form->getViewData()); @@ -302,7 +302,7 @@ public function testSetDataDifferentTimezonesDateTime() $displayedData = array( 'hour' => (int) $outputTime->format('H'), 'minute' => (int) $outputTime->format('i'), - 'second' => (int) $outputTime->format('s') + 'second' => (int) $outputTime->format('s'), ); $this->assertDateTimeEquals($dateTime, $form->getData()); @@ -510,8 +510,8 @@ public function testSingleTextWidgetWithSecondsShouldNotOverrideStepAttribute() 'widget' => 'single_text', 'with_seconds' => true, 'attr' => array( - 'step' => 30 - ) + 'step' => 30, + ), )); $view = $form->createView(); diff --git a/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/BindRequestListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/BindRequestListenerTest.php index 2ff072b2eb75b..00a93aa2643aa 100644 --- a/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/BindRequestListenerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/BindRequestListenerTest.php @@ -51,7 +51,7 @@ protected function setUp() 'name' => 'upload.png', 'size' => 123, 'tmp_name' => $path, - 'type' => 'image/png' + 'type' => 'image/png', ), ); diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php index bfb84a15f84b6..19d5cec9f491b 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php @@ -221,7 +221,7 @@ function () { throw new TransformationFailedException(); } $this->assertViolation('invalid_message_key', array( '{{ value }}' => 'foo', - '{{ foo }}' => 'bar' + '{{ foo }}' => 'bar', ), 'property.path', 'foo', null, Form::ERR_INVALID); } @@ -253,7 +253,7 @@ function () { throw new TransformationFailedException(); } $this->assertViolation('invalid_message_key', array( '{{ value }}' => 'foo', - '{{ foo }}' => 'bar' + '{{ foo }}' => 'bar', ), 'property.path', 'foo', null, Form::ERR_INVALID); } @@ -355,7 +355,7 @@ public function testHandleClosureValidationGroups() $object = $this->getMock('\stdClass'); $options = array('validation_groups' => function (FormInterface $form) { return array('group1', 'group2'); - }); + },); $form = $this->getBuilder('name', '\stdClass', $options) ->setData($object) ->getForm(); @@ -538,7 +538,7 @@ public function testViolationIfExtraData() $this->validator->validate($form, new Form()); $this->assertViolation('Extra!', array( - '{{ extra_fields }}' => 'foo' + '{{ extra_fields }}' => 'foo', ), 'property.path', array('foo' => 'bar')); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php index f42003d214c40..090abf4486e86 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php @@ -71,7 +71,7 @@ public static function dataProviderTestGuessMaxLengthForConstraintWithType() array('double'), array('float'), array('numeric'), - array('real') + array('real'), ); } } diff --git a/src/Symfony/Component/Form/Tests/Guess/GuessTest.php b/src/Symfony/Component/Form/Tests/Guess/GuessTest.php index 235eb6ed2d782..2422663720c67 100644 --- a/src/Symfony/Component/Form/Tests/Guess/GuessTest.php +++ b/src/Symfony/Component/Form/Tests/Guess/GuessTest.php @@ -13,7 +13,9 @@ use Symfony\Component\Form\Guess\Guess; -class TestGuess extends Guess {} +class TestGuess extends Guess +{ +} class GuessTest extends \PHPUnit_Framework_TestCase { diff --git a/src/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php b/src/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php index 9d3a997fec496..02b0a4ed742e8 100644 --- a/src/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php +++ b/src/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php @@ -82,7 +82,7 @@ public function testConvertEmptyUploadedFilesToNull() 'type' => '', 'tmp_name' => '', 'error' => UPLOAD_ERR_NO_FILE, - 'size' => 0 + 'size' => 0, ))); $form->expects($this->once()) diff --git a/src/Symfony/Component/Form/Tests/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php index d6d3238b4287a..657f145c6cf91 100644 --- a/src/Symfony/Component/Form/Tests/SimpleFormTest.php +++ b/src/Symfony/Component/Form/Tests/SimpleFormTest.php @@ -518,7 +518,7 @@ public function testSubmitExecutesTransformationChain() '' => '', // direction is reversed! 'norm' => 'filteredclient', - 'filterednorm' => 'cleanedclient' + 'filterednorm' => 'cleanedclient', ))) ->addModelTransformer(new FixedDataTransformer(array( '' => '', diff --git a/src/Symfony/Component/Form/Util/FormUtil.php b/src/Symfony/Component/Form/Util/FormUtil.php index b3beb458bee54..af6ac4a64394c 100644 --- a/src/Symfony/Component/Form/Util/FormUtil.php +++ b/src/Symfony/Component/Form/Util/FormUtil.php @@ -19,7 +19,9 @@ class FormUtil /** * This class should not be instantiated */ - private function __construct() {} + private function __construct() + { + } /** * Returns whether the given data is empty. diff --git a/src/Symfony/Component/Form/Util/OrderedHashMap.php b/src/Symfony/Component/Form/Util/OrderedHashMap.php index bf5b08cda6025..2ba53e26101d4 100644 --- a/src/Symfony/Component/Form/Util/OrderedHashMap.php +++ b/src/Symfony/Component/Form/Util/OrderedHashMap.php @@ -120,7 +120,7 @@ public function offsetExists($key) public function offsetGet($key) { if (!isset($this->elements[$key])) { - throw new \OutOfBoundsException('The offset "' . $key . '" does not exist.'); + throw new \OutOfBoundsException('The offset "'.$key.'" does not exist.'); } return $this->elements[$key]; diff --git a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php index 4133d2eabc871..d729546875efa 100644 --- a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php +++ b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php @@ -305,6 +305,6 @@ private function getErrorMessage($errorCode) $maxFilesize = $errorCode === UPLOAD_ERR_INI_SIZE ? self::getMaxFilesize() / 1024 : 0; $message = isset($errors[$errorCode]) ? $errors[$errorCode] : 'The file "%s" was not uploaded due to an unknown error.'; - return sprintf($message, $this->getClientOriginalName(), $maxFilesize); + return sprintf($message, $this->getClientOriginalName(), $maxFilesize); } } diff --git a/src/Symfony/Component/HttpFoundation/FileBag.php b/src/Symfony/Component/HttpFoundation/FileBag.php index 12bc5fe3c0e1d..699e408d02ab0 100644 --- a/src/Symfony/Component/HttpFoundation/FileBag.php +++ b/src/Symfony/Component/HttpFoundation/FileBag.php @@ -146,7 +146,7 @@ protected function fixPhpFilesArray($data) 'name' => $data['name'][$key], 'type' => $data['type'][$key], 'tmp_name' => $data['tmp_name'][$key], - 'size' => $data['size'][$key] + 'size' => $data['size'][$key], )); } diff --git a/src/Symfony/Component/HttpFoundation/IpUtils.php b/src/Symfony/Component/HttpFoundation/IpUtils.php index 815c2664005c7..892503e98fa08 100644 --- a/src/Symfony/Component/HttpFoundation/IpUtils.php +++ b/src/Symfony/Component/HttpFoundation/IpUtils.php @@ -21,7 +21,9 @@ class IpUtils /** * This class should not be instantiated */ - private function __construct() {} + private function __construct() + { + } /** * Checks if an IPv4 or IPv6 address is contained in the list of given IPs or subnets @@ -37,7 +39,7 @@ public static function checkIp($requestIp, $ips) $ips = array($ips); } - $method = false !== strpos($requestIp, ':') ? 'checkIp6': 'checkIp4'; + $method = false !== strpos($requestIp, ':') ? 'checkIp6' : 'checkIp4'; foreach ($ips as $ip) { if (self::$method($requestIp, $ip)) { diff --git a/src/Symfony/Component/HttpFoundation/ParameterBag.php b/src/Symfony/Component/HttpFoundation/ParameterBag.php index ebb17bb66ee39..8791275bafdaa 100644 --- a/src/Symfony/Component/HttpFoundation/ParameterBag.php +++ b/src/Symfony/Component/HttpFoundation/ParameterBag.php @@ -266,7 +266,7 @@ public function getInt($key, $default = 0, $deep = false) * * @return mixed */ - public function filter($key, $default = null, $deep = false, $filter=FILTER_DEFAULT, $options=array()) + public function filter($key, $default = null, $deep = false, $filter = FILTER_DEFAULT, $options = array()) { $value = $this->get($key, $default, $deep); diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index c6a784e1d0a3d..9fd02cc2d1489 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -982,7 +982,7 @@ public function getUserInfo() $pass = $this->getPassword(); if ('' != $pass) { - $userinfo .= ":$pass"; + $userinfo .= ":$pass"; } return $userinfo; diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index cfff05ff97d08..44d87d3007cb0 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -223,10 +223,10 @@ public function prepare(Request $request) // Fix Content-Type $charset = $this->charset ?: 'UTF-8'; if (!$headers->has('Content-Type')) { - $headers->set('Content-Type', 'text/html; charset=' . $charset); + $headers->set('Content-Type', 'text/html; charset='.$charset); } elseif (0 === stripos($headers->get('Content-Type'), 'text/') && false === stripos($headers->get('Content-Type'), 'charset')) { // add the charset - $headers->set('Content-Type', $headers->get('Content-Type') . '; charset=' . $charset); + $headers->set('Content-Type', $headers->get('Content-Type').'; charset='.$charset); } // Fix Content-Length diff --git a/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php b/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php index d62e3835abe08..7d7e307f9ecfc 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php +++ b/src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php @@ -76,7 +76,7 @@ public function add($type, $message) /** * {@inheritdoc} */ - public function peek($type, array $default =array()) + public function peek($type, array $default = array()) { return $this->has($type) ? $this->flashes[$type] : $default; } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php index 87aa7fb4f77a9..ca7920cfdb4c0 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php @@ -90,7 +90,7 @@ public function close() public function destroy($sessionId) { $this->getCollection()->remove(array( - $this->options['id_field'] => $sessionId + $this->options['id_field'] => $sessionId, )); return true; diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php index 1260ad0d295a9..22acdecf61047 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php @@ -18,7 +18,11 @@ */ if (version_compare(phpversion(), '5.4.0', '>=')) { - class NativeSessionHandler extends \SessionHandler {} + class NativeSessionHandler extends \SessionHandler + { + } } else { - class NativeSessionHandler {} + class NativeSessionHandler + { + } } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php index 221c7aecaa983..569e08958bcbb 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php @@ -235,18 +235,18 @@ private function getMergeSql() switch ($driver) { case 'mysql': - return "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) " . + return "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". "ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->timeCol = VALUES($this->timeCol)"; case 'oci': // DUAL is Oracle specific dummy table - return "MERGE INTO $this->table USING DUAL ON ($this->idCol = :id) " . - "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) " . + return "MERGE INTO $this->table USING DUAL ON ($this->idCol = :id) ". + "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". "WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->timeCol = :time"; case 'sqlsrv' === $driver && version_compare($this->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION), '10', '>='): // MERGE is only available since SQL Server 2008 and must be terminated by semicolon // It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx - return "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = :id) " . - "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) " . + return "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = :id) ". + "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". "WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->timeCol = :time;"; case 'sqlite': return "INSERT OR REPLACE INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time)"; diff --git a/src/Symfony/Component/HttpFoundation/Tests/AcceptHeaderItemTest.php b/src/Symfony/Component/HttpFoundation/Tests/AcceptHeaderItemTest.php index 582fbdefe1725..e4f354fc1f27d 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/AcceptHeaderItemTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/AcceptHeaderItemTest.php @@ -30,19 +30,19 @@ public function provideFromStringData() return array( array( 'text/html', - 'text/html', array() + 'text/html', array(), ), array( '"this;should,not=matter"', - 'this;should,not=matter', array() + 'this;should,not=matter', array(), ), array( "text/plain; charset=utf-8;param=\"this;should,not=matter\";\tfootnotes=true", - 'text/plain', array('charset' => 'utf-8', 'param' => 'this;should,not=matter', 'footnotes' => 'true') + 'text/plain', array('charset' => 'utf-8', 'param' => 'this;should,not=matter', 'footnotes' => 'true'), ), array( '"this;should,not=matter";charset=utf-8', - 'this;should,not=matter', array('charset' => 'utf-8') + 'this;should,not=matter', array('charset' => 'utf-8'), ), ); } @@ -61,11 +61,11 @@ public function provideToStringData() return array( array( 'text/html', array(), - 'text/html' + 'text/html', ), array( 'text/plain', array('charset' => 'utf-8', 'param' => 'this;should,not=matter', 'footnotes' => 'true'), - 'text/plain;charset=utf-8;param="this;should,not=matter";footnotes=true' + 'text/plain;charset=utf-8;param="this;should,not=matter";footnotes=true', ), ); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/ApacheRequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/ApacheRequestTest.php index 965a7d2bf0317..d9f9a323302a0 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ApacheRequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ApacheRequestTest.php @@ -39,7 +39,7 @@ public function provideServerVars() ), '/foo/app_dev.php/bar', '/foo/app_dev.php', - '/bar' + '/bar', ), array( array( diff --git a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php index 74344f76b711c..cef037fd9b611 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php @@ -20,7 +20,7 @@ class BinaryFileResponseTest extends ResponseTestCase { public function testConstruction() { - $file = __DIR__ . '/../README.md'; + $file = __DIR__.'/../README.md'; $response = new BinaryFileResponse($file, 404, array('X-Header' => 'Foo'), true, null, true, true); $this->assertEquals(404, $response->getStatusCode()); $this->assertEquals('Foo', $response->headers->get('X-Header')); @@ -152,7 +152,7 @@ public function provideInvalidRanges() { return array( array('bytes=-40'), - array('bytes=30-40') + array('bytes=30-40'), ); } @@ -162,7 +162,7 @@ public function testXSendfile() $request->headers->set('X-Sendfile-Type', 'X-Sendfile'); BinaryFileResponse::trustXSendfileTypeHeader(); - $response = BinaryFileResponse::create(__DIR__ . '/../README.md'); + $response = BinaryFileResponse::create(__DIR__.'/../README.md'); $response->prepare($request); $this->expectOutputString(''); @@ -213,6 +213,6 @@ public function getSampleXAccelMappings() protected function provideResponse() { - return new BinaryFileResponse(__DIR__ . '/../README.md'); + return new BinaryFileResponse(__DIR__.'/../README.md'); } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php index 1f29d56bc0348..738604bcc7892 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/FileBagTest.php @@ -40,7 +40,7 @@ public function testShouldConvertsUploadedFiles() 'type' => 'text/plain', 'tmp_name' => $tmpFile, 'error' => 0, - 'size' => 100 + 'size' => 100, ))); $this->assertEquals($file, $bag->get('file')); @@ -53,7 +53,7 @@ public function testShouldSetEmptyUploadedFilesToNull() 'type' => '', 'tmp_name' => '', 'error' => UPLOAD_ERR_NO_FILE, - 'size' => 0 + 'size' => 0, ))); $this->assertNull($bag->get('file')); @@ -81,7 +81,7 @@ public function testShouldConvertUploadedFilesWithPhpBug() 'size' => array( 'file' => 100, ), - ) + ), )); $files = $bag->all(); @@ -96,21 +96,21 @@ public function testShouldConvertNestedUploadedFilesWithPhpBug() $bag = new FileBag(array( 'child' => array( 'name' => array( - 'sub' => array('file' => basename($tmpFile)) + 'sub' => array('file' => basename($tmpFile)), ), 'type' => array( - 'sub' => array('file' => 'text/plain') + 'sub' => array('file' => 'text/plain'), ), 'tmp_name' => array( - 'sub' => array('file' => $tmpFile) + 'sub' => array('file' => $tmpFile), ), 'error' => array( - 'sub' => array('file' => 0) + 'sub' => array('file' => 0), ), 'size' => array( - 'sub' => array('file' => 100) + 'sub' => array('file' => 100), ), - ) + ), )); $files = $bag->all(); diff --git a/src/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php index 7f4f243b481bb..95af8a14d930a 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ParameterBagTest.php @@ -212,16 +212,15 @@ public function testFilter() $this->assertFalse($bag->filter('dec', '', false, FILTER_VALIDATE_INT, array( 'flags' => FILTER_FLAG_ALLOW_HEX, - 'options' => array('min_range' => 1, 'max_range' => 0xff)) + 'options' => array('min_range' => 1, 'max_range' => 0xff),) ), '->filter() gets a value of parameter as integer between boundaries'); $this->assertFalse($bag->filter('hex', '', false, FILTER_VALIDATE_INT, array( 'flags' => FILTER_FLAG_ALLOW_HEX, - 'options' => array('min_range' => 1, 'max_range' => 0xff)) + 'options' => array('min_range' => 1, 'max_range' => 0xff),) ), '->filter() gets a value of parameter as integer between boundaries'); $this->assertEquals(array('bang'), $bag->filter('array', '', false), '->filter() gets a value of parameter as an array'); - } /** diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php index 0e1a0f5caf363..63d37492ec126 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestMatcherTest.php @@ -54,7 +54,7 @@ public function testHost($pattern, $isMatch) $matcher->matchHost($pattern); $this->assertSame($isMatch, $matcher->matches($request)); - $matcher= new RequestMatcher(null, $pattern); + $matcher = new RequestMatcher(null, $pattern); $this->assertSame($isMatch, $matcher->matches($request)); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index 9907d122d80c2..60599693639c4 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php @@ -696,7 +696,7 @@ public function testGetPort() { $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( 'HTTP_X_FORWARDED_PROTO' => 'https', - 'HTTP_X_FORWARDED_PORT' => '443' + 'HTTP_X_FORWARDED_PORT' => '443', )); $port = $request->getPort(); @@ -705,40 +705,40 @@ public function testGetPort() Request::setTrustedProxies(array('1.1.1.1')); $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( 'HTTP_X_FORWARDED_PROTO' => 'https', - 'HTTP_X_FORWARDED_PORT' => '8443' + 'HTTP_X_FORWARDED_PORT' => '8443', )); $port = $request->getPort(); $this->assertEquals(8443, $port, 'With PROTO and PORT set PORT takes precedence.'); $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => 'https' + 'HTTP_X_FORWARDED_PROTO' => 'https', )); $port = $request->getPort(); $this->assertEquals(443, $port, 'With only PROTO set getPort() defaults to 443.'); $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => 'http' + 'HTTP_X_FORWARDED_PROTO' => 'http', )); $port = $request->getPort(); $this->assertEquals(80, $port, 'If X_FORWARDED_PROTO is set to HTTP return 80.'); $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => 'On' + 'HTTP_X_FORWARDED_PROTO' => 'On', )); $port = $request->getPort(); $this->assertEquals(443, $port, 'With only PROTO set and value is On, getPort() defaults to 443.'); $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => '1' + 'HTTP_X_FORWARDED_PROTO' => '1', )); $port = $request->getPort(); $this->assertEquals(443, $port, 'With only PROTO set and value is 1, getPort() defaults to 443.'); $request = Request::create('http://example.com', 'GET', array(), array(), array(), array( - 'HTTP_X_FORWARDED_PROTO' => 'something-else' + 'HTTP_X_FORWARDED_PROTO' => 'something-else', )); $port = $request->getPort(); $this->assertEquals(80, $port, 'With only PROTO set and value is not recognized, getPort() defaults to 80.'); @@ -1496,31 +1496,31 @@ public function iisRequestUriProvider() 'X_ORIGINAL_URL' => '/foo/bar', ), array(), - '/foo/bar' + '/foo/bar', ), array( array( 'X_REWRITE_URL' => '/foo/bar', ), array(), - '/foo/bar' + '/foo/bar', ), array( array(), array( 'IIS_WasUrlRewritten' => '1', - 'UNENCODED_URL' => '/foo/bar' + 'UNENCODED_URL' => '/foo/bar', ), - '/foo/bar' + '/foo/bar', ), array( array( 'X_ORIGINAL_URL' => '/foo/bar', ), array( - 'HTTP_X_ORIGINAL_URL' => '/foo/bar' + 'HTTP_X_ORIGINAL_URL' => '/foo/bar', ), - '/foo/bar' + '/foo/bar', ), array( array( @@ -1528,9 +1528,9 @@ public function iisRequestUriProvider() ), array( 'IIS_WasUrlRewritten' => '1', - 'UNENCODED_URL' => '/foo/bar' + 'UNENCODED_URL' => '/foo/bar', ), - '/foo/bar' + '/foo/bar', ), array( array( @@ -1539,16 +1539,16 @@ public function iisRequestUriProvider() array( 'HTTP_X_ORIGINAL_URL' => '/foo/bar', 'IIS_WasUrlRewritten' => '1', - 'UNENCODED_URL' => '/foo/bar' + 'UNENCODED_URL' => '/foo/bar', ), - '/foo/bar' + '/foo/bar', ), array( array(), array( 'ORIG_PATH_INFO' => '/foo/bar', ), - '/foo/bar' + '/foo/bar', ), array( array(), @@ -1556,8 +1556,8 @@ public function iisRequestUriProvider() 'ORIG_PATH_INFO' => '/foo/bar', 'QUERY_STRING' => 'foo=bar', ), - '/foo/bar?foo=bar' - ) + '/foo/bar?foo=bar', + ), ); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php index 1cb327860d223..1201deb9030ab 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php @@ -32,31 +32,31 @@ public function provideAllPreserveCase() return array( array( array('fOo' => 'BAR'), - array('fOo' => array('BAR'), 'Cache-Control' => array('no-cache')) + array('fOo' => array('BAR'), 'Cache-Control' => array('no-cache')), ), array( array('ETag' => 'xyzzy'), - array('ETag' => array('xyzzy'), 'Cache-Control' => array('private, must-revalidate')) + array('ETag' => array('xyzzy'), 'Cache-Control' => array('private, must-revalidate')), ), array( array('Content-MD5' => 'Q2hlY2sgSW50ZWdyaXR5IQ=='), - array('Content-MD5' => array('Q2hlY2sgSW50ZWdyaXR5IQ=='), 'Cache-Control' => array('no-cache')) + array('Content-MD5' => array('Q2hlY2sgSW50ZWdyaXR5IQ=='), 'Cache-Control' => array('no-cache')), ), array( array('P3P' => 'CP="CAO PSA OUR"'), - array('P3P' => array('CP="CAO PSA OUR"'), 'Cache-Control' => array('no-cache')) + array('P3P' => array('CP="CAO PSA OUR"'), 'Cache-Control' => array('no-cache')), ), array( array('WWW-Authenticate' => 'Basic realm="WallyWorld"'), - array('WWW-Authenticate' => array('Basic realm="WallyWorld"'), 'Cache-Control' => array('no-cache')) + array('WWW-Authenticate' => array('Basic realm="WallyWorld"'), 'Cache-Control' => array('no-cache')), ), array( array('X-UA-Compatible' => 'IE=edge,chrome=1'), - array('X-UA-Compatible' => array('IE=edge,chrome=1'), 'Cache-Control' => array('no-cache')) + array('X-UA-Compatible' => array('IE=edge,chrome=1'), 'Cache-Control' => array('no-cache')), ), array( array('X-XSS-Protection' => '1; mode=block'), - array('X-XSS-Protection' => array('1; mode=block'), 'Cache-Control' => array('no-cache')) + array('X-XSS-Protection' => array('1; mode=block'), 'Cache-Control' => array('no-cache')), ), ); } @@ -82,7 +82,7 @@ public function testCacheControlHeader() $bag = new ResponseHeaderBag(array( 'Expires' => 'Wed, 16 Feb 2011 14:17:43 GMT', - 'Cache-Control' => 'max-age=3600' + 'Cache-Control' => 'max-age=3600', )); $this->assertEquals('max-age=3600, private', $bag->get('Cache-Control')); diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index f16cb4930a59e..b76179aae079a 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -532,7 +532,7 @@ public function getStatusCodeFixtures() array('200', 'foo', 'foo'), array('199', null, ''), array('199', false, ''), - array('199', 'foo', 'foo') + array('199', 'foo', 'foo'), ); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php index 662c5880b170c..4cded7fa033b5 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php @@ -52,7 +52,7 @@ public function testHttpPasswordIsOptional() $this->assertEquals(array( 'AUTHORIZATION' => 'Basic '.base64_encode('foo:'), 'PHP_AUTH_USER' => 'foo', - 'PHP_AUTH_PW' => '' + 'PHP_AUTH_PW' => '', ), $bag->getHeaders()); } @@ -63,7 +63,7 @@ public function testHttpBasicAuthWithPhpCgi() $this->assertEquals(array( 'AUTHORIZATION' => 'Basic '.base64_encode('foo:bar'), 'PHP_AUTH_USER' => 'foo', - 'PHP_AUTH_PW' => 'bar' + 'PHP_AUTH_PW' => 'bar', ), $bag->getHeaders()); } @@ -84,7 +84,7 @@ public function testHttpBasicAuthWithPhpCgiRedirect() $this->assertEquals(array( 'AUTHORIZATION' => 'Basic '.base64_encode('username:pass:word'), 'PHP_AUTH_USER' => 'username', - 'PHP_AUTH_PW' => 'pass:word' + 'PHP_AUTH_PW' => 'pass:word', ), $bag->getHeaders()); } @@ -95,7 +95,7 @@ public function testHttpBasicAuthWithPhpCgiEmptyPassword() $this->assertEquals(array( 'AUTHORIZATION' => 'Basic '.base64_encode('foo:'), 'PHP_AUTH_USER' => 'foo', - 'PHP_AUTH_PW' => '' + 'PHP_AUTH_PW' => '', ), $bag->getHeaders()); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php index 93c634cde065e..2d1d77c330343 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/AttributeBagTest.php @@ -43,7 +43,7 @@ protected function setUp() 'category' => array( 'fishing' => array( 'first' => 'cod', - 'second' => 'sole') + 'second' => 'sole',), ), ); $this->bag = new AttributeBag('_sf2'); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php index 0c46a515a0c2b..70910680baf04 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Attribute/NamespacedAttributeBagTest.php @@ -43,7 +43,7 @@ protected function setUp() 'category' => array( 'fishing' => array( 'first' => 'cod', - 'second' => 'sole') + 'second' => 'sole',), ), ); $this->bag = new NamespacedAttributeBag('_sf2', '/'); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php index acfed71aed6db..d6e27bb30de53 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Flash/FlashBagTest.php @@ -91,7 +91,7 @@ public function testAll() $this->bag->set('error', 'Bar'); $this->assertEquals(array( 'notice' => array('Foo'), - 'error' => array('Bar')), $this->bag->all() + 'error' => array('Bar'),), $this->bag->all() ); $this->assertEquals(array(), $this->bag->all()); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php index 9577d5247886a..927766440b99b 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php @@ -41,7 +41,7 @@ protected function setUp() 'data_field' => 'data', 'time_field' => 'time', 'database' => 'sf2-test', - 'collection' => 'session-test' + 'collection' => 'session-test', ); $this->storage = new MongoDbSessionHandler($this->mongo, $this->options); @@ -162,7 +162,6 @@ public function testGc() private function createMongoCollectionMock() { - $mongoClient = $this->getMockBuilder('MongoClient') ->getMock(); $mongoDb = $this->getMockBuilder('MongoDB') diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php index ef70281ce08d3..c2363bb31e1bf 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MetadataBagTest.php @@ -74,7 +74,6 @@ public function testGetSetName() $this->assertEquals('__metadata', $this->bag->getName()); $this->bag->setName('foo'); $this->assertEquals('foo', $this->bag->getName()); - } public function testGetStorageKey() diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php index 6b8bba0d5b0d3..f8ac39c94c1d3 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php @@ -17,12 +17,11 @@ // https://github.com/sebastianbergmann/phpunit-mock-objects/issues/73 class ConcreteProxy extends AbstractProxy { - } class ConcreteSessionHandlerInterfaceProxy extends AbstractProxy implements \SessionHandlerInterface { - public function open($savePath, $sessionName) + public function open($savePath, $sessionName) { } diff --git a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php index de9c6f01535ee..8a35ebc70fc69 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php @@ -70,7 +70,7 @@ public function collect(Request $request, Response $response, \Exception $except 'wincache_enabled' => extension_loaded('wincache') && ini_get('wincache.ocenabled'), 'zend_opcache_enabled' => extension_loaded('Zend OPcache') && ini_get('opcache.enable'), 'bundles' => array(), - 'sapi_name' => php_sapi_name() + 'sapi_name' => php_sapi_name(), ); if (isset($this->kernel)) { diff --git a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php index f08720e8073bb..e8d92745caf4f 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php @@ -41,7 +41,7 @@ public function collect(Request $request, Response $response, \Exception $except $this->data = array( 'error_count' => $this->logger->countErrors(), 'logs' => $this->sanitizeLogs($this->logger->getLogs()), - 'deprecation_count' => $this->computeDeprecationCount() + 'deprecation_count' => $this->computeDeprecationCount(), ); } } diff --git a/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php b/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php index 8af3ad7c4d5f8..baf96c0d0d073 100644 --- a/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php +++ b/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php @@ -277,7 +277,7 @@ private function getListenerInfo($listener, $eventId, $eventName) if ($listener instanceof \Closure) { $info += array( 'type' => 'Closure', - 'pretty' => 'closure' + 'pretty' => 'closure', ); } elseif (is_string($listener)) { try { @@ -406,7 +406,8 @@ private function preDispatch($eventName, $eventId, Event $event) // which must be caught. try { $this->stopwatch->openSection($token); - } catch (\LogicException $e) {} + } catch (\LogicException $e) { + } break; } } @@ -432,7 +433,8 @@ private function postDispatch($eventName, $eventId, Event $event) // does not exist, then closing it throws an exception which must be caught. try { $this->stopwatch->stopSection($token); - } catch (\LogicException $e) {} + } catch (\LogicException $e) { + } // The children profiles have been updated by the previous 'kernel.response' // event. Only the root profile need to be updated with the 'kernel.terminate' // timing information. diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index 871b3a87fc900..e16ee6f311f18 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -152,7 +152,6 @@ public function getKernel() return $this->kernel; } - /** * Gets the Esi instance * diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 4e9594203b203..5106940f7e737 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -519,7 +519,6 @@ protected function initializeBundles() array_pop($bundleMap); } } - } /** diff --git a/src/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php index 39b517fac2e85..ba6f1952e4df8 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php +++ b/src/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php @@ -53,12 +53,11 @@ public function find($ip, $url, $limit, $method, $start = null, $end = null) $result = array(); foreach ($profileList as $item) { - if ($limit === 0) { break; } - if ($item=='') { + if ($item == '') { continue; } @@ -166,7 +165,6 @@ public function write(Profile $profile) $profileIndexed = false !== $this->getValue($this->getItemName($profile->getToken())); if ($this->setValue($this->getItemName($profile->getToken()), $data, $this->lifetime)) { - if (!$profileIndexed) { // Add to index $indexName = $this->getIndexName(); @@ -304,5 +302,4 @@ private function isItemNameValid($name) return true; } - } diff --git a/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php index 9d08813f57c1b..b7abad735c08f 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php +++ b/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php @@ -70,7 +70,7 @@ public function find($ip, $url, $limit, $method, $start = null, $end = null) } if (!empty($start) && $csvTime < $start) { - continue; + continue; } if (!empty($end) && $csvTime > $end) { diff --git a/src/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php index ad70b97b9b3c4..31f11ef086290 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php +++ b/src/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php @@ -91,7 +91,6 @@ protected function appendValue($key, $value, $expiration = 0) $memcache = $this->getMemcache(); if (method_exists($memcache, 'append')) { - // Memcache v3.0 if (!$result = $memcache->append($key, $value, false, $expiration)) { return $memcache->set($key, $value, false, $expiration); diff --git a/src/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php index 9be3410dba597..c5242806ee904 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php +++ b/src/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php @@ -82,7 +82,7 @@ public function write(Profile $profile) 'ip' => $profile->getIp(), 'method' => $profile->getMethod(), 'url' => $profile->getUrl(), - 'time' => $profile->getTime() + 'time' => $profile->getTime(), ); $result = $this->getMongo()->update(array('_id' => $profile->getToken()), array_filter($record, function ($v) { return !empty($v); }), array('upsert' => true)); diff --git a/src/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php index 7ea4244500aeb..d56e49dbae76c 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php +++ b/src/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php @@ -171,7 +171,6 @@ public function write(Profile $profile) $profileIndexed = false !== $this->getValue($this->getItemName($profile->getToken())); if ($this->setValue($this->getItemName($profile->getToken()), $data, $this->lifetime, self::REDIS_SERIALIZER_PHP)) { - if (!$profileIndexed) { // Add to index $indexName = $this->getIndexName(); diff --git a/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php b/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php index 8affb5f300bfb..9871a2ca43b9f 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php @@ -43,6 +43,5 @@ public function testRegisterCommands() $bundle2 = new ExtensionAbsentBundle(); $this->assertNull($bundle2->registerCommands($app)); - } } diff --git a/src/Symfony/Component/HttpKernel/Tests/ClientTest.php b/src/Symfony/Component/HttpKernel/Tests/ClientTest.php index 4d9918b504920..a2b70a5ab8d02 100644 --- a/src/Symfony/Component/HttpKernel/Tests/ClientTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/ClientTest.php @@ -75,7 +75,7 @@ public function testFilterResponseConvertsCookies() $expected = array( 'foo=bar; expires=Sun, 15 Feb 2009 20:00:00 GMT; domain=http://example.com; path=/foo; secure; httponly', - 'foo1=bar1; expires=Sun, 15 Feb 2009 20:00:00 GMT; domain=http://example.com; path=/foo; secure; httponly' + 'foo1=bar1; expires=Sun, 15 Feb 2009 20:00:00 GMT; domain=http://example.com; path=/foo; secure; httponly', ); $response = new Response(); diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ExceptionDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ExceptionDataCollectorTest.php index 54a8aabe671b9..c1e59f08a73c0 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ExceptionDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ExceptionDataCollectorTest.php @@ -43,5 +43,4 @@ public function testCollect() $this->assertSame('exception',$c->getName()); $this->assertSame($trace,$c->getTrace()); } - } diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php index ea82d9d315733..11553261140cd 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/LoggerDataCollectorTest.php @@ -50,28 +50,28 @@ public function getCollectTestData() 1, array(array('message' => 'foo', 'context' => array())), null, - 0 + 0, ), array( 1, array(array('message' => 'foo', 'context' => array('foo' => fopen(__FILE__, 'r')))), array(array('message' => 'foo', 'context' => array('foo' => 'Resource(stream)'))), - 0 + 0, ), array( 1, array(array('message' => 'foo', 'context' => array('foo' => new \stdClass()))), array(array('message' => 'foo', 'context' => array('foo' => 'Object(stdClass)'))), - 0 + 0, ), array( 1, array( array('message' => 'foo', 'context' => array('type' => ErrorHandler::TYPE_DEPRECATION)), - array('message' => 'foo2', 'context' => array('type' => ErrorHandler::TYPE_DEPRECATION)) + array('message' => 'foo2', 'context' => array('type' => ErrorHandler::TYPE_DEPRECATION)), ), null, - 2 + 2, ), ); } diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php index cd0251c1ee4a8..5b0d7464cafe1 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php @@ -74,7 +74,7 @@ public function testControllerInspection(Request $request, Response $response) 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'method' => 'testControllerInspection', 'file' => __FILE__, - 'line' => $r1->getStartLine() + 'line' => $r1->getStartLine(), ), ), @@ -102,7 +102,7 @@ function () { return 'foo'; }, 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'method' => 'staticControllerMethod', 'file' => __FILE__, - 'line' => $r2->getStartLine() + 'line' => $r2->getStartLine(), ), ), @@ -113,7 +113,7 @@ function () { return 'foo'; }, 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'method' => 'staticControllerMethod', 'file' => __FILE__, - 'line' => $r2->getStartLine() + 'line' => $r2->getStartLine(), ), ), @@ -124,7 +124,7 @@ function () { return 'foo'; }, 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'method' => 'magicMethod', 'file' => 'n/a', - 'line' => 'n/a' + 'line' => 'n/a', ), ), @@ -135,7 +135,7 @@ function () { return 'foo'; }, 'class' => 'Symfony\Component\HttpKernel\Tests\DataCollector\RequestDataCollectorTest', 'method' => 'magicMethod', 'file' => 'n/a', - 'line' => 'n/a' + 'line' => 'n/a', ), ), ); @@ -166,7 +166,7 @@ public function provider() $response->headers->setCookie(new Cookie('bazz','foo','2000-12-12')); return array( - array($request, $response) + array($request, $response), ); } @@ -204,5 +204,4 @@ public static function __callStatic($method, $args) { throw new \LogicException('Unexpected method call'); } - } diff --git a/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php b/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php index b9bc1d7f97e1a..576f6a7180f1c 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php @@ -38,7 +38,7 @@ public function testAddRemoveListener() $dispatcher = new EventDispatcher(); $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); - $tdispatcher->addListener('foo', $listener = function () { ; }); + $tdispatcher->addListener('foo', $listener = function () {; }); $listeners = $dispatcher->getListeners('foo'); $this->assertCount(1, $listeners); $this->assertSame($listener, $listeners[0]); @@ -52,7 +52,7 @@ public function testGetListeners() $dispatcher = new EventDispatcher(); $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); - $tdispatcher->addListener('foo', $listener = function () { ; }); + $tdispatcher->addListener('foo', $listener = function () {; }); $this->assertSame($dispatcher->getListeners('foo'), $tdispatcher->getListeners('foo')); } @@ -64,7 +64,7 @@ public function testHasListeners() $this->assertFalse($dispatcher->hasListeners('foo')); $this->assertFalse($tdispatcher->hasListeners('foo')); - $tdispatcher->addListener('foo', $listener = function () { ; }); + $tdispatcher->addListener('foo', $listener = function () {; }); $this->assertTrue($dispatcher->hasListeners('foo')); $this->assertTrue($tdispatcher->hasListeners('foo')); } @@ -89,7 +89,7 @@ public function testGetCalledListeners() { $dispatcher = new EventDispatcher(); $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); - $tdispatcher->addListener('foo', $listener = function () { ; }); + $tdispatcher->addListener('foo', $listener = function () {; }); $this->assertEquals(array(), $tdispatcher->getCalledListeners()); $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'type' => 'Closure', 'pretty' => 'closure')), $tdispatcher->getNotCalledListeners()); @@ -106,8 +106,8 @@ public function testLogger() $dispatcher = new EventDispatcher(); $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger); - $tdispatcher->addListener('foo', $listener1 = function () { ; }); - $tdispatcher->addListener('foo', $listener2 = function () { ; }); + $tdispatcher->addListener('foo', $listener1 = function () {; }); + $tdispatcher->addListener('foo', $listener2 = function () {; }); $logger->expects($this->at(0))->method('debug')->with("Notified event \"foo\" to listener \"closure\"."); $logger->expects($this->at(1))->method('debug')->with("Notified event \"foo\" to listener \"closure\"."); @@ -122,7 +122,7 @@ public function testLoggerWithStoppedEvent() $dispatcher = new EventDispatcher(); $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger); $tdispatcher->addListener('foo', $listener1 = function (Event $event) { $event->stopPropagation(); }); - $tdispatcher->addListener('foo', $listener2 = function () { ; }); + $tdispatcher->addListener('foo', $listener2 = function () {; }); $logger->expects($this->at(0))->method('debug')->with("Notified event \"foo\" to listener \"closure\"."); $logger->expects($this->at(1))->method('debug')->with("Listener \"closure\" stopped propagation of the event \"foo\"."); diff --git a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterListenersPassTest.php b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterListenersPassTest.php index 8c9fa0856d479..9fbb54f66a117 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterListenersPassTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterListenersPassTest.php @@ -133,5 +133,7 @@ public function testAbstractEventListener() class SubscriberService implements \Symfony\Component\EventDispatcher\EventSubscriberInterface { - public static function getSubscribedEvents() {} + public static function getSubscribedEvents() + { + } } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php index c6a01281a7d5c..a4ae8b8bb658d 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php @@ -108,7 +108,7 @@ public function provider() $event2 = new GetResponseForExceptionEvent(new TestKernelThatThrowsException(), $request, 'foo', $exception); return array( - array($event, $event2) + array($event, $event2), ); } diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php index 3f8e852104454..13f65109d9d5d 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ResponseListenerTest.php @@ -36,7 +36,6 @@ protected function setUp() $this->dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse')); $this->kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - } protected function tearDown() diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/BarCommand.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/BarCommand.php index b9a5417d945a6..0eb420f78936f 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/BarCommand.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/BarCommand.php @@ -13,6 +13,5 @@ class BarCommand extends Command { public function __construct($example, $name = 'bar') { - } } diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/FooCommand.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/FooCommand.php index bfe189bea35e6..c6570aa046c55 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/FooCommand.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/FooCommand.php @@ -19,5 +19,4 @@ protected function configure() { $this->setName('foo'); } - } diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForOverrideName.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForOverrideName.php index 32c05f4ba6a82..a1102ab7843c3 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForOverrideName.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForOverrideName.php @@ -20,11 +20,9 @@ class KernelForOverrideName extends Kernel public function registerBundles() { - } public function registerContainerConfiguration(LoaderInterface $loader) { - } } diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php index c69bbc8e9af79..f0a1cf4084306 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/RoutableFragmentRendererTest.php @@ -62,8 +62,12 @@ private function getRenderer() class Renderer extends RoutableFragmentRenderer { - public function render($uri, Request $request, array $options = array()) {} - public function getName() {} + public function render($uri, Request $request, array $options = array()) + { + } + public function getName() + { + } public function doGenerateFragmentUri(ControllerReference $reference, Request $request, $absolute = false) { diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index a19bc32679608..31665205cb539 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -497,7 +497,7 @@ public function testLocateResourceReturnsAllMatches() $this->assertEquals(array( __DIR__.'/Fixtures/Bundle2Bundle/foo.txt', - __DIR__.'/Fixtures/Bundle1Bundle/foo.txt'), + __DIR__.'/Fixtures/Bundle1Bundle/foo.txt',), $kernel->locateResource('@Bundle1Bundle/foo.txt', null, false)); } @@ -509,7 +509,7 @@ public function testLocateResourceReturnsAllMatchesBis() ->method('getBundle') ->will($this->returnValue(array( $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'), - $this->getBundle(__DIR__.'/Foobar') + $this->getBundle(__DIR__.'/Foobar'), ))) ; @@ -560,7 +560,7 @@ public function testLocateResourceReturnsTheDirOneForResourcesAndBundleOnes() $this->assertEquals(array( __DIR__.'/Fixtures/Resources/Bundle1Bundle/foo.txt', - __DIR__.'/Fixtures/Bundle1Bundle/Resources/foo.txt'), + __DIR__.'/Fixtures/Bundle1Bundle/Resources/foo.txt',), $kernel->locateResource('@Bundle1Bundle/Resources/foo.txt', __DIR__.'/Fixtures/Resources', false) ); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php b/src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php index 13b726fdc4181..60f5e42fc3995 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php +++ b/src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php @@ -18,7 +18,6 @@ */ class RedisMock { - private $connected; private $storage; diff --git a/src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php b/src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php index 15fe98695fae3..c72732563c672 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Profiler/MongoDbProfilerStorageTest.php @@ -77,23 +77,23 @@ public function getDsns() array('mongodb://localhost/symfony_tests/profiler_data', array( 'mongodb://localhost/symfony_tests', 'symfony_tests', - 'profiler_data' + 'profiler_data', )), array('mongodb://user:password@localhost/symfony_tests/profiler_data', array( 'mongodb://user:password@localhost/symfony_tests', 'symfony_tests', - 'profiler_data' + 'profiler_data', )), array('mongodb://user:password@localhost/admin/symfony_tests/profiler_data', array( 'mongodb://user:password@localhost/admin', 'symfony_tests', - 'profiler_data' + 'profiler_data', )), array('mongodb://user:password@localhost:27009,localhost:27010/?replicaSet=rs-name&authSource=admin/symfony_tests/profiler_data', array( 'mongodb://user:password@localhost:27009,localhost:27010/?replicaSet=rs-name&authSource=admin', 'symfony_tests', - 'profiler_data' - )) + 'profiler_data', + )), ); } diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/AmPmTransformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/AmPmTransformer.php index eb61e2e7cc132..31eca0d8f0e97 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/AmPmTransformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/AmPmTransformer.php @@ -40,7 +40,7 @@ public function getReverseMatchingRegExp($length) public function extractDateOptions($matched, $length) { return array( - 'marker' => $matched + 'marker' => $matched, ); } } diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php index d812cc44357dd..bfd1f32448820 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php @@ -270,7 +270,7 @@ protected function normalizeArray(array $data) $ret[$key[0]] = array( 'value' => $value, - 'pattern' => $key + 'pattern' => $key, ); } diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1200Transformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1200Transformer.php index a7a1794ae3b51..117b4f22234e7 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1200Transformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1200Transformer.php @@ -56,7 +56,7 @@ public function extractDateOptions($matched, $length) { return array( 'hour' => (int) $matched, - 'hourInstance' => $this + 'hourInstance' => $this, ); } } diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1201Transformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1201Transformer.php index 8a6595718dcfd..0a5d36f30c70c 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1201Transformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1201Transformer.php @@ -56,7 +56,7 @@ public function extractDateOptions($matched, $length) { return array( 'hour' => (int) $matched, - 'hourInstance' => $this + 'hourInstance' => $this, ); } } diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2400Transformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2400Transformer.php index 64702685fb31a..337ba0ebfb058 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2400Transformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2400Transformer.php @@ -55,7 +55,7 @@ public function extractDateOptions($matched, $length) { return array( 'hour' => (int) $matched, - 'hourInstance' => $this + 'hourInstance' => $this, ); } } diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2401Transformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2401Transformer.php index 18a2b0bd031af..082eabf942623 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2401Transformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2401Transformer.php @@ -58,7 +58,7 @@ public function extractDateOptions($matched, $length) { return array( 'hour' => (int) $matched, - 'hourInstance' => $this + 'hourInstance' => $this, ); } } diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/MonthTransformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/MonthTransformer.php index 874ace829bf25..7ed17c2293bbf 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/MonthTransformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/MonthTransformer.php @@ -33,7 +33,7 @@ class MonthTransformer extends Transformer 'September', 'October', 'November', - 'December' + 'December', ); /** diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php index b94fccd36a86e..96111b725ef9e 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php @@ -53,7 +53,7 @@ public function getReverseMatchingRegExp($length) public function extractDateOptions($matched, $length) { return array( - 'timezone' => self::getEtcTimeZoneId($matched) + 'timezone' => self::getEtcTimeZoneId($matched), ); } diff --git a/src/Symfony/Component/Intl/Intl.php b/src/Symfony/Component/Intl/Intl.php index df42a8c11c72f..a5db43ee8443b 100644 --- a/src/Symfony/Component/Intl/Intl.php +++ b/src/Symfony/Component/Intl/Intl.php @@ -207,5 +207,7 @@ private static function getBundleReader() /** * This class must not be instantiated. */ - private function __construct() {} + private function __construct() + { + } } diff --git a/src/Symfony/Component/Intl/Locale.php b/src/Symfony/Component/Intl/Locale.php index d7e0d33e84070..87415d4515bb4 100644 --- a/src/Symfony/Component/Intl/Locale.php +++ b/src/Symfony/Component/Intl/Locale.php @@ -44,5 +44,7 @@ public static function getFallback($locale) /** * This class must not be instantiated. */ - private function __construct() {} + private function __construct() + { + } } diff --git a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php index 52868bb40881b..4d7131e6dc931 100644 --- a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php +++ b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php @@ -154,7 +154,7 @@ class NumberFormatter private $attributes = array( self::FRACTION_DIGITS => 0, self::GROUPING_USED => 1, - self::ROUNDING_MODE => self::ROUND_HALFEVEN + self::ROUNDING_MODE => self::ROUND_HALFEVEN, ); /** @@ -171,7 +171,7 @@ class NumberFormatter */ private static $supportedStyles = array( 'CURRENCY' => self::CURRENCY, - 'DECIMAL' => self::DECIMAL + 'DECIMAL' => self::DECIMAL, ); /** @@ -182,7 +182,7 @@ class NumberFormatter private static $supportedAttributes = array( 'FRACTION_DIGITS' => self::FRACTION_DIGITS, 'GROUPING_USED' => self::GROUPING_USED, - 'ROUNDING_MODE' => self::ROUNDING_MODE + 'ROUNDING_MODE' => self::ROUNDING_MODE, ); /** @@ -195,7 +195,7 @@ class NumberFormatter private static $roundingModes = array( 'ROUND_HALFEVEN' => self::ROUND_HALFEVEN, 'ROUND_HALFDOWN' => self::ROUND_HALFDOWN, - 'ROUND_HALFUP' => self::ROUND_HALFUP + 'ROUND_HALFUP' => self::ROUND_HALFUP, ); /** @@ -209,7 +209,7 @@ class NumberFormatter private static $phpRoundingMap = array( self::ROUND_HALFDOWN => \PHP_ROUND_HALF_DOWN, self::ROUND_HALFEVEN => \PHP_ROUND_HALF_EVEN, - self::ROUND_HALFUP => \PHP_ROUND_HALF_UP + self::ROUND_HALFUP => \PHP_ROUND_HALF_UP, ); /** @@ -219,7 +219,7 @@ class NumberFormatter */ private static $int32Range = array( 'positive' => 2147483647, - 'negative' => -2147483648 + 'negative' => -2147483648, ); /** @@ -229,7 +229,7 @@ class NumberFormatter */ private static $int64Range = array( 'positive' => 9223372036854775807, - 'negative' => -9223372036854775808 + 'negative' => -9223372036854775808, ); private static $enSymbols = array( diff --git a/src/Symfony/Component/Intl/ResourceBundle/Compiler/BundleCompiler.php b/src/Symfony/Component/Intl/ResourceBundle/Compiler/BundleCompiler.php index 8249f66d0d686..9075842b9ab80 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Compiler/BundleCompiler.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Compiler/BundleCompiler.php @@ -38,7 +38,7 @@ class BundleCompiler implements BundleCompilerInterface */ public function __construct($genrb = 'genrb', $envVars = '') { - exec('which ' . $genrb, $output, $status); + exec('which '.$genrb, $output, $status); if (0 !== $status) { throw new RuntimeException(sprintf( @@ -47,7 +47,7 @@ public function __construct($genrb = 'genrb', $envVars = '') )); } - $this->genrb = ($envVars ? $envVars . ' ' : '') . $genrb; + $this->genrb = ($envVars ? $envVars.' ' : '').$genrb; } /** diff --git a/src/Symfony/Component/Intl/ResourceBundle/Reader/BufferedBundleReader.php b/src/Symfony/Component/Intl/ResourceBundle/Reader/BufferedBundleReader.php index 19f6d672afbf7..2a79385e61c52 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Reader/BufferedBundleReader.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Reader/BufferedBundleReader.php @@ -45,7 +45,7 @@ public function __construct(BundleReaderInterface $reader, $bufferSize) */ public function read($path, $locale) { - $hash = $path . '//' . $locale; + $hash = $path.'//'.$locale; if (!isset($this->buffer[$hash])) { $this->buffer[$hash] = $this->reader->read($path, $locale); diff --git a/src/Symfony/Component/Intl/ResourceBundle/Transformer/BundleTransformer.php b/src/Symfony/Component/Intl/ResourceBundle/Transformer/BundleTransformer.php index c613486f18f81..4f5a7a104b353 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Transformer/BundleTransformer.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Transformer/BundleTransformer.php @@ -57,7 +57,7 @@ public function compileBundles(CompilationContextInterface $context) $filesystem->mkdir($context->getBinaryDir()); foreach ($this->rules as $rule) { - $filesystem->mkdir($context->getBinaryDir() . '/' . $rule->getBundleName()); + $filesystem->mkdir($context->getBinaryDir().'/'.$rule->getBundleName()); $resources = (array) $rule->beforeCompile($context); @@ -70,7 +70,7 @@ public function compileBundles(CompilationContextInterface $context) )); } - $compiler->compile($resource, $context->getBinaryDir() . '/' . $rule->getBundleName()); + $compiler->compile($resource, $context->getBinaryDir().'/'.$rule->getBundleName()); } $rule->afterCompile($context); @@ -86,11 +86,11 @@ public function createStubs(StubbingContextInterface $context) $filesystem->mkdir($context->getStubDir()); foreach ($this->rules as $rule) { - $filesystem->mkdir($context->getStubDir() . '/' . $rule->getBundleName()); + $filesystem->mkdir($context->getStubDir().'/'.$rule->getBundleName()); $data = $rule->beforeCreateStub($context); - $phpWriter->write($context->getStubDir() . '/' . $rule->getBundleName(), 'en', $data); + $phpWriter->write($context->getStubDir().'/'.$rule->getBundleName(), 'en', $data); $rule->afterCreateStub($context); } diff --git a/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php b/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php index d38cfc7b700f7..e594853657019 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php @@ -43,12 +43,12 @@ public function beforeCompile(CompilationContextInterface $context) // in ICU <= 4.2 if (IcuVersion::compare($context->getIcuVersion(), '4.2', '<=', 1)) { return array( - $context->getSourceDir() . '/misc/supplementalData.txt', - $context->getSourceDir() . '/locales' + $context->getSourceDir().'/misc/supplementalData.txt', + $context->getSourceDir().'/locales', ); } - return $context->getSourceDir() . '/curr'; + return $context->getSourceDir().'/curr'; } /** @@ -59,8 +59,8 @@ public function afterCompile(CompilationContextInterface $context) // \ResourceBundle does not like locale names with uppercase chars, so rename // the resource file // See: http://bugs.php.net/bug.php?id=54025 - $fileName = $context->getBinaryDir() . '/curr/supplementalData.res'; - $fileNameLower = $context->getBinaryDir() . '/curr/supplementaldata.res'; + $fileName = $context->getBinaryDir().'/curr/supplementalData.res'; + $fileNameLower = $context->getBinaryDir().'/curr/supplementaldata.res'; $context->getFilesystem()->rename($fileName, $fileNameLower); } diff --git a/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LanguageBundleTransformationRule.php b/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LanguageBundleTransformationRule.php index 7d78d7488034c..e55d84475d5c4 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LanguageBundleTransformationRule.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LanguageBundleTransformationRule.php @@ -40,10 +40,10 @@ public function beforeCompile(CompilationContextInterface $context) { // The language data is contained in the locales bundle in ICU <= 4.2 if (IcuVersion::compare($context->getIcuVersion(), '4.2', '<=', 1)) { - return $context->getSourceDir() . '/locales'; + return $context->getSourceDir().'/locales'; } - return $context->getSourceDir() . '/lang'; + return $context->getSourceDir().'/lang'; } /** diff --git a/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LocaleBundleTransformationRule.php b/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LocaleBundleTransformationRule.php index 22ec9113721a9..427b80e89418d 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LocaleBundleTransformationRule.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LocaleBundleTransformationRule.php @@ -55,7 +55,7 @@ public function getBundleName() */ public function beforeCompile(CompilationContextInterface $context) { - $tempDir = sys_get_temp_dir() . '/icu-data-locales'; + $tempDir = sys_get_temp_dir().'/icu-data-locales'; $context->getFilesystem()->remove($tempDir); $context->getFilesystem()->mkdir($tempDir); @@ -70,7 +70,7 @@ public function beforeCompile(CompilationContextInterface $context) */ public function afterCompile(CompilationContextInterface $context) { - $context->getFilesystem()->remove(sys_get_temp_dir() . '/icu-data-locales'); + $context->getFilesystem()->remove(sys_get_temp_dir().'/icu-data-locales'); } /** @@ -92,17 +92,17 @@ public function afterCreateStub(StubbingContextInterface $context) private function scanLocales(CompilationContextInterface $context) { - $tempDir = sys_get_temp_dir() . '/icu-data-locales-source'; + $tempDir = sys_get_temp_dir().'/icu-data-locales-source'; $context->getFilesystem()->remove($tempDir); $context->getFilesystem()->mkdir($tempDir); // Temporarily generate the resource bundles - $context->getCompiler()->compile($context->getSourceDir() . '/locales', $tempDir); + $context->getCompiler()->compile($context->getSourceDir().'/locales', $tempDir); // Discover the list of supported locales, which are the names of the resource // bundles in the "locales" directory - $locales = glob($tempDir . '/*.res'); + $locales = glob($tempDir.'/*.res'); // Remove file extension and sort array_walk($locales, function (&$locale) { $locale = basename($locale, '.res'); }); @@ -112,7 +112,7 @@ private function scanLocales(CompilationContextInterface $context) foreach ($locales as $key => $locale) { // Delete all aliases from the list // i.e., "az_AZ" is an alias for "az_Latn_AZ" - $content = file_get_contents($context->getSourceDir() . '/locales/' . $locale . '.txt'); + $content = file_get_contents($context->getSourceDir().'/locales/'.$locale.'.txt'); // The key "%%ALIAS" is not accessible through the \ResourceBundle class, // so look in the original .txt file instead @@ -129,7 +129,7 @@ private function scanLocales(CompilationContextInterface $context) } if (null === $bundle) { - throw new RuntimeException('The resource bundle for locale ' . $locale . ' could not be loaded from directory ' . $tempDir); + throw new RuntimeException('The resource bundle for locale '.$locale.' could not be loaded from directory '.$tempDir); } // There seems to be no other way for identifying all keys in this specific diff --git a/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/RegionBundleTransformationRule.php b/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/RegionBundleTransformationRule.php index 300ad02563acc..37cd40706bce0 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/RegionBundleTransformationRule.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/RegionBundleTransformationRule.php @@ -40,10 +40,10 @@ public function beforeCompile(CompilationContextInterface $context) { // The region data is contained in the locales bundle in ICU <= 4.2 if (IcuVersion::compare($context->getIcuVersion(), '4.2', '<=', 1)) { - return $context->getSourceDir() . '/locales'; + return $context->getSourceDir().'/locales'; } - return $context->getSourceDir() . '/region'; + return $context->getSourceDir().'/region'; } /** diff --git a/src/Symfony/Component/Intl/ResourceBundle/Util/RecursiveArrayAccess.php b/src/Symfony/Component/Intl/ResourceBundle/Util/RecursiveArrayAccess.php index 0c22550401cb2..3b34b9e1fe8e0 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Util/RecursiveArrayAccess.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Util/RecursiveArrayAccess.php @@ -35,7 +35,7 @@ public static function get($array, array $indices) continue; } } - + throw new OutOfBoundsException(sprintf( 'The index %s does not exist.', $index @@ -45,5 +45,7 @@ public static function get($array, array $indices) return $array; } - private function __construct() {} + private function __construct() + { + } } diff --git a/src/Symfony/Component/Intl/ResourceBundle/Writer/TextBundleWriter.php b/src/Symfony/Component/Intl/ResourceBundle/Writer/TextBundleWriter.php index 2aa702089f1eb..0b3acc4dd632b 100644 --- a/src/Symfony/Component/Intl/ResourceBundle/Writer/TextBundleWriter.php +++ b/src/Symfony/Component/Intl/ResourceBundle/Writer/TextBundleWriter.php @@ -87,7 +87,7 @@ private function writeResource($file, $value, $indentation, $requireBraces = tru $intValues = count($value) === count(array_filter($value, 'is_int')); $keys = array_keys($value); - + // check that the keys are 0-indexed and ascending $intKeys = $keys === range(0, count($keys) - 1); diff --git a/src/Symfony/Component/Intl/Resources/bin/autoload.php b/src/Symfony/Component/Intl/Resources/bin/autoload.php index e45001152185b..ae058fd70df1a 100644 --- a/src/Symfony/Component/Intl/Resources/bin/autoload.php +++ b/src/Symfony/Component/Intl/Resources/bin/autoload.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -$autoload = __DIR__ . '/../../vendor/autoload.php'; +$autoload = __DIR__.'/../../vendor/autoload.php'; if (!file_exists($autoload)) { bailout('You should run "composer install --dev" in the component before running this script.'); diff --git a/src/Symfony/Component/Intl/Resources/bin/copy-stubs-to-component.php b/src/Symfony/Component/Intl/Resources/bin/copy-stubs-to-component.php index 76eeecfc834e2..6f7e7a07c9acb 100644 --- a/src/Symfony/Component/Intl/Resources/bin/copy-stubs-to-component.php +++ b/src/Symfony/Component/Intl/Resources/bin/copy-stubs-to-component.php @@ -12,8 +12,8 @@ use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Icu\IcuData; -require_once __DIR__ . '/common.php'; -require_once __DIR__ . '/autoload.php'; +require_once __DIR__.'/common.php'; +require_once __DIR__.'/autoload.php'; if (1 !== $GLOBALS['argc']) { bailout(<<exists($sourceDir)) { diff --git a/src/Symfony/Component/Intl/Resources/bin/create-stubs.php b/src/Symfony/Component/Intl/Resources/bin/create-stubs.php index d330d6b5fb5cf..7dc3fcb6f4e9b 100644 --- a/src/Symfony/Component/Intl/Resources/bin/create-stubs.php +++ b/src/Symfony/Component/Intl/Resources/bin/create-stubs.php @@ -19,8 +19,8 @@ use Symfony\Component\Intl\ResourceBundle\Transformer\Rule\RegionBundleTransformationRule; use Symfony\Component\Intl\ResourceBundle\Transformer\StubbingContext; -require_once __DIR__ . '/common.php'; -require_once __DIR__ . '/autoload.php'; +require_once __DIR__.'/common.php'; +require_once __DIR__.'/autoload.php'; if (1 !== $GLOBALS['argc']) { bailout(<<getStubDir() . '/version.txt'; +$versionFile = $context->getStubDir().'/version.txt'; file_put_contents($versionFile, "$icuVersionInIcuComponent\n"); diff --git a/src/Symfony/Component/Intl/Resources/bin/icu-version.php b/src/Symfony/Component/Intl/Resources/bin/icu-version.php index d54916f52b908..9b5d2977a8c25 100644 --- a/src/Symfony/Component/Intl/Resources/bin/icu-version.php +++ b/src/Symfony/Component/Intl/Resources/bin/icu-version.php @@ -11,8 +11,8 @@ use Symfony\Component\Intl\Intl; -require_once __DIR__ . '/common.php'; -require_once __DIR__ . '/autoload.php'; +require_once __DIR__.'/common.php'; +require_once __DIR__.'/autoload.php'; echo "ICU version: "; -echo Intl::getIcuVersion() . "\n"; +echo Intl::getIcuVersion()."\n"; diff --git a/src/Symfony/Component/Intl/Resources/bin/test-compat.php b/src/Symfony/Component/Intl/Resources/bin/test-compat.php index c1bf40f794f7c..22934bacfcc4b 100644 --- a/src/Symfony/Component/Intl/Resources/bin/test-compat.php +++ b/src/Symfony/Component/Intl/Resources/bin/test-compat.php @@ -11,8 +11,8 @@ use Symfony\Component\Intl\Intl; -require_once __DIR__ . '/common.php'; -require_once __DIR__ . '/autoload.php'; +require_once __DIR__.'/common.php'; +require_once __DIR__.'/autoload.php'; if (1 !== $GLOBALS['argc']) { bailout(<<&1'); + run('git checkout '.$branch.' 2>&1'); - exec('php ' . __DIR__ . '/util/test-compat-helper.php > /dev/null 2> /dev/null', $output, $status); + exec('php '.__DIR__.'/util/test-compat-helper.php > /dev/null 2> /dev/null', $output, $status); - echo "$branch: " . (0 === $status ? "YES" : "NO") . "\n"; + echo "$branch: ".(0 === $status ? "YES" : "NO")."\n"; } echo "Done.\n"; diff --git a/src/Symfony/Component/Intl/Resources/bin/update-icu-component.php b/src/Symfony/Component/Intl/Resources/bin/update-icu-component.php index 2b94fe417fe43..3e6ed79c48d3b 100644 --- a/src/Symfony/Component/Intl/Resources/bin/update-icu-component.php +++ b/src/Symfony/Component/Intl/Resources/bin/update-icu-component.php @@ -21,8 +21,8 @@ use Symfony\Component\Intl\Util\SvnRepository; use Symfony\Component\Filesystem\Filesystem; -require_once __DIR__ . '/common.php'; -require_once __DIR__ . '/autoload.php'; +require_once __DIR__.'/common.php'; +require_once __DIR__.'/autoload.php'; if ($GLOBALS['argc'] > 3 || 2 === $GLOBALS['argc'] && '-h' === $GLOBALS['argv'][1]) { bailout(<<remove($buildDir); $filesystem->mkdir($buildDir); - run('./configure --prefix=' . $buildDir . ' 2>&1'); + run('./configure --prefix='.$buildDir.' 2>&1'); echo "Running make...\n"; // If the directory "lib" does not exist in the download, create it or we // will run into problems when building libicuuc.so. - $filesystem->mkdir($sourceDir . '/lib'); + $filesystem->mkdir($sourceDir.'/lib'); // If the directory "bin" does not exist in the download, create it or we // will run into problems when building genrb. - $filesystem->mkdir($sourceDir . '/bin'); + $filesystem->mkdir($sourceDir.'/bin'); echo "[1/5] libicudata.so..."; - cd($sourceDir . '/stubdata'); + cd($sourceDir.'/stubdata'); run('make 2>&1 && make install 2>&1'); echo " ok.\n"; echo "[2/5] libicuuc.so..."; - cd($sourceDir . '/common'); + cd($sourceDir.'/common'); run('make 2>&1 && make install 2>&1'); echo " ok.\n"; echo "[3/5] libicui18n.so..."; - cd($sourceDir . '/i18n'); + cd($sourceDir.'/i18n'); run('make 2>&1 && make install 2>&1'); echo " ok.\n"; echo "[4/5] libicutu.so..."; - cd($sourceDir . '/tools/toolutil'); + cd($sourceDir.'/tools/toolutil'); run('make 2>&1 && make install 2>&1'); echo " ok.\n"; echo "[5/5] genrb..."; - cd($sourceDir . '/tools/genrb'); + cd($sourceDir.'/tools/genrb'); run('make 2>&1 && make install 2>&1'); echo " ok.\n"; } -$genrb = $buildDir . '/bin/genrb'; -$genrbEnv = 'LD_LIBRARY_PATH=' . $buildDir . '/lib '; +$genrb = $buildDir.'/bin/genrb'; +$genrbEnv = 'LD_LIBRARY_PATH='.$buildDir.'/lib '; echo "Using $genrb.\n"; -$icuVersionInDownload = get_icu_version_from_genrb($genrbEnv . ' ' . $genrb); +$icuVersionInDownload = get_icu_version_from_genrb($genrbEnv.' '.$genrb); echo "Preparing resource bundle compilation (version $icuVersionInDownload)...\n"; $context = new CompilationContext( - $sourceDir . '/data', + $sourceDir.'/data', IcuData::getResourceDirectory(), $filesystem, new BundleCompiler($genrb, $genrbEnv), @@ -197,13 +197,13 @@ SVN_INFO; -$svnInfoFile = $context->getBinaryDir() . '/svn-info.txt'; +$svnInfoFile = $context->getBinaryDir().'/svn-info.txt'; file_put_contents($svnInfoFile, $svnInfo); echo "Wrote $svnInfoFile.\n"; -$versionFile = $context->getBinaryDir() . '/version.txt'; +$versionFile = $context->getBinaryDir().'/version.txt'; file_put_contents($versionFile, "$icuVersionInDownload\n"); diff --git a/src/Symfony/Component/Intl/Resources/bin/util/test-compat-helper.php b/src/Symfony/Component/Intl/Resources/bin/util/test-compat-helper.php index 2734895c6d12a..648b09b0b53bf 100644 --- a/src/Symfony/Component/Intl/Resources/bin/util/test-compat-helper.php +++ b/src/Symfony/Component/Intl/Resources/bin/util/test-compat-helper.php @@ -12,12 +12,12 @@ use Symfony\Component\Icu\IcuData; use Symfony\Component\Intl\ResourceBundle\Reader\BinaryBundleReader; -require_once __DIR__ . '/../common.php'; -require_once __DIR__ . '/../autoload.php'; +require_once __DIR__.'/../common.php'; +require_once __DIR__.'/../autoload.php'; $reader = new BinaryBundleReader(); -$reader->read(IcuData::getResourceDirectory() . '/curr', 'en'); -$reader->read(IcuData::getResourceDirectory() . '/lang', 'en'); -$reader->read(IcuData::getResourceDirectory() . '/locales', 'en'); -$reader->read(IcuData::getResourceDirectory() . '/region', 'en'); +$reader->read(IcuData::getResourceDirectory().'/curr', 'en'); +$reader->read(IcuData::getResourceDirectory().'/lang', 'en'); +$reader->read(IcuData::getResourceDirectory().'/locales', 'en'); +$reader->read(IcuData::getResourceDirectory().'/region', 'en'); diff --git a/src/Symfony/Component/Intl/Resources/stubs/functions.php b/src/Symfony/Component/Intl/Resources/stubs/functions.php index b552d0e859ca4..f787654717312 100644 --- a/src/Symfony/Component/Intl/Resources/stubs/functions.php +++ b/src/Symfony/Component/Intl/Resources/stubs/functions.php @@ -12,7 +12,6 @@ use Symfony\Component\Intl\Globals\IntlGlobals; if (!function_exists('intl_is_failure')) { - /** * Stub implementation for the {@link intl_is_failure()} function of the intl * extension. @@ -76,5 +75,4 @@ function intl_error_name($errorCode) { return IntlGlobals::getErrorName($errorCode); } - } diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php index 1a68d90f4228e..2c6f5558fffa2 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php @@ -22,7 +22,6 @@ */ abstract class AbstractIntlDateFormatterTest extends \PHPUnit_Framework_TestCase { - protected function setUp() { \Locale::setDefault('en'); @@ -272,7 +271,7 @@ public function formatErrorProvider() // With PHP 5.5 IntlDateFormatter accepts empty values ('0') if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { return array( - array('y-M-d', 'foobar', 'datefmt_format: string \'foobar\' is not numeric, which would be required for it to be a valid date: U_ILLEGAL_ARGUMENT_ERROR') + array('y-M-d', 'foobar', 'datefmt_format: string \'foobar\' is not numeric, which would be required for it to be a valid date: U_ILLEGAL_ARGUMENT_ERROR'), ); } diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php index 64645167346e8..212a115d6eb31 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php @@ -49,7 +49,7 @@ public function testFormatWithUnsupportedTimestampArgument() 'tm_year' => 112, 'tm_wday' => 0, 'tm_yday' => 105, - 'tm_isdst' => 0 + 'tm_isdst' => 0, ); try { diff --git a/src/Symfony/Component/Intl/Tests/Locale/LocaleTest.php b/src/Symfony/Component/Intl/Tests/Locale/LocaleTest.php index 2a5d5d2db710d..7da0e2a5333c3 100644 --- a/src/Symfony/Component/Intl/Tests/Locale/LocaleTest.php +++ b/src/Symfony/Component/Intl/Tests/Locale/LocaleTest.php @@ -29,7 +29,7 @@ public function testComposeLocale() $subtags = array( 'language' => 'pt', 'script' => 'Latn', - 'region' => 'BR' + 'region' => 'BR', ); $this->call('composeLocale', $subtags); } @@ -129,7 +129,7 @@ public function testLookup() { $langtag = array( 'pt-Latn-BR', - 'pt-BR' + 'pt-BR', ); $this->call('lookup', $langtag, 'pt-BR-x-priv1'); } diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php index e1938de3fea22..32f0579908c70 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php @@ -49,7 +49,7 @@ public function formatCurrencyWithDecimalStyleProvider() array(1000.12, 'BRL', '1,000.12'), array(1000.12, 'CRC', '1,000.12'), array(1000.12, 'JPY', '1,000.12'), - array(1000.12, 'CHF', '1,000.12') + array(1000.12, 'CHF', '1,000.12'), ); } @@ -126,7 +126,7 @@ public function formatCurrencyWithCurrencyStyleBrazilianRealRoundingProvider() array(1000.127, 'BRL', 'R', '%s$1,000.13'), array(1000.129, 'BRL', 'R', '%s$1,000.13'), array(11.50999, 'BRL', 'R', '%s$11.51'), - array(11.9999464, 'BRL', 'R', '%s$12.00') + array(11.9999464, 'BRL', 'R', '%s$12.00'), ); } @@ -159,7 +159,7 @@ public function formatCurrencyWithCurrencyStyleSwissRoundingProvider() array(1200000.00, 'CHF', 'CHF', '%s1,200,000.00'), array(1200000.1, 'CHF', 'CHF', '%s1,200,000.10'), array(1200000.10, 'CHF', 'CHF', '%s1,200,000.10'), - array(1200000.101, 'CHF', 'CHF', '%s1,200,000.10') + array(1200000.101, 'CHF', 'CHF', '%s1,200,000.10'), ); } @@ -227,7 +227,7 @@ public function formatTypeInt32WithCurrencyStyleProvider() array($formatter, 1, '¤1.00'), array($formatter, 1.1, '¤1.00'), array($formatter, 2147483648, '(¤2,147,483,648.00)', $message), - array($formatter, -2147483649, '¤2,147,483,647.00', $message) + array($formatter, -2147483649, '¤2,147,483,647.00', $message), ); } @@ -270,7 +270,7 @@ public function formatTypeInt64WithCurrencyStyleProvider() array($formatter, 1, '¤1.00'), array($formatter, 1.1, '¤1.00'), array($formatter, 2147483648, '¤2,147,483,648.00'), - array($formatter, -2147483649, '(¤2,147,483,649.00)') + array($formatter, -2147483649, '(¤2,147,483,649.00)'), ); } @@ -369,7 +369,7 @@ public function formatFractionDigitsProvider() array(1.123, '1.1', 1, 1), array(1.123, '1.12', 2, 2), array(1.123, '1', -1, 0), - array(1.123, '1', 'abc', 0) + array(1.123, '1', 'abc', 0), ); } @@ -575,7 +575,7 @@ public function parseTypeInt32Provider() array('2,147,483,647', 2147483647), array('-2,147,483,648', -2147483647 - 1), array('2,147,483,648', false, '->parse() TYPE_INT32 returns false when the number is greater than the integer positive range.'), - array('-2,147,483,649', false, '->parse() TYPE_INT32 returns false when the number is greater than the integer negative range.') + array('-2,147,483,649', false, '->parse() TYPE_INT32 returns false when the number is greater than the integer negative range.'), ); } diff --git a/src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/PhpBundleWriterTest.php b/src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/PhpBundleWriterTest.php index 03302834d77a0..f9e0de8e3892e 100644 --- a/src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/PhpBundleWriterTest.php +++ b/src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/PhpBundleWriterTest.php @@ -34,7 +34,7 @@ class PhpBundleWriterTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->writer = new PhpBundleWriter(); - $this->directory = sys_get_temp_dir() . '/PhpBundleWriterTest/' . rand(1000, 9999); + $this->directory = sys_get_temp_dir().'/PhpBundleWriterTest/'.rand(1000, 9999); $this->filesystem = new Filesystem(); $this->filesystem->mkdir($this->directory); @@ -57,6 +57,6 @@ public function testWrite() 'Entry2' => 'String', )); - $this->assertFileEquals(__DIR__ . '/Fixtures/en.php', $this->directory . '/en.php'); + $this->assertFileEquals(__DIR__.'/Fixtures/en.php', $this->directory.'/en.php'); } } diff --git a/src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/TextBundleWriterTest.php b/src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/TextBundleWriterTest.php index f42b2738d797c..b3304fbb0633e 100644 --- a/src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/TextBundleWriterTest.php +++ b/src/Symfony/Component/Intl/Tests/ResourceBundle/Writer/TextBundleWriterTest.php @@ -92,7 +92,7 @@ public function testWriteTraversable() public function testWriteNoFallback() { $data = array( - 'Entry' => 'Value' + 'Entry' => 'Value', ); $this->writer->write($this->directory, 'en_nofallback', $data, $fallback = false); diff --git a/src/Symfony/Component/Intl/Util/IcuVersion.php b/src/Symfony/Component/Intl/Util/IcuVersion.php index 0eface090e894..e0ff28ff68320 100644 --- a/src/Symfony/Component/Intl/Util/IcuVersion.php +++ b/src/Symfony/Component/Intl/Util/IcuVersion.php @@ -101,5 +101,7 @@ public static function normalize($version, $precision) /** * Must not be instantiated. */ - private function __construct() {} + private function __construct() + { + } } diff --git a/src/Symfony/Component/Intl/Util/IntlTestHelper.php b/src/Symfony/Component/Intl/Util/IntlTestHelper.php index cace36c6f5bed..d90352366832f 100644 --- a/src/Symfony/Component/Intl/Util/IntlTestHelper.php +++ b/src/Symfony/Component/Intl/Util/IntlTestHelper.php @@ -40,11 +40,11 @@ public static function requireIntl(\PhpUnit_Framework_TestCase $testCase) // * the intl extension is not loaded if (IcuVersion::compare(Intl::getIcuVersion(), Intl::getIcuStubVersion(), '!=', 1)) { - $testCase->markTestSkipped('Please change ICU version to ' . Intl::getIcuStubVersion()); + $testCase->markTestSkipped('Please change ICU version to '.Intl::getIcuStubVersion()); } if (IcuVersion::compare(Intl::getIcuDataVersion(), Intl::getIcuStubVersion(), '!=', 1)) { - $testCase->markTestSkipped('Please change the Icu component to version 1.0.x or 1.' . IcuVersion::normalize(Intl::getIcuStubVersion(), 1) . '.x'); + $testCase->markTestSkipped('Please change the Icu component to version 1.0.x or 1.'.IcuVersion::normalize(Intl::getIcuStubVersion(), 1).'.x'); } // Normalize the default locale in case this is not done explicitly @@ -76,12 +76,12 @@ public static function requireFullIntl(\PhpUnit_Framework_TestCase $testCase) // ... and only if the version is *one specific version* ... if (IcuVersion::compare(Intl::getIcuVersion(), Intl::getIcuStubVersion(), '!=', 1)) { - $testCase->markTestSkipped('Please change ICU version to ' . Intl::getIcuStubVersion()); + $testCase->markTestSkipped('Please change ICU version to '.Intl::getIcuStubVersion()); } // ... and only if the data in the Icu component matches that version. if (IcuVersion::compare(Intl::getIcuDataVersion(), Intl::getIcuStubVersion(), '!=', 1)) { - $testCase->markTestSkipped('Please change the Icu component to version 1.0.x or 1.' . IcuVersion::normalize(Intl::getIcuStubVersion(), 1) . '.x'); + $testCase->markTestSkipped('Please change the Icu component to version 1.0.x or 1.'.IcuVersion::normalize(Intl::getIcuStubVersion(), 1).'.x'); } // Normalize the default locale in case this is not done explicitly @@ -124,5 +124,7 @@ public static function require64Bit(\PhpUnit_Framework_TestCase $testCase) /** * Must not be instantiated. */ - private function __construct() {} + private function __construct() + { + } } diff --git a/src/Symfony/Component/Intl/Util/SvnRepository.php b/src/Symfony/Component/Intl/Util/SvnRepository.php index 3fb3acb4fd112..3b891b380c853 100644 --- a/src/Symfony/Component/Intl/Util/SvnRepository.php +++ b/src/Symfony/Component/Intl/Util/SvnRepository.php @@ -56,14 +56,14 @@ public static function download($url, $targetDir) $filesystem = new Filesystem(); - if (!$filesystem->exists($targetDir . '/.svn')) { + if (!$filesystem->exists($targetDir.'/.svn')) { $filesystem->remove($targetDir); $filesystem->mkdir($targetDir); - exec('svn checkout ' . $url . ' ' . $targetDir, $output, $result); + exec('svn checkout '.$url.' '.$targetDir, $output, $result); if ($result !== 0) { - throw new RuntimeException('The SVN checkout of ' . $url . 'failed.'); + throw new RuntimeException('The SVN checkout of '.$url.'failed.'); } } diff --git a/src/Symfony/Component/Intl/Util/Version.php b/src/Symfony/Component/Intl/Util/Version.php index d767b17c992ff..addf01eaf6638 100644 --- a/src/Symfony/Component/Intl/Util/Version.php +++ b/src/Symfony/Component/Intl/Util/Version.php @@ -73,7 +73,7 @@ public static function compare($version1, $version2, $operator, $precision = nul public static function normalize($version, $precision) { if (null === $precision) { - return $version; + return $version; } $pattern = '[^\.]+'; @@ -82,7 +82,7 @@ public static function normalize($version, $precision) $pattern = sprintf('[^\.]+(\.%s)?', $pattern); } - if (!preg_match('/^' . $pattern . '/', $version, $matches)) { + if (!preg_match('/^'.$pattern.'/', $version, $matches)) { return; } @@ -92,5 +92,7 @@ public static function normalize($version, $precision) /** * Must not be instantiated. */ - private function __construct() {} + private function __construct() + { + } } diff --git a/src/Symfony/Component/Locale/Stub/StubLocale.php b/src/Symfony/Component/Locale/Stub/StubLocale.php index a4b554be6c81b..ceb34755e4330 100644 --- a/src/Symfony/Component/Locale/Stub/StubLocale.php +++ b/src/Symfony/Component/Locale/Stub/StubLocale.php @@ -101,7 +101,7 @@ private static function prepareCurrencies($locale) 'name' => $name, 'symbol' => $bundle->getCurrencySymbol($currency, $locale), 'fractionDigits' => $bundle->getFractionDigits($currency), - 'roundingIncrement' => $bundle->getRoundingIncrement($currency) + 'roundingIncrement' => $bundle->getRoundingIncrement($currency), ); self::$currenciesNames[$currency] = $name; } diff --git a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php index d50cd3fcfe3e4..2bfe3469d1f61 100644 --- a/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php +++ b/src/Symfony/Component/OptionsResolver/Tests/OptionsResolverTest.php @@ -623,7 +623,7 @@ public function testResolveWithoutOptionSucceedsIfRequiredAndDefaultValue() )); $this->assertEquals(array( - 'foo' => 'bar' + 'foo' => 'bar', ), $this->resolver->resolve(array())); } @@ -637,7 +637,7 @@ public function testResolveWithoutOptionSucceedsIfDefaultValueAndRequired() )); $this->assertEquals(array( - 'foo' => 'bar' + 'foo' => 'bar', ), $this->resolver->resolve(array())); } @@ -652,7 +652,7 @@ public function testResolveSucceedsIfOptionRequiredAndValueAllowed() $options = array( 'one' => '1', - 'two' => '2' + 'two' => '2', ); $this->assertEquals($options, $this->resolver->resolve($options)); diff --git a/src/Symfony/Component/OptionsResolver/Tests/OptionsTest.php b/src/Symfony/Component/OptionsResolver/Tests/OptionsTest.php index e24a764714b74..5db0995685a00 100644 --- a/src/Symfony/Component/OptionsResolver/Tests/OptionsTest.php +++ b/src/Symfony/Component/OptionsResolver/Tests/OptionsTest.php @@ -372,7 +372,7 @@ public function testReplaceClearsAndSets() 'two' => '2', 'three' => function (Options $options) { return '2' === $options['two'] ? '3' : 'foo'; - } + }, )); $this->assertEquals(array( @@ -389,7 +389,6 @@ public function testClearRemovesAllOptions() $this->options->clear(); $this->assertEmpty($this->options->all()); - } /** diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 3185633fbfd25..908a126ffa6b7 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -315,7 +315,7 @@ public function wait($callback = null) do { $this->checkTimeout(); $running = defined('PHP_WINDOWS_VERSION_BUILD') ? $this->isRunning() : $this->processPipes->hasOpenHandles(); - $close = !defined('PHP_WINDOWS_VERSION_BUILD') || !$running;; + $close = !defined('PHP_WINDOWS_VERSION_BUILD') || !$running; $this->readPipes(true, $close); } while ($running); diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index b78c4777bed46..42435af88629f 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -145,7 +145,7 @@ public function testProcessResponses($expected, $getter, $code) */ public function testProcessPipes($code, $size) { - $expected = str_repeat(str_repeat('*', 1024), $size) . '!'; + $expected = str_repeat(str_repeat('*', 1024), $size).'!'; $expectedLength = (1024 * $size) + 1; $p = $this->getProcess(sprintf('php -r %s', escapeshellarg($code))); @@ -215,7 +215,7 @@ public function chainedCommandsOutputProvider() { if (defined('PHP_WINDOWS_VERSION_BUILD')) { return array( - array("2 \r\n2\r\n", '&&', '2') + array("2 \r\n2\r\n", '&&', '2'), ); } @@ -611,7 +611,6 @@ public function testRunProcessWithTimeout() $process->run(); $this->fail('A RuntimeException should have been raised'); } catch (RuntimeException $e) { - } $duration = microtime(true) - $start; @@ -655,7 +654,6 @@ public function testCheckTimeoutOnStartedProcess() } $this->fail('A RuntimeException should have been raised'); } catch (RuntimeException $e) { - } $duration = microtime(true) - $start; @@ -671,7 +669,6 @@ public function testStartAfterATimeout() $process->run(); $this->fail('An exception should have been raised.'); } catch (\Exception $e) { - } $process->start(); usleep(10000); @@ -703,7 +700,7 @@ public function testSignal() { $this->verifyPosixIsEnabled(); - $process = $this->getProcess('exec php -f ' . __DIR__ . '/SignalListener.php'); + $process = $this->getProcess('exec php -f '.__DIR__.'/SignalListener.php'); $process->start(); usleep(500000); $process->signal(SIGUSR1); @@ -875,7 +872,7 @@ public function methodProvider() array('WorkingDirectory'), array('Env'), array('Stdin'), - array('Options') + array('Options'), ); return $defaults; diff --git a/src/Symfony/Component/Process/Tests/NonStopableProcess.php b/src/Symfony/Component/Process/Tests/NonStopableProcess.php index d81abf4040dd7..2183e48c6436d 100644 --- a/src/Symfony/Component/Process/Tests/NonStopableProcess.php +++ b/src/Symfony/Component/Process/Tests/NonStopableProcess.php @@ -18,14 +18,14 @@ function handleSignal($signal) $name = 'SIGINT'; break; default: - $name = $signal . ' (unknown)'; + $name = $signal.' (unknown)'; break; } echo "received signal $name\n"; } -declare(ticks = 1); +declare (ticks = 1); pcntl_signal(SIGTERM, 'handleSignal'); pcntl_signal(SIGINT, 'handleSignal'); diff --git a/src/Symfony/Component/Process/Tests/PipeStdinInStdoutStdErrStreamSelect.php b/src/Symfony/Component/Process/Tests/PipeStdinInStdoutStdErrStreamSelect.php index cdc75255e7f18..89d1f6a1acafb 100644 --- a/src/Symfony/Component/Process/Tests/PipeStdinInStdoutStdErrStreamSelect.php +++ b/src/Symfony/Component/Process/Tests/PipeStdinInStdoutStdErrStreamSelect.php @@ -26,22 +26,22 @@ } if (in_array(STDOUT, $w) && strlen($out) > 0) { - $written = fwrite(STDOUT, (binary) $out, 32768); - if (false === $written) { - die(ERR_WRITE_FAILED); - } - $out = (binary) substr($out, $written); + $written = fwrite(STDOUT, (binary) $out, 32768); + if (false === $written) { + die(ERR_WRITE_FAILED); + } + $out = (binary) substr($out, $written); } if (null === $read && strlen($out) < 1) { $write = array_diff($write, array(STDOUT)); } if (in_array(STDERR, $w) && strlen($err) > 0) { - $written = fwrite(STDERR, (binary) $err, 32768); - if (false === $written) { - die(ERR_WRITE_FAILED); - } - $err = (binary) substr($err, $written); + $written = fwrite(STDERR, (binary) $err, 32768); + if (false === $written) { + die(ERR_WRITE_FAILED); + } + $err = (binary) substr($err, $written); } if (null === $read && strlen($err) < 1) { $write = array_diff($write, array(STDERR)); diff --git a/src/Symfony/Component/Process/Tests/SignalListener.php b/src/Symfony/Component/Process/Tests/SignalListener.php index 143515d4dcfea..32910e1706874 100644 --- a/src/Symfony/Component/Process/Tests/SignalListener.php +++ b/src/Symfony/Component/Process/Tests/SignalListener.php @@ -1,11 +1,11 @@ readPropertiesUntil($objectOrArray, $propertyPath, $propertyPath->getLength()); + $propertyValues = & $this->readPropertiesUntil($objectOrArray, $propertyPath, $propertyPath->getLength()); return $propertyValues[count($propertyValues) - 1][self::VALUE]; } @@ -62,7 +62,7 @@ public function setValue(&$objectOrArray, $propertyPath, $value) throw new UnexpectedTypeException($propertyPath, 'string or Symfony\Component\PropertyAccess\PropertyPathInterface'); } - $propertyValues =& $this->readPropertiesUntil($objectOrArray, $propertyPath, $propertyPath->getLength() - 1); + $propertyValues = & $this->readPropertiesUntil($objectOrArray, $propertyPath, $propertyPath->getLength() - 1); $overwrite = true; // Add the root object to the list @@ -72,7 +72,7 @@ public function setValue(&$objectOrArray, $propertyPath, $value) )); for ($i = count($propertyValues) - 1; $i >= 0; --$i) { - $objectOrArray =& $propertyValues[$i][self::VALUE]; + $objectOrArray = & $propertyValues[$i][self::VALUE]; if ($overwrite) { if (!is_object($objectOrArray) && !is_array($objectOrArray)) { @@ -90,7 +90,7 @@ public function setValue(&$objectOrArray, $propertyPath, $value) } } - $value =& $objectOrArray; + $value = & $objectOrArray; $overwrite = !$propertyValues[$i][self::IS_REF]; } } @@ -125,14 +125,14 @@ private function &readPropertiesUntil(&$objectOrArray, PropertyPathInterface $pr } if ($isIndex) { - $propertyValue =& $this->readIndex($objectOrArray, $property); + $propertyValue = & $this->readIndex($objectOrArray, $property); } else { - $propertyValue =& $this->readProperty($objectOrArray, $property); + $propertyValue = & $this->readProperty($objectOrArray, $property); } - $objectOrArray =& $propertyValue[self::VALUE]; + $objectOrArray = & $propertyValue[self::VALUE]; - $propertyValues[] =& $propertyValue; + $propertyValues[] = & $propertyValue; } return $propertyValues; @@ -157,12 +157,12 @@ private function &readIndex(&$array, $index) // Use an array instead of an object since performance is very crucial here $result = array( self::VALUE => null, - self::IS_REF => false + self::IS_REF => false, ); if (isset($array[$index])) { if (is_array($array)) { - $result[self::VALUE] =& $array[$index]; + $result[self::VALUE] = & $array[$index]; $result[self::IS_REF] = true; } else { $result[self::VALUE] = $array[$index]; @@ -191,7 +191,7 @@ private function &readProperty(&$object, $property) // very crucial here $result = array( self::VALUE => null, - self::IS_REF => false + self::IS_REF => false, ); if (!is_object($object)) { @@ -214,7 +214,7 @@ private function &readProperty(&$object, $property) } elseif ($reflClass->hasMethod('__get') && $reflClass->getMethod('__get')->isPublic()) { $result[self::VALUE] = $object->$property; } elseif ($classHasProperty && $reflClass->getProperty($property)->isPublic()) { - $result[self::VALUE] =& $object->$property; + $result[self::VALUE] = & $object->$property; $result[self::IS_REF] = true; } elseif (!$classHasProperty && property_exists($object, $property)) { // Needed to support \stdClass instances. We need to explicitly @@ -222,7 +222,7 @@ private function &readProperty(&$object, $property) // a *protected* property was found on the class, property_exists() // returns true, consequently the following line will result in a // fatal error. - $result[self::VALUE] =& $object->$property; + $result[self::VALUE] = & $object->$property; $result[self::IS_REF] = true; } elseif ($this->magicCall && $reflClass->hasMethod('__call') && $reflClass->getMethod('__call')->isPublic()) { // we call the getter and hope the __call do the job diff --git a/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php b/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php index af2c46f9040b8..3567a6f2d813f 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php +++ b/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php @@ -129,7 +129,7 @@ public function replace($offset, $length, $path, $pathOffset = 0, $pathLength = if ($offset < 0 && abs($offset) <= $this->getLength()) { $offset = $this->getLength() + $offset; } elseif (!isset($this->elements[$offset])) { - throw new OutOfBoundsException('The offset ' . $offset . ' is not within the property path'); + throw new OutOfBoundsException('The offset '.$offset.' is not within the property path'); } if (0 === $pathLength) { diff --git a/src/Symfony/Component/PropertyAccess/StringUtil.php b/src/Symfony/Component/PropertyAccess/StringUtil.php index dd9ee3496c652..cceac9b42fa8d 100644 --- a/src/Symfony/Component/PropertyAccess/StringUtil.php +++ b/src/Symfony/Component/PropertyAccess/StringUtil.php @@ -114,7 +114,9 @@ class StringUtil /** * This class should not be instantiated */ - private function __construct() {} + private function __construct() + { + } /** * Returns the singular form of a word diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php index 7da0c068ddd68..08e6e5e6d04b9 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorCollectionTest.php @@ -48,11 +48,17 @@ public function getAxes() class PropertyAccessorCollectionTest_CarCustomSingular { - public function addFoo($axis) {} + public function addFoo($axis) + { + } - public function removeFoo($axis) {} + public function removeFoo($axis) + { + } - public function getAxes() {} + public function getAxes() + { + } } class PropertyAccessorCollectionTest_Engine @@ -61,44 +67,66 @@ class PropertyAccessorCollectionTest_Engine class PropertyAccessorCollectionTest_CarOnlyAdder { - public function addAxis($axis) {} + public function addAxis($axis) + { + } - public function getAxes() {} + public function getAxes() + { + } } class PropertyAccessorCollectionTest_CarOnlyRemover { - public function removeAxis($axis) {} + public function removeAxis($axis) + { + } - public function getAxes() {} + public function getAxes() + { + } } class PropertyAccessorCollectionTest_CarNoAdderAndRemover { - public function getAxes() {} + public function getAxes() + { + } } class PropertyAccessorCollectionTest_CarNoAdderAndRemoverWithProperty { protected $axes = array(); - public function getAxes() {} + public function getAxes() + { + } } class PropertyAccessorCollectionTest_CompositeCar { - public function getStructure() {} + public function getStructure() + { + } - public function setStructure($structure) {} + public function setStructure($structure) + { + } } class PropertyAccessorCollectionTest_CarStructure { - public function addAxis($axis) {} + public function addAxis($axis) + { + } - public function removeAxis($axis) {} + public function removeAxis($axis) + { + } - public function getAxes() {} + public function getAxes() + { + } } abstract class PropertyAccessorCollectionTest extends \PHPUnit_Framework_TestCase diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php index e22ca097be56d..f788d3284b334 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php @@ -379,5 +379,4 @@ public function testSetValueUpdatesMagicCall() $this->assertEquals('foobar', $object->getMagicProperty()); } - } diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyPathBuilderTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyPathBuilderTest.php index 14300b1ded102..5955049246931 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyPathBuilderTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyPathBuilderTest.php @@ -77,7 +77,7 @@ public function testAppendUsingString() { $this->builder->append('new1[new2]'); - $path = new PropertyPath(self::PREFIX . '.new1[new2]'); + $path = new PropertyPath(self::PREFIX.'.new1[new2]'); $this->assertEquals($path, $this->builder->getPropertyPath()); } diff --git a/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php b/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php index 1aff5229819f9..a9c07162fe6ac 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/StringUtilTest.php @@ -151,9 +151,9 @@ public function testSingularify($plural, $singular) { $single = StringUtil::singularify($plural); if (is_string($singular) && is_array($single)) { - $this->fail("--- Expected\n`string`: " . $singular . "\n+++ Actual\n`array`: " . implode(', ', $single)); + $this->fail("--- Expected\n`string`: ".$singular."\n+++ Actual\n`array`: ".implode(', ', $single)); } elseif (is_array($singular) && is_string($single)) { - $this->fail("--- Expected\n`array`: " . implode(', ', $singular) . "\n+++ Actual\n`string`: " . $single); + $this->fail("--- Expected\n`array`: ".implode(', ', $singular)."\n+++ Actual\n`string`: ".$single); } $this->assertEquals($singular, $single); diff --git a/src/Symfony/Component/Routing/CompiledRoute.php b/src/Symfony/Component/Routing/CompiledRoute.php index 7878455427d41..5e4c96073e718 100644 --- a/src/Symfony/Component/Routing/CompiledRoute.php +++ b/src/Symfony/Component/Routing/CompiledRoute.php @@ -130,5 +130,4 @@ public function getHostVariables() { return $this->hostVariables; } - } diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php b/src/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php index 01d8c03589476..9ff74499c38d1 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php @@ -50,7 +50,6 @@ public function dump(array $options = array()) $prevHostRegex = ''; foreach ($this->getRoutes()->all() as $name => $route) { - $compiledRoute = $route->compile(); $hostRegex = $compiledRoute->getHostRegex(); diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php b/src/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php index 99cd3caae6b88..3563d5149f158 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php @@ -57,7 +57,6 @@ public function addPrefixRoute(DumperRoute $route) $prefix = $route->getRoute()->compile()->getStaticPrefix(); for ($collection = $this; null !== $collection; $collection = $collection->getParent()) { - // Same prefix, add to current leave if ($collection->prefix === $prefix) { $collection->add($route); diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php index e378d67ff950b..195c56e99e79d 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php @@ -307,7 +307,6 @@ private function compileRoute(Route $route, $name, $supportsRedirections, $paren $code .= sprintf(" return \$this->mergeDefaults(array_replace(%s), %s);\n" , implode(', ', $vars), str_replace("\n", '', var_export($route->getDefaults(), true))); - } elseif ($route->getDefaults()) { $code .= sprintf(" return %s;\n", str_replace("\n", '', var_export(array_replace($route->getDefaults(), array('_route' => $name)), true))); } else { diff --git a/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php b/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php index b58869f7afc69..50b85e3dd6926 100644 --- a/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php +++ b/src/Symfony/Component/Routing/Tests/Annotation/RouteTest.php @@ -43,7 +43,7 @@ public function getValidParameters() array('defaults', array('_controller' => 'MyBlogBundle:Blog:index'), 'getDefaults'), array('schemes', array('https'), 'getSchemes'), array('methods', array('GET', 'POST'), 'getMethods'), - array('host', array('{locale}.example.com'), 'getHost') + array('host', array('{locale}.example.com'), 'getHost'), ); } } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.php b/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.php index b8bbbb5f8f01d..f1ecfe9418ece 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.php @@ -15,7 +15,7 @@ $collection->add('blog_show_legacy', new Route( '/blog/{slug}', array('_controller' => 'MyBlogBundle:Blog:show'), - array('_method' => 'GET|POST|put|OpTiOnS', '_scheme' => 'https', 'locale' => '\w+',), + array('_method' => 'GET|POST|put|OpTiOnS', '_scheme' => 'https', 'locale' => '\w+'), array('compiler_class' => 'RouteCompiler'), '{locale}.example.com' )); diff --git a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php index 5f8ef491276c2..3b8c6cb7483d7 100644 --- a/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php +++ b/src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php @@ -320,7 +320,7 @@ public function testUrlEncoding() .'?query=%40%3A%5B%5D%2F%28%29%2A%27%22+%2B%2C%3B-._%7E%26%24%3C%3E%7C%7B%7D%25%5C%5E%60%21%3Ffoo%3Dbar%23id', $this->getGenerator($routes)->generate('test', array( 'varpath' => $chars, - 'query' => $chars + 'query' => $chars, )) ); } @@ -395,21 +395,21 @@ public function testWithHostDifferentFromContext() { $routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com')); - $this->assertEquals('//fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', array('name' =>'Fabien', 'locale' => 'fr'))); + $this->assertEquals('//fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', array('name' => 'Fabien', 'locale' => 'fr'))); } public function testWithHostSameAsContext() { $routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com')); - $this->assertEquals('/app.php/Fabien', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test', array('name' =>'Fabien', 'locale' => 'fr'))); + $this->assertEquals('/app.php/Fabien', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test', array('name' => 'Fabien', 'locale' => 'fr'))); } public function testWithHostSameAsContextAndAbsolute() { $routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com')); - $this->assertEquals('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test', array('name' =>'Fabien', 'locale' => 'fr'), true)); + $this->assertEquals('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test', array('name' => 'Fabien', 'locale' => 'fr'), true)); } /** @@ -452,16 +452,16 @@ public function testGenerateNetworkPath() $routes = $this->getRoutes('test', new Route('/{name}', array(), array('_scheme' => 'http'), array(), '{locale}.example.com')); $this->assertSame('//fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', - array('name' =>'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'network path with different host' + array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'network path with different host' ); $this->assertSame('//fr.example.com/app.php/Fabien?query=string', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test', - array('name' =>'Fabien', 'locale' => 'fr', 'query' => 'string'), UrlGeneratorInterface::NETWORK_PATH), 'network path although host same as context' + array('name' => 'Fabien', 'locale' => 'fr', 'query' => 'string'), UrlGeneratorInterface::NETWORK_PATH), 'network path although host same as context' ); $this->assertSame('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test', - array('name' =>'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'absolute URL because scheme requirement does not match context' + array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'absolute URL because scheme requirement does not match context' ); $this->assertSame('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', - array('name' =>'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::ABSOLUTE_URL), 'absolute URL with same scheme because it is requested' + array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::ABSOLUTE_URL), 'absolute URL with same scheme because it is requested' ); } @@ -477,22 +477,22 @@ public function testGenerateRelativePath() $generator = $this->getGenerator($routes, array('host' => 'example.com', 'pathInfo' => '/fabien/symfony-is-great/')); $this->assertSame('comments', $generator->generate('comments', - array('author' =>'fabien', 'article' => 'symfony-is-great'), UrlGeneratorInterface::RELATIVE_PATH) + array('author' => 'fabien', 'article' => 'symfony-is-great'), UrlGeneratorInterface::RELATIVE_PATH) ); $this->assertSame('comments?page=2', $generator->generate('comments', - array('author' =>'fabien', 'article' => 'symfony-is-great', 'page' => 2), UrlGeneratorInterface::RELATIVE_PATH) + array('author' => 'fabien', 'article' => 'symfony-is-great', 'page' => 2), UrlGeneratorInterface::RELATIVE_PATH) ); $this->assertSame('../twig-is-great/', $generator->generate('article', - array('author' =>'fabien', 'article' => 'twig-is-great'), UrlGeneratorInterface::RELATIVE_PATH) + array('author' => 'fabien', 'article' => 'twig-is-great'), UrlGeneratorInterface::RELATIVE_PATH) ); $this->assertSame('../../bernhard/forms-are-great/', $generator->generate('article', - array('author' =>'bernhard', 'article' => 'forms-are-great'), UrlGeneratorInterface::RELATIVE_PATH) + array('author' => 'bernhard', 'article' => 'forms-are-great'), UrlGeneratorInterface::RELATIVE_PATH) ); $this->assertSame('//bernhard.example.com/app.php/forms-are-great', $generator->generate('host', - array('author' =>'bernhard', 'article' => 'forms-are-great'), UrlGeneratorInterface::RELATIVE_PATH) + array('author' => 'bernhard', 'article' => 'forms-are-great'), UrlGeneratorInterface::RELATIVE_PATH) ); $this->assertSame('https://example.com/app.php/bernhard', $generator->generate('scheme', - array('author' =>'bernhard'), UrlGeneratorInterface::RELATIVE_PATH) + array('author' => 'bernhard'), UrlGeneratorInterface::RELATIVE_PATH) ); $this->assertSame('../../about', $generator->generate('unrelated', array(), UrlGeneratorInterface::RELATIVE_PATH) @@ -513,102 +513,102 @@ public function provideRelativePaths() array( '/same/dir/', '/same/dir/', - '' + '', ), array( '/same/file', '/same/file', - '' + '', ), array( '/', '/file', - 'file' + 'file', ), array( '/', '/dir/file', - 'dir/file' + 'dir/file', ), array( '/dir/file.html', '/dir/different-file.html', - 'different-file.html' + 'different-file.html', ), array( '/same/dir/extra-file', '/same/dir/', - './' + './', ), array( '/parent/dir/', '/parent/', - '../' + '../', ), array( '/parent/dir/extra-file', '/parent/', - '../' + '../', ), array( '/a/b/', '/x/y/z/', - '../../x/y/z/' + '../../x/y/z/', ), array( '/a/b/c/d/e', '/a/c/d', - '../../../c/d' + '../../../c/d', ), array( '/a/b/c//', '/a/b/c/', - '../' + '../', ), array( '/a/b/c/', '/a/b/c//', - './/' + './/', ), array( '/root/a/b/c/', '/root/x/b/c/', - '../../../x/b/c/' + '../../../x/b/c/', ), array( '/a/b/c/d/', '/a', - '../../../../a' + '../../../../a', ), array( '/special-chars/sp%20ce/1€/mäh/e=mc²', '/special-chars/sp%20ce/1€/<µ>/e=mc²', - '../<µ>/e=mc²' + '../<µ>/e=mc²', ), array( 'not-rooted', 'dir/file', - 'dir/file' + 'dir/file', ), array( '//dir/', '', - '../../' + '../../', ), array( '/dir/', '/dir/file:with-colon', - './file:with-colon' + './file:with-colon', ), array( '/dir/', '/dir/subdir/file:with-colon', - 'subdir/file:with-colon' + 'subdir/file:with-colon', ), array( '/dir/', '/dir/:subdir/', - './:subdir/' + './:subdir/', ), ); } diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php index 5b7325c317c57..a8ebc3281d68f 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php @@ -74,17 +74,17 @@ public function getLoadTests() array( 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass', array('name' => 'route1'), - array('arg2' => 'defaultValue2', 'arg3' => 'defaultValue3') + array('arg2' => 'defaultValue2', 'arg3' => 'defaultValue3'), ), array( 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass', array('name' => 'route1', 'defaults' => array('arg2' => 'foo')), - array('arg2' => 'defaultValue2', 'arg3' => 'defaultValue3') + array('arg2' => 'defaultValue2', 'arg3' => 'defaultValue3'), ), array( 'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass', array('name' => 'route1', 'defaults' => array('arg2' => 'foobar')), - array('arg2' => false, 'arg3' => 'defaultValue3') + array('arg2' => false, 'arg3' => 'defaultValue3'), ), ); } diff --git a/src/Symfony/Component/Routing/Tests/Matcher/ApacheUrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/ApacheUrlMatcherTest.php index 38127a09f617e..05e6261a5f737 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/ApacheUrlMatcherTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/ApacheUrlMatcherTest.php @@ -103,7 +103,7 @@ public function getMatchData() 'ignoreAttributes' => array('attr_a', 'attr_b'), '_controller' => 'FrameworkBundle:Redirect:redirect', '_route' => 'product_view', - ) + ), ), array( 'REDIRECT_ envs', @@ -146,7 +146,7 @@ public function getMatchData() 'name' => 'world', '_route' => 'hello', ), - ) + ), ); } } diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php index 542ede85c0017..1b2dee688dc0b 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php @@ -255,7 +255,7 @@ public function getRouteCollections() return array( array($collection, 'url_matcher1.php', array()), array($redirectCollection, 'url_matcher2.php', array('base_class' => 'Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher')), - array($rootprefixCollection, 'url_matcher3.php', array()) + array($rootprefixCollection, 'url_matcher3.php', array()), ); } } diff --git a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php index 8a1428f170859..e8056e8c2209a 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php @@ -78,7 +78,8 @@ public function testMatch() try { $matcher->match('/no-match'); $this->fail(); - } catch (ResourceNotFoundException $e) {} + } catch (ResourceNotFoundException $e) { + } $this->assertEquals(array('_route' => 'foo', 'bar' => 'baz'), $matcher->match('/foo/baz')); // test that defaults are merged @@ -98,7 +99,8 @@ public function testMatch() try { $matcher->match('/foo'); $this->fail(); - } catch (MethodNotAllowedException $e) {} + } catch (MethodNotAllowedException $e) { + } // route does match with GET or HEAD method context $matcher = new UrlMatcher($collection, new RequestContext()); diff --git a/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php b/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php index d663ae960b3da..ef26c87161a27 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCompilerTest.php @@ -38,7 +38,7 @@ public function provideCompileData() array('/foo'), '/foo', '#^/foo$#s', array(), array( array('text', '/foo'), - )), + ),), array( 'Route with a variable', @@ -46,7 +46,7 @@ public function provideCompileData() '/foo', '#^/foo/(?P[^/]++)$#s', array('bar'), array( array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), - )), + ),), array( 'Route with a variable that has a default value', @@ -54,7 +54,7 @@ public function provideCompileData() '/foo', '#^/foo(?:/(?P[^/]++))?$#s', array('bar'), array( array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), - )), + ),), array( 'Route with several variables', @@ -63,7 +63,7 @@ public function provideCompileData() array('variable', '/', '[^/]++', 'foobar'), array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), - )), + ),), array( 'Route with several variables that have default values', @@ -72,7 +72,7 @@ public function provideCompileData() array('variable', '/', '[^/]++', 'foobar'), array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), - )), + ),), array( 'Route with several variables but some of them have no default values', @@ -81,28 +81,28 @@ public function provideCompileData() array('variable', '/', '[^/]++', 'foobar'), array('variable', '/', '[^/]++', 'bar'), array('text', '/foo'), - )), + ),), array( 'Route with an optional variable as the first segment', array('/{bar}', array('bar' => 'bar')), '', '#^/(?P[^/]++)?$#s', array('bar'), array( array('variable', '/', '[^/]++', 'bar'), - )), + ),), array( 'Route with a requirement of 0', array('/{bar}', array('bar' => null), array('bar' => '0')), '', '#^/(?P0)?$#s', array('bar'), array( array('variable', '/', '0', 'bar'), - )), + ),), array( 'Route with an optional variable as the first segment with requirements', array('/{bar}', array('bar' => 'bar'), array('bar' => '(foo|bar)')), '', '#^/(?P(foo|bar))?$#s', array('bar'), array( array('variable', '/', '(foo|bar)', 'bar'), - )), + ),), array( 'Route with only optional variables', @@ -110,7 +110,7 @@ public function provideCompileData() '', '#^/(?P[^/]++)?(?:/(?P[^/]++))?$#s', array('foo', 'bar'), array( array('variable', '/', '[^/]++', 'bar'), array('variable', '/', '[^/]++', 'foo'), - )), + ),), array( 'Route with a variable in last position', @@ -118,7 +118,7 @@ public function provideCompileData() '/foo', '#^/foo\-(?P[^/]++)$#s', array('bar'), array( array('variable', '-', '[^/]++', 'bar'), array('text', '/foo'), - )), + ),), array( 'Route with nested placeholders', @@ -127,7 +127,7 @@ public function provideCompileData() array('text', 'static}'), array('variable', '', '[^/]+', 'var'), array('text', '/{static'), - )), + ),), array( 'Route without separator between variables', @@ -138,7 +138,7 @@ public function provideCompileData() array('variable', '', '(y|Y)', 'y'), array('variable', '', '[^/\.]+', 'x'), array('variable', '/', '[^/\.]+', 'w'), - )), + ),), array( 'Route with a format', @@ -147,7 +147,7 @@ public function provideCompileData() array('variable', '.', '[^/]++', '_format'), array('variable', '/', '[^/\.]++', 'bar'), array('text', '/foo'), - )), + ),), ); } @@ -167,7 +167,7 @@ public function testRouteWithSameVariableTwice() */ public function testRouteWithNumericVariableName($name) { - $route = new Route('/{'. $name.'}'); + $route = new Route('/{'.$name.'}'); $route->compile(); } @@ -176,7 +176,7 @@ public function getNumericVariableNames() return array( array('09'), array('123'), - array('1e2') + array('1e2'), ); } diff --git a/src/Symfony/Component/Routing/Tests/RouteTest.php b/src/Symfony/Component/Routing/Tests/RouteTest.php index 9f496e259ea48..a7a41815596f1 100644 --- a/src/Symfony/Component/Routing/Tests/RouteTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteTest.php @@ -137,7 +137,7 @@ public function getInvalidRequirements() array(array()), array('^$'), array('^'), - array('$') + array('$'), ); } diff --git a/src/Symfony/Component/Routing/Tests/RouterTest.php b/src/Symfony/Component/Routing/Tests/RouterTest.php index a3c336e5b775e..e96c95ab78dba 100644 --- a/src/Symfony/Component/Routing/Tests/RouterTest.php +++ b/src/Symfony/Component/Routing/Tests/RouterTest.php @@ -30,7 +30,7 @@ public function testSetOptionsWithSupportedOptions() $this->router->setOptions(array( 'cache_dir' => './cache', 'debug' => true, - 'resource_type' => 'ResourceType' + 'resource_type' => 'ResourceType', )); $this->assertSame('./cache', $this->router->getOption('cache_dir')); @@ -48,7 +48,7 @@ public function testSetOptionsWithUnsupportedOptions() 'cache_dir' => './cache', 'option_foo' => true, 'option_bar' => 'baz', - 'resource_type' => 'ResourceType' + 'resource_type' => 'ResourceType', )); } @@ -102,14 +102,13 @@ public function testMatcherIsCreatedIfCacheIsNotConfigured($option) ->will($this->returnValue($this->getMock('Symfony\Component\Routing\RouteCollection'))); $this->assertInstanceOf('Symfony\\Component\\Routing\\Matcher\\UrlMatcher', $this->router->getMatcher()); - } public function provideMatcherOptionsPreventingCaching() { return array( array('cache_dir'), - array('matcher_cache_class') + array('matcher_cache_class'), ); } @@ -125,14 +124,13 @@ public function testGeneratorIsCreatedIfCacheIsNotConfigured($option) ->will($this->returnValue($this->getMock('Symfony\Component\Routing\RouteCollection'))); $this->assertInstanceOf('Symfony\\Component\\Routing\\Generator\\UrlGenerator', $this->router->getGenerator()); - } public function provideGeneratorOptionsPreventingCaching() { return array( array('cache_dir'), - array('generator_cache_class') + array('generator_cache_class'), ); } } diff --git a/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php b/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php index c422c2d0a9ba3..96b6a4b64b6d6 100644 --- a/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php +++ b/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php @@ -104,7 +104,7 @@ public function findAcls(array $oids, array $sids = array()) $currentBatch = array(); $oidLookup = array(); - for ($i=0,$c=count($oids); $i<$c; $i++) { + for ($i = 0,$c = count($oids); $i<$c; $i++) { $oid = $oids[$i]; $oidLookupKey = $oid->getIdentifier().$oid->getType(); $oidLookup[$oidLookupKey] = $oid; @@ -500,8 +500,8 @@ private function hydrateObjectIdentities(Statement $stmt, array $oidLookup, arra $acls = $aces = $emptyArray = array(); $oidCache = $oidLookup; $result = new \SplObjectStorage(); - $loadedAces =& $this->loadedAces; - $loadedAcls =& $this->loadedAcls; + $loadedAces = & $this->loadedAces; + $loadedAcls = & $this->loadedAcls; $permissionGrantingStrategy = $this->permissionGrantingStrategy; // we need these to set protected properties on hydrated objects @@ -593,7 +593,7 @@ private function hydrateObjectIdentities(Statement $stmt, array $oidLookup, arra // It is important to only ever have one ACE instance per actual row since // some ACEs are shared between ACL instances if (!isset($loadedAces[$aceId])) { - if (!isset($sids[$key = ($username?'1':'0').$securityIdentifier])) { + if (!isset($sids[$key = ($username ? '1' : '0').$securityIdentifier])) { if ($username) { $sids[$key] = new UserSecurityIdentity( substr($securityIdentifier, 1 + $pos = strpos($securityIdentifier, '-')), diff --git a/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php b/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php index b8f5fb8e20391..2a4eac0853d4f 100644 --- a/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php +++ b/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php @@ -188,7 +188,7 @@ public function propertyChanged($sender, $propertyName, $oldValue, $newValue) $propertyChanges['aces'] = new \SplObjectStorage(); } - $acePropertyChanges = $propertyChanges['aces']->contains($ace)? $propertyChanges['aces']->offsetGet($ace) : array(); + $acePropertyChanges = $propertyChanges['aces']->contains($ace) ? $propertyChanges['aces']->offsetGet($ace) : array(); if (isset($acePropertyChanges[$propertyName])) { $oldValue = $acePropertyChanges[$propertyName][0]; @@ -448,8 +448,8 @@ class_id, $query, $this->options['entry_table_name'], $classId, - null === $objectIdentityId? 'NULL' : intval($objectIdentityId), - null === $field? 'NULL' : $this->connection->quote($field), + null === $objectIdentityId ? 'NULL' : intval($objectIdentityId), + null === $field ? 'NULL' : $this->connection->quote($field), $aceOrder, $securityIdentityId, $mask, @@ -767,7 +767,7 @@ private function updateNewFieldAceProperty($name, array $changes) $classIds = new \SplObjectStorage(); $currentIds = array(); foreach ($changes[1] as $field => $new) { - for ($i=0,$c=count($new); $i<$c; $i++) { + for ($i = 0,$c = count($new); $i<$c; $i++) { $ace = $new[$i]; if (null === $ace->getId()) { @@ -844,7 +844,7 @@ private function updateNewAceProperty($name, array $changes) $sids = new \SplObjectStorage(); $classIds = new \SplObjectStorage(); $currentIds = array(); - for ($i=0,$c=count($new); $i<$c; $i++) { + for ($i = 0,$c = count($new); $i<$c; $i++) { $ace = $new[$i]; if (null === $ace->getId()) { @@ -887,7 +887,7 @@ private function updateOldAceProperty($name, array $changes) list($old, $new) = $changes; $currentIds = array(); - for ($i=0,$c=count($new); $i<$c; $i++) { + for ($i = 0,$c = count($new); $i<$c; $i++) { $ace = $new[$i]; if (null !== $ace->getId()) { @@ -925,11 +925,11 @@ private function updateAce(\SplObjectStorage $aces, $ace) if (isset($propertyChanges['aceOrder']) && $propertyChanges['aceOrder'][1] > $propertyChanges['aceOrder'][0] && $propertyChanges == $aces->offsetGet($ace)) { - $aces->next(); - if ($aces->valid()) { - $this->updateAce($aces, $aces->current()); - } + $aces->next(); + if ($aces->valid()) { + $this->updateAce($aces, $aces->current()); } + } if (isset($propertyChanges['mask'])) { $sets[] = sprintf('mask = %d', $propertyChanges['mask'][1]); @@ -949,5 +949,4 @@ private function updateAce(\SplObjectStorage $aces, $ace) $this->connection->executeQuery($this->getUpdateAccessControlEntrySql($ace->getId(), $sets)); } - } diff --git a/src/Symfony/Component/Security/Acl/Domain/Acl.php b/src/Symfony/Component/Security/Acl/Domain/Acl.php index cd02751f9515e..f426f34a3b541 100644 --- a/src/Symfony/Component/Security/Acl/Domain/Acl.php +++ b/src/Symfony/Component/Security/Acl/Domain/Acl.php @@ -125,7 +125,7 @@ public function getClassAces() */ public function getClassFieldAces($field) { - return isset($this->classFieldAces[$field])? $this->classFieldAces[$field] : array(); + return isset($this->classFieldAces[$field]) ? $this->classFieldAces[$field] : array(); } /** @@ -403,7 +403,7 @@ public function updateObjectFieldAuditing($index, $field, $auditSuccess, $auditF */ private function deleteAce($property, $index) { - $aces =& $this->$property; + $aces = & $this->$property; if (!isset($aces[$index])) { throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index)); } @@ -413,7 +413,7 @@ private function deleteAce($property, $index) $this->$property = array_values($this->$property); $this->onPropertyChanged($property, $oldValue, $this->$property); - for ($i=$index,$c=count($this->$property); $i<$c; $i++) { + for ($i = $index,$c = count($this->$property); $i<$c; $i++) { $this->onEntryPropertyChanged($aces[$i], 'aceOrder', $i+1, $i); } } @@ -428,7 +428,7 @@ private function deleteAce($property, $index) */ private function deleteFieldAce($property, $index, $field) { - $aces =& $this->$property; + $aces = & $this->$property; if (!isset($aces[$field][$index])) { throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index)); } @@ -438,7 +438,7 @@ private function deleteFieldAce($property, $index, $field) $aces[$field] = array_values($aces[$field]); $this->onPropertyChanged($property, $oldValue, $this->$property); - for ($i=$index,$c=count($aces[$field]); $i<$c; $i++) { + for ($i = $index,$c = count($aces[$field]); $i<$c; $i++) { $this->onEntryPropertyChanged($aces[$field][$i], 'aceOrder', $i+1, $i); } } @@ -473,7 +473,7 @@ private function insertAce($property, $index, $mask, SecurityIdentityInterface $ } } - $aces =& $this->$property; + $aces = & $this->$property; $oldValue = $this->$property; if (isset($aces[$index])) { $this->$property = array_merge( @@ -482,7 +482,7 @@ private function insertAce($property, $index, $mask, SecurityIdentityInterface $ array_slice($this->$property, $index) ); - for ($i=$index,$c=count($this->$property)-1; $i<$c; $i++) { + for ($i = $index,$c = count($this->$property)-1; $i<$c; $i++) { $this->onEntryPropertyChanged($aces[$i+1], 'aceOrder', $i, $i+1); } } @@ -522,7 +522,7 @@ private function insertFieldAce($property, $index, $field, $mask, SecurityIdenti } } - $aces =& $this->$property; + $aces = & $this->$property; if (!isset($aces[$field])) { $aces[$field] = array(); } @@ -539,7 +539,7 @@ private function insertFieldAce($property, $index, $field, $mask, SecurityIdenti array_slice($aces[$field], $index) ); - for ($i=$index,$c=count($aces[$field])-1; $i<$c; $i++) { + for ($i = $index,$c = count($aces[$field])-1; $i<$c; $i++) { $this->onEntryPropertyChanged($aces[$field][$i+1], 'aceOrder', $i, $i+1); } } @@ -559,7 +559,7 @@ private function insertFieldAce($property, $index, $field, $mask, SecurityIdenti */ private function updateAce($property, $index, $mask, $strategy = null) { - $aces =& $this->$property; + $aces = & $this->$property; if (!isset($aces[$index])) { throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index)); } @@ -618,7 +618,7 @@ private function updateFieldAce($property, $index, $field, $mask, $strategy = nu throw new \InvalidArgumentException('$field cannot be empty.'); } - $aces =& $this->$property; + $aces = & $this->$property; if (!isset($aces[$field][$index])) { throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index)); } diff --git a/src/Symfony/Component/Security/Acl/Permission/MaskBuilder.php b/src/Symfony/Component/Security/Acl/Permission/MaskBuilder.php index 4d475fbce440f..8ca25bcff5e62 100644 --- a/src/Symfony/Component/Security/Acl/Permission/MaskBuilder.php +++ b/src/Symfony/Component/Security/Acl/Permission/MaskBuilder.php @@ -128,7 +128,7 @@ public function getPattern() $length = strlen($pattern); $bitmask = str_pad(decbin($this->mask), $length, '0', STR_PAD_LEFT); - for ($i=$length-1; $i>=0; $i--) { + for ($i = $length-1; $i >= 0; $i--) { if ('1' === $bitmask[$i]) { try { $pattern[$i] = self::getCode(1 << ($length - $i - 1)); diff --git a/src/Symfony/Component/Security/Acl/Voter/AclVoter.php b/src/Symfony/Component/Security/Acl/Voter/AclVoter.php index b21b1e675bb6d..9657eedb8ddab 100644 --- a/src/Symfony/Component/Security/Acl/Voter/AclVoter.php +++ b/src/Symfony/Component/Security/Acl/Voter/AclVoter.php @@ -64,7 +64,7 @@ public function vote(TokenInterface $token, $object, array $attributes) if (null === $object) { if (null !== $this->logger) { - $this->logger->debug(sprintf('Object identity unavailable. Voting to %s', $this->allowIfObjectIdentityUnavailable? 'grant access' : 'abstain')); + $this->logger->debug(sprintf('Object identity unavailable. Voting to %s', $this->allowIfObjectIdentityUnavailable ? 'grant access' : 'abstain')); } return $this->allowIfObjectIdentityUnavailable ? self::ACCESS_GRANTED : self::ACCESS_ABSTAIN; @@ -79,7 +79,7 @@ public function vote(TokenInterface $token, $object, array $attributes) $oid = $object; } elseif (null === $oid = $this->objectIdentityRetrievalStrategy->getObjectIdentity($object)) { if (null !== $this->logger) { - $this->logger->debug(sprintf('Object identity unavailable. Voting to %s', $this->allowIfObjectIdentityUnavailable? 'grant access' : 'abstain')); + $this->logger->debug(sprintf('Object identity unavailable. Voting to %s', $this->allowIfObjectIdentityUnavailable ? 'grant access' : 'abstain')); } return $this->allowIfObjectIdentityUnavailable ? self::ACCESS_GRANTED : self::ACCESS_ABSTAIN; diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/PreAuthenticatedAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/PreAuthenticatedAuthenticationProvider.php index 21ce8d0ac821f..b1e6c3845a6ec 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/PreAuthenticatedAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/PreAuthenticatedAuthenticationProvider.php @@ -56,9 +56,9 @@ public function authenticate(TokenInterface $token) return; } - if (!$user = $token->getUser()) { - throw new BadCredentialsException('No pre-authenticated principal found in request.'); - } + if (!$user = $token->getUser()) { + throw new BadCredentialsException('No pre-authenticated principal found in request.'); + } /* if (null === $token->getCredentials()) { throw new BadCredentialsException('No pre-authenticated credentials found in request.'); @@ -66,13 +66,13 @@ public function authenticate(TokenInterface $token) */ $user = $this->userProvider->loadUserByUsername($user); - $this->userChecker->checkPostAuth($user); + $this->userChecker->checkPostAuth($user); - $authenticatedToken = new PreAuthenticatedToken($user, $token->getCredentials(), $this->providerKey, $user->getRoles()); - $authenticatedToken->setAttributes($token->getAttributes()); + $authenticatedToken = new PreAuthenticatedToken($user, $token->getCredentials(), $this->providerKey, $user->getRoles()); + $authenticatedToken->setAttributes($token->getAttributes()); - return $authenticatedToken; - } + return $authenticatedToken; + } /** * {@inheritdoc} diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php index 993960be9c8ad..6813adf99d512 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php @@ -154,7 +154,7 @@ public function serialize() is_object($this->user) ? clone $this->user : $this->user, $this->authenticated, $this->roles, - $this->attributes + $this->attributes, ) ); } diff --git a/src/Symfony/Component/Security/Core/Util/ClassUtils.php b/src/Symfony/Component/Security/Core/Util/ClassUtils.php index 26bf1a1264fa5..1d40c8d4e2eeb 100644 --- a/src/Symfony/Component/Security/Core/Util/ClassUtils.php +++ b/src/Symfony/Component/Security/Core/Util/ClassUtils.php @@ -39,7 +39,9 @@ class ClassUtils /** * This class should not be instantiated */ - private function __construct() {} + private function __construct() + { + } /** * Gets the real class name of a class name that could be a proxy. diff --git a/src/Symfony/Component/Security/Core/Util/StringUtils.php b/src/Symfony/Component/Security/Core/Util/StringUtils.php index acf8e9eed8af3..01441cb21674b 100644 --- a/src/Symfony/Component/Security/Core/Util/StringUtils.php +++ b/src/Symfony/Component/Security/Core/Util/StringUtils.php @@ -21,7 +21,9 @@ class StringUtils /** * This class should not be instantiated */ - private function __construct() {} + private function __construct() + { + } /** * Compares two strings. diff --git a/src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationFailureHandler.php b/src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationFailureHandler.php index f106a4afefde0..db96e67b56d72 100644 --- a/src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationFailureHandler.php +++ b/src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationFailureHandler.php @@ -53,7 +53,7 @@ public function __construct(HttpKernelInterface $httpKernel, HttpUtils $httpUtil 'failure_path' => null, 'failure_forward' => false, 'login_path' => '/login', - 'failure_path_parameter' => '_failure_path' + 'failure_path_parameter' => '_failure_path', ), $options); } @@ -63,7 +63,7 @@ public function __construct(HttpKernelInterface $httpKernel, HttpUtils $httpUtil public function onAuthenticationFailure(Request $request, AuthenticationException $exception) { if ($failureUrl = $request->get($this->options['failure_path_parameter'], null, true)) { - $this->options['failure_path'] = $failureUrl; + $this->options['failure_path'] = $failureUrl; } if (null === $this->options['failure_path']) { diff --git a/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php b/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php index db1b5081dc332..7581a68eba684 100644 --- a/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php +++ b/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php @@ -129,7 +129,7 @@ protected function generateCookieValue($class, $username, $expires, $password) $class, base64_encode($username), $expires, - $this->generateCookieHash($class, $username, $expires, $password) + $this->generateCookieHash($class, $username, $expires, $password), )); } diff --git a/src/Symfony/Component/Security/Tests/Acl/Dbal/AclProviderBenchmarkTest.php b/src/Symfony/Component/Security/Tests/Acl/Dbal/AclProviderBenchmarkTest.php index 8f6a30ceb7e82..e930b1977e5ab 100644 --- a/src/Symfony/Component/Security/Tests/Acl/Dbal/AclProviderBenchmarkTest.php +++ b/src/Symfony/Component/Security/Tests/Acl/Dbal/AclProviderBenchmarkTest.php @@ -96,7 +96,7 @@ protected function generateTestData() $this->insertEntryStmt = $this->con->prepare('INSERT INTO acl_entries (id, class_id, object_identity_id, field_name, ace_order, security_identity_id, mask, granting, granting_strategy, audit_success, audit_failure) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'); $this->insertOidAncestorStmt = $this->con->prepare('INSERT INTO acl_object_identity_ancestors (object_identity_id, ancestor_id) VALUES (?, ?)'); - for ($i=0; $i<40000; $i++) { + for ($i = 0; $i<40000; $i++) { $this->generateAclHierarchy(); } } @@ -111,7 +111,7 @@ protected function generateAclHierarchy() protected function generateAclLevel($depth, $parentId, $ancestors) { $level = count($ancestors); - for ($i=0,$t=rand(1, 10); $i<$t; $i++) { + for ($i = 0,$t = rand(1, 10); $i<$t; $i++) { $id = $this->generateAcl($this->chooseClassId(), $parentId, $ancestors); if ($level < $depth) { @@ -165,7 +165,7 @@ protected function chooseSid() $this->insertSidStmt->execute(array( $id, $this->getRandomString(rand(5, 30)), - rand(0, 1) + rand(0, 1), )); $id += 1; @@ -182,7 +182,7 @@ protected function generateAces($classId, $objectId) $sids = array(); $fieldOrder = array(); - for ($i=0; $i<=30; $i++) { + for ($i = 0; $i <= 30; $i++) { $fieldName = rand(0, 1) ? null : $this->getRandomString(rand(10, 20)); do { diff --git a/src/Symfony/Component/Security/Tests/Acl/Dbal/MutableAclProviderTest.php b/src/Symfony/Component/Security/Tests/Acl/Dbal/MutableAclProviderTest.php index 00a222801237a..832a8960d067c 100644 --- a/src/Symfony/Component/Security/Tests/Acl/Dbal/MutableAclProviderTest.php +++ b/src/Symfony/Component/Security/Tests/Acl/Dbal/MutableAclProviderTest.php @@ -88,7 +88,8 @@ public function testDeleteAcl() try { $provider->findAcl($oid); $this->fail('ACL has not been properly deleted.'); - } catch (AclNotFoundException $notFound) { } + } catch (AclNotFoundException $notFound) { + } } public function testDeleteAclDeletesChildren() @@ -103,7 +104,8 @@ public function testDeleteAclDeletesChildren() try { $provider->findAcl(new ObjectIdentity(1, 'Foo')); $this->fail('Child-ACLs have not been deleted.'); - } catch (AclNotFoundException $notFound) { } + } catch (AclNotFoundException $notFound) { + } } public function testFindAclsAddsPropertyListener() @@ -148,7 +150,7 @@ public function testFindAclsAddsPropertyListenerToParentAcls() 'parent' => array( 'object_identifier' => '1', 'class_type' => 'anotherFoo', - ) + ), )); $propertyChanges = $this->getField($provider, 'propertyChanges'); @@ -288,7 +290,8 @@ public function testUpdateAclThrowsExceptionOnConcurrentModificationOfSharedProp try { $provider->updateAcl($acl1); $this->fail('Provider failed to detect a concurrent modification.'); - } catch (ConcurrentModificationException $ex) { } + } catch (ConcurrentModificationException $ex) { + } } public function testUpdateAcl() diff --git a/src/Symfony/Component/Security/Tests/Acl/Domain/AclTest.php b/src/Symfony/Component/Security/Tests/Acl/Domain/AclTest.php index 4b67e625e352c..29acc3a25438f 100644 --- a/src/Symfony/Component/Security/Tests/Acl/Domain/AclTest.php +++ b/src/Symfony/Component/Security/Tests/Acl/Domain/AclTest.php @@ -128,7 +128,7 @@ public function testInsertAce($property, $method) $acl = $this->getAcl(); $listener = $this->getListener(array( - $property, 'aceOrder', $property, 'aceOrder', $property + $property, 'aceOrder', $property, 'aceOrder', $property, )); $acl->addPropertyChangedListener($listener); @@ -358,7 +358,7 @@ public function testUpdateFieldAce($type) $acl->{'insert'.$type}('foo', new UserSecurityIdentity('foo', 'Foo'), 1); $listener = $this->getListener(array( - 'mask', 'mask', 'strategy' + 'mask', 'mask', 'strategy', )); $acl->addPropertyChangedListener($listener); diff --git a/src/Symfony/Component/Security/Tests/Acl/Domain/AuditLoggerTest.php b/src/Symfony/Component/Security/Tests/Acl/Domain/AuditLoggerTest.php index a0f38eb42cb45..c8522b49de20e 100644 --- a/src/Symfony/Component/Security/Tests/Acl/Domain/AuditLoggerTest.php +++ b/src/Symfony/Component/Security/Tests/Acl/Domain/AuditLoggerTest.php @@ -28,7 +28,7 @@ public function testLogIfNeeded($granting, $audit) ->will($this->returnValue($audit)) ; - $ace + $ace ->expects($this->never()) ->method('isAuditFailure') ; diff --git a/src/Symfony/Component/Security/Tests/Acl/Domain/PermissionGrantingStrategyTest.php b/src/Symfony/Component/Security/Tests/Acl/Domain/PermissionGrantingStrategyTest.php index d200d2b0eb24f..4698a72583d2c 100644 --- a/src/Symfony/Component/Security/Tests/Acl/Domain/PermissionGrantingStrategyTest.php +++ b/src/Symfony/Component/Security/Tests/Acl/Domain/PermissionGrantingStrategyTest.php @@ -154,7 +154,8 @@ public function testIsGrantedStrategies($maskStrategy, $aceMask, $requiredMask, try { $strategy->isGranted($acl, array($requiredMask), array($sid)); $this->fail('The ACE is not supposed to match.'); - } catch (NoAceFoundException $noAce) { } + } catch (NoAceFoundException $noAce) { + } } else { $this->assertTrue($strategy->isGranted($acl, array($requiredMask), array($sid))); } diff --git a/src/Symfony/Component/Security/Tests/Acl/Domain/SecurityIdentityRetrievalStrategyTest.php b/src/Symfony/Component/Security/Tests/Acl/Domain/SecurityIdentityRetrievalStrategyTest.php index f649653db0f01..e5fb4ed9eb924 100644 --- a/src/Symfony/Component/Security/Tests/Acl/Domain/SecurityIdentityRetrievalStrategyTest.php +++ b/src/Symfony/Component/Security/Tests/Acl/Domain/SecurityIdentityRetrievalStrategyTest.php @@ -103,7 +103,7 @@ public function getSecurityIdentityRetrievalTests() array('guest', array('ROLE_FOO'), 'anonymous', array( new RoleSecurityIdentity('ROLE_FOO'), new RoleSecurityIdentity('IS_AUTHENTICATED_ANONYMOUSLY'), - )) + )), ); } diff --git a/src/Symfony/Component/Security/Tests/Core/Authentication/Token/AbstractTokenTest.php b/src/Symfony/Component/Security/Tests/Core/Authentication/Token/AbstractTokenTest.php index 5683b782cbccd..b8be6288dc7a9 100644 --- a/src/Symfony/Component/Security/Tests/Core/Authentication/Token/AbstractTokenTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Authentication/Token/AbstractTokenTest.php @@ -52,7 +52,9 @@ public function unserialize($serialized) parent::unserialize($parentStr); } - public function getCredentials() {} + public function getCredentials() + { + } } class AbstractTokenTest extends \PHPUnit_Framework_TestCase @@ -227,13 +229,13 @@ public function getUserChanges() 'foo', $user, ), array( - 'foo', $advancedUser + 'foo', $advancedUser, ), array( - $user, 'foo' + $user, 'foo', ), array( - $advancedUser, 'foo' + $advancedUser, 'foo', ), array( $user, new TestUser('foo'), @@ -254,10 +256,10 @@ public function getUserChanges() new TestUser('foo'), $advancedUser, ), array( - $user, $advancedUser + $user, $advancedUser, ), array( - $advancedUser, $user + $advancedUser, $user, ), ); } diff --git a/src/Symfony/Component/Security/Tests/Core/Authorization/AccessDecisionManagerTest.php b/src/Symfony/Component/Security/Tests/Core/Authorization/AccessDecisionManagerTest.php index 0300cb42548b5..37e12b7e284b3 100644 --- a/src/Symfony/Component/Security/Tests/Core/Authorization/AccessDecisionManagerTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Authorization/AccessDecisionManagerTest.php @@ -85,7 +85,7 @@ public function getStrategiesWith2RolesTests() array($token, 'consensus', $this->getVoter(VoterInterface::ACCESS_DENIED), false), array($token, 'consensus', $this->getVoter(VoterInterface::ACCESS_GRANTED), true), - + array($token, 'unanimous', $this->getVoterFor2Roles($token, VoterInterface::ACCESS_DENIED, VoterInterface::ACCESS_DENIED), false), array($token, 'unanimous', $this->getVoterFor2Roles($token, VoterInterface::ACCESS_DENIED, VoterInterface::ACCESS_GRANTED), false), array($token, 'unanimous', $this->getVoterFor2Roles($token, VoterInterface::ACCESS_GRANTED, VoterInterface::ACCESS_DENIED), false), @@ -164,7 +164,6 @@ protected function getVoter($vote) $voter->expects($this->any()) ->method('vote') ->will($this->returnValue($vote)); - ; return $voter; } @@ -175,7 +174,6 @@ protected function getVoterSupportsClass($ret) $voter->expects($this->any()) ->method('supportsClass') ->will($this->returnValue($ret)); - ; return $voter; } @@ -186,7 +184,6 @@ protected function getVoterSupportsAttribute($ret) $voter->expects($this->any()) ->method('supportsAttribute') ->will($this->returnValue($ret)); - ; return $voter; } diff --git a/src/Symfony/Component/Security/Tests/Core/Authorization/Voter/RoleVoterTest.php b/src/Symfony/Component/Security/Tests/Core/Authorization/Voter/RoleVoterTest.php index 63608ebb3b9a8..8a5cdc5e59f3d 100644 --- a/src/Symfony/Component/Security/Tests/Core/Authorization/Voter/RoleVoterTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Authorization/Voter/RoleVoterTest.php @@ -55,7 +55,6 @@ protected function getToken(array $roles) $token->expects($this->once()) ->method('getRoles') ->will($this->returnValue($roles)); - ; return $token; } diff --git a/src/Symfony/Component/Security/Tests/Core/Encoder/EncoderFactoryTest.php b/src/Symfony/Component/Security/Tests/Core/Encoder/EncoderFactoryTest.php index 2e55a4b6f8c69..85d4e91356dad 100644 --- a/src/Symfony/Component/Security/Tests/Core/Encoder/EncoderFactoryTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Encoder/EncoderFactoryTest.php @@ -82,11 +82,21 @@ public function testGetEncoderConfiguredForConcreteClassWithClassName() class SomeUser implements UserInterface { - public function getRoles() {} - public function getPassword() {} - public function getSalt() {} - public function getUsername() {} - public function eraseCredentials() {} + public function getRoles() + { + } + public function getPassword() + { + } + public function getSalt() + { + } + public function getUsername() + { + } + public function eraseCredentials() + { + } } class SomeChildUser extends SomeUser diff --git a/src/Symfony/Component/Security/Tests/Http/Authentication/DefaultAuthenticationSuccessHandlerTest.php b/src/Symfony/Component/Security/Tests/Http/Authentication/DefaultAuthenticationSuccessHandlerTest.php index e6bc6ca51247a..aa5902bdf3add 100644 --- a/src/Symfony/Component/Security/Tests/Http/Authentication/DefaultAuthenticationSuccessHandlerTest.php +++ b/src/Symfony/Component/Security/Tests/Http/Authentication/DefaultAuthenticationSuccessHandlerTest.php @@ -47,7 +47,7 @@ public function testDefaultTargetPathCanBeForced() { $options = array( 'always_use_default_target_path' => true, - 'default_target_path' => '/dashboard' + 'default_target_path' => '/dashboard', ); $response = $this->expectRedirectResponse('/dashboard'); diff --git a/src/Symfony/Component/Security/Tests/Http/EntryPoint/RetryAuthenticationEntryPointTest.php b/src/Symfony/Component/Security/Tests/Http/EntryPoint/RetryAuthenticationEntryPointTest.php index 91de1ca7fd4d5..95c73d24047f3 100644 --- a/src/Symfony/Component/Security/Tests/Http/EntryPoint/RetryAuthenticationEntryPointTest.php +++ b/src/Symfony/Component/Security/Tests/Http/EntryPoint/RetryAuthenticationEntryPointTest.php @@ -46,26 +46,26 @@ public function dataForStart() 80, 443, Request::create('http://localhost/foo/bar?baz=bat'), - 'https://localhost/foo/bar?baz=bat' + 'https://localhost/foo/bar?baz=bat', ), array( 80, 443, Request::create('https://localhost/foo/bar?baz=bat'), - 'http://localhost/foo/bar?baz=bat' + 'http://localhost/foo/bar?baz=bat', ), array( 80, 123, Request::create('http://localhost/foo/bar?baz=bat'), - 'https://localhost:123/foo/bar?baz=bat' + 'https://localhost:123/foo/bar?baz=bat', ), array( 8080, 443, Request::create('https://localhost/foo/bar?baz=bat'), - 'http://localhost:8080/foo/bar?baz=bat' - ) + 'http://localhost:8080/foo/bar?baz=bat', + ), ); } } diff --git a/src/Symfony/Component/Security/Tests/Http/Firewall/AbstractPreAuthenticatedListenerTest.php b/src/Symfony/Component/Security/Tests/Http/Firewall/AbstractPreAuthenticatedListenerTest.php index 76721ec9550f5..34263bc6a340c 100644 --- a/src/Symfony/Component/Security/Tests/Http/Firewall/AbstractPreAuthenticatedListenerTest.php +++ b/src/Symfony/Component/Security/Tests/Http/Firewall/AbstractPreAuthenticatedListenerTest.php @@ -64,7 +64,7 @@ public function testHandleWithValidValues() $listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array( $context, $authenticationManager, - 'TheProviderKey' + 'TheProviderKey', )); $listener ->expects($this->once()) @@ -110,7 +110,7 @@ public function testHandleWhenAuthenticationFails() $listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array( $context, $authenticationManager, - 'TheProviderKey' + 'TheProviderKey', )); $listener ->expects($this->once()) @@ -158,7 +158,7 @@ public function testHandleWhenAuthenticationFailsWithDifferentToken() $listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array( $context, $authenticationManager, - 'TheProviderKey' + 'TheProviderKey', )); $listener ->expects($this->once()) @@ -199,7 +199,7 @@ public function testHandleWithASimilarAuthenticatedToken() $listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array( $context, $authenticationManager, - 'TheProviderKey' + 'TheProviderKey', )); $listener ->expects($this->once()) @@ -248,7 +248,7 @@ public function testHandleWithAnInvalidSimilarToken() $listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', array( $context, $authenticationManager, - 'TheProviderKey' + 'TheProviderKey', )); $listener ->expects($this->once()) diff --git a/src/Symfony/Component/Security/Tests/Http/Firewall/BasicAuthenticationListenerTest.php b/src/Symfony/Component/Security/Tests/Http/Firewall/BasicAuthenticationListenerTest.php index 7616149015695..b345178c3395e 100644 --- a/src/Symfony/Component/Security/Tests/Http/Firewall/BasicAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Tests/Http/Firewall/BasicAuthenticationListenerTest.php @@ -39,7 +39,7 @@ public function testHandleWithValidUsernameAndPasswordServerParameters() { $request = new Request(array(), array(), array(), array(), array(), array( 'PHP_AUTH_USER' => 'TheUsername', - 'PHP_AUTH_PW' => 'ThePassword' + 'PHP_AUTH_PW' => 'ThePassword', )); $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); @@ -85,7 +85,7 @@ public function testHandleWhenAuthenticationFails() { $request = new Request(array(), array(), array(), array(), array(), array( 'PHP_AUTH_USER' => 'TheUsername', - 'PHP_AUTH_PW' => 'ThePassword' + 'PHP_AUTH_PW' => 'ThePassword', )); $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); @@ -214,7 +214,7 @@ public function testHandleWithADifferentAuthenticatedToken() { $request = new Request(array(), array(), array(), array(), array(), array( 'PHP_AUTH_USER' => 'TheUsername', - 'PHP_AUTH_PW' => 'ThePassword' + 'PHP_AUTH_PW' => 'ThePassword', )); $token = new PreAuthenticatedToken('TheUser', 'TheCredentials', 'TheProviderKey', array('ROLE_FOO')); diff --git a/src/Symfony/Component/Security/Tests/Http/Firewall/ContextListenerTest.php b/src/Symfony/Component/Security/Tests/Http/Firewall/ContextListenerTest.php index 336c3334fe9b7..1429f26b81242 100644 --- a/src/Symfony/Component/Security/Tests/Http/Firewall/ContextListenerTest.php +++ b/src/Symfony/Component/Security/Tests/Http/Firewall/ContextListenerTest.php @@ -186,7 +186,7 @@ public function provideInvalidToken() return array( array(serialize(new \__PHP_Incomplete_Class())), array(serialize(null)), - array(null) + array(null), ); } diff --git a/src/Symfony/Component/Security/Tests/Http/Firewall/DigestDataTest.php b/src/Symfony/Component/Security/Tests/Http/Firewall/DigestDataTest.php index 8b63d9c953f14..e5be6f8802d86 100644 --- a/src/Symfony/Component/Security/Tests/Http/Firewall/DigestDataTest.php +++ b/src/Symfony/Component/Security/Tests/Http/Firewall/DigestDataTest.php @@ -18,9 +18,9 @@ class DigestDataTest extends \PHPUnit_Framework_TestCase public function testGetResponse() { $digestAuth = new DigestData( - 'username="user", realm="Welcome, robot!", ' . - 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", ' . - 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' . + 'username="user", realm="Welcome, robot!", '. + 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", '. + 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", '. 'response="b52938fc9e6d7c01be7702ece9031b42"' ); @@ -30,9 +30,9 @@ public function testGetResponse() public function testGetUsername() { $digestAuth = new DigestData( - 'username="user", realm="Welcome, robot!", ' . - 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", ' . - 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' . + 'username="user", realm="Welcome, robot!", '. + 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", '. + 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", '. 'response="b52938fc9e6d7c01be7702ece9031b42"' ); @@ -42,9 +42,9 @@ public function testGetUsername() public function testGetUsernameWithQuote() { $digestAuth = new DigestData( - 'username="\"user\"", realm="Welcome, robot!", ' . - 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", ' . - 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' . + 'username="\"user\"", realm="Welcome, robot!", '. + 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", '. + 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", '. 'response="b52938fc9e6d7c01be7702ece9031b42"' ); @@ -54,9 +54,9 @@ public function testGetUsernameWithQuote() public function testGetUsernameWithQuoteAndEscape() { $digestAuth = new DigestData( - 'username="\"u\\\\\"ser\"", realm="Welcome, robot!", ' . - 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", ' . - 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' . + 'username="\"u\\\\\"ser\"", realm="Welcome, robot!", '. + 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", '. + 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", '. 'response="b52938fc9e6d7c01be7702ece9031b42"' ); @@ -66,9 +66,9 @@ public function testGetUsernameWithQuoteAndEscape() public function testGetUsernameWithSingleQuote() { $digestAuth = new DigestData( - 'username="\"u\'ser\"", realm="Welcome, robot!", ' . - 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", ' . - 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' . + 'username="\"u\'ser\"", realm="Welcome, robot!", '. + 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", '. + 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", '. 'response="b52938fc9e6d7c01be7702ece9031b42"' ); @@ -78,9 +78,9 @@ public function testGetUsernameWithSingleQuote() public function testGetUsernameWithSingleQuoteAndEscape() { $digestAuth = new DigestData( - 'username="\"u\\\'ser\"", realm="Welcome, robot!", ' . - 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", ' . - 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' . + 'username="\"u\\\'ser\"", realm="Welcome, robot!", '. + 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", '. + 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", '. 'response="b52938fc9e6d7c01be7702ece9031b42"' ); @@ -90,9 +90,9 @@ public function testGetUsernameWithSingleQuoteAndEscape() public function testGetUsernameWithEscape() { $digestAuth = new DigestData( - 'username="\"u\\ser\"", realm="Welcome, robot!", ' . - 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", ' . - 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' . + 'username="\"u\\ser\"", realm="Welcome, robot!", '. + 'nonce="MTM0NzMyMTgyMy42NzkzOmRlZjM4NmIzOGNjMjE0OWJiNDU0MDAxNzJmYmM1MmZl", '. + 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", '. 'response="b52938fc9e6d7c01be7702ece9031b42"' ); @@ -106,8 +106,8 @@ public function testValidateAndDecode() $nonce = base64_encode($time.':'.md5($time.':'.$key)); $digestAuth = new DigestData( - 'username="user", realm="Welcome, robot!", nonce="'.$nonce.'", ' . - 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' . + 'username="user", realm="Welcome, robot!", nonce="'.$nonce.'", '. + 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", '. 'response="b52938fc9e6d7c01be7702ece9031b42"' ); @@ -146,8 +146,8 @@ public function testIsNonceExpired() $nonce = base64_encode($time.':'.md5($time.':'.$key)); $digestAuth = new DigestData( - 'username="user", realm="Welcome, robot!", nonce="'.$nonce.'", ' . - 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", ' . + 'username="user", realm="Welcome, robot!", nonce="'.$nonce.'", '. + 'uri="/path/info?p1=5&p2=5", cnonce="MDIwODkz", nc=00000001, qop="auth", '. 'response="b52938fc9e6d7c01be7702ece9031b42"' ); diff --git a/src/Symfony/Component/Security/Tests/Http/Firewall/X509AuthenticationListenerTest.php b/src/Symfony/Component/Security/Tests/Http/Firewall/X509AuthenticationListenerTest.php index 291f919b91724..1ba7311ad5be5 100644 --- a/src/Symfony/Component/Security/Tests/Http/Firewall/X509AuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Tests/Http/Firewall/X509AuthenticationListenerTest.php @@ -113,7 +113,7 @@ public function testGetPreAuthenticatedDataWithDifferentKeys() $request = new Request(array(), array(), array(), array(), array(), array( 'TheUserKey' => 'TheUser', - 'TheCredentialsKey' => 'TheCredentials' + 'TheCredentialsKey' => 'TheCredentials', )); $context = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'); diff --git a/src/Symfony/Component/Security/Tests/Http/FirewallTest.php b/src/Symfony/Component/Security/Tests/Http/FirewallTest.php index 0c1d82c1804f2..8932b108a683f 100644 --- a/src/Symfony/Component/Security/Tests/Http/FirewallTest.php +++ b/src/Symfony/Component/Security/Tests/Http/FirewallTest.php @@ -88,7 +88,7 @@ public function testOnKernelRequestStopsWhenThereIsAResponse() array( $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false), - HttpKernelInterface::MASTER_REQUEST + HttpKernelInterface::MASTER_REQUEST, ) ); $event diff --git a/src/Symfony/Component/Security/Tests/Http/HttpUtilsTest.php b/src/Symfony/Component/Security/Tests/Http/HttpUtilsTest.php index db1aa4b94e6ad..2e281fd48f7e9 100644 --- a/src/Symfony/Component/Security/Tests/Http/HttpUtilsTest.php +++ b/src/Symfony/Component/Security/Tests/Http/HttpUtilsTest.php @@ -139,7 +139,7 @@ public function provideSecurityContextAttributes() return array( array(SecurityContextInterface::AUTHENTICATION_ERROR), array(SecurityContextInterface::ACCESS_DENIED_ERROR), - array(SecurityContextInterface::LAST_USERNAME) + array(SecurityContextInterface::LAST_USERNAME), ); } diff --git a/src/Symfony/Component/Security/Tests/Http/RememberMe/AbstractRememberMeServicesTest.php b/src/Symfony/Component/Security/Tests/Http/RememberMe/AbstractRememberMeServicesTest.php index 02ca8d251959d..67b415deea3c1 100644 --- a/src/Symfony/Component/Security/Tests/Http/RememberMe/AbstractRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Tests/Http/RememberMe/AbstractRememberMeServicesTest.php @@ -250,7 +250,7 @@ protected function getService($userProvider = null, $options = array(), $logger } return $this->getMockForAbstractClass('Symfony\Component\Security\Http\RememberMe\AbstractRememberMeServices', array( - array($userProvider), 'fookey', 'fookey', $options, $logger + array($userProvider), 'fookey', 'fookey', $options, $logger, )); } diff --git a/src/Symfony/Component/Security/Tests/Http/RememberMe/PersistentTokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Tests/Http/RememberMe/PersistentTokenBasedRememberMeServicesTest.php index 26a878f009330..0d485f30bce01 100644 --- a/src/Symfony/Component/Security/Tests/Http/RememberMe/PersistentTokenBasedRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Tests/Http/RememberMe/PersistentTokenBasedRememberMeServicesTest.php @@ -124,7 +124,8 @@ public function testAutoLoginThrowsExceptionOnStolenCookieAndRemovesItFromThePer try { $service->autoLogin($request); $this->fail('Expected CookieTheftException was not thrown.'); - } catch (CookieTheftException $theft) { } + } catch (CookieTheftException $theft) { + } $this->assertTrue($request->attributes->has(RememberMeServicesInterface::COOKIE_ATTR_NAME)); } diff --git a/src/Symfony/Component/Security/Tests/Http/RememberMe/ResponseListenerTest.php b/src/Symfony/Component/Security/Tests/Http/RememberMe/ResponseListenerTest.php index 8b4667d865600..59e5fe267f8c1 100644 --- a/src/Symfony/Component/Security/Tests/Http/RememberMe/ResponseListenerTest.php +++ b/src/Symfony/Component/Security/Tests/Http/RememberMe/ResponseListenerTest.php @@ -31,7 +31,7 @@ public function testRememberMeCookieIsSentWithResponse() $cookie = new Cookie('rememberme'); $request = $this->getRequest(array( - RememberMeServicesInterface::COOKIE_ATTR_NAME => $cookie + RememberMeServicesInterface::COOKIE_ATTR_NAME => $cookie, )); $response = $this->getResponse(); diff --git a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php index aad5b79cbb44a..6fa42c241e0a9 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php @@ -123,7 +123,7 @@ private function resolveContext(array $context) $defaultOptions = array( 'json_decode_associative' => $this->associative, 'json_decode_recursion_depth' => $this->recursionDepth, - 'json_decode_options' => 0 + 'json_decode_options' => 0, ); return array_merge($defaultOptions, $context); diff --git a/src/Symfony/Component/Serializer/Encoder/JsonEncode.php b/src/Symfony/Component/Serializer/Encoder/JsonEncode.php index e8a06835d1437..e2b276b74e437 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonEncode.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonEncode.php @@ -18,7 +18,7 @@ */ class JsonEncode implements EncoderInterface { - private $options ; + private $options; private $lastError = JSON_ERROR_NONE; public function __construct($bitmask = 0) diff --git a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php index ca3509a819d28..8e6ce2292f465 100644 --- a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php @@ -435,5 +435,4 @@ private function resolveXmlRootName(array $context = array()) ? $context['xml_root_node_name'] : $this->rootNodeName; } - } diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php index b07b18e24d4a9..f2ee035ce2de4 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php @@ -67,11 +67,11 @@ public function testAttributes() $obj->xmlFoo = array( 'foo-bar' => array( '@id' => 1, - '@name' => 'Bar' + '@name' => 'Bar', ), 'Foo' => array( 'Bar' => "Test", - '@Type' => 'test' + '@Type' => 'test', ), 'föo_bär' => 'a', "Bar" => array(1,2,3), @@ -124,7 +124,7 @@ public function testEncodeScalarRootAttributes() { $array = array( '#' => 'Paul', - '@gender' => 'm' + '@gender' => 'm', ); $expected = ''."\n". @@ -137,7 +137,7 @@ public function testEncodeRootAttributes() { $array = array( 'firstname' => 'Paul', - '@gender' => 'm' + '@gender' => 'm', ); $expected = ''."\n". @@ -230,7 +230,7 @@ public function testDecodeScalarRootAttributes() $expected = array( '#' => 'Peter', - '@gender' => 'M' + '@gender' => 'M', ); $this->assertEquals($expected, $this->encoder->decode($source, 'xml')); @@ -244,7 +244,7 @@ public function testDecodeRootAttributes() $expected = array( 'firstname' => 'Peter', 'lastname' => 'Mac Calloway', - '@gender' => 'M' + '@gender' => 'M', ); $this->assertEquals($expected, $this->encoder->decode($source, 'xml')); @@ -263,8 +263,8 @@ public function testDecodeArray() $expected = array( 'people' => array('person' => array( array('firstname' => 'Benjamin', 'lastname' => 'Alexandre'), - array('firstname' => 'Damien', 'lastname' => 'Clay') - )) + array('firstname' => 'Damien', 'lastname' => 'Clay'), + )), ); $this->assertEquals($expected, $this->encoder->decode($source, 'xml')); @@ -276,11 +276,11 @@ public function testDecodeWithoutItemHash() $obj->xmlFoo = array( 'foo-bar' => array( '@key' => "value", - 'item' => array("@key" => 'key', "key-val" => 'val') + 'item' => array("@key" => 'key', "key-val" => 'val'), ), 'Foo' => array( 'Bar' => "Test", - '@Type' => 'test' + '@Type' => 'test', ), 'föo_bär' => 'a', "Bar" => array(1,2,3), @@ -289,11 +289,11 @@ public function testDecodeWithoutItemHash() $expected = array( 'foo-bar' => array( '@key' => "value", - 'key' => array('@key' => 'key', "key-val" => 'val') + 'key' => array('@key' => 'key', "key-val" => 'val'), ), 'Foo' => array( 'Bar' => "Test", - '@Type' => 'test' + '@Type' => 'test', ), 'föo_bär' => 'a', "Bar" => array(1,2,3), diff --git a/src/Symfony/Component/Serializer/Tests/Fixtures/DenormalizableDummy.php b/src/Symfony/Component/Serializer/Tests/Fixtures/DenormalizableDummy.php index 09b8a5281216d..d78f34a3cde71 100644 --- a/src/Symfony/Component/Serializer/Tests/Fixtures/DenormalizableDummy.php +++ b/src/Symfony/Component/Serializer/Tests/Fixtures/DenormalizableDummy.php @@ -16,10 +16,7 @@ class DenormalizableDummy implements DenormalizableInterface { - public function denormalize(DenormalizerInterface $denormalizer, $data, $format = null, array $context = array()) { - } - } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php index 1cbceece04458..eb65810453dd7 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -191,7 +191,7 @@ public function provideCallbacks() ), 'baz', array('foo' => '', 'bar' => null), - 'Null an item' + 'Null an item', ), array( array( diff --git a/src/Symfony/Component/Stopwatch/Stopwatch.php b/src/Symfony/Component/Stopwatch/Stopwatch.php index 99d09529f6521..9a5ab45a10a36 100644 --- a/src/Symfony/Component/Stopwatch/Stopwatch.php +++ b/src/Symfony/Component/Stopwatch/Stopwatch.php @@ -138,7 +138,6 @@ public function getSectionEvents($id) } } - /** * @internal This class is for internal usage only * diff --git a/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php b/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php index 6805effb48925..0e4b5f014ee40 100644 --- a/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php +++ b/src/Symfony/Component/Stopwatch/Tests/StopwatchTest.php @@ -62,7 +62,7 @@ public function testIsNotStartedEvent() 'foo' => $this->getMockBuilder('Symfony\Component\Stopwatch\StopwatchEvent') ->setConstructorArgs(array(microtime(true) * 1000)) - ->getMock()) + ->getMock(),) ); $this->assertFalse($stopwatch->isStarted('foo')); diff --git a/src/Symfony/Component/Translation/Dumper/PoFileDumper.php b/src/Symfony/Component/Translation/Dumper/PoFileDumper.php index c091d4c41eed2..983064b5d7ca9 100644 --- a/src/Symfony/Component/Translation/Dumper/PoFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/PoFileDumper.php @@ -35,9 +35,9 @@ public function format(MessageCatalogue $messages, $domain = 'messages') $newLine = false; foreach ($messages->all($domain) as $source => $target) { if ($newLine) { - $output .= "\n"; + $output .= "\n"; } else { - $newLine = true; + $newLine = true; } $output .= sprintf('msgid "%s"'."\n", $this->escape($source)); $output .= sprintf('msgstr "%s"', $this->escape($target)); diff --git a/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php b/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php index 3fd3f1499db80..5920fef20ca72 100644 --- a/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/YamlFileDumper.php @@ -26,7 +26,7 @@ class YamlFileDumper extends FileDumper */ protected function format(MessageCatalogue $messages, $domain) { - return Yaml::dump($messages->all($domain)); + return Yaml::dump($messages->all($domain)); } /** diff --git a/src/Symfony/Component/Translation/Loader/ArrayLoader.php b/src/Symfony/Component/Translation/Loader/ArrayLoader.php index 99058fbfbf126..b9ef7e5ea018f 100644 --- a/src/Symfony/Component/Translation/Loader/ArrayLoader.php +++ b/src/Symfony/Component/Translation/Loader/ArrayLoader.php @@ -53,7 +53,7 @@ public function load($resource, $locale, $domain = 'messages') private function flatten(array &$messages, array $subnode = null, $path = null) { if (null === $subnode) { - $subnode =& $messages; + $subnode = & $messages; } foreach ($subnode as $key => $value) { if (is_array($value)) { diff --git a/src/Symfony/Component/Translation/Loader/CsvFileLoader.php b/src/Symfony/Component/Translation/Loader/CsvFileLoader.php index bc10188c4c5da..f7f901236c2d0 100644 --- a/src/Symfony/Component/Translation/Loader/CsvFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/CsvFileLoader.php @@ -66,7 +66,7 @@ public function load($resource, $locale, $domain = 'messages') if (count($data) == 2) { $messages[$data[0]] = $data[1]; } else { - continue; + continue; } } diff --git a/src/Symfony/Component/Translation/Loader/PoFileLoader.php b/src/Symfony/Component/Translation/Loader/PoFileLoader.php index a1aff1a872476..6d5e835568021 100644 --- a/src/Symfony/Component/Translation/Loader/PoFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/PoFileLoader.php @@ -136,7 +136,6 @@ private function parse($resource) $size = strpos($line, ']'); $item['translated'][(int) substr($line, 7, 1)] = substr($line, $size + 3, -1); } - } // save last item $this->addMessage($messages, $item); @@ -172,7 +171,7 @@ private function addMessage(array &$messages, array $item) $messages[stripcslashes($item['ids']['plural'])] = stripcslashes(implode('|', $plurals)); } } elseif (!empty($item['ids']['singular'])) { - $messages[stripcslashes($item['ids']['singular'])] = stripcslashes($item['translated']); + $messages[stripcslashes($item['ids']['singular'])] = stripcslashes($item['translated']); } } } diff --git a/src/Symfony/Component/Translation/Tests/Catalogue/DiffOperationTest.php b/src/Symfony/Component/Translation/Tests/Catalogue/DiffOperationTest.php index b70324285e60c..b0227d2550a98 100644 --- a/src/Symfony/Component/Translation/Tests/Catalogue/DiffOperationTest.php +++ b/src/Symfony/Component/Translation/Tests/Catalogue/DiffOperationTest.php @@ -44,7 +44,7 @@ public function testGetResultFromSingleDomain() { $this->assertEquals( new MessageCatalogue('en', array( - 'messages' => array('a' => 'old_a', 'c' => 'new_c') + 'messages' => array('a' => 'old_a', 'c' => 'new_c'), )), $this->createOperation( new MessageCatalogue('en', array('messages' => array('a' => 'old_a', 'b' => 'old_b'))), diff --git a/src/Symfony/Component/Translation/Tests/Catalogue/MergeOperationTest.php b/src/Symfony/Component/Translation/Tests/Catalogue/MergeOperationTest.php index 6f463b9a02dad..a97ec04ad109a 100644 --- a/src/Symfony/Component/Translation/Tests/Catalogue/MergeOperationTest.php +++ b/src/Symfony/Component/Translation/Tests/Catalogue/MergeOperationTest.php @@ -44,7 +44,7 @@ public function testGetResultFromSingleDomain() { $this->assertEquals( new MessageCatalogue('en', array( - 'messages' => array('a' => 'old_a', 'b' => 'old_b', 'c' => 'new_c') + 'messages' => array('a' => 'old_a', 'b' => 'old_b', 'c' => 'new_c'), )), $this->createOperation( new MessageCatalogue('en', array('messages' => array('a' => 'old_a', 'b' => 'old_b'))), diff --git a/src/Symfony/Component/Translation/Tests/Dumper/IcuResFileDumperTest.php b/src/Symfony/Component/Translation/Tests/Dumper/IcuResFileDumperTest.php index cb30c6661ca73..f3b29ceadf112 100644 --- a/src/Symfony/Component/Translation/Tests/Dumper/IcuResFileDumperTest.php +++ b/src/Symfony/Component/Translation/Tests/Dumper/IcuResFileDumperTest.php @@ -25,7 +25,7 @@ public function testDump() $catalogue = new MessageCatalogue('en'); $catalogue->add(array('foo' => 'bar')); - $tempDir = sys_get_temp_dir() . '/IcuResFileDumperTest'; + $tempDir = sys_get_temp_dir().'/IcuResFileDumperTest'; mkdir($tempDir); $dumper = new IcuResFileDumper(); $dumper->dump($catalogue, array('path' => $tempDir)); diff --git a/src/Symfony/Component/Translation/Tests/PluralizationRulesTest.php b/src/Symfony/Component/Translation/Tests/PluralizationRulesTest.php index 038153546837d..2140013c54768 100644 --- a/src/Symfony/Component/Translation/Tests/PluralizationRulesTest.php +++ b/src/Symfony/Component/Translation/Tests/PluralizationRulesTest.php @@ -28,7 +28,6 @@ */ class PluralizationRulesTest extends \PHPUnit_Framework_TestCase { - /** * We test failed langcode here. * @@ -60,7 +59,7 @@ public function testLangcodes($nplural, $langCodes) */ public function successLangcodes() { - return array( + return array( array('1' , array('ay','bo', 'cgg','dz','id', 'ja', 'jbo', 'ka','kk','km','ko','ky')), array('2' , array('nl', 'fr', 'en', 'de', 'de_GE')), array('3' , array('be','bs','cs','hr')), @@ -80,7 +79,7 @@ public function successLangcodes() */ public function failingLangcodes() { - return array( + return array( array('1' , array('fa')), array('2' , array('jbo')), array('3' , array('cbs')), @@ -113,7 +112,7 @@ protected function generateTestData($plural, $langCodes) { $matrix = array(); foreach ($langCodes as $langCode) { - for ($count=0; $count<200; $count++) { + for ($count = 0; $count<200; $count++) { $plural = PluralizationRules::get($count, $langCode); $matrix[$langCode][$count] = $plural; } diff --git a/src/Symfony/Component/Translation/Tests/TranslatorTest.php b/src/Symfony/Component/Translation/Tests/TranslatorTest.php index cf9c8df659f7f..3fa87161d0a4d 100644 --- a/src/Symfony/Component/Translation/Tests/TranslatorTest.php +++ b/src/Symfony/Component/Translation/Tests/TranslatorTest.php @@ -17,7 +17,6 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase { - /** * @dataProvider getInvalidLocalesTests * @expectedException \InvalidArgumentException @@ -356,12 +355,12 @@ public function getFlattenedTransTests() $messages = array( 'symfony2' => array( 'is' => array( - 'great' => 'Symfony2 est super!' - ) + 'great' => 'Symfony2 est super!', + ), ), 'foo' => array( 'bar' => array( - 'baz' => 'Foo Bar Baz' + 'baz' => 'Foo Bar Baz', ), 'baz' => 'Foo Baz', ), diff --git a/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php b/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php index 2e8230bb839b9..3438a4daa628d 100644 --- a/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php +++ b/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php @@ -34,7 +34,7 @@ public function validate($value, Constraint $constraint) $this->context->addViolation($constraint->message, array( '{{ value }}' => $this->formatValue($value, self::OBJECT_TO_STRING | self::PRETTY_DATE), '{{ compared_value }}' => $this->formatValue($constraint->value, self::OBJECT_TO_STRING | self::PRETTY_DATE), - '{{ compared_value_type }}' => $this->formatTypeOf($constraint->value) + '{{ compared_value_type }}' => $this->formatTypeOf($constraint->value), )); } } diff --git a/src/Symfony/Component/Validator/Constraints/BlankValidator.php b/src/Symfony/Component/Validator/Constraints/BlankValidator.php index e8406a238efa8..8fde2b8dd07f4 100644 --- a/src/Symfony/Component/Validator/Constraints/BlankValidator.php +++ b/src/Symfony/Component/Validator/Constraints/BlankValidator.php @@ -28,7 +28,7 @@ public function validate($value, Constraint $constraint) { if ('' !== $value && null !== $value) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $this->formatValue($value) + '{{ value }}' => $this->formatValue($value), )); } } diff --git a/src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php b/src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php index 73f602adce4bc..76a202bc4dc2e 100644 --- a/src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php @@ -28,14 +28,14 @@ class CardSchemeValidator extends ConstraintValidator * American Express card numbers start with 34 or 37 and have 15 digits. */ 'AMEX' => array( - '/^3[47][0-9]{13}$/' + '/^3[47][0-9]{13}$/', ), /** * China UnionPay cards start with 62 and have between 16 and 19 digits. * Please note that these cards do not follow Luhn Algorithm as a checksum. */ 'CHINA_UNIONPAY' => array( - '/^62[0-9]{14,17}$/' + '/^62[0-9]{14,17}$/', ), /** * Diners Club card numbers begin with 300 through 305, 36 or 38. All have 14 digits. @@ -53,45 +53,45 @@ class CardSchemeValidator extends ConstraintValidator '/^6011[0-9]{12}$/', '/^64[4-9][0-9]{13}$/', '/^65[0-9]{14}$/', - '/^622(12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|91[0-9]|92[0-5])[0-9]{10}$/' + '/^622(12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|91[0-9]|92[0-5])[0-9]{10}$/', ), /** * InstaPayment cards begin with 637 through 639 and have 16 digits */ 'INSTAPAYMENT' => array( - '/^63[7-9][0-9]{13}$/' + '/^63[7-9][0-9]{13}$/', ), /** * JCB cards beginning with 2131 or 1800 have 15 digits. * JCB cards beginning with 35 have 16 digits. */ 'JCB' => array( - '/^(?:2131|1800|35[0-9]{3})[0-9]{11}$/' + '/^(?:2131|1800|35[0-9]{3})[0-9]{11}$/', ), /** * Laser cards begin with either 6304, 6706, 6709 or 6771 and have between 16 and 19 digits */ 'LASER' => array( - '/^(6304|670[69]|6771)[0-9]{12,15}$/' + '/^(6304|670[69]|6771)[0-9]{12,15}$/', ), /** * Maestro cards begin with either 5018, 5020, 5038, 5893, 6304, 6759, 6761, 6762, 6763 or 0604 * They have between 12 and 19 digits */ 'MAESTRO' => array( - '/^(5018|5020|5038|6304|6759|6761|676[23]|0604)[0-9]{8,15}$/' + '/^(5018|5020|5038|6304|6759|6761|676[23]|0604)[0-9]{8,15}$/', ), /** * All MasterCard numbers start with the numbers 51 through 55. All have 16 digits. */ 'MASTERCARD' => array( - '/^5[1-5][0-9]{14}$/' + '/^5[1-5][0-9]{14}$/', ), /** * All Visa card numbers start with a 4. New cards have 16 digits. Old cards have 13. */ 'VISA' => array( - '/^4([0-9]{12}|[0-9]{15})$/' + '/^4([0-9]{12}|[0-9]{15})$/', ), ); diff --git a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php index 79081fee49cea..93f13c75da384 100644 --- a/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ChoiceValidator.php @@ -69,7 +69,7 @@ public function validate($value, Constraint $constraint) if ($constraint->min !== null && $count < $constraint->min) { $this->context->addViolation($constraint->minMessage, array( - '{{ limit }}' => $constraint->min + '{{ limit }}' => $constraint->min, ), $value, (int) $constraint->min); return; @@ -77,14 +77,14 @@ public function validate($value, Constraint $constraint) if ($constraint->max !== null && $count > $constraint->max) { $this->context->addViolation($constraint->maxMessage, array( - '{{ limit }}' => $constraint->max + '{{ limit }}' => $constraint->max, ), $value, (int) $constraint->max); return; } } elseif (!in_array($value, $choices, $constraint->strict)) { $this->context->addViolation($constraint->message, array( - '{{ value }}' => $this->formatValue($value) + '{{ value }}' => $this->formatValue($value), )); } } diff --git a/src/Symfony/Component/Validator/Constraints/CollectionValidator.php b/src/Symfony/Component/Validator/Constraints/CollectionValidator.php index 33f839d3b9498..4c6a714e7e08a 100644 --- a/src/Symfony/Component/Validator/Constraints/CollectionValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CollectionValidator.php @@ -46,7 +46,7 @@ public function validate($value, Constraint $constraint) $this->context->validateValue($value[$field], $fieldConstraint->constraints, '['.$field.']', $group); } elseif (!$fieldConstraint instanceof Optional && !$constraint->allowMissingFields) { $this->context->addViolationAt('['.$field.']', $constraint->missingFieldsMessage, array( - '{{ field }}' => $this->formatValue($field) + '{{ field }}' => $this->formatValue($field), ), null); } } @@ -55,7 +55,7 @@ public function validate($value, Constraint $constraint) foreach ($value as $field => $fieldValue) { if (!isset($constraint->fields[$field])) { $this->context->addViolationAt('['.$field.']', $constraint->extraFieldsMessage, array( - '{{ field }}' => $this->formatValue($field) + '{{ field }}' => $this->formatValue($field), ), $fieldValue); } } diff --git a/src/Symfony/Component/Validator/Constraints/FileValidator.php b/src/Symfony/Component/Validator/Constraints/FileValidator.php index 006064594bef7..44378e681e0ed 100644 --- a/src/Symfony/Component/Validator/Constraints/FileValidator.php +++ b/src/Symfony/Component/Validator/Constraints/FileValidator.php @@ -97,7 +97,7 @@ public function validate($value, Constraint $constraint) if (!is_file($path)) { $this->context->addViolation($constraint->notFoundMessage, array( - '{{ file }}' => $this->formatValue($path) + '{{ file }}' => $this->formatValue($path), )); return; @@ -105,7 +105,7 @@ public function validate($value, Constraint $constraint) if (!is_readable($path)) { $this->context->addViolation($constraint->notReadableMessage, array( - '{{ file }}' => $this->formatValue($path) + '{{ file }}' => $this->formatValue($path), )); return; diff --git a/src/Symfony/Component/Validator/Constraints/ImageValidator.php b/src/Symfony/Component/Validator/Constraints/ImageValidator.php index 79890b83046fd..1671565762eee 100644 --- a/src/Symfony/Component/Validator/Constraints/ImageValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ImageValidator.php @@ -60,7 +60,7 @@ public function validate($value, Constraint $constraint) if ($width < $constraint->minWidth) { $this->context->addViolation($constraint->minWidthMessage, array( '{{ width }}' => $width, - '{{ min_width }}' => $constraint->minWidth + '{{ min_width }}' => $constraint->minWidth, )); return; @@ -75,7 +75,7 @@ public function validate($value, Constraint $constraint) if ($width > $constraint->maxWidth) { $this->context->addViolation($constraint->maxWidthMessage, array( '{{ width }}' => $width, - '{{ max_width }}' => $constraint->maxWidth + '{{ max_width }}' => $constraint->maxWidth, )); return; @@ -90,7 +90,7 @@ public function validate($value, Constraint $constraint) if ($height < $constraint->minHeight) { $this->context->addViolation($constraint->minHeightMessage, array( '{{ height }}' => $height, - '{{ min_height }}' => $constraint->minHeight + '{{ min_height }}' => $constraint->minHeight, )); return; @@ -105,7 +105,7 @@ public function validate($value, Constraint $constraint) if ($height > $constraint->maxHeight) { $this->context->addViolation($constraint->maxHeightMessage, array( '{{ height }}' => $height, - '{{ max_height }}' => $constraint->maxHeight + '{{ max_height }}' => $constraint->maxHeight, )); } } diff --git a/src/Symfony/Component/Validator/Constraints/IsbnValidator.php b/src/Symfony/Component/Validator/Constraints/IsbnValidator.php index 5fee10e718b86..4f246960f335a 100644 --- a/src/Symfony/Component/Validator/Constraints/IsbnValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IsbnValidator.php @@ -100,7 +100,8 @@ private function isValidIsbn13($isbn) } for ($i = 1; $i < 12; $i += 2) { - $checkSum += $isbn{$i} * 3; + $checkSum += $isbn{$i} + * 3; } return 0 === $checkSum % 10; diff --git a/src/Symfony/Component/Validator/Constraints/IssnValidator.php b/src/Symfony/Component/Validator/Constraints/IssnValidator.php index 301b40d2d97b2..24618eac5095c 100644 --- a/src/Symfony/Component/Validator/Constraints/IssnValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IssnValidator.php @@ -55,7 +55,8 @@ public function validate($value, Constraint $constraint) $canonical = strtoupper(str_replace('-', '', $value)); // Calculate a checksum. "X" equals 10. - $checkSum = 'X' === $canonical{7} ? 10 : $canonical{7}; + $checkSum = 'X' === $canonical{7} + ? 10 : $canonical{7}; for ($i = 0; $i < 7; ++$i) { // Multiply the first digit by 8, the second by 7, etc. diff --git a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php index 792d8e51409f3..981ec55e0c887 100644 --- a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php @@ -131,7 +131,7 @@ public function __sleep() 'members', 'name', 'properties', - 'defaultGroup' + 'defaultGroup', )); } diff --git a/src/Symfony/Component/Validator/Tests/ConstraintTest.php b/src/Symfony/Component/Validator/Tests/ConstraintTest.php index f1f73fca06eb3..63eaf6242ae60 100644 --- a/src/Symfony/Component/Validator/Tests/ConstraintTest.php +++ b/src/Symfony/Component/Validator/Tests/ConstraintTest.php @@ -53,7 +53,7 @@ public function testInvalidAndRequiredOptionsPassed() new ConstraintC(array( 'option1' => 'default', - 'foo' => 'bar' + 'foo' => 'bar', )); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php index a56f734554fd1..8ced06b1bdd15 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php @@ -87,7 +87,7 @@ public function testInvalidComparisonToValue($dirtyValue, $dirtyValueAsString, $ $this->assertViolation('Constraint Message', array( '{{ value }}' => $dirtyValueAsString, '{{ compared_value }}' => $comparedValueString, - '{{ compared_value_type }}' => $comparedValueType + '{{ compared_value_type }}' => $comparedValueType, )); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php index bc4e1c214a02c..864b58a35b7d2 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/AbstractConstraintValidatorTest.php @@ -74,7 +74,7 @@ protected function createContext() $this->metadata, $this->value, $this->group, - $this->propertyPath + $this->propertyPath, )) ->setMethods(array('validate', 'validateValue')) ->getMock(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php index 1d83d10b0f2ad..c73a4a9cf6b3b 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/BlankValidatorTest.php @@ -41,7 +41,7 @@ public function testBlankIsValid() public function testInvalidValues($value, $valueAsString) { $constraint = new Blank(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); $this->validator->validate($value, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php index 038f1a39111bd..377999bc76b81 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CallbackValidatorTest.php @@ -121,7 +121,7 @@ public function testSingleStaticMethod() { $object = new CallbackValidatorTest_Object(); $constraint = new Callback(array( - array(__CLASS__.'_Class', 'validateCallback') + array(__CLASS__.'_Class', 'validateCallback'), )); $this->validator->validate($object, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php index 113a31e3cfc06..335f620218978 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ChoiceValidatorTest.php @@ -89,7 +89,7 @@ public function testValidChoiceCallbackClosure() { $constraint = new Choice(array('callback' => function () { return array('foo', 'bar'); - })); + },)); $this->validator->validate('bar', $constraint); @@ -228,7 +228,7 @@ public function testStrictDisallowsDifferentType() $constraint = new Choice(array( 'choices' => array(1, 2), 'strict' => true, - 'message' => 'myMessage' + 'message' => 'myMessage', )); $this->validator->validate('2', $constraint); @@ -243,7 +243,7 @@ public function testNonStrictWithMultipleChoices() $constraint = new Choice(array( 'choices' => array(1, 2, 3), 'multiple' => true, - 'strict' => false + 'strict' => false, )); $this->validator->validate(array('2', 3), $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php index 8c26957e6f412..a620ee576ca9f 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CollectionValidatorTest.php @@ -112,7 +112,7 @@ public function testWalkMultipleConstraints() 'fields' => array( 'foo' => $constraints, 'bar' => $constraints, - ) + ), ))); $this->assertNoViolation(); @@ -137,7 +137,7 @@ public function testExtraFieldsDisallowed() ))); $this->assertViolation('myMessage', array( - '{{ field }}' => '"baz"' + '{{ field }}' => '"baz"', ), 'property.path[baz]', 6); } @@ -196,7 +196,7 @@ public function testMissingFieldsDisallowed() ))); $this->assertViolation('myMessage', array( - '{{ field }}' => '"foo"' + '{{ field }}' => '"foo"', ), 'property.path[foo]', null); } @@ -306,7 +306,7 @@ public function testRequiredFieldNotPresent() ))); $this->assertViolation('myMessage', array( - '{{ field }}' => '"foo"' + '{{ field }}' => '"foo"', ), 'property.path[foo]', null); } @@ -354,7 +354,7 @@ public function testRequiredFieldMultipleConstraints() public function testObjectShouldBeLeftUnchanged() { $value = new \ArrayObject(array( - 'foo' => 3 + 'foo' => 3, )); $constraint = new Range(array('min' => 2)); @@ -364,11 +364,11 @@ public function testObjectShouldBeLeftUnchanged() $this->validator->validate($value, new Collection(array( 'fields' => array( 'foo' => $constraint, - ) + ), ))); $this->assertEquals(array( - 'foo' => 3 + 'foo' => 3, ), (array) $value); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php index c910c1156ccc2..1b8bb09232f21 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CountValidatorTest.php @@ -116,7 +116,7 @@ public function testInvalidValuesMax($value) { $constraint = new Count(array( 'max' => 4, - 'maxMessage' => 'myMessage' + 'maxMessage' => 'myMessage', )); $this->validator->validate($value, $constraint); @@ -134,7 +134,7 @@ public function testInvalidValuesMin($value) { $constraint = new Count(array( 'min' => 4, - 'minMessage' => 'myMessage' + 'minMessage' => 'myMessage', )); $this->validator->validate($value, $constraint); @@ -153,7 +153,7 @@ public function testInvalidValuesExact($value) $constraint = new Count(array( 'min' => 4, 'max' => 4, - 'exactMessage' => 'myMessage' + 'exactMessage' => 'myMessage', )); $this->validator->validate($value, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php index c6693020f83ae..a8090aee20090 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php @@ -76,7 +76,7 @@ public function getValidCountries() public function testInvalidCountries($country) { $constraint = new Country(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); $this->validator->validate($country, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php index 0480b60ed7078..c9238c2711bc1 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CurrencyValidatorTest.php @@ -90,7 +90,7 @@ public function getValidCurrencies() public function testInvalidCurrencies($currency) { $constraint = new Currency(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); $this->validator->validate($currency, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php index 5addbf34de874..76961236d3bb4 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php @@ -75,7 +75,7 @@ public function getValidDateTimes() public function testInvalidDateTimes($dateTime) { $constraint = new DateTime(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); $this->validator->validate($dateTime, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php index 8fdacee94d490..2adcd46a4360b 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php @@ -75,7 +75,7 @@ public function getValidDates() public function testInvalidDates($date) { $constraint = new Date(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); $this->validator->validate($date, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php index e4722e159e5b3..18e23b8b4d1b7 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/EmailValidatorTest.php @@ -68,7 +68,7 @@ public function getValidEmails() public function testInvalidEmails($email) { $constraint = new Email(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); $this->validator->validate($email, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php index e9abbb9a386cc..7de6b9c5ae4b8 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FalseValidatorTest.php @@ -38,13 +38,13 @@ public function testFalseIsValid() public function testTrueIsInvalid() { $constraint = new False(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); $this->validator->validate(true, $constraint); $this->assertViolation('myMessage', array( - '{{ value }}' => 'true' + '{{ value }}' => 'true', )); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php index 6c8cb8abbb26a..c93a514304f19 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php @@ -353,13 +353,12 @@ public function testUploadedFileError($error, $message, array $params = array(), $constraint = new File(array( $message => 'myMessage', - 'maxSize' => $maxSize + 'maxSize' => $maxSize, )); $this->validator->validate($file, $constraint); $this->assertViolation('myMessage', $params); - } public function uploadedFileErrorProvider() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php index bb90f7c283307..0d7327ad36dad 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanOrEqualValidatorTest.php @@ -53,7 +53,7 @@ public function provideInvalidComparisons() return array( array(1, '1', 2, '2', 'integer'), array(new \DateTime('2000/01/01'), 'Jan 1, 2000, 12:00 AM', new \DateTime('2005/01/01'), 'Jan 1, 2005, 12:00 AM', 'DateTime'), - array('b', '"b"', 'c', '"c"', 'string') + array('b', '"b"', 'c', '"c"', 'string'), ); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php index 64c5dbff65247..dea2bc0cd3f99 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/GreaterThanValidatorTest.php @@ -56,7 +56,7 @@ public function provideInvalidComparisons() array(new ComparisonTest_Class(4), '4', new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'), array(new ComparisonTest_Class(5), '5', new ComparisonTest_Class(5), '5', __NAMESPACE__.'\ComparisonTest_Class'), array('22', '"22"', '333', '"333"', 'string'), - array('22', '"22"', '22', '"22"', 'string') + array('22', '"22"', '22', '"22"', 'string'), ); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php index 8cf7f5ae53c59..6a84a66324f69 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php @@ -13,7 +13,6 @@ use Symfony\Component\Validator\Constraints\Iban; use Symfony\Component\Validator\Constraints\IbanValidator; -use Symfony\Component\Validator\Validation; class IbanValidatorTest extends AbstractConstraintValidatorTest { @@ -154,7 +153,7 @@ public function getValidIbans() public function testInvalidIbans($iban) { $constraint = new Iban(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); $this->validator->validate($iban, $constraint); @@ -181,7 +180,7 @@ public function getInvalidIbans() //Ibans with lower case values are invalid array('Ae260211000000230064016'), - array('ae260211000000230064016') + array('ae260211000000230064016'), ); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php index 01f1a06199c46..35a934ee27cbb 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/ImageValidatorTest.php @@ -13,7 +13,6 @@ use Symfony\Component\Validator\Constraints\Image; use Symfony\Component\Validator\Constraints\ImageValidator; -use Symfony\Component\Validator\Validation; class ImageValidatorTest extends AbstractConstraintValidatorTest { diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php index bc849278de59f..5316330623a0a 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IpValidatorTest.php @@ -13,7 +13,6 @@ use Symfony\Component\Validator\Constraints\Ip; use Symfony\Component\Validator\Constraints\IpValidator; -use Symfony\Component\Validator\Validation; class IpValidatorTest extends AbstractConstraintValidatorTest { diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php index bb49937dfdbf2..8de704edee311 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IsbnValidatorTest.php @@ -13,7 +13,6 @@ use Symfony\Component\Validator\Constraints\Isbn; use Symfony\Component\Validator\Constraints\IsbnValidator; -use Symfony\Component\Validator\Validation; /** * @see https://en.wikipedia.org/wiki/Isbn @@ -40,7 +39,7 @@ public function getValidIsbn10() array('0321812700'), array('0-45122-5244'), array('0-4712-92311'), - array('0-9752298-0-X') + array('0-9752298-0-X'), ); } @@ -181,7 +180,7 @@ public function testInvalidIsbn10($isbn) */ public function testValidIsbn13($isbn) { - $constraint = new Isbn(array('isbn13' => true,)); + $constraint = new Isbn(array('isbn13' => true)); $this->validator->validate($isbn, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php index b48357a880cd2..992536ebf29b0 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php @@ -13,7 +13,6 @@ use Symfony\Component\Validator\Constraints\Issn; use Symfony\Component\Validator\Constraints\IssnValidator; -use Symfony\Component\Validator\Validation; /** * @see https://en.wikipedia.org/wiki/Issn @@ -79,7 +78,7 @@ public function getInvalidFormatedIssn() return array( array(0), array('1539'), - array('2156-537A') + array('2156-537A'), ); } @@ -92,7 +91,6 @@ public function getInvalidValueIssn() array('1684-537X'), array('1996-0795'), ); - } public function getInvalidIssn() diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php index ad2b1e89715cb..5ef9d3a6efbdb 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php @@ -76,7 +76,7 @@ public function getValidLanguages() public function testInvalidLanguages($language) { $constraint = new Language(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); $this->validator->validate($language, $constraint); @@ -100,7 +100,7 @@ public function testValidateUsingCountrySpecificLocale() $existingLanguage = 'en'; $this->validator->validate($existingLanguage, new Language(array( - 'message' => 'aMessage' + 'message' => 'aMessage', ))); $this->assertNoViolation(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php index 31039c08ae040..4457d264dd00a 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LengthValidatorTest.php @@ -13,7 +13,6 @@ use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\LengthValidator; -use Symfony\Component\Validator\Validation; class LengthValidatorTest extends AbstractConstraintValidatorTest { @@ -146,7 +145,7 @@ public function testInvalidValuesMin($value, $mbOnly = false) $constraint = new Length(array( 'min' => 4, - 'minMessage' => 'myMessage' + 'minMessage' => 'myMessage', )); $this->validator->validate($value, $constraint); @@ -168,7 +167,7 @@ public function testInvalidValuesMax($value, $mbOnly = false) $constraint = new Length(array( 'max' => 4, - 'maxMessage' => 'myMessage' + 'maxMessage' => 'myMessage', )); $this->validator->validate($value, $constraint); @@ -191,7 +190,7 @@ public function testInvalidValuesExact($value, $mbOnly = false) $constraint = new Length(array( 'min' => 4, 'max' => 4, - 'exactMessage' => 'myMessage' + 'exactMessage' => 'myMessage', )); $this->validator->validate($value, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php index 0f4f749b8bcc8..71da446386129 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualValidatorTest.php @@ -56,7 +56,7 @@ public function provideInvalidComparisons() array(2, '2', 1, '1', 'integer'), array(new \DateTime('2010-01-01'), 'Jan 1, 2010, 12:00 AM', new \DateTime('2000-01-01'), 'Jan 1, 2000, 12:00 AM', 'DateTime'), array(new ComparisonTest_Class(5), '5', new ComparisonTest_Class(4), '4', __NAMESPACE__.'\ComparisonTest_Class'), - array('c', '"c"', 'b', '"b"', 'string') + array('c', '"c"', 'b', '"b"', 'string'), ); } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php index 8c76485e53343..31d988df59532 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php @@ -78,7 +78,7 @@ public function getValidLocales() public function testInvalidLocales($locale) { $constraint = new Locale(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); $this->validator->validate($locale, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php index 9b02bf6492237..830c0436ead91 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LuhnValidatorTest.php @@ -13,7 +13,6 @@ use Symfony\Component\Validator\Constraints\Luhn; use Symfony\Component\Validator\Constraints\LuhnValidator; -use Symfony\Component\Validator\Validation; class LuhnValidatorTest extends AbstractConstraintValidatorTest { diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php index fe289514665cf..0f9337b8b77d7 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php @@ -13,7 +13,6 @@ use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotBlankValidator; -use Symfony\Component\Validator\Validation; class NotBlankValidatorTest extends AbstractConstraintValidatorTest { @@ -46,7 +45,7 @@ public function getValidValues() public function testNullIsInvalid() { $constraint = new NotBlank(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); $this->validator->validate(null, $constraint); @@ -59,7 +58,7 @@ public function testNullIsInvalid() public function testBlankIsInvalid() { $constraint = new NotBlank(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); $this->validator->validate('', $constraint); @@ -72,7 +71,7 @@ public function testBlankIsInvalid() public function testFalseIsInvalid() { $constraint = new NotBlank(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); $this->validator->validate(false, $constraint); @@ -85,7 +84,7 @@ public function testFalseIsInvalid() public function testEmptyArrayIsInvalid() { $constraint = new NotBlank(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); $this->validator->validate(array(), $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php index 8224423e9bf02..f9de951b61fdf 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NotNullValidatorTest.php @@ -13,7 +13,6 @@ use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\NotNullValidator; -use Symfony\Component\Validator\Validation; class NotNullValidatorTest extends AbstractConstraintValidatorTest { @@ -45,7 +44,7 @@ public function getValidValues() public function testNullIsInvalid() { $constraint = new NotNull(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); $this->validator->validate(null, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php index b659bc029a46f..a66bf83414794 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/NullValidatorTest.php @@ -13,7 +13,6 @@ use Symfony\Component\Validator\Constraints\Null; use Symfony\Component\Validator\Constraints\NullValidator; -use Symfony\Component\Validator\Validation; class NullValidatorTest extends AbstractConstraintValidatorTest { @@ -35,7 +34,7 @@ public function testNullIsValid() public function testInvalidValues($value, $valueAsString) { $constraint = new Null(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); $this->validator->validate($value, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php index 9c043a6d56098..3af24e896c764 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RangeValidatorTest.php @@ -13,7 +13,6 @@ use Symfony\Component\Validator\Constraints\Range; use Symfony\Component\Validator\Constraints\RangeValidator; -use Symfony\Component\Validator\Validation; class RangeValidatorTest extends AbstractConstraintValidatorTest { diff --git a/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php index 91f0c0532fce6..e28a8e03ccea3 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/RegexValidatorTest.php @@ -13,7 +13,6 @@ use Symfony\Component\Validator\Constraints\Regex; use Symfony\Component\Validator\Constraints\RegexValidator; -use Symfony\Component\Validator\Validation; class RegexValidatorTest extends AbstractConstraintValidatorTest { @@ -72,7 +71,7 @@ public function testInvalidValues($value) { $constraint = new Regex(array( 'pattern' => '/^[0-9]+$/', - 'message' => 'myMessage' + 'message' => 'myMessage', )); $this->validator->validate($value, $constraint); @@ -151,7 +150,7 @@ public function testHtmlPattern() // Dropped because of match=false $constraint = new Regex(array( 'pattern' => '/[a-z]+/', - 'match' => false + 'match' => false, )); $this->assertNull($constraint->getHtmlPattern()); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php index 4cc5f028b43b1..3536a72a25cc9 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php @@ -13,7 +13,6 @@ use Symfony\Component\Validator\Constraints\Time; use Symfony\Component\Validator\Constraints\TimeValidator; -use Symfony\Component\Validator\Validation; class TimeValidatorTest extends AbstractConstraintValidatorTest { @@ -76,7 +75,7 @@ public function getValidTimes() public function testInvalidTimes($time) { $constraint = new Time(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); $this->validator->validate($time, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php index e401b8702214d..68f207eba2e07 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TrueValidatorTest.php @@ -13,7 +13,6 @@ use Symfony\Component\Validator\Constraints\True; use Symfony\Component\Validator\Constraints\TrueValidator; -use Symfony\Component\Validator\Validation; class TrueValidatorTest extends AbstractConstraintValidatorTest { @@ -39,7 +38,7 @@ public function testTrueIsValid() public function testFalseIsInvalid() { $constraint = new True(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); $this->validator->validate(false, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php index 139184638737c..7a7fcea74eb97 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TypeValidatorTest.php @@ -13,7 +13,6 @@ use Symfony\Component\Validator\Constraints\Type; use Symfony\Component\Validator\Constraints\TypeValidator; -use Symfony\Component\Validator\Validation; class TypeValidatorTest extends AbstractConstraintValidatorTest { @@ -113,7 +112,7 @@ public function testInvalidValues($value, $type, $valueAsString) { $constraint = new Type(array( 'type' => $type, - 'message' => 'myMessage' + 'message' => 'myMessage', )); $this->validator->validate($value, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php index 0d4e8e3394e31..353c9acc67f75 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php @@ -114,7 +114,7 @@ public function getValidUrls() public function testInvalidUrls($url) { $constraint = new Url(array( - 'message' => 'myMessage' + 'message' => 'myMessage', )); $this->validator->validate($url, $constraint); @@ -155,7 +155,7 @@ public function getInvalidUrls() public function testCustomProtocolIsValid($url) { $constraint = new Url(array( - 'protocols' => array('ftp', 'file', 'git') + 'protocols' => array('ftp', 'file', 'git'), )); $this->validator->validate($url, $constraint); diff --git a/src/Symfony/Component/Validator/Tests/ExecutionContextTest.php b/src/Symfony/Component/Validator/Tests/ExecutionContextTest.php index dcc9c027bf75b..cf91137e3a816 100644 --- a/src/Symfony/Component/Validator/Tests/ExecutionContextTest.php +++ b/src/Symfony/Component/Validator/Tests/ExecutionContextTest.php @@ -284,7 +284,7 @@ public function testGetPropertyPathWithNestedCollectionsMixed() 'foo' => new ConstraintA(), 'bar' => new ConstraintA(), )), - 'name' => new ConstraintA() + 'name' => new ConstraintA(), )); $visitor = new ValidationVisitor('Root', $this->metadataFactory, new ConstraintValidatorFactory(), $this->translator); diff --git a/src/Symfony/Component/Validator/Tests/Fixtures/StubGlobalExecutionContext.php b/src/Symfony/Component/Validator/Tests/Fixtures/StubGlobalExecutionContext.php index bfe096a86dad7..aa8b74c8b90f5 100644 --- a/src/Symfony/Component/Validator/Tests/Fixtures/StubGlobalExecutionContext.php +++ b/src/Symfony/Component/Validator/Tests/Fixtures/StubGlobalExecutionContext.php @@ -27,7 +27,7 @@ class StubGlobalExecutionContext implements GlobalExecutionContextInterface private $visitor; - function __construct($root = null, ValidationVisitorInterface $visitor = null) + public function __construct($root = null, ValidationVisitorInterface $visitor = null) { $this->violations = new ConstraintViolationList(); $this->root = $root; diff --git a/src/Symfony/Component/Validator/Tests/Mapping/ElementMetadataTest.php b/src/Symfony/Component/Validator/Tests/Mapping/ElementMetadataTest.php index 8cf3e6dec4683..03ec6652b3888 100644 --- a/src/Symfony/Component/Validator/Tests/Mapping/ElementMetadataTest.php +++ b/src/Symfony/Component/Validator/Tests/Mapping/ElementMetadataTest.php @@ -70,4 +70,6 @@ public function testSerialize() } } -class TestElementMetadata extends ElementMetadata {} +class TestElementMetadata extends ElementMetadata +{ +} diff --git a/src/Symfony/Component/Validator/Tests/ValidationVisitorTest.php b/src/Symfony/Component/Validator/Tests/ValidationVisitorTest.php index f2838737a2e1c..2fe4395c2d2ac 100644 --- a/src/Symfony/Component/Validator/Tests/ValidationVisitorTest.php +++ b/src/Symfony/Component/Validator/Tests/ValidationVisitorTest.php @@ -587,7 +587,7 @@ public function testInitializeObjectsOnFirstValidation() $this->visitor = new ValidationVisitor('Root', $this->metadataFactory, new ConstraintValidatorFactory(), new DefaultTranslator(), null, array( $initializer1, - $initializer2 + $initializer2, )); // prepare constraint which diff --git a/src/Symfony/Component/Validator/Validator.php b/src/Symfony/Component/Validator/Validator.php index 39d886a1717c3..963558d4cd9f8 100644 --- a/src/Symfony/Component/Validator/Validator.php +++ b/src/Symfony/Component/Validator/Validator.php @@ -54,8 +54,7 @@ public function __construct( TranslatorInterface $translator, $translationDomain = 'validators', array $objectInitializers = array() - ) - { + ) { $this->metadataFactory = $metadataFactory; $this->validatorFactory = $validatorFactory; $this->translator = $translator; diff --git a/src/Symfony/Component/Yaml/Escaper.php b/src/Symfony/Component/Yaml/Escaper.php index 15a121792f9d6..7f6ec2bef297d 100644 --- a/src/Symfony/Component/Yaml/Escaper.php +++ b/src/Symfony/Component/Yaml/Escaper.php @@ -31,13 +31,13 @@ class Escaper "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f", "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f", - "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9"); + "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9",); private static $escaped = array('\\\\', '\\"', '\\\\', '\\"', "\\0", "\\x01", "\\x02", "\\x03", "\\x04", "\\x05", "\\x06", "\\a", "\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\x0e", "\\x0f", "\\x10", "\\x11", "\\x12", "\\x13", "\\x14", "\\x15", "\\x16", "\\x17", "\\x18", "\\x19", "\\x1a", "\\e", "\\x1c", "\\x1d", "\\x1e", "\\x1f", - "\\N", "\\_", "\\L", "\\P"); + "\\N", "\\_", "\\L", "\\P",); /** * Determines if a PHP value would require double quoting in YAML. diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 5c578e35d3249..910db804cdafb 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -92,7 +92,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) { $c = $this->getRealCurrentLineNb() + 1; $parser = new Parser($c); - $parser->refs =& $this->refs; + $parser->refs = & $this->refs; $data[] = $parser->parse($this->getNextEmbedBlock(null, true), $exceptionOnInvalidType, $objectSupport); } else { if (isset($values['leadspaces']) @@ -102,7 +102,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = // this is a compact notation element, add to next block and parse $c = $this->getRealCurrentLineNb(); $parser = new Parser($c); - $parser->refs =& $this->refs; + $parser->refs = & $this->refs; $block = $values['value']; if ($this->isNextLineIndented()) { @@ -145,7 +145,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = } $c = $this->getRealCurrentLineNb() + 1; $parser = new Parser($c); - $parser->refs =& $this->refs; + $parser->refs = & $this->refs; $parsed = $parser->parse($value, $exceptionOnInvalidType, $objectSupport); $merged = array(); @@ -182,7 +182,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport = } else { $c = $this->getRealCurrentLineNb() + 1; $parser = new Parser($c); - $parser->refs =& $this->refs; + $parser->refs = & $this->refs; $data[$key] = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport); } } else { @@ -647,5 +647,4 @@ private function isStringUnIndentedCollectionItem() { return (0 === strpos($this->currentLine, '- ')); } - } diff --git a/src/Symfony/Component/Yaml/Tests/DumperTest.php b/src/Symfony/Component/Yaml/Tests/DumperTest.php index 53d164c4ba55a..51e12d41f5458 100644 --- a/src/Symfony/Component/Yaml/Tests/DumperTest.php +++ b/src/Symfony/Component/Yaml/Tests/DumperTest.php @@ -55,7 +55,7 @@ public function testSetIndentation() { $this->dumper->setIndentation(7); -$expected = <<assertEquals($expected, $this->dumper->dump($this->array, -10), '->dump() takes an inline level argument'); -$this->assertEquals($expected, $this->dumper->dump($this->array, 0), '->dump() takes an inline level argument'); + $this->assertEquals($expected, $this->dumper->dump($this->array, -10), '->dump() takes an inline level argument'); + $this->assertEquals($expected, $this->dumper->dump($this->array, 0), '->dump() takes an inline level argument'); -$expected = << array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo'))), '[foo, bar: { foo: bar }]' => array('foo', '1' => array('bar' => array('foo' => 'bar'))), - '[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']' => array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%',), true, '@service_container',), + '[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']' => array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container'), ); } @@ -276,7 +276,7 @@ protected function getTestsForDump() '[foo, { bar: foo, foo: [foo, { bar: foo }] }, [foo, { bar: foo }]]' => array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo'))), - '[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']' => array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%',), true, '@service_container',), + '[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']' => array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container'), ); } } diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 01c7b5399511f..e5492f846f8a5 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -405,7 +405,7 @@ public function testBlockLiteralWithLeadingNewlines() EOF; $expected = array( - 'foo' => "\n\nbar" + 'foo' => "\n\nbar", ); $this->assertSame($expected, $this->parser->parse($yaml)); @@ -449,7 +449,7 @@ public function testNonUtf8Exception() $yamls = array( iconv("UTF-8", "ISO-8859-1", "foo: 'äöüß'"), iconv("UTF-8", "ISO-8859-15", "euro: '€'"), - iconv("UTF-8", "CP1252", "cp1252: '©ÉÇáñ'") + iconv("UTF-8", "CP1252", "cp1252: '©ÉÇáñ'"), ); foreach ($yamls as $yaml) { @@ -458,7 +458,7 @@ public function testNonUtf8Exception() $this->fail('charsets other than UTF-8 are rejected.'); } catch (\Exception $e) { - $this->assertInstanceOf('Symfony\Component\Yaml\Exception\ParseException', $e, 'charsets other than UTF-8 are rejected.'); + $this->assertInstanceOf('Symfony\Component\Yaml\Exception\ParseException', $e, 'charsets other than UTF-8 are rejected.'); } } } diff --git a/src/Symfony/Component/Yaml/Unescaper.php b/src/Symfony/Component/Yaml/Unescaper.php index b47d4a59285b9..50b1018c404c1 100644 --- a/src/Symfony/Component/Yaml/Unescaper.php +++ b/src/Symfony/Component/Yaml/Unescaper.php @@ -130,12 +130,12 @@ private static function utf8chr($c) return chr($c); } if (0x800 > $c) { - return chr(0xC0 | $c>>6).chr(0x80 | $c & 0x3F); + return chr(0xC0 | $c >> 6).chr(0x80 | $c & 0x3F); } if (0x10000 > $c) { - return chr(0xE0 | $c>>12).chr(0x80 | $c>>6 & 0x3F).chr(0x80 | $c & 0x3F); + return chr(0xE0 | $c >> 12).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F); } - return chr(0xF0 | $c>>18).chr(0x80 | $c>>12 & 0x3F).chr(0x80 | $c>>6 & 0x3F).chr(0x80 | $c & 0x3F); + return chr(0xF0 | $c >> 18).chr(0x80 | $c >> 12 & 0x3F).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F); } } From b63926b24666798e8e20030b7c4f9b29ae7b7f09 Mon Sep 17 00:00:00 2001 From: Daniel Beyer Date: Sat, 20 Sep 2014 16:09:40 +0200 Subject: [PATCH 1298/1305] [Finder] Escape location for regex searches --- .../Finder/Adapter/AbstractFindAdapter.php | 4 +-- .../Component/Finder/Tests/FinderTest.php | 26 ++++++++++++++----- .../Fixtures/r+e.g?e*x[c]a(r)s/dir/bar.dat | 0 3 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 src/Symfony/Component/Finder/Tests/Fixtures/r+e.g?e*x[c]a(r)s/dir/bar.dat diff --git a/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php b/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php index 7f2a52fbcd810..4d73b32c34d20 100644 --- a/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php +++ b/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php @@ -216,7 +216,7 @@ private function buildPathsFiltering(Command $command, $dir, array $paths, $not // Fixes 'not search' regex problems. if ($expr->isRegex()) { $regex = $expr->getRegex(); - $regex->prepend($regex->hasStartFlag() ? $dir.DIRECTORY_SEPARATOR : '.*')->setEndJoker(!$regex->hasEndFlag()); + $regex->prepend($regex->hasStartFlag() ? preg_quote($dir).DIRECTORY_SEPARATOR : '.*')->setEndJoker(!$regex->hasEndFlag()); } else { $expr->prepend('*')->append('*'); } @@ -247,7 +247,7 @@ private function buildSizesFiltering(Command $command, array $sizes) $command->add('-size -'.($size->getTarget() + 1).'c'); break; case '>=': - $command->add('-size +'. ($size->getTarget() - 1).'c'); + $command->add('-size +'.($size->getTarget() - 1).'c'); break; case '>': $command->add('-size +'.$size->getTarget().'c'); diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index 598821d24f521..924c67bd897c0 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -569,6 +569,20 @@ public function testIteratorKeys(Adapter\AdapterInterface $adapter) } } + /** + * @dataProvider getAdaptersTestData + */ + public function testRegexSpecialCharsLocationWithPathRestrictionContainingStartFlag(Adapter\AdapterInterface $adapter) + { + $finder = $this->buildFinder($adapter); + $finder->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'r+e.g?e*x[c]a(r)s') + ->path('/^dir/'); + + $expected = array('r+e.g?e*x[c]a(r)s'.DIRECTORY_SEPARATOR.'dir', + 'r+e.g?e*x[c]a(r)s'.DIRECTORY_SEPARATOR.'dir'.DIRECTORY_SEPARATOR.'bar.dat',); + $this->assertIterator($this->toAbsoluteFixtures($expected), $finder); + } + public function testAdaptersOrdering() { $finder = Finder::create() @@ -673,7 +687,7 @@ public function getTestPathData() $tests = array( array('', '', array()), array('/^A\/B\/C/', '/C$/', - array('A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat') + array('A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat'), ), array('/^A\/B/', 'foobar', array( @@ -681,7 +695,7 @@ public function getTestPathData() 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C', 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'ab.dat', 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat', - ) + ), ), array('A/B/C', 'foobar', array( @@ -689,7 +703,7 @@ public function getTestPathData() 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat', 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C', 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat.copy', - ) + ), ), array('A/B', 'foobar', array( @@ -703,12 +717,12 @@ public function getTestPathData() 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat', 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'ab.dat.copy', 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat.copy', - ) + ), ), array('/^with space\//', 'foobar', array( 'with space'.DIRECTORY_SEPARATOR.'foo.txt', - ) + ), ), ); @@ -808,7 +822,7 @@ private function getValidAdapters() array( new Adapter\BsdFindAdapter(), new Adapter\GnuFindAdapter(), - new Adapter\PhpAdapter() + new Adapter\PhpAdapter(), ), function (Adapter\AdapterInterface $adapter) { return $adapter->isSupported(); diff --git a/src/Symfony/Component/Finder/Tests/Fixtures/r+e.g?e*x[c]a(r)s/dir/bar.dat b/src/Symfony/Component/Finder/Tests/Fixtures/r+e.g?e*x[c]a(r)s/dir/bar.dat new file mode 100644 index 0000000000000..e69de29bb2d1d From 37dc57bda25029d96d1c01a76998dd5822a3fba8 Mon Sep 17 00:00:00 2001 From: znerol Date: Mon, 22 Sep 2014 15:00:09 +0200 Subject: [PATCH 1299/1305] Fix @return docs on HttpCache::restoreResponseBody() --- src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index e16ee6f311f18..ee5f8d41881c3 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -601,8 +601,6 @@ protected function store(Request $request, Response $response) * * @param Request $request A Request instance * @param Response $response A Response instance - * - * @return Response A Response instance */ private function restoreResponseBody(Request $request, Response $response) { From 3b02af9f7985c745927366aadd5b1d2770153172 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Sun, 6 Jul 2014 16:36:42 +0200 Subject: [PATCH 1300/1305] [2.3] Add missing development dependencies --- .travis.yml | 14 +++++++++++--- src/Symfony/Bridge/Doctrine/composer.json | 2 +- src/Symfony/Bridge/ProxyManager/composer.json | 3 +++ src/Symfony/Bundle/FrameworkBundle/composer.json | 8 ++++++-- src/Symfony/Bundle/SecurityBundle/composer.json | 3 +++ .../Tests/Controller/ProfilerControllerTest.php | 3 +-- src/Symfony/Bundle/WebProfilerBundle/composer.json | 1 + src/Symfony/Component/Form/composer.json | 3 ++- src/Symfony/Component/Routing/composer.json | 1 + src/Symfony/Component/Translation/composer.json | 1 + 10 files changed, 30 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 14c7704c4c7bf..cecdc9500c054 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,9 +11,16 @@ php: matrix: allow_failures: - php: hhvm-nightly + include: + - php: 5.5 + env: components=yes services: mongodb +env: + global: + - components=no + before_install: - travis_retry sudo apt-get install parallel - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then echo "" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini; fi;' @@ -25,8 +32,9 @@ before_install: # - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "5.3.3" ]; then phpunit --self-update; fi;' install: - - COMPOSER_ROOT_VERSION=dev-master composer --prefer-source install + - sh -c 'if [ "$components" = "no" ]; then sh -c "COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev install"; fi;' script: - - ls -d src/Symfony/*/* | parallel --gnu --keep-order 'echo "Running {} tests"; phpunit --exclude-group tty,benchmark {};' - - echo "Running tests requiring tty"; phpunit --group tty + - sh -c 'if [ "$components" = "no" ]; then sh -c "ls -d src/Symfony/*/* | parallel --gnu --keep-order '\''echo \"Running {} tests\"; phpunit --exclude-group tty,benchmark {};'\''"; fi;' + - sh -c 'if [ "$components" = "no" ]; then sh -c "echo "\""Running tests requiring tty"\""; phpunit --group tty"; fi;' + - sh -c 'if [ "$components" = "yes" ]; then sh -c "find src/Symfony -mindepth 3 -type f -name '\''phpunit.xml.dist'\'' | sed '\''s#\(.*\)/.*#\1#'\'' | parallel --gnu --keep-order '\''echo \"Running {} tests\"; cd {}; COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev install; phpunit --exclude-group tty,benchmark;'\''"; fi;' diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json index e657db70d1bba..30f4586427530 100644 --- a/src/Symfony/Bridge/Doctrine/composer.json +++ b/src/Symfony/Bridge/Doctrine/composer.json @@ -25,7 +25,7 @@ "symfony/form": "~2.2", "symfony/http-kernel": "~2.2", "symfony/security": "~2.2", - "symfony/validator": "~2.2", + "symfony/validator": "~2.3.0", "doctrine/data-fixtures": "1.0.*", "doctrine/dbal": "~2.2", "doctrine/orm": "~2.2,>=2.2.3" diff --git a/src/Symfony/Bridge/ProxyManager/composer.json b/src/Symfony/Bridge/ProxyManager/composer.json index 4d3abb604815e..c4a59154ce97c 100644 --- a/src/Symfony/Bridge/ProxyManager/composer.json +++ b/src/Symfony/Bridge/ProxyManager/composer.json @@ -20,6 +20,9 @@ "symfony/dependency-injection": "~2.3", "ocramius/proxy-manager": ">=0.3.1,<0.4-dev" }, + "require-dev": { + "symfony/config": "2.3" + }, "autoload": { "psr-0": { "Symfony\\Bridge\\ProxyManager\\": "" diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index daa1eee38b641..8fc450f7daece 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -29,11 +29,15 @@ "doctrine/common": "~2.2" }, "require-dev": { + "symfony/browser-kit": "~2.3", + "symfony/console": "~2.0", "symfony/finder": "~2.0", "symfony/security": "~2.3", - "symfony/form": "~2.3", + "symfony/form": "~2.3.0", "symfony/class-loader": "~2.1", - "symfony/validator": "~2.1" + "symfony/process": "~2.0", + "symfony/validator": "~2.1", + "symfony/yaml": "~2.0" }, "suggest": { "symfony/console": "", diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json index 776f590bc87c1..a41dff51c1525 100644 --- a/src/Symfony/Bundle/SecurityBundle/composer.json +++ b/src/Symfony/Bundle/SecurityBundle/composer.json @@ -21,9 +21,12 @@ "symfony/http-kernel": "~2.2" }, "require-dev": { + "symfony/browser-kit": "~2.3", + "symfony/form": "~2.3", "symfony/framework-bundle": "~2.2", "symfony/twig-bundle": "~2.2", "symfony/form": "~2.1", + "symfony/process": "~2.0", "symfony/validator": "~2.2", "symfony/yaml": "~2.0" }, diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php index bff1919aa9b1a..c10449d323ce7 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php @@ -11,12 +11,11 @@ namespace Symfony\Bundle\WebProfilerBundle\Tests\Controller; -use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Bundle\WebProfilerBundle\Controller\ProfilerController; use Symfony\Component\HttpKernel\Profiler\Profile; use Symfony\Component\HttpFoundation\Request; -class ProfilerControllerTest extends TestCase +class ProfilerControllerTest extends \PHPUnit_Framework_TestCase { /** * @dataProvider getEmptyTokenCases diff --git a/src/Symfony/Bundle/WebProfilerBundle/composer.json b/src/Symfony/Bundle/WebProfilerBundle/composer.json index c3f20e87e7943..e384965bf418e 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/composer.json +++ b/src/Symfony/Bundle/WebProfilerBundle/composer.json @@ -23,6 +23,7 @@ }, "require-dev": { "symfony/config": "~2.2", + "symfony/console": "~2.3", "symfony/dependency-injection": "~2.0", "symfony/stopwatch": "~2.2" }, diff --git a/src/Symfony/Component/Form/composer.json b/src/Symfony/Component/Form/composer.json index 14f9dadce40a2..f55a042086369 100644 --- a/src/Symfony/Component/Form/composer.json +++ b/src/Symfony/Component/Form/composer.json @@ -23,7 +23,8 @@ "symfony/property-access": "~2.3" }, "require-dev": { - "symfony/validator": "~2.2", + "doctrine/collections": "~1.0", + "symfony/validator": "~2.3.0", "symfony/http-foundation": "~2.2" }, "suggest": { diff --git a/src/Symfony/Component/Routing/composer.json b/src/Symfony/Component/Routing/composer.json index 9a737c6b0287b..18c06d3501f38 100644 --- a/src/Symfony/Component/Routing/composer.json +++ b/src/Symfony/Component/Routing/composer.json @@ -20,6 +20,7 @@ }, "require-dev": { "symfony/config": "~2.2", + "symfony/http-foundation": "~2.3", "symfony/yaml": "~2.0", "doctrine/common": "~2.2", "psr/log": "~1.0" diff --git a/src/Symfony/Component/Translation/composer.json b/src/Symfony/Component/Translation/composer.json index 96a8e662a8ad7..e65668b43fa33 100644 --- a/src/Symfony/Component/Translation/composer.json +++ b/src/Symfony/Component/Translation/composer.json @@ -20,6 +20,7 @@ }, "require-dev": { "symfony/config": "~2.0", + "symfony/intl": "~2.3", "symfony/yaml": "~2.2" }, "suggest": { From fab61effafe71a08cfa25f60bd350a217253f68e Mon Sep 17 00:00:00 2001 From: Andrej Hudec Date: Thu, 11 Sep 2014 22:00:09 +0200 Subject: [PATCH 1301/1305] [Translation] [Config] Clear libxml errors after parsing XML file --- .../Component/Config/Tests/Util/XmlUtilsTest.php | 10 ++++++++++ src/Symfony/Component/Config/Util/XmlUtils.php | 7 ++++--- .../Translation/Loader/XliffFileLoader.php | 3 ++- .../Tests/Loader/XliffFileLoaderTest.php | 16 ++++++++++++++++ 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php index d10863a92254c..900e6b0f7542a 100644 --- a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php +++ b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php @@ -58,6 +58,16 @@ public function testLoadFile() } $this->assertInstanceOf('DOMDocument', XmlUtils::loadFile($fixtures.'valid.xml', array($mock, 'validate'))); + $this->assertSame(array(), libxml_get_errors()); + } + + public function testLoadFileWithInternalErrorsEnabled() + { + libxml_use_internal_errors(true); + + $this->assertSame(array(), libxml_get_errors()); + $this->assertInstanceOf('DOMDocument', XmlUtils::loadFile(__DIR__.'/../Fixtures/Util/invalid_schema.xml')); + $this->assertSame(array(), libxml_get_errors()); } /** diff --git a/src/Symfony/Component/Config/Util/XmlUtils.php b/src/Symfony/Component/Config/Util/XmlUtils.php index b120fdf18875f..01234171765fd 100644 --- a/src/Symfony/Component/Config/Util/XmlUtils.php +++ b/src/Symfony/Component/Config/Util/XmlUtils.php @@ -31,7 +31,7 @@ private function __construct() /** * Loads an XML file. * - * @param string $file An XML file path + * @param string $file An XML file path * @param string|callable $schemaOrCallable An XSD schema file path or callable * * @return \DOMDocument @@ -95,10 +95,11 @@ public static function loadFile($file, $schemaOrCallable = null) } throw new \InvalidArgumentException(implode("\n", $messages), 0, $e); } - - libxml_use_internal_errors($internalErrors); } + libxml_clear_errors(); + libxml_use_internal_errors($internalErrors); + return $dom; } diff --git a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php index a86b02c2ee3b3..c9fa2a95b5823 100644 --- a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php @@ -116,6 +116,7 @@ private function parseFile($file) $dom->normalizeDocument(); + libxml_clear_errors(); libxml_use_internal_errors($internalErrors); return array(simplexml_import_dom($dom), strtoupper($dom->encoding)); @@ -124,7 +125,7 @@ private function parseFile($file) /** * Returns the XML errors of the internal XML parser * - * @param bool $internalErrors + * @param bool $internalErrors * * @return array An array of errors */ diff --git a/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php index 020a8721f18ee..50865c24524ae 100644 --- a/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php +++ b/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php @@ -31,6 +31,22 @@ public function testLoad() $this->assertEquals('en', $catalogue->getLocale()); $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources()); + $this->assertSame(array(), libxml_get_errors()); + } + + public function testLoadWithInternalErrorsEnabled() + { + libxml_use_internal_errors(true); + + $this->assertSame(array(), libxml_get_errors()); + + $loader = new XliffFileLoader(); + $resource = __DIR__.'/../fixtures/resources.xlf'; + $catalogue = $loader->load($resource, 'en', 'domain1'); + + $this->assertEquals('en', $catalogue->getLocale()); + $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources()); + $this->assertSame(array(), libxml_get_errors()); } public function testLoadWithResname() From 5fbb278b7a3aa882b8490fed752928e7d5cac1f7 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 23 Sep 2014 03:52:24 +0000 Subject: [PATCH 1302/1305] Avoid question mark and asterisk in folder names to prevent windows filesystem issues. A previous commit introduced a folder with a question mark and an asterisk which are invalid NTFS folder name characters and prevented checkout on those systems. --- src/Symfony/Component/Finder/Tests/FinderTest.php | 6 +++--- .../{r+e.g?e*x[c]a(r)s => r+e.gex[c]a(r)s}/dir/bar.dat | 0 2 files changed, 3 insertions(+), 3 deletions(-) rename src/Symfony/Component/Finder/Tests/Fixtures/{r+e.g?e*x[c]a(r)s => r+e.gex[c]a(r)s}/dir/bar.dat (100%) diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index 924c67bd897c0..72679c6b9b8a6 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -575,11 +575,11 @@ public function testIteratorKeys(Adapter\AdapterInterface $adapter) public function testRegexSpecialCharsLocationWithPathRestrictionContainingStartFlag(Adapter\AdapterInterface $adapter) { $finder = $this->buildFinder($adapter); - $finder->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'r+e.g?e*x[c]a(r)s') + $finder->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'r+e.gex[c]a(r)s') ->path('/^dir/'); - $expected = array('r+e.g?e*x[c]a(r)s'.DIRECTORY_SEPARATOR.'dir', - 'r+e.g?e*x[c]a(r)s'.DIRECTORY_SEPARATOR.'dir'.DIRECTORY_SEPARATOR.'bar.dat',); + $expected = array('r+e.gex[c]a(r)s'.DIRECTORY_SEPARATOR.'dir', + 'r+e.gex[c]a(r)s'.DIRECTORY_SEPARATOR.'dir'.DIRECTORY_SEPARATOR.'bar.dat',); $this->assertIterator($this->toAbsoluteFixtures($expected), $finder); } diff --git a/src/Symfony/Component/Finder/Tests/Fixtures/r+e.g?e*x[c]a(r)s/dir/bar.dat b/src/Symfony/Component/Finder/Tests/Fixtures/r+e.gex[c]a(r)s/dir/bar.dat similarity index 100% rename from src/Symfony/Component/Finder/Tests/Fixtures/r+e.g?e*x[c]a(r)s/dir/bar.dat rename to src/Symfony/Component/Finder/Tests/Fixtures/r+e.gex[c]a(r)s/dir/bar.dat From 36998bb629cce171d1f210badf4ef4848f9d9488 Mon Sep 17 00:00:00 2001 From: Yevgen Kovalienia Date: Tue, 23 Sep 2014 00:14:46 +0200 Subject: [PATCH 1303/1305] typo fixed in AbstractProcessTest (getoutput() => getOutput()) --- src/Symfony/Component/Process/Tests/AbstractProcessTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index 42435af88629f..5689d34067afc 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -705,7 +705,7 @@ public function testSignal() usleep(500000); $process->signal(SIGUSR1); - while ($process->isRunning() && false === strpos($process->getoutput(), 'Caught SIGUSR1')) { + while ($process->isRunning() && false === strpos($process->getOutput(), 'Caught SIGUSR1')) { usleep(10000); } From 42ec76e9d022788817fafeae0dbf94fe2281656a Mon Sep 17 00:00:00 2001 From: Sergey Kolodyazhnyy Date: Wed, 18 Jun 2014 22:51:10 +0200 Subject: [PATCH 1304/1305] Response::isNotModified returns true when If-Modified-Since is later than Last-Modified --- .../Component/HttpFoundation/Response.php | 14 ++- .../HttpFoundation/Tests/ResponseTest.php | 96 +++++++++++++++++++ 2 files changed, 105 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index 44d87d3007cb0..cffe28f07e498 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -1033,12 +1033,16 @@ public function isNotModified(Request $request) return false; } - $lastModified = $request->headers->get('If-Modified-Since'); - $notModified = false; + $notModified = false; + $lastModified = $this->headers->get('Last-Modified'); + $modifiedSince = $request->headers->get('If-Modified-Since'); + if ($etags = $request->getEtags()) { - $notModified = (in_array($this->getEtag(), $etags) || in_array('*', $etags)) && (!$lastModified || $this->headers->get('Last-Modified') == $lastModified); - } elseif ($lastModified) { - $notModified = $lastModified == $this->headers->get('Last-Modified'); + $notModified = in_array($this->getEtag(), $etags) || in_array('*', $etags); + } + + if ($modifiedSince && $lastModified) { + $notModified = strtotime($modifiedSince) >= strtotime($lastModified) && (!$etags || $notModified); } if ($notModified) { diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index b76179aae079a..35ca767795858 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -118,6 +118,102 @@ public function testIsNotModified() $this->assertFalse($modified); } + public function testIsNotModifiedNotSafe() + { + $request = Request::create('/homepage', 'POST'); + + $response = new Response(); + $this->assertFalse($response->isNotModified($request)); + } + + public function testIsNotModifiedLastModified() + { + $before = 'Sun, 25 Aug 2013 18:32:31 GMT'; + $modified = 'Sun, 25 Aug 2013 18:33:31 GMT'; + $after = 'Sun, 25 Aug 2013 19:33:31 GMT'; + + $request = new Request(); + $request->headers->set('If-Modified-Since', $modified); + + $response = new Response(); + + $response->headers->set('Last-Modified', $modified); + $this->assertTrue($response->isNotModified($request)); + + $response->headers->set('Last-Modified', $before); + $this->assertTrue($response->isNotModified($request)); + + $response->headers->set('Last-Modified', $after); + $this->assertFalse($response->isNotModified($request)); + + $response->headers->set('Last-Modified', ''); + $this->assertFalse($response->isNotModified($request)); + } + + public function testIsNotModifiedEtag() + { + $etagOne = 'randomly_generated_etag'; + $etagTwo = 'randomly_generated_etag_2'; + + $request = new Request(); + $request->headers->set('if_none_match', sprintf('%s, %s, %s', $etagOne, $etagTwo, 'etagThree')); + + $response = new Response(); + + $response->headers->set('ETag', $etagOne); + $this->assertTrue($response->isNotModified($request)); + + $response->headers->set('ETag', $etagTwo); + $this->assertTrue($response->isNotModified($request)); + + $response->headers->set('ETag', ''); + $this->assertFalse($response->isNotModified($request)); + } + + public function testIsNotModifiedLastModifiedAndEtag() + { + $before = 'Sun, 25 Aug 2013 18:32:31 GMT'; + $modified = 'Sun, 25 Aug 2013 18:33:31 GMT'; + $after = 'Sun, 25 Aug 2013 19:33:31 GMT'; + $etag = 'randomly_generated_etag'; + + $request = new Request(); + $request->headers->set('if_none_match', sprintf('%s, %s', $etag, 'etagThree')); + $request->headers->set('If-Modified-Since', $modified); + + $response = new Response(); + + $response->headers->set('ETag', $etag); + $response->headers->set('Last-Modified', $after); + $this->assertFalse($response->isNotModified($request)); + + $response->headers->set('ETag', 'non-existent-etag'); + $response->headers->set('Last-Modified', $before); + $this->assertFalse($response->isNotModified($request)); + + $response->headers->set('ETag', $etag); + $response->headers->set('Last-Modified', $modified); + $this->assertTrue($response->isNotModified($request)); + } + + public function testIsNotModifiedIfModifiedSinceAndEtagWithoutLastModified() + { + $modified = 'Sun, 25 Aug 2013 18:33:31 GMT'; + $etag = 'randomly_generated_etag'; + + $request = new Request(); + $request->headers->set('if_none_match', sprintf('%s, %s', $etag, 'etagThree')); + $request->headers->set('If-Modified-Since', $modified); + + $response = new Response(); + + $response->headers->set('ETag', $etag); + $this->assertTrue($response->isNotModified($request)); + + $response->headers->set('ETag', 'non-existent-etag'); + $this->assertFalse($response->isNotModified($request)); + } + public function testIsValidateable() { $response = new Response('', 200, array('Last-Modified' => $this->createDateTimeOneHourAgo()->format(DATE_RFC2822))); From b521caf84c4db13ad24ad471f469c81c6ca1ecfe Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Wed, 27 Feb 2013 12:10:38 +0100 Subject: [PATCH 1305/1305] [Form] Fixed ValidatorTypeGuesser to guess properties without constraints not to be required --- src/Symfony/Component/Form/CHANGELOG.md | 7 +- .../Validator/ValidatorTypeGuesser.php | 6 +- .../Validator/ValidatorTypeGuesserTest.php | 104 ++++++++++++++---- 3 files changed, 93 insertions(+), 24 deletions(-) diff --git a/src/Symfony/Component/Form/CHANGELOG.md b/src/Symfony/Component/Form/CHANGELOG.md index a696c7be9a9c8..09935c748bc8b 100644 --- a/src/Symfony/Component/Form/CHANGELOG.md +++ b/src/Symfony/Component/Form/CHANGELOG.md @@ -1,9 +1,14 @@ CHANGELOG ========= +2.3.20 +------ + + * the validator guesser guesses fields for properties without any constraints + to not be required now 2.3.0 ------- +----- * deprecated FormPerformanceTestCase and FormIntegrationTestCase in the Symfony\Component\Form\Tests namespace and moved them to the Symfony\Component\Form\Test namespace * deprecated TypeTestCase in the Symfony\Component\Form\Tests\Extension\Core\Type namespace and moved it to the Symfony\Component\Form\Test namespace diff --git a/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php b/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php index 589fc12a36c8f..8884629dc91ab 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php +++ b/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php @@ -276,10 +276,10 @@ protected function guess($class, $property, \Closure $closure, $defaultValue = n } } } + } - if (null !== $defaultValue) { - $guesses[] = new ValueGuess($defaultValue, Guess::LOW_CONFIDENCE); - } + if (null !== $defaultValue) { + $guesses[] = new ValueGuess($defaultValue, Guess::LOW_CONFIDENCE); } return Guess::getBestGuess($guesses); diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php index 090abf4486e86..e2de925ad1a78 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php @@ -13,32 +13,91 @@ use Symfony\Component\Form\Extension\Validator\ValidatorTypeGuesser; use Symfony\Component\Form\Guess\Guess; +use Symfony\Component\Form\Guess\ValueGuess; +use Symfony\Component\Validator\Constraints\Email; use Symfony\Component\Validator\Constraints\Length; +use Symfony\Component\Validator\Constraints\NotBlank; +use Symfony\Component\Validator\Constraints\NotNull; +use Symfony\Component\Validator\Constraints\Range; +use Symfony\Component\Validator\Constraints\True; use Symfony\Component\Validator\Constraints\Type; +use Symfony\Component\Validator\Mapping\ClassMetadata; /** -* @author franek -*/ + * @author franek + * @author Bernhard Schussek + */ class ValidatorTypeGuesserTest extends \PHPUnit_Framework_TestCase { - private $typeGuesser; + const TEST_CLASS = 'Symfony\Component\Form\Tests\Extension\Validator\ValidatorTypeGuesserTest_TestClass'; + + const TEST_PROPERTY = 'property'; + + /** + * @var ValidatorTypeGuesser + */ + private $guesser; + + /** + * @var ClassMetadata + */ + private $metadata; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $metadataFactory; - public function setUp() + protected function setUp() { if (!class_exists('Symfony\Component\Validator\Constraint')) { $this->markTestSkipped('The "Validator" component is not available'); } - $metadataFactory = $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface'); + $this->metadata = new ClassMetadata(self::TEST_CLASS); + $this->metadataFactory = $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface'); + $this->metadataFactory->expects($this->any()) + ->method('getMetadataFor') + ->with(self::TEST_CLASS) + ->will($this->returnValue($this->metadata)); + $this->guesser = new ValidatorTypeGuesser($this->metadataFactory); + } + + public function guessRequiredProvider() + { + return array( + array(new NotNull(), new ValueGuess(true, Guess::HIGH_CONFIDENCE)), + array(new NotBlank(), new ValueGuess(true, Guess::HIGH_CONFIDENCE)), + array(new True(), new ValueGuess(true, Guess::HIGH_CONFIDENCE)), + array(new Length(10), new ValueGuess(false, Guess::LOW_CONFIDENCE)), + array(new Range(array('min' => 1, 'max' => 20)), new ValueGuess(false, Guess::LOW_CONFIDENCE)), + ); + } + + /** + * @dataProvider guessRequiredProvider + */ + public function testGuessRequired($constraint, $guess) + { + // add distracting constraint + $this->metadata->addPropertyConstraint(self::TEST_PROPERTY, new Email()); + + // add constraint under test + $this->metadata->addPropertyConstraint(self::TEST_PROPERTY, $constraint); - $this->typeGuesser = new ValidatorTypeGuesser($metadataFactory); + $this->assertEquals($guess, $this->guesser->guessRequired(self::TEST_CLASS, self::TEST_PROPERTY)); + } + + public function testGuessRequiredReturnsFalseForUnmappedProperties() + { + $this->assertEquals(new ValueGuess(false, Guess::LOW_CONFIDENCE), $this->guesser->guessRequired(self::TEST_CLASS, self::TEST_PROPERTY)); } public function testGuessMaxLengthForConstraintWithMaxValue() { $constraint = new Length(array('max' => '2')); - $result = $this->typeGuesser->guessMaxLengthForConstraint($constraint); + $result = $this->guesser->guessMaxLengthForConstraint($constraint); $this->assertInstanceOf('Symfony\Component\Form\Guess\ValueGuess', $result); $this->assertEquals(2, $result->getValue()); $this->assertEquals(Guess::HIGH_CONFIDENCE, $result->getConfidence()); @@ -48,30 +107,35 @@ public function testGuessMaxLengthForConstraintWithMinValue() { $constraint = new Length(array('min' => '2')); - $result = $this->typeGuesser->guessMaxLengthForConstraint($constraint); + $result = $this->guesser->guessMaxLengthForConstraint($constraint); $this->assertNull($result); } + public function maxLengthTypeProvider() + { + return array ( + array('double'), + array('float'), + array('numeric'), + array('real'), + ); + } + /** -* @dataProvider dataProviderTestGuessMaxLengthForConstraintWithType -*/ + * @dataProvider maxLengthTypeProvider + */ public function testGuessMaxLengthForConstraintWithType($type) { $constraint = new Type($type); - $result = $this->typeGuesser->guessMaxLengthForConstraint($constraint); + $result = $this->guesser->guessMaxLengthForConstraint($constraint); $this->assertInstanceOf('Symfony\Component\Form\Guess\ValueGuess', $result); $this->assertEquals(null, $result->getValue()); $this->assertEquals(Guess::MEDIUM_CONFIDENCE, $result->getConfidence()); } +} - public static function dataProviderTestGuessMaxLengthForConstraintWithType() - { - return array ( - array('double'), - array('float'), - array('numeric'), - array('real'), - ); - } +class ValidatorTypeGuesserTest_TestClass +{ + private $property; }