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
+17 -15
View File
@@ -20,11 +20,24 @@ use Symfony\Component\Serializer\Exception\NotEncodableValueException;
*/
class JsonEncode implements EncoderInterface
{
private $options;
public const OPTIONS = 'json_encode_options';
public function __construct($bitmask = 0)
private $defaultContext = [
self::OPTIONS => 0,
];
/**
* @param array $defaultContext
*/
public function __construct($defaultContext = [])
{
$this->options = $bitmask;
if (!\is_array($defaultContext)) {
@trigger_error(sprintf('Passing an integer as first parameter of the "%s()" method is deprecated since Symfony 4.2, use the "json_encode_options" key of the context instead.', __METHOD__), \E_USER_DEPRECATED);
$this->defaultContext[self::OPTIONS] = (int) $defaultContext;
} else {
$this->defaultContext = array_merge($this->defaultContext, $defaultContext);
}
}
/**
@@ -34,8 +47,7 @@ class JsonEncode implements EncoderInterface
*/
public function encode($data, $format, array $context = [])
{
$context = $this->resolveContext($context);
$options = $context['json_encode_options'];
$options = $context[self::OPTIONS] ?? $this->defaultContext[self::OPTIONS];
try {
$encodedJson = json_encode($data, $options);
@@ -61,14 +73,4 @@ class JsonEncode implements EncoderInterface
{
return JsonEncoder::FORMAT === $format;
}
/**
* Merge default json encode options with context.
*
* @return array
*/
private function resolveContext(array $context = [])
{
return array_merge(['json_encode_options' => $this->options], $context);
}
}