fix merge

This commit is contained in:
Nicolas Grekas 2019-10-02 11:05:24 +02:00
parent b628210df7
commit e490db8834

View File

@ -35,7 +35,7 @@ class CsvEncoder implements EncoderInterface, DecoderInterface
private $defaultContext = [ private $defaultContext = [
self::DELIMITER_KEY => ',', self::DELIMITER_KEY => ',',
self::ENCLOSURE_KEY => '"', self::ENCLOSURE_KEY => '"',
self::ESCAPE_CHAR_KEY => '\\', self::ESCAPE_CHAR_KEY => '',
self::ESCAPE_FORMULAS_KEY => false, self::ESCAPE_FORMULAS_KEY => false,
self::HEADERS_KEY => [], self::HEADERS_KEY => [],
self::KEY_SEPARATOR_KEY => '.', self::KEY_SEPARATOR_KEY => '.',
@ -47,10 +47,6 @@ class CsvEncoder implements EncoderInterface, DecoderInterface
*/ */
public function __construct($defaultContext = [], string $enclosure = '"', string $escapeChar = '', string $keySeparator = '.', bool $escapeFormulas = false) public function __construct($defaultContext = [], string $enclosure = '"', string $escapeChar = '', string $keySeparator = '.', bool $escapeFormulas = false)
{ {
if ('' === $escapeChar && \PHP_VERSION_ID < 70400) {
$escapeChar = '\\';
}
if (!\is_array($defaultContext)) { if (!\is_array($defaultContext)) {
@trigger_error('Passing configuration options directly to the constructor is deprecated since Symfony 4.2, use the default context instead.', E_USER_DEPRECATED); @trigger_error('Passing configuration options directly to the constructor is deprecated since Symfony 4.2, use the default context instead.', E_USER_DEPRECATED);
@ -64,6 +60,10 @@ class CsvEncoder implements EncoderInterface, DecoderInterface
} }
$this->defaultContext = array_merge($this->defaultContext, $defaultContext); $this->defaultContext = array_merge($this->defaultContext, $defaultContext);
if (\PHP_VERSION_ID < 70400 && '' === $this->defaultContext[self::ESCAPE_CHAR_KEY]) {
$this->defaultContext[self::ESCAPE_CHAR_KEY] = '\\';
}
} }
/** /**