diff --git a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit index 0aab91a5d0..fa03dc2bf6 100755 --- a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit +++ b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit @@ -56,10 +56,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')) { @@ -77,6 +74,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'; 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 %} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php index b1a957201f..0b2c341c47 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php @@ -159,7 +159,7 @@ class TranslationUpdateCommandTest extends TestCase ->expects($this->any()) ->method('getFormats') ->will( - $this->returnValue(['xlf', 'yml']) + $this->returnValue(['xlf', 'yml', 'yaml']) ); if (null === $kernel) { diff --git a/src/Symfony/Component/Debug/DebugClassLoader.php b/src/Symfony/Component/Debug/DebugClassLoader.php index d22e144e95..785aa75838 100644 --- a/src/Symfony/Component/Debug/DebugClassLoader.php +++ b/src/Symfony/Component/Debug/DebugClassLoader.php @@ -324,7 +324,7 @@ class DebugClassLoader $finalOrInternal = false; 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]; $finalOrInternal = true; diff --git a/src/Symfony/Component/Debug/Tests/Fixtures/FinalMethod.php b/src/Symfony/Component/Debug/Tests/Fixtures/FinalMethod.php index 03e47e8a7a..60a28b24c2 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() { diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index f1bafe9812..9d16f9c27c 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -138,7 +138,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 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..b44d8212df --- /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/HttpKernel/Log/Logger.php b/src/Symfony/Component/HttpKernel/Log/Logger.php index 2344aa0a54..3969487b77 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(string $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'])) { 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。 + diff --git a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php index cbe5709767..e110dbd0bc 100644 --- a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php @@ -30,6 +30,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; */ abstract class ConstraintValidatorTestCase extends TestCase { + use TestCaseSetUpTearDownTrait; + /** * @var ExecutionContextInterface */ @@ -49,7 +51,7 @@ abstract class ConstraintValidatorTestCase extends TestCase protected $constraint; protected $defaultTimezone; - protected function setUp() + private function doSetUp() { $this->group = 'MyGroup'; $this->metadata = null; @@ -71,7 +73,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..236e02267b --- /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(); + } + } +}