Upgrade 1-11.38

This commit is contained in:
xesmyd
2026-03-30 14:10:30 +02:00
parent f2a7e6d1fc
commit ac648ef29d
24665 changed files with 69682 additions and 2205004 deletions
+13 -5
View File
@@ -14,6 +14,7 @@ namespace Symfony\Component\Serializer\Encoder;
use Symfony\Component\Serializer\Exception\RuntimeException;
use Symfony\Component\Yaml\Dumper;
use Symfony\Component\Yaml\Parser;
use Symfony\Component\Yaml\Yaml;
/**
* Encodes YAML data.
@@ -22,7 +23,10 @@ use Symfony\Component\Yaml\Parser;
*/
class YamlEncoder implements EncoderInterface, DecoderInterface
{
const FORMAT = 'yaml';
public const FORMAT = 'yaml';
private const ALTERNATIVE_FORMAT = 'yml';
public const PRESERVE_EMPTY_OBJECTS = 'preserve_empty_objects';
private $dumper;
private $parser;
@@ -34,8 +38,8 @@ class YamlEncoder implements EncoderInterface, DecoderInterface
throw new RuntimeException('The YamlEncoder class requires the "Yaml" component. Install "symfony/yaml" to use it.');
}
$this->dumper = $dumper ?: new Dumper();
$this->parser = $parser ?: new Parser();
$this->dumper = $dumper ?? new Dumper();
$this->parser = $parser ?? new Parser();
$this->defaultContext = array_merge($this->defaultContext, $defaultContext);
}
@@ -46,6 +50,10 @@ class YamlEncoder implements EncoderInterface, DecoderInterface
{
$context = array_merge($this->defaultContext, $context);
if (isset($context[self::PRESERVE_EMPTY_OBJECTS])) {
$context['yaml_flags'] |= Yaml::DUMP_OBJECT_AS_MAP;
}
return $this->dumper->dump($data, $context['yaml_inline'], $context['yaml_indent'], $context['yaml_flags']);
}
@@ -54,7 +62,7 @@ class YamlEncoder implements EncoderInterface, DecoderInterface
*/
public function supportsEncoding($format)
{
return self::FORMAT === $format;
return self::FORMAT === $format || self::ALTERNATIVE_FORMAT === $format;
}
/**
@@ -72,6 +80,6 @@ class YamlEncoder implements EncoderInterface, DecoderInterface
*/
public function supportsDecoding($format)
{
return self::FORMAT === $format;
return self::FORMAT === $format || self::ALTERNATIVE_FORMAT === $format;
}
}