diff --git a/.travis.yml b/.travis.yml
index b279eac021..19bcdeac8e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -159,7 +159,7 @@ before_install:
tfold ext.apcu tpecl apcu-5.1.16 apcu.so $INI
tfold ext.mongodb tpecl mongodb-1.6.0alpha1 mongodb.so $INI
tfold ext.igbinary tpecl igbinary-2.0.8 igbinary.so $INI
- tfold ext.zookeeper tpecl zookeeper-0.6.0 zookeeper.so $INI
+ tfold ext.zookeeper tpecl zookeeper-0.7.1 zookeeper.so $INI
tfold ext.amqp tpecl amqp-1.9.4 amqp.so $INI
done
diff --git a/src/Symfony/Bridge/Monolog/Logger.php b/src/Symfony/Bridge/Monolog/Logger.php
index de021426e0..fb668be62b 100644
--- a/src/Symfony/Bridge/Monolog/Logger.php
+++ b/src/Symfony/Bridge/Monolog/Logger.php
@@ -12,6 +12,7 @@
namespace Symfony\Bridge\Monolog;
use Monolog\Logger as BaseLogger;
+use Monolog\ResettableInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
use Symfony\Contracts\Service\ResetInterface;
@@ -73,6 +74,10 @@ class Logger extends BaseLogger implements DebugLoggerInterface, ResetInterface
public function reset()
{
$this->clear();
+
+ if ($this instanceof ResettableInterface) {
+ parent::reset();
+ }
}
/**
diff --git a/src/Symfony/Bridge/Monolog/Tests/LoggerTest.php b/src/Symfony/Bridge/Monolog/Tests/LoggerTest.php
index 2ee7bc7d93..143200f6c5 100644
--- a/src/Symfony/Bridge/Monolog/Tests/LoggerTest.php
+++ b/src/Symfony/Bridge/Monolog/Tests/LoggerTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Bridge\Monolog\Tests;
use Monolog\Handler\TestHandler;
+use Monolog\ResettableInterface;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Monolog\Logger;
use Symfony\Bridge\Monolog\Processor\DebugProcessor;
@@ -108,6 +109,22 @@ class LoggerTest extends TestCase
$this->assertSame(0, $logger->countErrors());
}
+ public function testReset()
+ {
+ $handler = new TestHandler();
+ $logger = new Logger('test', [$handler]);
+ $logger->pushProcessor(new DebugProcessor());
+
+ $logger->info('test');
+ $logger->reset();
+
+ $this->assertEmpty($logger->getLogs());
+ $this->assertSame(0, $logger->countErrors());
+ if (class_exists(ResettableInterface::class)) {
+ $this->assertEmpty($handler->getRecords());
+ }
+ }
+
/**
* @group legacy
* @expectedDeprecation The "Symfony\Bridge\Monolog\Logger::getLogs()" method will have a new "Request $request = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.
diff --git a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit
index 66d44c9073..6609eeff62 100755
--- a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit
+++ b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit
@@ -58,10 +58,7 @@ if (PHP_VERSION_ID >= 70100) {
$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')) {
@@ -79,6 +76,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 9375051e47..2bd1b2cc6d 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 c1bfd0004e..1ec04fd970 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 ff4240b3a8..ee1df28271 100644
--- a/src/Symfony/Component/Debug/DebugClassLoader.php
+++ b/src/Symfony/Component/Debug/DebugClassLoader.php
@@ -365,7 +365,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/DependencyInjection/FormPass.php b/src/Symfony/Component/Form/DependencyInjection/FormPass.php
index 0c6306672d..358bf71205 100644
--- a/src/Symfony/Component/Form/DependencyInjection/FormPass.php
+++ b/src/Symfony/Component/Form/DependencyInjection/FormPass.php
@@ -102,9 +102,9 @@ class FormPass implements CompilerPassInterface
} elseif (method_exists($serviceDefinition->getClass(), 'getExtendedTypes')) {
$extendsTypes = false;
+ $typeExtensionsClasses[] = $serviceDefinition->getClass();
foreach ($serviceDefinition->getClass()::getExtendedTypes() as $extendedType) {
$typeExtensions[$extendedType][] = new Reference($serviceId);
- $typeExtensionsClasses[] = $serviceDefinition->getClass();
$extendsTypes = true;
}
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/Messenger/Tests/Transport/AmqpExt/AmqpSenderTest.php b/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpSenderTest.php
index 7fcb41c159..14fee16ca6 100644
--- a/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpSenderTest.php
+++ b/src/Symfony/Component/Messenger/Tests/Transport/AmqpExt/AmqpSenderTest.php
@@ -38,6 +38,21 @@ class AmqpSenderTest extends TestCase
$sender->send($envelope);
}
+ public function testItSendsTheEncodedMessageWithoutHeaders()
+ {
+ $envelope = new Envelope(new DummyMessage('Oy'));
+ $encoded = ['body' => '...'];
+
+ $serializer = $this->getMockBuilder(SerializerInterface::class)->getMock();
+ $serializer->method('encode')->with($envelope)->willReturnOnConsecutiveCalls($encoded);
+
+ $connection = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock();
+ $connection->expects($this->once())->method('publish')->with($encoded['body'], []);
+
+ $sender = new AmqpSender($connection, $serializer);
+ $sender->send($envelope);
+ }
+
/**
* @expectedException \Symfony\Component\Messenger\Exception\TransportException
*/
diff --git a/src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpSender.php b/src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpSender.php
index e9760ac2eb..daf8199a5d 100644
--- a/src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpSender.php
+++ b/src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpSender.php
@@ -43,7 +43,7 @@ class AmqpSender implements SenderInterface
$encodedMessage = $this->serializer->encode($envelope);
try {
- $this->connection->publish($encodedMessage['body'], $encodedMessage['headers']);
+ $this->connection->publish($encodedMessage['body'], $encodedMessage['headers'] ?? []);
} catch (\AMQPException $e) {
throw new TransportException($e->getMessage(), 0, $e);
}
diff --git a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php
index 83f14acb70..a0a97fb224 100644
--- a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php
+++ b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php
@@ -118,7 +118,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
}
if (
- $context['enable_constructor_extraction'] ?? $this->enableConstructorExtraction &&
+ ($context['enable_constructor_extraction'] ?? $this->enableConstructorExtraction) &&
$fromConstructor = $this->extractFromConstructor($class, $property)
) {
return $fromConstructor;
diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php
index 7472d6ef21..84f3d8f925 100644
--- a/src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php
+++ b/src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php
@@ -313,4 +313,29 @@ class ReflectionExtractorTest extends TestCase
[NotInstantiable::class, 'foo', false],
];
}
+
+ /**
+ * @dataProvider constructorTypesProvider
+ */
+ public function testExtractTypeConstructor(string $class, string $property, array $type = null)
+ {
+ /* Check that constructor extractions works by default, and if passed in via context.
+ Check that null is returned if constructor extraction is disabled */
+ $this->assertEquals($type, $this->extractor->getTypes($class, $property, []));
+ $this->assertEquals($type, $this->extractor->getTypes($class, $property, ['enable_constructor_extraction' => true]));
+ $this->assertNull($this->extractor->getTypes($class, $property, ['enable_constructor_extraction' => false]));
+ }
+
+ public function constructorTypesProvider(): array
+ {
+ return [
+ // php71 dummy has following constructor: __construct(string $string, int $intPrivate)
+ [Php71Dummy::class, 'string', [new Type(Type::BUILTIN_TYPE_STRING, false)]],
+ [Php71Dummy::class, 'intPrivate', [new Type(Type::BUILTIN_TYPE_INT, false)]],
+ // Php71DummyExtended2 adds int $intWithAccessor
+ [Php71DummyExtended2::class, 'intWithAccessor', [new Type(Type::BUILTIN_TYPE_INT, false)]],
+ [Php71DummyExtended2::class, 'intPrivate', [new Type(Type::BUILTIN_TYPE_INT, false)]],
+ [DefaultValue::class, 'foo', null],
+ ];
+ }
}
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。
+