diff --git a/appveyor.yml b/.appveyor.yml similarity index 99% rename from appveyor.yml rename to .appveyor.yml index 55b41de6b1a10..35bef75debbb9 100644 --- a/appveyor.yml +++ b/.appveyor.yml @@ -1,5 +1,5 @@ build: false -clone_depth: 1 +clone_depth: 2 clone_folder: c:\projects\symfony cache: diff --git a/.editorconfig b/.editorconfig index 153cf3ef5bd04..d769b46a4b6ff 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,8 +3,17 @@ root = true ; Unix-style newlines [*] +charset = utf-8 end_of_line = LF +insert_final_newline = true +trim_trailing_whitespace = true -[*.php] +[*.{php,html,twig}] indent_style = space indent_size = 4 + +[*.md] +max_line_length = 80 + +[COMMIT_EDITMSG] +max_line_length = 0 diff --git a/.github/build-packages.php b/.github/build-packages.php index b67a699609d66..b09cea2fe230a 100644 --- a/.github/build-packages.php +++ b/.github/build-packages.php @@ -6,9 +6,14 @@ } chdir(dirname(__DIR__)); +$json = ltrim(file_get_contents('composer.json')); +if ($json !== $package = preg_replace('/\n "repositories": \[\n.*?\n \],/s', '', $json)) { + file_put_contents('composer.json', $package); +} + $dirs = $_SERVER['argv']; array_shift($dirs); -$mergeBase = trim(shell_exec(sprintf('git merge-base %s HEAD', array_shift($dirs)))); +$mergeBase = trim(shell_exec(sprintf('git merge-base "%s" HEAD', array_shift($dirs)))); $packages = array(); $flags = \PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE : 0; @@ -49,7 +54,7 @@ $packages[$package->name][$package->version] = $package; - $versions = file_get_contents('https://packagist.org/p/'.$package->name.'.json'); + $versions = @file_get_contents('https://repo.packagist.org/p/'.$package->name.'.json') ?: sprintf('{"packages":{"%s":{"dev-master":%s}}}', $package->name, file_get_contents($dir.'/composer.json')); $versions = json_decode($versions)->packages->{$package->name}; if ($package->version === str_replace('-dev', '.x-dev', $versions->{'dev-master'}->extra->{'branch-alias'}->{'dev-master'})) { @@ -74,8 +79,6 @@ 'type' => 'composer', 'url' => 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__)).'/', )); - if (false === strpos($json, "\n \"repositories\": [\n")) { - $json = rtrim(json_encode(array('repositories' => $package->repositories), $flags), "\n}").','.substr($json, 1); - file_put_contents('composer.json', $json); - } + $json = rtrim(json_encode(array('repositories' => $package->repositories), $flags), "\n}").','.substr($json, 1); + file_put_contents('composer.json', $json); } diff --git a/.github/rm-invalid-lowest-lock-files.php b/.github/rm-invalid-lowest-lock-files.php index c71463262171a..3105942a09030 100644 --- a/.github/rm-invalid-lowest-lock-files.php +++ b/.github/rm-invalid-lowest-lock-files.php @@ -79,7 +79,7 @@ function getContentHash(array $composerJson) continue 2; } - if (isset($composerJsons[$name][2]['repositories']) && !isset($lockedJson[$key]['repositories'])) { + if (isset($composerJsons[$name][2]['repositories']) && !isset($lockedJson['repositories'])) { // the locked package has been patched locally but the lock references a commit, // which means the referencing package itself is not modified continue; diff --git a/.travis.yml b/.travis.yml index 54b8a101f255d..776f433d5149f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ dist: trusty sudo: false git: - depth: 1 + depth: 2 addons: apt_packages: diff --git a/CHANGELOG-4.1.md b/CHANGELOG-4.1.md index 98aa4aca6a284..b8a496b945cfc 100644 --- a/CHANGELOG-4.1.md +++ b/CHANGELOG-4.1.md @@ -7,6 +7,49 @@ in 4.1 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/v4.1.0...v4.1.1 +* 4.1.5 (2018-09-30) + + * bug #28636 [HttpFoundation] X-Accel-Mapping does not use HTTP key=value syntax (c960657) + * bug #28376 [TwigBundle] Fixed caching of templates in src/Resources//views on cache warmup (yceruto) + * bug #28565 [HttpFoundation][Security] forward locale and format to subrequests (nicolas-grekas) + * bug #28561 [Cache] prevent getting older entries when the version key is evicted (nicolas-grekas) + * bug #28562 [HttpFoundation] fix hidding warnings from session handlers (nicolas-grekas) + * bug #28545 [Console] Send the right exit code to console.terminate listeners (mpdude) + * bug #28553 [Debug] Fix false-positive "MicroKernelTrait::loadRoutes()" method is considered internal" (nicolas-grekas) + * bug #28466 [Form] fail reverse transforming invalid RFC 3339 dates (xabbuh) + * bug #28540 [Intl] parse numbers terminated with decimal separator (xabbuh) + * bug #28548 [Console] Fixed boxed table style with colspan (ro0NL) + * bug #28433 [HttpFoundation] Allow reuse of Session between requests if ID did not change (tgalopin) + * bug #28508 [Form] forward false label option to nested types (xabbuh) + * bug #28471 [MonologBridge] Re-add option option to ignore empty context and extra data (mpdude) + * bug #28464 [Form] forward the invalid_message option in date types (xabbuh) + * bug #28524 [PhpUnitBridge] fix disabling DeprecationErrorHandler using phpunit.xml file (soerenbernstein) + * bug #28512 [DI] fix infinite loop involving self-references in decorated services (nicolas-grekas) + * bug #28507 [DI] fix dumping lazy services (nicolas-grekas) + * bug #28469 [Form][TwigBridge] fix not displaying labels when value is false (xabbuh) + * bug #28495 [PhpUnitBridge] Implement startTest rather than startTestSuite (greg0ire) + * bug #28480 [DI] Detect circular references with ChildDefinition parent (Seb33300) + * bug #28497 [VarDumper] Fix global dump function return value for PHP7 (patrickcarlohickman) + * bug #28499 [Ldap] Use shut up operator on connection errors at ldap_start_tls (Andras Debreczeni) + * bug #28372 [Form] Fix DateTimeType html5 input format (franzwilding, mcfedr) + * bug #28396 [Intl] Blacklist Eurozone and United Nations in Region Data Generator (gregurco) + * bug #28418 [FrameworkBundle] Register the messenger data collector only when the profiler is enabled (pierredup) + * bug #28393 [Console] fixed corrupt error output for unknown multibyte short option (downace) + * bug #28411 [Debug] fix detecting overriden final/internal methods implemented using traits (nicolas-grekas) + * bug #28404 [Controller][ServiceValueResolver] Making method access case insensitive (nicoweb) + * bug #28401 [Console] Fix SymfonyQuestionHelper::askQuestion() with choice value as default (chalasr) + * bug #28388 [DI] configure inlined services before injecting them when dumping the container (nicolas-grekas) + * bug #28377 fix fopen flags (SpacePossum) + * bug #27764 [TwigBundle] Fixed caching of templates in default path on cache warmup (yceruto) + * bug #28366 [DI] Fix dumping some complex service graphs (nicolas-grekas) + * bug #27970 [FileValidator] Format file size in validation message according to binaryFormat option (jfredon) + * bug #28029 [TwigBundle] remove cache warmers when Twig cache is disabled (xabbuh) + * bug #28322 [Workflow] Make sure we do not run the next transition on an updated state (Nyholm) + * bug #28344 [HttpKernel][FrameworkBundle] Fix escaping of serialized payloads passed to test clients (nicolas-grekas) + * bug #28183 [WebProfilerBundle] fix wrong url when base path is the index (ismail1432) + * bug #28334 [FWB][Messenger] Revert "Move commands-specifics to a compiler pass in FWB" (sroze) + * bug #28328 [Messenger][FrameworkBundle] Move commands-specifics to a compiler pass in FWB (sroze) + * 4.1.4 (2018-08-28) * bug #28278 [HttpFoundation] Fix unprepared BinaryFileResponse sends empty file (wackymole) diff --git a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php index 59cdc3b418eba..f521dcbd3fb18 100644 --- a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php +++ b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php @@ -202,11 +202,7 @@ public function configureOptions(OptionsResolver $resolver) $em = $this->registry->getManagerForClass($options['class']); if (null === $em) { - throw new RuntimeException(sprintf( - 'Class "%s" seems not to be a managed Doctrine entity. '. - 'Did you forget to map it?', - $options['class'] - )); + throw new RuntimeException(sprintf('Class "%s" seems not to be a managed Doctrine entity. Did you forget to map it?', $options['class'])); } return $em; diff --git a/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php b/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php index e0dcaae6c2f6d..c3b7588e95049 100644 --- a/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php +++ b/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php @@ -27,13 +27,14 @@ * and to do the conversion of the datetime column. * * In order to use this class, you need the following table in your database: - * CREATE TABLE `rememberme_token` ( - * `series` char(88) UNIQUE PRIMARY KEY NOT NULL, - * `value` char(88) NOT NULL, - * `lastUsed` datetime NOT NULL, - * `class` varchar(100) NOT NULL, - * `username` varchar(200) NOT NULL - * ); + * + * CREATE TABLE `rememberme_token` ( + * `series` char(88) UNIQUE PRIMARY KEY NOT NULL, + * `value` char(88) NOT NULL, + * `lastUsed` datetime NOT NULL, + * `class` varchar(100) NOT NULL, + * `username` varchar(200) NOT NULL + * ); */ class DoctrineTokenProvider implements TokenProviderInterface { diff --git a/src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php b/src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php index 07c4a7cba40f4..feb735e8ac740 100644 --- a/src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php +++ b/src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php @@ -61,6 +61,7 @@ public function __construct(array $options = array()) 'colors' => true, 'multiline' => false, 'level_name_format' => '%-9s', + 'ignore_empty_context_and_extra' => true, ), $options); if (class_exists(VarCloner::class)) { @@ -101,20 +102,16 @@ public function format(array $record) $levelColor = self::$levelColorMap[$record['level']]; - if ($this->options['multiline']) { - $separator = "\n"; + if (!$this->options['ignore_empty_context_and_extra'] || !empty($record['context'])) { + $context = ($this->options['multiline'] ? "\n" : ' ').$this->dumpData($record['context']); } else { - $separator = ' '; - } - - $context = $this->dumpData($record['context']); - if ($context) { - $context = $separator.$context; + $context = ''; } - $extra = $this->dumpData($record['extra']); - if ($extra) { - $extra = $separator.$extra; + if (!$this->options['ignore_empty_context_and_extra'] || !empty($record['extra'])) { + $extra = ($this->options['multiline'] ? "\n" : ' ').$this->dumpData($record['extra']); + } else { + $extra = ''; } $formatted = strtr($this->options['format'], array( diff --git a/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php b/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php index 92b319f13a989..0764f89151f10 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php @@ -64,9 +64,9 @@ public function testVerbosityMapping($verbosity, $level, $isHandling, array $map $realOutput = $this->getMockBuilder('Symfony\Component\Console\Output\Output')->setMethods(array('doWrite'))->getMock(); $realOutput->setVerbosity($verbosity); if ($realOutput->isDebug()) { - $log = "16:21:54 $levelName [app] My info message\n[]\n[]\n"; + $log = "16:21:54 $levelName [app] My info message\n"; } else { - $log = "16:21:54 $levelName [app] My info message [] []\n"; + $log = "16:21:54 $levelName [app] My info message\n"; } $realOutput ->expects($isHandling ? $this->once() : $this->never()) @@ -149,7 +149,7 @@ public function testWritingAndFormatting() $output ->expects($this->once()) ->method('write') - ->with("16:21:54 INFO [app] My info message\n[]\n[]\n") + ->with("16:21:54 INFO [app] My info message\n") ; $handler = new ConsoleHandler(null, false); diff --git a/src/Symfony/Bridge/Monolog/composer.json b/src/Symfony/Bridge/Monolog/composer.json index a4d3e984100c9..3a9be518f95d7 100644 --- a/src/Symfony/Bridge/Monolog/composer.json +++ b/src/Symfony/Bridge/Monolog/composer.json @@ -27,11 +27,12 @@ "symfony/var-dumper": "~3.4|~4.0" }, "conflict": { + "symfony/console": "<3.4", "symfony/http-foundation": "<3.4" }, "suggest": { "symfony/http-kernel": "For using the debugging handlers together with the response life cycle of the HTTP kernel.", - "symfony/console": "For the possibility to show log messages in console commands depending on verbosity settings. You need version ~2.3 of the console for it.", + "symfony/console": "For the possibility to show log messages in console commands depending on verbosity settings.", "symfony/event-dispatcher": "Needed when using log messages in console commands.", "symfony/var-dumper": "For using the debugging handlers like the console handler or the log server handler." }, diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index 7086c834b1845..dd396eeee407d 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -54,7 +54,11 @@ public static function register($mode = 0) if (false === $mode) { $mode = getenv('SYMFONY_DEPRECATIONS_HELPER'); } - if (DeprecationErrorHandler::MODE_WEAK !== $mode && DeprecationErrorHandler::MODE_WEAK_VENDORS !== $mode && (!isset($mode[0]) || '/' !== $mode[0])) { + if (DeprecationErrorHandler::MODE_DISABLED !== $mode + && DeprecationErrorHandler::MODE_WEAK !== $mode + && DeprecationErrorHandler::MODE_WEAK_VENDORS !== $mode + && (!isset($mode[0]) || '/' !== $mode[0]) + ) { $mode = preg_match('/^[1-9][0-9]*$/', $mode) ? (int) $mode : 0; } @@ -108,7 +112,7 @@ public static function register($mode = 0) return $ErrorHandler::handleError($type, $msg, $file, $line, $context); } - $trace = debug_backtrace(true); + $trace = debug_backtrace(); $group = 'other'; $isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $inVendors($file); diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV5.php b/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV5.php index 4bf19223f3c16..9d754eebc85df 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV5.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV5.php @@ -12,8 +12,8 @@ namespace Symfony\Bridge\PhpUnit\Legacy; /** - * CoverageListener adds `@covers ` on each test suite when possible - * to make the code coverage more accurate. + * CoverageListener adds `@covers ` on each test when possible to + * make the code coverage more accurate. * * @author Grégoire Pineau * diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV6.php b/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV6.php index f0dfc7577cd03..0917ea4710c21 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV6.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV6.php @@ -15,8 +15,8 @@ use PHPUnit\Framework\Test; /** - * CoverageListener adds `@covers ` on each test suite when possible - * to make the code coverage more accurate. + * CoverageListener adds `@covers ` on each test when possible to + * make the code coverage more accurate. * * @author Grégoire Pineau * diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV7.php b/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV7.php index 1d29a88441b1f..a35034c48b32b 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV7.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV7.php @@ -11,13 +11,13 @@ namespace Symfony\Bridge\PhpUnit\Legacy; +use PHPUnit\Framework\Test; use PHPUnit\Framework\TestListener; use PHPUnit\Framework\TestListenerDefaultImplementation; -use PHPUnit\Framework\TestSuite; /** - * CoverageListener adds `@covers ` on each test suite when possible - * to make the code coverage more accurate. + * CoverageListener adds `@covers ` on each test when possible to + * make the code coverage more accurate. * * @author Grégoire Pineau * @@ -34,8 +34,8 @@ public function __construct(callable $sutFqcnResolver = null, $warningOnSutNotFo $this->trait = new CoverageListenerTrait($sutFqcnResolver, $warningOnSutNotFound); } - public function startTestSuite(TestSuite $suite): void + public function startTest(Test $test): void { - $this->trait->startTest($suite); + $this->trait->startTest($test); } } diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_base_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_base_layout.html.twig index 2630803573ec7..136cabccb19ed 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_base_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_base_layout.html.twig @@ -64,11 +64,13 @@ {%- if datetime is not defined or not datetime -%}
{%- endif %} + {%- if label is not same as(false) -%}
{{ form_label(form.year) }} {{ form_label(form.month) }} {{ form_label(form.day) }}
+ {%- endif -%} {{- date_pattern|replace({ '{{ year }}': form_widget(form.year), @@ -89,10 +91,10 @@ {%- if datetime is not defined or false == datetime -%}
{%- endif -%} -
{{ form_label(form.hour) }}
+ {%- if label is not same as(false) -%}
{{ form_label(form.hour) }}
{%- endif -%} {{- form_widget(form.hour) -}} - {%- if with_minutes -%}:
{{ form_label(form.minute) }}
{{ form_widget(form.minute) }}{%- endif -%} - {%- if with_seconds -%}:
{{ form_label(form.second) }}
{{ form_widget(form.second) }}{%- endif -%} + {%- if with_minutes -%}:{%- if label is not same as(false) -%}
{{ form_label(form.minute) }}
{%- endif -%}{{ form_widget(form.minute) }}{%- endif -%} + {%- if with_seconds -%}:{%- if label is not same as(false) -%}
{{ form_label(form.second) }}
{%- endif -%}{{ form_widget(form.second) }}{%- endif -%} {%- if datetime is not defined or false == datetime -%}
{%- endif -%} diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php index ff1c221b79ff7..87d0b7677fbec 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php @@ -1577,7 +1577,7 @@ public function testDateTimeWithWidgetSingleText() [@type="datetime-local"] [@name="name"] [@class="my&class form-control"] - [@value="2011-02-03T04:05:06Z"] + [@value="2011-02-03T04:05:06"] ' ); } @@ -1598,7 +1598,7 @@ public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets() [@type="datetime-local"] [@name="name"] [@class="my&class form-control"] - [@value="2011-02-03T04:05:06Z"] + [@value="2011-02-03T04:05:06"] ' ); } diff --git a/src/Symfony/Bridge/Twig/TokenParser/DumpTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/DumpTokenParser.php index 7cdbb77b4349b..a4d7d6f690078 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/DumpTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/DumpTokenParser.php @@ -19,11 +19,10 @@ * Token Parser for the 'dump' tag. * * Dump variables with: - *
- *  {% dump %}
- *  {% dump foo %}
- *  {% dump foo, bar %}
- * 
+ * + * {% dump %} + * {% dump foo %} + * {% dump foo, bar %} * * @author Julien Galenski */ diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index 839636282c78a..0123c1d3a7ee3 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -23,7 +23,7 @@ "symfony/asset": "~3.4|~4.0", "symfony/dependency-injection": "~3.4|~4.0", "symfony/finder": "~3.4|~4.0", - "symfony/form": "^4.1.2", + "symfony/form": "^4.1.5", "symfony/http-foundation": "~3.4|~4.0", "symfony/http-kernel": "~3.4|~4.0", "symfony/polyfill-intl-icu": "~1.0", diff --git a/src/Symfony/Bundle/FrameworkBundle/Client.php b/src/Symfony/Bundle/FrameworkBundle/Client.php index 899a2f40a5145..c86a2772eb3cd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Client.php +++ b/src/Symfony/Bundle/FrameworkBundle/Client.php @@ -161,8 +161,8 @@ protected function doRequestInProcess($request) */ protected function getScript($request) { - $kernel = str_replace("'", "\\'", serialize($this->kernel)); - $request = str_replace("'", "\\'", serialize($request)); + $kernel = var_export(serialize($this->kernel), true); + $request = var_export(serialize($request), true); $errorReporting = error_reporting(); $requires = ''; @@ -171,7 +171,7 @@ protected function getScript($request) $r = new \ReflectionClass($class); $file = \dirname(\dirname($r->getFileName())).'/autoload.php'; if (file_exists($file)) { - $requires .= "require_once '".str_replace("'", "\\'", $file)."';\n"; + $requires .= 'require_once '.var_export($file, true).";\n"; } } } @@ -180,7 +180,7 @@ protected function getScript($request) throw new \RuntimeException('Composer autoloader not found.'); } - $requires .= "require_once '".str_replace("'", "\\'", (new \ReflectionObject($this->kernel))->getFileName())."';\n"; + $requires .= 'require_once '.var_export((new \ReflectionObject($this->kernel))->getFileName(), true).";\n"; $profilerCode = ''; if ($this->profiler) { @@ -194,11 +194,11 @@ protected function getScript($request) $requires -\$kernel = unserialize('$kernel'); +\$kernel = unserialize($kernel); \$kernel->boot(); $profilerCode -\$request = unserialize('$request'); +\$request = unserialize($request); EOF; return $code.$this->getHandleScript(); diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 19f62d8dc74e2..b1eb75f76cf10 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -108,6 +108,7 @@ class FrameworkExtension extends Extension private $sessionConfigEnabled = false; private $annotationsConfigEnabled = false; private $validatorConfigEnabled = false; + private $messengerConfigEnabled = false; /** * Responds to the app.config configuration parameter. @@ -269,7 +270,7 @@ public function load(array $configs, ContainerBuilder $container) $this->registerLockConfiguration($config['lock'], $container, $loader); } - if ($this->isConfigEnabled($container, $config['messenger'])) { + if ($this->messengerConfigEnabled = $this->isConfigEnabled($container, $config['messenger'])) { $this->registerMessengerConfiguration($config['messenger'], $container, $loader, $config['serializer'], $config['validation']); } else { $container->removeDefinition('console.command.messenger_consume_messages'); @@ -445,6 +446,10 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $ $container->getDefinition('translator.data_collector')->setDecoratedService('translator'); } + if ($this->messengerConfigEnabled) { + $loader->load('messenger_debug.xml'); + } + $container->setParameter('profiler_listener.only_exceptions', $config['only_exceptions']); $container->setParameter('profiler_listener.only_master_requests', $config['only_master_requests']); diff --git a/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php b/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php index 5130071bcdec1..8a4e8e45bd3fc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php @@ -39,17 +39,17 @@ abstract protected function configureRoutes(RouteCollectionBuilder $routes); * * You can register extensions: * - * $c->loadFromExtension('framework', array( - * 'secret' => '%secret%' - * )); + * $c->loadFromExtension('framework', array( + * 'secret' => '%secret%' + * )); * * Or services: * - * $c->register('halloween', 'FooBundle\HalloweenProvider'); + * $c->register('halloween', 'FooBundle\HalloweenProvider'); * * Or parameters: * - * $c->setParameter('halloween', 'lot of fun'); + * $c->setParameter('halloween', 'lot of fun'); * * @param ContainerBuilder $c * @param LoaderInterface $loader diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/messenger.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/messenger.xml index 0b09978d33870..d1fc9a80f466a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/messenger.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/messenger.xml @@ -34,17 +34,13 @@ - + - - - - diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/messenger_debug.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/messenger_debug.xml new file mode 100644 index 0000000000000..2f226222ce1ad --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/messenger_debug.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php index 29f4d1a3552d9..76c19536f5adf 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php @@ -170,14 +170,7 @@ private function resolve($value) return (string) $resolved; } - throw new RuntimeException(sprintf( - '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, - \gettype($resolved) - ) - ); + throw new RuntimeException(sprintf('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, \gettype($resolved))); }, $value); return str_replace('%%', '%', $escapedValue); diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php index 2360c602ae948..23b5c4e91e1aa 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php @@ -224,18 +224,14 @@ public function block(FormView $view, $blockName, array $variables = array()) * Use this helper for CSRF protection without the overhead of creating a * form. * - * - * echo $view['form']->csrfToken('rm_user_'.$user->getId()); - * + * echo $view['form']->csrfToken('rm_user_'.$user->getId()); * * Check the token in your action using the same CSRF token id. * - * - * // $csrfProvider being an instance of Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface - * if (!$csrfProvider->isCsrfTokenValid('rm_user_'.$user->getId(), $token)) { - * throw new \RuntimeException('CSRF attack detected.'); - * } - * + * // $csrfProvider being an instance of Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface + * if (!$csrfProvider->isCsrfTokenValid('rm_user_'.$user->getId(), $token)) { + * throw new \RuntimeException('CSRF attack detected.'); + * } * * @param string $tokenId The CSRF token id of the protected action * diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php index e62e2921a1875..b5aaa2604b24d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php @@ -23,7 +23,7 @@ abstract class WebTestCase extends KernelTestCase /** * Creates a Client. * - * @param array $options An array of options to pass to the createKernel class + * @param array $options An array of options to pass to the createKernel method * @param array $server An array of server parameters * * @return Client A Client instance diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index de0fe10f91224..2554dc58ac16c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -67,6 +67,7 @@ "symfony/asset": "<3.4", "symfony/console": "<3.4", "symfony/form": "<4.1", + "symfony/messenger": ">=4.2", "symfony/property-info": "<3.4", "symfony/serializer": "<4.1", "symfony/stopwatch": "<3.4", diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/GuardAuthenticationFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/GuardAuthenticationFactory.php index 643f5d2fc2e43..b6a92245191a8 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/GuardAuthenticationFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/GuardAuthenticationFactory.php @@ -97,10 +97,7 @@ private function determineEntryPoint($defaultEntryPointId, array $config) if ($defaultEntryPointId) { // explode if they've configured the entry_point, but there is already one if ($config['entry_point']) { - throw new \LogicException(sprintf( - 'The guard authentication provider cannot use the "%s" entry_point because another entry point is already configured by another provider! Either remove the other provider or move the entry_point configuration as a root key under your firewall (i.e. at the same level as "guard").', - $config['entry_point'] - )); + throw new \LogicException(sprintf('The guard authentication provider cannot use the "%s" entry_point because another entry point is already configured by another provider! Either remove the other provider or move the entry_point configuration as a root key under your firewall (i.e. at the same level as "guard").', $config['entry_point'])); } return $defaultEntryPointId; @@ -118,9 +115,6 @@ private function determineEntryPoint($defaultEntryPointId, array $config) } // we have multiple entry points - we must ask them to configure one - throw new \LogicException(sprintf( - 'Because you have multiple guard configurators, you need to set the "guard.entry_point" key to one of your configurators (%s)', - implode(', ', $authenticatorIds) - )); + throw new \LogicException(sprintf('Because you have multiple guard configurators, you need to set the "guard.entry_point" key to one of your configurators (%s)', implode(', ', $authenticatorIds))); } } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php index f44a25d0fb496..1bfa7fa357bf4 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php @@ -159,8 +159,8 @@ public function testFirewalls() null, null, array( - 'simple_form', - 'anonymous', + 'simple_form', + 'anonymous', ), null, ), diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php index 5a107a07c598a..0292f6f6a4056 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php @@ -47,10 +47,15 @@ public function process(ContainerBuilder $container) $coreThemePath = \dirname(\dirname($reflClass->getFileName())).'/Resources/views/Form'; $container->getDefinition('twig.loader.native_filesystem')->addMethodCall('addPath', array($coreThemePath)); - $paths = $container->getDefinition('twig.cache_warmer')->getArgument(2); + $paths = $container->getDefinition('twig.template_iterator')->getArgument(2); $paths[$coreThemePath] = null; - $container->getDefinition('twig.cache_warmer')->replaceArgument(2, $paths); $container->getDefinition('twig.template_iterator')->replaceArgument(2, $paths); + + if ($container->hasDefinition('twig.cache_warmer')) { + $paths = $container->getDefinition('twig.cache_warmer')->getArgument(2); + $paths[$coreThemePath] = null; + $container->getDefinition('twig.cache_warmer')->replaceArgument(2, $paths); + } } if ($container->has('router')) { diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php index d3a24dfa479a3..a5e87cf61f3ad 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php @@ -147,6 +147,11 @@ public function load(array $configs, ContainerBuilder $container) $container->registerForAutoconfiguration(ExtensionInterface::class)->addTag('twig.extension'); $container->registerForAutoconfiguration(LoaderInterface::class)->addTag('twig.loader'); $container->registerForAutoconfiguration(RuntimeExtensionInterface::class)->addTag('twig.runtime'); + + if (false === $config['cache']) { + $container->removeDefinition('twig.cache_warmer'); + $container->removeDefinition('twig.template_cache_warmer'); + } } private function getBundleTemplatePaths(ContainerBuilder $container, array $config) diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml index 5d014e930c53e..3fa98b8bef936 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml @@ -41,6 +41,7 @@ %kernel.root_dir% + %twig.default_path% diff --git a/src/Symfony/Bundle/TwigBundle/TemplateIterator.php b/src/Symfony/Bundle/TwigBundle/TemplateIterator.php index 189a2e9563c3e..1bbb4af6dcdc1 100644 --- a/src/Symfony/Bundle/TwigBundle/TemplateIterator.php +++ b/src/Symfony/Bundle/TwigBundle/TemplateIterator.php @@ -25,17 +25,20 @@ class TemplateIterator implements \IteratorAggregate private $rootDir; private $templates; private $paths; + private $defaultPath; /** - * @param KernelInterface $kernel A KernelInterface instance - * @param string $rootDir The directory where global templates can be stored - * @param array $paths Additional Twig paths to warm + * @param KernelInterface $kernel A KernelInterface instance + * @param string $rootDir The directory where global templates can be stored + * @param array $paths Additional Twig paths to warm + * @param string $defaultPath The directory where global templates can be stored */ - public function __construct(KernelInterface $kernel, string $rootDir, array $paths = array()) + public function __construct(KernelInterface $kernel, string $rootDir, array $paths = array(), string $defaultPath = null) { $this->kernel = $kernel; $this->rootDir = $rootDir; $this->paths = $paths; + $this->defaultPath = $defaultPath; } /** @@ -47,7 +50,10 @@ public function getIterator() return $this->templates; } - $this->templates = $this->findTemplatesInDirectory($this->rootDir.'/Resources/views'); + $this->templates = array_merge( + $this->findTemplatesInDirectory($this->rootDir.'/Resources/views'), + $this->findTemplatesInDirectory($this->defaultPath, null, array('bundles')) + ); foreach ($this->kernel->getBundles() as $bundle) { $name = $bundle->getName(); if ('Bundle' === substr($name, -6)) { @@ -57,7 +63,8 @@ public function getIterator() $this->templates = array_merge( $this->templates, $this->findTemplatesInDirectory($bundle->getPath().'/Resources/views', $name), - $this->findTemplatesInDirectory($this->rootDir.'/'.$bundle->getName().'/views', $name) + $this->findTemplatesInDirectory($this->rootDir.'/Resources/'.$bundle->getName().'/views', $name), + $this->findTemplatesInDirectory($this->defaultPath.'/bundles/'.$bundle->getName(), $name) ); } @@ -76,14 +83,14 @@ public function getIterator() * * @return array */ - private function findTemplatesInDirectory($dir, $namespace = null) + private function findTemplatesInDirectory($dir, $namespace = null, array $excludeDirs = array()) { if (!is_dir($dir)) { return array(); } $templates = array(); - foreach (Finder::create()->files()->followLinks()->in($dir) as $file) { + foreach (Finder::create()->files()->followLinks()->in($dir)->exclude($excludeDirs) as $file) { $templates[] = (null !== $namespace ? '@'.$namespace.'/' : '').str_replace('\\', '/', $file->getRelativePathname()); } diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/templates/bundles/BarBundle/layout.html.twig b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/templates/bundles/BarBundle/layout.html.twig new file mode 100644 index 0000000000000..bb07ecfe55a36 --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/templates/bundles/BarBundle/layout.html.twig @@ -0,0 +1 @@ +This is a layout diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Fixtures/templates/Resources/BarBundle/views/base.html.twig b/src/Symfony/Bundle/TwigBundle/Tests/Fixtures/templates/Resources/BarBundle/views/base.html.twig new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php b/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php index 636d5796f874f..04eb5e1878384 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php @@ -25,13 +25,15 @@ public function testGetIterator() $kernel->expects($this->any())->method('getBundles')->will($this->returnValue(array( $bundle, ))); - $iterator = new TemplateIterator($kernel, __DIR__.'/Fixtures/templates', array(__DIR__.'/Fixtures/templates/Foo' => 'Foo')); + $iterator = new TemplateIterator($kernel, __DIR__.'/Fixtures/templates', array(__DIR__.'/Fixtures/templates/Foo' => 'Foo'), __DIR__.'/DependencyInjection/Fixtures/templates'); $sorted = iterator_to_array($iterator); sort($sorted); $this->assertEquals( array( + '@Bar/base.html.twig', '@Bar/index.html.twig', + '@Bar/layout.html.twig', '@Foo/index.html.twig', 'layout.html.twig', 'sub/sub.html.twig', diff --git a/src/Symfony/Bundle/WebProfilerBundle/README.md b/src/Symfony/Bundle/WebProfilerBundle/README.md index 03780d5e5904e..48e6075636519 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/README.md +++ b/src/Symfony/Bundle/WebProfilerBundle/README.md @@ -1,6 +1,12 @@ WebProfilerBundle ================= +The Web profiler bundle is a **development tool** that gives detailed +information about the execution of any request. + +**Never** enable it on production servers as it will lead to major security +vulnerabilities in your project. + Resources --------- diff --git a/src/Symfony/Component/Cache/Traits/AbstractTrait.php b/src/Symfony/Component/Cache/Traits/AbstractTrait.php index ec60fe79c4a6b..87aeba9e7b174 100644 --- a/src/Symfony/Component/Cache/Traits/AbstractTrait.php +++ b/src/Symfony/Component/Cache/Traits/AbstractTrait.php @@ -106,14 +106,7 @@ public function clear() { $this->deferred = array(); if ($cleared = $this->versioningIsEnabled) { - $namespaceVersion = 2; - try { - foreach ($this->doFetch(array('@'.$this->namespace)) as $v) { - $namespaceVersion = 1 + (int) $v; - } - } catch (\Exception $e) { - } - $namespaceVersion .= ':'; + $namespaceVersion = substr_replace(base64_encode(pack('V', mt_rand())), ':', 5); try { $cleared = $this->doSave(array('@'.$this->namespace => $namespaceVersion), 0); } catch (\Exception $e) { @@ -247,6 +240,10 @@ private function getId($key) foreach ($this->doFetch(array('@'.$this->namespace)) as $v) { $this->namespaceVersion = $v; } + if ('1:' === $this->namespaceVersion) { + $this->namespaceVersion = substr_replace(base64_encode(pack('V', time())), ':', 5); + $this->doSave(array('@'.$this->namespace => $this->namespaceVersion), 0); + } } catch (\Exception $e) { } } diff --git a/src/Symfony/Component/Config/Definition/ArrayNode.php b/src/Symfony/Component/Config/Definition/ArrayNode.php index 87007b2b3659c..58a6829ec89d6 100644 --- a/src/Symfony/Component/Config/Definition/ArrayNode.php +++ b/src/Symfony/Component/Config/Definition/ArrayNode.php @@ -219,15 +219,13 @@ public function addChild(NodeInterface $node) protected function finalizeValue($value) { if (false === $value) { - $msg = sprintf('Unsetting key for path "%s", value: %s', $this->getPath(), json_encode($value)); - throw new UnsetKeyException($msg); + throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: %s', $this->getPath(), json_encode($value))); } foreach ($this->children as $name => $child) { if (!array_key_exists($name, $value)) { if ($child->isRequired()) { - $msg = sprintf('The child node "%s" at path "%s" must be configured.', $name, $this->getPath()); - $ex = new InvalidConfigurationException($msg); + $ex = new InvalidConfigurationException(sprintf('The child node "%s" at path "%s" must be configured.', $name, $this->getPath())); $ex->setPath($this->getPath()); throw $ex; @@ -264,11 +262,7 @@ protected function finalizeValue($value) protected function validateType($value) { if (!\is_array($value) && (!$this->allowFalse || false !== $value)) { - $ex = new InvalidTypeException(sprintf( - 'Invalid type for path "%s". Expected array, but got %s', - $this->getPath(), - \gettype($value) - )); + $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected array, but got %s', $this->getPath(), \gettype($value))); if ($hint = $this->getInfo()) { $ex->addHint($hint); } @@ -307,8 +301,7 @@ protected function normalizeValue($value) // if extra fields are present, throw exception if (\count($value) && !$this->ignoreExtraKeys) { - $msg = sprintf('Unrecognized option%s "%s" under "%s"', 1 === \count($value) ? '' : 's', implode(', ', array_keys($value)), $this->getPath()); - $ex = new InvalidConfigurationException($msg); + $ex = new InvalidConfigurationException(sprintf('Unrecognized option%s "%s" under "%s"', 1 === \count($value) ? '' : 's', implode(', ', array_keys($value)), $this->getPath())); $ex->setPath($this->getPath()); throw $ex; @@ -365,13 +358,7 @@ protected function mergeValues($leftSide, $rightSide) // no conflict if (!array_key_exists($k, $leftSide)) { if (!$this->allowNewKeys) { - $ex = new InvalidConfigurationException(sprintf( - 'You are not allowed to define new elements for path "%s". ' - .'Please define all elements for this path in one config file. ' - .'If you are trying to overwrite an element, make sure you redefine it ' - .'with the same name.', - $this->getPath() - )); + $ex = new InvalidConfigurationException(sprintf('You are not allowed to define new elements for path "%s". Please define all elements for this path in one config file. If you are trying to overwrite an element, make sure you redefine it with the same name.', $this->getPath())); $ex->setPath($this->getPath()); throw $ex; diff --git a/src/Symfony/Component/Config/Definition/BaseNode.php b/src/Symfony/Component/Config/Definition/BaseNode.php index 61e75eb5895ba..3ed993291a312 100644 --- a/src/Symfony/Component/Config/Definition/BaseNode.php +++ b/src/Symfony/Component/Config/Definition/BaseNode.php @@ -288,12 +288,7 @@ public function getPath() final public function merge($leftSide, $rightSide) { if (!$this->allowOverwrite) { - throw new ForbiddenOverwriteException(sprintf( - 'Configuration path "%s" cannot be overwritten. You have to ' - .'define all options for this path, and any of its sub-paths in ' - .'one configuration section.', - $this->getPath() - )); + throw new ForbiddenOverwriteException(sprintf('Configuration path "%s" cannot be overwritten. You have to define all options for this path, and any of its sub-paths in one configuration section.', $this->getPath())); } if ($leftSide !== $leftPlaceholders = self::resolvePlaceholderValue($leftSide)) { diff --git a/src/Symfony/Component/Config/Definition/BooleanNode.php b/src/Symfony/Component/Config/Definition/BooleanNode.php index 6be06bbb6b1c6..40f693915ac92 100644 --- a/src/Symfony/Component/Config/Definition/BooleanNode.php +++ b/src/Symfony/Component/Config/Definition/BooleanNode.php @@ -26,11 +26,7 @@ class BooleanNode extends ScalarNode protected function validateType($value) { if (!\is_bool($value)) { - $ex = new InvalidTypeException(sprintf( - 'Invalid type for path "%s". Expected boolean, but got %s.', - $this->getPath(), - \gettype($value) - )); + $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected boolean, but got %s.', $this->getPath(), \gettype($value))); if ($hint = $this->getInfo()) { $ex->addHint($hint); } diff --git a/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php index 2d8e1d630bbd5..b82f1445c25ca 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php @@ -468,9 +468,7 @@ protected function validateConcreteNode(ArrayNode $node) $path = $node->getPath(); if (null !== $this->key) { - throw new InvalidDefinitionException( - sprintf('->useAttributeAsKey() is not applicable to concrete nodes at path "%s"', $path) - ); + throw new InvalidDefinitionException(sprintf('->useAttributeAsKey() is not applicable to concrete nodes at path "%s"', $path)); } if (false === $this->allowEmptyValue) { @@ -478,21 +476,15 @@ protected function validateConcreteNode(ArrayNode $node) } if (true === $this->atLeastOne) { - throw new InvalidDefinitionException( - sprintf('->requiresAtLeastOneElement() is not applicable to concrete nodes at path "%s"', $path) - ); + throw new InvalidDefinitionException(sprintf('->requiresAtLeastOneElement() is not applicable to concrete nodes at path "%s"', $path)); } if ($this->default) { - throw new InvalidDefinitionException( - sprintf('->defaultValue() is not applicable to concrete nodes at path "%s"', $path) - ); + throw new InvalidDefinitionException(sprintf('->defaultValue() is not applicable to concrete nodes at path "%s"', $path)); } if (false !== $this->addDefaultChildren) { - throw new InvalidDefinitionException( - sprintf('->addDefaultChildrenIfNoneSet() is not applicable to concrete nodes at path "%s"', $path) - ); + throw new InvalidDefinitionException(sprintf('->addDefaultChildrenIfNoneSet() is not applicable to concrete nodes at path "%s"', $path)); } } @@ -506,28 +498,20 @@ protected function validatePrototypeNode(PrototypedArrayNode $node) $path = $node->getPath(); if ($this->addDefaults) { - throw new InvalidDefinitionException( - sprintf('->addDefaultsIfNotSet() is not applicable to prototype nodes at path "%s"', $path) - ); + throw new InvalidDefinitionException(sprintf('->addDefaultsIfNotSet() is not applicable to prototype nodes at path "%s"', $path)); } if (false !== $this->addDefaultChildren) { if ($this->default) { - throw new InvalidDefinitionException( - sprintf('A default value and default children might not be used together at path "%s"', $path) - ); + throw new InvalidDefinitionException(sprintf('A default value and default children might not be used together at path "%s"', $path)); } if (null !== $this->key && (null === $this->addDefaultChildren || \is_int($this->addDefaultChildren) && $this->addDefaultChildren > 0)) { - throw new InvalidDefinitionException( - sprintf('->addDefaultChildrenIfNoneSet() should set default children names as ->useAttributeAsKey() is used at path "%s"', $path) - ); + throw new InvalidDefinitionException(sprintf('->addDefaultChildrenIfNoneSet() should set default children names as ->useAttributeAsKey() is used at path "%s"', $path)); } if (null === $this->key && (\is_string($this->addDefaultChildren) || \is_array($this->addDefaultChildren))) { - throw new InvalidDefinitionException( - sprintf('->addDefaultChildrenIfNoneSet() might not set default children names as ->useAttributeAsKey() is not used at path "%s"', $path) - ); + throw new InvalidDefinitionException(sprintf('->addDefaultChildrenIfNoneSet() might not set default children names as ->useAttributeAsKey() is not used at path "%s"', $path)); } } } diff --git a/src/Symfony/Component/Config/Definition/EnumNode.php b/src/Symfony/Component/Config/Definition/EnumNode.php index a9bbb28afcd16..c54117a34ae52 100644 --- a/src/Symfony/Component/Config/Definition/EnumNode.php +++ b/src/Symfony/Component/Config/Definition/EnumNode.php @@ -43,11 +43,7 @@ protected function finalizeValue($value) $value = parent::finalizeValue($value); if (!\in_array($value, $this->values, true)) { - $ex = new InvalidConfigurationException(sprintf( - 'The value %s is not allowed for path "%s". Permissible values: %s', - json_encode($value), - $this->getPath(), - implode(', ', array_map('json_encode', $this->values)))); + $ex = new InvalidConfigurationException(sprintf('The value %s is not allowed for path "%s". Permissible values: %s', json_encode($value), $this->getPath(), implode(', ', array_map('json_encode', $this->values)))); $ex->setPath($this->getPath()); throw $ex; diff --git a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php index fd686a1e5ef32..4017b9d67c240 100644 --- a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php +++ b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php @@ -185,8 +185,7 @@ public function addChild(NodeInterface $node) protected function finalizeValue($value) { if (false === $value) { - $msg = sprintf('Unsetting key for path "%s", value: %s', $this->getPath(), json_encode($value)); - throw new UnsetKeyException($msg); + throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: %s', $this->getPath(), json_encode($value))); } foreach ($value as $k => $v) { @@ -199,8 +198,7 @@ protected function finalizeValue($value) } if (\count($value) < $this->minNumberOfElements) { - $msg = sprintf('The path "%s" should have at least %d element(s) defined.', $this->getPath(), $this->minNumberOfElements); - $ex = new InvalidConfigurationException($msg); + $ex = new InvalidConfigurationException(sprintf('The path "%s" should have at least %d element(s) defined.', $this->getPath(), $this->minNumberOfElements)); $ex->setPath($this->getPath()); throw $ex; @@ -232,8 +230,7 @@ protected function normalizeValue($value) foreach ($value as $k => $v) { if (null !== $this->keyAttribute && \is_array($v)) { if (!isset($v[$this->keyAttribute]) && \is_int($k) && !$isAssoc) { - $msg = sprintf('The attribute "%s" must be set for path "%s".', $this->keyAttribute, $this->getPath()); - $ex = new InvalidConfigurationException($msg); + $ex = new InvalidConfigurationException(sprintf('The attribute "%s" must be set for path "%s".', $this->keyAttribute, $this->getPath())); $ex->setPath($this->getPath()); throw $ex; @@ -262,8 +259,7 @@ protected function normalizeValue($value) } if (array_key_exists($k, $normalized)) { - $msg = sprintf('Duplicate key "%s" for path "%s".', $k, $this->getPath()); - $ex = new DuplicateKeyException($msg); + $ex = new DuplicateKeyException(sprintf('Duplicate key "%s" for path "%s".', $k, $this->getPath())); $ex->setPath($this->getPath()); throw $ex; @@ -314,11 +310,7 @@ protected function mergeValues($leftSide, $rightSide) // no conflict if (!array_key_exists($k, $leftSide)) { if (!$this->allowNewKeys) { - $ex = new InvalidConfigurationException(sprintf( - 'You are not allowed to define new elements for path "%s". '. - 'Please define all elements for this path in one config file.', - $this->getPath() - )); + $ex = new InvalidConfigurationException(sprintf('You are not allowed to define new elements for path "%s". Please define all elements for this path in one config file.', $this->getPath())); $ex->setPath($this->getPath()); throw $ex; @@ -342,27 +334,31 @@ protected function mergeValues($leftSide, $rightSide) * one is same as this->keyAttribute and the other is 'value', then the prototype will be different. * * For example, assume $this->keyAttribute is 'name' and the value array is as follows: - * array( + * * array( - * 'name' => 'name001', - * 'value' => 'value001' + * array( + * 'name' => 'name001', + * 'value' => 'value001' + * ) * ) - * ) * * Now, the key is 0 and the child node is: - * array( - * 'name' => 'name001', - * 'value' => 'value001' - * ) + * + * array( + * 'name' => 'name001', + * 'value' => 'value001' + * ) * * When normalizing the value array, the 'name' element will removed from the child node * and its value becomes the new key of the child node: - * array( - * 'name001' => array('value' => 'value001') - * ) + * + * array( + * 'name001' => array('value' => 'value001') + * ) * * Now only 'value' element is left in the child node which can be further simplified into a string: - * array('name001' => 'value001') + * + * array('name001' => 'value001') * * Now, the key becomes 'name001' and the child node becomes 'value001' and * the prototype of child node 'name001' should be a ScalarNode instead of an ArrayNode instance. diff --git a/src/Symfony/Component/Config/Definition/ScalarNode.php b/src/Symfony/Component/Config/Definition/ScalarNode.php index 97fa1ed22a35c..ee870b6a85ea9 100644 --- a/src/Symfony/Component/Config/Definition/ScalarNode.php +++ b/src/Symfony/Component/Config/Definition/ScalarNode.php @@ -33,11 +33,7 @@ class ScalarNode extends VariableNode protected function validateType($value) { if (!is_scalar($value) && null !== $value) { - $ex = new InvalidTypeException(sprintf( - 'Invalid type for path "%s". Expected scalar, but got %s.', - $this->getPath(), - \gettype($value) - )); + $ex = new InvalidTypeException(sprintf('Invalid type for path "%s". Expected scalar, but got %s.', $this->getPath(), \gettype($value))); if ($hint = $this->getInfo()) { $ex->addHint($hint); } diff --git a/src/Symfony/Component/Config/Definition/VariableNode.php b/src/Symfony/Component/Config/Definition/VariableNode.php index 0cd84c72bf303..1a3442d9613db 100644 --- a/src/Symfony/Component/Config/Definition/VariableNode.php +++ b/src/Symfony/Component/Config/Definition/VariableNode.php @@ -82,11 +82,7 @@ protected function validateType($value) protected function finalizeValue($value) { if (!$this->allowEmptyValue && $this->isValueEmpty($value)) { - $ex = new InvalidConfigurationException(sprintf( - 'The path "%s" cannot contain an empty value, but got %s.', - $this->getPath(), - json_encode($value) - )); + $ex = new InvalidConfigurationException(sprintf('The path "%s" cannot contain an empty value, but got %s.', $this->getPath(), json_encode($value))); if ($hint = $this->getInfo()) { $ex->addHint($hint); } diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 3ef76b3f337fa..5d1651ef4431d 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -159,6 +159,8 @@ public function run(InputInterface $input = null, OutputInterface $output = null } else { $exitCode = 1; } + + return $exitCode; } finally { // if the exception handler changed, keep it // otherwise, unregister $renderException diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 38bb8b998c526..dd99e0d477bb6 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -173,10 +173,14 @@ protected function interact(InputInterface $input, OutputInterface $output) } /** - * Initializes the command just after the input has been validated. + * Initializes the command after the input has been bound and before the input + * is validated. * * This is mainly useful when a lot of commands extends one main command * where some things need to be initialized based on the input arguments and options. + * + * @see InputInterface::bind() + * @see InputInterface::validate() */ protected function initialize(InputInterface $input, OutputInterface $output) { diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php b/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php index d09994f2253b8..906021f6f94ab 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatterStyle.php @@ -90,11 +90,7 @@ public function setForeground($color = null) } if (!isset(static::$availableForegroundColors[$color])) { - throw new InvalidArgumentException(sprintf( - 'Invalid foreground color specified: "%s". Expected one of (%s)', - $color, - implode(', ', array_keys(static::$availableForegroundColors)) - )); + throw new InvalidArgumentException(sprintf('Invalid foreground color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableForegroundColors)))); } $this->foreground = static::$availableForegroundColors[$color]; @@ -116,11 +112,7 @@ public function setBackground($color = null) } if (!isset(static::$availableBackgroundColors[$color])) { - throw new InvalidArgumentException(sprintf( - 'Invalid background color specified: "%s". Expected one of (%s)', - $color, - implode(', ', array_keys(static::$availableBackgroundColors)) - )); + throw new InvalidArgumentException(sprintf('Invalid background color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableBackgroundColors)))); } $this->background = static::$availableBackgroundColors[$color]; @@ -136,11 +128,7 @@ public function setBackground($color = null) public function setOption($option) { if (!isset(static::$availableOptions[$option])) { - throw new InvalidArgumentException(sprintf( - 'Invalid option specified: "%s". Expected one of (%s)', - $option, - implode(', ', array_keys(static::$availableOptions)) - )); + throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions)))); } if (!\in_array(static::$availableOptions[$option], $this->options)) { @@ -158,11 +146,7 @@ public function setOption($option) public function unsetOption($option) { if (!isset(static::$availableOptions[$option])) { - throw new InvalidArgumentException(sprintf( - 'Invalid option specified: "%s". Expected one of (%s)', - $option, - implode(', ', array_keys(static::$availableOptions)) - )); + throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions)))); } $pos = array_search(static::$availableOptions[$option], $this->options); diff --git a/src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php b/src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php index 9697772072fa6..260c03e20bf85 100644 --- a/src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php +++ b/src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php @@ -58,7 +58,7 @@ protected function writePrompt(OutputInterface $output, Question $question) case $question instanceof ChoiceQuestion: $choices = $question->getChoices(); - $text = sprintf(' %s [%s]:', $text, OutputFormatter::escape($choices[$default])); + $text = sprintf(' %s [%s]:', $text, OutputFormatter::escape(isset($choices[$default]) ? $choices[$default] : $default)); break; diff --git a/src/Symfony/Component/Console/Helper/Table.php b/src/Symfony/Component/Console/Helper/Table.php index f0dbec4ebe01f..a23ece0609342 100644 --- a/src/Symfony/Component/Console/Helper/Table.php +++ b/src/Symfony/Component/Console/Helper/Table.php @@ -294,15 +294,14 @@ public function setRow($column, array $row) * Renders table to output. * * Example: - * - * +---------------+-----------------------+------------------+ - * | ISBN | Title | Author | - * +---------------+-----------------------+------------------+ - * | 99921-58-10-7 | Divine Comedy | Dante Alighieri | - * | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | - * | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | - * +---------------+-----------------------+------------------+ - * + * + * +---------------+-----------------------+------------------+ + * | ISBN | Title | Author | + * +---------------+-----------------------+------------------+ + * | 99921-58-10-7 | Divine Comedy | Dante Alighieri | + * | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | + * | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | + * +---------------+-----------------------+------------------+ */ public function render() { @@ -348,7 +347,9 @@ public function render() /** * Renders horizontal header separator. * - * Example: +-----+-----------+-------+ + * Example: + * + * +-----+-----------+-------+ */ private function renderRowSeparator(int $type = self::SEPARATOR_MID) { @@ -394,7 +395,10 @@ private function renderColumnSeparator($type = self::BORDER_OUTSIDE) /** * Renders table row. * - * Example: | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | + * Example: + * + * | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | + * */ private function renderRow(array $row, string $cellFormat) { @@ -652,13 +656,13 @@ private function calculateColumnsWidth(iterable $rows) $lengths[] = $this->getCellWidth($row, $column); } - $this->effectiveColumnWidths[$column] = max($lengths) + \strlen($this->style->getCellRowContentFormat()) - 2; + $this->effectiveColumnWidths[$column] = max($lengths) + Helper::strlen($this->style->getCellRowContentFormat()) - 2; } } private function getColumnSeparatorWidth(): int { - return \strlen(sprintf($this->style->getBorderFormat(), $this->style->getBorderChars()[3])); + return Helper::strlen(sprintf($this->style->getBorderFormat(), $this->style->getBorderChars()[3])); } private function getCellWidth(array $row, int $column): int diff --git a/src/Symfony/Component/Console/Input/ArgvInput.php b/src/Symfony/Component/Console/Input/ArgvInput.php index da268677a69cf..b459ae47499fe 100644 --- a/src/Symfony/Component/Console/Input/ArgvInput.php +++ b/src/Symfony/Component/Console/Input/ArgvInput.php @@ -121,7 +121,8 @@ private function parseShortOptionSet($name) $len = \strlen($name); for ($i = 0; $i < $len; ++$i) { if (!$this->definition->hasShortcut($name[$i])) { - throw new RuntimeException(sprintf('The "-%s" option does not exist.', $name[$i])); + $encoding = mb_detect_encoding($name, null, true); + throw new RuntimeException(sprintf('The "-%s" option does not exist.', false === $encoding ? $name[$i] : mb_substr($name, $i, 1, $encoding))); } $option = $this->definition->getOptionForShortcut($name[$i]); diff --git a/src/Symfony/Component/Console/Input/InputArgument.php b/src/Symfony/Component/Console/Input/InputArgument.php index 409c4c4a922cc..6a2b9f8acb304 100644 --- a/src/Symfony/Component/Console/Input/InputArgument.php +++ b/src/Symfony/Component/Console/Input/InputArgument.php @@ -86,7 +86,7 @@ public function isArray() /** * Sets the default value. * - * @param mixed $default The default value + * @param string|string[] $default The default value * * @throws LogicException When incorrect default value is given */ @@ -110,7 +110,7 @@ public function setDefault($default = null) /** * Returns the default value. * - * @return mixed The default value + * @return string|string[] The default value */ public function getDefault() { diff --git a/src/Symfony/Component/Console/Input/InputDefinition.php b/src/Symfony/Component/Console/Input/InputDefinition.php index dc9f8b241fb9d..21fc67df2f482 100644 --- a/src/Symfony/Component/Console/Input/InputDefinition.php +++ b/src/Symfony/Component/Console/Input/InputDefinition.php @@ -20,8 +20,8 @@ * Usage: * * $definition = new InputDefinition(array( - * new InputArgument('name', InputArgument::REQUIRED), - * new InputOption('foo', 'f', InputOption::VALUE_REQUIRED), + * new InputArgument('name', InputArgument::REQUIRED), + * new InputOption('foo', 'f', InputOption::VALUE_REQUIRED), * )); * * @author Fabien Potencier diff --git a/src/Symfony/Component/Console/Input/InputInterface.php b/src/Symfony/Component/Console/Input/InputInterface.php index 43810f7ac21bd..bc30c205b50db 100644 --- a/src/Symfony/Component/Console/Input/InputInterface.php +++ b/src/Symfony/Component/Console/Input/InputInterface.php @@ -61,6 +61,8 @@ public function getParameterOption($values, $default = false, $onlyParams = fals /** * Binds the current Input instance with the given arguments and options. + * + * @throws RuntimeException */ public function bind(InputDefinition $definition); @@ -83,7 +85,7 @@ public function getArguments(); * * @param string $name The argument name * - * @return mixed The argument value + * @return string|string[] The argument value * * @throws InvalidArgumentException When argument given doesn't exist */ @@ -92,8 +94,8 @@ public function getArgument($name); /** * Sets an argument value by name. * - * @param string $name The argument name - * @param string $value The argument value + * @param string $name The argument name + * @param string|string[] $value The argument value * * @throws InvalidArgumentException When argument given doesn't exist */ @@ -120,7 +122,7 @@ public function getOptions(); * * @param string $name The option name * - * @return mixed The option value + * @return string|string[]|bool The option value * * @throws InvalidArgumentException When option given doesn't exist */ @@ -129,8 +131,8 @@ public function getOption($name); /** * Sets an option value by name. * - * @param string $name The option name - * @param string|bool $value The option value + * @param string $name The option name + * @param string|string[]|bool $value The option value * * @throws InvalidArgumentException When option given doesn't exist */ diff --git a/src/Symfony/Component/Console/Input/InputOption.php b/src/Symfony/Component/Console/Input/InputOption.php index a8dade4de7452..7a5a326c95133 100644 --- a/src/Symfony/Component/Console/Input/InputOption.php +++ b/src/Symfony/Component/Console/Input/InputOption.php @@ -149,7 +149,7 @@ public function isArray() /** * Sets the default value. * - * @param mixed $default The default value + * @param string|string[]|bool $default The default value * * @throws LogicException When incorrect default value is given */ @@ -173,7 +173,7 @@ public function setDefault($default = null) /** * Returns the default value. * - * @return mixed The default value + * @return string|string[]|bool The default value */ public function getDefault() { diff --git a/src/Symfony/Component/Console/Output/StreamOutput.php b/src/Symfony/Component/Console/Output/StreamOutput.php index 210ce007a6c18..fe8632b350b12 100644 --- a/src/Symfony/Component/Console/Output/StreamOutput.php +++ b/src/Symfony/Component/Console/Output/StreamOutput.php @@ -20,11 +20,11 @@ * * Usage: * - * $output = new StreamOutput(fopen('php://stdout', 'w')); + * $output = new StreamOutput(fopen('php://stdout', 'w')); * * As `StreamOutput` can use any stream, you can also use a file: * - * $output = new StreamOutput(fopen('/path/to/output.log', 'a', false)); + * $output = new StreamOutput(fopen('/path/to/output.log', 'a', false)); * * @author Fabien Potencier */ diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index 28c37bb4ce3ae..c202f2bd1f1e1 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -960,6 +960,31 @@ public function testRunReturnsIntegerExitCode() $this->assertSame(4, $exitCode, '->run() returns integer exit code extracted from raised exception'); } + public function testRunDispatchesIntegerExitCode() + { + $passedRightValue = false; + + // We can assume here that some other test asserts that the event is dispatched at all + $dispatcher = new EventDispatcher(); + $self = $this; + $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use ($self, &$passedRightValue) { + $passedRightValue = (4 === $event->getExitCode()); + }); + + $application = new Application(); + $application->setDispatcher($dispatcher); + $application->setAutoExit(false); + + $application->register('test')->setCode(function (InputInterface $input, OutputInterface $output) { + throw new \Exception('', 4); + }); + + $tester = new ApplicationTester($application); + $tester->run(array('command' => 'test')); + + $this->assertTrue($passedRightValue, '-> exit code 4 was passed in the console.terminate event'); + } + public function testRunReturnsExitCodeOneForExceptionCodeZero() { $exception = new \Exception('', 0); @@ -975,6 +1000,31 @@ public function testRunReturnsExitCodeOneForExceptionCodeZero() $this->assertSame(1, $exitCode, '->run() returns exit code 1 when exception code is 0'); } + public function testRunDispatchesExitCodeOneForExceptionCodeZero() + { + $passedRightValue = false; + + // We can assume here that some other test asserts that the event is dispatched at all + $dispatcher = new EventDispatcher(); + $self = $this; + $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use ($self, &$passedRightValue) { + $passedRightValue = (1 === $event->getExitCode()); + }); + + $application = new Application(); + $application->setDispatcher($dispatcher); + $application->setAutoExit(false); + + $application->register('test')->setCode(function (InputInterface $input, OutputInterface $output) { + throw new \Exception(); + }); + + $tester = new ApplicationTester($application); + $tester->run(array('command' => 'test')); + + $this->assertTrue($passedRightValue, '-> exit code 1 was passed in the console.terminate event'); + } + /** * @expectedException \LogicException * @expectedExceptionMessage An option with shortcut "e" already exists. diff --git a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php index fff72d4271b59..9406e5b863d06 100644 --- a/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/SymfonyQuestionHelperTest.php @@ -74,6 +74,18 @@ public function testAskChoice() $this->assertOutputContains('What is your favorite superhero? [Superman, Batman]', $output); } + public function testAskChoiceWithChoiceValueAsDefault() + { + $questionHelper = new SymfonyQuestionHelper(); + $helperSet = new HelperSet(array(new FormatterHelper())); + $questionHelper->setHelperSet($helperSet); + $question = new ChoiceQuestion('What is your favorite superhero?', array('Superman', 'Batman', 'Spiderman'), 'Batman'); + $question->setMaxAttempts(1); + + $this->assertSame('Batman', $questionHelper->ask($this->createStreamableInputInterfaceMock($this->getInputStream("Batman\n")), $output = $this->createOutputInterface(), $question)); + $this->assertOutputContains('What is your favorite superhero? [Batman]', $output); + } + public function testAskReturnsNullIfValidatorAllowsIt() { $questionHelper = new SymfonyQuestionHelper(); diff --git a/src/Symfony/Component/Console/Tests/Helper/TableTest.php b/src/Symfony/Component/Console/Tests/Helper/TableTest.php index 508db66621572..7a9a688adec0d 100644 --- a/src/Symfony/Component/Console/Tests/Helper/TableTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/TableTest.php @@ -783,7 +783,7 @@ public function testThrowsWhenTheCellInAnArray() $table->render(); } - public function testColumnWith() + public function testColumnWidth() { $table = new Table($output = $this->getOutputStream()); $table @@ -815,7 +815,7 @@ public function testColumnWith() $this->assertEquals($expected, $this->getOutputContent($output)); } - public function testColumnWiths() + public function testColumnWidths() { $table = new Table($output = $this->getOutputStream()); $table @@ -974,6 +974,42 @@ public function testGetStyleDefinition() Table::getStyleDefinition('absent'); } + public function testBoxedStyleWithColspan() + { + $boxed = new TableStyle(); + $boxed + ->setHorizontalBorderChars('─') + ->setVerticalBorderChars('│') + ->setCrossingChars('┼', '┌', '┬', '┐', '┤', '┘', '┴', '└', '├') + ; + + $table = new Table($output = $this->getOutputStream()); + $table->setStyle($boxed); + $table + ->setHeaders(array('ISBN', 'Title', 'Author')) + ->setRows(array( + array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'), + new TableSeparator(), + array(new TableCell('This value spans 3 columns.', array('colspan' => 3))), + )) + ; + $table->render(); + + $expected = + <<assertSame($expected, $this->getOutputContent($output)); + } + protected function getOutputStream($decorated = false) { return new StreamOutput($this->stream, StreamOutput::VERBOSITY_NORMAL, $decorated); diff --git a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php index 75742409037f3..b91b6d71df790 100644 --- a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php @@ -246,6 +246,11 @@ public function provideInvalidInput() new InputDefinition(array(new InputArgument('number'))), 'The "-1" option does not exist.', ), + array( + array('cli.php', '-fЩ'), + new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_NONE))), + 'The "-Щ" option does not exist.', + ), ); } diff --git a/src/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php b/src/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php index 52b9c2f63cfaa..ebe508fefd0c9 100644 --- a/src/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php +++ b/src/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php @@ -133,10 +133,7 @@ public function translateContains(XPathExpr $xpath, FunctionNode $function): XPa $arguments = $function->getArguments(); foreach ($arguments as $token) { if (!($token->isString() || $token->isIdentifier())) { - throw new ExpressionErrorException( - 'Expected a single string or identifier for :contains(), got ' - .implode(', ', $arguments) - ); + throw new ExpressionErrorException('Expected a single string or identifier for :contains(), got '.implode(', ', $arguments)); } } @@ -154,10 +151,7 @@ public function translateLang(XPathExpr $xpath, FunctionNode $function): XPathEx $arguments = $function->getArguments(); foreach ($arguments as $token) { if (!($token->isString() || $token->isIdentifier())) { - throw new ExpressionErrorException( - 'Expected a single string or identifier for :lang(), got ' - .implode(', ', $arguments) - ); + throw new ExpressionErrorException('Expected a single string or identifier for :lang(), got '.implode(', ', $arguments)); } } diff --git a/src/Symfony/Component/CssSelector/XPath/Extension/HtmlExtension.php b/src/Symfony/Component/CssSelector/XPath/Extension/HtmlExtension.php index 625ffa5cad670..cd8e0d5fd8677 100644 --- a/src/Symfony/Component/CssSelector/XPath/Extension/HtmlExtension.php +++ b/src/Symfony/Component/CssSelector/XPath/Extension/HtmlExtension.php @@ -158,10 +158,7 @@ public function translateLang(XPathExpr $xpath, FunctionNode $function) $arguments = $function->getArguments(); foreach ($arguments as $token) { if (!($token->isString() || $token->isIdentifier())) { - throw new ExpressionErrorException( - 'Expected a single string or identifier for :lang(), got ' - .implode(', ', $arguments) - ); + throw new ExpressionErrorException('Expected a single string or identifier for :lang(), got '.implode(', ', $arguments)); } } diff --git a/src/Symfony/Component/Debug/DebugClassLoader.php b/src/Symfony/Component/Debug/DebugClassLoader.php index ecf92516c3d72..b7f3ca37fe6fd 100644 --- a/src/Symfony/Component/Debug/DebugClassLoader.php +++ b/src/Symfony/Component/Debug/DebugClassLoader.php @@ -128,8 +128,6 @@ public static function disable() * * @param string $class The name of the class * - * @return bool|null True, if loaded - * * @throws \RuntimeException */ public function loadClass($class) @@ -183,196 +181,223 @@ private function checkClass($class, $file = null) throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: "%s" vs "%s".', $class, $name)); } - // Don't trigger deprecations for classes in the same vendor - if (2 > $len = 1 + (\strpos($name, '\\') ?: \strpos($name, '_'))) { - $len = 0; - $ns = ''; - } else { - $ns = \substr($name, 0, $len); + $deprecations = $this->checkAnnotations($refl, $name); + + foreach ($deprecations as $message) { + @trigger_error($message, E_USER_DEPRECATED); } + } - // Detect annotations on the class - if (false !== $doc = $refl->getDocComment()) { - foreach (array('final', 'deprecated', 'internal') as $annotation) { - if (false !== \strpos($doc, $annotation) && preg_match('#\n \* @'.$annotation.'(?:( .+?)\.?)?\r?\n \*(?: @|/$)#s', $doc, $notice)) { - self::${$annotation}[$name] = isset($notice[1]) ? preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]) : ''; - } - } + if (!$file) { + return; + } + + if (!$exists) { + if (false !== strpos($class, '/')) { + throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\" in PHP, not "/".', $class)); } - $parentAndTraits = \class_uses($name, false); - if ($parent = \get_parent_class($class)) { - $parentAndTraits[] = $parent; + throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file)); + } - if (!isset(self::$checkedClasses[$parent])) { - $this->checkClass($parent); - } + if (self::$caseCheck && $message = $this->checkCase($refl, $file, $class)) { + throw new \RuntimeException(sprintf('Case mismatch between class and real file names: "%s" vs "%s" in "%s".', $message[0], $message[1], $message[2])); + } + } - if (isset(self::$final[$parent])) { - @trigger_error(sprintf('The "%s" class is considered final%s. It may change without further notice as of its next major version. You should not extend it from "%s".', $parent, self::$final[$parent], $name), E_USER_DEPRECATED); + public function checkAnnotations(\ReflectionClass $refl, $class) + { + $deprecations = array(); + + // Don't trigger deprecations for classes in the same vendor + if (2 > $len = 1 + (\strpos($class, '\\') ?: \strpos($class, '_'))) { + $len = 0; + $ns = ''; + } else { + $ns = \substr($class, 0, $len); + } + + // Detect annotations on the class + if (false !== $doc = $refl->getDocComment()) { + foreach (array('final', 'deprecated', 'internal') as $annotation) { + if (false !== \strpos($doc, $annotation) && preg_match('#\n \* @'.$annotation.'(?:( .+?)\.?)?\r?\n \*(?: @|/$)#s', $doc, $notice)) { + self::${$annotation}[$class] = isset($notice[1]) ? preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]) : ''; } } + } - // Detect if the parent is annotated - foreach ($parentAndTraits + $this->getOwnInterfaces($name, $parent) as $use) { - if (!isset(self::$checkedClasses[$use])) { - $this->checkClass($use); - } - if (isset(self::$deprecated[$use]) && \strncmp($ns, $use, $len)) { - $type = class_exists($name, false) ? 'class' : (interface_exists($name, false) ? 'interface' : 'trait'); - $verb = class_exists($use, false) || interface_exists($name, false) ? 'extends' : (interface_exists($use, false) ? 'implements' : 'uses'); + $parent = \get_parent_class($class); + $parentAndOwnInterfaces = $this->getOwnInterfaces($class, $parent); + if ($parent) { + $parentAndOwnInterfaces[$parent] = $parent; - @trigger_error(sprintf('The "%s" %s %s "%s" that is deprecated%s.', $name, $type, $verb, $use, self::$deprecated[$use]), E_USER_DEPRECATED); - } - if (isset(self::$internal[$use]) && \strncmp($ns, $use, $len)) { - @trigger_error(sprintf('The "%s" %s is considered internal%s. It may change without further notice. You should not use it from "%s".', $use, class_exists($use, false) ? 'class' : (interface_exists($use, false) ? 'interface' : 'trait'), self::$internal[$use], $name), E_USER_DEPRECATED); - } + if (!isset(self::$checkedClasses[$parent])) { + $this->checkClass($parent); } - // Inherit @final and @internal annotations for methods - self::$finalMethods[$name] = array(); - self::$internalMethods[$name] = array(); - foreach ($parentAndTraits as $use) { - foreach (array('finalMethods', 'internalMethods') as $property) { - if (isset(self::${$property}[$use])) { - self::${$property}[$name] = self::${$property}[$name] ? self::${$property}[$use] + self::${$property}[$name] : self::${$property}[$use]; - } - } + if (isset(self::$final[$parent])) { + $deprecations[] = sprintf('The "%s" class is considered final%s. It may change without further notice as of its next major version. You should not extend it from "%s".', $parent, self::$final[$parent], $class); } + } - $isClass = \class_exists($name, false); - foreach ($refl->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED) as $method) { - if ($method->class !== $name) { - continue; - } + // Detect if the parent is annotated + foreach ($parentAndOwnInterfaces + \class_uses($class, false) as $use) { + if (!isset(self::$checkedClasses[$use])) { + $this->checkClass($use); + } + if (isset(self::$deprecated[$use]) && \strncmp($ns, $use, $len)) { + $type = class_exists($class, false) ? 'class' : (interface_exists($class, false) ? 'interface' : 'trait'); + $verb = class_exists($use, false) || interface_exists($class, false) ? 'extends' : (interface_exists($use, false) ? 'implements' : 'uses'); - // Method from a trait - if ($method->getFilename() !== $refl->getFileName()) { - continue; - } + $deprecations[] = sprintf('The "%s" %s %s "%s" that is deprecated%s.', $class, $type, $verb, $use, self::$deprecated[$use]); + } + if (isset(self::$internal[$use]) && \strncmp($ns, $use, $len)) { + $deprecations[] = sprintf('The "%s" %s is considered internal%s. It may change without further notice. You should not use it from "%s".', $use, class_exists($use, false) ? 'class' : (interface_exists($use, false) ? 'interface' : 'trait'), self::$internal[$use], $class); + } + } - if ($isClass && $parent && isset(self::$finalMethods[$parent][$method->name])) { - list($declaringClass, $message) = self::$finalMethods[$parent][$method->name]; - @trigger_error(sprintf('The "%s::%s()" method is considered final%s. It may change without further notice as of its next major version. You should not extend it from "%s".', $declaringClass, $method->name, $message, $name), E_USER_DEPRECATED); - } + if (\trait_exists($class)) { + return $deprecations; + } - foreach ($parentAndTraits as $use) { - if (isset(self::$internalMethods[$use][$method->name])) { - list($declaringClass, $message) = self::$internalMethods[$use][$method->name]; - if (\strncmp($ns, $declaringClass, $len)) { - @trigger_error(sprintf('The "%s::%s()" method is considered internal%s. It may change without further notice. You should not extend it from "%s".', $declaringClass, $method->name, $message, $name), E_USER_DEPRECATED); - } - } + // Inherit @final and @internal annotations for methods + self::$finalMethods[$class] = array(); + self::$internalMethods[$class] = array(); + foreach ($parentAndOwnInterfaces as $use) { + foreach (array('finalMethods', 'internalMethods') as $property) { + if (isset(self::${$property}[$use])) { + self::${$property}[$class] = self::${$property}[$class] ? self::${$property}[$use] + self::${$property}[$class] : self::${$property}[$use]; } + } + } + + foreach ($refl->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED) as $method) { + if ($method->class !== $class) { + continue; + } - // Detect method annotations - if (false === $doc = $method->getDocComment()) { - continue; + if ($parent && isset(self::$finalMethods[$parent][$method->name])) { + list($declaringClass, $message) = self::$finalMethods[$parent][$method->name]; + $deprecations[] = sprintf('The "%s::%s()" method is considered final%s. It may change without further notice as of its next major version. You should not extend it from "%s".', $declaringClass, $method->name, $message, $class); + } + + if (isset(self::$internalMethods[$class][$method->name])) { + list($declaringClass, $message) = self::$internalMethods[$class][$method->name]; + if (\strncmp($ns, $declaringClass, $len)) { + $deprecations[] = sprintf('The "%s::%s()" method is considered internal%s. It may change without further notice. You should not extend it from "%s".', $declaringClass, $method->name, $message, $class); } + } - foreach (array('final', 'internal') as $annotation) { - if (false !== \strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$)#s', $doc, $notice)) { - $message = isset($notice[1]) ? preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]) : ''; - self::${$annotation.'Methods'}[$name][$method->name] = array($name, $message); - } + // Detect method annotations + if (false === $doc = $method->getDocComment()) { + continue; + } + + foreach (array('final', 'internal') as $annotation) { + if (false !== \strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$)#s', $doc, $notice)) { + $message = isset($notice[1]) ? preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]) : ''; + self::${$annotation.'Methods'}[$class][$method->name] = array($class, $message); } } } - if ($file) { - if (!$exists) { - if (false !== strpos($class, '/')) { - throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\" in PHP, not "/".', $class)); - } + return $deprecations; + } - throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file)); - } - if (self::$caseCheck) { - $real = explode('\\', $class.strrchr($file, '.')); - $tail = explode(\DIRECTORY_SEPARATOR, str_replace('/', \DIRECTORY_SEPARATOR, $file)); + public function checkCase(\ReflectionClass $refl, $file, $class) + { + $real = explode('\\', $class.strrchr($file, '.')); + $tail = explode(\DIRECTORY_SEPARATOR, str_replace('/', \DIRECTORY_SEPARATOR, $file)); - $i = \count($tail) - 1; - $j = \count($real) - 1; + $i = \count($tail) - 1; + $j = \count($real) - 1; - while (isset($tail[$i], $real[$j]) && $tail[$i] === $real[$j]) { - --$i; - --$j; - } + while (isset($tail[$i], $real[$j]) && $tail[$i] === $real[$j]) { + --$i; + --$j; + } - array_splice($tail, 0, $i + 1); - } - if (self::$caseCheck && $tail) { - $tail = \DIRECTORY_SEPARATOR.implode(\DIRECTORY_SEPARATOR, $tail); - $tailLen = \strlen($tail); - $real = $refl->getFileName(); - - if (2 === self::$caseCheck) { - // realpath() on MacOSX doesn't normalize the case of characters - - $i = 1 + strrpos($real, '/'); - $file = substr($real, $i); - $real = substr($real, 0, $i); - - if (isset(self::$darwinCache[$real])) { - $kDir = $real; - } else { - $kDir = strtolower($real); - - if (isset(self::$darwinCache[$kDir])) { - $real = self::$darwinCache[$kDir][0]; - } else { - $dir = getcwd(); - chdir($real); - $real = getcwd().'/'; - chdir($dir); - - $dir = $real; - $k = $kDir; - $i = \strlen($dir) - 1; - while (!isset(self::$darwinCache[$k])) { - self::$darwinCache[$k] = array($dir, array()); - self::$darwinCache[$dir] = &self::$darwinCache[$k]; - - while ('/' !== $dir[--$i]) { - } - $k = substr($k, 0, ++$i); - $dir = substr($dir, 0, $i--); - } - } - } + array_splice($tail, 0, $i + 1); - $dirFiles = self::$darwinCache[$kDir][1]; - - if (isset($dirFiles[$file])) { - $kFile = $file; - } else { - $kFile = strtolower($file); - - if (!isset($dirFiles[$kFile])) { - foreach (scandir($real, 2) as $f) { - if ('.' !== $f[0]) { - $dirFiles[$f] = $f; - if ($f === $file) { - $kFile = $k = $file; - } elseif ($f !== $k = strtolower($f)) { - $dirFiles[$k] = $f; - } - } - } - self::$darwinCache[$kDir][1] = $dirFiles; - } - } + if (!$tail) { + return; + } + + $tail = \DIRECTORY_SEPARATOR.implode(\DIRECTORY_SEPARATOR, $tail); + $tailLen = \strlen($tail); + $real = $refl->getFileName(); + + if (2 === self::$caseCheck) { + $real = $this->darwinRealpath($real); + } - $real .= $dirFiles[$kFile]; + if (0 === substr_compare($real, $tail, -$tailLen, $tailLen, true) + && 0 !== substr_compare($real, $tail, -$tailLen, $tailLen, false) + ) { + return array(substr($tail, -$tailLen + 1), substr($real, -$tailLen + 1), substr($real, 0, -$tailLen + 1)); + } + } + + /** + * `realpath` on MacOSX doesn't normalize the case of characters. + */ + private function darwinRealpath($real) + { + $i = 1 + strrpos($real, '/'); + $file = substr($real, $i); + $real = substr($real, 0, $i); + + if (isset(self::$darwinCache[$real])) { + $kDir = $real; + } else { + $kDir = strtolower($real); + + if (isset(self::$darwinCache[$kDir])) { + $real = self::$darwinCache[$kDir][0]; + } else { + $dir = getcwd(); + chdir($real); + $real = getcwd().'/'; + chdir($dir); + + $dir = $real; + $k = $kDir; + $i = \strlen($dir) - 1; + while (!isset(self::$darwinCache[$k])) { + self::$darwinCache[$k] = array($dir, array()); + self::$darwinCache[$dir] = &self::$darwinCache[$k]; + + while ('/' !== $dir[--$i]) { + } + $k = substr($k, 0, ++$i); + $dir = substr($dir, 0, $i--); } + } + } - if (0 === substr_compare($real, $tail, -$tailLen, $tailLen, true) - && 0 !== substr_compare($real, $tail, -$tailLen, $tailLen, false) - ) { - throw new \RuntimeException(sprintf('Case mismatch between class and real file names: "%s" vs "%s" in "%s".', substr($tail, -$tailLen + 1), substr($real, -$tailLen + 1), substr($real, 0, -$tailLen + 1))); + $dirFiles = self::$darwinCache[$kDir][1]; + + if (isset($dirFiles[$file])) { + return $real .= $dirFiles[$file]; + } + + $kFile = strtolower($file); + + if (!isset($dirFiles[$kFile])) { + foreach (scandir($real, 2) as $f) { + if ('.' !== $f[0]) { + $dirFiles[$f] = $f; + if ($f === $file) { + $kFile = $k = $file; + } elseif ($f !== $k = strtolower($f)) { + $dirFiles[$k] = $f; + } } } + self::$darwinCache[$kDir][1] = $dirFiles; } + + return $real .= $dirFiles[$kFile]; } /** diff --git a/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php b/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php index 1580ca993ba58..4a2375549d592 100644 --- a/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php +++ b/src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php @@ -220,24 +220,21 @@ class_exists('Test\\'.__NAMESPACE__.'\\ExtendsFinalClass', true); public function testExtendedFinalMethod() { - set_error_handler(function () { return false; }); - $e = error_reporting(0); - trigger_error('', E_USER_NOTICE); + $deprecations = array(); + set_error_handler(function ($type, $msg) use (&$deprecations) { $deprecations[] = $msg; }); + $e = error_reporting(E_USER_DEPRECATED); class_exists(__NAMESPACE__.'\\Fixtures\\ExtendedFinalMethod', true); error_reporting($e); restore_error_handler(); - $lastError = error_get_last(); - unset($lastError['file'], $lastError['line']); - $xError = array( - 'type' => E_USER_DEPRECATED, - 'message' => 'The "Symfony\Component\Debug\Tests\Fixtures\FinalMethod::finalMethod()" method is considered final. It may change without further notice as of its next major version. You should not extend it from "Symfony\Component\Debug\Tests\Fixtures\ExtendedFinalMethod".', + 'The "Symfony\Component\Debug\Tests\Fixtures\FinalMethod::finalMethod()" method is considered final. It may change without further notice as of its next major version. You should not extend it from "Symfony\Component\Debug\Tests\Fixtures\ExtendedFinalMethod".', + 'The "Symfony\Component\Debug\Tests\Fixtures\FinalMethod::finalMethod2()" method is considered final. It may change without further notice as of its next major version. You should not extend it from "Symfony\Component\Debug\Tests\Fixtures\ExtendedFinalMethod".', ); - $this->assertSame($xError, $lastError); + $this->assertSame($xError, $deprecations); } public function testExtendedDeprecatedMethodDoesntTriggerAnyNotice() @@ -269,12 +266,26 @@ class_exists('Test\\'.__NAMESPACE__.'\\ExtendsInternals', true); restore_error_handler(); $this->assertSame($deprecations, array( - 'The "Symfony\Component\Debug\Tests\Fixtures\InternalClass" class is considered internal. It may change without further notice. You should not use it from "Test\Symfony\Component\Debug\Tests\ExtendsInternalsParent".', 'The "Symfony\Component\Debug\Tests\Fixtures\InternalInterface" interface is considered internal. It may change without further notice. You should not use it from "Test\Symfony\Component\Debug\Tests\ExtendsInternalsParent".', + 'The "Symfony\Component\Debug\Tests\Fixtures\InternalClass" class is considered internal. It may change without further notice. You should not use it from "Test\Symfony\Component\Debug\Tests\ExtendsInternalsParent".', 'The "Symfony\Component\Debug\Tests\Fixtures\InternalTrait" trait is considered internal. It may change without further notice. You should not use it from "Test\Symfony\Component\Debug\Tests\ExtendsInternals".', - 'The "Symfony\Component\Debug\Tests\Fixtures\InternalTrait2::internalMethod()" method is considered internal. It may change without further notice. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsInternals".', + 'The "Symfony\Component\Debug\Tests\Fixtures\InternalClass::internalMethod()" method is considered internal. It may change without further notice. You should not extend it from "Test\Symfony\Component\Debug\Tests\ExtendsInternals".', )); } + + public function testUseTraitWithInternalMethod() + { + $deprecations = array(); + set_error_handler(function ($type, $msg) use (&$deprecations) { $deprecations[] = $msg; }); + $e = error_reporting(E_USER_DEPRECATED); + + class_exists('Test\\'.__NAMESPACE__.'\\UseTraitWithInternalMethod', true); + + error_reporting($e); + restore_error_handler(); + + $this->assertSame(array(), $deprecations); + } } class ClassLoader @@ -328,6 +339,8 @@ public function internalMethod() { } }'); } elseif ('Test\\'.__NAMESPACE__.'\ExtendsInternalsParent' === $class) { eval('namespace Test\\'.__NAMESPACE__.'; class ExtendsInternalsParent extends \\'.__NAMESPACE__.'\Fixtures\InternalClass implements \\'.__NAMESPACE__.'\Fixtures\InternalInterface { }'); + } elseif ('Test\\'.__NAMESPACE__.'\UseTraitWithInternalMethod' === $class) { + eval('namespace Test\\'.__NAMESPACE__.'; class UseTraitWithInternalMethod { use \\'.__NAMESPACE__.'\Fixtures\TraitWithInternalMethod; }'); } } } diff --git a/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php index 739e5b2b15b7d..a2647f57f201a 100644 --- a/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedMethodFatalErrorHandlerTest.php @@ -64,10 +64,10 @@ public function provideUndefinedMethodData() ), array( array( - 'type' => 1, - 'message' => 'Call to undefined method class@anonymous::test()', - 'file' => '/home/possum/work/symfony/test.php', - 'line' => 11, + 'type' => 1, + 'message' => 'Call to undefined method class@anonymous::test()', + 'file' => '/home/possum/work/symfony/test.php', + 'line' => 11, ), 'Attempted to call an undefined method named "test" of class "class@anonymous".', ), diff --git a/src/Symfony/Component/Debug/Tests/Fixtures/ExtendedFinalMethod.php b/src/Symfony/Component/Debug/Tests/Fixtures/ExtendedFinalMethod.php index 2bd337e5a2db0..050d19ff5e720 100644 --- a/src/Symfony/Component/Debug/Tests/Fixtures/ExtendedFinalMethod.php +++ b/src/Symfony/Component/Debug/Tests/Fixtures/ExtendedFinalMethod.php @@ -4,6 +4,8 @@ class ExtendedFinalMethod extends FinalMethod { + use FinalMethod2Trait; + /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Debug/Tests/Fixtures/FinalMethod.php b/src/Symfony/Component/Debug/Tests/Fixtures/FinalMethod.php index d8c673a5c51b0..03e47e8a7aada 100644 --- a/src/Symfony/Component/Debug/Tests/Fixtures/FinalMethod.php +++ b/src/Symfony/Component/Debug/Tests/Fixtures/FinalMethod.php @@ -11,6 +11,13 @@ public function finalMethod() { } + /** + * @final + */ + public function finalMethod2() + { + } + public function anotherMethod() { } diff --git a/src/Symfony/Component/Debug/Tests/Fixtures/FinalMethod2Trait.php b/src/Symfony/Component/Debug/Tests/Fixtures/FinalMethod2Trait.php new file mode 100644 index 0000000000000..8547f3afed7ab --- /dev/null +++ b/src/Symfony/Component/Debug/Tests/Fixtures/FinalMethod2Trait.php @@ -0,0 +1,10 @@ + --EXPECTF-- The "Symfony\Component\Debug\Tests\Fixtures\FinalMethod::finalMethod()" method is considered final. It may change without further notice as of its next major version. You should not extend it from "Symfony\Component\Debug\Tests\Fixtures\ExtendedFinalMethod". +The "Symfony\Component\Debug\Tests\Fixtures\FinalMethod::finalMethod2()" method is considered final. It may change without further notice as of its next major version. You should not extend it from "Symfony\Component\Debug\Tests\Fixtures\ExtendedFinalMethod". diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php index 27f2c21adb3ce..38a172074d92c 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AnalyzeServiceReferencesPass.php @@ -113,6 +113,8 @@ protected function processValue($value, $isRoot = false) return $value; } $this->currentDefinition = $value; + } elseif ($this->currentDefinition === $value) { + return $value; } $this->lazy = false; diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php index 7cf4f4a6e2f58..a3ada1ddcfde8 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckDefinitionValidityPass.php @@ -66,13 +66,7 @@ public function process(ContainerBuilder $container) )); } - throw new RuntimeException(sprintf( - 'The definition for "%s" has no class. If you intend to inject ' - .'this service dynamically at runtime, please mark it as synthetic=true. ' - .'If this is an abstract definition solely used by child definitions, ' - .'please add abstract=true, otherwise specify a class to get rid of this error.', - $id - )); + throw new RuntimeException(sprintf('The definition for "%s" has no class. If you intend to inject this service dynamically at runtime, please mark it as synthetic=true. If this is an abstract definition solely used by child definitions, please add abstract=true, otherwise specify a class to get rid of this error.', $id)); } // tag attribute values must be scalars diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php index 323dc6f28783c..8f2a3bdf706cf 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php @@ -34,12 +34,7 @@ protected function processValue($value, $isRoot = false) $targetDefinition = $this->container->getDefinition((string) $value); if ($targetDefinition->isAbstract()) { - throw new RuntimeException(sprintf( - 'The definition "%s" has a reference to an abstract definition "%s". ' - .'Abstract definitions cannot be the target of references.', - $this->currentId, - $value - )); + throw new RuntimeException(sprintf('The definition "%s" has a reference to an abstract definition "%s". Abstract definitions cannot be the target of references.', $this->currentId, $value)); } } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveChildDefinitionsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveChildDefinitionsPass.php index 11414811b2878..ac6687c36a109 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveChildDefinitionsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveChildDefinitionsPass.php @@ -15,6 +15,7 @@ use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Exception\ExceptionInterface; use Symfony\Component\DependencyInjection\Exception\RuntimeException; +use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException; /** * This replaces all ChildDefinition instances with their equivalent fully @@ -25,6 +26,8 @@ */ class ResolveChildDefinitionsPass extends AbstractRecursivePass { + private $currentPath; + protected function processValue($value, $isRoot = false) { if (!$value instanceof Definition) { @@ -36,6 +39,7 @@ protected function processValue($value, $isRoot = false) $value = $this->container->getDefinition($this->currentId); } if ($value instanceof ChildDefinition) { + $this->currentPath = array(); $value = $this->resolveDefinition($value); if ($isRoot) { $this->container->setDefinition($this->currentId, $value); @@ -56,6 +60,8 @@ private function resolveDefinition(ChildDefinition $definition) { try { return $this->doResolveDefinition($definition); + } catch (ServiceCircularReferenceException $e) { + throw $e; } catch (ExceptionInterface $e) { $r = new \ReflectionProperty($e, 'message'); $r->setAccessible(true); @@ -71,6 +77,13 @@ private function doResolveDefinition(ChildDefinition $definition) throw new RuntimeException(sprintf('Parent definition "%s" does not exist.', $parent)); } + $searchKey = array_search($parent, $this->currentPath); + $this->currentPath[] = $parent; + + if (false !== $searchKey) { + throw new ServiceCircularReferenceException($parent, \array_slice($this->currentPath, $searchKey)); + } + $parentDef = $this->container->findDefinition($parent); if ($parentDef instanceof ChildDefinition) { $id = $this->currentId; diff --git a/src/Symfony/Component/DependencyInjection/ContainerAwareInterface.php b/src/Symfony/Component/DependencyInjection/ContainerAwareInterface.php index d78491bb96335..e7b9d575ece50 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerAwareInterface.php +++ b/src/Symfony/Component/DependencyInjection/ContainerAwareInterface.php @@ -18,5 +18,8 @@ */ interface ContainerAwareInterface { + /** + * Sets the container. + */ public function setContainer(ContainerInterface $container = null); } diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 080b5de005f57..13d94e44c7e40 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -616,10 +616,10 @@ private function doGet($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_ * the parameters passed to the container constructor to have precedence * over the loaded ones. * - * $container = new ContainerBuilder(new ParameterBag(array('foo' => 'bar'))); - * $loader = new LoaderXXX($container); - * $loader->load('resource_name'); - * $container->register('foo', 'stdClass'); + * $container = new ContainerBuilder(new ParameterBag(array('foo' => 'bar'))); + * $loader = new LoaderXXX($container); + * $loader->load('resource_name'); + * $container->register('foo', 'stdClass'); * * In the above example, even if the loaded resource defines a foo * parameter, the value will still be 'bar' as defined in the ContainerBuilder @@ -1243,14 +1243,14 @@ private function doResolveServices($value, array &$inlineServices = array(), $is * * Example: * - * $container->register('foo')->addTag('my.tag', array('hello' => 'world')); + * $container->register('foo')->addTag('my.tag', array('hello' => 'world')); * - * $serviceIds = $container->findTaggedServiceIds('my.tag'); - * foreach ($serviceIds as $serviceId => $tags) { - * foreach ($tags as $tag) { - * echo $tag['hello']; + * $serviceIds = $container->findTaggedServiceIds('my.tag'); + * foreach ($serviceIds as $serviceId => $tags) { + * foreach ($tags as $tag) { + * echo $tag['hello']; + * } * } - * } * * @param string $name * @param bool $throwOnAbstract diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index e4d5db251b311..3a1bc9c37d301 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -115,7 +115,7 @@ public function setFactory($factory) /** * Gets the factory. * - * @return string|array The PHP function or an array containing a class/Reference and a method to call + * @return string|array|null The PHP function or an array containing a class/Reference and a method to call */ public function getFactory() { diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index f37641030a4da..c90d3f61e2984 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -56,7 +56,9 @@ class PhpDumper extends Dumper private $definitionVariables; private $referenceVariables; private $variableCount; - private $reservedVariables = array('instance', 'class'); + private $inlinedDefinitions; + private $serviceCalls; + private $reservedVariables = array('instance', 'class', 'this'); private $expressionLanguage; private $targetDirRegex; private $targetDirMaxMatches; @@ -153,7 +155,7 @@ public function dump(array $options = array()) } } - (new AnalyzeServiceReferencesPass(false, !$this->getProxyDumper() instanceof NullDumper))->process($this->container); + (new AnalyzeServiceReferencesPass(false))->process($this->container); $this->circularReferences = array(); $checkedNodes = array(); foreach ($this->container->getCompiler()->getServiceReferenceGraph()->getNodes() as $id => $node) { @@ -301,59 +303,6 @@ private function getProxyDumper(): ProxyDumper return $this->proxyDumper; } - private function addServiceLocalTempVariables(string $cId, Definition $definition, \SplObjectStorage $inlinedDefinitions, array $serviceCalls, bool $preInstance = false): string - { - $calls = array(); - - foreach ($inlinedDefinitions as $def) { - if ($preInstance && !$inlinedDefinitions[$def][1]) { - continue; - } - $this->getServiceCallsFromArguments(array($def->getArguments(), $def->getFactory()), $calls, $preInstance, $cId); - if ($def !== $definition) { - $arguments = array($def->getProperties(), $def->getMethodCalls(), $def->getConfigurator()); - $this->getServiceCallsFromArguments($arguments, $calls, $preInstance && !$this->hasReference($cId, $arguments, true), $cId); - } - } - if (!isset($inlinedDefinitions[$definition])) { - $arguments = array($definition->getProperties(), $definition->getMethodCalls(), $definition->getConfigurator()); - $this->getServiceCallsFromArguments($arguments, $calls, false, $cId); - } - - $code = ''; - foreach ($calls as $id => list($callCount)) { - if ('service_container' === $id || $id === $cId || isset($this->referenceVariables[$id])) { - continue; - } - if ($callCount <= 1 && $serviceCalls[$id][0] <= 1) { - continue; - } - - $name = $this->getNextVariableName(); - $this->referenceVariables[$id] = new Variable($name); - - $reference = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE >= $serviceCalls[$id][1] ? new Reference($id, $serviceCalls[$id][1]) : null; - $code .= sprintf(" \$%s = %s;\n", $name, $this->getServiceCall($id, $reference)); - } - - if ('' !== $code) { - if ($preInstance) { - $code .= sprintf(<<<'EOTXT' - - if (isset($this->%s['%s'])) { - return $this->%1$s['%2$s']; - } - -EOTXT - , $definition->isPublic() ? 'services' : 'privates', $cId); - } - - $code .= "\n"; - } - - return $code; - } - private function analyzeCircularReferences(array $edges, &$checkedNodes, &$currentPath) { foreach ($edges as $edge) { @@ -433,19 +382,19 @@ private function generateProxyClasses() } } - private function addServiceInclude(string $cId, Definition $definition, \SplObjectStorage $inlinedDefinitions, array $serviceCalls): string + private function addServiceInclude(string $cId, Definition $definition): string { $code = ''; if ($this->inlineRequires && !$this->isHotPath($definition)) { $lineage = array(); - foreach ($inlinedDefinitions as $def) { + foreach ($this->inlinedDefinitions as $def) { if (!$def->isDeprecated() && \is_string($class = \is_array($factory = $def->getFactory()) && \is_string($factory[0]) ? $factory[0] : $def->getClass())) { $this->collectLineage($class, $lineage); } } - foreach ($serviceCalls as $id => list($callCount, $behavior)) { + foreach ($this->serviceCalls as $id => list($callCount, $behavior)) { if ('service_container' !== $id && $id !== $cId && ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE !== $behavior && $this->container->has($id) @@ -461,7 +410,7 @@ private function addServiceInclude(string $cId, Definition $definition, \SplObje } } - foreach ($inlinedDefinitions as $def) { + foreach ($this->inlinedDefinitions as $def) { if ($file = $def->getFile()) { $code .= sprintf(" include_once %s;\n", $this->dumpValue($file)); } @@ -474,57 +423,6 @@ private function addServiceInclude(string $cId, Definition $definition, \SplObje return $code; } - /** - * Generates the inline definition of a service. - * - * @throws RuntimeException When the factory definition is incomplete - * @throws ServiceCircularReferenceException When a circular reference is detected - */ - private function addServiceInlinedDefinitions(string $id, Definition $definition, \SplObjectStorage $inlinedDefinitions, bool &$isSimpleInstance, bool $preInstance = false): string - { - $code = ''; - - foreach ($inlinedDefinitions as $def) { - if ($definition === $def || isset($this->definitionVariables[$def])) { - continue; - } - if ($inlinedDefinitions[$def][0] <= 1 && !$def->getMethodCalls() && !$def->getProperties() && !$def->getConfigurator() && false === strpos($this->dumpValue($def->getClass()), '$')) { - continue; - } - if ($preInstance && !$inlinedDefinitions[$def][1]) { - continue; - } - - $name = $this->getNextVariableName(); - $this->definitionVariables[$def] = new Variable($name); - - // a construct like: - // $a = new ServiceA(ServiceB $b); $b = new ServiceB(ServiceA $a); - // this is an indication for a wrong implementation, you can circumvent this problem - // by setting up your service structure like this: - // $b = new ServiceB(); - // $a = new ServiceA(ServiceB $b); - // $b->setServiceA(ServiceA $a); - if (isset($inlinedDefinitions[$definition]) && $this->hasReference($id, array($def->getArguments(), $def->getFactory()))) { - throw new ServiceCircularReferenceException($id, array($id, '...', $id)); - } - - $code .= $this->addNewInstance($def, '$'.$name, ' = ', $id); - - if (!$this->hasReference($id, array($def->getProperties(), $def->getMethodCalls(), $def->getConfigurator()), true)) { - $code .= $this->addServiceProperties($def, $name); - $code .= $this->addServiceMethodCalls($def, $name); - $code .= $this->addServiceConfigurator($def, $name); - } else { - $isSimpleInstance = false; - } - - $code .= "\n"; - } - - return $code; - } - /** * @throws InvalidArgumentException * @throws RuntimeException @@ -553,14 +451,7 @@ private function addServiceInstance(string $id, Definition $definition, string $ $instantiation .= ' = '; } - $code = $this->addNewInstance($definition, $return, $instantiation, $id); - $this->referenceVariables[$id] = new Variable('instance'); - - if (!$isSimpleInstance) { - $code .= "\n"; - } - - return $code; + return $this->addNewInstance($definition, $return, $instantiation, $id); } private function isTrivialInstance(Definition $definition): bool @@ -620,7 +511,7 @@ private function addServiceMethodCalls(Definition $definition, string $variableN return $calls; } - private function addServiceProperties(Definition $definition, $variableName = 'instance') + private function addServiceProperties(Definition $definition, string $variableName = 'instance') { $code = ''; foreach ($definition->getProperties() as $name => $value) { @@ -630,36 +521,6 @@ private function addServiceProperties(Definition $definition, $variableName = 'i return $code; } - /** - * @throws ServiceCircularReferenceException when the container contains a circular reference - */ - private function addServiceInlinedDefinitionsSetup(string $id, Definition $definition, \SplObjectStorage $inlinedDefinitions, bool $isSimpleInstance): string - { - $code = ''; - foreach ($inlinedDefinitions as $def) { - if ($definition === $def || !$this->hasReference($id, array($def->getProperties(), $def->getMethodCalls(), $def->getConfigurator()), true)) { - continue; - } - - // if the instance is simple, the return statement has already been generated - // so, the only possible way to get there is because of a circular reference - if ($isSimpleInstance) { - throw new ServiceCircularReferenceException($id, array($id, '...', $id)); - } - - $name = (string) $this->definitionVariables[$def]; - $code .= $this->addServiceProperties($def, $name); - $code .= $this->addServiceMethodCalls($def, $name); - $code .= $this->addServiceConfigurator($def, $name); - } - - if ('' !== $code && ($definition->getProperties() || $definition->getMethodCalls() || $definition->getConfigurator())) { - $code .= "\n"; - } - - return $code; - } - private function addServiceConfigurator(Definition $definition, string $variableName = 'instance'): string { if (!$callable = $definition->getConfigurator()) { @@ -693,6 +554,7 @@ private function addService(string $id, Definition $definition, string &$file = $this->definitionVariables = new \SplObjectStorage(); $this->referenceVariables = array(); $this->variableCount = 0; + $this->definitionVariables[$definition] = $this->referenceVariables[$id] = new Variable('instance'); $return = array(); @@ -758,25 +620,10 @@ protected function {$methodName}($lazyInitialization) return $asFile ? substr($code, 8).$e : $code.' '.$e." }\n"; } - $inlinedDefinitions = $this->getDefinitionsFromArguments(array($definition)); - $constructorDefinitions = $this->getDefinitionsFromArguments(array($definition->getArguments(), $definition->getFactory())); - $otherDefinitions = new \SplObjectStorage(); - $serviceCalls = array(); - - foreach ($inlinedDefinitions as $def) { - if ($def === $definition || isset($constructorDefinitions[$def])) { - $constructorDefinitions[$def] = $inlinedDefinitions[$def]; - } else { - $otherDefinitions[$def] = $inlinedDefinitions[$def]; - } - $arguments = array($def->getArguments(), $def->getFactory(), $def->getProperties(), $def->getMethodCalls(), $def->getConfigurator()); - $this->getServiceCallsFromArguments($arguments, $serviceCalls, false, $id); - } - - $isSimpleInstance = !$definition->getProperties() && !$definition->getMethodCalls() && !$definition->getConfigurator(); - $preInstance = isset($this->circularReferences[$id]) && !$this->getProxyDumper()->isProxyCandidate($definition) && $definition->isShared(); + $this->serviceCalls = array(); + $this->inlinedDefinitions = $this->getDefinitionsFromArguments(array($definition), null, $this->serviceCalls); - $code .= $this->addServiceInclude($id, $definition, $inlinedDefinitions, $serviceCalls); + $code .= $this->addServiceInclude($id, $definition); if ($this->getProxyDumper()->isProxyCandidate($definition)) { $factoryCode = $asFile ? "\$this->load('%s.php', false)" : '$this->%s(false)'; @@ -787,20 +634,22 @@ protected function {$methodName}($lazyInitialization) $code .= sprintf(" @trigger_error(%s, E_USER_DEPRECATED);\n\n", $this->export($definition->getDeprecationMessage($id))); } - $code .= - $this->addServiceLocalTempVariables($id, $definition, $constructorDefinitions, $serviceCalls, $preInstance). - $this->addServiceInlinedDefinitions($id, $definition, $constructorDefinitions, $isSimpleInstance, $preInstance). - $this->addServiceInstance($id, $definition, $isSimpleInstance). - $this->addServiceLocalTempVariables($id, $definition, $constructorDefinitions->offsetUnset($definition) ?: $constructorDefinitions, $serviceCalls). - $this->addServiceLocalTempVariables($id, $definition, $otherDefinitions, $serviceCalls). - $this->addServiceInlinedDefinitions($id, $definition, $constructorDefinitions, $isSimpleInstance). - $this->addServiceInlinedDefinitions($id, $definition, $otherDefinitions, $isSimpleInstance). - $this->addServiceInlinedDefinitionsSetup($id, $definition, $inlinedDefinitions, $isSimpleInstance). - $this->addServiceProperties($definition). - $this->addServiceMethodCalls($definition). - $this->addServiceConfigurator($definition). - (!$isSimpleInstance ? "\n return \$instance;\n" : '') - ; + $head = $tail = ''; + $arguments = array($definition->getArguments(), $definition->getFactory()); + $this->addInlineVariables($head, $tail, $id, $arguments, true); + $code .= '' !== $head ? $head."\n" : ''; + + if ($arguments = array_filter(array($definition->getProperties(), $definition->getMethodCalls(), $definition->getConfigurator()))) { + $this->addInlineVariables($tail, $tail, $id, $arguments, false); + + $tail .= '' !== $tail ? "\n" : ''; + $tail .= $this->addServiceProperties($definition); + $tail .= $this->addServiceMethodCalls($definition); + $tail .= $this->addServiceConfigurator($definition); + } + + $code .= $this->addServiceInstance($id, $definition, '' === $tail) + .('' !== $tail ? "\n".$tail."\n return \$instance;\n" : ''); if ($asFile) { $code = implode("\n", array_map(function ($line) { return $line ? substr($line, 8) : $line; }, explode("\n", $code))); @@ -808,12 +657,108 @@ protected function {$methodName}($lazyInitialization) $code .= " }\n"; } - $this->definitionVariables = null; - $this->referenceVariables = null; + $this->definitionVariables = $this->inlinedDefinitions = null; + $this->referenceVariables = $this->serviceCalls = null; return $code; } + private function addInlineVariables(string &$head, string &$tail, string $id, array $arguments, bool $forConstructor): bool + { + $hasSelfRef = false; + + foreach ($arguments as $argument) { + if (\is_array($argument)) { + $hasSelfRef = $this->addInlineVariables($head, $tail, $id, $argument, $forConstructor) || $hasSelfRef; + } elseif ($argument instanceof Reference) { + $hasSelfRef = $this->addInlineReference($head, $tail, $id, $argument, $forConstructor) || $hasSelfRef; + } elseif ($argument instanceof Definition) { + $hasSelfRef = $this->addInlineService($head, $tail, $id, $argument, $forConstructor) || $hasSelfRef; + } + } + + return $hasSelfRef; + } + + private function addInlineReference(string &$head, string &$tail, string $id, string $targetId, bool $forConstructor): bool + { + if ('service_container' === $targetId || isset($this->referenceVariables[$targetId])) { + return isset($this->circularReferences[$id][$targetId]); + } + + list($callCount, $behavior) = $this->serviceCalls[$targetId]; + + if (2 > $callCount && (!$forConstructor || !isset($this->circularReferences[$id][$targetId]))) { + return isset($this->circularReferences[$id][$targetId]); + } + + $name = $this->getNextVariableName(); + $this->referenceVariables[$targetId] = new Variable($name); + + $reference = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE >= $behavior ? new Reference($targetId, $behavior) : null; + $code = sprintf(" \$%s = %s;\n", $name, $this->getServiceCall($targetId, $reference)); + + if (!isset($this->circularReferences[$id][$targetId])) { + $head .= $code; + + return false; + } + + if (!$forConstructor) { + $tail .= $code; + + return true; + } + + $head .= $code.sprintf(<<<'EOTXT' + + if (isset($this->%s['%s'])) { + return $this->%1$s['%2$s']; + } + +EOTXT + , + $this->container->getDefinition($id)->isPublic() ? 'services' : 'privates', + $id + ); + + return false; + } + + private function addInlineService(string &$head, string &$tail, string $id, Definition $definition, bool $forConstructor): bool + { + if (isset($this->definitionVariables[$definition])) { + return false; + } + + $arguments = array($definition->getArguments(), $definition->getFactory()); + + if (2 > $this->inlinedDefinitions[$definition] && !$definition->getMethodCalls() && !$definition->getProperties() && !$definition->getConfigurator() && false === strpos($this->dumpValue($definition->getClass()), '$')) { + return $this->addInlineVariables($head, $tail, $id, $arguments, $forConstructor); + } + + $name = $this->getNextVariableName(); + $this->definitionVariables[$definition] = new Variable($name); + + $code = ''; + $hasSelfRef = $this->addInlineVariables($code, $tail, $id, $arguments, $forConstructor); + $code .= $this->addNewInstance($definition, '$'.$name, ' = ', $id); + $hasSelfRef ? $tail .= ('' !== $tail ? "\n" : '').$code : $head .= ('' !== $head ? "\n" : '').$code; + + $code = ''; + $arguments = array($definition->getProperties(), $definition->getMethodCalls(), $definition->getConfigurator()); + $hasSelfRef = $this->addInlineVariables($code, $tail, $id, $arguments, false) || $hasSelfRef; + + $code .= $this->addServiceProperties($definition, $name); + $code .= $this->addServiceMethodCalls($definition, $name); + $code .= $this->addServiceConfigurator($definition, $name); + if ('' !== $code) { + $hasSelfRef ? $tail .= ('' !== $tail ? "\n" : '').$code : $head .= $code; + } + + return $hasSelfRef; + } + private function addServices(): string { $publicServices = $privateServices = ''; @@ -1076,6 +1021,9 @@ private function addRemovedIds(): string $ids = array_keys($ids); sort($ids); foreach ($ids as $id) { + if (preg_match('/^\.\d+_[^~]++~[._a-zA-Z\d]{7}$/', $id)) { + continue; + } $code .= ' '.$this->doExport($id)." => true,\n"; } @@ -1373,102 +1321,39 @@ private function getServiceConditionals($value): string return implode(' && ', $conditions); } - private function getServiceCallsFromArguments(array $arguments, array &$calls, bool $preInstance, string $callerId) + private function getDefinitionsFromArguments(array $arguments, \SplObjectStorage $definitions = null, array &$calls = array()): \SplObjectStorage { + if (null === $definitions) { + $definitions = new \SplObjectStorage(); + } + foreach ($arguments as $argument) { if (\is_array($argument)) { - $this->getServiceCallsFromArguments($argument, $calls, $preInstance, $callerId); + $this->getDefinitionsFromArguments($argument, $definitions, $calls); } elseif ($argument instanceof Reference) { $id = (string) $argument; if (!isset($calls[$id])) { - $calls[$id] = array((int) ($preInstance && isset($this->circularReferences[$callerId][$id])), $argument->getInvalidBehavior()); + $calls[$id] = array(0, $argument->getInvalidBehavior()); } else { $calls[$id][1] = min($calls[$id][1], $argument->getInvalidBehavior()); } ++$calls[$id][0]; - } - } - } - - private function getDefinitionsFromArguments(array $arguments, bool $isConstructorArgument = true, \SplObjectStorage $definitions = null): \SplObjectStorage - { - if (null === $definitions) { - $definitions = new \SplObjectStorage(); - } - - foreach ($arguments as $argument) { - if (\is_array($argument)) { - $this->getDefinitionsFromArguments($argument, $isConstructorArgument, $definitions); } elseif (!$argument instanceof Definition) { // no-op } elseif (isset($definitions[$argument])) { - $def = $definitions[$argument]; - $definitions[$argument] = array(1 + $def[0], $isConstructorArgument || $def[1]); + $definitions[$argument] = 1 + $definitions[$argument]; } else { - $definitions[$argument] = array(1, $isConstructorArgument); - $this->getDefinitionsFromArguments($argument->getArguments(), $isConstructorArgument, $definitions); - $this->getDefinitionsFromArguments(array($argument->getFactory()), $isConstructorArgument, $definitions); - $this->getDefinitionsFromArguments($argument->getProperties(), false, $definitions); - $this->getDefinitionsFromArguments($argument->getMethodCalls(), false, $definitions); - $this->getDefinitionsFromArguments(array($argument->getConfigurator()), false, $definitions); - // move current definition last in the list - $def = $definitions[$argument]; - unset($definitions[$argument]); - $definitions[$argument] = $def; + $definitions[$argument] = 1; + $arguments = array($argument->getArguments(), $argument->getFactory(), $argument->getProperties(), $argument->getMethodCalls(), $argument->getConfigurator()); + $this->getDefinitionsFromArguments($arguments, $definitions, $calls); } } return $definitions; } - private function hasReference(string $id, array $arguments, bool $deep = false, array &$visited = array()): bool - { - if (!isset($this->circularReferences[$id])) { - return false; - } - - foreach ($arguments as $argument) { - if (\is_array($argument)) { - if ($this->hasReference($id, $argument, $deep, $visited)) { - return true; - } - - continue; - } elseif ($argument instanceof Reference) { - $argumentId = (string) $argument; - if ($id === $argumentId) { - return true; - } - - if (!$deep || isset($visited[$argumentId]) || !isset($this->circularReferences[$argumentId])) { - continue; - } - - $visited[$argumentId] = true; - - $service = $this->container->getDefinition($argumentId); - } elseif ($argument instanceof Definition) { - $service = $argument; - } else { - continue; - } - - // if the proxy manager is enabled, disable searching for references in lazy services, - // as these services will be instantiated lazily and don't have direct related references. - if ($service->isLazy() && !$this->getProxyDumper() instanceof NullDumper) { - continue; - } - - if ($this->hasReference($id, array($service->getArguments(), $service->getFactory(), $service->getProperties(), $service->getMethodCalls(), $service->getConfigurator()), $deep, $visited)) { - return true; - } - } - - return false; - } - /** * @throws RuntimeException */ @@ -1485,7 +1370,7 @@ private function dumpValue($value, bool $interpolate = true): string return sprintf('array(%s)', implode(', ', $code)); } elseif ($value instanceof ArgumentInterface) { - $scope = array($this->definitionVariables, $this->referenceVariables, $this->variableCount); + $scope = array($this->definitionVariables, $this->referenceVariables); $this->definitionVariables = $this->referenceVariables = null; try { @@ -1533,7 +1418,7 @@ private function dumpValue($value, bool $interpolate = true): string return implode("\n", $code); } } finally { - list($this->definitionVariables, $this->referenceVariables, $this->variableCount) = $scope; + list($this->definitionVariables, $this->referenceVariables) = $scope; } } elseif ($value instanceof Definition) { if (null !== $this->definitionVariables && $this->definitionVariables->contains($value)) { diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index 55cd003b0ad74..1c5cd194bec2b 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -399,7 +399,7 @@ private function processAnonymousServices(\DOMDocument $xml, $file, $defaults) { $definitions = array(); $count = 0; - $suffix = ContainerBuilder::hash($file); + $suffix = '~'.ContainerBuilder::hash($file); $xpath = new \DOMXPath($xml); $xpath->registerNamespace('container', self::NS); @@ -409,7 +409,7 @@ private function processAnonymousServices(\DOMDocument $xml, $file, $defaults) foreach ($nodes as $node) { if ($services = $this->getChildren($node, 'service')) { // give it a unique name - $id = sprintf('.%d_%s', ++$count, preg_replace('/^.*\\\\/', '', $services[0]->getAttribute('class')).'~'.$suffix); + $id = sprintf('.%d_%s', ++$count, preg_replace('/^.*\\\\/', '', $services[0]->getAttribute('class')).$suffix); $node->setAttribute('id', $id); $node->setAttribute('service', $id); @@ -669,13 +669,7 @@ private function validateExtensions(\DOMDocument $dom, $file) // can it be handled by an extension? if (!$this->container->hasExtension($node->namespaceURI)) { $extensionNamespaces = array_filter(array_map(function (ExtensionInterface $ext) { return $ext->getNamespace(); }, $this->container->getExtensions())); - throw new InvalidArgumentException(sprintf( - 'There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s', - $node->tagName, - $file, - $node->namespaceURI, - $extensionNamespaces ? sprintf('"%s"', implode('", "', $extensionNamespaces)) : 'none' - )); + throw new InvalidArgumentException(sprintf('There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s', $node->tagName, $file, $node->namespaceURI, $extensionNamespaces ? sprintf('"%s"', implode('", "', $extensionNamespaces)) : 'none')); } } } diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index 07273d9089a88..63e7385d81898 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -142,7 +142,7 @@ public function load($resource, $type = null) // services $this->anonymousServicesCount = 0; - $this->anonymousServicesSuffix = ContainerBuilder::hash($path); + $this->anonymousServicesSuffix = '~'.ContainerBuilder::hash($path); $this->setCurrentDir(\dirname($path)); try { $this->parseDefinitions($content, $path); @@ -654,13 +654,7 @@ private function validate($content, $file) if (!$this->container->hasExtension($namespace)) { $extensionNamespaces = array_filter(array_map(function (ExtensionInterface $ext) { return $ext->getAlias(); }, $this->container->getExtensions())); - throw new InvalidArgumentException(sprintf( - 'There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s', - $namespace, - $file, - $namespace, - $extensionNamespaces ? sprintf('"%s"', implode('", "', $extensionNamespaces)) : 'none' - )); + throw new InvalidArgumentException(sprintf('There is no extension able to load the configuration for "%s" (in %s). Looked for namespace "%s", found %s', $namespace, $file, $namespace, $extensionNamespaces ? sprintf('"%s"', implode('", "', $extensionNamespaces)) : 'none')); } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php index cf011b43e3b85..a1630691eadae 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveChildDefinitionsPassTest.php @@ -396,4 +396,21 @@ protected function process(ContainerBuilder $container) $pass = new ResolveChildDefinitionsPass(); $pass->process($container); } + + /** + * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException + * @expectedExceptionMessageRegExp /^Circular reference detected for service "c", path: "c -> b -> a -> c"./ + */ + public function testProcessDetectsChildDefinitionIndirectCircularReference() + { + $container = new ContainerBuilder(); + + $container->register('a'); + + $container->setDefinition('b', new ChildDefinition('a')); + $container->setDefinition('c', new ChildDefinition('b')); + $container->setDefinition('a', new ChildDefinition('c')); + + $this->process($container); + } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index f6fa62fc31ecd..b0a5d10fbeb7f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -1476,6 +1476,22 @@ public function testErroredDefinition() $container->get('errored_definition'); } + + public function testDecoratedSelfReferenceInvolvingPrivateServices() + { + $container = new ContainerBuilder(); + $container->register('foo', 'stdClass') + ->setPublic(false) + ->setProperty('bar', new Reference('foo')); + $container->register('baz', 'stdClass') + ->setPublic(false) + ->setProperty('inner', new Reference('baz.inner')) + ->setDecoratedService('foo'); + + $container->compile(); + + $this->assertSame(array('service_container'), array_keys($container->getDefinitions())); + } } class FooClass diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index 8d6d0781b1672..8ddb1f744dd8f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -392,8 +392,8 @@ public function testResolvedBase64EnvParameters() $container->compile(true); $expected = array( - 'env(foo)' => 'd29ybGQ=', - 'hello' => 'world', + 'env(foo)' => 'd29ybGQ=', + 'hello' => 'world', ); $this->assertSame($expected, $container->getParameterBag()->all()); } @@ -878,6 +878,28 @@ public function provideAlmostCircular() yield array('private'); } + public function testDeepServiceGraph() + { + $container = new ContainerBuilder(); + + $loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')); + $loader->load('services_deep_graph.yml'); + + $container->compile(); + + $dumper = new PhpDumper($container); + $dumper->dump(); + + $this->assertStringEqualsFile(self::$fixturesPath.'/php/services_deep_graph.php', $dumper->dump(array('class' => 'Symfony_DI_PhpDumper_Test_Deep_Graph'))); + + require self::$fixturesPath.'/php/services_deep_graph.php'; + + $container = new \Symfony_DI_PhpDumper_Test_Deep_Graph(); + + $this->assertInstanceOf(FooForDeepGraph::class, $container->get('foo')); + $this->assertEquals((object) array('p2' => (object) array('p3' => (object) array())), $container->get('foo')->bClone); + } + public function testHotPathOptimizations() { $container = include self::$fixturesPath.'/containers/container_inline_requires.php'; @@ -1026,3 +1048,14 @@ public static function getProvidedTypes() return array('rot13' => 'string'); } } + +class FooForDeepGraph +{ + public $bClone; + + public function __construct(\stdClass $a, \stdClass $b) + { + // clone to verify that $b has been fully initialized before + $this->bClone = clone $b; + } +} diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php index d6f1d6b118416..30e3c6ac1fa78 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_private.php @@ -125,6 +125,7 @@ protected function getConnectionService() $this->services['connection'] = $instance = new \stdClass($a, $b); $a->subscriber = ($this->services['subscriber'] ?? $this->getSubscriberService()); + $b->logger = ($this->services['logger'] ?? $this->getLoggerService()); return $instance; @@ -139,17 +140,19 @@ protected function getConnection2Service() { $a = new \stdClass(); - $b = new \stdClass(); + $c = new \stdClass(); - $this->services['connection2'] = $instance = new \stdClass($a, $b); + $this->services['connection2'] = $instance = new \stdClass($a, $c); - $c = ($this->services['manager2'] ?? $this->getManager2Service()); + $b = ($this->services['manager2'] ?? $this->getManager2Service()); + + $a->subscriber2 = new \stdClass($b); $d = new \stdClass($instance); - $a->subscriber2 = new \stdClass($c); - $d->handler2 = new \stdClass($c); - $b->logger2 = $d; + $d->handler2 = new \stdClass($b); + + $c->logger2 = $d; return $instance; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php index 42c09d33f5328..ac105989239f6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_almost_circular_public.php @@ -138,17 +138,11 @@ protected function getBar5Service() */ protected function getConnectionService() { - $a = ($this->services['dispatcher'] ?? $this->getDispatcherService()); - - if (isset($this->services['connection'])) { - return $this->services['connection']; - } - - $b = new \stdClass(); + $a = new \stdClass(); - $this->services['connection'] = $instance = new \stdClass($a, $b); + $this->services['connection'] = $instance = new \stdClass(($this->services['dispatcher'] ?? $this->getDispatcherService()), $a); - $b->logger = ($this->services['logger'] ?? $this->getLoggerService()); + $a->logger = ($this->services['logger'] ?? $this->getLoggerService()); return $instance; } @@ -160,20 +154,15 @@ protected function getConnectionService() */ protected function getConnection2Service() { - $a = ($this->services['dispatcher2'] ?? $this->getDispatcher2Service()); - - if (isset($this->services['connection2'])) { - return $this->services['connection2']; - } + $a = new \stdClass(); - $b = new \stdClass(); + $this->services['connection2'] = $instance = new \stdClass(($this->services['dispatcher2'] ?? $this->getDispatcher2Service()), $a); - $this->services['connection2'] = $instance = new \stdClass($a, $b); + $b = new \stdClass($instance); - $c = new \stdClass($instance); + $b->handler2 = new \stdClass(($this->services['manager2'] ?? $this->getManager2Service())); - $c->handler2 = new \stdClass(($this->services['manager2'] ?? $this->getManager2Service())); - $b->logger2 = $c; + $a->logger2 = $b; return $instance; } @@ -383,12 +372,6 @@ protected function getManager2Service() */ protected function getSubscriberService() { - $a = ($this->services['manager'] ?? $this->getManagerService()); - - if (isset($this->services['subscriber'])) { - return $this->services['subscriber']; - } - - return $this->services['subscriber'] = new \stdClass($a); + return $this->services['subscriber'] = new \stdClass(($this->services['manager'] ?? $this->getManagerService())); } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deep_graph.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deep_graph.php new file mode 100644 index 0000000000000..4d9b68ee00024 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_deep_graph.php @@ -0,0 +1,96 @@ +services = $this->privates = array(); + $this->methodMap = array( + 'bar' => 'getBarService', + 'foo' => 'getFooService', + ); + + $this->aliases = array(); + } + + public function reset() + { + $this->privates = array(); + parent::reset(); + } + + public function compile() + { + throw new LogicException('You cannot compile a dumped container that was already compiled.'); + } + + public function isCompiled() + { + return true; + } + + public function getRemovedIds() + { + return array( + 'Psr\\Container\\ContainerInterface' => true, + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, + ); + } + + /** + * Gets the public 'bar' shared service. + * + * @return \stdClass + */ + protected function getBarService() + { + $this->services['bar'] = $instance = new \stdClass(); + + $instance->p5 = new \stdClass(($this->services['foo'] ?? $this->getFooService())); + + return $instance; + } + + /** + * Gets the public 'foo' shared service. + * + * @return \Symfony\Component\DependencyInjection\Tests\Dumper\FooForDeepGraph + */ + protected function getFooService() + { + $a = ($this->services['bar'] ?? $this->getBarService()); + + if (isset($this->services['foo'])) { + return $this->services['foo']; + } + + $b = new \stdClass(); + $c = new \stdClass(); + $c->p3 = new \stdClass(); + $b->p2 = $c; + + return $this->services['foo'] = new \Symfony\Component\DependencyInjection\Tests\Dumper\FooForDeepGraph($a, $b); + } +} diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php index 7a882f4461f9a..029967067d607 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_inline_requires.php @@ -101,8 +101,8 @@ protected function getC1Service() */ protected function getC2Service() { - include_once $this->targetDirs[1].'/includes/HotPath/C3.php'; include_once $this->targetDirs[1].'/includes/HotPath/C2.php'; + include_once $this->targetDirs[1].'/includes/HotPath/C3.php'; return $this->services['Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C2'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C2(new \Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C3()); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_deep_graph.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_deep_graph.yml new file mode 100644 index 0000000000000..f16329aef7b23 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_deep_graph.yml @@ -0,0 +1,24 @@ + +services: + foo: + class: Symfony\Component\DependencyInjection\Tests\Dumper\FooForDeepGraph + public: true + arguments: + - '@bar' + - !service + class: stdClass + properties: + p2: !service + class: stdClass + properties: + p3: !service + class: stdClass + + bar: + class: stdClass + public: true + properties: + p5: !service + class: stdClass + arguments: ['@foo'] + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index f89eb40dcf8d4..0acfc05532a2c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -556,7 +556,7 @@ public function testAnonymousServices() $this->assertCount(1, $args); $this->assertInstanceOf(Reference::class, $args[0]); $this->assertTrue($container->has((string) $args[0])); - $this->assertRegExp('/^\.\d+_Bar[._A-Za-z0-9]{7}$/', (string) $args[0]); + $this->assertRegExp('/^\.\d+_Bar~[._A-Za-z0-9]{7}$/', (string) $args[0]); $anonymous = $container->getDefinition((string) $args[0]); $this->assertEquals('Bar', $anonymous->getClass()); @@ -568,7 +568,7 @@ public function testAnonymousServices() $this->assertInternalType('array', $factory); $this->assertInstanceOf(Reference::class, $factory[0]); $this->assertTrue($container->has((string) $factory[0])); - $this->assertRegExp('/^\.\d+_Quz[._A-Za-z0-9]{7}$/', (string) $factory[0]); + $this->assertRegExp('/^\.\d+_Quz~[._A-Za-z0-9]{7}$/', (string) $factory[0]); $this->assertEquals('constructFoo', $factory[1]); $anonymous = $container->getDefinition((string) $factory[0]); diff --git a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ContainerBagTest.php b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ContainerBagTest.php index a5e358dd1f213..7b9d1dc5dadc3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ContainerBagTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ContainerBagTest.php @@ -26,7 +26,7 @@ class ContainerBagTest extends TestCase /** @var ContainerBag */ private $containerBag; - public function setUp() + protected function setUp() { $this->parameterBag = new ParameterBag(array('foo' => 'value')); $this->containerBag = new ContainerBag(new Container($this->parameterBag)); diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 489737909e586..83d2369fe740a 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -626,7 +626,7 @@ public function evaluate($xpath) * * Example: * - * $crawler->filter('h1 a')->extract(array('_text', 'href')); + * $crawler->filter('h1 a')->extract(array('_text', 'href')); * * @param array $attributes An array of attributes * @@ -885,7 +885,7 @@ public function registerNamespace($prefix, $namespace) * Escaped characters are: quotes (") and apostrophe ('). * * Examples: - * + * * echo Crawler::xpathLiteral('foo " bar'); * //prints 'foo " bar' * @@ -894,7 +894,7 @@ public function registerNamespace($prefix, $namespace) * * echo Crawler::xpathLiteral('a\'b"c'); * //prints concat('a', "'", 'b"c') - * + * * * @param string $s String to be escaped * diff --git a/src/Symfony/Component/DomCrawler/FormFieldRegistry.php b/src/Symfony/Component/DomCrawler/FormFieldRegistry.php index d2acb15adac06..6398cc60693ad 100644 --- a/src/Symfony/Component/DomCrawler/FormFieldRegistry.php +++ b/src/Symfony/Component/DomCrawler/FormFieldRegistry.php @@ -186,9 +186,7 @@ private function walk(array $array, $base = '', array &$output = array()) /** * Splits a field name into segments as a web browser would do. * - * * getSegments('base[foo][3][]') = array('base', 'foo, '3', ''); - * * * @param string $name The name of the field * diff --git a/src/Symfony/Component/DomCrawler/Tests/FormTest.php b/src/Symfony/Component/DomCrawler/Tests/FormTest.php index 2f653d6c58158..29e6ac5e2687c 100644 --- a/src/Symfony/Component/DomCrawler/Tests/FormTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/FormTest.php @@ -948,12 +948,12 @@ public function testgetPhpValuesWithEmptyTextarea() { $dom = new \DOMDocument(); $dom->loadHTML(' - - - - - - '); + + + + + ' + ); $nodes = $dom->getElementsByTagName('form'); $form = new Form($nodes->item(0), 'http://example.com'); diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index be2b5f8562f2d..d9da65183731c 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -50,6 +50,10 @@ public function testCopyUnreadableFileFails() $this->markTestSkipped('This test cannot run on Windows.'); } + if (!getenv('USER') || 'root' === getenv('USER')) { + $this->markTestSkipped('This test will fail if run under superuser'); + } + $sourceFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_source_file'; $targetFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_target_file'; @@ -124,6 +128,10 @@ public function testCopyWithOverrideWithReadOnlyTargetFails() $this->markTestSkipped('This test cannot run on Windows.'); } + if (!getenv('USER') || 'root' === getenv('USER')) { + $this->markTestSkipped('This test will fail if run under superuser'); + } + $sourceFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_source_file'; $targetFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_target_file'; @@ -161,7 +169,10 @@ public function testCopyCreatesTargetDirectoryIfItDoesNotExist() */ public function testCopyForOriginUrlsAndExistingLocalFileDefaultsToCopy() { - $sourceFilePath = 'http://symfony.com/images/common/logo/logo_symfony_header.png'; + if (!\in_array('https', stream_get_wrappers())) { + $this->markTestSkipped('"https" stream wrapper is not enabled.'); + } + $sourceFilePath = 'https://symfony.com/images/common/logo/logo_symfony_header.png'; $targetFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_target_file'; file_put_contents($targetFilePath, 'TARGET FILE'); diff --git a/src/Symfony/Component/Finder/Finder.php b/src/Symfony/Component/Finder/Finder.php index 056c836d3fdbf..df8996da5992d 100644 --- a/src/Symfony/Component/Finder/Finder.php +++ b/src/Symfony/Component/Finder/Finder.php @@ -31,7 +31,7 @@ * * All methods return the current Finder object to allow easy chaining: * - * $finder = Finder::create()->files()->name('*.php')->in(__DIR__); + * $finder = Finder::create()->files()->name('*.php')->in(__DIR__); * * @author Fabien Potencier */ @@ -105,8 +105,8 @@ public function files() * * Usage: * - * $finder->depth('> 1') // the Finder will start matching at level 1. - * $finder->depth('< 3') // the Finder will descend at most 3 levels of directories below the starting point. + * $finder->depth('> 1') // the Finder will start matching at level 1. + * $finder->depth('< 3') // the Finder will descend at most 3 levels of directories below the starting point. * * @param string|int $level The depth level expression * @@ -127,10 +127,10 @@ public function depth($level) * * The date must be something that strtotime() is able to parse: * - * $finder->date('since yesterday'); - * $finder->date('until 2 days ago'); - * $finder->date('> now - 2 hours'); - * $finder->date('>= 2005-10-15'); + * $finder->date('since yesterday'); + * $finder->date('until 2 days ago'); + * $finder->date('> now - 2 hours'); + * $finder->date('>= 2005-10-15'); * * @param string $date A date range string * @@ -152,9 +152,9 @@ public function date($date) * * You can use patterns (delimited with / sign), globs or simple strings. * - * $finder->name('*.php') - * $finder->name('/\.php$/') // same as above - * $finder->name('test.php') + * $finder->name('*.php') + * $finder->name('/\.php$/') // same as above + * $finder->name('test.php') * * @param string $pattern A pattern (a regexp, a glob, or a string) * @@ -190,8 +190,8 @@ public function notName($pattern) * * Strings or PCRE patterns can be used: * - * $finder->contains('Lorem ipsum') - * $finder->contains('/Lorem ipsum/i') + * $finder->contains('Lorem ipsum') + * $finder->contains('/Lorem ipsum/i') * * @param string $pattern A pattern (string or regexp) * @@ -211,8 +211,8 @@ public function contains($pattern) * * Strings or PCRE patterns can be used: * - * $finder->notContains('Lorem ipsum') - * $finder->notContains('/Lorem ipsum/i') + * $finder->notContains('Lorem ipsum') + * $finder->notContains('/Lorem ipsum/i') * * @param string $pattern A pattern (string or regexp) * @@ -232,8 +232,8 @@ public function notContains($pattern) * * You can use patterns (delimited with / sign) or simple strings. * - * $finder->path('some/special/dir') - * $finder->path('/some\/special\/dir/') // same as above + * $finder->path('some/special/dir') + * $finder->path('/some\/special\/dir/') // same as above * * Use only / as dirname separator. * @@ -255,8 +255,8 @@ public function path($pattern) * * You can use patterns (delimited with / sign) or simple strings. * - * $finder->notPath('some/special/dir') - * $finder->notPath('/some\/special\/dir/') // same as above + * $finder->notPath('some/special/dir') + * $finder->notPath('/some\/special\/dir/') // same as above * * Use only / as dirname separator. * @@ -276,9 +276,9 @@ public function notPath($pattern) /** * Adds tests for file sizes. * - * $finder->size('> 10K'); - * $finder->size('<= 1Ki'); - * $finder->size(4); + * $finder->size('> 10K'); + * $finder->size('<= 1Ki'); + * $finder->size(4); * * @param string|int $size A size range string or an integer * @@ -589,7 +589,7 @@ public function getIterator() * * The set can be another Finder, an Iterator, an IteratorAggregate, or even a plain array. * - * @param mixed $iterator + * @param iterable $iterator * * @return $this * diff --git a/src/Symfony/Component/Finder/Glob.php b/src/Symfony/Component/Finder/Glob.php index d8df62bfea63a..27d9ce3d11938 100644 --- a/src/Symfony/Component/Finder/Glob.php +++ b/src/Symfony/Component/Finder/Glob.php @@ -14,14 +14,14 @@ /** * Glob matches globbing patterns against text. * - * if match_glob("foo.*", "foo.bar") echo "matched\n"; + * if match_glob("foo.*", "foo.bar") echo "matched\n"; * - * // prints foo.bar and foo.baz - * $regex = glob_to_regex("foo.*"); - * for (array('foo.bar', 'foo.baz', 'foo', 'bar') as $t) - * { - * if (/$regex/) echo "matched: $car\n"; - * } + * // prints foo.bar and foo.baz + * $regex = glob_to_regex("foo.*"); + * for (array('foo.bar', 'foo.baz', 'foo', 'bar') as $t) + * { + * if (/$regex/) echo "matched: $car\n"; + * } * * Glob implements glob(3) style matching that can be used to match * against text, rather than fetching names from a filesystem. diff --git a/src/Symfony/Component/Finder/Tests/Iterator/MockSplFileInfo.php b/src/Symfony/Component/Finder/Tests/Iterator/MockSplFileInfo.php index 36e6528d019b9..a5ac93a46c82f 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/MockSplFileInfo.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/MockSplFileInfo.php @@ -29,12 +29,12 @@ public function __construct($param) parent::__construct($param); } elseif (\is_array($param)) { $defaults = array( - 'name' => 'file.txt', - 'contents' => null, - 'mode' => null, - 'type' => null, - 'relativePath' => null, - 'relativePathname' => null, + 'name' => 'file.txt', + 'contents' => null, + 'mode' => null, + 'type' => null, + 'relativePath' => null, + 'relativePathname' => null, ); $defaults = array_merge($defaults, $param); parent::__construct($defaults['name']); diff --git a/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php b/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php index 8d8e10da1f8b7..15b8a1bab0e54 100644 --- a/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php +++ b/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php @@ -24,18 +24,14 @@ * * Pass the decorated factory to the constructor: * - * ```php - * $decorator = new PropertyAccessDecorator($factory); - * ``` + * $decorator = new PropertyAccessDecorator($factory); * * You can now pass property paths for generating choice values, labels, view * indices, HTML attributes and for determining the preferred choices and the * choice groups: * - * ```php - * // extract values from the $value property - * $list = $createListFromChoices($objects, 'value'); - * ``` + * // extract values from the $value property + * $list = $createListFromChoices($objects, 'value'); * * @author Bernhard Schussek */ diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ArrayToPartsTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ArrayToPartsTransformer.php index 53d4deddd379c..b09fba8532d48 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ArrayToPartsTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ArrayToPartsTransformer.php @@ -76,9 +76,7 @@ public function reverseTransform($array) return; } - throw new TransformationFailedException( - sprintf('The keys "%s" should not be empty', implode('", "', $emptyKeys) - )); + throw new TransformationFailedException(sprintf('The keys "%s" should not be empty', implode('", "', $emptyKeys))); } return $result; diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php index 60c39b6f8f655..4a547dbdceb91 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php @@ -131,9 +131,7 @@ public function reverseTransform($value) } if (\count($emptyFields) > 0) { - throw new TransformationFailedException( - sprintf('The fields "%s" should not be empty', implode('", "', $emptyFields) - )); + throw new TransformationFailedException(sprintf('The fields "%s" should not be empty', implode('", "', $emptyFields))); } if (isset($value['month']) && !ctype_digit((string) $value['month'])) { diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformer.php new file mode 100644 index 0000000000000..ed90331266443 --- /dev/null +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformer.php @@ -0,0 +1,104 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Extension\Core\DataTransformer; + +use Symfony\Component\Form\Exception\TransformationFailedException; + +/** + * @author Franz Wilding + * @author Bernhard Schussek + * @author Fred Cox + */ +class DateTimeToHtml5LocalDateTimeTransformer extends BaseDateTimeTransformer +{ + const HTML5_FORMAT = 'Y-m-d\\TH:i:s'; + + /** + * Transforms a \DateTime into a local date and time string. + * + * According to the HTML standard, the input string of a datetime-local + * input is a RFC3339 date followed by 'T', followed by a RFC3339 time. + * https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-local-date-and-time-string + * + * @param \DateTime|\DateTimeInterface $dateTime A DateTime object + * + * @return string The formatted date + * + * @throws TransformationFailedException If the given value is not an + * instance of \DateTime or \DateTimeInterface + */ + public function transform($dateTime) + { + if (null === $dateTime) { + return ''; + } + + if (!$dateTime instanceof \DateTime && !$dateTime instanceof \DateTimeInterface) { + throw new TransformationFailedException('Expected a \DateTime or \DateTimeInterface.'); + } + + if ($this->inputTimezone !== $this->outputTimezone) { + if (!$dateTime instanceof \DateTimeImmutable) { + $dateTime = clone $dateTime; + } + + $dateTime = $dateTime->setTimezone(new \DateTimeZone($this->outputTimezone)); + } + + return $dateTime->format(self::HTML5_FORMAT); + } + + /** + * Transforms a local date and time string into a \DateTime. + * + * When transforming back to DateTime the regex is slightly laxer, taking into + * account rules for parsing a local date and time string + * https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#parse-a-local-date-and-time-string + * + * @param string $dateTimeLocal Formatted string + * + * @return \DateTime Normalized date + * + * @throws TransformationFailedException If the given value is not a string, + * if the value could not be transformed + */ + public function reverseTransform($dateTimeLocal) + { + if (!\is_string($dateTimeLocal)) { + throw new TransformationFailedException('Expected a string.'); + } + + if ('' === $dateTimeLocal) { + return; + } + + if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})[T ]\d{2}:\d{2}(?::\d{2})?$/', $dateTimeLocal, $matches)) { + throw new TransformationFailedException(sprintf('The date "%s" is not a valid date.', $dateTimeLocal)); + } + + try { + $dateTime = new \DateTime($dateTimeLocal, new \DateTimeZone($this->outputTimezone)); + } catch (\Exception $e) { + throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e); + } + + if ($this->inputTimezone !== $dateTime->getTimezone()->getName()) { + $dateTime->setTimezone(new \DateTimeZone($this->inputTimezone)); + } + + if (!checkdate($matches[2], $matches[3], $matches[1])) { + throw new TransformationFailedException(sprintf('The date "%s-%s-%s" is not a valid date.', $matches[1], $matches[2], $matches[3])); + } + + return $dateTime; + } +} diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php index 4f3a944361204..45cc5c641b8b5 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php @@ -68,6 +68,10 @@ public function reverseTransform($rfc3339) return; } + if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})T\d{2}:\d{2}(?::\d{2})?(?:\.\d)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))$/', $rfc3339, $matches)) { + throw new TransformationFailedException(sprintf('The date "%s" is not a valid date.', $rfc3339)); + } + try { $dateTime = new \DateTime($rfc3339); } catch (\Exception $e) { @@ -78,15 +82,8 @@ public function reverseTransform($rfc3339) $dateTime->setTimezone(new \DateTimeZone($this->inputTimezone)); } - if (preg_match('/(\d{4})-(\d{2})-(\d{2})/', $rfc3339, $matches)) { - if (!checkdate($matches[2], $matches[3], $matches[1])) { - throw new TransformationFailedException(sprintf( - 'The date "%s-%s-%s" is not a valid date.', - $matches[1], - $matches[2], - $matches[3] - )); - } + if (!checkdate($matches[2], $matches[3], $matches[1])) { + throw new TransformationFailedException(sprintf('The date "%s-%s-%s" is not a valid date.', $matches[1], $matches[2], $matches[3])); } return $dateTime; diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php index 16e776b9ea8ed..c82de94f5b8ac 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php @@ -122,12 +122,7 @@ public function reverseTransform($value) $lastErrors = \DateTime::getLastErrors(); if (0 < $lastErrors['warning_count'] || 0 < $lastErrors['error_count']) { - throw new TransformationFailedException( - implode(', ', array_merge( - array_values($lastErrors['warnings']), - array_values($lastErrors['errors']) - )) - ); + throw new TransformationFailedException(implode(', ', array_merge(array_values($lastErrors['warnings']), array_values($lastErrors['errors'])))); } try { diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php index 84df5ba7b60e7..09c77deaf2aa8 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php @@ -201,9 +201,7 @@ public function reverseTransform($value) $remainder = trim($remainder, " \t\n\r\0\x0b\xc2\xa0"); if ('' !== $remainder) { - throw new TransformationFailedException( - sprintf('The number contains unrecognized characters: "%s"', $remainder) - ); + throw new TransformationFailedException(sprintf('The number contains unrecognized characters: "%s"', $remainder)); } } diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ValueToDuplicatesTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ValueToDuplicatesTransformer.php index c9adb0ad5a6fa..49032a6777c83 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/ValueToDuplicatesTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/ValueToDuplicatesTransformer.php @@ -64,9 +64,7 @@ public function reverseTransform($array) foreach ($this->keys as $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' - ); + throw new TransformationFailedException('All values in the array should be the same'); } } else { $emptyKeys[] = $key; @@ -79,9 +77,7 @@ public function reverseTransform($array) return; } - throw new TransformationFailedException( - sprintf('The keys "%s" should not be empty', implode('", "', $emptyKeys) - )); + throw new TransformationFailedException(sprintf('The keys "%s" should not be empty', implode('", "', $emptyKeys))); } return $result; diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index c81f562fcb4bd..c9d45ba0d65a1 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -128,10 +128,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) // Throw exception if unknown values were submitted if (\count($unknownValues) > 0) { - throw new TransformationFailedException(sprintf( - 'The choices "%s" do not exist in the choice list.', - implode('", "', array_keys($unknownValues)) - )); + throw new TransformationFailedException(sprintf('The choices "%s" do not exist in the choice list.', implode('", "', array_keys($unknownValues)))); } $event->setData($data); diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php index 505b42b42e2dc..cd00449a4bfd9 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php @@ -16,8 +16,8 @@ use Symfony\Component\Form\Extension\Core\DataTransformer\DataTransformerChain; use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeImmutableToDateTimeTransformer; use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer; +use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToHtml5LocalDateTimeTransformer; use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToLocalizedStringTransformer; -use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToRfc3339Transformer; use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer; use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer; use Symfony\Component\Form\FormBuilderInterface; @@ -34,21 +34,8 @@ class DateTimeType extends AbstractType const DEFAULT_TIME_FORMAT = \IntlDateFormatter::MEDIUM; /** - * This is not quite the HTML5 format yet, because ICU lacks the - * capability of parsing and generating RFC 3339 dates. - * - * For more information see: - * - * http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax - * https://www.w3.org/TR/html5/sec-forms.html#local-date-and-time-state-typedatetimelocal - * http://tools.ietf.org/html/rfc3339 - * - * An ICU ticket was created: - * http://icu-project.org/trac/ticket/9421 - * - * It was supposedly fixed, but is not available in all PHP installations - * yet. To temporarily circumvent this issue, DateTimeToRfc3339Transformer - * is used when the format matches this constant. + * The HTML5 datetime-local format as defined in + * http://w3c.github.io/html-reference/datatypes.html#form.data.datetime-local. */ const HTML5_FORMAT = "yyyy-MM-dd'T'HH:mm:ss"; @@ -89,7 +76,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) if ('single_text' === $options['widget']) { if (self::HTML5_FORMAT === $pattern) { - $builder->addViewTransformer(new DateTimeToRfc3339Transformer( + $builder->addViewTransformer(new DateTimeToHtml5LocalDateTimeTransformer( $options['model_timezone'], $options['view_timezone'] )); @@ -133,6 +120,11 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'invalid_message_parameters', ))); + if (false === $options['label']) { + $dateOptions['label'] = false; + $timeOptions['label'] = false; + } + if (null !== $options['date_widget']) { $dateOptions['widget'] = $options['date_widget']; } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php index 8f5fa3253bdae..6d6eb17afbff3 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php @@ -78,6 +78,18 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'error_bubbling' => true, ); + if (isset($options['invalid_message'])) { + $dayOptions['invalid_message'] = $options['invalid_message']; + $monthOptions['invalid_message'] = $options['invalid_message']; + $yearOptions['invalid_message'] = $options['invalid_message']; + } + + if (isset($options['invalid_message_parameters'])) { + $dayOptions['invalid_message_parameters'] = $options['invalid_message_parameters']; + $monthOptions['invalid_message_parameters'] = $options['invalid_message_parameters']; + $yearOptions['invalid_message_parameters'] = $options['invalid_message_parameters']; + } + $formatter = new \IntlDateFormatter( \Locale::getDefault(), $dateFormat, diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php index e81f91b98983a..4fd8866c99411 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php @@ -73,6 +73,18 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'error_bubbling' => true, ); + if (isset($options['invalid_message'])) { + $hourOptions['invalid_message'] = $options['invalid_message']; + $minuteOptions['invalid_message'] = $options['invalid_message']; + $secondOptions['invalid_message'] = $options['invalid_message']; + } + + if (isset($options['invalid_message_parameters'])) { + $hourOptions['invalid_message_parameters'] = $options['invalid_message_parameters']; + $minuteOptions['invalid_message_parameters'] = $options['invalid_message_parameters']; + $secondOptions['invalid_message_parameters'] = $options['invalid_message_parameters']; + } + if ('choice' === $options['widget']) { $hours = $minutes = array(); diff --git a/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php b/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php index 826fcdfba3bfc..a97f6af1a2ef1 100644 --- a/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php +++ b/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php @@ -60,13 +60,7 @@ public function getTypeExtensions($name) // validate result of getExtendedType() to ensure it is consistent with the service definition if ($extension->getExtendedType() !== $name) { - throw new InvalidArgumentException( - sprintf('The extended type specified for the service "%s" does not match the actual extended type. Expected "%s", given "%s".', - $serviceId, - $name, - $extension->getExtendedType() - ) - ); + throw new InvalidArgumentException(sprintf('The extended type specified for the service "%s" does not match the actual extended type. Expected "%s", given "%s".', $serviceId, $name, $extension->getExtendedType())); } } } diff --git a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php index 3168a8ee1b5fc..d23467596ea89 100644 --- a/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php +++ b/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php @@ -137,7 +137,7 @@ public function validate($form, Constraint $constraint) /** * Returns the validation groups of the given form. * - * @return array The validation groups + * @return string|GroupSequence|(string|GroupSequence)[] The validation groups */ private static function getValidationGroups(FormInterface $form) { @@ -172,10 +172,10 @@ private static function getValidationGroups(FormInterface $form) /** * Post-processes the validation groups option for a given form. * - * @param array|callable $groups The validation groups - * @param FormInterface $form The validated form + * @param string|GroupSequence|(string|GroupSequence)[]|callable $groups The validation groups + * @param FormInterface $form The validated form * - * @return array The validation groups + * @return (string|GroupSequence)[] The validation groups */ private static function resolveValidationGroups($groups, FormInterface $form) { diff --git a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php index acfa5eab9c0ef..d5e22b926d1dc 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php +++ b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php @@ -198,9 +198,7 @@ public function isIndex($index) * * Consider the following violation path: * - * - * children[address].children[office].data.street - * + * children[address].children[office].data.street * * In this example, "address" and "office" map to forms, while * "street does not. diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index dae0d273d42b5..e6f6febda5691 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -358,13 +358,7 @@ public function setData($modelData) ? 'an instance of class '.\get_class($viewData) : 'a(n) '.\gettype($viewData); - 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 '. - $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 '.$dataClass.'.'); } } @@ -861,11 +855,7 @@ public function add($child, $type = null, array $options = array()) $child = $this->config->getFormFactory()->createNamed($child, $type, null, $options); } } elseif ($child->getConfig()->getAutoInitialize()) { - throw new RuntimeException(sprintf( - 'Automatic initialization is only supported on root forms. You '. - 'should set the "auto_initialize" option to false on the field "%s".', - $child->getName() - )); + throw new RuntimeException(sprintf('Automatic initialization is only supported on root forms. You should set the "auto_initialize" option to false on the field "%s".', $child->getName())); } $this->children[$child->getName()] = $child; @@ -1039,11 +1029,7 @@ private function modelToNorm($value) $value = $transformer->transform($value); } } catch (TransformationFailedException $exception) { - throw new TransformationFailedException( - 'Unable to transform value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), - $exception->getCode(), - $exception - ); + throw new TransformationFailedException('Unable to transform value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), $exception->getCode(), $exception); } return $value; @@ -1067,11 +1053,7 @@ private function normToModel($value) $value = $transformers[$i]->reverseTransform($value); } } catch (TransformationFailedException $exception) { - throw new TransformationFailedException( - 'Unable to reverse value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), - $exception->getCode(), - $exception - ); + throw new TransformationFailedException('Unable to reverse value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), $exception->getCode(), $exception); } return $value; @@ -1102,11 +1084,7 @@ private function normToView($value) $value = $transformer->transform($value); } } catch (TransformationFailedException $exception) { - throw new TransformationFailedException( - 'Unable to transform value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), - $exception->getCode(), - $exception - ); + throw new TransformationFailedException('Unable to transform value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), $exception->getCode(), $exception); } return $value; @@ -1134,11 +1112,7 @@ private function viewToNorm($value) $value = $transformers[$i]->reverseTransform($value); } } catch (TransformationFailedException $exception) { - throw new TransformationFailedException( - 'Unable to reverse value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), - $exception->getCode(), - $exception - ); + throw new TransformationFailedException('Unable to reverse value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), $exception->getCode(), $exception); } return $value; diff --git a/src/Symfony/Component/Form/FormConfigBuilder.php b/src/Symfony/Component/Form/FormConfigBuilder.php index da2dc87fa99d3..fbed08beda00d 100644 --- a/src/Symfony/Component/Form/FormConfigBuilder.php +++ b/src/Symfony/Component/Form/FormConfigBuilder.php @@ -791,11 +791,7 @@ public function setMethod($method) $upperCaseMethod = strtoupper($method); if (!\in_array($upperCaseMethod, self::$allowedMethods)) { - throw new InvalidArgumentException(sprintf( - 'The form method is "%s", but should be one of "%s".', - $method, - implode('", "', self::$allowedMethods) - )); + throw new InvalidArgumentException(sprintf('The form method is "%s", but should be one of "%s".', $method, implode('", "', self::$allowedMethods))); } $this->method = $upperCaseMethod; @@ -862,10 +858,7 @@ public static function validateName($name) } if (!self::isValidName($name)) { - throw new InvalidArgumentException(sprintf( - 'The name "%s" contains illegal characters. Names should start with a letter, digit or underscore and only contain letters, digits, numbers, underscores ("_"), hyphens ("-") and colons (":").', - $name - )); + throw new InvalidArgumentException(sprintf('The name "%s" contains illegal characters. Names should start with a letter, digit or underscore and only contain letters, digits, numbers, underscores ("_"), hyphens ("-") and colons (":").', $name)); } } diff --git a/src/Symfony/Component/Form/FormErrorIterator.php b/src/Symfony/Component/Form/FormErrorIterator.php index ef6e2b78cd161..919b61596988c 100644 --- a/src/Symfony/Component/Form/FormErrorIterator.php +++ b/src/Symfony/Component/Form/FormErrorIterator.php @@ -51,12 +51,7 @@ public function __construct(FormInterface $form, array $errors) { foreach ($errors as $error) { if (!($error instanceof FormError || $error instanceof self)) { - throw new InvalidArgumentException(sprintf( - 'The errors must be instances of '. - '"\Symfony\Component\Form\FormError" or "%s". Got: "%s".', - __CLASS__, - \is_object($error) ? \get_class($error) : \gettype($error) - )); + throw new InvalidArgumentException(sprintf('The errors must be instances of "Symfony\Component\Form\FormError" or "%s". Got: "%s".', __CLASS__, \is_object($error) ? \get_class($error) : \gettype($error))); } } diff --git a/src/Symfony/Component/Form/FormRendererEngineInterface.php b/src/Symfony/Component/Form/FormRendererEngineInterface.php index 6a35d46bf43c7..a6906538f918b 100644 --- a/src/Symfony/Component/Form/FormRendererEngineInterface.php +++ b/src/Symfony/Component/Form/FormRendererEngineInterface.php @@ -55,11 +55,9 @@ public function getResourceForBlockName(FormView $view, $blockName); * and continues with the child of that root, the child of that child etc. * The following is an example for a block hierarchy: * - * - * form_widget - * text_widget - * url_widget - * + * form_widget + * text_widget + * url_widget * * In this example, "url_widget" is the most specific block, while the other * blocks are its ancestors in the hierarchy. @@ -93,11 +91,9 @@ public function getResourceForBlockNameHierarchy(FormView $view, array $blockNam * and continues with the child of that root, the child of that child etc. * The following is an example for a block hierarchy: * - * - * form_widget - * text_widget - * url_widget - * + * form_widget + * text_widget + * url_widget * * The second parameter $hierarchyLevel determines the level of the hierarchy * that should be rendered. diff --git a/src/Symfony/Component/Form/FormRendererInterface.php b/src/Symfony/Component/Form/FormRendererInterface.php index 432892dbbc2ad..f116c9634c998 100644 --- a/src/Symfony/Component/Form/FormRendererInterface.php +++ b/src/Symfony/Component/Form/FormRendererInterface.php @@ -71,18 +71,14 @@ public function searchAndRenderBlock(FormView $view, $blockNameSuffix, array $va * Use this helper for CSRF protection without the overhead of creating a * form. * - * - * - * + * * * Check the token in your action using the same token ID. * - * - * // $csrfProvider being an instance of Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface - * if (!$csrfProvider->isCsrfTokenValid('rm_user_'.$user->getId(), $token)) { - * throw new \RuntimeException('CSRF attack detected.'); - * } - * + * // $csrfProvider being an instance of Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface + * if (!$csrfProvider->isCsrfTokenValid('rm_user_'.$user->getId(), $token)) { + * throw new \RuntimeException('CSRF attack detected.'); + * } * * @param string $tokenId The ID of the CSRF token * diff --git a/src/Symfony/Component/Form/Forms.php b/src/Symfony/Component/Form/Forms.php index 061e98e170589..4554144d8866e 100644 --- a/src/Symfony/Component/Form/Forms.php +++ b/src/Symfony/Component/Form/Forms.php @@ -18,28 +18,24 @@ * * Use this class to conveniently create new form factories: * - * - * use Symfony\Component\Form\Forms; + * use Symfony\Component\Form\Forms; * - * $formFactory = Forms::createFormFactory(); + * $formFactory = Forms::createFormFactory(); * - * $form = $formFactory->createBuilder() - * ->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType') - * ->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType') - * ->add('age', 'Symfony\Component\Form\Extension\Core\Type\IntegerType') - * ->add('gender', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( - * 'choices' => array('Male' => 'm', 'Female' => 'f'), - * )) - * ->getForm(); - * + * $form = $formFactory->createBuilder() + * ->add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType') + * ->add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType') + * ->add('age', 'Symfony\Component\Form\Extension\Core\Type\IntegerType') + * ->add('gender', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( + * 'choices' => array('Male' => 'm', 'Female' => 'f'), + * )) + * ->getForm(); * * You can also add custom extensions to the form factory: * - * - * $formFactory = Forms::createFormFactoryBuilder() - * ->addExtension(new AcmeExtension()) - * ->getFormFactory(); - * + * $formFactory = Forms::createFormFactoryBuilder() + * ->addExtension(new AcmeExtension()) + * ->getFormFactory(); * * If you create custom form types or type extensions, it is * generally recommended to create your own extensions that lazily @@ -47,54 +43,46 @@ * does not matter that much, you can also pass them directly to the * form factory: * - * - * $formFactory = Forms::createFormFactoryBuilder() - * ->addType(new PersonType()) - * ->addType(new PhoneNumberType()) - * ->addTypeExtension(new FormTypeHelpTextExtension()) - * ->getFormFactory(); - * + * $formFactory = Forms::createFormFactoryBuilder() + * ->addType(new PersonType()) + * ->addType(new PhoneNumberType()) + * ->addTypeExtension(new FormTypeHelpTextExtension()) + * ->getFormFactory(); * * Support for the Validator component is provided by ValidatorExtension. * This extension needs a validator object to function properly: * - * - * use Symfony\Component\Validator\Validation; - * use Symfony\Component\Form\Extension\Validator\ValidatorExtension; + * use Symfony\Component\Validator\Validation; + * use Symfony\Component\Form\Extension\Validator\ValidatorExtension; * - * $validator = Validation::createValidator(); - * $formFactory = Forms::createFormFactoryBuilder() - * ->addExtension(new ValidatorExtension($validator)) - * ->getFormFactory(); - * + * $validator = Validation::createValidator(); + * $formFactory = Forms::createFormFactoryBuilder() + * ->addExtension(new ValidatorExtension($validator)) + * ->getFormFactory(); * * Support for the Templating component is provided by TemplatingExtension. * This extension needs a PhpEngine object for rendering forms. As second * argument you should pass the names of the default themes. Here is an * example for using the default layout with "
" tags: * - * - * use Symfony\Component\Form\Extension\Templating\TemplatingExtension; + * use Symfony\Component\Form\Extension\Templating\TemplatingExtension; * - * $formFactory = Forms::createFormFactoryBuilder() - * ->addExtension(new TemplatingExtension($engine, null, array( - * 'FrameworkBundle:Form', - * ))) - * ->getFormFactory(); - * + * $formFactory = Forms::createFormFactoryBuilder() + * ->addExtension(new TemplatingExtension($engine, null, array( + * 'FrameworkBundle:Form', + * ))) + * ->getFormFactory(); * * The next example shows how to include the "
" layout: * - * - * use Symfony\Component\Form\Extension\Templating\TemplatingExtension; + * use Symfony\Component\Form\Extension\Templating\TemplatingExtension; * - * $formFactory = Forms::createFormFactoryBuilder() - * ->addExtension(new TemplatingExtension($engine, null, array( - * 'FrameworkBundle:Form', - * 'FrameworkBundle:FormTable', - * ))) - * ->getFormFactory(); - * + * $formFactory = Forms::createFormFactoryBuilder() + * ->addExtension(new TemplatingExtension($engine, null, array( + * 'FrameworkBundle:Form', + * 'FrameworkBundle:FormTable', + * ))) + * ->getFormFactory(); * * @author Bernhard Schussek */ diff --git a/src/Symfony/Component/Form/Test/FormPerformanceTestCase.php b/src/Symfony/Component/Form/Test/FormPerformanceTestCase.php index a6d8dc7411d99..01440575a1126 100644 --- a/src/Symfony/Component/Form/Test/FormPerformanceTestCase.php +++ b/src/Symfony/Component/Form/Test/FormPerformanceTestCase.php @@ -36,14 +36,7 @@ protected function runTest() $time = microtime(true) - $s; if (0 != $this->maxRunningTime && $time > $this->maxRunningTime) { - $this->fail( - sprintf( - 'expected running time: <= %s but was: %s', - - $this->maxRunningTime, - $time - ) - ); + $this->fail(sprintf('expected running time: <= %s but was: %s', $this->maxRunningTime, $time)); } } diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index c491d9c534a25..40d4e5688c94a 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -1501,7 +1501,7 @@ public function testDateTimeWithWidgetSingleText() '/input [@type="datetime-local"] [@name="name"] - [@value="2011-02-03T04:05:06Z"] + [@value="2011-02-03T04:05:06"] ' ); } @@ -1521,7 +1521,7 @@ public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets() '/input [@type="datetime-local"] [@name="name"] - [@value="2011-02-03T04:05:06Z"] + [@value="2011-02-03T04:05:06"] ' ); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformerTest.php new file mode 100644 index 0000000000000..8573ddf818d2d --- /dev/null +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformerTest.php @@ -0,0 +1,128 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToHtml5LocalDateTimeTransformer; + +class DateTimeToHtml5LocalDateTimeTransformerTest extends TestCase +{ + public static function assertEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) + { + if ($expected instanceof \DateTime && $actual instanceof \DateTime) { + $expected = $expected->format('c'); + $actual = $actual->format('c'); + } + + parent::assertEquals($expected, $actual, $message, $delta, $maxDepth, $canonicalize, $ignoreCase); + } + + public function transformProvider() + { + return array( + array('UTC', 'UTC', '2010-02-03 04:05:06 UTC', '2010-02-03T04:05:06'), + array('UTC', 'UTC', null, ''), + array('America/New_York', 'Asia/Hong_Kong', '2010-02-03 04:05:06 America/New_York', '2010-02-03T17:05:06'), + array('America/New_York', 'Asia/Hong_Kong', null, ''), + array('UTC', 'Asia/Hong_Kong', '2010-02-03 04:05:06 UTC', '2010-02-03T12:05:06'), + array('America/New_York', 'UTC', '2010-02-03 04:05:06 America/New_York', '2010-02-03T09:05:06'), + ); + } + + public function reverseTransformProvider() + { + return array( + // format without seconds, as appears in some browsers + array('UTC', 'UTC', '2010-02-03 04:05:06 UTC', '2010-02-03T04:05:06'), + array('UTC', 'UTC', null, ''), + array('America/New_York', 'Asia/Hong_Kong', '2010-02-03 04:05:06 America/New_York', '2010-02-03T17:05:06'), + array('America/New_York', 'Asia/Hong_Kong', null, ''), + array('UTC', 'Asia/Hong_Kong', '2010-02-03 04:05:06 UTC', '2010-02-03T12:05:06'), + array('America/New_York', 'UTC', '2010-02-03 04:05:06 America/New_York', '2010-02-03T09:05:06'), + array('UTC', 'UTC', '2010-02-03 04:05:00 UTC', '2010-02-03T04:05'), + array('America/New_York', 'Asia/Hong_Kong', '2010-02-03 04:05:00 America/New_York', '2010-02-03T17:05'), + array('Europe/Amsterdam', 'Europe/Amsterdam', '2013-08-21 10:30:00 Europe/Amsterdam', '2013-08-21T10:30:00'), + ); + } + + /** + * @dataProvider transformProvider + */ + public function testTransform($fromTz, $toTz, $from, $to) + { + $transformer = new DateTimeToHtml5LocalDateTimeTransformer($fromTz, $toTz); + + $this->assertSame($to, $transformer->transform(null !== $from ? new \DateTime($from) : null)); + } + + /** + * @dataProvider transformProvider + */ + public function testTransformDateTimeImmutable($fromTz, $toTz, $from, $to) + { + $transformer = new DateTimeToHtml5LocalDateTimeTransformer($fromTz, $toTz); + + $this->assertSame($to, $transformer->transform(null !== $from ? new \DateTimeImmutable($from) : null)); + } + + /** + * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException + */ + public function testTransformRequiresValidDateTime() + { + $transformer = new DateTimeToHtml5LocalDateTimeTransformer(); + $transformer->transform('2010-01-01'); + } + + /** + * @dataProvider reverseTransformProvider + */ + public function testReverseTransform($toTz, $fromTz, $to, $from) + { + $transformer = new DateTimeToHtml5LocalDateTimeTransformer($toTz, $fromTz); + + if (null !== $to) { + $this->assertEquals(new \DateTime($to), $transformer->reverseTransform($from)); + } else { + $this->assertNull($transformer->reverseTransform($from)); + } + } + + /** + * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException + */ + public function testReverseTransformRequiresString() + { + $transformer = new DateTimeToHtml5LocalDateTimeTransformer(); + $transformer->reverseTransform(12345); + } + + /** + * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException + */ + public function testReverseTransformWithNonExistingDate() + { + $transformer = new DateTimeToHtml5LocalDateTimeTransformer('UTC', 'UTC'); + + $transformer->reverseTransform('2010-04-31T04:05'); + } + + /** + * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException + */ + public function testReverseTransformExpectsValidDateString() + { + $transformer = new DateTimeToHtml5LocalDateTimeTransformer('UTC', 'UTC'); + + $transformer->reverseTransform('2010-2010-2010'); + } +} 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 70f8e3edd2912..f21c01b7ccb51 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php @@ -133,12 +133,25 @@ public function testReverseTransformWithNonExistingDate() } /** + * @dataProvider invalidDateStringProvider * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ - public function testReverseTransformExpectsValidDateString() + public function testReverseTransformExpectsValidDateString($date) { $transformer = new DateTimeToRfc3339Transformer('UTC', 'UTC'); - $transformer->reverseTransform('2010-2010-2010'); + $transformer->reverseTransform($date); + } + + public function invalidDateStringProvider() + { + return array( + 'invalid month' => array('2010-2010-01'), + 'invalid day' => array('2010-10-2010'), + 'no date' => array('x'), + 'cookie format' => array('Saturday, 01-May-2010 04:05:00 Z'), + 'RFC 822 format' => array('Sat, 01 May 10 04:05:00 +0000'), + 'RSS format' => array('Sat, 01 May 2010 04:05:00 +0000'), + ); } } 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 6e2b4a4bcbf8b..a45b183142c3d 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php @@ -239,12 +239,12 @@ public function testSubmitDifferentTimezonesDateTime() $outputTime = new \DateTime('2010-06-02 03:04:00 Pacific/Tahiti'); - $form->submit('2010-06-02T03:04:00-10:00'); + $form->submit('2010-06-02T03:04:00'); $outputTime->setTimezone(new \DateTimeZone('America/New_York')); $this->assertEquals($outputTime, $form->getData()); - $this->assertEquals('2010-06-02T03:04:00-10:00', $form->getViewData()); + $this->assertEquals('2010-06-02T03:04:00', $form->getViewData()); } public function testSubmitDifferentTimezonesDateTimeImmutable() @@ -258,13 +258,13 @@ public function testSubmitDifferentTimezonesDateTimeImmutable() $outputTime = new \DateTimeImmutable('2010-06-02 03:04:00 Pacific/Tahiti'); - $form->submit('2010-06-02T03:04:00-10:00'); + $form->submit('2010-06-02T03:04:00'); $outputTime = $outputTime->setTimezone(new \DateTimeZone('America/New_York')); $this->assertInstanceOf(\DateTimeImmutable::class, $form->getData()); $this->assertEquals($outputTime, $form->getData()); - $this->assertEquals('2010-06-02T03:04:00-10:00', $form->getViewData()); + $this->assertEquals('2010-06-02T03:04:00', $form->getViewData()); } public function testSubmitStringSingleText() @@ -276,10 +276,10 @@ public function testSubmitStringSingleText() 'widget' => 'single_text', )); - $form->submit('2010-06-02T03:04:00Z'); + $form->submit('2010-06-02T03:04:00'); $this->assertEquals('2010-06-02 03:04:00', $form->getData()); - $this->assertEquals('2010-06-02T03:04:00Z', $form->getViewData()); + $this->assertEquals('2010-06-02T03:04:00', $form->getViewData()); } public function testSubmitStringSingleTextWithSeconds() @@ -292,10 +292,10 @@ public function testSubmitStringSingleTextWithSeconds() 'with_seconds' => true, )); - $form->submit('2010-06-02T03:04:05Z'); + $form->submit('2010-06-02T03:04:05'); $this->assertEquals('2010-06-02 03:04:05', $form->getData()); - $this->assertEquals('2010-06-02T03:04:05Z', $form->getViewData()); + $this->assertEquals('2010-06-02T03:04:05', $form->getViewData()); } public function testSubmitDifferentPattern() diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index 34a415fcbe90f..6d728b93ac7ac 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -219,8 +219,8 @@ public function prepare(Request $request) // Do X-Accel-Mapping substitutions. // @link http://wiki.nginx.org/X-accel#X-Accel-Redirect $parts = HeaderUtils::split($request->headers->get('X-Accel-Mapping', ''), ',='); - $mappings = HeaderUtils::combine($parts); - foreach ($mappings as $pathPrefix => $location) { + foreach ($parts as $part) { + list($pathPrefix, $location) = $part; if (substr($path, 0, \strlen($pathPrefix)) === $pathPrefix) { $path = $location.substr($path, \strlen($pathPrefix)); break; diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index ab5241737614a..19fd858c39c6a 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -1325,7 +1325,7 @@ public function setFormat($format, $mimeTypes) * * _format request attribute * * $default * - * @param string $default The default format + * @param string|null $default The default format * * @return string The request format */ diff --git a/src/Symfony/Component/HttpFoundation/Session/Session.php b/src/Symfony/Component/HttpFoundation/Session/Session.php index 8a33a9c3a725e..3349906875864 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Session.php +++ b/src/Symfony/Component/HttpFoundation/Session/Session.php @@ -209,7 +209,9 @@ public function getId() */ public function setId($id) { - $this->storage->setId($id); + if ($this->storage->getId() !== $id) { + $this->storage->setId($id); + } } /** diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php index dd37eae14e10d..61a7afd90400c 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php @@ -50,9 +50,7 @@ public function __construct(\Memcached $memcached, array $options = array()) $this->memcached = $memcached; if ($diff = array_diff(array_keys($options), array('prefix', 'expiretime'))) { - throw new \InvalidArgumentException(sprintf( - 'The following options are not supported "%s"', implode(', ', $diff) - )); + throw new \InvalidArgumentException(sprintf('The following options are not supported "%s"', implode(', ', $diff))); } $this->ttl = isset($options['expiretime']) ? (int) $options['expiretime'] : 86400; diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index bf54f19e3fe82..dc4ce44b2dd9c 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -227,29 +227,22 @@ public function save() unset($_SESSION[$key]); } - // Register custom error handler to catch a possible failure warning during session write - set_error_handler(function ($errno, $errstr, $errfile, $errline) { - throw new \ErrorException($errstr, $errno, E_WARNING, $errfile, $errline); - }, E_WARNING); + // Register error handler to add information about the current save handler + $previousHandler = set_error_handler(function ($type, $msg, $file, $line) use (&$previousHandler) { + if (E_WARNING === $type && 0 === strpos($msg, 'session_write_close():')) { + $handler = $this->saveHandler instanceof SessionHandlerProxy ? $this->saveHandler->getHandler() : $this->saveHandler; + $msg = sprintf('session_write_close(): Failed to write session data with "%s" handler', \get_class($handler)); + } + + return $previousHandler ? $previousHandler($type, $msg, $file, $line) : false; + }); try { - $e = null; session_write_close(); - } catch (\ErrorException $e) { } finally { restore_error_handler(); $_SESSION = $session; } - if (null !== $e) { - // The default PHP error message is not very helpful, as it does not give any information on the current save handler. - // Therefore, we catch this error and trigger a warning with a better error message - $handler = $this->getSaveHandler(); - if ($handler instanceof SessionHandlerProxy) { - $handler = $handler->getHandler(); - } - - trigger_error(sprintf('session_write_close(): Failed to write session data with %s handler', \get_class($handler)), E_USER_WARNING); - } $this->closed = true; $this->started = false; diff --git a/src/Symfony/Component/HttpFoundation/StreamedResponse.php b/src/Symfony/Component/HttpFoundation/StreamedResponse.php index 6dba703d2811b..40f785c866bdf 100644 --- a/src/Symfony/Component/HttpFoundation/StreamedResponse.php +++ b/src/Symfony/Component/HttpFoundation/StreamedResponse.php @@ -129,6 +129,8 @@ public function setContent($content) throw new \LogicException('The content cannot be set on a StreamedResponse instance.'); } + $this->streamed = true; + return $this; } @@ -141,16 +143,4 @@ public function getContent() { return false; } - - /** - * {@inheritdoc} - * - * @return $this - */ - public function setNotModified() - { - $this->setCallback(function () {}); - - return parent::setNotModified(); - } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php index a3253d18ebdb8..6bf04e16b7171 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php @@ -337,7 +337,8 @@ public function getSampleXAccelMappings() { return array( array('/var/www/var/www/files/foo.txt', '/var/www/=/files/', '/files/var/www/files/foo.txt'), - array('/home/foo/bar.txt', '/var/www/=/files/,/home/foo/=/baz/', '/baz/bar.txt'), + array('/home/Foo/bar.txt', '/var/www/=/files/,/home/Foo/=/baz/', '/baz/bar.txt'), + array('/home/Foo/bar.txt', '"/var/www/"="/files/", "/home/Foo/"="/baz/"', '/baz/bar.txt'), ); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php index 37d722660fbc0..63351e575a3c8 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php @@ -70,6 +70,27 @@ public function testSetId() $this->assertEquals('0123456789abcdef', $this->session->getId()); } + public function testSetIdAfterStart() + { + $this->session->start(); + $id = $this->session->getId(); + + $e = null; + try { + $this->session->setId($id); + } catch (\Exception $e) { + } + + $this->assertNull($e); + + try { + $this->session->setId('different'); + } catch (\Exception $e) { + } + + $this->assertInstanceOf('\LogicException', $e); + } + public function testSetName() { $this->assertEquals('MOCKSESSID', $this->session->getName()); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php index 0c182e0b0bf57..893e120ce166e 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php @@ -48,7 +48,7 @@ protected function setUp() $this->data = array( $this->attributes->getStorageKey() => array('foo' => 'bar'), $this->flashes->getStorageKey() => array('notice' => 'hello'), - ); + ); $this->storage = new MockArraySessionStorage(); $this->storage->registerBag($this->flashes); diff --git a/src/Symfony/Component/HttpKernel/Bundle/Bundle.php b/src/Symfony/Component/HttpKernel/Bundle/Bundle.php index 23e093373d6de..26dea9b205193 100644 --- a/src/Symfony/Component/HttpKernel/Bundle/Bundle.php +++ b/src/Symfony/Component/HttpKernel/Bundle/Bundle.php @@ -33,23 +33,21 @@ abstract class Bundle implements BundleInterface private $namespace; /** - * Boots the Bundle. + * {@inheritdoc} */ public function boot() { } /** - * Shutdowns the Bundle. + * {@inheritdoc} */ public function shutdown() { } /** - * Builds the bundle. - * - * It is only ever called once when the cache is empty. + * {@inheritdoc} * * This method can be overridden to register compilation passes, * other extensions, ... @@ -80,10 +78,7 @@ public function getContainerExtension() $expectedAlias = Container::underscore($basename); if ($expectedAlias != $extension->getAlias()) { - throw new \LogicException(sprintf( - 'Users will expect the alias of the default extension of a bundle to be the underscored version of the bundle name ("%s"). You can override "Bundle::getContainerExtension()" if you want to use "%s" or another alias.', - $expectedAlias, $extension->getAlias() - )); + throw new \LogicException(sprintf('Users will expect the alias of the default extension of a bundle to be the underscored version of the bundle name ("%s"). You can override "Bundle::getContainerExtension()" if you want to use "%s" or another alias.', $expectedAlias, $extension->getAlias())); } $this->extension = $extension; @@ -98,9 +93,7 @@ public function getContainerExtension() } /** - * Gets the Bundle namespace. - * - * @return string The Bundle namespace + * {@inheritdoc} */ public function getNamespace() { @@ -112,9 +105,7 @@ public function getNamespace() } /** - * Gets the Bundle directory path. - * - * @return string The Bundle absolute path + * {@inheritdoc} */ public function getPath() { diff --git a/src/Symfony/Component/HttpKernel/Client.php b/src/Symfony/Component/HttpKernel/Client.php index d3ca8cee1d2ed..62555e9a5ac4d 100644 --- a/src/Symfony/Component/HttpKernel/Client.php +++ b/src/Symfony/Component/HttpKernel/Client.php @@ -81,8 +81,9 @@ protected function doRequest($request) */ protected function getScript($request) { - $kernel = str_replace("'", "\\'", serialize($this->kernel)); - $request = str_replace("'", "\\'", serialize($request)); + $kernel = var_export(serialize($this->kernel), true); + $request = var_export(serialize($request), true); + $errorReporting = error_reporting(); $requires = ''; @@ -91,7 +92,7 @@ protected function getScript($request) $r = new \ReflectionClass($class); $file = \dirname(\dirname($r->getFileName())).'/autoload.php'; if (file_exists($file)) { - $requires .= "require_once '".str_replace("'", "\\'", $file)."';\n"; + $requires .= 'require_once '.var_export($file, true).";\n"; } } } @@ -107,8 +108,8 @@ protected function getScript($request) $requires -\$kernel = unserialize('$kernel'); -\$request = unserialize('$request'); +\$kernel = unserialize($kernel); +\$request = unserialize($request); EOF; return $code.$this->getHandleScript(); diff --git a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/ServiceValueResolver.php b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/ServiceValueResolver.php index a2ab592ad0255..e7df546b6680b 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/ServiceValueResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/ServiceValueResolver.php @@ -48,6 +48,10 @@ public function supports(Request $request, ArgumentMetadata $argument) $controller = ltrim($controller, '\\'); } + if (!$this->container->has($controller) && false !== $i = strrpos($controller, ':')) { + $controller = substr($controller, 0, $i).strtolower(substr($controller, $i)); + } + return $this->container->has($controller) && $this->container->get($controller)->has($argument->getName()); } @@ -64,6 +68,11 @@ public function resolve(Request $request, ArgumentMetadata $argument) $controller = ltrim($controller, '\\'); } + if (!$this->container->has($controller)) { + $i = strrpos($controller, ':'); + $controller = substr($controller, 0, $i).strtolower(substr($controller, $i)); + } + try { yield $this->container->get($controller)->get($argument->getName()); } catch (RuntimeException $e) { diff --git a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php index bafb509548554..e187022b54586 100644 --- a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php +++ b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php @@ -96,7 +96,7 @@ private function getFileLinkFormat() } return array( - $request->getSchemeAndHttpHost().$request->getBaseUrl().$this->urlFormat, + $request->getSchemeAndHttpHost().$request->getBasePath().$this->urlFormat, $this->baseDir.\DIRECTORY_SEPARATOR, '', ); } diff --git a/src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php b/src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php index f523e7c45f782..ecf12f21822ba 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php +++ b/src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php @@ -125,6 +125,13 @@ protected function createSubRequest($uri, Request $request) } $setSession($subRequest, $request); + if ($request->get('_format')) { + $subRequest->attributes->set('_format', $request->get('_format')); + } + if ($request->getDefaultLocale() !== $request->getLocale()) { + $subRequest->setLocale($request->getLocale()); + } + return $subRequest; } diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 9404cc0fba7d9..9e4e86dfff43b 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -63,11 +63,11 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '4.1.4'; - const VERSION_ID = 40104; + const VERSION = '4.1.5'; + const VERSION_ID = 40105; const MAJOR_VERSION = 4; const MINOR_VERSION = 1; - const RELEASE_VERSION = 4; + const RELEASE_VERSION = 5; const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '01/2019'; @@ -90,7 +90,7 @@ public function __clone() } /** - * Boots the current kernel. + * {@inheritdoc} */ public function boot() { @@ -250,11 +250,7 @@ public function locateResource($name, $dir = null, $first = true) if ($isResource && file_exists($file = $dir.'/'.$bundle->getName().$overridePath)) { if (null !== $resourceBundle) { - throw new \RuntimeException(sprintf('"%s" resource is hidden by a resource from the "%s" derived bundle. Create a "%s" file to override the bundle resource.', - $file, - $resourceBundle, - $dir.'/'.$bundle->getName().$overridePath - )); + throw new \RuntimeException(sprintf('"%s" resource is hidden by a resource from the "%s" derived bundle. Create a "%s" file to override the bundle resource.', $file, $resourceBundle, $dir.'/'.$bundle->getName().$overridePath)); } $files[] = $file; diff --git a/src/Symfony/Component/HttpKernel/KernelInterface.php b/src/Symfony/Component/HttpKernel/KernelInterface.php index b99040781927e..485f3bf8424b3 100644 --- a/src/Symfony/Component/HttpKernel/KernelInterface.php +++ b/src/Symfony/Component/HttpKernel/KernelInterface.php @@ -127,7 +127,7 @@ public function getRootDir(); /** * Gets the current container. * - * @return ContainerInterface A ContainerInterface instance + * @return ContainerInterface|null A ContainerInterface instance or null when the Kernel is shutdown */ public function getContainer(); diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php index 33b64d54480f2..0b38af9556922 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolver/ServiceValueResolverTest.php @@ -68,6 +68,24 @@ public function testExistingControllerWithATrailingBackSlash() $this->assertYieldEquals(array(new DummyService()), $resolver->resolve($request, $argument)); } + public function testExistingControllerWithMethodNameStartUppercase() + { + $resolver = new ServiceValueResolver(new ServiceLocator(array( + 'App\\Controller\\Mine::method' => function () { + return new ServiceLocator(array( + 'dummy' => function () { + return new DummyService(); + }, + )); + }, + ))); + $request = $this->requestWithAttributes(array('_controller' => 'App\\Controller\\Mine::Method')); + $argument = new ArgumentMetadata('dummy', DummyService::class, false, false, null); + + $this->assertTrue($resolver->supports($request, $argument)); + $this->assertYieldEquals(array(new DummyService()), $resolver->resolve($request, $argument)); + } + public function testControllerNameIsAnArray() { $resolver = new ServiceValueResolver(new ServiceLocator(array( diff --git a/src/Symfony/Component/HttpKernel/Tests/Debug/FileLinkFormatterTest.php b/src/Symfony/Component/HttpKernel/Tests/Debug/FileLinkFormatterTest.php index e14780ac687f3..5c93bd90e3565 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Debug/FileLinkFormatterTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Debug/FileLinkFormatterTest.php @@ -37,7 +37,6 @@ public function testWhenFileLinkFormatAndNoRequest() public function testWhenFileLinkFormatAndRequest() { $file = __DIR__.\DIRECTORY_SEPARATOR.'file.php'; - $baseDir = __DIR__; $requestStack = new RequestStack(); $request = new Request(); $requestStack->push($request); @@ -56,12 +55,12 @@ public function testWhenNoFileLinkFormatAndRequest() $request->server->set('SERVER_NAME', 'www.example.org'); $request->server->set('SERVER_PORT', 80); - $request->server->set('SCRIPT_NAME', '/app.php'); - $request->server->set('SCRIPT_FILENAME', '/web/app.php'); - $request->server->set('REQUEST_URI', '/app.php/example'); + $request->server->set('SCRIPT_NAME', '/index.php'); + $request->server->set('SCRIPT_FILENAME', '/public/index.php'); + $request->server->set('REQUEST_URI', '/index.php/example'); $sut = new FileLinkFormatter(null, $requestStack, __DIR__, '/_profiler/open?file=%f&line=%l#line%l'); - $this->assertSame('http://www.example.org/app.php/_profiler/open?file=file.php&line=3#line3', $sut->format($file, 3)); + $this->assertSame('http://www.example.org/_profiler/open?file=file.php&line=3#line3', $sut->format($file, 3)); } } diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php index f633a4bf777c0..ceaa249ab6060 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php @@ -145,6 +145,26 @@ public function testExceptionInSubRequestsDoesNotMangleOutputBuffers() $this->assertEquals('Foo', ob_get_clean()); } + public function testLocaleAndFormatAreIsKeptInSubrequest() + { + $expectedSubRequest = Request::create('/'); + $expectedSubRequest->attributes->set('_format', 'foo'); + $expectedSubRequest->setLocale('fr'); + if (Request::HEADER_X_FORWARDED_FOR & Request::getTrustedHeaderSet()) { + $expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1')); + $expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1'); + } + $expectedSubRequest->headers->set('forwarded', array('for="127.0.0.1";host="localhost";proto=http')); + $expectedSubRequest->server->set('HTTP_FORWARDED', 'for="127.0.0.1";host="localhost";proto=http'); + + $strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest)); + + $request = Request::create('/'); + $request->attributes->set('_format', 'foo'); + $request->setLocale('fr'); + $strategy->render('/', $request); + } + public function testESIHeaderIsKeptInSubrequest() { $expectedSubRequest = Request::create('/'); diff --git a/src/Symfony/Component/Intl/Data/Bundle/Compiler/GenrbCompiler.php b/src/Symfony/Component/Intl/Data/Bundle/Compiler/GenrbCompiler.php index 13f423342b1ea..9893ff42b1377 100644 --- a/src/Symfony/Component/Intl/Data/Bundle/Compiler/GenrbCompiler.php +++ b/src/Symfony/Component/Intl/Data/Bundle/Compiler/GenrbCompiler.php @@ -37,10 +37,7 @@ public function __construct(string $genrb = 'genrb', string $envVars = '') exec('which '.$genrb, $output, $status); if (0 !== $status) { - throw new RuntimeException(sprintf( - 'The command "%s" is not installed', - $genrb - )); + throw new RuntimeException(sprintf('The command "%s" is not installed', $genrb)); } $this->genrb = ($envVars ? $envVars.' ' : '').$genrb; @@ -58,12 +55,7 @@ public function compile($sourcePath, $targetDir) exec($this->genrb.' --quiet -e UTF-8 -d '.$targetDir.' '.$sourcePath, $output, $status); if (0 !== $status) { - throw new RuntimeException(sprintf( - 'genrb failed with status %d while compiling %s to %s.', - $status, - $sourcePath, - $targetDir - )); + throw new RuntimeException(sprintf('genrb failed with status %d while compiling %s to %s.', $status, $sourcePath, $targetDir)); } } } diff --git a/src/Symfony/Component/Intl/Data/Bundle/Reader/IntlBundleReader.php b/src/Symfony/Component/Intl/Data/Bundle/Reader/IntlBundleReader.php index 3bcd98dc89e13..684f3d9c90317 100644 --- a/src/Symfony/Component/Intl/Data/Bundle/Reader/IntlBundleReader.php +++ b/src/Symfony/Component/Intl/Data/Bundle/Reader/IntlBundleReader.php @@ -40,11 +40,7 @@ public function read($path, $locale) // 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 ResourceBundleNotFoundException(sprintf( - 'The resource bundle "%s/%s.res" could not be found.', - $path, - $locale - )); + 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, diff --git a/src/Symfony/Component/Intl/Data/Bundle/Reader/JsonBundleReader.php b/src/Symfony/Component/Intl/Data/Bundle/Reader/JsonBundleReader.php index b5786d12a22ef..5c41c4043918e 100644 --- a/src/Symfony/Component/Intl/Data/Bundle/Reader/JsonBundleReader.php +++ b/src/Symfony/Component/Intl/Data/Bundle/Reader/JsonBundleReader.php @@ -36,27 +36,17 @@ public function read($path, $locale) } if (!file_exists($fileName)) { - throw new ResourceBundleNotFoundException(sprintf( - 'The resource bundle "%s" does not exist.', - $fileName - )); + throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s" does not exist.', $fileName)); } if (!is_file($fileName)) { - throw new RuntimeException(sprintf( - 'The resource bundle "%s" is not a file.', - $fileName - )); + throw new RuntimeException(sprintf('The resource bundle "%s" is not a file.', $fileName)); } $data = json_decode(file_get_contents($fileName), true); if (null === $data) { - throw new RuntimeException(sprintf( - 'The resource bundle "%s" contains invalid JSON: %s', - $fileName, - json_last_error_msg() - )); + throw new RuntimeException(sprintf('The resource bundle "%s" contains invalid JSON: %s', $fileName, json_last_error_msg())); } return $data; diff --git a/src/Symfony/Component/Intl/Data/Bundle/Reader/PhpBundleReader.php b/src/Symfony/Component/Intl/Data/Bundle/Reader/PhpBundleReader.php index 7c4b71c93ac1a..bbe2dfda6b973 100644 --- a/src/Symfony/Component/Intl/Data/Bundle/Reader/PhpBundleReader.php +++ b/src/Symfony/Component/Intl/Data/Bundle/Reader/PhpBundleReader.php @@ -36,19 +36,11 @@ public function read($path, $locale) } if (!file_exists($fileName)) { - throw new ResourceBundleNotFoundException(sprintf( - 'The resource bundle "%s/%s.php" does not exist.', - $path, - $locale - )); + throw new ResourceBundleNotFoundException(sprintf('The resource bundle "%s/%s.php" does not exist.', $path, $locale)); } if (!is_file($fileName)) { - throw new RuntimeException(sprintf( - 'The resource bundle "%s/%s.php" is not a file.', - $path, - $locale - )); + throw new RuntimeException(sprintf('The resource bundle "%s/%s.php" is not a file.', $path, $locale)); } return include $fileName; diff --git a/src/Symfony/Component/Intl/Data/Generator/LanguageDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/LanguageDataGenerator.php index ab09f1c6f1314..9b3cf0a40682b 100644 --- a/src/Symfony/Component/Intl/Data/Generator/LanguageDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/LanguageDataGenerator.php @@ -173,32 +173,19 @@ private function generateAlpha2ToAlpha3Mapping(ArrayAccessibleResourceBundle $me if (isset(self::$preferredAlpha2ToAlpha3Mapping[$language])) { // Validate to prevent typos if (!isset($aliases[self::$preferredAlpha2ToAlpha3Mapping[$language]])) { - throw new RuntimeException( - 'The statically set three-letter mapping '. - self::$preferredAlpha2ToAlpha3Mapping[$language].' '. - 'for the language code '.$language.' seems to be '. - 'invalid. Typo?' - ); + throw new RuntimeException('The statically set three-letter mapping '.self::$preferredAlpha2ToAlpha3Mapping[$language].' for the language code '.$language.' seems to be invalid. Typo?'); } $alpha3 = self::$preferredAlpha2ToAlpha3Mapping[$language]; $alpha2 = $aliases[$alpha3]['replacement']; if ($language !== $alpha2) { - throw new RuntimeException( - 'The statically set three-letter mapping '.$alpha3.' '. - 'for the language code '.$language.' seems to be '. - 'an alias for '.$alpha2.'. Wrong mapping?' - ); + throw new RuntimeException('The statically set three-letter mapping '.$alpha3.' for the language code '.$language.' seems to be an alias for '.$alpha2.'. Wrong mapping?'); } $alpha2ToAlpha3[$language] = $alpha3; } elseif (isset($alpha2ToAlpha3[$language])) { - throw new RuntimeException( - 'Multiple three-letter mappings exist for the language '. - 'code '.$language.'. Please add one of them to the '. - 'property $preferredAlpha2ToAlpha3Mapping.' - ); + throw new RuntimeException('Multiple three-letter mappings exist for the language code '.$language.'. Please add one of them to the property $preferredAlpha2ToAlpha3Mapping.'); } else { $alpha2ToAlpha3[$language] = $alias; } diff --git a/src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php b/src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php index e1265b3a1b742..920e2e311b049 100644 --- a/src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php +++ b/src/Symfony/Component/Intl/Data/Generator/RegionDataGenerator.php @@ -34,6 +34,8 @@ class RegionDataGenerator extends AbstractDataGenerator const BOUVET_ISLAND_ID = 'BV'; const HEARD_MCDONALD_ISLANDS_ID = 'HM'; const CLIPPERTON_ISLAND_ID = 'CP'; + const EUROZONE_ID = 'EZ'; + const UNITED_NATIONS_ID = 'UN'; /** * Regions excluded from generation. @@ -43,6 +45,8 @@ class RegionDataGenerator extends AbstractDataGenerator // Look like countries, but are sub-continents self::OUTLYING_OCEANIA_REGION_ID => true, self::EUROPEAN_UNION_ID => true, + self::EUROZONE_ID => true, + self::UNITED_NATIONS_ID => true, // No longer exists self::NETHERLANDS_ANTILLES_ID => true, // Uninhabited islands diff --git a/src/Symfony/Component/Intl/Data/Util/RecursiveArrayAccess.php b/src/Symfony/Component/Intl/Data/Util/RecursiveArrayAccess.php index 086b550478057..c133932c9e6ff 100644 --- a/src/Symfony/Component/Intl/Data/Util/RecursiveArrayAccess.php +++ b/src/Symfony/Component/Intl/Data/Util/RecursiveArrayAccess.php @@ -36,10 +36,7 @@ public static function get($array, array $indices) } } - throw new OutOfBoundsException(sprintf( - 'The index %s does not exist.', - $index - )); + throw new OutOfBoundsException(sprintf('The index %s does not exist.', $index)); } return $array; diff --git a/src/Symfony/Component/Intl/Data/Util/RingBuffer.php b/src/Symfony/Component/Intl/Data/Util/RingBuffer.php index d7facfd249ba3..7b999eeeddde9 100644 --- a/src/Symfony/Component/Intl/Data/Util/RingBuffer.php +++ b/src/Symfony/Component/Intl/Data/Util/RingBuffer.php @@ -53,10 +53,7 @@ public function offsetExists($key) public function offsetGet($key) { if (!isset($this->indices[$key])) { - throw new OutOfBoundsException(sprintf( - 'The index "%s" does not exist.', - $key - )); + throw new OutOfBoundsException(sprintf('The index "%s" does not exist.', $key)); } return $this->values[$this->indices[$key]]; diff --git a/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimezoneTransformer.php b/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimezoneTransformer.php index 23734ed8fd9de..6120e3e482ec8 100644 --- a/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimezoneTransformer.php +++ b/src/Symfony/Component/Intl/DateFormatter/DateFormat/TimezoneTransformer.php @@ -106,10 +106,7 @@ public static function getEtcTimeZoneId($formattedTimeZone) $signal = '-' == $matches['signal'] ? '+' : '-'; if (0 < $minutes) { - throw new NotImplementedException(sprintf( - 'It is not possible to use a GMT time zone with minutes offset different than zero (0). GMT time zone tried: %s.', - $formattedTimeZone - )); + throw new NotImplementedException(sprintf('It is not possible to use a GMT time zone with minutes offset different than zero (0). GMT time zone tried: %s.', $formattedTimeZone)); } return 'Etc/GMT'.(0 !== $hours ? $signal.$hours : ''); diff --git a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php index 6be7b71503ea8..8b37414f96f3b 100644 --- a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php +++ b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php @@ -360,10 +360,7 @@ public function format($value, $type = self::TYPE_DEFAULT) } if (self::CURRENCY == $this->style) { - throw new NotImplementedException(sprintf( - '%s() method does not support the formatting of currencies (instance with CURRENCY style). %s', - __METHOD__, NotImplementedException::INTL_INSTALL_MESSAGE - )); + throw new NotImplementedException(sprintf('%s() method does not support the formatting of currencies (instance with CURRENCY style). %s', __METHOD__, NotImplementedException::INTL_INSTALL_MESSAGE)); } // Only the default type is supported. @@ -519,7 +516,7 @@ public function parse($value, $type = self::TYPE_DOUBLE, &$position = 0) $groupSep = $this->getAttribute(self::GROUPING_USED) ? ',' : ''; // Any string before the numeric value causes error in the parsing - if (preg_match("/^-?(?:\.\d++|([\d{$groupSep}]++)(?:\.\d++)?)/", $value, $matches)) { + if (preg_match("/^-?(?:\.\d++|([\d{$groupSep}]++)(?:\.\d*+)?)/", $value, $matches)) { $value = $matches[0]; $position = \strlen($value); if ($error = $groupSep && isset($matches[1]) && !preg_match('/^\d{1,3}+(?:(?:,\d{3})++|\d*+)$/', $matches[1])) { diff --git a/src/Symfony/Component/Intl/Resources/data/regions/af.json b/src/Symfony/Component/Intl/Resources/data/regions/af.json index 2b280fd249db1..726c0350799c2 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/af.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/af.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Spanje", "ET": "Ethiopië", - "EZ": "Eurosone", "FI": "Finland", "FJ": "Fidji", "FK": "Falklandeilande", @@ -237,7 +236,6 @@ "UA": "Oekraïne", "UG": "Uganda", "UM": "Klein afgeleë eilande van die VSA", - "UN": "Verenigde Nasies", "US": "Verenigde State van Amerika", "UY": "Uruguay", "UZ": "Oesbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/am.json b/src/Symfony/Component/Intl/Resources/data/regions/am.json index 0936881e34dd1..929f7797e823c 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/am.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/am.json @@ -72,7 +72,6 @@ "ER": "ኤርትራ", "ES": "ስፔን", "ET": "ኢትዮጵያ", - "EZ": "የአውሮፓ ዞን", "FI": "ፊንላንድ", "FJ": "ፊጂ", "FK": "የፎክላንድ ደሴቶች", @@ -237,7 +236,6 @@ "UA": "ዩክሬን", "UG": "ዩጋንዳ", "UM": "የዩ ኤስ ጠረፍ ላይ ያሉ ደሴቶች", - "UN": "የተባበሩት መንግስታት", "US": "ዩናይትድ ስቴትስ", "UY": "ኡራጓይ", "UZ": "ኡዝቤኪስታን", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/ar.json b/src/Symfony/Component/Intl/Resources/data/regions/ar.json index 93ce837ca1ecd..989681613e67c 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/ar.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/ar.json @@ -72,7 +72,6 @@ "ER": "إريتريا", "ES": "إسبانيا", "ET": "إثيوبيا", - "EZ": "منطقة اليورو", "FI": "فنلندا", "FJ": "فيجي", "FK": "جزر فوكلاند", @@ -237,7 +236,6 @@ "UA": "أوكرانيا", "UG": "أوغندا", "UM": "جزر الولايات المتحدة النائية", - "UN": "الأمم المتحدة", "US": "الولايات المتحدة", "UY": "أورغواي", "UZ": "أوزبكستان", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/as.json b/src/Symfony/Component/Intl/Resources/data/regions/as.json index 50baeecf10cc0..2a61a13138b71 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/as.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/as.json @@ -72,7 +72,6 @@ "ER": "এৰিত্ৰিয়া", "ES": "স্পেইন", "ET": "ইথিঅ’পিয়া", - "EZ": "ইউৰোজ’ন", "FI": "ফিনলেণ্ড", "FJ": "ফিজি", "FK": "ফকলেণ্ড দ্বীপপুঞ্জ", @@ -237,7 +236,6 @@ "UA": "ইউক্ৰেইন", "UG": "উগাণ্ডা", "UM": "ইউ. এছ. আউটলায়িং দ্বীপপুঞ্জ", - "UN": "ৰাষ্ট্ৰসংঘ", "US": "মাৰ্কিন যুক্তৰাষ্ট্ৰ", "UY": "উৰুগুৱে", "UZ": "উজবেকিস্তান", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/az.json b/src/Symfony/Component/Intl/Resources/data/regions/az.json index 2bc9b27e4b692..217a2f388388d 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/az.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/az.json @@ -72,7 +72,6 @@ "ER": "Eritreya", "ES": "İspaniya", "ET": "Efiopiya", - "EZ": "Avrozona", "FI": "Finlandiya", "FJ": "Fici", "FK": "Folklend adaları", @@ -237,7 +236,6 @@ "UA": "Ukrayna", "UG": "Uqanda", "UM": "ABŞ-a bağlı kiçik adacıqlar", - "UN": "Birləşmiş Millətlər Təşkilatı", "US": "Amerika Birləşmiş Ştatları", "UY": "Uruqvay", "UZ": "Özbəkistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/be.json b/src/Symfony/Component/Intl/Resources/data/regions/be.json index 916a0653e726f..f117642b14a48 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/be.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/be.json @@ -72,7 +72,6 @@ "ER": "Эрытрэя", "ES": "Іспанія", "ET": "Эфіопія", - "EZ": "Еўразона", "FI": "Фінляндыя", "FJ": "Фіджы", "FK": "Фалклендскія астравы", @@ -237,7 +236,6 @@ "UA": "Украіна", "UG": "Уганда", "UM": "Малыя Аддаленыя астравы ЗША", - "UN": "ААН", "US": "Злучаныя Штаты Амерыкі", "UY": "Уругвай", "UZ": "Узбекістан", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/bg.json b/src/Symfony/Component/Intl/Resources/data/regions/bg.json index 0a4de0c69eb56..8d46867ad975c 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/bg.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/bg.json @@ -72,7 +72,6 @@ "ER": "Еритрея", "ES": "Испания", "ET": "Етиопия", - "EZ": "Еврозона", "FI": "Финландия", "FJ": "Фиджи", "FK": "Фолклендски острови", @@ -237,7 +236,6 @@ "UA": "Украйна", "UG": "Уганда", "UM": "Отдалечени острови на САЩ", - "UN": "Организация на обединените нации", "US": "Съединени щати", "UY": "Уругвай", "UZ": "Узбекистан", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/bn.json b/src/Symfony/Component/Intl/Resources/data/regions/bn.json index 35626e5519c09..8a0ec061f1883 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/bn.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/bn.json @@ -72,7 +72,6 @@ "ER": "ইরিত্রিয়া", "ES": "স্পেন", "ET": "ইথিওপিয়া", - "EZ": "ইউরোজোন", "FI": "ফিনল্যান্ড", "FJ": "ফিজি", "FK": "ফকল্যান্ড দ্বীপপুঞ্জ", @@ -237,7 +236,6 @@ "UA": "ইউক্রেন", "UG": "উগান্ডা", "UM": "যুক্তরাষ্ট্রের পার্শ্ববর্তী দ্বীপপুঞ্জ", - "UN": "জাতিসংঘ", "US": "মার্কিন যুক্তরাষ্ট্র", "UY": "উরুগুয়ে", "UZ": "উজবেকিস্তান", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/br.json b/src/Symfony/Component/Intl/Resources/data/regions/br.json index 5f1bdd18120d2..ad7fd7262d433 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/br.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/br.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Spagn", "ET": "Etiopia", - "EZ": "takad an euro", "FI": "Finland", "FJ": "Fidji", "FK": "Inizi Falkland", @@ -237,7 +236,6 @@ "UA": "Ukraina", "UG": "Ouganda", "UM": "Inizi diabell ar Stadoù-Unanet", - "UN": "Broadoù unanet", "US": "Stadoù-Unanet", "UY": "Uruguay", "UZ": "Ouzbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/bs.json b/src/Symfony/Component/Intl/Resources/data/regions/bs.json index a923f5fd90c29..387c866323465 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/bs.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/bs.json @@ -72,7 +72,6 @@ "ER": "Eritreja", "ES": "Španija", "ET": "Etiopija", - "EZ": "Eurozona", "FI": "Finska", "FJ": "Fidži", "FK": "Folklandska ostrva", @@ -237,7 +236,6 @@ "UA": "Ukrajina", "UG": "Uganda", "UM": "Američka Vanjska Ostrva", - "UN": "Ujedinjene Nacije", "US": "Sjedinjene Američke Države", "UY": "Urugvaj", "UZ": "Uzbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/bs_Cyrl.json b/src/Symfony/Component/Intl/Resources/data/regions/bs_Cyrl.json index 76c673b03b2ae..a31e2b35bf507 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/bs_Cyrl.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/bs_Cyrl.json @@ -72,7 +72,6 @@ "ER": "Еритреја", "ES": "Шпанија", "ET": "Етиопија", - "EZ": "Еурозона", "FI": "Финска", "FJ": "Фиџи", "FK": "Фокландска острва", @@ -236,7 +235,6 @@ "UA": "Украјина", "UG": "Уганда", "UM": "Мања удаљена острва САД", - "UN": "Уједињене нације", "US": "Сједињене Америчке Државе", "UY": "Уругвај", "UZ": "Узбекистан", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/ca.json b/src/Symfony/Component/Intl/Resources/data/regions/ca.json index 50a0177b4d7d2..2336686f511ca 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/ca.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/ca.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Espanya", "ET": "Etiòpia", - "EZ": "zona euro", "FI": "Finlàndia", "FJ": "Fiji", "FK": "Illes Malvines", @@ -237,7 +236,6 @@ "UA": "Ucraïna", "UG": "Uganda", "UM": "Illes Perifèriques Menors dels EUA", - "UN": "Nacions Unides", "US": "Estats Units", "UY": "Uruguai", "UZ": "Uzbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/ce.json b/src/Symfony/Component/Intl/Resources/data/regions/ce.json index 934580a09914e..e86ed1000e2a1 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/ce.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/ce.json @@ -72,7 +72,6 @@ "ER": "Эритрей", "ES": "Испани", "ET": "Эфиопи", - "EZ": "еврозона", "FI": "Финлянди", "FJ": "Фиджи", "FK": "Фолклендан гӀайренаш", @@ -237,7 +236,6 @@ "UA": "Украина", "UG": "Уганда", "UM": "АЦШн арахьара кегийн гӀайренаш", - "UN": "Вовшахкхетта Къаьмнийн Организаци", "US": "Цхьанатоьхна Штаташ", "UY": "Уругвай", "UZ": "Узбекистан", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/cs.json b/src/Symfony/Component/Intl/Resources/data/regions/cs.json index 68eea5b4ac7b9..375a62819d333 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/cs.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/cs.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Španělsko", "ET": "Etiopie", - "EZ": "eurozóna", "FI": "Finsko", "FJ": "Fidži", "FK": "Falklandské ostrovy", @@ -237,7 +236,6 @@ "UA": "Ukrajina", "UG": "Uganda", "UM": "Menší odlehlé ostrovy USA", - "UN": "Organizace spojených národů", "US": "Spojené státy", "UY": "Uruguay", "UZ": "Uzbekistán", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/cy.json b/src/Symfony/Component/Intl/Resources/data/regions/cy.json index caa829ed16014..2fd5967749108 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/cy.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/cy.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Sbaen", "ET": "Ethiopia", - "EZ": "Ardal yr Ewro", "FI": "Y Ffindir", "FJ": "Fiji", "FK": "Ynysoedd y Falkland\/Malvinas", @@ -237,7 +236,6 @@ "UA": "Wcráin", "UG": "Uganda", "UM": "Ynysoedd Pellennig UDA", - "UN": "y Cenhedloedd Unedig", "US": "Yr Unol Daleithiau", "UY": "Uruguay", "UZ": "Uzbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/da.json b/src/Symfony/Component/Intl/Resources/data/regions/da.json index ef8b2658a839a..ddda65b193cf8 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/da.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/da.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Spanien", "ET": "Etiopien", - "EZ": "eurozonen", "FI": "Finland", "FJ": "Fiji", "FK": "Falklandsøerne", @@ -237,7 +236,6 @@ "UA": "Ukraine", "UG": "Uganda", "UM": "Amerikanske oversøiske øer", - "UN": "De Forenede Nationer", "US": "USA", "UY": "Uruguay", "UZ": "Usbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/de.json b/src/Symfony/Component/Intl/Resources/data/regions/de.json index b521ae4bc511e..38e353f6a35a4 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/de.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/de.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Spanien", "ET": "Äthiopien", - "EZ": "Eurozone", "FI": "Finnland", "FJ": "Fidschi", "FK": "Falklandinseln", @@ -237,7 +236,6 @@ "UA": "Ukraine", "UG": "Uganda", "UM": "Amerikanische Überseeinseln", - "UN": "Vereinte Nationen", "US": "Vereinigte Staaten", "UY": "Uruguay", "UZ": "Usbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/el.json b/src/Symfony/Component/Intl/Resources/data/regions/el.json index 447264e8c6ebc..8387c53c9106b 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/el.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/el.json @@ -72,7 +72,6 @@ "ER": "Ερυθραία", "ES": "Ισπανία", "ET": "Αιθιοπία", - "EZ": "Ευρωζώνη", "FI": "Φινλανδία", "FJ": "Φίτζι", "FK": "Νήσοι Φόκλαντ", @@ -237,7 +236,6 @@ "UA": "Ουκρανία", "UG": "Ουγκάντα", "UM": "Απομακρυσμένες Νησίδες ΗΠΑ", - "UN": "Ηνωμένα Έθνη", "US": "Ηνωμένες Πολιτείες", "UY": "Ουρουγουάη", "UZ": "Ουζμπεκιστάν", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/en.json b/src/Symfony/Component/Intl/Resources/data/regions/en.json index 74663075241bc..7b053c475c022 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/en.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/en.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Spain", "ET": "Ethiopia", - "EZ": "Eurozone", "FI": "Finland", "FJ": "Fiji", "FK": "Falkland Islands", @@ -237,7 +236,6 @@ "UA": "Ukraine", "UG": "Uganda", "UM": "U.S. Outlying Islands", - "UN": "United Nations", "US": "United States", "UY": "Uruguay", "UZ": "Uzbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/es.json b/src/Symfony/Component/Intl/Resources/data/regions/es.json index 3369ed0e0b945..451b4a7de640d 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/es.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/es.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "España", "ET": "Etiopía", - "EZ": "zona euro", "FI": "Finlandia", "FJ": "Fiyi", "FK": "Islas Malvinas", @@ -237,7 +236,6 @@ "UA": "Ucrania", "UG": "Uganda", "UM": "Islas menores alejadas de EE. UU.", - "UN": "Naciones Unidas", "US": "Estados Unidos", "UY": "Uruguay", "UZ": "Uzbekistán", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/es_419.json b/src/Symfony/Component/Intl/Resources/data/regions/es_419.json index 3b0afed924741..9b25f033b2010 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/es_419.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/es_419.json @@ -4,7 +4,6 @@ "AC": "Isla Ascensión", "BA": "Bosnia-Herzegovina", "CI": "Costa de Marfil", - "EZ": "Eurozona", "GG": "Guernesey", "IC": "Islas Canarias", "TA": "Tristán da Cunha", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/es_MX.json b/src/Symfony/Component/Intl/Resources/data/regions/es_MX.json index 6b0c66ccfc6e6..63cc2187ad45d 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/es_MX.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/es_MX.json @@ -3,12 +3,10 @@ "Names": { "BA": "Bosnia y Herzegovina", "CI": "Côte d’Ivoire", - "EZ": "zona euro", "GG": "Guernsey", "TA": "Tristán de Acuña", "TL": "Timor-Leste", "UM": "Islas menores alejadas de EE. UU.", - "UN": "UN", "VI": "Islas Vírgenes de EE. UU." } } diff --git a/src/Symfony/Component/Intl/Resources/data/regions/es_US.json b/src/Symfony/Component/Intl/Resources/data/regions/es_US.json index b1325a4b7da2e..3c694616bc6ba 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/es_US.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/es_US.json @@ -3,7 +3,6 @@ "Names": { "AC": "Isla de la Ascensión", "CI": "Côte d’Ivoire", - "EZ": "zona euro", "GG": "Guernsey", "TL": "Timor-Leste", "UM": "Islas menores alejadas de EE. UU.", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/et.json b/src/Symfony/Component/Intl/Resources/data/regions/et.json index e22adf5ffddb6..61008dc9e10ce 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/et.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/et.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Hispaania", "ET": "Etioopia", - "EZ": "euroala", "FI": "Soome", "FJ": "Fidži", "FK": "Falklandi saared", @@ -237,7 +236,6 @@ "UA": "Ukraina", "UG": "Uganda", "UM": "Ühendriikide hajasaared", - "UN": "Ühendatud Rahvaste Organisatsioon", "US": "Ameerika Ühendriigid", "UY": "Uruguay", "UZ": "Usbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/eu.json b/src/Symfony/Component/Intl/Resources/data/regions/eu.json index 9df3ed11c06c5..795a63a14a709 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/eu.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/eu.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Espainia", "ET": "Etiopia", - "EZ": "Eurogunea", "FI": "Finlandia", "FJ": "Fiji", "FK": "Malvinak", @@ -237,7 +236,6 @@ "UA": "Ukraina", "UG": "Uganda", "UM": "Ameriketako Estatu Batuetako Kanpoaldeko Uharte Txikiak", - "UN": "Nazio Batuak", "US": "Ameriketako Estatu Batuak", "UY": "Uruguai", "UZ": "Uzbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/fa.json b/src/Symfony/Component/Intl/Resources/data/regions/fa.json index fb2ac4af4cc69..d62eb92a0e597 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/fa.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/fa.json @@ -72,7 +72,6 @@ "ER": "اریتره", "ES": "اسپانیا", "ET": "اتیوپی", - "EZ": "منطقه یورو", "FI": "فنلاند", "FJ": "فیجی", "FK": "جزایر فالکلند", @@ -237,7 +236,6 @@ "UA": "اوکراین", "UG": "اوگاندا", "UM": "جزایر دورافتادهٔ ایالات متحده", - "UN": "سازمان ملل متحد", "US": "ایالات متحده", "UY": "اروگوئه", "UZ": "ازبکستان", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/fi.json b/src/Symfony/Component/Intl/Resources/data/regions/fi.json index 4ba9dcd1e77a3..a46d8175c79cc 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/fi.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/fi.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Espanja", "ET": "Etiopia", - "EZ": "euroalue", "FI": "Suomi", "FJ": "Fidži", "FK": "Falklandinsaaret", @@ -237,7 +236,6 @@ "UA": "Ukraina", "UG": "Uganda", "UM": "Yhdysvaltain erillissaaret", - "UN": "Yhdistyneet kansakunnat", "US": "Yhdysvallat", "UY": "Uruguay", "UZ": "Uzbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/fo.json b/src/Symfony/Component/Intl/Resources/data/regions/fo.json index 8459fc4314f81..649d9bc1bc787 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/fo.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/fo.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Spania", "ET": "Etiopia", - "EZ": "Evrasona", "FI": "Finnland", "FJ": "Fiji", "FK": "Falklandsoyggjar", @@ -237,7 +236,6 @@ "UA": "Ukraina", "UG": "Uganda", "UM": "Sambandsríki Amerikas fjarskotnu oyggjar", - "UN": "Sameindu Tjóðir", "US": "Sambandsríki Amerika", "UY": "Uruguai", "UZ": "Usbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/fr.json b/src/Symfony/Component/Intl/Resources/data/regions/fr.json index 17184b5d4f503..466fd46366f91 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/fr.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/fr.json @@ -72,7 +72,6 @@ "ER": "Érythrée", "ES": "Espagne", "ET": "Éthiopie", - "EZ": "zone euro", "FI": "Finlande", "FJ": "Fidji", "FK": "Îles Malouines", @@ -237,7 +236,6 @@ "UA": "Ukraine", "UG": "Ouganda", "UM": "Îles mineures éloignées des États-Unis", - "UN": "Nations Unies", "US": "États-Unis", "UY": "Uruguay", "UZ": "Ouzbékistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/ga.json b/src/Symfony/Component/Intl/Resources/data/regions/ga.json index ba938a53c13d6..6ca450d3aa64b 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/ga.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/ga.json @@ -72,7 +72,6 @@ "ER": "an Eiritré", "ES": "an Spáinn", "ET": "an Aetóip", - "EZ": "Limistéar an euro", "FI": "an Fhionlainn", "FJ": "Fidsí", "FK": "Oileáin Fháclainne", @@ -237,7 +236,6 @@ "UA": "an Úcráin", "UG": "Uganda", "UM": "Oileáin Imeallacha S.A.M.", - "UN": "na Náisiúin Aontaiteh", "US": "Stáit Aontaithe Mheiriceá", "UY": "Uragua", "UZ": "an Úisbéiceastáin", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/gd.json b/src/Symfony/Component/Intl/Resources/data/regions/gd.json index 6844ad29d3c84..88ebf40449e36 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/gd.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/gd.json @@ -72,7 +72,6 @@ "ER": "Eartra", "ES": "An Spàinnt", "ET": "An Itiop", - "EZ": "Raon an Eòro", "FI": "An Fhionnlann", "FJ": "Fìdi", "FK": "Na h-Eileanan Fàclannach", @@ -237,7 +236,6 @@ "UA": "An Ucràin", "UG": "Uganda", "UM": "Meanbh-Eileanan Iomallach nan SA", - "UN": "Na Dùthchannan Aonaichte", "US": "Na Stàitean Aonaichte", "UY": "Uruguaidh", "UZ": "Usbagastàn", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/gl.json b/src/Symfony/Component/Intl/Resources/data/regions/gl.json index e6f23e88f5bed..1cdd8900e1036 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/gl.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/gl.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "España", "ET": "Etiopía", - "EZ": "Eurozona", "FI": "Finlandia", "FJ": "Fidxi", "FK": "Illas Malvinas", @@ -237,7 +236,6 @@ "UA": "Ucraína", "UG": "Uganda", "UM": "Illas Ultramarinas dos EUA", - "UN": "Nacións Unidas", "US": "Estados Unidos de América", "UY": "Uruguai", "UZ": "Uzbequistán", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/gu.json b/src/Symfony/Component/Intl/Resources/data/regions/gu.json index d3e310380bcd4..83e9ba7a6268f 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/gu.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/gu.json @@ -72,7 +72,6 @@ "ER": "એરિટ્રિયા", "ES": "સ્પેન", "ET": "ઇથિઓપિયા", - "EZ": "યુરોઝોન", "FI": "ફિનલેન્ડ", "FJ": "ફીજી", "FK": "ફૉકલેન્ડ આઇલેન્ડ્સ", @@ -237,7 +236,6 @@ "UA": "યુક્રેન", "UG": "યુગાંડા", "UM": "યુ.એસ. આઉટલાઇનિંગ આઇલેન્ડ્સ", - "UN": "સંયુક્ત રાષ્ટ્ર", "US": "યુનાઇટેડ સ્ટેટ્સ", "UY": "ઉરુગ્વે", "UZ": "ઉઝ્બેકિસ્તાન", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/he.json b/src/Symfony/Component/Intl/Resources/data/regions/he.json index ce12c7030efa7..1bbfb96d1f06e 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/he.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/he.json @@ -72,7 +72,6 @@ "ER": "אריתריאה", "ES": "ספרד", "ET": "אתיופיה", - "EZ": "גוש האירו", "FI": "פינלנד", "FJ": "פיג׳י", "FK": "איי פוקלנד", @@ -237,7 +236,6 @@ "UA": "אוקראינה", "UG": "אוגנדה", "UM": "האיים המרוחקים הקטנים של ארה״ב", - "UN": "האומות המאוחדות", "US": "ארצות הברית", "UY": "אורוגוואי", "UZ": "אוזבקיסטן", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/hi.json b/src/Symfony/Component/Intl/Resources/data/regions/hi.json index 3cb506ce25115..9ea72b6b228dd 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/hi.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/hi.json @@ -72,7 +72,6 @@ "ER": "इरिट्रिया", "ES": "स्पेन", "ET": "इथियोपिया", - "EZ": "यूरोज़ोन", "FI": "फ़िनलैंड", "FJ": "फ़िजी", "FK": "फ़ॉकलैंड द्वीपसमूह", @@ -237,7 +236,6 @@ "UA": "यूक्रेन", "UG": "युगांडा", "UM": "यू॰एस॰ आउटलाइंग द्वीपसमूह", - "UN": "संयुक्त राष्ट्र", "US": "संयुक्त राज्य", "UY": "उरूग्वे", "UZ": "उज़्बेकिस्तान", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/hr.json b/src/Symfony/Component/Intl/Resources/data/regions/hr.json index b086e081de377..03f59c24e93ce 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/hr.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/hr.json @@ -72,7 +72,6 @@ "ER": "Eritreja", "ES": "Španjolska", "ET": "Etiopija", - "EZ": "eurozona", "FI": "Finska", "FJ": "Fidži", "FK": "Falklandski otoci", @@ -237,7 +236,6 @@ "UA": "Ukrajina", "UG": "Uganda", "UM": "Mali udaljeni otoci SAD-a", - "UN": "Ujedinjeni narodi", "US": "Sjedinjene Američke Države", "UY": "Urugvaj", "UZ": "Uzbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/hu.json b/src/Symfony/Component/Intl/Resources/data/regions/hu.json index badd300ee33e6..5011e0398285d 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/hu.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/hu.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Spanyolország", "ET": "Etiópia", - "EZ": "Eurózóna", "FI": "Finnország", "FJ": "Fidzsi", "FK": "Falkland-szigetek", @@ -237,7 +236,6 @@ "UA": "Ukrajna", "UG": "Uganda", "UM": "Az USA lakatlan külbirtokai", - "UN": "Egyesült Nemzetek Szervezete", "US": "Egyesült Államok", "UY": "Uruguay", "UZ": "Üzbegisztán", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/hy.json b/src/Symfony/Component/Intl/Resources/data/regions/hy.json index 08be7f38349f0..6f4ba308e0890 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/hy.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/hy.json @@ -72,7 +72,6 @@ "ER": "Էրիթրեա", "ES": "Իսպանիա", "ET": "Եթովպիա", - "EZ": "Եվրագոտի", "FI": "Ֆինլանդիա", "FJ": "Ֆիջի", "FK": "Ֆոլքլենդյան կղզիներ", @@ -237,7 +236,6 @@ "UA": "Ուկրաինա", "UG": "Ուգանդա", "UM": "Արտաքին կղզիներ (ԱՄՆ)", - "UN": "Միավորված ազգերի կազմակերպություն", "US": "Միացյալ Նահանգներ", "UY": "Ուրուգվայ", "UZ": "Ուզբեկստան", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/id.json b/src/Symfony/Component/Intl/Resources/data/regions/id.json index 552825ccdffd1..007d02cccbfd5 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/id.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/id.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Spanyol", "ET": "Etiopia", - "EZ": "Zona Euro", "FI": "Finlandia", "FJ": "Fiji", "FK": "Kepulauan Malvinas", @@ -237,7 +236,6 @@ "UA": "Ukraina", "UG": "Uganda", "UM": "Kepulauan Terluar A.S.", - "UN": "Perserikatan Bangsa-Bangsa", "US": "Amerika Serikat", "UY": "Uruguay", "UZ": "Uzbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/in.json b/src/Symfony/Component/Intl/Resources/data/regions/in.json index 552825ccdffd1..007d02cccbfd5 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/in.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/in.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Spanyol", "ET": "Etiopia", - "EZ": "Zona Euro", "FI": "Finlandia", "FJ": "Fiji", "FK": "Kepulauan Malvinas", @@ -237,7 +236,6 @@ "UA": "Ukraina", "UG": "Uganda", "UM": "Kepulauan Terluar A.S.", - "UN": "Perserikatan Bangsa-Bangsa", "US": "Amerika Serikat", "UY": "Uruguay", "UZ": "Uzbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/is.json b/src/Symfony/Component/Intl/Resources/data/regions/is.json index db171546d2bff..294f9fb20b580 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/is.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/is.json @@ -72,7 +72,6 @@ "ER": "Erítrea", "ES": "Spánn", "ET": "Eþíópía", - "EZ": "Evrusvæðið", "FI": "Finnland", "FJ": "Fídjíeyjar", "FK": "Falklandseyjar", @@ -237,7 +236,6 @@ "UA": "Úkraína", "UG": "Úganda", "UM": "Smáeyjar Bandaríkjanna", - "UN": "Sameinuðu þjóðirnar", "US": "Bandaríkin", "UY": "Úrúgvæ", "UZ": "Úsbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/it.json b/src/Symfony/Component/Intl/Resources/data/regions/it.json index 865a31a6accbd..5cef8d7ec790b 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/it.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/it.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Spagna", "ET": "Etiopia", - "EZ": "Eurozona", "FI": "Finlandia", "FJ": "Figi", "FK": "Isole Falkland", @@ -237,7 +236,6 @@ "UA": "Ucraina", "UG": "Uganda", "UM": "Altre isole americane del Pacifico", - "UN": "Nazioni Unite", "US": "Stati Uniti", "UY": "Uruguay", "UZ": "Uzbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/iw.json b/src/Symfony/Component/Intl/Resources/data/regions/iw.json index ce12c7030efa7..1bbfb96d1f06e 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/iw.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/iw.json @@ -72,7 +72,6 @@ "ER": "אריתריאה", "ES": "ספרד", "ET": "אתיופיה", - "EZ": "גוש האירו", "FI": "פינלנד", "FJ": "פיג׳י", "FK": "איי פוקלנד", @@ -237,7 +236,6 @@ "UA": "אוקראינה", "UG": "אוגנדה", "UM": "האיים המרוחקים הקטנים של ארה״ב", - "UN": "האומות המאוחדות", "US": "ארצות הברית", "UY": "אורוגוואי", "UZ": "אוזבקיסטן", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/ja.json b/src/Symfony/Component/Intl/Resources/data/regions/ja.json index 511a6bde6573f..f62db01842d52 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/ja.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/ja.json @@ -72,7 +72,6 @@ "ER": "エリトリア", "ES": "スペイン", "ET": "エチオピア", - "EZ": "ユーロ圏", "FI": "フィンランド", "FJ": "フィジー", "FK": "フォークランド諸島", @@ -237,7 +236,6 @@ "UA": "ウクライナ", "UG": "ウガンダ", "UM": "合衆国領有小離島", - "UN": "国際連合", "US": "アメリカ合衆国", "UY": "ウルグアイ", "UZ": "ウズベキスタン", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/ka.json b/src/Symfony/Component/Intl/Resources/data/regions/ka.json index 861ca2ea951ac..4d145bab65e37 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/ka.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/ka.json @@ -72,7 +72,6 @@ "ER": "ერიტრეა", "ES": "ესპანეთი", "ET": "ეთიოპია", - "EZ": "ევროზონა", "FI": "ფინეთი", "FJ": "ფიჯი", "FK": "ფოლკლენდის კუნძულები", @@ -237,7 +236,6 @@ "UA": "უკრაინა", "UG": "უგანდა", "UM": "აშშ-ის შორეული კუნძულები", - "UN": "გაერო", "US": "ამერიკის შეერთებული შტატები", "UY": "ურუგვაი", "UZ": "უზბეკეთი", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/kk.json b/src/Symfony/Component/Intl/Resources/data/regions/kk.json index 0c6e912947b2e..2cd5007dd1061 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/kk.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/kk.json @@ -72,7 +72,6 @@ "ER": "Эритрея", "ES": "Испания", "ET": "Эфиопия", - "EZ": "Еуроаймақ", "FI": "Финляндия", "FJ": "Фиджи", "FK": "Фолкленд аралдары", @@ -237,7 +236,6 @@ "UA": "Украина", "UG": "Уганда", "UM": "АҚШ-тың сыртқы кіші аралдары", - "UN": "Біріккен Ұлттар Ұйымы", "US": "Америка Құрама Штаттары", "UY": "Уругвай", "UZ": "Өзбекстан", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/km.json b/src/Symfony/Component/Intl/Resources/data/regions/km.json index 50d149e55e0dc..21fe35191db61 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/km.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/km.json @@ -72,7 +72,6 @@ "ER": "អេរីត្រេ", "ES": "អេស្ប៉ាញ", "ET": "អេត្យូពី", - "EZ": "តំបន់ចាយលុយអឺរ៉ូ", "FI": "ហ្វាំងឡង់", "FJ": "ហ្វីជី", "FK": "កោះ​ហ្វក់ឡែន", @@ -237,7 +236,6 @@ "UA": "អ៊ុយក្រែន", "UG": "អ៊ូហ្គង់ដា", "UM": "កោះ​អៅឡាយីង​អាមេរិក", - "UN": "អង្គការសហប្រជាជាតិ", "US": "សហរដ្ឋអាមេរិក", "UY": "អ៊ុយរូហ្គាយ", "UZ": "អ៊ូសបេគីស្ថាន", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/kn.json b/src/Symfony/Component/Intl/Resources/data/regions/kn.json index 0265e4f39be72..9e452245b0637 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/kn.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/kn.json @@ -72,7 +72,6 @@ "ER": "ಎರಿಟ್ರಿಯಾ", "ES": "ಸ್ಪೇನ್", "ET": "ಇಥಿಯೋಪಿಯಾ", - "EZ": "ಯೂರೋಝೋನ್‌", "FI": "ಫಿನ್‌ಲ್ಯಾಂಡ್", "FJ": "ಫಿಜಿ", "FK": "ಫಾಕ್‌ಲ್ಯಾಂಡ್ ದ್ವೀಪಗಳು", @@ -237,7 +236,6 @@ "UA": "ಉಕ್ರೈನ್", "UG": "ಉಗಾಂಡಾ", "UM": "ಯುಎಸ್‌ ಔಟ್‌ಲೇಯಿಂಗ್ ದ್ವೀಪಗಳು", - "UN": "ಸಂಯುಕ್ತ ಸಂಸ್ಥಾನಗಳು", "US": "ಅಮೇರಿಕಾ ಸಂಯುಕ್ತ ಸಂಸ್ಥಾನ", "UY": "ಉರುಗ್ವೆ", "UZ": "ಉಜ್ಬೇಕಿಸ್ಥಾನ್", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/ko.json b/src/Symfony/Component/Intl/Resources/data/regions/ko.json index e33d48d1b9deb..b955a71a5d35f 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/ko.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/ko.json @@ -72,7 +72,6 @@ "ER": "에리트리아", "ES": "스페인", "ET": "에티오피아", - "EZ": "유로존", "FI": "핀란드", "FJ": "피지", "FK": "포클랜드 제도", @@ -237,7 +236,6 @@ "UA": "우크라이나", "UG": "우간다", "UM": "미국령 해외 제도", - "UN": "유엔", "US": "미국", "UY": "우루과이", "UZ": "우즈베키스탄", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/ky.json b/src/Symfony/Component/Intl/Resources/data/regions/ky.json index e3acf4db41793..9b6d27ce8369d 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/ky.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/ky.json @@ -72,7 +72,6 @@ "ER": "Эритрея", "ES": "Испания", "ET": "Эфиопия", - "EZ": "Еврозона", "FI": "Финляндия", "FJ": "Фиджи", "FK": "Фолкленд аралдары", @@ -237,7 +236,6 @@ "UA": "Украина", "UG": "Уганда", "UM": "АКШнын сырткы аралдары", - "UN": "БУ", "US": "Америка Кошмо Штаттары", "UY": "Уругвай", "UZ": "Өзбекстан", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/lo.json b/src/Symfony/Component/Intl/Resources/data/regions/lo.json index 8de0bb9006954..fb116d91a0068 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/lo.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/lo.json @@ -72,7 +72,6 @@ "ER": "ເອຣິເທຣຍ", "ES": "ສະເປນ", "ET": "ອີທິໂອເປຍ", - "EZ": "ເຂດຢູໂຣບ", "FI": "ຟິນແລນ", "FJ": "ຟິຈິ", "FK": "ຫມູ່ເກາະຟອກແລນ", @@ -237,7 +236,6 @@ "UA": "ຢູເຄຣນ", "UG": "ອູການດາ", "UM": "ໝູ່ເກາະຮອບນອກຂອງສະຫະລັດຯ", - "UN": "ສະຫະປະຊາຊາດ", "US": "ສະຫະລັດ", "UY": "ອູຣຸກວຍ", "UZ": "ອຸສເບກິສະຖານ", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/lt.json b/src/Symfony/Component/Intl/Resources/data/regions/lt.json index d3d868d21ec1c..f7a79dbb770fd 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/lt.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/lt.json @@ -72,7 +72,6 @@ "ER": "Eritrėja", "ES": "Ispanija", "ET": "Etiopija", - "EZ": "euro zona", "FI": "Suomija", "FJ": "Fidžis", "FK": "Folklando Salos", @@ -237,7 +236,6 @@ "UA": "Ukraina", "UG": "Uganda", "UM": "Jungtinių Valstijų Mažosios Tolimosios Salos", - "UN": "Jungtinės Tautos", "US": "Jungtinės Valstijos", "UY": "Urugvajus", "UZ": "Uzbekistanas", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/lv.json b/src/Symfony/Component/Intl/Resources/data/regions/lv.json index a5d6739a27730..87ad10494cecd 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/lv.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/lv.json @@ -72,7 +72,6 @@ "ER": "Eritreja", "ES": "Spānija", "ET": "Etiopija", - "EZ": "Eirozona", "FI": "Somija", "FJ": "Fidži", "FK": "Folklenda salas", @@ -237,7 +236,6 @@ "UA": "Ukraina", "UG": "Uganda", "UM": "ASV Mazās Aizjūras salas", - "UN": "Apvienoto Nāciju Organizācija", "US": "Amerikas Savienotās Valstis", "UY": "Urugvaja", "UZ": "Uzbekistāna", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/meta.json b/src/Symfony/Component/Intl/Resources/data/regions/meta.json index 9dbe566037405..54569d238e0aa 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/meta.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/meta.json @@ -72,7 +72,6 @@ "ER", "ES", "ET", - "EZ", "FI", "FJ", "FK", @@ -237,7 +236,6 @@ "UA", "UG", "UM", - "UN", "US", "UY", "UZ", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/mk.json b/src/Symfony/Component/Intl/Resources/data/regions/mk.json index d03ade1157a73..bc11772b20bda 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/mk.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/mk.json @@ -72,7 +72,6 @@ "ER": "Еритреја", "ES": "Шпанија", "ET": "Етиопија", - "EZ": "Еврозона", "FI": "Финска", "FJ": "Фиџи", "FK": "Фолкландски Острови", @@ -237,7 +236,6 @@ "UA": "Украина", "UG": "Уганда", "UM": "Американски територии во Пацификот", - "UN": "Обединети нации", "US": "Соединети Американски Држави", "UY": "Уругвај", "UZ": "Узбекистан", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/ml.json b/src/Symfony/Component/Intl/Resources/data/regions/ml.json index 54e7f6568d3a4..6f367931cc9e4 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/ml.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/ml.json @@ -72,7 +72,6 @@ "ER": "എറിത്രിയ", "ES": "സ്‌പെയിൻ", "ET": "എത്യോപ്യ", - "EZ": "യൂറോസോൺ", "FI": "ഫിൻലാൻഡ്", "FJ": "ഫിജി", "FK": "ഫാക്ക്‌ലാന്റ് ദ്വീപുകൾ", @@ -237,7 +236,6 @@ "UA": "ഉക്രെയ്‌ൻ", "UG": "ഉഗാണ്ട", "UM": "യു.എസ്. ദ്വീപസമൂഹങ്ങൾ", - "UN": "ഐക്യരാഷ്ട്രസഭ", "US": "അമേരിക്കൻ ഐക്യനാടുകൾ", "UY": "ഉറുഗ്വേ", "UZ": "ഉസ്‌ബെക്കിസ്ഥാൻ", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/mn.json b/src/Symfony/Component/Intl/Resources/data/regions/mn.json index f32d2000b4a11..a40f22bb718c5 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/mn.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/mn.json @@ -72,7 +72,6 @@ "ER": "Эритрей", "ES": "Испани", "ET": "Этиоп", - "EZ": "Евро бүс", "FI": "Финланд", "FJ": "Фижи", "FK": "Фолклендийн арлууд", @@ -237,7 +236,6 @@ "UA": "Украин", "UG": "Уганда", "UM": "Америкийн Нэгдсэн Улсын бага арлууд", - "UN": "Нэгдсэн Үндэстний Байгууллага", "US": "Америкийн Нэгдсэн Улс", "UY": "Уругвай", "UZ": "Узбекистан", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/mr.json b/src/Symfony/Component/Intl/Resources/data/regions/mr.json index f80e64ff770d3..91786de809b82 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/mr.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/mr.json @@ -72,7 +72,6 @@ "ER": "एरिट्रिया", "ES": "स्पेन", "ET": "इथिओपिया", - "EZ": "युरोझोन", "FI": "फिनलंड", "FJ": "फिजी", "FK": "फॉकलंड बेटे", @@ -237,7 +236,6 @@ "UA": "युक्रेन", "UG": "युगांडा", "UM": "यू.एस. आउटलाइंग बेटे", - "UN": "संयुक्त राष्ट्र", "US": "युनायटेड स्टेट्स", "UY": "उरुग्वे", "UZ": "उझबेकिस्तान", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/ms.json b/src/Symfony/Component/Intl/Resources/data/regions/ms.json index a5b9fae212e0f..6c407fbc872d1 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/ms.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/ms.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Sepanyol", "ET": "Ethiopia", - "EZ": "Zon Euro", "FI": "Finland", "FJ": "Fiji", "FK": "Kepulauan Falkland", @@ -237,7 +236,6 @@ "UA": "Ukraine", "UG": "Uganda", "UM": "Kepulauan Terpencil A.S.", - "UN": "Bangsa-bangsa Bersatu", "US": "Amerika Syarikat", "UY": "Uruguay", "UZ": "Uzbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/my.json b/src/Symfony/Component/Intl/Resources/data/regions/my.json index 73946f0ac61fa..5a40c847b516a 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/my.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/my.json @@ -72,7 +72,6 @@ "ER": "အီရီထရီးယား", "ES": "စပိန်", "ET": "အီသီယိုးပီးယား", - "EZ": "ဥရောပဒေသ", "FI": "ဖင်လန်", "FJ": "ဖီဂျီ", "FK": "ဖော့ကလန် ကျွန်းစု", @@ -237,7 +236,6 @@ "UA": "ယူကရိန်း", "UG": "ယူဂန်းဒါး", "UM": "ယူနိုက်တက်စတိတ် ကျွန်းနိုင်ငံများ", - "UN": "ကုလသမဂ္ဂ", "US": "အမေရိကန် ပြည်ထောင်စု", "UY": "ဥရုဂွေး", "UZ": "ဥဇဘက်ကစ္စတန်", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/nb.json b/src/Symfony/Component/Intl/Resources/data/regions/nb.json index ad15e817644d3..dcf10608a7458 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/nb.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/nb.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Spania", "ET": "Etiopia", - "EZ": "eurosonen", "FI": "Finland", "FJ": "Fiji", "FK": "Falklandsøyene", @@ -237,7 +236,6 @@ "UA": "Ukraina", "UG": "Uganda", "UM": "USAs ytre øyer", - "UN": "FN", "US": "USA", "UY": "Uruguay", "UZ": "Usbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/ne.json b/src/Symfony/Component/Intl/Resources/data/regions/ne.json index a72f1fdccf6ea..34600f488c87e 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/ne.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/ne.json @@ -72,7 +72,6 @@ "ER": "एरित्रिया", "ES": "स्पेन", "ET": "इथियोपिया", - "EZ": "युरोजोन", "FI": "फिन्ल्याण्ड", "FJ": "फिजी", "FK": "फकल्याण्ड टापुहरु", @@ -237,7 +236,6 @@ "UA": "युक्रेन", "UG": "युगाण्डा", "UM": "संयुक्त राज्यका बाह्य टापुहरु", - "UN": "संयुक्त राष्ट्र संघ", "US": "संयुक्त राज्य", "UY": "उरूग्वे", "UZ": "उज्बेकिस्तान", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/nl.json b/src/Symfony/Component/Intl/Resources/data/regions/nl.json index a57efb1b355b2..48abedc9313bb 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/nl.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/nl.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Spanje", "ET": "Ethiopië", - "EZ": "eurozone", "FI": "Finland", "FJ": "Fiji", "FK": "Falklandeilanden", @@ -237,7 +236,6 @@ "UA": "Oekraïne", "UG": "Oeganda", "UM": "Kleine afgelegen eilanden van de Verenigde Staten", - "UN": "Verenigde Naties", "US": "Verenigde Staten", "UY": "Uruguay", "UZ": "Oezbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/nn.json b/src/Symfony/Component/Intl/Resources/data/regions/nn.json index 60e95611cf146..e80e7639fa26b 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/nn.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/nn.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Spania", "ET": "Etiopia", - "EZ": "eurosona", "FI": "Finland", "FJ": "Fiji", "FK": "Falklandsøyane", @@ -237,7 +236,6 @@ "UA": "Ukraina", "UG": "Uganda", "UM": "USAs ytre småøyar", - "UN": "SN", "US": "USA", "UY": "Uruguay", "UZ": "Usbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/no.json b/src/Symfony/Component/Intl/Resources/data/regions/no.json index ad15e817644d3..dcf10608a7458 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/no.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/no.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Spania", "ET": "Etiopia", - "EZ": "eurosonen", "FI": "Finland", "FJ": "Fiji", "FK": "Falklandsøyene", @@ -237,7 +236,6 @@ "UA": "Ukraina", "UG": "Uganda", "UM": "USAs ytre øyer", - "UN": "FN", "US": "USA", "UY": "Uruguay", "UZ": "Usbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/or.json b/src/Symfony/Component/Intl/Resources/data/regions/or.json index c7d9d4c46118a..e2680dc0d3c79 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/or.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/or.json @@ -72,7 +72,6 @@ "ER": "ଇରିଟ୍ରିୟା", "ES": "ସ୍ପେନ୍", "ET": "ଇଥିଓପିଆ", - "EZ": "ୟୁରୋକ୍ଷେତ୍ର", "FI": "ଫିନଲ୍ୟାଣ୍ଡ", "FJ": "ଫିଜି", "FK": "ଫକ୍‌ଲ୍ୟାଣ୍ଡ ଦ୍ଵୀପପୁଞ୍ଜ", @@ -237,7 +236,6 @@ "UA": "ୟୁକ୍ରେନ୍‌", "UG": "ଉଗାଣ୍ଡା", "UM": "ଯୁକ୍ତରାଷ୍ଟ୍ର ଆଉଟ୍‌ଲାଇଙ୍ଗ ଦ୍ଵୀପପୁଞ୍ଜ", - "UN": "ଜାତିସଂଘ", "US": "ଯୁକ୍ତ ରାଷ୍ଟ୍ର", "UY": "ଉରୁଗୁଏ", "UZ": "ଉଜବେକିସ୍ତାନ", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/pa.json b/src/Symfony/Component/Intl/Resources/data/regions/pa.json index 206bf55846097..f8091bd3bdecf 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/pa.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/pa.json @@ -72,7 +72,6 @@ "ER": "ਇਰੀਟ੍ਰਿਆ", "ES": "ਸਪੇਨ", "ET": "ਇਥੋਪੀਆ", - "EZ": "EZ", "FI": "ਫਿਨਲੈਂਡ", "FJ": "ਫ਼ਿਜੀ", "FK": "ਫ਼ਾਕਲੈਂਡ ਟਾਪੂ", @@ -237,7 +236,6 @@ "UA": "ਯੂਕਰੇਨ", "UG": "ਯੂਗਾਂਡਾ", "UM": "ਯੂ.ਐੱਸ. ਦੂਰ-ਦੁਰਾਡੇ ਟਾਪੂ", - "UN": "ਸੰਯੁਕਤ ਰਾਸ਼ਟਰ", "US": "ਸੰਯੁਕਤ ਰਾਜ", "UY": "ਉਰੂਗਵੇ", "UZ": "ਉਜ਼ਬੇਕਿਸਤਾਨ", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/pl.json b/src/Symfony/Component/Intl/Resources/data/regions/pl.json index 9abb131f316fd..671b9d6d74d88 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/pl.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/pl.json @@ -72,7 +72,6 @@ "ER": "Erytrea", "ES": "Hiszpania", "ET": "Etiopia", - "EZ": "strefa euro", "FI": "Finlandia", "FJ": "Fidżi", "FK": "Falklandy", @@ -237,7 +236,6 @@ "UA": "Ukraina", "UG": "Uganda", "UM": "Dalekie Wyspy Mniejsze Stanów Zjednoczonych", - "UN": "Organizacja Narodów Zjednoczonych", "US": "Stany Zjednoczone", "UY": "Urugwaj", "UZ": "Uzbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/ps.json b/src/Symfony/Component/Intl/Resources/data/regions/ps.json index 03675445edcd4..45d6a2d8e5ebb 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/ps.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/ps.json @@ -72,7 +72,6 @@ "ER": "اریتره", "ES": "هسپانیه", "ET": "حبشه", - "EZ": "اروپاسيمه", "FI": "فنلینډ", "FJ": "في جي", "FK": "فوکلنډ ټاپو", @@ -237,7 +236,6 @@ "UA": "اوکراین", "UG": "یوګانډا", "UM": "د متحده ایالاتو ټاپو ټاپوګانې", - "UN": "ملگري ملتونه", "US": "متحده ایالات", "UY": "یوروګوی", "UZ": "اوزبکستان", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/pt.json b/src/Symfony/Component/Intl/Resources/data/regions/pt.json index 6bf9bf4269523..a004367e161f9 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/pt.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/pt.json @@ -72,7 +72,6 @@ "ER": "Eritreia", "ES": "Espanha", "ET": "Etiópia", - "EZ": "zona do euro", "FI": "Finlândia", "FJ": "Fiji", "FK": "Ilhas Malvinas", @@ -237,7 +236,6 @@ "UA": "Ucrânia", "UG": "Uganda", "UM": "Ilhas Menores Distantes dos EUA", - "UN": "Nações Unidas", "US": "Estados Unidos", "UY": "Uruguai", "UZ": "Uzbequistão", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/pt_PT.json b/src/Symfony/Component/Intl/Resources/data/regions/pt_PT.json index 38c9ce880b379..5b84703bffea6 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/pt_PT.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/pt_PT.json @@ -19,7 +19,6 @@ "DM": "Domínica", "EE": "Estónia", "EH": "Sara Ocidental", - "EZ": "Zona Euro", "FK": "Ilhas Falkland", "FO": "Ilhas Faroé", "GL": "Gronelândia", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/ro.json b/src/Symfony/Component/Intl/Resources/data/regions/ro.json index 76157267588b0..11c04d88d2c7f 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/ro.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/ro.json @@ -72,7 +72,6 @@ "ER": "Eritreea", "ES": "Spania", "ET": "Etiopia", - "EZ": "Zona euro", "FI": "Finlanda", "FJ": "Fiji", "FK": "Insulele Falkland", @@ -237,7 +236,6 @@ "UA": "Ucraina", "UG": "Uganda", "UM": "Insulele Îndepărtate ale S.U.A.", - "UN": "Națiunile Unite", "US": "Statele Unite ale Americii", "UY": "Uruguay", "UZ": "Uzbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/ru.json b/src/Symfony/Component/Intl/Resources/data/regions/ru.json index 3b172ca715175..569797192e320 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/ru.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/ru.json @@ -72,7 +72,6 @@ "ER": "Эритрея", "ES": "Испания", "ET": "Эфиопия", - "EZ": "еврозона", "FI": "Финляндия", "FJ": "Фиджи", "FK": "Фолклендские о-ва", @@ -237,7 +236,6 @@ "UA": "Украина", "UG": "Уганда", "UM": "Внешние малые о-ва (США)", - "UN": "Организация Объединенных Наций", "US": "Соединенные Штаты", "UY": "Уругвай", "UZ": "Узбекистан", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/se_FI.json b/src/Symfony/Component/Intl/Resources/data/regions/se_FI.json index 5aba89f37403b..41c5b42ffc25d 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/se_FI.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/se_FI.json @@ -2,10 +2,8 @@ "Version": "2.1.38.73", "Names": { "BA": "Bosnia ja Hercegovina", - "EZ": "Euroavádat", "KH": "Kamboža", "SD": "Sudan", - "TD": "Chad", - "UN": "Ovttastuvvan Našuvnnat" + "TD": "Chad" } } diff --git a/src/Symfony/Component/Intl/Resources/data/regions/sh.json b/src/Symfony/Component/Intl/Resources/data/regions/sh.json index e8b664995118a..b634f3bef4f3e 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/sh.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/sh.json @@ -72,7 +72,6 @@ "ER": "Eritreja", "ES": "Španija", "ET": "Etiopija", - "EZ": "Evrozona", "FI": "Finska", "FJ": "Fidži", "FK": "Foklandska Ostrva", @@ -237,7 +236,6 @@ "UA": "Ukrajina", "UG": "Uganda", "UM": "Udaljena ostrva SAD", - "UN": "Ujedinjene nacije", "US": "Sjedinjene Države", "UY": "Urugvaj", "UZ": "Uzbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/si.json b/src/Symfony/Component/Intl/Resources/data/regions/si.json index 9975aeec7d45f..c3b969881e4bb 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/si.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/si.json @@ -72,7 +72,6 @@ "ER": "එරිත්‍රියාව", "ES": "ස්පාඤ්ඤය", "ET": "ඉතියෝපියාව", - "EZ": "යුරෝ කලාපය", "FI": "ෆින්ලන්තය", "FJ": "ෆීජී", "FK": "ෆෝක්ලන්ත දූපත්", @@ -237,7 +236,6 @@ "UA": "යුක්රේනය", "UG": "උගන්ඩාව", "UM": "එක්සත් ජනපද ඈත දූපත්", - "UN": "එක්සත් ජාතීන්", "US": "එක්සත් ජනපදය", "UY": "උරුගුවේ", "UZ": "උස්බෙකිස්ථානය", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/sk.json b/src/Symfony/Component/Intl/Resources/data/regions/sk.json index 0bba0649a8f31..7d8d918b4495c 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/sk.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/sk.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Španielsko", "ET": "Etiópia", - "EZ": "eurozóna", "FI": "Fínsko", "FJ": "Fidži", "FK": "Falklandy", @@ -237,7 +236,6 @@ "UA": "Ukrajina", "UG": "Uganda", "UM": "Menšie odľahlé ostrovy USA", - "UN": "Organizácia Spojených národov", "US": "Spojené štáty", "UY": "Uruguaj", "UZ": "Uzbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/sl.json b/src/Symfony/Component/Intl/Resources/data/regions/sl.json index c84a219667d13..15bea67b9d04a 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/sl.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/sl.json @@ -72,7 +72,6 @@ "ER": "Eritreja", "ES": "Španija", "ET": "Etiopija", - "EZ": "evroobmočje", "FI": "Finska", "FJ": "Fidži", "FK": "Falklandski otoki", @@ -237,7 +236,6 @@ "UA": "Ukrajina", "UG": "Uganda", "UM": "Stranski zunanji otoki Združenih držav", - "UN": "Združeni narodi", "US": "Združene države Amerike", "UY": "Urugvaj", "UZ": "Uzbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/sq.json b/src/Symfony/Component/Intl/Resources/data/regions/sq.json index af82944add734..67a4d6bcf7c0f 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/sq.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/sq.json @@ -72,7 +72,6 @@ "ER": "Eritre", "ES": "Spanjë", "ET": "Etiopi", - "EZ": "Eurozonë", "FI": "Finlandë", "FJ": "Fixhi", "FK": "Ishujt Falkland", @@ -237,7 +236,6 @@ "UA": "Ukrainë", "UG": "Ugandë", "UM": "Ishujt Periferikë të SHBA-së", - "UN": "Kombet e Bashkuara", "US": "Shtetet e Bashkuara të Amerikës", "UY": "Uruguai", "UZ": "Uzbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/sr.json b/src/Symfony/Component/Intl/Resources/data/regions/sr.json index 125467cbb16d4..e11116d2d8196 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/sr.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/sr.json @@ -72,7 +72,6 @@ "ER": "Еритреја", "ES": "Шпанија", "ET": "Етиопија", - "EZ": "Еврозона", "FI": "Финска", "FJ": "Фиџи", "FK": "Фокландска Острва", @@ -237,7 +236,6 @@ "UA": "Украјина", "UG": "Уганда", "UM": "Удаљена острва САД", - "UN": "Уједињене нације", "US": "Сједињене Државе", "UY": "Уругвај", "UZ": "Узбекистан", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/sr_Latn.json b/src/Symfony/Component/Intl/Resources/data/regions/sr_Latn.json index e8b664995118a..b634f3bef4f3e 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/sr_Latn.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/sr_Latn.json @@ -72,7 +72,6 @@ "ER": "Eritreja", "ES": "Španija", "ET": "Etiopija", - "EZ": "Evrozona", "FI": "Finska", "FJ": "Fidži", "FK": "Foklandska Ostrva", @@ -237,7 +236,6 @@ "UA": "Ukrajina", "UG": "Uganda", "UM": "Udaljena ostrva SAD", - "UN": "Ujedinjene nacije", "US": "Sjedinjene Države", "UY": "Urugvaj", "UZ": "Uzbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/sv.json b/src/Symfony/Component/Intl/Resources/data/regions/sv.json index 5801373a61caa..934324ff96fda 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/sv.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/sv.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Spanien", "ET": "Etiopien", - "EZ": "eurozonen", "FI": "Finland", "FJ": "Fiji", "FK": "Falklandsöarna", @@ -237,7 +236,6 @@ "UA": "Ukraina", "UG": "Uganda", "UM": "USA:s yttre öar", - "UN": "Förenta Nationerna", "US": "USA", "UY": "Uruguay", "UZ": "Uzbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/sw.json b/src/Symfony/Component/Intl/Resources/data/regions/sw.json index 2cb97478b9b35..a91a143bbc696 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/sw.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/sw.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Uhispania", "ET": "Ethiopia", - "EZ": "EZ", "FI": "Ufini", "FJ": "Fiji", "FK": "Visiwa vya Falkland", @@ -237,7 +236,6 @@ "UA": "Ukraine", "UG": "Uganda", "UM": "Visiwa Vidogo vya Nje vya Marekani", - "UN": "Umoja wa Mataifa", "US": "Marekani", "UY": "Uruguay", "UZ": "Uzibekistani", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/ta.json b/src/Symfony/Component/Intl/Resources/data/regions/ta.json index 0cc6b2e94f282..b8238eeae1acc 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/ta.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/ta.json @@ -72,7 +72,6 @@ "ER": "எரிட்ரியா", "ES": "ஸ்பெயின்", "ET": "எத்தியோப்பியா", - "EZ": "யூரோஜோன்", "FI": "பின்லாந்து", "FJ": "ஃபிஜி", "FK": "ஃபாக்லாந்து தீவுகள்", @@ -237,7 +236,6 @@ "UA": "உக்ரைன்", "UG": "உகாண்டா", "UM": "யூ.எஸ். வெளிப்புறத் தீவுகள்", - "UN": "ஐக்கிய நாடுகள்", "US": "அமெரிக்கா", "UY": "உருகுவே", "UZ": "உஸ்பெகிஸ்தான்", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/te.json b/src/Symfony/Component/Intl/Resources/data/regions/te.json index e845e339bfb40..0045be5f4e123 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/te.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/te.json @@ -72,7 +72,6 @@ "ER": "ఎరిట్రియా", "ES": "స్పెయిన్", "ET": "ఇథియోపియా", - "EZ": "యూరోజోన్", "FI": "ఫిన్లాండ్", "FJ": "ఫిజీ", "FK": "ఫాక్‌ల్యాండ్ దీవులు", @@ -237,7 +236,6 @@ "UA": "ఉక్రెయిన్", "UG": "ఉగాండా", "UM": "సంయుక్త రాజ్య అమెరికా బయట ఉన్న దీవులు", - "UN": "యునైటెడ్ నేషన్స్", "US": "యునైటెడ్ స్టేట్స్", "UY": "ఉరుగ్వే", "UZ": "ఉజ్బెకిస్తాన్", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/th.json b/src/Symfony/Component/Intl/Resources/data/regions/th.json index 3317bbc7543e0..defa020527ad5 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/th.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/th.json @@ -72,7 +72,6 @@ "ER": "เอริเทรีย", "ES": "สเปน", "ET": "เอธิโอเปีย", - "EZ": "ยูโรโซน", "FI": "ฟินแลนด์", "FJ": "ฟิจิ", "FK": "หมู่เกาะฟอล์กแลนด์", @@ -237,7 +236,6 @@ "UA": "ยูเครน", "UG": "ยูกันดา", "UM": "หมู่เกาะรอบนอกของสหรัฐอเมริกา", - "UN": "สหประชาชาติ", "US": "สหรัฐอเมริกา", "UY": "อุรุกวัย", "UZ": "อุซเบกิสถาน", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/tl.json b/src/Symfony/Component/Intl/Resources/data/regions/tl.json index 19554b3f88089..546894d8f35d2 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/tl.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/tl.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Spain", "ET": "Ethiopia", - "EZ": "Eurozone", "FI": "Finland", "FJ": "Fiji", "FK": "Falkland Islands", @@ -237,7 +236,6 @@ "UA": "Ukraine", "UG": "Uganda", "UM": "U.S. Outlying Islands", - "UN": "United Nations", "US": "Estados Unidos", "UY": "Uruguay", "UZ": "Uzbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/to.json b/src/Symfony/Component/Intl/Resources/data/regions/to.json index 5b63c0201836c..28812f59eed6e 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/to.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/to.json @@ -72,7 +72,6 @@ "ER": "ʻElitulia", "ES": "Sipeini", "ET": "ʻĪtiōpia", - "EZ": "ʻEulope fekauʻaki-paʻanga", "FI": "Finilani", "FJ": "Fisi", "FK": "ʻOtumotu Fokulani", @@ -237,7 +236,6 @@ "UA": "ʻŪkalaʻine", "UG": "ʻIukanitā", "UM": "ʻOtumotu siʻi ʻo ʻAmelika", - "UN": "ʻŪ fonua fakatahataha", "US": "Puleʻanga fakatahataha ʻAmelika", "UY": "ʻUlukuai", "UZ": "ʻUsipekitani", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/tr.json b/src/Symfony/Component/Intl/Resources/data/regions/tr.json index 6e12bc5f1f1be..6996536cbd2eb 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/tr.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/tr.json @@ -72,7 +72,6 @@ "ER": "Eritre", "ES": "İspanya", "ET": "Etiyopya", - "EZ": "Euro Bölgesi", "FI": "Finlandiya", "FJ": "Fiji", "FK": "Falkland Adaları", @@ -237,7 +236,6 @@ "UA": "Ukrayna", "UG": "Uganda", "UM": "ABD Küçük Harici Adaları", - "UN": "Birleşmiş Milletler", "US": "Amerika Birleşik Devletleri", "UY": "Uruguay", "UZ": "Özbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/uk.json b/src/Symfony/Component/Intl/Resources/data/regions/uk.json index 5ddda82648360..08d88962151d0 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/uk.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/uk.json @@ -72,7 +72,6 @@ "ER": "Еритрея", "ES": "Іспанія", "ET": "Ефіопія", - "EZ": "Єврозона", "FI": "Фінляндія", "FJ": "Фіджі", "FK": "Фолклендські острови", @@ -237,7 +236,6 @@ "UA": "Україна", "UG": "Уганда", "UM": "Віддалені острови США", - "UN": "Організація Об’єднаних Націй", "US": "Сполучені Штати", "UY": "Уруґвай", "UZ": "Узбекистан", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/ur.json b/src/Symfony/Component/Intl/Resources/data/regions/ur.json index f315ffdedf7bf..ec4a8aff46592 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/ur.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/ur.json @@ -72,7 +72,6 @@ "ER": "اریٹیریا", "ES": "ہسپانیہ", "ET": "ایتھوپیا", - "EZ": "یوروزون", "FI": "فن لینڈ", "FJ": "فجی", "FK": "فاکلینڈ جزائر", @@ -237,7 +236,6 @@ "UA": "یوکرین", "UG": "یوگنڈا", "UM": "امریکہ سے باہر کے چھوٹے جزائز", - "UN": "اقوام متحدہ", "US": "ریاستہائے متحدہ", "UY": "یوروگوئے", "UZ": "ازبکستان", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/uz.json b/src/Symfony/Component/Intl/Resources/data/regions/uz.json index ab2ddfc66edff..ff17448c5707b 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/uz.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/uz.json @@ -72,7 +72,6 @@ "ER": "Eritreya", "ES": "Ispaniya", "ET": "Efiopiya", - "EZ": "yevrozona", "FI": "Finlandiya", "FJ": "Fiji", "FK": "Folklend orollari", @@ -237,7 +236,6 @@ "UA": "Ukraina", "UG": "Uganda", "UM": "AQSH yondosh orollari", - "UN": "Birlashgan Millatlar Tashkiloti", "US": "Amerika Qo‘shma Shtatlari", "UY": "Urugvay", "UZ": "Oʻzbekiston", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/vi.json b/src/Symfony/Component/Intl/Resources/data/regions/vi.json index 4d286235a8b53..71df7f435e522 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/vi.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/vi.json @@ -72,7 +72,6 @@ "ER": "Eritrea", "ES": "Tây Ban Nha", "ET": "Ethiopia", - "EZ": "Khu vực đồng Euro", "FI": "Phần Lan", "FJ": "Fiji", "FK": "Quần đảo Falkland", @@ -237,7 +236,6 @@ "UA": "Ukraina", "UG": "Uganda", "UM": "Các tiểu đảo xa của Hoa Kỳ", - "UN": "Liên hiệp quốc", "US": "Hoa Kỳ", "UY": "Uruguay", "UZ": "Uzbekistan", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/zh.json b/src/Symfony/Component/Intl/Resources/data/regions/zh.json index 4fc172b7647ad..6a1e11eefd4da 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/zh.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/zh.json @@ -72,7 +72,6 @@ "ER": "厄立特里亚", "ES": "西班牙", "ET": "埃塞俄比亚", - "EZ": "欧元区", "FI": "芬兰", "FJ": "斐济", "FK": "福克兰群岛", @@ -237,7 +236,6 @@ "UA": "乌克兰", "UG": "乌干达", "UM": "美国本土外小岛屿", - "UN": "联合国", "US": "美国", "UY": "乌拉圭", "UZ": "乌兹别克斯坦", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/zh_Hant.json b/src/Symfony/Component/Intl/Resources/data/regions/zh_Hant.json index 1b7ef475ad1e1..ab60d9829570c 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/zh_Hant.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/zh_Hant.json @@ -72,7 +72,6 @@ "ER": "厄利垂亞", "ES": "西班牙", "ET": "衣索比亞", - "EZ": "歐元區", "FI": "芬蘭", "FJ": "斐濟", "FK": "福克蘭群島", @@ -237,7 +236,6 @@ "UA": "烏克蘭", "UG": "烏干達", "UM": "美國本土外小島嶼", - "UN": "聯合國", "US": "美國", "UY": "烏拉圭", "UZ": "烏茲別克", diff --git a/src/Symfony/Component/Intl/Resources/data/regions/zu.json b/src/Symfony/Component/Intl/Resources/data/regions/zu.json index e92b1858c0684..77f36017cfd58 100644 --- a/src/Symfony/Component/Intl/Resources/data/regions/zu.json +++ b/src/Symfony/Component/Intl/Resources/data/regions/zu.json @@ -72,7 +72,6 @@ "ER": "i-Eritrea", "ES": "i-Spain", "ET": "i-Ethiopia", - "EZ": "EZ", "FI": "i-Finland", "FJ": "i-Fiji", "FK": "i-Falkland Islands", @@ -237,7 +236,6 @@ "UA": "i-Ukraine", "UG": "i-Uganda", "UM": "i-U.S. Minor Outlying Islands", - "UN": "I-United Nations", "US": "i-United States", "UY": "i-Uruguay", "UZ": "i-Uzbekistan", diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractRegionDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractRegionDataProviderTest.php index 1b790d41c9a73..f282d64e01930 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractRegionDataProviderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractRegionDataProviderTest.php @@ -94,7 +94,6 @@ abstract class AbstractRegionDataProviderTest extends AbstractDataProviderTest 'ER', 'ES', 'ET', - 'EZ', 'FI', 'FJ', 'FK', @@ -259,7 +258,6 @@ abstract class AbstractRegionDataProviderTest extends AbstractDataProviderTest 'UA', 'UG', 'UM', - 'UN', 'US', 'UY', 'UZ', diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php index 3f1b29870357e..e747ad9cf639d 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php @@ -654,6 +654,7 @@ public function parseProvider() array('-123,4567', false, '->parse() does not parse when invalid grouping used.', 9), array('-123,,456', false, '->parse() does not parse when invalid grouping used.', 4), array('-123,,456', -123.0, '->parse() parses when grouping is disabled.', 4, false), + array('239.', 239.0, '->parse() parses when string ends with decimal separator.', 4, false), ); } diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php index d2453f20d6287..3ff790d05181f 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php @@ -137,7 +137,7 @@ private function connect() throw new LdapException(sprintf('Could not connect to Ldap server: %s.', ldap_error($this->connection))); } - if ('tls' === $this->config['encryption'] && false === ldap_start_tls($this->connection)) { + if ('tls' === $this->config['encryption'] && false === @ldap_start_tls($this->connection)) { throw new LdapException(sprintf('Could not initiate TLS connection: %s.', ldap_error($this->connection))); } } diff --git a/src/Symfony/Component/Lock/Lock.php b/src/Symfony/Component/Lock/Lock.php index f32ad351e3e8e..bef58fbec277f 100644 --- a/src/Symfony/Component/Lock/Lock.php +++ b/src/Symfony/Component/Lock/Lock.php @@ -69,10 +69,10 @@ public function __destruct() public function acquire($blocking = false) { try { - if (!$blocking) { - $this->store->save($this->key); - } else { + if ($blocking) { $this->store->waitAndSave($this->key); + } else { + $this->store->save($this->key); } $this->dirty = true; diff --git a/src/Symfony/Component/Lock/Store/CombinedStore.php b/src/Symfony/Component/Lock/Store/CombinedStore.php index b3c76d013e332..b0ca2c1454e0b 100644 --- a/src/Symfony/Component/Lock/Store/CombinedStore.php +++ b/src/Symfony/Component/Lock/Store/CombinedStore.php @@ -151,8 +151,6 @@ public function delete(Key $key) $store->delete($key); } catch (\Exception $e) { $this->logger->notice('One store failed to delete the "{resource}" lock.', array('resource' => $key, 'store' => $store, 'exception' => $e)); - } catch (\Throwable $e) { - $this->logger->notice('One store failed to delete the "{resource}" lock.', array('resource' => $key, 'store' => $store, 'exception' => $e)); } } } diff --git a/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php index 699a3072b3415..f2c55b056b324 100644 --- a/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php @@ -58,7 +58,7 @@ public function getStore() /** @var CombinedStore */ private $store; - public function setup() + protected function setUp() { $this->strategy = $this->getMockBuilder(StrategyInterface::class)->getMock(); $this->store1 = $this->getMockBuilder(StoreInterface::class)->getMock(); diff --git a/src/Symfony/Component/Lock/Tests/Strategy/ConsensusStrategyTest.php b/src/Symfony/Component/Lock/Tests/Strategy/ConsensusStrategyTest.php index 87e83a9925695..b8c09dfb31fa2 100644 --- a/src/Symfony/Component/Lock/Tests/Strategy/ConsensusStrategyTest.php +++ b/src/Symfony/Component/Lock/Tests/Strategy/ConsensusStrategyTest.php @@ -22,7 +22,7 @@ class ConsensusStrategyTest extends TestCase /** @var ConsensusStrategy */ private $strategy; - public function setup() + protected function setUp() { $this->strategy = new ConsensusStrategy(); } diff --git a/src/Symfony/Component/Lock/Tests/Strategy/UnanimousStrategyTest.php b/src/Symfony/Component/Lock/Tests/Strategy/UnanimousStrategyTest.php index beff54a685747..4e63e6b4e2cd4 100644 --- a/src/Symfony/Component/Lock/Tests/Strategy/UnanimousStrategyTest.php +++ b/src/Symfony/Component/Lock/Tests/Strategy/UnanimousStrategyTest.php @@ -22,7 +22,7 @@ class UnanimousStrategyTest extends TestCase /** @var UnanimousStrategy */ private $strategy; - public function setup() + protected function setUp() { $this->strategy = new UnanimousStrategy(); } diff --git a/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php b/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php index 2de3289a51695..a714375ede1b2 100644 --- a/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php +++ b/src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php @@ -64,7 +64,7 @@ public function process(ContainerBuilder $container) $container->getParameterBag()->remove($busMiddlewareParameter); } - if ($container->hasDefinition('messenger.data_collector')) { + if ($container->hasDefinition('data_collector.messenger')) { $this->registerBusToCollector($container, $busId); } } @@ -276,7 +276,7 @@ private function registerBusToCollector(ContainerBuilder $container, string $bus (new Definition(TraceableMessageBus::class, array(new Reference($tracedBusId.'.inner'))))->setDecoratedService($busId) ); - $container->getDefinition('messenger.data_collector')->addMethodCall('registerBus', array($busId, new Reference($tracedBusId))); + $container->getDefinition('data_collector.messenger')->addMethodCall('registerBus', array($busId, new Reference($tracedBusId))); } private function registerBusMiddleware(ContainerBuilder $container, string $busId, array $middlewareCollection) diff --git a/src/Symfony/Component/Messenger/LICENSE b/src/Symfony/Component/Messenger/LICENSE new file mode 100644 index 0000000000000..ad399a798d6d2 --- /dev/null +++ b/src/Symfony/Component/Messenger/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2018 Fabien Potencier + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php b/src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php index f3fc76baa386d..3fed181ad20e9 100644 --- a/src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php +++ b/src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php @@ -435,14 +435,14 @@ public function testRegistersTraceableBusesToCollector() $dataCollector = $this->getMockBuilder(MessengerDataCollector::class)->getMock(); $container = $this->getContainerBuilder($fooBusId = 'messenger.bus.foo'); - $container->register('messenger.data_collector', $dataCollector); + $container->register('data_collector.messenger', $dataCollector); $container->setParameter('kernel.debug', true); (new MessengerPass())->process($container); $this->assertTrue($container->hasDefinition($debuggedFooBusId = 'debug.traced.'.$fooBusId)); $this->assertSame(array($fooBusId, null, 0), $container->getDefinition($debuggedFooBusId)->getDecoratedService()); - $this->assertEquals(array(array('registerBus', array($fooBusId, new Reference($debuggedFooBusId)))), $container->getDefinition('messenger.data_collector')->getMethodCalls()); + $this->assertEquals(array(array('registerBus', array($fooBusId, new Reference($debuggedFooBusId)))), $container->getDefinition('data_collector.messenger')->getMethodCalls()); } public function testRegistersMiddlewareFromServices() diff --git a/src/Symfony/Component/OptionsResolver/OptionsResolver.php b/src/Symfony/Component/OptionsResolver/OptionsResolver.php index 73e35a96196ac..5dd026f7a0f80 100644 --- a/src/Symfony/Component/OptionsResolver/OptionsResolver.php +++ b/src/Symfony/Component/OptionsResolver/OptionsResolver.php @@ -353,11 +353,9 @@ public function getDefinedOptions() * * The normalizer should be a closure with the following signature: * - * ```php - * function (Options $options, $value) { - * // ... - * } - * ``` + * function (Options $options, $value) { + * // ... + * } * * The closure is invoked when {@link resolve()} is called. The closure * has access to the resolved values of other options through the passed @@ -383,11 +381,7 @@ public function setNormalizer($option, \Closure $normalizer) } if (!isset($this->defined[$option])) { - throw new UndefinedOptionsException(sprintf( - 'The option "%s" does not exist. Defined options are: "%s".', - $option, - implode('", "', array_keys($this->defined)) - )); + throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined)))); } $this->normalizers[$option] = $normalizer; @@ -426,11 +420,7 @@ public function setAllowedValues($option, $allowedValues) } if (!isset($this->defined[$option])) { - throw new UndefinedOptionsException(sprintf( - 'The option "%s" does not exist. Defined options are: "%s".', - $option, - implode('", "', array_keys($this->defined)) - )); + throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined)))); } $this->allowedValues[$option] = \is_array($allowedValues) ? $allowedValues : array($allowedValues); @@ -471,11 +461,7 @@ public function addAllowedValues($option, $allowedValues) } if (!isset($this->defined[$option])) { - throw new UndefinedOptionsException(sprintf( - 'The option "%s" does not exist. Defined options are: "%s".', - $option, - implode('", "', array_keys($this->defined)) - )); + throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined)))); } if (!\is_array($allowedValues)) { @@ -516,11 +502,7 @@ public function setAllowedTypes($option, $allowedTypes) } if (!isset($this->defined[$option])) { - throw new UndefinedOptionsException(sprintf( - 'The option "%s" does not exist. Defined options are: "%s".', - $option, - implode('", "', array_keys($this->defined)) - )); + throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined)))); } $this->allowedTypes[$option] = (array) $allowedTypes; @@ -555,11 +537,7 @@ public function addAllowedTypes($option, $allowedTypes) } if (!isset($this->defined[$option])) { - throw new UndefinedOptionsException(sprintf( - 'The option "%s" does not exist. Defined options are: "%s".', - $option, - implode('", "', array_keys($this->defined)) - )); + throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined)))); } if (!isset($this->allowedTypes[$option])) { @@ -664,11 +642,7 @@ public function resolve(array $options = array()) ksort($clone->defined); ksort($diff); - throw new UndefinedOptionsException(sprintf( - (\count($diff) > 1 ? 'The options "%s" do not exist.' : 'The option "%s" does not exist.').' Defined options are: "%s".', - implode('", "', array_keys($diff)), - implode('", "', array_keys($clone->defined)) - )); + throw new UndefinedOptionsException(sprintf((\count($diff) > 1 ? 'The options "%s" do not exist.' : 'The option "%s" does not exist.').' Defined options are: "%s".', implode('", "', array_keys($diff)), implode('", "', array_keys($clone->defined)))); } // Override options set by the user @@ -683,10 +657,7 @@ public function resolve(array $options = array()) if (\count($diff) > 0) { ksort($diff); - throw new MissingOptionsException(sprintf( - \count($diff) > 1 ? 'The required options "%s" are missing.' : 'The required option "%s" is missing.', - implode('", "', array_keys($diff)) - )); + throw new MissingOptionsException(sprintf(\count($diff) > 1 ? 'The required options "%s" are missing.' : 'The required option "%s" is missing.', implode('", "', array_keys($diff)))); } // Lock the container @@ -730,17 +701,10 @@ public function offsetGet($option) // Check whether the option is set at all if (!array_key_exists($option, $this->defaults)) { if (!isset($this->defined[$option])) { - throw new NoSuchOptionException(sprintf( - 'The option "%s" does not exist. Defined options are: "%s".', - $option, - implode('", "', array_keys($this->defined)) - )); + throw new NoSuchOptionException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined)))); } - throw new NoSuchOptionException(sprintf( - 'The optional option "%s" has no value set. You should make sure it is set with "isset" before reading it.', - $option - )); + throw new NoSuchOptionException(sprintf('The optional option "%s" has no value set. You should make sure it is set with "isset" before reading it.', $option)); } $value = $this->defaults[$option]; @@ -750,10 +714,7 @@ public function offsetGet($option) // If the closure is already being called, we have a cyclic // dependency if (isset($this->calling[$option])) { - throw new OptionDefinitionException(sprintf( - 'The options "%s" have a cyclic dependency.', - implode('", "', array_keys($this->calling)) - )); + throw new OptionDefinitionException(sprintf('The options "%s" have a cyclic dependency.', implode('", "', array_keys($this->calling)))); } // The following section must be protected from cyclic @@ -809,7 +770,9 @@ public function offsetGet($option) // Don't include closures in the exception message continue; - } elseif ($value === $allowedValue) { + } + + if ($value === $allowedValue) { $success = true; break; } @@ -840,10 +803,7 @@ public function offsetGet($option) // If the closure is already being called, we have a cyclic // dependency if (isset($this->calling[$option])) { - throw new OptionDefinitionException(sprintf( - 'The options "%s" have a cyclic dependency.', - implode('", "', array_keys($this->calling)) - )); + throw new OptionDefinitionException(sprintf('The options "%s" have a cyclic dependency.', implode('", "', array_keys($this->calling)))); } $normalizer = $this->normalizers[$option]; @@ -1083,17 +1043,4 @@ private static function isValueValidType(string $type, $value): bool { return (\function_exists($isFunction = 'is_'.$type) && $isFunction($value)) || $value instanceof $type; } - - private function getInvalidValues(array $arrayValues, string $type): array - { - $invalidValues = array(); - - foreach ($arrayValues as $key => $value) { - if (!self::isValueValidType($type, $value)) { - $invalidValues[$key] = $value; - } - } - - return $invalidValues; - } } diff --git a/src/Symfony/Component/Process/PhpProcess.php b/src/Symfony/Component/Process/PhpProcess.php index 7ac930e96c722..6cf02a2fca461 100644 --- a/src/Symfony/Component/Process/PhpProcess.php +++ b/src/Symfony/Component/Process/PhpProcess.php @@ -16,9 +16,9 @@ /** * PhpProcess runs a PHP script in an independent process. * - * $p = new PhpProcess(''); - * $p->run(); - * print $p->getOutput()."\n"; + * $p = new PhpProcess(''); + * $p->run(); + * print $p->getOutput()."\n"; * * @author Fabien Potencier */ diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 70514472d5e07..b95430d36d77a 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -1392,8 +1392,8 @@ private function resetProcessData() $this->exitcode = null; $this->fallbackStatus = array(); $this->processInformation = null; - $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'wb+'); - $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'wb+'); + $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b'); + $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b'); $this->process = null; $this->latestSignal = null; $this->status = self::STATUS_READY; diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index 08d79743cdd07..290a037f883d5 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -272,22 +272,13 @@ private function readPropertiesUntil($zval, PropertyPathInterface $propertyPath, if (!$ignoreInvalidIndices) { if (!\is_array($zval[self::VALUE])) { if (!$zval[self::VALUE] instanceof \Traversable) { - throw new NoSuchIndexException(sprintf( - 'Cannot read index "%s" while trying to traverse path "%s".', - $property, - (string) $propertyPath - )); + throw new NoSuchIndexException(sprintf('Cannot read index "%s" while trying to traverse path "%s".', $property, (string) $propertyPath)); } $zval[self::VALUE] = iterator_to_array($zval[self::VALUE]); } - throw new NoSuchIndexException(sprintf( - 'Cannot read index "%s" while trying to traverse path "%s". Available indices are "%s".', - $property, - (string) $propertyPath, - print_r(array_keys($zval[self::VALUE]), true) - )); + throw new NoSuchIndexException(sprintf('Cannot read index "%s" while trying to traverse path "%s". Available indices are "%s".', $property, (string) $propertyPath, print_r(array_keys($zval[self::VALUE]), true))); } if ($i + 1 < $propertyPath->getLength()) { diff --git a/src/Symfony/Component/PropertyAccess/PropertyPath.php b/src/Symfony/Component/PropertyAccess/PropertyPath.php index 890b8ffce61b4..2897a4adfab8b 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyPath.php +++ b/src/Symfony/Component/PropertyAccess/PropertyPath.php @@ -77,12 +77,7 @@ public function __construct($propertyPath) return; } if (!\is_string($propertyPath)) { - throw new InvalidArgumentException(sprintf( - 'The property path constructor needs a string or an instance of '. - '"Symfony\Component\PropertyAccess\PropertyPath". '. - 'Got: "%s"', - \is_object($propertyPath) ? \get_class($propertyPath) : \gettype($propertyPath) - )); + throw new InvalidArgumentException(sprintf('The property path constructor needs a string or an instance of "Symfony\Component\PropertyAccess\PropertyPath". Got: "%s"', \is_object($propertyPath) ? \get_class($propertyPath) : \gettype($propertyPath))); } if ('' === $propertyPath) { @@ -113,12 +108,7 @@ public function __construct($propertyPath) } if ('' !== $remaining) { - throw new InvalidPropertyPathException(sprintf( - 'Could not parse property path "%s". Unexpected token "%s" at position %d', - $propertyPath, - $remaining[0], - $position - )); + throw new InvalidPropertyPathException(sprintf('Could not parse property path "%s". Unexpected token "%s" at position %d', $propertyPath, $remaining[0], $position)); } $this->length = \count($this->elements); diff --git a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php index 3188f130ac389..bd35c75a9361d 100644 --- a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php @@ -244,28 +244,16 @@ protected function validate($config, $name, $path) throw new \InvalidArgumentException(sprintf('The definition of "%s" in "%s" must be a YAML array.', $name, $path)); } if ($extraKeys = array_diff(array_keys($config), self::$availableKeys)) { - throw new \InvalidArgumentException(sprintf( - 'The routing file "%s" contains unsupported keys for "%s": "%s". Expected one of: "%s".', - $path, $name, implode('", "', $extraKeys), implode('", "', self::$availableKeys) - )); + throw new \InvalidArgumentException(sprintf('The routing file "%s" contains unsupported keys for "%s": "%s". Expected one of: "%s".', $path, $name, implode('", "', $extraKeys), implode('", "', self::$availableKeys))); } if (isset($config['resource']) && isset($config['path'])) { - throw new \InvalidArgumentException(sprintf( - 'The routing file "%s" must not specify both the "resource" key and the "path" key for "%s". Choose between an import and a route definition.', - $path, $name - )); + throw new \InvalidArgumentException(sprintf('The routing file "%s" must not specify both the "resource" key and the "path" key for "%s". Choose between an import and a route definition.', $path, $name)); } if (!isset($config['resource']) && isset($config['type'])) { - throw new \InvalidArgumentException(sprintf( - 'The "type" key for the route definition "%s" in "%s" is unsupported. It is only available for imports in combination with the "resource" key.', - $name, $path - )); + throw new \InvalidArgumentException(sprintf('The "type" key for the route definition "%s" in "%s" is unsupported. It is only available for imports in combination with the "resource" key.', $name, $path)); } if (!isset($config['resource']) && !isset($config['path'])) { - throw new \InvalidArgumentException(sprintf( - 'You must define a "path" for the route "%s" in file "%s".', - $name, $path - )); + throw new \InvalidArgumentException(sprintf('You must define a "path" for the route "%s" in file "%s".', $name, $path)); } if (isset($config['controller']) && isset($config['defaults']['_controller'])) { throw new \InvalidArgumentException(sprintf('The routing file "%s" must not specify both the "controller" key and the defaults key "_controller" for "%s".', $path, $name)); diff --git a/src/Symfony/Component/Routing/RouteCollectionBuilder.php b/src/Symfony/Component/Routing/RouteCollectionBuilder.php index d5ff578c5dd3e..eb42887fa6066 100644 --- a/src/Symfony/Component/Routing/RouteCollectionBuilder.php +++ b/src/Symfony/Component/Routing/RouteCollectionBuilder.php @@ -46,7 +46,7 @@ public function __construct(LoaderInterface $loader = null) /** * Import an external routing resource and returns the RouteCollectionBuilder. * - * $routes->import('blog.yml', '/blog'); + * $routes->import('blog.yml', '/blog'); * * @param mixed $resource * @param string|null $prefix diff --git a/src/Symfony/Component/Security/Core/User/UserInterface.php b/src/Symfony/Component/Security/Core/User/UserInterface.php index 0ce8eca92aa4e..da28bf7d61096 100644 --- a/src/Symfony/Component/Security/Core/User/UserInterface.php +++ b/src/Symfony/Component/Security/Core/User/UserInterface.php @@ -35,12 +35,10 @@ interface UserInterface /** * Returns the roles granted to the user. * - * - * public function getRoles() - * { - * return array('ROLE_USER'); - * } - * + * public function getRoles() + * { + * return array('ROLE_USER'); + * } * * Alternatively, the roles might be stored on a ``roles`` property, * and populated in any number of different ways when the user object diff --git a/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php b/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php index 214a189e99b17..2ec282144cfe3 100644 --- a/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php +++ b/src/Symfony/Component/Security/Csrf/Tests/CsrfTokenManagerTest.php @@ -210,12 +210,12 @@ private function getGeneratorAndStorage() ); } - public function setUp() + protected function setUp() { $_SERVER['HTTPS'] = 'on'; } - public function tearDown() + protected function tearDown() { parent::tearDown(); diff --git a/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php b/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php index 2fbcef30d6698..f08dc557bb6c0 100644 --- a/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php +++ b/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php @@ -192,10 +192,7 @@ private function triggerRememberMe(AuthenticatorInterface $guardAuthenticator, R } if (!$response instanceof Response) { - throw new \LogicException(sprintf( - '%s::onAuthenticationSuccess *must* return a Response if you want to use the remember me functionality. Return a Response, or set remember_me to false under the guard configuration.', - \get_class($guardAuthenticator) - )); + throw new \LogicException(sprintf('%s::onAuthenticationSuccess *must* return a Response if you want to use the remember me functionality. Return a Response, or set remember_me to false under the guard configuration.', \get_class($guardAuthenticator))); } $this->rememberMeServices->loginSuccess($request, $response, $token); diff --git a/src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php b/src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php index aedbb655974ed..9212778c07bb9 100644 --- a/src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php +++ b/src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php @@ -79,11 +79,7 @@ public function handleAuthenticationSuccess(TokenInterface $token, Request $requ return $response; } - throw new \UnexpectedValueException(sprintf( - 'The %s::onAuthenticationSuccess method must return null or a Response object. You returned %s.', - \get_class($guardAuthenticator), - \is_object($response) ? \get_class($response) : \gettype($response) - )); + throw new \UnexpectedValueException(sprintf('The %s::onAuthenticationSuccess method must return null or a Response object. You returned %s.', \get_class($guardAuthenticator), \is_object($response) ? \get_class($response) : \gettype($response))); } /** @@ -113,11 +109,7 @@ public function handleAuthenticationFailure(AuthenticationException $authenticat return $response; } - throw new \UnexpectedValueException(sprintf( - 'The %s::onAuthenticationFailure method must return null or a Response object. You returned %s.', - \get_class($guardAuthenticator), - \is_object($response) ? \get_class($response) : \gettype($response) - )); + throw new \UnexpectedValueException(sprintf('The %s::onAuthenticationFailure method must return null or a Response object. You returned %s.', \get_class($guardAuthenticator), \is_object($response) ? \get_class($response) : \gettype($response))); } /** diff --git a/src/Symfony/Component/Security/Http/EntryPoint/AuthenticationEntryPointInterface.php b/src/Symfony/Component/Security/Http/EntryPoint/AuthenticationEntryPointInterface.php index f9484e0a6c7dc..c37a0e4875797 100644 --- a/src/Symfony/Component/Security/Http/EntryPoint/AuthenticationEntryPointInterface.php +++ b/src/Symfony/Component/Security/Http/EntryPoint/AuthenticationEntryPointInterface.php @@ -31,10 +31,14 @@ interface AuthenticationEntryPointInterface * response that "helps" the user start into the authentication process. * * Examples: - * A) For a form login, you might redirect to the login page - * return new RedirectResponse('/login'); - * B) For an API token authentication system, you return a 401 response - * return new Response('Auth header required', 401); + * + * - For a form login, you might redirect to the login page + * + * return new RedirectResponse('/login'); + * + * - For an API token authentication system, you return a 401 response + * + * return new Response('Auth header required', 401); * * @param Request $request The request that resulted in an AuthenticationException * @param AuthenticationException $authException The exception that started the authentication process diff --git a/src/Symfony/Component/Security/Http/HttpUtils.php b/src/Symfony/Component/Security/Http/HttpUtils.php index 1b9ed4efdc881..f334a6d5c4a92 100644 --- a/src/Symfony/Component/Security/Http/HttpUtils.php +++ b/src/Symfony/Component/Security/Http/HttpUtils.php @@ -95,6 +95,13 @@ public function createRequest(Request $request, $path) $newRequest->attributes->set(Security::LAST_USERNAME, $request->attributes->get(Security::LAST_USERNAME)); } + if ($request->get('_format')) { + $newRequest->attributes->set('_format', $request->get('_format')); + } + if ($request->getDefaultLocale() !== $request->getLocale()) { + $newRequest->setLocale($request->getLocale()); + } + return $newRequest; } diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php index b7e333d701750..d5cdecab3eee4 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php @@ -124,10 +124,7 @@ public function setCallbacks(array $callbacks) { foreach ($callbacks as $attribute => $callback) { if (!\is_callable($callback)) { - throw new InvalidArgumentException(sprintf( - 'The given callback for attribute "%s" is not callable.', - $attribute - )); + throw new InvalidArgumentException(sprintf('The given callback for attribute "%s" is not callable.', $attribute)); } } $this->callbacks = $callbacks; @@ -386,13 +383,7 @@ protected function instantiateObject(array &$data, $class, array &$context, \Ref } elseif ($constructorParameter->isDefaultValueAvailable()) { $params[] = $constructorParameter->getDefaultValue(); } else { - throw new MissingConstructorArgumentsException( - sprintf( - 'Cannot create an instance of %s from serialized data because its constructor requires parameter "%s" to be present.', - $class, - $constructorParameter->name - ) - ); + throw new MissingConstructorArgumentsException(sprintf('Cannot create an instance of %s from serialized data because its constructor requires parameter "%s" to be present.', $class, $constructorParameter->name)); } } diff --git a/src/Symfony/Component/Serializer/Serializer.php b/src/Symfony/Component/Serializer/Serializer.php index de31321e5b538..27167fc6d6865 100644 --- a/src/Symfony/Component/Serializer/Serializer.php +++ b/src/Symfony/Component/Serializer/Serializer.php @@ -34,9 +34,9 @@ * objects are turned into arrays by normalizers. * arrays are turned into various output formats by encoders. * - * $serializer->serialize($obj, 'xml') - * $serializer->decode($data, 'xml') - * $serializer->denormalize($data, 'Class', 'xml') + * $serializer->serialize($obj, 'xml') + * $serializer->decode($data, 'xml') + * $serializer->denormalize($data, 'Class', 'xml') * * @author Jordi Boggiano * @author Johannes M. Schmitt diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php index 00e83b56107c6..41b154a01376b 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php @@ -189,8 +189,8 @@ public function testContext() public function testEncodeScalarRootAttributes() { $array = array( - '#' => 'Paul', - '@gender' => 'm', + '#' => 'Paul', + '@gender' => 'm', ); $expected = ''."\n". @@ -202,8 +202,8 @@ public function testEncodeScalarRootAttributes() public function testEncodeRootAttributes() { $array = array( - 'firstname' => 'Paul', - '@gender' => 'm', + 'firstname' => 'Paul', + '@gender' => 'm', ); $expected = ''."\n". @@ -215,7 +215,7 @@ public function testEncodeRootAttributes() public function testEncodeCdataWrapping() { $array = array( - 'firstname' => 'Paul ', + 'firstname' => 'Paul ', ); $expected = ''."\n". diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php index f5b0e6a53bd85..444fdabc1b20a 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php @@ -75,8 +75,7 @@ public function testNormalizeWithParentClass() $group->setKevin('Kevin'); $group->setCoopTilleuls('coop'); $this->assertEquals( - array('foo' => 'foo', 'bar' => 'bar', 'kevin' => 'Kevin', - 'coopTilleuls' => 'coop', 'fooBar' => null, 'symfony' => null, 'baz' => 'baz', ), + array('foo' => 'foo', 'bar' => 'bar', 'kevin' => 'Kevin', 'coopTilleuls' => 'coop', 'fooBar' => null, 'symfony' => null, 'baz' => 'baz'), $this->normalizer->normalize($group, 'any') ); } diff --git a/src/Symfony/Component/Translation/Catalogue/AbstractOperation.php b/src/Symfony/Component/Translation/Catalogue/AbstractOperation.php index c303a4f6e491c..ca6a5b220f6cd 100644 --- a/src/Symfony/Component/Translation/Catalogue/AbstractOperation.php +++ b/src/Symfony/Component/Translation/Catalogue/AbstractOperation.php @@ -39,21 +39,20 @@ abstract class AbstractOperation implements OperationInterface * This array stores 'all', 'new' and 'obsolete' messages for all valid domains. * * The data structure of this array is as follows: - * ```php - * array( - * 'domain 1' => array( - * 'all' => array(...), - * 'new' => array(...), - * 'obsolete' => array(...) - * ), - * 'domain 2' => array( - * 'all' => array(...), - * 'new' => array(...), - * 'obsolete' => array(...) - * ), - * ... - * ) - * ``` + * + * array( + * 'domain 1' => array( + * 'all' => array(...), + * 'new' => array(...), + * 'obsolete' => array(...) + * ), + * 'domain 2' => array( + * 'all' => array(...), + * 'new' => array(...), + * 'obsolete' => array(...) + * ), + * ... + * ) * * @var array The array that stores 'all', 'new' and 'obsolete' messages */ diff --git a/src/Symfony/Component/Translation/Dumper/CsvFileDumper.php b/src/Symfony/Component/Translation/Dumper/CsvFileDumper.php index ebfa831dbd0ca..0880528dc9b03 100644 --- a/src/Symfony/Component/Translation/Dumper/CsvFileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/CsvFileDumper.php @@ -28,7 +28,7 @@ class CsvFileDumper extends FileDumper */ public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array()) { - $handle = fopen('php://memory', 'rb+'); + $handle = fopen('php://memory', 'r+b'); foreach ($messages->all($domain) as $source => $target) { fputcsv($handle, array($source, $target), $this->delimiter, $this->enclosure); diff --git a/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php b/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php index 504a69e6dd0b1..6665eca49946e 100644 --- a/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php +++ b/src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php @@ -42,85 +42,85 @@ public function testCollect() { $collectedMessages = array( array( - 'id' => 'foo', - 'translation' => 'foo (en)', - 'locale' => 'en', - 'domain' => 'messages', - 'state' => DataCollectorTranslator::MESSAGE_DEFINED, - 'parameters' => array(), - 'transChoiceNumber' => null, + 'id' => 'foo', + 'translation' => 'foo (en)', + 'locale' => 'en', + 'domain' => 'messages', + 'state' => DataCollectorTranslator::MESSAGE_DEFINED, + 'parameters' => array(), + 'transChoiceNumber' => null, ), array( - 'id' => 'bar', - 'translation' => 'bar (fr)', - 'locale' => 'fr', - 'domain' => 'messages', - 'state' => DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK, - 'parameters' => array(), - 'transChoiceNumber' => null, + 'id' => 'bar', + 'translation' => 'bar (fr)', + 'locale' => 'fr', + 'domain' => 'messages', + 'state' => DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK, + 'parameters' => array(), + 'transChoiceNumber' => null, ), array( - 'id' => 'choice', - 'translation' => 'choice', - 'locale' => 'en', - 'domain' => 'messages', - 'state' => DataCollectorTranslator::MESSAGE_MISSING, - 'parameters' => array('%count%' => 3), - 'transChoiceNumber' => 3, + 'id' => 'choice', + 'translation' => 'choice', + 'locale' => 'en', + 'domain' => 'messages', + 'state' => DataCollectorTranslator::MESSAGE_MISSING, + 'parameters' => array('%count%' => 3), + 'transChoiceNumber' => 3, ), array( - 'id' => 'choice', - 'translation' => 'choice', - 'locale' => 'en', - 'domain' => 'messages', - 'state' => DataCollectorTranslator::MESSAGE_MISSING, - 'parameters' => array('%count%' => 3), - 'transChoiceNumber' => 3, + 'id' => 'choice', + 'translation' => 'choice', + 'locale' => 'en', + 'domain' => 'messages', + 'state' => DataCollectorTranslator::MESSAGE_MISSING, + 'parameters' => array('%count%' => 3), + 'transChoiceNumber' => 3, ), array( - 'id' => 'choice', - 'translation' => 'choice', - 'locale' => 'en', - 'domain' => 'messages', - 'state' => DataCollectorTranslator::MESSAGE_MISSING, - 'parameters' => array('%count%' => 4, '%foo%' => 'bar'), - 'transChoiceNumber' => 4, + 'id' => 'choice', + 'translation' => 'choice', + 'locale' => 'en', + 'domain' => 'messages', + 'state' => DataCollectorTranslator::MESSAGE_MISSING, + 'parameters' => array('%count%' => 4, '%foo%' => 'bar'), + 'transChoiceNumber' => 4, ), ); $expectedMessages = array( array( - 'id' => 'foo', - 'translation' => 'foo (en)', - 'locale' => 'en', - 'domain' => 'messages', - 'state' => DataCollectorTranslator::MESSAGE_DEFINED, - 'count' => 1, - 'parameters' => array(), - 'transChoiceNumber' => null, + 'id' => 'foo', + 'translation' => 'foo (en)', + 'locale' => 'en', + 'domain' => 'messages', + 'state' => DataCollectorTranslator::MESSAGE_DEFINED, + 'count' => 1, + 'parameters' => array(), + 'transChoiceNumber' => null, ), array( - 'id' => 'bar', - 'translation' => 'bar (fr)', - 'locale' => 'fr', - 'domain' => 'messages', - 'state' => DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK, - 'count' => 1, - 'parameters' => array(), - 'transChoiceNumber' => null, + 'id' => 'bar', + 'translation' => 'bar (fr)', + 'locale' => 'fr', + 'domain' => 'messages', + 'state' => DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK, + 'count' => 1, + 'parameters' => array(), + 'transChoiceNumber' => null, ), array( - 'id' => 'choice', - 'translation' => 'choice', - 'locale' => 'en', - 'domain' => 'messages', - 'state' => DataCollectorTranslator::MESSAGE_MISSING, - 'count' => 3, - 'parameters' => array( - array('%count%' => 3), - array('%count%' => 3), - array('%count%' => 4, '%foo%' => 'bar'), - ), - 'transChoiceNumber' => 3, + 'id' => 'choice', + 'translation' => 'choice', + 'locale' => 'en', + 'domain' => 'messages', + 'state' => DataCollectorTranslator::MESSAGE_MISSING, + 'count' => 3, + 'parameters' => array( + array('%count%' => 3), + array('%count%' => 3), + array('%count%' => 4, '%foo%' => 'bar'), + ), + 'transChoiceNumber' => 3, ), ); diff --git a/src/Symfony/Component/Translation/Tests/DataCollectorTranslatorTest.php b/src/Symfony/Component/Translation/Tests/DataCollectorTranslatorTest.php index cc196223ccfa8..1cdd33b395f0d 100644 --- a/src/Symfony/Component/Translation/Tests/DataCollectorTranslatorTest.php +++ b/src/Symfony/Component/Translation/Tests/DataCollectorTranslatorTest.php @@ -31,49 +31,49 @@ public function testCollectMessages() $expectedMessages = array(); $expectedMessages[] = array( - 'id' => 'foo', - 'translation' => 'foo (en)', - 'locale' => 'en', - 'domain' => 'messages', - 'state' => DataCollectorTranslator::MESSAGE_DEFINED, - 'parameters' => array(), - 'transChoiceNumber' => null, + 'id' => 'foo', + 'translation' => 'foo (en)', + 'locale' => 'en', + 'domain' => 'messages', + 'state' => DataCollectorTranslator::MESSAGE_DEFINED, + 'parameters' => array(), + 'transChoiceNumber' => null, ); $expectedMessages[] = array( - 'id' => 'bar', - 'translation' => 'bar (fr)', - 'locale' => 'fr', - 'domain' => 'messages', - 'state' => DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK, - 'parameters' => array(), - 'transChoiceNumber' => null, + 'id' => 'bar', + 'translation' => 'bar (fr)', + 'locale' => 'fr', + 'domain' => 'messages', + 'state' => DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK, + 'parameters' => array(), + 'transChoiceNumber' => null, ); $expectedMessages[] = array( - 'id' => 'choice', - 'translation' => 'choice', - 'locale' => 'en', - 'domain' => 'messages', - 'state' => DataCollectorTranslator::MESSAGE_MISSING, - 'parameters' => array(), - 'transChoiceNumber' => 0, + 'id' => 'choice', + 'translation' => 'choice', + 'locale' => 'en', + 'domain' => 'messages', + 'state' => DataCollectorTranslator::MESSAGE_MISSING, + 'parameters' => array(), + 'transChoiceNumber' => 0, ); $expectedMessages[] = array( - 'id' => 'bar_ru', - 'translation' => 'bar (ru)', - 'locale' => 'ru', - 'domain' => 'messages', - 'state' => DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK, - 'parameters' => array(), - 'transChoiceNumber' => null, + 'id' => 'bar_ru', + 'translation' => 'bar (ru)', + 'locale' => 'ru', + 'domain' => 'messages', + 'state' => DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK, + 'parameters' => array(), + 'transChoiceNumber' => null, ); $expectedMessages[] = array( - 'id' => 'bar_ru', - 'translation' => 'bar (ru)', - 'locale' => 'ru', - 'domain' => 'messages', - 'state' => DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK, - 'parameters' => array('foo' => 'bar'), - 'transChoiceNumber' => null, + 'id' => 'bar_ru', + 'translation' => 'bar (ru)', + 'locale' => 'ru', + 'domain' => 'messages', + 'state' => DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK, + 'parameters' => array('foo' => 'bar'), + 'transChoiceNumber' => null, ); $this->assertEquals($expectedMessages, $collector->getCollectedMessages()); diff --git a/src/Symfony/Component/Validator/Constraint.php b/src/Symfony/Component/Validator/Constraint.php index 70a11ef8c98c7..45d4bcf41a4b8 100644 --- a/src/Symfony/Component/Validator/Constraint.php +++ b/src/Symfony/Component/Validator/Constraint.php @@ -70,11 +70,7 @@ abstract class Constraint public static function getErrorName($errorCode) { if (!isset(static::$errorNames[$errorCode])) { - throw new InvalidArgumentException(sprintf( - 'The error code "%s" does not exist for constraint of type "%s".', - $errorCode, - \get_called_class() - )); + throw new InvalidArgumentException(sprintf('The error code "%s" does not exist for constraint of type "%s".', $errorCode, \get_called_class())); } return static::$errorNames[$errorCode]; @@ -137,9 +133,7 @@ public function __construct($options = null) $option = $this->getDefaultOption(); if (null === $option) { - throw new ConstraintDefinitionException( - sprintf('No default option is configured for constraint %s', \get_class($this)) - ); + throw new ConstraintDefinitionException(sprintf('No default option is configured for constraint %s', \get_class($this))); } if (array_key_exists($option, $knownOptions)) { @@ -151,17 +145,11 @@ public function __construct($options = null) } if (\count($invalidOptions) > 0) { - throw new InvalidOptionsException( - sprintf('The options "%s" do not exist in constraint %s', implode('", "', $invalidOptions), \get_class($this)), - $invalidOptions - ); + throw new InvalidOptionsException(sprintf('The options "%s" do not exist in constraint %s', implode('", "', $invalidOptions), \get_class($this)), $invalidOptions); } if (\count($missingOptions) > 0) { - throw new MissingOptionsException( - sprintf('The options "%s" must be set for constraint %s', implode('", "', array_keys($missingOptions)), \get_class($this)), - array_keys($missingOptions) - ); + throw new MissingOptionsException(sprintf('The options "%s" must be set for constraint %s', implode('", "', array_keys($missingOptions)), \get_class($this)), array_keys($missingOptions)); } } diff --git a/src/Symfony/Component/Validator/ConstraintViolationInterface.php b/src/Symfony/Component/Validator/ConstraintViolationInterface.php index b66b0741a5669..5ac25cf9ba53a 100644 --- a/src/Symfony/Component/Validator/ConstraintViolationInterface.php +++ b/src/Symfony/Component/Validator/ConstraintViolationInterface.php @@ -19,11 +19,9 @@ * element in the validation graph and the root element that was originally * passed to the validator. For example, take the following graph: * - *
- * (Person)---(firstName: string)
- *      \
- *   (address: Address)---(street: string)
- * 
+ * (Person)---(firstName: string) + * \ + * (address: Address)---(street: string) * * If the Person object is validated and validation fails for the * "firstName" property, the generated violation has the Person diff --git a/src/Symfony/Component/Validator/Constraints/Composite.php b/src/Symfony/Component/Validator/Constraints/Composite.php index 2f2b8d29a0e64..d233f06335e1a 100644 --- a/src/Symfony/Component/Validator/Constraints/Composite.php +++ b/src/Symfony/Component/Validator/Constraints/Composite.php @@ -99,13 +99,7 @@ public function __construct($options = null) $excessGroups = array_diff($constraint->groups, $this->groups); if (\count($excessGroups) > 0) { - throw new ConstraintDefinitionException(sprintf( - 'The group(s) "%s" passed to the constraint %s '. - 'should also be passed to its containing constraint %s', - implode('", "', $excessGroups), - \get_class($constraint), - \get_class($this) - )); + throw new ConstraintDefinitionException(sprintf('The group(s) "%s" passed to the constraint %s should also be passed to its containing constraint %s', implode('", "', $excessGroups), \get_class($constraint), \get_class($this))); } } else { $constraint->groups = $this->groups; diff --git a/src/Symfony/Component/Validator/Constraints/FileValidator.php b/src/Symfony/Component/Validator/Constraints/FileValidator.php index e59f25247e9f6..7b556775df5df 100644 --- a/src/Symfony/Component/Validator/Constraints/FileValidator.php +++ b/src/Symfony/Component/Validator/Constraints/FileValidator.php @@ -57,7 +57,7 @@ public function validate($value, Constraint $constraint) $binaryFormat = $constraint->binaryFormat; } else { $limitInBytes = $iniLimitSize; - $binaryFormat = true; + $binaryFormat = null === $constraint->binaryFormat ? true : $constraint->binaryFormat; } list($sizeAsString, $limitAsString, $suffix) = $this->factorizeSizes(0, $limitInBytes, $binaryFormat); diff --git a/src/Symfony/Component/Validator/Constraints/Traverse.php b/src/Symfony/Component/Validator/Constraints/Traverse.php index 0b74d98d463ec..4572c9b2193c4 100644 --- a/src/Symfony/Component/Validator/Constraints/Traverse.php +++ b/src/Symfony/Component/Validator/Constraints/Traverse.php @@ -26,10 +26,7 @@ class Traverse extends Constraint public function __construct($options = null) { if (\is_array($options) && array_key_exists('groups', $options)) { - throw new ConstraintDefinitionException(sprintf( - 'The option "groups" is not supported by the constraint %s', - __CLASS__ - )); + throw new ConstraintDefinitionException(sprintf('The option "groups" is not supported by the constraint %s', __CLASS__)); } parent::__construct($options); diff --git a/src/Symfony/Component/Validator/GroupSequenceProviderInterface.php b/src/Symfony/Component/Validator/GroupSequenceProviderInterface.php index 62e8a5ed0d4f7..5894397da4deb 100644 --- a/src/Symfony/Component/Validator/GroupSequenceProviderInterface.php +++ b/src/Symfony/Component/Validator/GroupSequenceProviderInterface.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Validator; +use Symfony\Component\Validator\Constraints\GroupSequence; + /** * Defines the interface for a group sequence provider. */ @@ -20,7 +22,7 @@ interface GroupSequenceProviderInterface * Returns which validation groups should be used for a certain state * of the object. * - * @return array An array of validation groups + * @return string[]|GroupSequence An array of validation groups */ public function getGroupSequence(); } diff --git a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php index cffbaf636643a..7b616eb7aa1fa 100644 --- a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php @@ -175,17 +175,11 @@ public function getDefaultGroup() public function addConstraint(Constraint $constraint) { if (!\in_array(Constraint::CLASS_CONSTRAINT, (array) $constraint->getTargets())) { - throw new ConstraintDefinitionException(sprintf( - 'The constraint "%s" cannot be put on classes.', - \get_class($constraint) - )); + throw new ConstraintDefinitionException(sprintf('The constraint "%s" cannot be put on classes.', \get_class($constraint))); } if ($constraint instanceof Valid) { - throw new ConstraintDefinitionException(sprintf( - 'The constraint "%s" cannot be put on classes.', - \get_class($constraint) - )); + throw new ConstraintDefinitionException(sprintf('The constraint "%s" cannot be put on classes.', \get_class($constraint))); } if ($constraint instanceof Traverse) { @@ -398,7 +392,7 @@ public function getConstrainedProperties() /** * Sets the default group sequence for this class. * - * @param array $groupSequence An array of group names + * @param string[]|GroupSequence $groupSequence An array of group names * * @return $this * diff --git a/src/Symfony/Component/Validator/Mapping/GenericMetadata.php b/src/Symfony/Component/Validator/Mapping/GenericMetadata.php index 21f9da1334189..a5364f9b08720 100644 --- a/src/Symfony/Component/Validator/Mapping/GenericMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/GenericMetadata.php @@ -122,11 +122,7 @@ public function __clone() public function addConstraint(Constraint $constraint) { if ($constraint instanceof Traverse) { - throw new ConstraintDefinitionException(sprintf( - 'The constraint "%s" can only be put on classes. Please use '. - '"Symfony\Component\Validator\Constraints\Valid" instead.', - \get_class($constraint) - )); + throw new ConstraintDefinitionException(sprintf('The constraint "%s" can only be put on classes. Please use "Symfony\Component\Validator\Constraints\Valid" instead.', \get_class($constraint))); } if ($constraint instanceof Valid && null === $constraint->groups) { diff --git a/src/Symfony/Component/Validator/Mapping/MemberMetadata.php b/src/Symfony/Component/Validator/Mapping/MemberMetadata.php index d4621cb7dd82c..9986eaca94115 100644 --- a/src/Symfony/Component/Validator/Mapping/MemberMetadata.php +++ b/src/Symfony/Component/Validator/Mapping/MemberMetadata.php @@ -72,10 +72,7 @@ public function __construct(string $class, string $name, string $property) public function addConstraint(Constraint $constraint) { if (!\in_array(Constraint::PROPERTY_CONSTRAINT, (array) $constraint->getTargets())) { - throw new ConstraintDefinitionException(sprintf( - 'The constraint %s cannot be put on properties or getters', - \get_class($constraint) - )); + throw new ConstraintDefinitionException(sprintf('The constraint %s cannot be put on properties or getters', \get_class($constraint))); } parent::addConstraint($constraint); diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.ja.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.ja.xlf index a9d6b0812bf9d..0c61d15715b50 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.ja.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.ja.xlf @@ -318,6 +318,14 @@ Error エラー + + This is not a valid UUID. + 有効なUUIDではありません。 + + + This value should be a multiple of {{ compared_value }}. + {{ compared_value }}の倍数でなければなりません。 + diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php index 1f6865a9ac5ff..daddd275ea5d1 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php @@ -451,11 +451,17 @@ public function uploadedFileErrorProvider() '{{ suffix }}' => 'bytes', ), '1'); + // access FileValidator::factorizeSizes() private method to format max file size + $reflection = new \ReflectionClass(\get_class(new FileValidator())); + $method = $reflection->getMethod('factorizeSizes'); + $method->setAccessible(true); + list($sizeAsString, $limit, $suffix) = $method->invokeArgs(new FileValidator(), array(0, UploadedFile::getMaxFilesize(), false)); + // it correctly parses the maxSize option and not only uses simple string comparison // 1000M should be bigger than the ini value $tests[] = array(UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', array( - '{{ limit }}' => UploadedFile::getMaxFilesize() / 1048576, - '{{ suffix }}' => 'MiB', + '{{ limit }}' => $limit, + '{{ suffix }}' => $suffix, ), '1000M'); // it correctly parses the maxSize option and not only uses simple string comparison diff --git a/src/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php b/src/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php index 1cc96c834e6f6..c8b545b54b4a6 100644 --- a/src/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php +++ b/src/Symfony/Component/Validator/Validator/ContextualValidatorInterface.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Validator\Validator; use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Constraints\GroupSequence; use Symfony\Component\Validator\ConstraintViolationListInterface; /** @@ -39,12 +40,9 @@ public function atPath($path); * If no constraint is passed, the constraint * {@link \Symfony\Component\Validator\Constraints\Valid} is assumed. * - * @param mixed $value The value to validate - * @param Constraint|Constraint[] $constraints The constraint(s) to validate - * against - * @param array|null $groups The validation groups to - * validate. If none is given, - * "Default" is assumed + * @param mixed $value The value to validate + * @param Constraint|Constraint[] $constraints The constraint(s) to validate against + * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed * * @return $this */ @@ -54,10 +52,9 @@ public function validate($value, $constraints = null, $groups = null); * Validates a property of an object against the constraints specified * for this property. * - * @param object $object The object - * @param string $propertyName The name of the validated property - * @param array|null $groups The validation groups to validate. If - * none is given, "Default" is assumed + * @param object $object The object + * @param string $propertyName The name of the validated property + * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed * * @return $this */ @@ -67,12 +64,10 @@ public function validateProperty($object, $propertyName, $groups = null); * Validates a value against the constraints specified for an object's * property. * - * @param object|string $objectOrClass The object or its class name - * @param string $propertyName The name of the property - * @param mixed $value The value to validate against the - * property's constraints - * @param array|null $groups The validation groups to validate. If - * none is given, "Default" is assumed + * @param object|string $objectOrClass The object or its class name + * @param string $propertyName The name of the property + * @param mixed $value The value to validate against the property's constraints + * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed * * @return $this */ diff --git a/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php b/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php index eb1835c88a441..c1af13eaa09a0 100644 --- a/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php +++ b/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php @@ -161,11 +161,7 @@ public function validate($value, $constraints = null, $groups = null) return $this; } - throw new RuntimeException(sprintf( - 'Cannot validate values of type "%s" automatically. Please '. - 'provide a constraint.', - \gettype($value) - )); + throw new RuntimeException(sprintf('Cannot validate values of type "%s" automatically. Please provide a constraint.', \gettype($value))); } /** @@ -176,12 +172,7 @@ public function validateProperty($object, $propertyName, $groups = null) $classMetadata = $this->metadataFactory->getMetadataFor($object); if (!$classMetadata instanceof ClassMetadataInterface) { - throw new ValidatorException(sprintf( - 'The metadata factory should return instances of '. - '"\Symfony\Component\Validator\Mapping\ClassMetadataInterface", '. - 'got: "%s".', - \is_object($classMetadata) ? \get_class($classMetadata) : \gettype($classMetadata) - )); + throw new ValidatorException(sprintf('The metadata factory should return instances of "\Symfony\Component\Validator\Mapping\ClassMetadataInterface", got: "%s".', \is_object($classMetadata) ? \get_class($classMetadata) : \gettype($classMetadata))); } $propertyMetadatas = $classMetadata->getPropertyMetadata($propertyName); @@ -225,12 +216,7 @@ public function validatePropertyValue($objectOrClass, $propertyName, $value, $gr $classMetadata = $this->metadataFactory->getMetadataFor($objectOrClass); if (!$classMetadata instanceof ClassMetadataInterface) { - throw new ValidatorException(sprintf( - 'The metadata factory should return instances of '. - '"\Symfony\Component\Validator\Mapping\ClassMetadataInterface", '. - 'got: "%s".', - \is_object($classMetadata) ? \get_class($classMetadata) : \gettype($classMetadata) - )); + throw new ValidatorException(sprintf('The metadata factory should return instances of "\Symfony\Component\Validator\Mapping\ClassMetadataInterface", got: "%s".', \is_object($classMetadata) ? \get_class($classMetadata) : \gettype($classMetadata))); } $propertyMetadatas = $classMetadata->getPropertyMetadata($propertyName); @@ -286,9 +272,9 @@ public function getViolations() /** * Normalizes the given group or list of groups to an array. * - * @param mixed $groups The groups to normalize + * @param string|GroupSequence|(string|GroupSequence)[] $groups The groups to normalize * - * @return array A group array + * @return (string|GroupSequence)[] A group array */ protected function normalizeGroups($groups) { @@ -309,7 +295,7 @@ protected function normalizeGroups($groups) * * @param object $object The object to cascade * @param string $propertyPath The current property path - * @param string[] $groups The validated groups + * @param (string|GroupSequence)[] $groups The validated groups * @param int $traversalStrategy The strategy for traversing the * cascaded object * @param ExecutionContextInterface $context The current execution context @@ -328,12 +314,7 @@ private function validateObject($object, $propertyPath, array $groups, $traversa $classMetadata = $this->metadataFactory->getMetadataFor($object); if (!$classMetadata instanceof ClassMetadataInterface) { - throw new UnsupportedMetadataException(sprintf( - 'The metadata factory should return instances of '. - '"Symfony\Component\Validator\Mapping\ClassMetadataInterface", '. - 'got: "%s".', - \is_object($classMetadata) ? \get_class($classMetadata) : \gettype($classMetadata) - )); + throw new UnsupportedMetadataException(sprintf('The metadata factory should return instances of "Symfony\Component\Validator\Mapping\ClassMetadataInterface", got: "%s".', \is_object($classMetadata) ? \get_class($classMetadata) : \gettype($classMetadata))); } $this->validateClassNode( @@ -374,10 +355,10 @@ private function validateObject($object, $propertyPath, array $groups, $traversa * objects are iterated as well. Nested arrays are always iterated, * regardless of the value of $recursive. * - * @param iterable $collection The collection - * @param string $propertyPath The current property path - * @param string[] $groups The validated groups - * @param ExecutionContextInterface $context The current execution context + * @param iterable $collection The collection + * @param string $propertyPath The current property path + * @param (string|GroupSequence)[] $groups The validated groups + * @param ExecutionContextInterface $context The current execution context * * @see ClassNode * @see CollectionNode @@ -443,7 +424,7 @@ private function validateEachObjectIn($collection, $propertyPath, array $groups, * the object * @param string $propertyPath The property path leading * to the object - * @param string[] $groups The groups in which the + * @param (string|GroupSequence)[] $groups The groups in which the * object should be validated * @param string[]|null $cascadedGroups The groups in which * cascaded objects should @@ -555,12 +536,7 @@ private function validateClassNode($object, $cacheKey, ClassMetadataInterface $m // returns two metadata objects, not just one foreach ($metadata->getPropertyMetadata($propertyName) as $propertyMetadata) { if (!$propertyMetadata instanceof PropertyMetadataInterface) { - throw new UnsupportedMetadataException(sprintf( - 'The property metadata instances should implement '. - '"Symfony\Component\Validator\Mapping\PropertyMetadataInterface", '. - 'got: "%s".', - \is_object($propertyMetadata) ? \get_class($propertyMetadata) : \gettype($propertyMetadata) - )); + throw new UnsupportedMetadataException(sprintf('The property metadata instances should implement "Symfony\Component\Validator\Mapping\PropertyMetadataInterface", got: "%s".', \is_object($propertyMetadata) ? \get_class($propertyMetadata) : \gettype($propertyMetadata))); } $propertyValue = $propertyMetadata->getPropertyValue($object); @@ -597,11 +573,7 @@ private function validateClassNode($object, $cacheKey, ClassMetadataInterface $m // If TRAVERSE, fail if we have no Traversable if (!$object instanceof \Traversable) { - throw new ConstraintDefinitionException(sprintf( - 'Traversal was enabled for "%s", but this class '. - 'does not implement "\Traversable".', - \get_class($object) - )); + throw new ConstraintDefinitionException(sprintf('Traversal was enabled for "%s", but this class does not implement "\Traversable".', \get_class($object))); } $this->validateEachObjectIn( @@ -636,7 +608,7 @@ private function validateClassNode($object, $cacheKey, ClassMetadataInterface $m * value * @param string $propertyPath The property path leading * to the value - * @param string[] $groups The groups in which the + * @param (string|GroupSequence)[] $groups The groups in which the * value should be validated * @param string[]|null $cascadedGroups The groups in which * cascaded objects should diff --git a/src/Symfony/Component/Validator/Validator/ValidatorInterface.php b/src/Symfony/Component/Validator/Validator/ValidatorInterface.php index 5bac2e88987f6..78157465ab5ce 100644 --- a/src/Symfony/Component/Validator/Validator/ValidatorInterface.php +++ b/src/Symfony/Component/Validator/Validator/ValidatorInterface.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Validator\Validator; use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Constraints\GroupSequence; use Symfony\Component\Validator\ConstraintViolationListInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface; @@ -29,12 +30,9 @@ interface ValidatorInterface extends MetadataFactoryInterface * If no constraint is passed, the constraint * {@link \Symfony\Component\Validator\Constraints\Valid} is assumed. * - * @param mixed $value The value to validate - * @param Constraint|Constraint[] $constraints The constraint(s) to validate - * against - * @param array|null $groups The validation groups to - * validate. If none is given, - * "Default" is assumed + * @param mixed $value The value to validate + * @param Constraint|Constraint[] $constraints The constraint(s) to validate against + * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed * * @return ConstraintViolationListInterface A list of constraint violations * If the list is empty, validation @@ -46,10 +44,9 @@ public function validate($value, $constraints = null, $groups = null); * Validates a property of an object against the constraints specified * for this property. * - * @param object $object The object - * @param string $propertyName The name of the validated property - * @param array|null $groups The validation groups to validate. If - * none is given, "Default" is assumed + * @param object $object The object + * @param string $propertyName The name of the validated property + * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed * * @return ConstraintViolationListInterface A list of constraint violations * If the list is empty, validation @@ -61,12 +58,10 @@ public function validateProperty($object, $propertyName, $groups = null); * Validates a value against the constraints specified for an object's * property. * - * @param object|string $objectOrClass The object or its class name - * @param string $propertyName The name of the property - * @param mixed $value The value to validate against the - * property's constraints - * @param array|null $groups The validation groups to validate. If - * none is given, "Default" is assumed + * @param object|string $objectOrClass The object or its class name + * @param string $propertyName The name of the property + * @param mixed $value The value to validate against the property's constraints + * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed * * @return ConstraintViolationListInterface A list of constraint violations * If the list is empty, validation diff --git a/src/Symfony/Component/VarDumper/Resources/functions/dump.php b/src/Symfony/Component/VarDumper/Resources/functions/dump.php index 1ea3dc8434ddd..248f255129ea8 100644 --- a/src/Symfony/Component/VarDumper/Resources/functions/dump.php +++ b/src/Symfony/Component/VarDumper/Resources/functions/dump.php @@ -19,8 +19,8 @@ function dump($var, ...$moreVars) { VarDumper::dump($var); - foreach ($moreVars as $var) { - VarDumper::dump($var); + foreach ($moreVars as $v) { + VarDumper::dump($v); } if (1 < func_num_args()) { @@ -36,8 +36,8 @@ function dd($var, ...$moreVars) { VarDumper::dump($var); - foreach ($moreVars as $var) { - VarDumper::dump($var); + foreach ($moreVars as $v) { + VarDumper::dump($v); } exit(1); diff --git a/src/Symfony/Component/VarDumper/Tests/Dumper/FunctionsTest.php b/src/Symfony/Component/VarDumper/Tests/Dumper/FunctionsTest.php new file mode 100644 index 0000000000000..81ecdddc56823 --- /dev/null +++ b/src/Symfony/Component/VarDumper/Tests/Dumper/FunctionsTest.php @@ -0,0 +1,57 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Tests\Dumper; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\VarDumper\Cloner\VarCloner; +use Symfony\Component\VarDumper\Dumper\CliDumper; +use Symfony\Component\VarDumper\VarDumper; + +class FunctionsTest extends TestCase +{ + public function testDumpReturnsFirstArg() + { + $this->setupVarDumper(); + + $var1 = 'a'; + + ob_start(); + $return = dump($var1); + $out = ob_get_clean(); + + $this->assertEquals($var1, $return); + } + + public function testDumpReturnsAllArgsInArray() + { + $this->setupVarDumper(); + + $var1 = 'a'; + $var2 = 'b'; + $var3 = 'c'; + + ob_start(); + $return = dump($var1, $var2, $var3); + $out = ob_get_clean(); + + $this->assertEquals(array($var1, $var2, $var3), $return); + } + + protected function setupVarDumper() + { + $cloner = new VarCloner(); + $dumper = new CliDumper('php://output'); + VarDumper::setHandler(function ($var) use ($cloner, $dumper) { + $dumper->dump($cloner->cloneVar($var)); + }); + } +} diff --git a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php index 8ef966666eeb0..87f48002487d7 100644 --- a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php +++ b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php @@ -345,6 +345,25 @@ public function testApplyWithSameNameTransition2() $this->assertTrue($marking->has('d')); } + public function testApplyWithSameNameTransition3() + { + $subject = new \stdClass(); + $subject->marking = array('a' => 1); + + $places = range('a', 'd'); + $transitions = array(); + $transitions[] = new Transition('t', 'a', 'b'); + $transitions[] = new Transition('t', 'b', 'c'); + $transitions[] = new Transition('t', 'c', 'd'); + $definition = new Definition($places, $transitions); + $workflow = new Workflow($definition, new MultipleStateMarkingStore()); + + $marking = $workflow->apply($subject, 't'); + // We want to make sure we do not end up in "d" + $this->assertTrue($marking->has('b')); + $this->assertFalse($marking->has('d')); + } + public function testApplyWithEventDispatcher() { $definition = $this->createComplexWorkflowDefinition(); diff --git a/src/Symfony/Component/Workflow/Workflow.php b/src/Symfony/Component/Workflow/Workflow.php index 963f1b8b27180..21676e0fc89ae 100644 --- a/src/Symfony/Component/Workflow/Workflow.php +++ b/src/Symfony/Component/Workflow/Workflow.php @@ -139,6 +139,7 @@ public function apply($subject, $transitionName) $transitionBlockerList = null; $applied = false; + $approvedTransitionQueue = array(); foreach ($this->definition->getTransitions() as $transition) { if ($transition->getName() !== $transitionName) { @@ -149,7 +150,10 @@ public function apply($subject, $transitionName) if (!$transitionBlockerList->isEmpty()) { continue; } + $approvedTransitionQueue[] = $transition; + } + foreach ($approvedTransitionQueue as $transition) { $applied = true; $this->leave($subject, $transition, $marking); diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 16ad0afe7e373..a4085eb6d8336 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -1945,6 +1945,10 @@ public function testParsingNotReadableFilesThrowsException() $this->markTestSkipped('chmod is not supported on Windows'); } + if (!getenv('USER') || 'root' === getenv('USER')) { + $this->markTestSkipped('This test will fail if run under superuser'); + } + $file = __DIR__.'/Fixtures/not_readable.yml'; chmod($file, 0200); diff --git a/src/Symfony/Component/Yaml/Yaml.php b/src/Symfony/Component/Yaml/Yaml.php index 80de7e877723c..94a5e4ad7d7d4 100644 --- a/src/Symfony/Component/Yaml/Yaml.php +++ b/src/Symfony/Component/Yaml/Yaml.php @@ -37,11 +37,10 @@ class Yaml /** * Parses a YAML file into a PHP value. * - * Usage: - * - * $array = Yaml::parseFile('config.yml'); - * print_r($array); - * + * Usage: + * + * $array = Yaml::parseFile('config.yml'); + * print_r($array); * * @param string $filename The path to the YAML file to be parsed * @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior