From 3be1850dcb93dabd34457d4f4a3e9b7c4888673d Mon Sep 17 00:00:00 2001 From: alfidinouhail Date: Mon, 4 Mar 2019 22:35:02 +0000 Subject: [PATCH 01/10] Added translations for chineese language. --- .../translations/validators.zh_CN.xlf | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.zh_CN.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.zh_CN.xlf index d4ed03ded1..3c2f25c0f7 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.zh_CN.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.zh_CN.xlf @@ -310,10 +310,30 @@ This value does not match the expected {{ charset }} charset. 该值不符合 {{ charset }} 编码。 + + This is not a valid Business Identifier Code (BIC). + 这不是有效的业务标识符代码(BIC)。 + Error 错误 + + This is not a valid UUID. + 这不是有效的UUID。 + + + This value should be a multiple of {{ compared_value }}. + 此值应为 {{ compared_value }} 的倍数。 + + + This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}. + 此业务标识符代码(BIC)与IBAN {{ iban }} 无关。 + + + This value should be valid JSON. + 该值应该是有效的JSON。 + From e97ea77af5e613ca11dd5e7bd66c27dbd41e2253 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Wed, 6 Mar 2019 15:53:23 +0100 Subject: [PATCH 02/10] [Debug][DebugClassLoader] Detect annotations before blank docblock lines on final and internal methods --- src/Symfony/Component/Debug/DebugClassLoader.php | 2 +- src/Symfony/Component/Debug/Tests/Fixtures/FinalMethod.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Debug/DebugClassLoader.php b/src/Symfony/Component/Debug/DebugClassLoader.php index e6ae092073..87071530c6 100644 --- a/src/Symfony/Component/Debug/DebugClassLoader.php +++ b/src/Symfony/Component/Debug/DebugClassLoader.php @@ -307,7 +307,7 @@ class DebugClassLoader } foreach (['final', 'internal'] as $annotation) { - if (false !== \strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$)#s', $doc, $notice)) { + if (false !== \strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s', $doc, $notice)) { $message = isset($notice[1]) ? preg_replace('#\.?\r?\n( \*)? *(?= |\r?\n|$)#', '', $notice[1]) : ''; self::${$annotation.'Methods'}[$class][$method->name] = [$class, $message]; } diff --git a/src/Symfony/Component/Debug/Tests/Fixtures/FinalMethod.php b/src/Symfony/Component/Debug/Tests/Fixtures/FinalMethod.php index 98a47524c4..595dd0a887 100644 --- a/src/Symfony/Component/Debug/Tests/Fixtures/FinalMethod.php +++ b/src/Symfony/Component/Debug/Tests/Fixtures/FinalMethod.php @@ -13,6 +13,8 @@ class FinalMethod /** * @final + * + * @return int */ public function finalMethod2() { From 5ef254fa65ac0454918ff0ee62835e8da749d39c Mon Sep 17 00:00:00 2001 From: Massimiliano Arione Date: Thu, 7 Mar 2019 11:36:06 +0100 Subject: [PATCH 03/10] compatibility with phpunit8 --- .../Form/Test/FormIntegrationTestCase.php | 4 +- .../Form/Test/TestCaseSetUpTearDownTrait.php | 82 +++++++++++++++++++ .../Component/Form/Test/TypeTestCase.php | 6 +- .../Test/ConstraintValidatorTestCase.php | 6 +- .../Test/TestCaseSetUpTearDownTrait.php | 82 +++++++++++++++++++ 5 files changed, 175 insertions(+), 5 deletions(-) create mode 100644 src/Symfony/Component/Form/Test/TestCaseSetUpTearDownTrait.php create mode 100644 src/Symfony/Component/Validator/Test/TestCaseSetUpTearDownTrait.php diff --git a/src/Symfony/Component/Form/Test/FormIntegrationTestCase.php b/src/Symfony/Component/Form/Test/FormIntegrationTestCase.php index 7aa7c1c438..b50d943779 100644 --- a/src/Symfony/Component/Form/Test/FormIntegrationTestCase.php +++ b/src/Symfony/Component/Form/Test/FormIntegrationTestCase.php @@ -20,12 +20,14 @@ use Symfony\Component\Form\Forms; */ abstract class FormIntegrationTestCase extends TestCase { + use TestCaseSetUpTearDownTrait; + /** * @var FormFactoryInterface */ protected $factory; - protected function setUp() + private function doSetUp() { $this->factory = Forms::createFormFactoryBuilder() ->addExtensions($this->getExtensions()) diff --git a/src/Symfony/Component/Form/Test/TestCaseSetUpTearDownTrait.php b/src/Symfony/Component/Form/Test/TestCaseSetUpTearDownTrait.php new file mode 100644 index 0000000000..279755f758 --- /dev/null +++ b/src/Symfony/Component/Form/Test/TestCaseSetUpTearDownTrait.php @@ -0,0 +1,82 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Form\Test; + +use PHPUnit\Framework\TestCase; + +// Auto-adapt to PHPUnit 8 that added a `void` return-type to the setUp/tearDown methods + +if (method_exists(\ReflectionMethod::class, 'hasReturnType') && (new \ReflectionMethod(TestCase::class, 'tearDown'))->hasReturnType()) { + eval(' + namespace Symfony\Component\Form\Test; + + /** + * @internal + */ + trait TestCaseSetUpTearDownTrait + { + private function doSetUp(): void + { + } + + private function doTearDown(): void + { + } + + protected function setUp(): void + { + $this->doSetUp(); + } + + protected function tearDown(): void + { + $this->doTearDown(); + } + } +'); +} else { + /** + * @internal + */ + trait TestCaseSetUpTearDownTrait + { + /** + * @return void + */ + private function doSetUp() + { + } + + /** + * @return void + */ + private function doTearDown() + { + } + + /** + * @return void + */ + protected function setUp() + { + $this->doSetUp(); + } + + /** + * @return void + */ + protected function tearDown() + { + $this->doTearDown(); + } + } +} diff --git a/src/Symfony/Component/Form/Test/TypeTestCase.php b/src/Symfony/Component/Form/Test/TypeTestCase.php index 7c9aa96a9e..19fb5c32a0 100644 --- a/src/Symfony/Component/Form/Test/TypeTestCase.php +++ b/src/Symfony/Component/Form/Test/TypeTestCase.php @@ -17,6 +17,8 @@ use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait; abstract class TypeTestCase extends FormIntegrationTestCase { + use TestCaseSetUpTearDownTrait; + /** * @var FormBuilder */ @@ -27,7 +29,7 @@ abstract class TypeTestCase extends FormIntegrationTestCase */ protected $dispatcher; - protected function setUp() + private function doSetUp() { parent::setUp(); @@ -35,7 +37,7 @@ abstract class TypeTestCase extends FormIntegrationTestCase $this->builder = new FormBuilder('', null, $this->dispatcher, $this->factory); } - protected function tearDown() + private function doTearDown() { if (\in_array(ValidatorExtensionTrait::class, class_uses($this))) { $this->validator = null; diff --git a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php index afe1f1a582..f07adb9423 100644 --- a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php @@ -29,6 +29,8 @@ use Symfony\Component\Validator\Mapping\PropertyMetadata; */ abstract class ConstraintValidatorTestCase extends TestCase { + use TestCaseSetUpTearDownTrait; + /** * @var ExecutionContextInterface */ @@ -48,7 +50,7 @@ abstract class ConstraintValidatorTestCase extends TestCase protected $constraint; protected $defaultTimezone; - protected function setUp() + private function doSetUp() { $this->group = 'MyGroup'; $this->metadata = null; @@ -70,7 +72,7 @@ abstract class ConstraintValidatorTestCase extends TestCase $this->setDefaultTimezone('UTC'); } - protected function tearDown() + private function doTearDown() { $this->restoreDefaultTimezone(); } diff --git a/src/Symfony/Component/Validator/Test/TestCaseSetUpTearDownTrait.php b/src/Symfony/Component/Validator/Test/TestCaseSetUpTearDownTrait.php new file mode 100644 index 0000000000..426c148913 --- /dev/null +++ b/src/Symfony/Component/Validator/Test/TestCaseSetUpTearDownTrait.php @@ -0,0 +1,82 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Validator\Test; + +use PHPUnit\Framework\TestCase; + +// Auto-adapt to PHPUnit 8 that added a `void` return-type to the setUp/tearDown methods + +if (method_exists(\ReflectionMethod::class, 'hasReturnType') && (new \ReflectionMethod(TestCase::class, 'tearDown'))->hasReturnType()) { + eval(' + namespace Symfony\Component\Validator\Test; + + /** + * @internal + */ + trait TestCaseSetUpTearDownTrait + { + private function doSetUp(): void + { + } + + private function doTearDown(): void + { + } + + protected function setUp(): void + { + $this->doSetUp(); + } + + protected function tearDown(): void + { + $this->doTearDown(); + } + } +'); +} else { + /** + * @internal + */ + trait TestCaseSetUpTearDownTrait + { + /** + * @return void + */ + private function doSetUp() + { + } + + /** + * @return void + */ + private function doTearDown() + { + } + + /** + * @return void + */ + protected function setUp() + { + $this->doSetUp(); + } + + /** + * @return void + */ + protected function tearDown() + { + $this->doTearDown(); + } + } +} From 83826daba9cf2ddc7e43a05f39f39264d6206aaa Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 8 Mar 2019 19:10:13 +0100 Subject: [PATCH 04/10] update docblock to match the actual behavior --- src/Symfony/Component/DependencyInjection/Container.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index e822643439..e385f06898 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -159,7 +159,7 @@ class Container implements ResettableContainerInterface /** * Sets a service. * - * Setting a service to null resets the service: has() returns false and get() + * Setting a synthetic service to null resets it: has() returns false and get() * behaves in the same way as if the service was never created. * * @param string $id The service identifier From d69d5717cdb8a7ddab8a8a68d1b71bd70218af45 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Sat, 9 Mar 2019 08:26:56 -0500 Subject: [PATCH 05/10] Change default log level for output streams --- src/Symfony/Component/HttpKernel/Log/Logger.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpKernel/Log/Logger.php b/src/Symfony/Component/HttpKernel/Log/Logger.php index 6cfc759490..e174587d15 100644 --- a/src/Symfony/Component/HttpKernel/Log/Logger.php +++ b/src/Symfony/Component/HttpKernel/Log/Logger.php @@ -40,7 +40,7 @@ class Logger extends AbstractLogger public function __construct($minLevel = null, $output = 'php://stderr', callable $formatter = null) { if (null === $minLevel) { - $minLevel = LogLevel::WARNING; + $minLevel = 'php://stdout' === $output || 'php://stderr' === $output ? LogLevel::CRITICAL : LogLevel::WARNING; if (isset($_ENV['SHELL_VERBOSITY']) || isset($_SERVER['SHELL_VERBOSITY'])) { switch ((int) (isset($_ENV['SHELL_VERBOSITY']) ? $_ENV['SHELL_VERBOSITY'] : $_SERVER['SHELL_VERBOSITY'])) { From ba4203064136cb6e462c0c9f1f2a9cc2699bbc54 Mon Sep 17 00:00:00 2001 From: Gary PEGEOT Date: Sat, 9 Mar 2019 15:04:18 +0000 Subject: [PATCH 06/10] [translation] Update defaut format from yml to yaml --- .../Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php | 2 +- .../Tests/Command/TranslationUpdateCommandTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index 72e410d2c3..2a06b102e8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -83,7 +83,7 @@ class TranslationUpdateCommand extends ContainerAwareCommand new InputArgument('bundle', InputArgument::OPTIONAL, 'The bundle name or directory where to load the messages'), new InputOption('prefix', null, InputOption::VALUE_OPTIONAL, 'Override the default prefix', '__'), new InputOption('no-prefix', null, InputOption::VALUE_NONE, '[DEPRECATED] If set, no prefix is added to the translations'), - new InputOption('output-format', null, InputOption::VALUE_OPTIONAL, 'Override the default output format', 'yml'), + new InputOption('output-format', null, InputOption::VALUE_OPTIONAL, 'Override the default output format', 'yaml'), new InputOption('dump-messages', null, InputOption::VALUE_NONE, 'Should the messages be dumped in the console'), new InputOption('force', null, InputOption::VALUE_NONE, 'Should the update be done'), new InputOption('no-backup', null, InputOption::VALUE_NONE, 'Should backup be disabled'), diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php index 42d4115f1f..87bc6c09e2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php @@ -143,7 +143,7 @@ class TranslationUpdateCommandTest extends TestCase ->expects($this->any()) ->method('getFormats') ->will( - $this->returnValue(['xlf', 'yml']) + $this->returnValue(['xlf', 'yml', 'yaml']) ); if (null === $kernel) { From 2ee178b5c5fb50e9efb87728b7e12e77ecd342c5 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 10 Mar 2019 10:14:34 +0100 Subject: [PATCH 07/10] [TwigBridge] Remove use spaceless tag --- .../templates/form/custom_widgets.html.twig | 28 ++++++++----------- .../Fixtures/templates/form/theme.html.twig | 6 ++-- .../templates/form/theme_extends.html.twig | 6 ++-- .../templates/form/theme_use.html.twig | 6 ++-- 4 files changed, 17 insertions(+), 29 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form/custom_widgets.html.twig b/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form/custom_widgets.html.twig index 4eda8d76d3..36e9c702a9 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form/custom_widgets.html.twig +++ b/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form/custom_widgets.html.twig @@ -1,25 +1,19 @@ -{% block _text_id_widget %} -{% spaceless %} +{% block _text_id_widget -%}
- {{ form_widget(form) }} + {{- form_widget(form) -}}
-{% endspaceless %} -{% endblock _text_id_widget %} +{%- endblock _text_id_widget %} -{% block _names_entry_label %} -{% spaceless %} +{% block _names_entry_label -%} {% if label is empty %} - {% set label = name|humanize %} - {% endif %} + {%- set label = name|humanize -%} + {% endif -%} -{% endspaceless %} -{% endblock _names_entry_label %} +{%- endblock _names_entry_label %} -{% block _name_c_entry_label %} -{% spaceless %} +{% block _name_c_entry_label -%} {% if label is empty %} - {% set label = name|humanize %} - {% endif %} + {%- set label = name|humanize -%} + {% endif -%} -{% endspaceless %} -{% endblock _name_c_entry_label %} +{%- endblock _name_c_entry_label %} diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form/theme.html.twig b/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form/theme.html.twig index da1c1b649b..e8816be96e 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form/theme.html.twig +++ b/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form/theme.html.twig @@ -1,6 +1,4 @@ {% block form_widget_simple %} -{% spaceless %} - {% set type = type|default('text') %} + {%- set type = type|default('text') -%} -{% endspaceless %} -{% endblock form_widget_simple %} +{%- endblock form_widget_simple %} diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form/theme_extends.html.twig b/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form/theme_extends.html.twig index 8c719867ec..501b555efc 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form/theme_extends.html.twig +++ b/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form/theme_extends.html.twig @@ -1,8 +1,6 @@ {% extends 'form_div_layout.html.twig' %} {% block form_widget_simple %} -{% spaceless %} - {% set type = type|default('text') %} + {%- set type = type|default('text') -%} -{% endspaceless %} -{% endblock form_widget_simple %} +{%- endblock form_widget_simple %} diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form/theme_use.html.twig b/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form/theme_use.html.twig index d485b8d0e7..37150734a4 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form/theme_use.html.twig +++ b/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/templates/form/theme_use.html.twig @@ -1,8 +1,6 @@ {% use 'form_div_layout.html.twig' %} {% block form_widget_simple %} -{% spaceless %} - {% set type = type|default('text') %} + {%- set type = type|default('text') -%} -{% endspaceless %} -{% endblock form_widget_simple %} +{%- endblock form_widget_simple %} From 628502645e67783800c541b91d90397668edb70a Mon Sep 17 00:00:00 2001 From: nicoweb Date: Fri, 8 Mar 2019 22:50:51 +0100 Subject: [PATCH 08/10] [PHPUnit-Bridge] override some environment variables --- src/Symfony/Bridge/PhpUnit/bin/simple-phpunit | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit index 2e23aa8900..5d203730c4 100755 --- a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit +++ b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit @@ -26,10 +26,7 @@ if (PHP_VERSION_ID >= 70200) { $PHPUNIT_VERSION = '4.8'; } -if ('composer.json' !== $COMPOSER_JSON = getenv('COMPOSER') ?: 'composer.json') { - putenv('COMPOSER=composer.json'); - $_SERVER['COMPOSER'] = $_ENV['COMPOSER'] = 'composer.json'; -} +$COMPOSER_JSON = getenv('COMPOSER') ?: 'composer.json'; $root = __DIR__; while (!file_exists($root.'/'.$COMPOSER_JSON) || file_exists($root.'/DeprecationErrorHandler.php')) { @@ -47,6 +44,19 @@ if ('phpdbg' === PHP_SAPI) { $PHP .= ' -qrr'; } +$defaultEnvs = [ + 'COMPOSER' => 'composer.json', + 'COMPOSER_VENDOR_DIR' => 'vendor', + 'COMPOSER_BIN_DIR' => 'bin', +]; + +foreach ($defaultEnvs as $envName => $envValue) { + if ($envValue !== getenv($envName)) { + putenv("$envName=$envValue"); + $_SERVER[$envName] = $_ENV[$envName] = $envValue; + } +} + $COMPOSER = file_exists($COMPOSER = $oldPwd.'/composer.phar') || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar`) : `which composer.phar 2> /dev/null`)) ? $PHP.' '.escapeshellarg($COMPOSER) : 'composer'; From 504d4f271632c65ced4c8cfcf2178a73813c01b9 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 10 Mar 2019 11:06:19 +0100 Subject: [PATCH 09/10] cs fix --- .../Component/Form/Test/TestCaseSetUpTearDownTrait.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Form/Test/TestCaseSetUpTearDownTrait.php b/src/Symfony/Component/Form/Test/TestCaseSetUpTearDownTrait.php index 279755f758..b44d8212df 100644 --- a/src/Symfony/Component/Form/Test/TestCaseSetUpTearDownTrait.php +++ b/src/Symfony/Component/Form/Test/TestCaseSetUpTearDownTrait.php @@ -31,12 +31,12 @@ if (method_exists(\ReflectionMethod::class, 'hasReturnType') && (new \Reflection private function doTearDown(): void { } - + protected function setUp(): void { $this->doSetUp(); } - + protected function tearDown(): void { $this->doTearDown(); From b43cfc831d8d9441552ceef5d9abc61e6b12d1c0 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 10 Mar 2019 11:07:44 +0100 Subject: [PATCH 10/10] cs fix --- .../Component/Validator/Test/TestCaseSetUpTearDownTrait.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Validator/Test/TestCaseSetUpTearDownTrait.php b/src/Symfony/Component/Validator/Test/TestCaseSetUpTearDownTrait.php index 426c148913..236e02267b 100644 --- a/src/Symfony/Component/Validator/Test/TestCaseSetUpTearDownTrait.php +++ b/src/Symfony/Component/Validator/Test/TestCaseSetUpTearDownTrait.php @@ -31,12 +31,12 @@ if (method_exists(\ReflectionMethod::class, 'hasReturnType') && (new \Reflection private function doTearDown(): void { } - + protected function setUp(): void { $this->doSetUp(); } - + protected function tearDown(): void { $this->doTearDown();