init
This commit is contained in:
26
backend/vendor/symfony/serializer/Annotation/Context.php
vendored
Normal file
26
backend/vendor/symfony/serializer/Annotation/Context.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Annotation;
|
||||
|
||||
// do not deprecate in 6.4/7.0, to make it easier for the ecosystem to support 6.4, 7.4 and 8.0 simultaneously
|
||||
|
||||
class_exists(\Symfony\Component\Serializer\Attribute\Context::class);
|
||||
|
||||
if (false) {
|
||||
/**
|
||||
* @deprecated since Symfony 7.4, use {@see \Symfony\Component\Serializer\Attribute\Context} instead
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
||||
class Context extends \Symfony\Component\Serializer\Attribute\Context
|
||||
{
|
||||
}
|
||||
}
|
||||
24
backend/vendor/symfony/serializer/Annotation/DiscriminatorMap.php
vendored
Normal file
24
backend/vendor/symfony/serializer/Annotation/DiscriminatorMap.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Annotation;
|
||||
|
||||
class_exists(\Symfony\Component\Serializer\Attribute\DiscriminatorMap::class);
|
||||
|
||||
if (false) {
|
||||
/**
|
||||
* @deprecated since Symfony 7.4, use {@see \Symfony\Component\Serializer\Attribute\DiscriminatorMap} instead
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_CLASS)]
|
||||
class DiscriminatorMap extends \Symfony\Component\Serializer\Attribute\DiscriminatorMap
|
||||
{
|
||||
}
|
||||
}
|
||||
24
backend/vendor/symfony/serializer/Annotation/Groups.php
vendored
Normal file
24
backend/vendor/symfony/serializer/Annotation/Groups.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Annotation;
|
||||
|
||||
class_exists(\Symfony\Component\Serializer\Attribute\Groups::class);
|
||||
|
||||
if (false) {
|
||||
/**
|
||||
* @deprecated since Symfony 7.4, use {@see \Symfony\Component\Serializer\Attribute\Groups} instead
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY | \Attribute::TARGET_CLASS)]
|
||||
class Groups extends \Symfony\Component\Serializer\Attribute\Groups
|
||||
{
|
||||
}
|
||||
}
|
||||
24
backend/vendor/symfony/serializer/Annotation/Ignore.php
vendored
Normal file
24
backend/vendor/symfony/serializer/Annotation/Ignore.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Annotation;
|
||||
|
||||
class_exists(\Symfony\Component\Serializer\Attribute\Ignore::class);
|
||||
|
||||
if (false) {
|
||||
/**
|
||||
* @deprecated since Symfony 7.4, use {@see \Symfony\Component\Serializer\Attribute\Ignore} instead
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
|
||||
class Ignore extends \Symfony\Component\Serializer\Attribute\Ignore
|
||||
{
|
||||
}
|
||||
}
|
||||
24
backend/vendor/symfony/serializer/Annotation/MaxDepth.php
vendored
Normal file
24
backend/vendor/symfony/serializer/Annotation/MaxDepth.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Annotation;
|
||||
|
||||
class_exists(\Symfony\Component\Serializer\Attribute\MaxDepth::class);
|
||||
|
||||
if (false) {
|
||||
/**
|
||||
* @deprecated since Symfony 7.4, use {@see \Symfony\Component\Serializer\Attribute\MaxDepth} instead
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
|
||||
class MaxDepth extends \Symfony\Component\Serializer\Attribute\MaxDepth
|
||||
{
|
||||
}
|
||||
}
|
||||
24
backend/vendor/symfony/serializer/Annotation/SerializedName.php
vendored
Normal file
24
backend/vendor/symfony/serializer/Annotation/SerializedName.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Annotation;
|
||||
|
||||
class_exists(\Symfony\Component\Serializer\Attribute\SerializedName::class);
|
||||
|
||||
if (false) {
|
||||
/**
|
||||
* @deprecated since Symfony 7.4, use {@see \Symfony\Component\Serializer\Attribute\SerializedName} instead
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
|
||||
class SerializedName extends \Symfony\Component\Serializer\Attribute\SerializedName
|
||||
{
|
||||
}
|
||||
}
|
||||
24
backend/vendor/symfony/serializer/Annotation/SerializedPath.php
vendored
Normal file
24
backend/vendor/symfony/serializer/Annotation/SerializedPath.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Annotation;
|
||||
|
||||
class_exists(\Symfony\Component\Serializer\Attribute\SerializedPath::class);
|
||||
|
||||
if (false) {
|
||||
/**
|
||||
* @deprecated since Symfony 7.4, use {@see \Symfony\Component\Serializer\Attribute\SerializedPath} instead
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
|
||||
class SerializedPath extends \Symfony\Component\Serializer\Attribute\SerializedPath
|
||||
{
|
||||
}
|
||||
}
|
||||
78
backend/vendor/symfony/serializer/Attribute/Context.php
vendored
Normal file
78
backend/vendor/symfony/serializer/Attribute/Context.php
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Attribute;
|
||||
|
||||
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
||||
class Context
|
||||
{
|
||||
public readonly array $groups;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $context The common context to use when serializing or deserializing
|
||||
* @param array<string, mixed> $normalizationContext The context to use when serializing
|
||||
* @param array<string, mixed> $denormalizationContext The context to use when deserializing
|
||||
* @param string|string[] $groups The groups to use when serializing or deserializing
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly array $context = [],
|
||||
public readonly array $normalizationContext = [],
|
||||
public readonly array $denormalizationContext = [],
|
||||
string|array $groups = [],
|
||||
) {
|
||||
if (!$context && !$normalizationContext && !$denormalizationContext) {
|
||||
throw new InvalidArgumentException(\sprintf('At least one of the "context", "normalizationContext", or "denormalizationContext" options must be provided as a non-empty array to "%s".', static::class));
|
||||
}
|
||||
|
||||
$this->groups = (array) $groups;
|
||||
|
||||
foreach ($this->groups as $group) {
|
||||
if (!\is_string($group)) {
|
||||
throw new InvalidArgumentException(\sprintf('Parameter "groups" given to "%s" must be a string or an array of strings, "%s" given.', static::class, get_debug_type($group)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[\Deprecated('Use the "context" property instead', 'symfony/serializer:7.4')]
|
||||
public function getContext(): array
|
||||
{
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
#[\Deprecated('Use the "normalizationContext" property instead', 'symfony/serializer:7.4')]
|
||||
public function getNormalizationContext(): array
|
||||
{
|
||||
return $this->normalizationContext;
|
||||
}
|
||||
|
||||
#[\Deprecated('Use the "denormalizationContext" property instead', 'symfony/serializer:7.4')]
|
||||
public function getDenormalizationContext(): array
|
||||
{
|
||||
return $this->denormalizationContext;
|
||||
}
|
||||
|
||||
#[\Deprecated('Use the "groups" property instead', 'symfony/serializer:7.4')]
|
||||
public function getGroups(): array
|
||||
{
|
||||
return $this->groups;
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists(\Symfony\Component\Serializer\Annotation\Context::class, false)) {
|
||||
class_alias(Context::class, \Symfony\Component\Serializer\Annotation\Context::class);
|
||||
}
|
||||
68
backend/vendor/symfony/serializer/Attribute/DiscriminatorMap.php
vendored
Normal file
68
backend/vendor/symfony/serializer/Attribute/DiscriminatorMap.php
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Attribute;
|
||||
|
||||
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @author Samuel Roze <samuel.roze@gmail.com>
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_CLASS)]
|
||||
class DiscriminatorMap
|
||||
{
|
||||
/**
|
||||
* @param string $typeProperty The property holding the type discriminator
|
||||
* @param array<string, class-string> $mapping The mapping between types and classes (i.e. ['admin_user' => AdminUser::class])
|
||||
* @param ?string $defaultType The fallback value if nothing specified by $typeProperty
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly string $typeProperty,
|
||||
public readonly array $mapping,
|
||||
public readonly ?string $defaultType = null,
|
||||
) {
|
||||
if (!$typeProperty) {
|
||||
throw new InvalidArgumentException(\sprintf('Parameter "typeProperty" given to "%s" cannot be empty.', static::class));
|
||||
}
|
||||
|
||||
if (!$mapping) {
|
||||
throw new InvalidArgumentException(\sprintf('Parameter "mapping" given to "%s" cannot be empty.', static::class));
|
||||
}
|
||||
|
||||
if (null !== $this->defaultType && !\array_key_exists($this->defaultType, $this->mapping)) {
|
||||
throw new InvalidArgumentException(\sprintf('Default type "%s" given to "%s" must be present in "mapping" types.', $this->defaultType, static::class));
|
||||
}
|
||||
}
|
||||
|
||||
#[\Deprecated('Use the "typeProperty" property instead', 'symfony/serializer:7.4')]
|
||||
public function getTypeProperty(): string
|
||||
{
|
||||
return $this->typeProperty;
|
||||
}
|
||||
|
||||
#[\Deprecated('Use the "mapping" property instead', 'symfony/serializer:7.4')]
|
||||
public function getMapping(): array
|
||||
{
|
||||
return $this->mapping;
|
||||
}
|
||||
|
||||
#[\Deprecated('Use the "defaultType" property instead', 'symfony/serializer:7.4')]
|
||||
public function getDefaultType(): ?string
|
||||
{
|
||||
return $this->defaultType;
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists(\Symfony\Component\Serializer\Annotation\DiscriminatorMap::class, false)) {
|
||||
class_alias(DiscriminatorMap::class, \Symfony\Component\Serializer\Annotation\DiscriminatorMap::class);
|
||||
}
|
||||
32
backend/vendor/symfony/serializer/Attribute/ExtendsSerializationFor.php
vendored
Normal file
32
backend/vendor/symfony/serializer/Attribute/ExtendsSerializationFor.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Attribute;
|
||||
|
||||
/**
|
||||
* Declares that serialization attributes listed on the current class should be added to the given class.
|
||||
*
|
||||
* Classes that use this attribute should contain only properties and methods that
|
||||
* exist on the target class (not necessarily all of them).
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_CLASS)]
|
||||
final class ExtendsSerializationFor
|
||||
{
|
||||
/**
|
||||
* @param class-string $class
|
||||
*/
|
||||
public function __construct(
|
||||
public string $class,
|
||||
) {
|
||||
}
|
||||
}
|
||||
57
backend/vendor/symfony/serializer/Attribute/Groups.php
vendored
Normal file
57
backend/vendor/symfony/serializer/Attribute/Groups.php
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Attribute;
|
||||
|
||||
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY | \Attribute::TARGET_CLASS)]
|
||||
class Groups
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
public readonly array $groups;
|
||||
|
||||
/**
|
||||
* @param string|string[] $groups The groups to define on the attribute target
|
||||
*/
|
||||
public function __construct(string|array $groups)
|
||||
{
|
||||
$this->groups = (array) $groups;
|
||||
|
||||
if (!$this->groups) {
|
||||
throw new InvalidArgumentException(\sprintf('Parameter given to "%s" cannot be empty.', static::class));
|
||||
}
|
||||
|
||||
foreach ($this->groups as $group) {
|
||||
if (!\is_string($group) || '' === $group) {
|
||||
throw new InvalidArgumentException(\sprintf('Parameter given to "%s" must be a string or an array of non-empty strings.', static::class));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
#[\Deprecated('Use the "groups" property instead', 'symfony/serializer:7.4')]
|
||||
public function getGroups(): array
|
||||
{
|
||||
return $this->groups;
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists(\Symfony\Component\Serializer\Annotation\Groups::class, false)) {
|
||||
class_alias(Groups::class, \Symfony\Component\Serializer\Annotation\Groups::class);
|
||||
}
|
||||
24
backend/vendor/symfony/serializer/Attribute/Ignore.php
vendored
Normal file
24
backend/vendor/symfony/serializer/Attribute/Ignore.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Attribute;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
|
||||
class Ignore
|
||||
{
|
||||
}
|
||||
|
||||
if (!class_exists(\Symfony\Component\Serializer\Annotation\Ignore::class, false)) {
|
||||
class_alias(Ignore::class, \Symfony\Component\Serializer\Annotation\Ignore::class);
|
||||
}
|
||||
42
backend/vendor/symfony/serializer/Attribute/MaxDepth.php
vendored
Normal file
42
backend/vendor/symfony/serializer/Attribute/MaxDepth.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Attribute;
|
||||
|
||||
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
|
||||
class MaxDepth
|
||||
{
|
||||
/**
|
||||
* @param int $maxDepth The maximum serialization depth
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly int $maxDepth,
|
||||
) {
|
||||
if ($maxDepth <= 0) {
|
||||
throw new InvalidArgumentException(\sprintf('Parameter given to "%s" must be a positive integer.', static::class));
|
||||
}
|
||||
}
|
||||
|
||||
#[\Deprecated('Use the "maxdepth" property instead', 'symfony/serializer:7.4')]
|
||||
public function getMaxDepth(): int
|
||||
{
|
||||
return $this->maxDepth;
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists(\Symfony\Component\Serializer\Annotation\MaxDepth::class, false)) {
|
||||
class_alias(MaxDepth::class, \Symfony\Component\Serializer\Annotation\MaxDepth::class);
|
||||
}
|
||||
42
backend/vendor/symfony/serializer/Attribute/SerializedName.php
vendored
Normal file
42
backend/vendor/symfony/serializer/Attribute/SerializedName.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Attribute;
|
||||
|
||||
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @author Fabien Bourigault <bourigaultfabien@gmail.com>
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
|
||||
class SerializedName
|
||||
{
|
||||
/**
|
||||
* @param string $serializedName The name of the property as it will be serialized
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly string $serializedName,
|
||||
) {
|
||||
if ('' === $serializedName) {
|
||||
throw new InvalidArgumentException(\sprintf('Parameter given to "%s" must be a non-empty string.', self::class));
|
||||
}
|
||||
}
|
||||
|
||||
#[\Deprecated('Use the "serializedName" property instead', 'symfony/serializer:7.4')]
|
||||
public function getSerializedName(): string
|
||||
{
|
||||
return $this->serializedName;
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists(\Symfony\Component\Serializer\Annotation\SerializedName::class, false)) {
|
||||
class_alias(SerializedName::class, \Symfony\Component\Serializer\Annotation\SerializedName::class);
|
||||
}
|
||||
47
backend/vendor/symfony/serializer/Attribute/SerializedPath.php
vendored
Normal file
47
backend/vendor/symfony/serializer/Attribute/SerializedPath.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Attribute;
|
||||
|
||||
use Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException;
|
||||
use Symfony\Component\PropertyAccess\PropertyPath;
|
||||
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @author Tobias Bönner <tobi@boenner.family>
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
|
||||
class SerializedPath
|
||||
{
|
||||
public readonly PropertyPath $serializedPath;
|
||||
|
||||
/**
|
||||
* @param string $serializedPath A path using a valid PropertyAccess syntax where the value is stored in a normalized representation
|
||||
*/
|
||||
public function __construct(string $serializedPath)
|
||||
{
|
||||
try {
|
||||
$this->serializedPath = new PropertyPath($serializedPath);
|
||||
} catch (InvalidPropertyPathException) {
|
||||
throw new InvalidArgumentException(\sprintf('Parameter given to "%s" must be a valid property path.', self::class));
|
||||
}
|
||||
}
|
||||
|
||||
#[\Deprecated('Use the "serializedPath" property instead', 'symfony/serializer:7.4')]
|
||||
public function getSerializedPath(): PropertyPath
|
||||
{
|
||||
return $this->serializedPath;
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists(\Symfony\Component\Serializer\Annotation\SerializedPath::class, false)) {
|
||||
class_alias(SerializedPath::class, \Symfony\Component\Serializer\Annotation\SerializedPath::class);
|
||||
}
|
||||
384
backend/vendor/symfony/serializer/CHANGELOG.md
vendored
Normal file
384
backend/vendor/symfony/serializer/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,384 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
7.4
|
||||
---
|
||||
|
||||
* Add `#[ExtendsSerializationFor]` to declare new serialization attributes for a class
|
||||
* Add `AttributeMetadataPass` to declare compile-time constraint metadata using attributes
|
||||
* Add `CDATA_WRAPPING_NAME_PATTERN` support to `XmlEncoder`
|
||||
* Add support for `can*()` methods to `AttributeLoader`
|
||||
* Make `AttributeMetadata` and `ClassMetadata` final
|
||||
* Add `XmlEncoder::PRESERVE_NUMERIC_KEYS` context option
|
||||
* Deprecate class aliases in the `Annotation` namespace, use attributes instead
|
||||
* Deprecate getters in attribute classes in favor of public properties
|
||||
* Deprecate `ClassMetadataFactoryCompiler`
|
||||
* Add `FORCE_TIMEZONE_KEY` to `DateTimeNormalizer` to force the timezone during denormalization
|
||||
|
||||
7.3
|
||||
---
|
||||
|
||||
* Deprecate the `CompiledClassMetadataFactory` and `CompiledClassMetadataCacheWarmer` classes
|
||||
* Register `NormalizerInterface` and `DenormalizerInterface` aliases for named serializers
|
||||
* Add `NumberNormalizer` to normalize `BcMath\Number` and `GMP` as `string`
|
||||
* Add `defaultType` to `DiscriminatorMap`
|
||||
|
||||
7.2
|
||||
---
|
||||
|
||||
* Deprecate the `csv_escape_char` context option of `CsvEncoder` and the `CsvEncoder::ESCAPE_CHAR_KEY` constant
|
||||
* Deprecate `CsvEncoderContextBuilder::withEscapeChar()` method
|
||||
* Add `SnakeCaseToCamelCaseNameConverter`
|
||||
* Support subclasses of `\DateTime` and `\DateTimeImmutable` for denormalization
|
||||
* Add the `UidNormalizer::NORMALIZATION_FORMAT_RFC9562` constant
|
||||
* Add support for configuring multiple serializer instances with different
|
||||
default contexts, name converters, sets of normalizers and encoders
|
||||
* Add support for collection profiles of multiple serializer instances
|
||||
* Deprecate `AdvancedNameConverterInterface`, use `NameConverterInterface` instead
|
||||
|
||||
7.1
|
||||
---
|
||||
|
||||
* Add arguments `$class`, `$format` and `$context` to `NameConverterInterface::normalize()` and `NameConverterInterface::denormalize()`
|
||||
* Add `DateTimeNormalizer::CAST_KEY` context option
|
||||
* Add `Default` and "class name" default groups
|
||||
* Add `AbstractNormalizer::FILTER_BOOL` context option
|
||||
* Add `CamelCaseToSnakeCaseNameConverter::REQUIRE_SNAKE_CASE_PROPERTIES` context option
|
||||
* Deprecate `AbstractNormalizerContextBuilder::withDefaultContructorArguments(?array $defaultContructorArguments)`, use `withDefaultConstructorArguments(?array $defaultConstructorArguments)` instead (note the missing `s` character in Constructor word in deprecated method)
|
||||
* Add `XmlEncoder::CDATA_WRAPPING_PATTERN` context option
|
||||
|
||||
7.0
|
||||
---
|
||||
|
||||
* Add method `getSupportedTypes()` to `DenormalizerInterface` and `NormalizerInterface`
|
||||
* Remove denormalization support for `AbstractUid` in `UidNormalizer`, use one of `AbstractUid` child class instead
|
||||
* Denormalizing to an abstract class in `UidNormalizer` now throws an `\Error`
|
||||
* Remove `ContextAwareDenormalizerInterface`, use `DenormalizerInterface` instead
|
||||
* Remove `ContextAwareNormalizerInterface`, use `NormalizerInterface` instead
|
||||
* Remove `CacheableSupportsMethodInterface`, use `NormalizerInterface` and `DenormalizerInterface` instead
|
||||
* Require explicit argument when calling `AttributeMetadata::setSerializedName()` and `ClassMetadata::setClassDiscriminatorMapping()`
|
||||
* Add argument `$context` to `NormalizerInterface::supportsNormalization()` and `DenormalizerInterface::supportsDenormalization()`
|
||||
* Remove Doctrine annotations support in favor of native attributes
|
||||
* Remove `AnnotationLoader`, use `AttributeLoader` instead
|
||||
|
||||
6.4
|
||||
---
|
||||
|
||||
* Add `TranslatableNormalizer`
|
||||
* Allow `Context` attribute to target classes
|
||||
* Deprecate Doctrine annotations support in favor of native attributes
|
||||
* Allow the `Groups` attribute/annotation on classes
|
||||
* JsonDecode: Add `json_decode_detailed_errors` option
|
||||
* Make `ProblemNormalizer` give details about Messenger's `ValidationFailedException`
|
||||
* Add `XmlEncoder::CDATA_WRAPPING` context option
|
||||
* Deprecate `AnnotationLoader`, use `AttributeLoader` instead
|
||||
* Add aliases for all classes in the `Annotation` namespace to `Attribute`
|
||||
|
||||
6.3
|
||||
---
|
||||
|
||||
* Add `AbstractNormalizer::REQUIRE_ALL_PROPERTIES` context flag to require all properties to be listed in the input instead of falling back to null for nullable ones
|
||||
* Add `XmlEncoder::SAVE_OPTIONS` context option
|
||||
* Add `BackedEnumNormalizer::ALLOW_INVALID_VALUES` context option
|
||||
* Add `UnsupportedFormatException` which is thrown when there is no decoder for a given format
|
||||
* Add method `getSupportedTypes(?string $format)` to `NormalizerInterface` and `DenormalizerInterface`
|
||||
* Make `ProblemNormalizer` give details about `ValidationFailedException` and `PartialDenormalizationException`
|
||||
* Deprecate `CacheableSupportsMethodInterface` in favor of the new `getSupportedTypes(?string $format)` methods
|
||||
* The following Normalizer classes will become final in 7.0:
|
||||
* `ConstraintViolationListNormalizer`
|
||||
* `CustomNormalizer`
|
||||
* `DataUriNormalizer`
|
||||
* `DateIntervalNormalizer`
|
||||
* `DateTimeNormalizer`
|
||||
* `DateTimeZoneNormalizer`
|
||||
* `GetSetMethodNormalizer`
|
||||
* `JsonSerializableNormalizer`
|
||||
* `ObjectNormalizer`
|
||||
* `PropertyNormalizer`
|
||||
|
||||
6.2
|
||||
---
|
||||
|
||||
* Add support for constructor promoted properties to `Context` attribute
|
||||
* Add context option `PropertyNormalizer::NORMALIZE_VISIBILITY` with bitmask flags `PropertyNormalizer::NORMALIZE_PUBLIC`, `PropertyNormalizer::NORMALIZE_PROTECTED`, `PropertyNormalizer::NORMALIZE_PRIVATE`
|
||||
* Add method `withNormalizeVisibility` to `PropertyNormalizerContextBuilder`
|
||||
* Deprecate calling `AttributeMetadata::setSerializedName()`, `ClassMetadata::setClassDiscriminatorMapping()` without arguments
|
||||
* Change the signature of `AttributeMetadataInterface::setSerializedName()` to `setSerializedName(?string)`
|
||||
* Change the signature of `ClassMetadataInterface::setClassDiscriminatorMapping()` to `setClassDiscriminatorMapping(?ClassDiscriminatorMapping)`
|
||||
* Add option YamlEncoder::YAML_INDENTATION to YamlEncoder constructor options to configure additional indentation for each level of nesting. This allows configuring indentation in the service configuration.
|
||||
* Add `SerializedPath` annotation to flatten nested attributes
|
||||
|
||||
6.1
|
||||
---
|
||||
|
||||
* Add `TraceableSerializer`, `TraceableNormalizer`, `TraceableEncoder` and `SerializerDataCollector` to integrate with the web profiler
|
||||
* Add the ability to create contexts using context builders
|
||||
* Set `Context` annotation as not final
|
||||
* Deprecate `ContextAwareNormalizerInterface`, use `NormalizerInterface` instead
|
||||
* Deprecate `ContextAwareDenormalizerInterface`, use `DenormalizerInterface` instead
|
||||
* Deprecate supporting denormalization for `AbstractUid` in `UidNormalizer`, use one of `AbstractUid` child class instead
|
||||
* Deprecate denormalizing to an abstract class in `UidNormalizer`
|
||||
* Add support for `can*()` methods to `ObjectNormalizer`
|
||||
|
||||
6.0
|
||||
---
|
||||
|
||||
* Remove `ArrayDenormalizer::setSerializer()`, call `setDenormalizer()` instead
|
||||
* Remove the ability to create instances of the annotation classes by passing an array of parameters, use named arguments instead
|
||||
|
||||
5.4
|
||||
---
|
||||
|
||||
* Add support of PHP backed enumerations
|
||||
* Add support for serializing empty array as object
|
||||
* Return empty collections as `ArrayObject` from `Serializer::normalize()` when `PRESERVE_EMPTY_OBJECTS` is set
|
||||
* Add support for collecting type errors during denormalization
|
||||
* Add missing arguments in `MissingConstructorArgumentsException`
|
||||
|
||||
5.3
|
||||
---
|
||||
|
||||
* Add the ability to provide (de)normalization context using metadata (e.g. `@Symfony\Component\Serializer\Annotation\Context`)
|
||||
* Deprecate `ArrayDenormalizer::setSerializer()`, call `setDenormalizer()` instead
|
||||
* Add normalization formats to `UidNormalizer`
|
||||
* Add `CsvEncoder::END_OF_LINE` context option
|
||||
* Deprecate creating instances of the annotation classes by passing an array of parameters, use named arguments instead
|
||||
|
||||
5.2.0
|
||||
-----
|
||||
|
||||
* added `CompiledClassMetadataFactory` and `ClassMetadataFactoryCompiler` for faster metadata loading.
|
||||
* added `UidNormalizer`
|
||||
* added `FormErrorNormalizer`
|
||||
* added `MimeMessageNormalizer`
|
||||
* serializer mapping can be configured using php attributes
|
||||
|
||||
5.1.0
|
||||
-----
|
||||
|
||||
* added support for scalar values denormalization
|
||||
* added support for `\stdClass` to `ObjectNormalizer`
|
||||
* added the ability to ignore properties using metadata (e.g. `@Symfony\Component\Serializer\Annotation\Ignore`)
|
||||
* added an option to serialize constraint violations payloads (e.g. severity)
|
||||
|
||||
5.0.0
|
||||
-----
|
||||
|
||||
* throw an exception when creating a `Serializer` with normalizers which neither implement `NormalizerInterface` nor `DenormalizerInterface`
|
||||
* throw an exception when creating a `Serializer` with encoders which neither implement `EncoderInterface` nor `DecoderInterface`
|
||||
* changed the default value of the `CsvEncoder` "as_collection" option to `true`
|
||||
* removed `AbstractNormalizer::$circularReferenceLimit`, `AbstractNormalizer::$circularReferenceHandler`,
|
||||
`AbstractNormalizer::$callbacks`, `AbstractNormalizer::$ignoredAttributes`,
|
||||
`AbstractNormalizer::$camelizedAttributes`, `AbstractNormalizer::setCircularReferenceLimit()`,
|
||||
`AbstractNormalizer::setCircularReferenceHandler()`, `AbstractNormalizer::setCallbacks()` and
|
||||
`AbstractNormalizer::setIgnoredAttributes()`, use the default context instead.
|
||||
* removed `AbstractObjectNormalizer::$maxDepthHandler` and `AbstractObjectNormalizer::setMaxDepthHandler()`,
|
||||
use the default context instead.
|
||||
* removed `XmlEncoder::setRootNodeName()` & `XmlEncoder::getRootNodeName()`, use the default context instead.
|
||||
* removed individual encoders/normalizers options as constructor arguments.
|
||||
* removed support for instantiating a `DataUriNormalizer` with a default MIME type guesser when the `symfony/mime` component isn't installed.
|
||||
* removed the `XmlEncoder::TYPE_CASE_ATTRIBUTES` constant. Use `XmlEncoder::TYPE_CAST_ATTRIBUTES` instead.
|
||||
|
||||
4.4.0
|
||||
-----
|
||||
|
||||
* deprecated the `XmlEncoder::TYPE_CASE_ATTRIBUTES` constant, use `XmlEncoder::TYPE_CAST_ATTRIBUTES` instead
|
||||
* added option to output a UTF-8 BOM in CSV encoder via `CsvEncoder::OUTPUT_UTF8_BOM_KEY` context option
|
||||
* added `ProblemNormalizer` to normalize errors according to the API Problem spec (RFC 7807)
|
||||
|
||||
4.3.0
|
||||
-----
|
||||
|
||||
* added the list of constraint violations' parameters in `ConstraintViolationListNormalizer`
|
||||
* added support for serializing `DateTimeZone` objects
|
||||
* added a `deep_object_to_populate` context option to recursive denormalize on `object_to_populate` object.
|
||||
|
||||
4.2.0
|
||||
-----
|
||||
|
||||
* using the default context is the new recommended way to configure normalizers and encoders
|
||||
* added a `skip_null_values` context option to not serialize properties with a `null` values
|
||||
* `AbstractNormalizer::handleCircularReference` is now final and receives
|
||||
two optional extra arguments: the format and the context
|
||||
* added support for XML comment encoding (encoding `['#comment' => ' foo ']` results `<!-- foo -->`)
|
||||
* added optional `int[] $encoderIgnoredNodeTypes` argument to `XmlEncoder::__construct`
|
||||
to configure node types to be ignored during encoding
|
||||
* added `AdvancedNameConverterInterface` to access the class,
|
||||
the format and the context in a name converter
|
||||
* the `AbstractNormalizer::handleCircularReference()` method will have two new `$format`
|
||||
and `$context` arguments in version 5.0, not defining them is deprecated
|
||||
* deprecated creating a `Serializer` with normalizers which do not implement
|
||||
either `NormalizerInterface` or `DenormalizerInterface`
|
||||
* deprecated creating a `Serializer` with normalizers which do not implement
|
||||
either `NormalizerInterface` or `DenormalizerInterface`
|
||||
* deprecated creating a `Serializer` with encoders which do not implement
|
||||
either `EncoderInterface` or `DecoderInterface`
|
||||
* added the optional `$objectClassResolver` argument in `AbstractObjectNormalizer`
|
||||
and `ObjectNormalizer` constructor
|
||||
* added `MetadataAwareNameConverter` to configure the serialized name of properties through metadata
|
||||
* `YamlEncoder` now handles the `.yml` extension too
|
||||
* `AbstractNormalizer::$circularReferenceLimit`, `AbstractNormalizer::$circularReferenceHandler`,
|
||||
`AbstractNormalizer::$callbacks`, `AbstractNormalizer::$ignoredAttributes`,
|
||||
`AbstractNormalizer::$camelizedAttributes`, `AbstractNormalizer::setCircularReferenceLimit()`,
|
||||
`AbstractNormalizer::setCircularReferenceHandler()`, `AbstractNormalizer::setCallbacks()` and
|
||||
`AbstractNormalizer::setIgnoredAttributes()` are deprecated, use the default context instead.
|
||||
* `AbstractObjectNormalizer::$maxDepthHandler` and `AbstractObjectNormalizer::setMaxDepthHandler()`
|
||||
are deprecated, use the default context instead.
|
||||
* passing configuration options directly to the constructor of `CsvEncoder`, `JsonDecode` and
|
||||
`XmlEncoder` is deprecated since Symfony 4.2, use the default context instead.
|
||||
|
||||
4.1.0
|
||||
-----
|
||||
|
||||
* added `CacheableSupportsMethodInterface` for normalizers and denormalizers that use
|
||||
only the type and the format in their `supports*()` methods
|
||||
* added `MissingConstructorArgumentsException` new exception for deserialization failure
|
||||
of objects that needs data insertion in constructor
|
||||
* added an optional `default_constructor_arguments` option of context to specify a default data in
|
||||
case the object is not initializable by its constructor because of data missing
|
||||
* added optional `bool $escapeFormulas = false` argument to `CsvEncoder::__construct`
|
||||
* added `AbstractObjectNormalizer::setMaxDepthHandler` to set a handler to call when the configured
|
||||
maximum depth is reached
|
||||
* added optional `int[] $ignoredNodeTypes` argument to `XmlEncoder::__construct`. XML decoding now
|
||||
ignores comment node types by default.
|
||||
* added `ConstraintViolationListNormalizer`
|
||||
|
||||
4.0.0
|
||||
-----
|
||||
|
||||
* removed the `SerializerAwareEncoder` and `SerializerAwareNormalizer` classes,
|
||||
use the `SerializerAwareTrait` instead
|
||||
* removed the `Serializer::$normalizerCache` and `Serializer::$denormalizerCache`
|
||||
properties
|
||||
* added an optional `string $format = null` argument to `AbstractNormalizer::instantiateObject`
|
||||
* added an optional `array $context = []` to `Serializer::supportsNormalization`, `Serializer::supportsDenormalization`,
|
||||
`Serializer::supportsEncoding` and `Serializer::supportsDecoding`
|
||||
|
||||
3.4.0
|
||||
-----
|
||||
|
||||
* added `AbstractObjectNormalizer::DISABLE_TYPE_ENFORCEMENT` context option
|
||||
to disable throwing an `UnexpectedValueException` on a type mismatch
|
||||
* added support for serializing `DateInterval` objects
|
||||
* added getter for extra attributes in `ExtraAttributesException`
|
||||
* improved `CsvEncoder` to handle variable nested structures
|
||||
* CSV headers can be passed to the `CsvEncoder` via the `csv_headers` serialization context variable
|
||||
* added `$context` when checking for encoding, decoding and normalizing in `Serializer`
|
||||
|
||||
3.3.0
|
||||
-----
|
||||
|
||||
* added `SerializerPass`
|
||||
|
||||
3.1.0
|
||||
-----
|
||||
|
||||
* added support for serializing objects that implement `JsonSerializable`
|
||||
* added the `DenormalizerAwareTrait` and `NormalizerAwareTrait` traits to
|
||||
support normalizer/denormalizer awareness
|
||||
* added the `DenormalizerAwareInterface` and `NormalizerAwareInterface`
|
||||
interfaces to support normalizer/denormalizer awareness
|
||||
* added a PSR-6 compatible adapter for caching metadata
|
||||
* added a `MaxDepth` option to limit the depth of the object graph when
|
||||
serializing objects
|
||||
* added support for serializing `SplFileInfo` objects
|
||||
* added support for serializing objects that implement `DateTimeInterface`
|
||||
* added `AbstractObjectNormalizer` as a base class for normalizers that deal
|
||||
with objects
|
||||
* added support to relation deserialization
|
||||
|
||||
2.7.0
|
||||
-----
|
||||
|
||||
* added support for serialization and deserialization groups including
|
||||
annotations, XML and YAML mapping.
|
||||
* added `AbstractNormalizer` to factorise code and ease normalizers development
|
||||
* added circular references handling for `PropertyNormalizer`
|
||||
* added support for a context key called `object_to_populate` in `AbstractNormalizer`
|
||||
to reuse existing objects in the deserialization process
|
||||
* added `NameConverterInterface` and `CamelCaseToSnakeCaseNameConverter`
|
||||
* [DEPRECATION] `GetSetMethodNormalizer::setCamelizedAttributes()` and
|
||||
`PropertyNormalizer::setCamelizedAttributes()` are replaced by
|
||||
`CamelCaseToSnakeCaseNameConverter`
|
||||
* [DEPRECATION] the `Exception` interface has been renamed to `ExceptionInterface`
|
||||
* added `ObjectNormalizer` leveraging the `PropertyAccess` component to normalize
|
||||
objects containing both properties and getters / setters / issers / hassers methods.
|
||||
* added `xml_type_cast_attributes` context option for allowing users to opt-out of typecasting
|
||||
xml attributes.
|
||||
|
||||
2.6.0
|
||||
-----
|
||||
|
||||
* added a new serializer: `PropertyNormalizer`. Like `GetSetMethodNormalizer`,
|
||||
this normalizer will map an object's properties to an array.
|
||||
* added circular references handling for `GetSetMethodNormalizer`
|
||||
|
||||
2.5.0
|
||||
-----
|
||||
|
||||
* added support for `is.*` getters in `GetSetMethodNormalizer`
|
||||
|
||||
2.4.0
|
||||
-----
|
||||
|
||||
* added `$context` support for XMLEncoder.
|
||||
* [DEPRECATION] JsonEncode and JsonDecode where modified to throw
|
||||
an exception if error found. No need for `get*Error()` functions
|
||||
|
||||
2.3.0
|
||||
-----
|
||||
|
||||
* added `GetSetMethodNormalizer::setCamelizedAttributes` to allow calling
|
||||
camel cased methods for underscored properties
|
||||
|
||||
2.2.0
|
||||
-----
|
||||
|
||||
* [BC BREAK] All Serializer, Normalizer and Encoder interfaces have been
|
||||
modified to include an optional `$context` array parameter.
|
||||
* The XML Root name can now be configured with the `xml_root_name`
|
||||
parameter in the context option to the `XmlEncoder`.
|
||||
* Options to `json_encode` and `json_decode` can be passed through
|
||||
the context options of `JsonEncode` and `JsonDecode` encoder/decoders.
|
||||
|
||||
2.1.0
|
||||
-----
|
||||
|
||||
* added DecoderInterface::supportsDecoding(),
|
||||
EncoderInterface::supportsEncoding()
|
||||
* removed NormalizableInterface::denormalize(),
|
||||
NormalizerInterface::denormalize(),
|
||||
NormalizerInterface::supportsDenormalization()
|
||||
* removed normalize() denormalize() encode() decode() supportsSerialization()
|
||||
supportsDeserialization() supportsEncoding() supportsDecoding()
|
||||
getEncoder() from SerializerInterface
|
||||
* Serializer now implements NormalizerInterface, DenormalizerInterface,
|
||||
EncoderInterface, DecoderInterface in addition to SerializerInterface
|
||||
* added DenormalizableInterface and DenormalizerInterface
|
||||
* [BC BREAK] changed `GetSetMethodNormalizer`'s key names from all lowercased
|
||||
to camelCased (e.g. `mypropertyvalue` to `myPropertyValue`)
|
||||
* [BC BREAK] convert the `item` XML tag to an array
|
||||
|
||||
``` xml
|
||||
<?xml version="1.0"?>
|
||||
<response>
|
||||
<item><title><![CDATA[title1]]></title></item><item><title><![CDATA[title2]]></title></item>
|
||||
</response>
|
||||
```
|
||||
|
||||
Before:
|
||||
|
||||
Array()
|
||||
|
||||
After:
|
||||
|
||||
Array(
|
||||
[item] => Array(
|
||||
[0] => Array(
|
||||
[title] => title1
|
||||
)
|
||||
[1] => Array(
|
||||
[title] => title2
|
||||
)
|
||||
)
|
||||
)
|
||||
55
backend/vendor/symfony/serializer/CacheWarmer/CompiledClassMetadataCacheWarmer.php
vendored
Normal file
55
backend/vendor/symfony/serializer/CacheWarmer/CompiledClassMetadataCacheWarmer.php
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\CacheWarmer;
|
||||
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
|
||||
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryCompiler;
|
||||
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
|
||||
|
||||
trigger_deprecation('symfony/serializer', '7.3', 'The "%s" class is deprecated.', CompiledClassMetadataCacheWarmer::class);
|
||||
|
||||
/**
|
||||
* @author Fabien Bourigault <bourigaultfabien@gmail.com>
|
||||
*
|
||||
* @deprecated since Symfony 7.3
|
||||
*/
|
||||
final class CompiledClassMetadataCacheWarmer implements CacheWarmerInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly array $classesToCompile,
|
||||
private readonly ClassMetadataFactoryInterface $classMetadataFactory,
|
||||
private readonly ClassMetadataFactoryCompiler $classMetadataFactoryCompiler,
|
||||
private readonly Filesystem $filesystem,
|
||||
) {
|
||||
}
|
||||
|
||||
public function warmUp(string $cacheDir, ?string $buildDir = null): array
|
||||
{
|
||||
$metadatas = [];
|
||||
|
||||
foreach ($this->classesToCompile as $classToCompile) {
|
||||
$metadatas[] = $this->classMetadataFactory->getMetadataFor($classToCompile);
|
||||
}
|
||||
|
||||
$code = $this->classMetadataFactoryCompiler->compile($metadatas);
|
||||
|
||||
$this->filesystem->dumpFile("{$cacheDir}/serializer.class.metadata.php", $code);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function isOptional(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
120
backend/vendor/symfony/serializer/Command/DebugCommand.php
vendored
Normal file
120
backend/vendor/symfony/serializer/Command/DebugCommand.php
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Command;
|
||||
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Helper\Dumper;
|
||||
use Symfony\Component\Console\Helper\Table;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Serializer\Mapping\ClassMetadataInterface;
|
||||
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
|
||||
|
||||
/**
|
||||
* A console command to debug Serializer information.
|
||||
*
|
||||
* @author Loïc Frémont <lc.fremont@gmail.com>
|
||||
*/
|
||||
#[AsCommand(name: 'debug:serializer', description: 'Display serialization information for classes')]
|
||||
class DebugCommand extends Command
|
||||
{
|
||||
public function __construct(private readonly ClassMetadataFactoryInterface $serializer)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
$this
|
||||
->addArgument('class', InputArgument::REQUIRED, 'A fully qualified class name')
|
||||
->setHelp("The <info>%command.name% 'App\Entity\Dummy'</info> command dumps the serializer groups for the dummy class.")
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$class = $input->getArgument('class');
|
||||
|
||||
if (!class_exists($class)) {
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$io->error(\sprintf('Class "%s" was not found.', $class));
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$this->dumpSerializerDataForClass($input, $output, $class);
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
private function dumpSerializerDataForClass(InputInterface $input, OutputInterface $output, string $class): void
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$title = \sprintf('<info>%s</info>', $class);
|
||||
$rows = [];
|
||||
$dump = new Dumper($output);
|
||||
|
||||
$classMetadata = $this->serializer->getMetadataFor($class);
|
||||
|
||||
foreach ($this->getAttributesData($classMetadata) as $propertyName => $data) {
|
||||
$rows[] = [
|
||||
$propertyName,
|
||||
$dump($data),
|
||||
];
|
||||
}
|
||||
|
||||
$io->section($title);
|
||||
|
||||
if (!$rows) {
|
||||
$io->text('No Serializer data were found for this class.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$table = new Table($output);
|
||||
$table->setHeaders(['Property', 'Options']);
|
||||
$table->setRows($rows);
|
||||
$table->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<string, mixed>>
|
||||
*/
|
||||
private function getAttributesData(ClassMetadataInterface $classMetadata): array
|
||||
{
|
||||
$data = [];
|
||||
|
||||
$mapping = $classMetadata->getClassDiscriminatorMapping();
|
||||
$typeProperty = $mapping?->getTypeProperty();
|
||||
|
||||
foreach ($classMetadata->getAttributesMetadata() as $attributeMetadata) {
|
||||
$data[$attributeMetadata->getName()] = [
|
||||
'groups' => $attributeMetadata->getGroups(),
|
||||
'maxDepth' => $attributeMetadata->getMaxDepth(),
|
||||
'serializedName' => $attributeMetadata->getSerializedName(),
|
||||
'serializedPath' => $attributeMetadata->getSerializedPath() ? (string) $attributeMetadata->getSerializedPath() : null,
|
||||
'ignore' => $attributeMetadata->isIgnored(),
|
||||
'normalizationContexts' => $attributeMetadata->getNormalizationContexts(),
|
||||
'denormalizationContexts' => $attributeMetadata->getDenormalizationContexts(),
|
||||
];
|
||||
|
||||
if ($mapping && $typeProperty === $attributeMetadata->getName()) {
|
||||
$data[$attributeMetadata->getName()]['discriminatorMap'] = $mapping->getTypesMapping();
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
31
backend/vendor/symfony/serializer/Context/ContextBuilderInterface.php
vendored
Normal file
31
backend/vendor/symfony/serializer/Context/ContextBuilderInterface.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Context;
|
||||
|
||||
/**
|
||||
* Common interface for context builders.
|
||||
*
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
* @author Robin Chalas <robin.chalas@gmail.com>
|
||||
*/
|
||||
interface ContextBuilderInterface
|
||||
{
|
||||
/**
|
||||
* @param self|array<string, mixed> $context
|
||||
*/
|
||||
public function withContext(self|array $context): static;
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(): array;
|
||||
}
|
||||
54
backend/vendor/symfony/serializer/Context/ContextBuilderTrait.php
vendored
Normal file
54
backend/vendor/symfony/serializer/Context/ContextBuilderTrait.php
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Context;
|
||||
|
||||
/**
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*/
|
||||
trait ContextBuilderTrait
|
||||
{
|
||||
/**
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
private array $context = [];
|
||||
|
||||
protected function with(string $key, mixed $value): static
|
||||
{
|
||||
$instance = new static();
|
||||
$instance->context = array_merge($this->context, [$key => $value]);
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContextBuilderInterface|array<string, mixed> $context
|
||||
*/
|
||||
public function withContext(ContextBuilderInterface|array $context): static
|
||||
{
|
||||
if ($context instanceof ContextBuilderInterface) {
|
||||
$context = $context->toArray();
|
||||
}
|
||||
|
||||
$instance = new static();
|
||||
$instance->context = array_merge($this->context, $context);
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return $this->context;
|
||||
}
|
||||
}
|
||||
139
backend/vendor/symfony/serializer/Context/Encoder/CsvEncoderContextBuilder.php
vendored
Normal file
139
backend/vendor/symfony/serializer/Context/Encoder/CsvEncoderContextBuilder.php
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Context\Encoder;
|
||||
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderInterface;
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderTrait;
|
||||
use Symfony\Component\Serializer\Encoder\CsvEncoder;
|
||||
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* A helper providing autocompletion for available CsvEncoder options.
|
||||
*
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*/
|
||||
final class CsvEncoderContextBuilder implements ContextBuilderInterface
|
||||
{
|
||||
use ContextBuilderTrait;
|
||||
|
||||
/**
|
||||
* Configures the column delimiter character.
|
||||
*
|
||||
* Must be a single character.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function withDelimiter(?string $delimiter): static
|
||||
{
|
||||
if (null !== $delimiter && 1 !== \strlen($delimiter)) {
|
||||
throw new InvalidArgumentException(\sprintf('The "%s" delimiter must be a single character.', $delimiter));
|
||||
}
|
||||
|
||||
return $this->with(CsvEncoder::DELIMITER_KEY, $delimiter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the field enclosure character.
|
||||
*
|
||||
* Must be a single character.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function withEnclosure(?string $enclosure): static
|
||||
{
|
||||
if (null !== $enclosure && 1 !== \strlen($enclosure)) {
|
||||
throw new InvalidArgumentException(\sprintf('The "%s" enclosure must be a single character.', $enclosure));
|
||||
}
|
||||
|
||||
return $this->with(CsvEncoder::ENCLOSURE_KEY, $enclosure);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the escape character.
|
||||
*
|
||||
* Must be empty or a single character.
|
||||
*
|
||||
* @deprecated since Symfony 7.2, to be removed in 8.0
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function withEscapeChar(?string $escapeChar): static
|
||||
{
|
||||
trigger_deprecation('symfony/serializer', '7.2', 'The "%s" method is deprecated. It will be removed in 8.0.', __METHOD__);
|
||||
|
||||
if (null !== $escapeChar && \strlen($escapeChar) > 1) {
|
||||
throw new InvalidArgumentException(\sprintf('The "%s" escape character must be empty or a single character.', $escapeChar));
|
||||
}
|
||||
|
||||
return $this->with(CsvEncoder::ESCAPE_CHAR_KEY, $escapeChar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the key separator when (un)flattening arrays.
|
||||
*/
|
||||
public function withKeySeparator(?string $keySeparator): static
|
||||
{
|
||||
return $this->with(CsvEncoder::KEY_SEPARATOR_KEY, $keySeparator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the headers.
|
||||
*
|
||||
* @param list<mixed>|null $headers
|
||||
*/
|
||||
public function withHeaders(?array $headers): static
|
||||
{
|
||||
return $this->with(CsvEncoder::HEADERS_KEY, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures whether formulas should be escaped.
|
||||
*/
|
||||
public function withEscapedFormulas(?bool $escapedFormulas): static
|
||||
{
|
||||
return $this->with(CsvEncoder::ESCAPE_FORMULAS_KEY, $escapedFormulas);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures whether the decoded result should be considered as a collection
|
||||
* or as a single element.
|
||||
*/
|
||||
public function withAsCollection(?bool $asCollection): static
|
||||
{
|
||||
return $this->with(CsvEncoder::AS_COLLECTION_KEY, $asCollection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures whether the input (or output) is containing (or will contain) headers.
|
||||
*/
|
||||
public function withNoHeaders(?bool $noHeaders): static
|
||||
{
|
||||
return $this->with(CsvEncoder::NO_HEADERS_KEY, $noHeaders);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the end of line characters.
|
||||
*/
|
||||
public function withEndOfLine(?string $endOfLine): static
|
||||
{
|
||||
return $this->with(CsvEncoder::END_OF_LINE, $endOfLine);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures whether to add the UTF-8 Byte Order Mark (BOM)
|
||||
* at the beginning of the encoded result or not.
|
||||
*/
|
||||
public function withOutputUtf8Bom(?bool $outputUtf8Bom): static
|
||||
{
|
||||
return $this->with(CsvEncoder::OUTPUT_UTF8_BOM_KEY, $outputUtf8Bom);
|
||||
}
|
||||
}
|
||||
72
backend/vendor/symfony/serializer/Context/Encoder/JsonEncoderContextBuilder.php
vendored
Normal file
72
backend/vendor/symfony/serializer/Context/Encoder/JsonEncoderContextBuilder.php
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Context\Encoder;
|
||||
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderInterface;
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderTrait;
|
||||
use Symfony\Component\Serializer\Encoder\JsonDecode;
|
||||
use Symfony\Component\Serializer\Encoder\JsonEncode;
|
||||
|
||||
/**
|
||||
* A helper providing autocompletion for available JsonEncoder options.
|
||||
*
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*/
|
||||
final class JsonEncoderContextBuilder implements ContextBuilderInterface
|
||||
{
|
||||
use ContextBuilderTrait;
|
||||
|
||||
/**
|
||||
* Configures the json_encode flags bitmask.
|
||||
*
|
||||
* @see https://php.net/json.constants
|
||||
*
|
||||
* @param positive-int|null $options
|
||||
*/
|
||||
public function withEncodeOptions(?int $options): static
|
||||
{
|
||||
return $this->with(JsonEncode::OPTIONS, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the json_decode flags bitmask.
|
||||
*
|
||||
* @see https://php.net/json.constants
|
||||
*
|
||||
* @param positive-int|null $options
|
||||
*/
|
||||
public function withDecodeOptions(?int $options): static
|
||||
{
|
||||
return $this->with(JsonDecode::OPTIONS, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures whether decoded objects will be given as
|
||||
* associative arrays or as nested stdClass.
|
||||
*/
|
||||
public function withAssociative(?bool $associative): static
|
||||
{
|
||||
return $this->with(JsonDecode::ASSOCIATIVE, $associative);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the maximum recursion depth.
|
||||
*
|
||||
* Must be strictly positive.
|
||||
*
|
||||
* @param positive-int|null $recursionDepth
|
||||
*/
|
||||
public function withRecursionDepth(?int $recursionDepth): static
|
||||
{
|
||||
return $this->with(JsonDecode::RECURSION_DEPTH, $recursionDepth);
|
||||
}
|
||||
}
|
||||
179
backend/vendor/symfony/serializer/Context/Encoder/XmlEncoderContextBuilder.php
vendored
Normal file
179
backend/vendor/symfony/serializer/Context/Encoder/XmlEncoderContextBuilder.php
vendored
Normal file
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Context\Encoder;
|
||||
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderInterface;
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderTrait;
|
||||
use Symfony\Component\Serializer\Encoder\XmlEncoder;
|
||||
|
||||
/**
|
||||
* A helper providing autocompletion for available XmlEncoder options.
|
||||
*
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*/
|
||||
final class XmlEncoderContextBuilder implements ContextBuilderInterface
|
||||
{
|
||||
use ContextBuilderTrait;
|
||||
|
||||
/**
|
||||
* Configures whether the decoded result should be considered as a collection
|
||||
* or as a single element.
|
||||
*/
|
||||
public function withAsCollection(?bool $asCollection): static
|
||||
{
|
||||
return $this->with(XmlEncoder::AS_COLLECTION, $asCollection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures node types to ignore while decoding.
|
||||
*
|
||||
* @see https://php.net/dom.constants
|
||||
*
|
||||
* @param list<int>|null $decoderIgnoredNodeTypes
|
||||
*/
|
||||
public function withDecoderIgnoredNodeTypes(?array $decoderIgnoredNodeTypes): static
|
||||
{
|
||||
return $this->with(XmlEncoder::DECODER_IGNORED_NODE_TYPES, $decoderIgnoredNodeTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures node types to ignore while encoding.
|
||||
*
|
||||
* @see https://php.net/dom.constants
|
||||
*
|
||||
* @param list<int>|null $encoderIgnoredNodeTypes
|
||||
*/
|
||||
public function withEncoderIgnoredNodeTypes(?array $encoderIgnoredNodeTypes): static
|
||||
{
|
||||
return $this->with(XmlEncoder::ENCODER_IGNORED_NODE_TYPES, $encoderIgnoredNodeTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the DOMDocument encoding.
|
||||
*
|
||||
* @see https://php.net/class.domdocument#domdocument.props.encoding
|
||||
*/
|
||||
public function withEncoding(?string $encoding): static
|
||||
{
|
||||
return $this->with(XmlEncoder::ENCODING, $encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures whether to encode with indentation and extra space.
|
||||
*
|
||||
* @see https://php.net/class.domdocument#domdocument.props.formatoutput
|
||||
*/
|
||||
public function withFormatOutput(?bool $formatOutput): static
|
||||
{
|
||||
return $this->with(XmlEncoder::FORMAT_OUTPUT, $formatOutput);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the DOMDocument::loadXml options bitmask.
|
||||
*
|
||||
* @see https://php.net/libxml.constants
|
||||
*
|
||||
* @param positive-int|null $loadOptions
|
||||
*/
|
||||
public function withLoadOptions(?int $loadOptions): static
|
||||
{
|
||||
return $this->with(XmlEncoder::LOAD_OPTIONS, $loadOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the DOMDocument::saveXml options bitmask.
|
||||
*
|
||||
* @see https://php.net/libxml.constants
|
||||
*
|
||||
* @param positive-int|null $saveOptions
|
||||
*/
|
||||
public function withSaveOptions(?int $saveOptions): static
|
||||
{
|
||||
return $this->with(XmlEncoder::SAVE_OPTIONS, $saveOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures whether to keep empty nodes.
|
||||
*/
|
||||
public function withRemoveEmptyTags(?bool $removeEmptyTags): static
|
||||
{
|
||||
return $this->with(XmlEncoder::REMOVE_EMPTY_TAGS, $removeEmptyTags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures name of the root node.
|
||||
*/
|
||||
public function withRootNodeName(?string $rootNodeName): static
|
||||
{
|
||||
return $this->with(XmlEncoder::ROOT_NODE_NAME, $rootNodeName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures whether the document will be standalone.
|
||||
*
|
||||
* @see https://php.net/class.domdocument#domdocument.props.xmlstandalone
|
||||
*/
|
||||
public function withStandalone(?bool $standalone): static
|
||||
{
|
||||
return $this->with(XmlEncoder::STANDALONE, $standalone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures whether casting numeric string attributes to integers or floats.
|
||||
*/
|
||||
public function withTypeCastAttributes(?bool $typeCastAttributes): static
|
||||
{
|
||||
return $this->with(XmlEncoder::TYPE_CAST_ATTRIBUTES, $typeCastAttributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the version number of the document.
|
||||
*
|
||||
* @see https://php.net/class.domdocument#domdocument.props.xmlversion
|
||||
*/
|
||||
public function withVersion(?string $version): static
|
||||
{
|
||||
return $this->with(XmlEncoder::VERSION, $version);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures whether to wrap strings within CDATA sections.
|
||||
*/
|
||||
public function withCdataWrapping(?bool $cdataWrapping): static
|
||||
{
|
||||
return $this->with(XmlEncoder::CDATA_WRAPPING, $cdataWrapping);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the pattern used to evaluate if a CDATA section should be added.
|
||||
*/
|
||||
public function withCdataWrappingPattern(?string $cdataWrappingPattern): static
|
||||
{
|
||||
return $this->with(XmlEncoder::CDATA_WRAPPING_PATTERN, $cdataWrappingPattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures whether to ignore empty attributes.
|
||||
*/
|
||||
public function withIgnoreEmptyAttributes(?bool $ignoreEmptyAttributes): static
|
||||
{
|
||||
return $this->with(XmlEncoder::IGNORE_EMPTY_ATTRIBUTES, $ignoreEmptyAttributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures whether to preserve numeric keys in array.
|
||||
*/
|
||||
public function withPreserveNumericKeys(?bool $preserveNumericKeys): static
|
||||
{
|
||||
return $this->with(XmlEncoder::PRESERVE_NUMERIC_KEYS, $preserveNumericKeys);
|
||||
}
|
||||
}
|
||||
69
backend/vendor/symfony/serializer/Context/Encoder/YamlEncoderContextBuilder.php
vendored
Normal file
69
backend/vendor/symfony/serializer/Context/Encoder/YamlEncoderContextBuilder.php
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Context\Encoder;
|
||||
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderInterface;
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderTrait;
|
||||
use Symfony\Component\Serializer\Encoder\YamlEncoder;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
/**
|
||||
* A helper providing autocompletion for available YamlEncoder options.
|
||||
*
|
||||
* Note that the "indentation" setting is not offered in this builder because
|
||||
* it can only be set during the construction of the YamlEncoder, but not per
|
||||
* call.
|
||||
*
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*/
|
||||
final class YamlEncoderContextBuilder implements ContextBuilderInterface
|
||||
{
|
||||
use ContextBuilderTrait;
|
||||
|
||||
/**
|
||||
* Configures the threshold to switch to inline YAML.
|
||||
*/
|
||||
public function withInlineThreshold(?int $inlineThreshold): static
|
||||
{
|
||||
return $this->with(YamlEncoder::YAML_INLINE, $inlineThreshold);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the indentation level.
|
||||
*
|
||||
* Must be positive.
|
||||
*
|
||||
* @param int<0, max>|null $indentLevel
|
||||
*/
|
||||
public function withIndentLevel(?int $indentLevel): static
|
||||
{
|
||||
return $this->with(YamlEncoder::YAML_INDENT, $indentLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures \Symfony\Component\Yaml\Dumper::dump flags bitmask.
|
||||
*
|
||||
* @see Yaml
|
||||
*/
|
||||
public function withFlags(?int $flags): static
|
||||
{
|
||||
return $this->with(YamlEncoder::YAML_FLAGS, $flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures whether to preserve empty objects "{}" or to convert them to null.
|
||||
*/
|
||||
public function withPreservedEmptyObjects(?bool $preserveEmptyObjects): static
|
||||
{
|
||||
return $this->with(YamlEncoder::PRESERVE_EMPTY_OBJECTS, $preserveEmptyObjects);
|
||||
}
|
||||
}
|
||||
188
backend/vendor/symfony/serializer/Context/Normalizer/AbstractNormalizerContextBuilder.php
vendored
Normal file
188
backend/vendor/symfony/serializer/Context/Normalizer/AbstractNormalizerContextBuilder.php
vendored
Normal file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Context\Normalizer;
|
||||
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderInterface;
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderTrait;
|
||||
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
|
||||
/**
|
||||
* A helper providing autocompletion for available AbstractNormalizer options.
|
||||
*
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*/
|
||||
abstract class AbstractNormalizerContextBuilder implements ContextBuilderInterface
|
||||
{
|
||||
use ContextBuilderTrait;
|
||||
|
||||
/**
|
||||
* Configures how many loops of circular reference to allow while normalizing.
|
||||
*
|
||||
* The value 1 means that when we encounter the same object a
|
||||
* second time, we consider that a circular reference.
|
||||
*
|
||||
* You can raise this value for special cases, e.g. in combination with the
|
||||
* max depth setting of the object normalizer.
|
||||
*
|
||||
* Must be strictly positive.
|
||||
*
|
||||
* @param positive-int|null $circularReferenceLimit
|
||||
*/
|
||||
public function withCircularReferenceLimit(?int $circularReferenceLimit): static
|
||||
{
|
||||
return $this->with(AbstractNormalizer::CIRCULAR_REFERENCE_LIMIT, $circularReferenceLimit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures an object to be updated instead of creating a new instance.
|
||||
*
|
||||
* If you have a nested structure, child objects will be overwritten with
|
||||
* new instances unless you set AbstractObjectNormalizer::DEEP_OBJECT_TO_POPULATE to true.
|
||||
*/
|
||||
public function withObjectToPopulate(?object $objectToPopulate): static
|
||||
{
|
||||
return $this->with(AbstractNormalizer::OBJECT_TO_POPULATE, $objectToPopulate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures groups containing attributes to (de)normalize.
|
||||
*
|
||||
* Eg: ['group1', 'group2']
|
||||
*
|
||||
* @param list<string>|string|null $groups
|
||||
*/
|
||||
public function withGroups(array|string|null $groups): static
|
||||
{
|
||||
if (null === $groups) {
|
||||
return $this->with(AbstractNormalizer::GROUPS, null);
|
||||
}
|
||||
|
||||
return $this->with(AbstractNormalizer::GROUPS, (array) $groups);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures attributes to (de)normalize.
|
||||
*
|
||||
* For nested structures, this list needs to reflect the object tree.
|
||||
*
|
||||
* Eg: ['foo', 'bar', 'object' => ['baz']]
|
||||
*
|
||||
* @param array<string|array>|null $attributes
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function withAttributes(?array $attributes): static
|
||||
{
|
||||
$it = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($attributes ?? []), \RecursiveIteratorIterator::LEAVES_ONLY);
|
||||
|
||||
foreach ($it as $attribute) {
|
||||
if (!\is_string($attribute)) {
|
||||
throw new InvalidArgumentException(\sprintf('Each attribute must be a string, "%s" given.', get_debug_type($attribute)));
|
||||
}
|
||||
}
|
||||
|
||||
return $this->with(AbstractNormalizer::ATTRIBUTES, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* If AbstractNormalizer::ATTRIBUTES are specified, and the source has fields that are not part of that list,
|
||||
* configures whether to ignore those attributes or throw an ExtraAttributesException.
|
||||
*/
|
||||
public function withAllowExtraAttributes(?bool $allowExtraAttributes): static
|
||||
{
|
||||
return $this->with(AbstractNormalizer::ALLOW_EXTRA_ATTRIBUTES, $allowExtraAttributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 7.1, use withDefaultConstructorArguments(?array $defaultConstructorArguments)" instead
|
||||
*
|
||||
* @param array<class-string, array<string, mixed>>|null $defaultContructorArguments
|
||||
*/
|
||||
public function withDefaultContructorArguments(?array $defaultContructorArguments): static
|
||||
{
|
||||
trigger_deprecation('symfony/serializer', '7.1', 'The "%s()" method is deprecated, use "withDefaultConstructorArguments(?array $defaultConstructorArguments)" instead.', __METHOD__);
|
||||
|
||||
return self::withDefaultConstructorArguments($defaultContructorArguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures a hashmap of classes containing hashmaps of constructor argument => default value.
|
||||
*
|
||||
* The names need to match the parameter names in the constructor arguments.
|
||||
*
|
||||
* Eg: [Foo::class => ['foo' => true, 'bar' => 0]]
|
||||
*
|
||||
* @param array<class-string, array<string, mixed>>|null $defaultConstructorArguments
|
||||
*/
|
||||
public function withDefaultConstructorArguments(?array $defaultConstructorArguments): static
|
||||
{
|
||||
return $this->with(AbstractNormalizer::DEFAULT_CONSTRUCTOR_ARGUMENTS, $defaultConstructorArguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures an hashmap of field name => callable to normalize this field.
|
||||
*
|
||||
* The callable is called if the field is encountered with the arguments:
|
||||
*
|
||||
* - mixed $attributeValue value of this field
|
||||
* - object $object the whole object being normalized
|
||||
* - string $attributeName name of the attribute being normalized
|
||||
* - string $format the requested format
|
||||
* - array<string, mixed> $context the serialization context
|
||||
*
|
||||
* @param array<string, callable>|null $callbacks
|
||||
*/
|
||||
public function withCallbacks(?array $callbacks): static
|
||||
{
|
||||
return $this->with(AbstractNormalizer::CALLBACKS, $callbacks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures an handler to call when a circular reference has been detected.
|
||||
*
|
||||
* If no handler is specified, a CircularReferenceException is thrown.
|
||||
*
|
||||
* The method will be called with ($object, $format, $context) and its
|
||||
* return value is returned as the result of the normalize call.
|
||||
*/
|
||||
public function withCircularReferenceHandler(?callable $circularReferenceHandler): static
|
||||
{
|
||||
return $this->with(AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER, $circularReferenceHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures attributes to be skipped when normalizing an object tree.
|
||||
*
|
||||
* This list is applied to each element of nested structures.
|
||||
*
|
||||
* Eg: ['foo', 'bar']
|
||||
*
|
||||
* Note: The behaviour for nested structures is different from ATTRIBUTES
|
||||
* for historical reason. Aligning the behaviour would be a BC break.
|
||||
*
|
||||
* @param list<string>|null $ignoredAttributes
|
||||
*/
|
||||
public function withIgnoredAttributes(?array $ignoredAttributes): static
|
||||
{
|
||||
return $this->with(AbstractNormalizer::IGNORED_ATTRIBUTES, $ignoredAttributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures requiring all properties to be listed in the input instead
|
||||
* of falling back to null for nullable ones.
|
||||
*/
|
||||
public function withRequireAllProperties(?bool $requireAllProperties = true): static
|
||||
{
|
||||
return $this->with(AbstractNormalizer::REQUIRE_ALL_PROPERTIES, $requireAllProperties);
|
||||
}
|
||||
}
|
||||
131
backend/vendor/symfony/serializer/Context/Normalizer/AbstractObjectNormalizerContextBuilder.php
vendored
Normal file
131
backend/vendor/symfony/serializer/Context/Normalizer/AbstractObjectNormalizerContextBuilder.php
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Context\Normalizer;
|
||||
|
||||
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
|
||||
|
||||
/**
|
||||
* A helper providing autocompletion for available AbstractObjectNormalizer options.
|
||||
*
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*/
|
||||
abstract class AbstractObjectNormalizerContextBuilder extends AbstractNormalizerContextBuilder
|
||||
{
|
||||
/**
|
||||
* Configures whether to respect the max depth metadata on fields.
|
||||
*/
|
||||
public function withEnableMaxDepth(?bool $enableMaxDepth): static
|
||||
{
|
||||
return $this->with(AbstractObjectNormalizer::ENABLE_MAX_DEPTH, $enableMaxDepth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures a pattern to keep track of the current depth.
|
||||
*
|
||||
* Must contain exactly two string placeholders.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function withDepthKeyPattern(?string $depthKeyPattern): static
|
||||
{
|
||||
if (null === $depthKeyPattern) {
|
||||
return $this->with(AbstractObjectNormalizer::DEPTH_KEY_PATTERN, null);
|
||||
}
|
||||
|
||||
// This will match every occurrences of sprintf specifiers
|
||||
$matches = [];
|
||||
preg_match_all('/(?<!%)(?:%{2})*%(?<specifier>[a-z])/', $depthKeyPattern, $matches);
|
||||
|
||||
if (2 !== \count($matches['specifier']) || 's' !== $matches['specifier'][0] || 's' !== $matches['specifier'][1]) {
|
||||
throw new InvalidArgumentException(\sprintf('The depth key pattern "%s" is not valid. You must set exactly two string placeholders.', $depthKeyPattern));
|
||||
}
|
||||
|
||||
return $this->with(AbstractObjectNormalizer::DEPTH_KEY_PATTERN, $depthKeyPattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures whether verifying types match during denormalization.
|
||||
*/
|
||||
public function withDisableTypeEnforcement(?bool $disableTypeEnforcement): static
|
||||
{
|
||||
return $this->with(AbstractObjectNormalizer::DISABLE_TYPE_ENFORCEMENT, $disableTypeEnforcement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures whether fields with the value `null` should be output during normalization.
|
||||
*/
|
||||
public function withSkipNullValues(?bool $skipNullValues): static
|
||||
{
|
||||
return $this->with(AbstractObjectNormalizer::SKIP_NULL_VALUES, $skipNullValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures whether uninitialized typed class properties should be excluded during normalization.
|
||||
*/
|
||||
public function withSkipUninitializedValues(?bool $skipUninitializedValues): static
|
||||
{
|
||||
return $this->with(AbstractObjectNormalizer::SKIP_UNINITIALIZED_VALUES, $skipUninitializedValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures a callback to allow to set a value for an attribute when the max depth has
|
||||
* been reached.
|
||||
*
|
||||
* If no callback is given, the attribute is skipped. If a callable is
|
||||
* given, its return value is used (even if null).
|
||||
*
|
||||
* The arguments are:
|
||||
*
|
||||
* - mixed $attributeValue value of this field
|
||||
* - object $object the whole object being normalized
|
||||
* - string $attributeName name of the attribute being normalized
|
||||
* - string $format the requested format
|
||||
* - array<string, mixed> $context the serialization context
|
||||
*/
|
||||
public function withMaxDepthHandler(?callable $maxDepthHandler): static
|
||||
{
|
||||
return $this->with(AbstractObjectNormalizer::MAX_DEPTH_HANDLER, $maxDepthHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures which context key are not relevant to determine which attributes
|
||||
* of an object to (de)normalize.
|
||||
*
|
||||
* @param list<string>|null $excludeFromCacheKeys
|
||||
*/
|
||||
public function withExcludeFromCacheKeys(?array $excludeFromCacheKeys): static
|
||||
{
|
||||
return $this->with(AbstractObjectNormalizer::EXCLUDE_FROM_CACHE_KEY, $excludeFromCacheKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures whether to tell the denormalizer to also populate existing objects on
|
||||
* attributes of the main object.
|
||||
*
|
||||
* Setting this to true is only useful if you also specify the root object
|
||||
* in AbstractNormalizer::OBJECT_TO_POPULATE.
|
||||
*/
|
||||
public function withDeepObjectToPopulate(?bool $deepObjectToPopulate): static
|
||||
{
|
||||
return $this->with(AbstractObjectNormalizer::DEEP_OBJECT_TO_POPULATE, $deepObjectToPopulate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures whether an empty object should be kept as an object (in
|
||||
* JSON: {}) or converted to a list (in JSON: []).
|
||||
*/
|
||||
public function withPreserveEmptyObjects(?bool $preserveEmptyObjects): static
|
||||
{
|
||||
return $this->with(AbstractObjectNormalizer::PRESERVE_EMPTY_OBJECTS, $preserveEmptyObjects);
|
||||
}
|
||||
}
|
||||
35
backend/vendor/symfony/serializer/Context/Normalizer/BackedEnumNormalizerContextBuilder.php
vendored
Normal file
35
backend/vendor/symfony/serializer/Context/Normalizer/BackedEnumNormalizerContextBuilder.php
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Context\Normalizer;
|
||||
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderInterface;
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\BackedEnumNormalizer;
|
||||
|
||||
/**
|
||||
* A helper providing autocompletion for available BackedEnumNormalizer options.
|
||||
*
|
||||
* @author Nicolas PHILIPPE <nikophil@gmail.com>
|
||||
*/
|
||||
final class BackedEnumNormalizerContextBuilder implements ContextBuilderInterface
|
||||
{
|
||||
use ContextBuilderTrait;
|
||||
|
||||
/**
|
||||
* Configures if invalid values are allowed in denormalization.
|
||||
* They will be denormalized into `null` values.
|
||||
*/
|
||||
public function withAllowInvalidValues(bool $allowInvalidValues): static
|
||||
{
|
||||
return $this->with(BackedEnumNormalizer::ALLOW_INVALID_VALUES, $allowInvalidValues);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Context\Normalizer;
|
||||
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderInterface;
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\ConstraintViolationListNormalizer;
|
||||
|
||||
/**
|
||||
* A helper providing autocompletion for available ConstraintViolationList options.
|
||||
*
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*/
|
||||
final class ConstraintViolationListNormalizerContextBuilder implements ContextBuilderInterface
|
||||
{
|
||||
use ContextBuilderTrait;
|
||||
|
||||
/**
|
||||
* Configure the instance field of normalized data.
|
||||
*/
|
||||
public function withInstance(mixed $instance): static
|
||||
{
|
||||
return $this->with(ConstraintViolationListNormalizer::INSTANCE, $instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the status field of normalized data.
|
||||
*/
|
||||
public function withStatus(?int $status): static
|
||||
{
|
||||
return $this->with(ConstraintViolationListNormalizer::STATUS, $status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the title field of normalized data.
|
||||
*/
|
||||
public function withTitle(?string $title): static
|
||||
{
|
||||
return $this->with(ConstraintViolationListNormalizer::TITLE, $title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the type field of normalized data.
|
||||
*/
|
||||
public function withType(?string $type): static
|
||||
{
|
||||
return $this->with(ConstraintViolationListNormalizer::TYPE, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the payload fields which will act as an allowlist
|
||||
* for the payload field of normalized data.
|
||||
*
|
||||
* Eg: ['foo', 'bar']
|
||||
*
|
||||
* @param list<string>|null $payloadFields
|
||||
*/
|
||||
public function withPayloadFields(?array $payloadFields): static
|
||||
{
|
||||
return $this->with(ConstraintViolationListNormalizer::PAYLOAD_FIELDS, $payloadFields);
|
||||
}
|
||||
}
|
||||
36
backend/vendor/symfony/serializer/Context/Normalizer/DateIntervalNormalizerContextBuilder.php
vendored
Normal file
36
backend/vendor/symfony/serializer/Context/Normalizer/DateIntervalNormalizerContextBuilder.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Context\Normalizer;
|
||||
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderInterface;
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\DateIntervalNormalizer;
|
||||
|
||||
/**
|
||||
* A helper providing autocompletion for available DateIntervalNormalizer options.
|
||||
*
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*/
|
||||
final class DateIntervalNormalizerContextBuilder implements ContextBuilderInterface
|
||||
{
|
||||
use ContextBuilderTrait;
|
||||
|
||||
/**
|
||||
* Configures the format of the interval.
|
||||
*
|
||||
* @see https://php.net/manual/en/dateinterval.format.php
|
||||
*/
|
||||
public function withFormat(?string $format): static
|
||||
{
|
||||
return $this->with(DateIntervalNormalizer::FORMAT_KEY, $format);
|
||||
}
|
||||
}
|
||||
74
backend/vendor/symfony/serializer/Context/Normalizer/DateTimeNormalizerContextBuilder.php
vendored
Normal file
74
backend/vendor/symfony/serializer/Context/Normalizer/DateTimeNormalizerContextBuilder.php
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Context\Normalizer;
|
||||
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderInterface;
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderTrait;
|
||||
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
|
||||
|
||||
/**
|
||||
* A helper providing autocompletion for available DateTimeNormalizer options.
|
||||
*
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*/
|
||||
final class DateTimeNormalizerContextBuilder implements ContextBuilderInterface
|
||||
{
|
||||
use ContextBuilderTrait;
|
||||
|
||||
/**
|
||||
* Configures the format of the date.
|
||||
*
|
||||
* @see https://secure.php.net/manual/en/datetime.format.php
|
||||
*/
|
||||
public function withFormat(?string $format): static
|
||||
{
|
||||
return $this->with(DateTimeNormalizer::FORMAT_KEY, $format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the timezone of the date.
|
||||
*
|
||||
* It could be either a \DateTimeZone or a string
|
||||
* that will be used to construct the \DateTimeZone
|
||||
*
|
||||
* @see https://secure.php.net/manual/en/class.datetimezone.php
|
||||
*
|
||||
* @param ?bool $force Whether to enforce the timezone during denormalization
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function withTimezone(\DateTimeZone|string|null $timezone, ?bool $force = null): static
|
||||
{
|
||||
if (null === $timezone) {
|
||||
return $this->with(DateTimeNormalizer::TIMEZONE_KEY, null)->with(DateTimeNormalizer::FORCE_TIMEZONE_KEY, $force);
|
||||
}
|
||||
|
||||
if (\is_string($timezone)) {
|
||||
try {
|
||||
$timezone = new \DateTimeZone($timezone);
|
||||
} catch (\Exception $e) {
|
||||
throw new InvalidArgumentException(\sprintf('The "%s" timezone is invalid.', $timezone), previous: $e);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->with(DateTimeNormalizer::TIMEZONE_KEY, $timezone)->with(DateTimeNormalizer::FORCE_TIMEZONE_KEY, $force);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param 'int'|'float'|null $cast
|
||||
*/
|
||||
public function withCast(?string $cast): static
|
||||
{
|
||||
return $this->with(DateTimeNormalizer::CAST_KEY, $cast);
|
||||
}
|
||||
}
|
||||
50
backend/vendor/symfony/serializer/Context/Normalizer/FormErrorNormalizerContextBuilder.php
vendored
Normal file
50
backend/vendor/symfony/serializer/Context/Normalizer/FormErrorNormalizerContextBuilder.php
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Context\Normalizer;
|
||||
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderInterface;
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\FormErrorNormalizer;
|
||||
|
||||
/**
|
||||
* A helper providing autocompletion for available FormErrorNormalizer options.
|
||||
*
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*/
|
||||
final class FormErrorNormalizerContextBuilder implements ContextBuilderInterface
|
||||
{
|
||||
use ContextBuilderTrait;
|
||||
|
||||
/**
|
||||
* Configures the title of the normalized data.
|
||||
*/
|
||||
public function withTitle(?string $title): static
|
||||
{
|
||||
return $this->with(FormErrorNormalizer::TITLE, $title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the type of the normalized data.
|
||||
*/
|
||||
public function withType(?string $type): static
|
||||
{
|
||||
return $this->with(FormErrorNormalizer::TYPE, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the code of the normalized data.
|
||||
*/
|
||||
public function withStatusCode(?int $statusCode): static
|
||||
{
|
||||
return $this->with(FormErrorNormalizer::CODE, $statusCode);
|
||||
}
|
||||
}
|
||||
21
backend/vendor/symfony/serializer/Context/Normalizer/GetSetMethodNormalizerContextBuilder.php
vendored
Normal file
21
backend/vendor/symfony/serializer/Context/Normalizer/GetSetMethodNormalizerContextBuilder.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Context\Normalizer;
|
||||
|
||||
/**
|
||||
* A helper providing autocompletion for available GetSetMethodNormalizer options.
|
||||
*
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*/
|
||||
final class GetSetMethodNormalizerContextBuilder extends AbstractObjectNormalizerContextBuilder
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Context\Normalizer;
|
||||
|
||||
/**
|
||||
* A helper providing autocompletion for available JsonSerializableNormalizer options.
|
||||
*
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*/
|
||||
final class JsonSerializableNormalizerContextBuilder extends AbstractNormalizerContextBuilder
|
||||
{
|
||||
}
|
||||
21
backend/vendor/symfony/serializer/Context/Normalizer/ObjectNormalizerContextBuilder.php
vendored
Normal file
21
backend/vendor/symfony/serializer/Context/Normalizer/ObjectNormalizerContextBuilder.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Context\Normalizer;
|
||||
|
||||
/**
|
||||
* A helper providing autocompletion for available ObjectNormalizer options.
|
||||
*
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*/
|
||||
final class ObjectNormalizerContextBuilder extends AbstractObjectNormalizerContextBuilder
|
||||
{
|
||||
}
|
||||
50
backend/vendor/symfony/serializer/Context/Normalizer/ProblemNormalizerContextBuilder.php
vendored
Normal file
50
backend/vendor/symfony/serializer/Context/Normalizer/ProblemNormalizerContextBuilder.php
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Context\Normalizer;
|
||||
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderInterface;
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\ProblemNormalizer;
|
||||
|
||||
/**
|
||||
* A helper providing autocompletion for available ProblemNormalizer options.
|
||||
*
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*/
|
||||
final class ProblemNormalizerContextBuilder implements ContextBuilderInterface
|
||||
{
|
||||
use ContextBuilderTrait;
|
||||
|
||||
/**
|
||||
* Configure the title field of normalized data.
|
||||
*/
|
||||
public function withTitle(?string $title): static
|
||||
{
|
||||
return $this->with(ProblemNormalizer::TITLE, $title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the type field of normalized data.
|
||||
*/
|
||||
public function withType(?string $type): static
|
||||
{
|
||||
return $this->with(ProblemNormalizer::TYPE, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the status field of normalized data.
|
||||
*/
|
||||
public function withStatusCode(int|string|null $statusCode): static
|
||||
{
|
||||
return $this->with(ProblemNormalizer::STATUS, $statusCode);
|
||||
}
|
||||
}
|
||||
30
backend/vendor/symfony/serializer/Context/Normalizer/PropertyNormalizerContextBuilder.php
vendored
Normal file
30
backend/vendor/symfony/serializer/Context/Normalizer/PropertyNormalizerContextBuilder.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Context\Normalizer;
|
||||
|
||||
use Symfony\Component\Serializer\Normalizer\PropertyNormalizer;
|
||||
|
||||
/**
|
||||
* A helper providing autocompletion for available PropertyNormalizer options.
|
||||
*
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*/
|
||||
final class PropertyNormalizerContextBuilder extends AbstractObjectNormalizerContextBuilder
|
||||
{
|
||||
/**
|
||||
* Configures whether fields should be output based on visibility.
|
||||
*/
|
||||
public function withNormalizeVisibility(int $normalizeVisibility): static
|
||||
{
|
||||
return $this->with(PropertyNormalizer::NORMALIZE_VISIBILITY, $normalizeVisibility);
|
||||
}
|
||||
}
|
||||
41
backend/vendor/symfony/serializer/Context/Normalizer/UidNormalizerContextBuilder.php
vendored
Normal file
41
backend/vendor/symfony/serializer/Context/Normalizer/UidNormalizerContextBuilder.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Context\Normalizer;
|
||||
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderInterface;
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderTrait;
|
||||
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Serializer\Normalizer\UidNormalizer;
|
||||
|
||||
/**
|
||||
* A helper providing autocompletion for available UidNormalizer options.
|
||||
*
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*/
|
||||
final class UidNormalizerContextBuilder implements ContextBuilderInterface
|
||||
{
|
||||
use ContextBuilderTrait;
|
||||
|
||||
/**
|
||||
* Configures the uuid format for normalization.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function withNormalizationFormat(?string $normalizationFormat): static
|
||||
{
|
||||
if (null !== $normalizationFormat && !\in_array($normalizationFormat, UidNormalizer::NORMALIZATION_FORMATS, true)) {
|
||||
throw new InvalidArgumentException(\sprintf('The "%s" normalization format is not valid.', $normalizationFormat));
|
||||
}
|
||||
|
||||
return $this->with(UidNormalizer::NORMALIZATION_FORMAT_KEY, $normalizationFormat);
|
||||
}
|
||||
}
|
||||
53
backend/vendor/symfony/serializer/Context/Normalizer/UnwrappingDenormalizerContextBuilder.php
vendored
Normal file
53
backend/vendor/symfony/serializer/Context/Normalizer/UnwrappingDenormalizerContextBuilder.php
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Context\Normalizer;
|
||||
|
||||
use Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException;
|
||||
use Symfony\Component\PropertyAccess\PropertyPath;
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderInterface;
|
||||
use Symfony\Component\Serializer\Context\ContextBuilderTrait;
|
||||
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Serializer\Normalizer\UnwrappingDenormalizer;
|
||||
|
||||
/**
|
||||
* A helper providing autocompletion for available UnwrappingDenormalizer options.
|
||||
*
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*/
|
||||
final class UnwrappingDenormalizerContextBuilder implements ContextBuilderInterface
|
||||
{
|
||||
use ContextBuilderTrait;
|
||||
|
||||
/**
|
||||
* Configures the path of wrapped data during denormalization.
|
||||
*
|
||||
* Eg: [foo].bar[bar]
|
||||
*
|
||||
* @see https://symfony.com/doc/current/components/property_access.html
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function withUnwrapPath(?string $unwrapPath): static
|
||||
{
|
||||
if (null === $unwrapPath) {
|
||||
return $this->with(UnwrappingDenormalizer::UNWRAP_PATH, null);
|
||||
}
|
||||
|
||||
try {
|
||||
new PropertyPath($unwrapPath);
|
||||
} catch (InvalidPropertyPathException $e) {
|
||||
throw new InvalidArgumentException(\sprintf('The "%s" property path is not valid.', $unwrapPath), previous: $e);
|
||||
}
|
||||
|
||||
return $this->with(UnwrappingDenormalizer::UNWRAP_PATH, $unwrapPath);
|
||||
}
|
||||
}
|
||||
39
backend/vendor/symfony/serializer/Context/SerializerContextBuilder.php
vendored
Normal file
39
backend/vendor/symfony/serializer/Context/SerializerContextBuilder.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Context;
|
||||
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Symfony\Component\Serializer\Serializer;
|
||||
|
||||
/**
|
||||
* A helper providing autocompletion for available Serializer options.
|
||||
*
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*/
|
||||
final class SerializerContextBuilder implements ContextBuilderInterface
|
||||
{
|
||||
use ContextBuilderTrait;
|
||||
|
||||
/**
|
||||
* Configures whether an empty array should be transformed to an
|
||||
* object (in JSON: {}) or to a list (in JSON: []).
|
||||
*/
|
||||
public function withEmptyArrayAsObject(?bool $emptyArrayAsObject): static
|
||||
{
|
||||
return $this->with(Serializer::EMPTY_ARRAY_AS_OBJECT, $emptyArrayAsObject);
|
||||
}
|
||||
|
||||
public function withCollectDenormalizationErrors(?bool $collectDenormalizationErrors): static
|
||||
{
|
||||
return $this->with(DenormalizerInterface::COLLECT_DENORMALIZATION_ERRORS, $collectDenormalizationErrors);
|
||||
}
|
||||
}
|
||||
259
backend/vendor/symfony/serializer/DataCollector/SerializerDataCollector.php
vendored
Normal file
259
backend/vendor/symfony/serializer/DataCollector/SerializerDataCollector.php
vendored
Normal file
@@ -0,0 +1,259 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\DataCollector;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
|
||||
use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface;
|
||||
use Symfony\Component\Serializer\Debug\TraceableSerializer;
|
||||
use Symfony\Component\VarDumper\Cloner\Data;
|
||||
|
||||
/**
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class SerializerDataCollector extends DataCollector implements LateDataCollectorInterface
|
||||
{
|
||||
private const DATA_TEMPLATE = [
|
||||
'serialize' => [],
|
||||
'deserialize' => [],
|
||||
'normalize' => [],
|
||||
'denormalize' => [],
|
||||
'encode' => [],
|
||||
'decode' => [],
|
||||
];
|
||||
|
||||
private array $dataGroupedByName;
|
||||
private array $collected = [];
|
||||
|
||||
public function reset(): void
|
||||
{
|
||||
$this->data = [];
|
||||
unset($this->dataGroupedByName);
|
||||
$this->collected = [];
|
||||
}
|
||||
|
||||
public function collect(Request $request, Response $response, ?\Throwable $exception = null): void
|
||||
{
|
||||
// Everything is collected during the request, and formatted on kernel terminate.
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return 'serializer';
|
||||
}
|
||||
|
||||
public function getData(?string $name = null): Data|array
|
||||
{
|
||||
return null === $name ? $this->data : $this->getDataGroupedByName()[$name];
|
||||
}
|
||||
|
||||
public function getHandledCount(?string $name = null): int
|
||||
{
|
||||
return array_sum(array_map('count', $this->getData($name)));
|
||||
}
|
||||
|
||||
public function getTotalTime(): float
|
||||
{
|
||||
$totalTime = 0;
|
||||
|
||||
foreach ($this->data as $handled) {
|
||||
$totalTime += array_sum(array_map(fn (array $el): float => $el['time'], $handled));
|
||||
}
|
||||
|
||||
return $totalTime;
|
||||
}
|
||||
|
||||
public function getSerializerNames(): array
|
||||
{
|
||||
return array_keys($this->getDataGroupedByName());
|
||||
}
|
||||
|
||||
public function collectSerialize(string $traceId, mixed $data, string $format, array $context, float $time, array $caller, string $name): void
|
||||
{
|
||||
unset($context[TraceableSerializer::DEBUG_TRACE_ID]);
|
||||
|
||||
$this->collected[$traceId] = array_merge(
|
||||
$this->collected[$traceId] ?? [],
|
||||
compact('data', 'format', 'context', 'time', 'caller', 'name'),
|
||||
['method' => 'serialize'],
|
||||
);
|
||||
}
|
||||
|
||||
public function collectDeserialize(string $traceId, mixed $data, string $type, string $format, array $context, float $time, array $caller, string $name): void
|
||||
{
|
||||
unset($context[TraceableSerializer::DEBUG_TRACE_ID]);
|
||||
|
||||
$this->collected[$traceId] = array_merge(
|
||||
$this->collected[$traceId] ?? [],
|
||||
compact('data', 'format', 'type', 'context', 'time', 'caller', 'name'),
|
||||
['method' => 'deserialize'],
|
||||
);
|
||||
}
|
||||
|
||||
public function collectNormalize(string $traceId, mixed $data, ?string $format, array $context, float $time, array $caller, string $name): void
|
||||
{
|
||||
unset($context[TraceableSerializer::DEBUG_TRACE_ID]);
|
||||
|
||||
$this->collected[$traceId] = array_merge(
|
||||
$this->collected[$traceId] ?? [],
|
||||
compact('data', 'format', 'context', 'time', 'caller', 'name'),
|
||||
['method' => 'normalize'],
|
||||
);
|
||||
}
|
||||
|
||||
public function collectDenormalize(string $traceId, mixed $data, string $type, ?string $format, array $context, float $time, array $caller, string $name): void
|
||||
{
|
||||
unset($context[TraceableSerializer::DEBUG_TRACE_ID]);
|
||||
|
||||
$this->collected[$traceId] = array_merge(
|
||||
$this->collected[$traceId] ?? [],
|
||||
compact('data', 'format', 'type', 'context', 'time', 'caller', 'name'),
|
||||
['method' => 'denormalize'],
|
||||
);
|
||||
}
|
||||
|
||||
public function collectEncode(string $traceId, mixed $data, ?string $format, array $context, float $time, array $caller, string $name): void
|
||||
{
|
||||
unset($context[TraceableSerializer::DEBUG_TRACE_ID]);
|
||||
|
||||
$this->collected[$traceId] = array_merge(
|
||||
$this->collected[$traceId] ?? [],
|
||||
compact('data', 'format', 'context', 'time', 'caller', 'name'),
|
||||
['method' => 'encode'],
|
||||
);
|
||||
}
|
||||
|
||||
public function collectDecode(string $traceId, mixed $data, ?string $format, array $context, float $time, array $caller, string $name): void
|
||||
{
|
||||
unset($context[TraceableSerializer::DEBUG_TRACE_ID]);
|
||||
|
||||
$this->collected[$traceId] = array_merge(
|
||||
$this->collected[$traceId] ?? [],
|
||||
compact('data', 'format', 'context', 'time', 'caller', 'name'),
|
||||
['method' => 'decode'],
|
||||
);
|
||||
}
|
||||
|
||||
public function collectNormalization(string $traceId, string $normalizer, float $time, string $name): void
|
||||
{
|
||||
$method = 'normalize';
|
||||
|
||||
$this->collected[$traceId]['normalization'][] = compact('normalizer', 'method', 'time', 'name');
|
||||
}
|
||||
|
||||
public function collectDenormalization(string $traceId, string $normalizer, float $time, string $name): void
|
||||
{
|
||||
$method = 'denormalize';
|
||||
|
||||
$this->collected[$traceId]['normalization'][] = compact('normalizer', 'method', 'time', 'name');
|
||||
}
|
||||
|
||||
public function collectEncoding(string $traceId, string $encoder, float $time, string $name): void
|
||||
{
|
||||
$method = 'encode';
|
||||
|
||||
$this->collected[$traceId]['encoding'][] = compact('encoder', 'method', 'time', 'name');
|
||||
}
|
||||
|
||||
public function collectDecoding(string $traceId, string $encoder, float $time, string $name): void
|
||||
{
|
||||
$method = 'decode';
|
||||
|
||||
$this->collected[$traceId]['encoding'][] = compact('encoder', 'method', 'time', 'name');
|
||||
}
|
||||
|
||||
public function lateCollect(): void
|
||||
{
|
||||
$this->data = self::DATA_TEMPLATE;
|
||||
|
||||
foreach ($this->collected as $collected) {
|
||||
if (!isset($collected['data'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'data' => $this->cloneVar($collected['data']),
|
||||
'dataType' => get_debug_type($collected['data']),
|
||||
'type' => $collected['type'] ?? null,
|
||||
'format' => $collected['format'],
|
||||
'time' => $collected['time'],
|
||||
'context' => $this->cloneVar($collected['context']),
|
||||
'normalization' => [],
|
||||
'encoding' => [],
|
||||
'caller' => $collected['caller'] ?? null,
|
||||
'name' => $collected['name'],
|
||||
];
|
||||
|
||||
if (isset($collected['normalization'])) {
|
||||
$mainNormalization = array_pop($collected['normalization']);
|
||||
|
||||
$data['normalizer'] = ['time' => $mainNormalization['time']] + $this->getMethodLocation($mainNormalization['normalizer'], $mainNormalization['method']);
|
||||
|
||||
foreach ($collected['normalization'] as $normalization) {
|
||||
if (!isset($data['normalization'][$normalization['normalizer']])) {
|
||||
$data['normalization'][$normalization['normalizer']] = ['time' => 0, 'calls' => 0] + $this->getMethodLocation($normalization['normalizer'], $normalization['method']);
|
||||
}
|
||||
|
||||
++$data['normalization'][$normalization['normalizer']]['calls'];
|
||||
$data['normalization'][$normalization['normalizer']]['time'] += $normalization['time'];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($collected['encoding'])) {
|
||||
$mainEncoding = array_pop($collected['encoding']);
|
||||
|
||||
$data['encoder'] = ['time' => $mainEncoding['time']] + $this->getMethodLocation($mainEncoding['encoder'], $mainEncoding['method']);
|
||||
|
||||
foreach ($collected['encoding'] as $encoding) {
|
||||
if (!isset($data['encoding'][$encoding['encoder']])) {
|
||||
$data['encoding'][$encoding['encoder']] = ['time' => 0, 'calls' => 0] + $this->getMethodLocation($encoding['encoder'], $encoding['method']);
|
||||
}
|
||||
|
||||
++$data['encoding'][$encoding['encoder']]['calls'];
|
||||
$data['encoding'][$encoding['encoder']]['time'] += $encoding['time'];
|
||||
}
|
||||
}
|
||||
|
||||
$this->data[$collected['method']][] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
private function getDataGroupedByName(): array
|
||||
{
|
||||
if (!isset($this->dataGroupedByName)) {
|
||||
$this->dataGroupedByName = [];
|
||||
|
||||
foreach ($this->data as $method => $items) {
|
||||
foreach ($items as $item) {
|
||||
$this->dataGroupedByName[$item['name']] ??= self::DATA_TEMPLATE;
|
||||
$this->dataGroupedByName[$item['name']][$method][] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->dataGroupedByName;
|
||||
}
|
||||
|
||||
private function getMethodLocation(string $class, string $method): array
|
||||
{
|
||||
$reflection = new \ReflectionClass($class);
|
||||
|
||||
return [
|
||||
'class' => $reflection->getShortName(),
|
||||
'file' => $reflection->getFileName(),
|
||||
'line' => $reflection->getMethod($method)->getStartLine(),
|
||||
];
|
||||
}
|
||||
}
|
||||
110
backend/vendor/symfony/serializer/Debug/TraceableEncoder.php
vendored
Normal file
110
backend/vendor/symfony/serializer/Debug/TraceableEncoder.php
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Debug;
|
||||
|
||||
use Symfony\Component\Serializer\DataCollector\SerializerDataCollector;
|
||||
use Symfony\Component\Serializer\Encoder\DecoderInterface;
|
||||
use Symfony\Component\Serializer\Encoder\EncoderInterface;
|
||||
use Symfony\Component\Serializer\Encoder\NormalizationAwareInterface;
|
||||
use Symfony\Component\Serializer\SerializerAwareInterface;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
|
||||
/**
|
||||
* Collects some data about encoding.
|
||||
*
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class TraceableEncoder implements EncoderInterface, DecoderInterface, SerializerAwareInterface
|
||||
{
|
||||
public function __construct(
|
||||
private EncoderInterface|DecoderInterface $encoder,
|
||||
private SerializerDataCollector $dataCollector,
|
||||
private readonly string $serializerName = 'default',
|
||||
) {
|
||||
}
|
||||
|
||||
public function encode(mixed $data, string $format, array $context = []): string
|
||||
{
|
||||
if (!$this->encoder instanceof EncoderInterface) {
|
||||
throw new \BadMethodCallException(\sprintf('The "%s()" method cannot be called as nested encoder doesn\'t implements "%s".', __METHOD__, EncoderInterface::class));
|
||||
}
|
||||
|
||||
$startTime = microtime(true);
|
||||
$encoded = $this->encoder->encode($data, $format, $context);
|
||||
$time = microtime(true) - $startTime;
|
||||
|
||||
if ($traceId = ($context[TraceableSerializer::DEBUG_TRACE_ID] ?? null)) {
|
||||
$this->dataCollector->collectEncoding($traceId, $this->encoder::class, $time, $this->serializerName);
|
||||
}
|
||||
|
||||
return $encoded;
|
||||
}
|
||||
|
||||
public function supportsEncoding(string $format, array $context = []): bool
|
||||
{
|
||||
if (!$this->encoder instanceof EncoderInterface) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->encoder->supportsEncoding($format, $context);
|
||||
}
|
||||
|
||||
public function decode(string $data, string $format, array $context = []): mixed
|
||||
{
|
||||
if (!$this->encoder instanceof DecoderInterface) {
|
||||
throw new \BadMethodCallException(\sprintf('The "%s()" method cannot be called as nested encoder doesn\'t implements "%s".', __METHOD__, DecoderInterface::class));
|
||||
}
|
||||
|
||||
$startTime = microtime(true);
|
||||
$encoded = $this->encoder->decode($data, $format, $context);
|
||||
$time = microtime(true) - $startTime;
|
||||
|
||||
if ($traceId = ($context[TraceableSerializer::DEBUG_TRACE_ID] ?? null)) {
|
||||
$this->dataCollector->collectDecoding($traceId, $this->encoder::class, $time, $this->serializerName);
|
||||
}
|
||||
|
||||
return $encoded;
|
||||
}
|
||||
|
||||
public function supportsDecoding(string $format, array $context = []): bool
|
||||
{
|
||||
if (!$this->encoder instanceof DecoderInterface) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->encoder->supportsDecoding($format, $context);
|
||||
}
|
||||
|
||||
public function setSerializer(SerializerInterface $serializer): void
|
||||
{
|
||||
if (!$this->encoder instanceof SerializerAwareInterface) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->encoder->setSerializer($serializer);
|
||||
}
|
||||
|
||||
public function needsNormalization(): bool
|
||||
{
|
||||
return !$this->encoder instanceof NormalizationAwareInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* Proxies all method calls to the original encoder.
|
||||
*/
|
||||
public function __call(string $method, array $arguments): mixed
|
||||
{
|
||||
return $this->encoder->{$method}(...$arguments);
|
||||
}
|
||||
}
|
||||
129
backend/vendor/symfony/serializer/Debug/TraceableNormalizer.php
vendored
Normal file
129
backend/vendor/symfony/serializer/Debug/TraceableNormalizer.php
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Debug;
|
||||
|
||||
use Symfony\Component\Serializer\DataCollector\SerializerDataCollector;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Symfony\Component\Serializer\SerializerAwareInterface;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
|
||||
/**
|
||||
* Collects some data about normalization.
|
||||
*
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class TraceableNormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface, NormalizerAwareInterface, DenormalizerAwareInterface
|
||||
{
|
||||
public function __construct(
|
||||
private NormalizerInterface|DenormalizerInterface $normalizer,
|
||||
private SerializerDataCollector $dataCollector,
|
||||
private readonly string $serializerName = 'default',
|
||||
) {
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return $this->normalizer->getSupportedTypes($format);
|
||||
}
|
||||
|
||||
public function normalize(mixed $data, ?string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
|
||||
{
|
||||
if (!$this->normalizer instanceof NormalizerInterface) {
|
||||
throw new \BadMethodCallException(\sprintf('The "%s()" method cannot be called as nested normalizer doesn\'t implements "%s".', __METHOD__, NormalizerInterface::class));
|
||||
}
|
||||
|
||||
$startTime = microtime(true);
|
||||
$normalized = $this->normalizer->normalize($data, $format, $context);
|
||||
$time = microtime(true) - $startTime;
|
||||
|
||||
if ($traceId = ($context[TraceableSerializer::DEBUG_TRACE_ID] ?? null)) {
|
||||
$this->dataCollector->collectNormalization($traceId, $this->normalizer::class, $time, $this->serializerName);
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
if (!$this->normalizer instanceof NormalizerInterface) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->normalizer->supportsNormalization($data, $format, $context);
|
||||
}
|
||||
|
||||
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
|
||||
{
|
||||
if (!$this->normalizer instanceof DenormalizerInterface) {
|
||||
throw new \BadMethodCallException(\sprintf('The "%s()" method cannot be called as nested normalizer doesn\'t implements "%s".', __METHOD__, DenormalizerInterface::class));
|
||||
}
|
||||
|
||||
$startTime = microtime(true);
|
||||
$denormalized = $this->normalizer->denormalize($data, $type, $format, $context);
|
||||
$time = microtime(true) - $startTime;
|
||||
|
||||
if ($traceId = ($context[TraceableSerializer::DEBUG_TRACE_ID] ?? null)) {
|
||||
$this->dataCollector->collectDenormalization($traceId, $this->normalizer::class, $time, $this->serializerName);
|
||||
}
|
||||
|
||||
return $denormalized;
|
||||
}
|
||||
|
||||
public function supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
if (!$this->normalizer instanceof DenormalizerInterface) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->normalizer->supportsDenormalization($data, $type, $format, $context);
|
||||
}
|
||||
|
||||
public function setSerializer(SerializerInterface $serializer): void
|
||||
{
|
||||
if (!$this->normalizer instanceof SerializerAwareInterface) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->normalizer->setSerializer($serializer);
|
||||
}
|
||||
|
||||
public function setNormalizer(NormalizerInterface $normalizer): void
|
||||
{
|
||||
if (!$this->normalizer instanceof NormalizerAwareInterface) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->normalizer->setNormalizer($normalizer);
|
||||
}
|
||||
|
||||
public function setDenormalizer(DenormalizerInterface $denormalizer): void
|
||||
{
|
||||
if (!$this->normalizer instanceof DenormalizerAwareInterface) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->normalizer->setDenormalizer($denormalizer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Proxies all method calls to the original normalizer.
|
||||
*/
|
||||
public function __call(string $method, array $arguments): mixed
|
||||
{
|
||||
return $this->normalizer->{$method}(...$arguments);
|
||||
}
|
||||
}
|
||||
186
backend/vendor/symfony/serializer/Debug/TraceableSerializer.php
vendored
Normal file
186
backend/vendor/symfony/serializer/Debug/TraceableSerializer.php
vendored
Normal file
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Debug;
|
||||
|
||||
use Symfony\Component\Serializer\DataCollector\SerializerDataCollector;
|
||||
use Symfony\Component\Serializer\Encoder\DecoderInterface;
|
||||
use Symfony\Component\Serializer\Encoder\EncoderInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
|
||||
/**
|
||||
* Collects some data about serialization.
|
||||
*
|
||||
* @author Mathias Arlaud <mathias.arlaud@gmail.com>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class TraceableSerializer implements SerializerInterface, NormalizerInterface, DenormalizerInterface, EncoderInterface, DecoderInterface
|
||||
{
|
||||
public const DEBUG_TRACE_ID = 'debug_trace_id';
|
||||
|
||||
public function __construct(
|
||||
private SerializerInterface&NormalizerInterface&DenormalizerInterface&EncoderInterface&DecoderInterface $serializer,
|
||||
private SerializerDataCollector $dataCollector,
|
||||
private readonly string $serializerName = 'default',
|
||||
) {
|
||||
}
|
||||
|
||||
public function serialize(mixed $data, string $format, array $context = []): string
|
||||
{
|
||||
$context[self::DEBUG_TRACE_ID] = $traceId = bin2hex(random_bytes(4));
|
||||
|
||||
$startTime = microtime(true);
|
||||
$result = $this->serializer->serialize($data, $format, $context);
|
||||
$time = microtime(true) - $startTime;
|
||||
|
||||
$caller = $this->getCaller(__FUNCTION__, SerializerInterface::class);
|
||||
|
||||
$this->dataCollector->collectSerialize($traceId, $data, $format, $context, $time, $caller, $this->serializerName);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function deserialize(mixed $data, string $type, string $format, array $context = []): mixed
|
||||
{
|
||||
$context[self::DEBUG_TRACE_ID] = $traceId = bin2hex(random_bytes(4));
|
||||
|
||||
$startTime = microtime(true);
|
||||
$result = $this->serializer->deserialize($data, $type, $format, $context);
|
||||
$time = microtime(true) - $startTime;
|
||||
|
||||
$caller = $this->getCaller(__FUNCTION__, SerializerInterface::class);
|
||||
|
||||
$this->dataCollector->collectDeserialize($traceId, $data, $type, $format, $context, $time, $caller, $this->serializerName);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function normalize(mixed $data, ?string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
|
||||
{
|
||||
$context[self::DEBUG_TRACE_ID] = $traceId = bin2hex(random_bytes(4));
|
||||
|
||||
$startTime = microtime(true);
|
||||
$result = $this->serializer->normalize($data, $format, $context);
|
||||
$time = microtime(true) - $startTime;
|
||||
|
||||
$caller = $this->getCaller(__FUNCTION__, NormalizerInterface::class);
|
||||
|
||||
$this->dataCollector->collectNormalize($traceId, $data, $format, $context, $time, $caller, $this->serializerName);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
|
||||
{
|
||||
$context[self::DEBUG_TRACE_ID] = $traceId = bin2hex(random_bytes(4));
|
||||
|
||||
$startTime = microtime(true);
|
||||
$result = $this->serializer->denormalize($data, $type, $format, $context);
|
||||
$time = microtime(true) - $startTime;
|
||||
|
||||
$caller = $this->getCaller(__FUNCTION__, DenormalizerInterface::class);
|
||||
|
||||
$this->dataCollector->collectDenormalize($traceId, $data, $type, $format, $context, $time, $caller, $this->serializerName);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function encode(mixed $data, string $format, array $context = []): string
|
||||
{
|
||||
$context[self::DEBUG_TRACE_ID] = $traceId = bin2hex(random_bytes(4));
|
||||
|
||||
$startTime = microtime(true);
|
||||
$result = $this->serializer->encode($data, $format, $context);
|
||||
$time = microtime(true) - $startTime;
|
||||
|
||||
$caller = $this->getCaller(__FUNCTION__, EncoderInterface::class);
|
||||
|
||||
$this->dataCollector->collectEncode($traceId, $data, $format, $context, $time, $caller, $this->serializerName);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function decode(string $data, string $format, array $context = []): mixed
|
||||
{
|
||||
$context[self::DEBUG_TRACE_ID] = $traceId = bin2hex(random_bytes(4));
|
||||
|
||||
$startTime = microtime(true);
|
||||
$result = $this->serializer->decode($data, $format, $context);
|
||||
$time = microtime(true) - $startTime;
|
||||
|
||||
$caller = $this->getCaller(__FUNCTION__, DecoderInterface::class);
|
||||
|
||||
$this->dataCollector->collectDecode($traceId, $data, $format, $context, $time, $caller, $this->serializerName);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return $this->serializer->getSupportedTypes($format);
|
||||
}
|
||||
|
||||
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
return $this->serializer->supportsNormalization($data, $format, $context);
|
||||
}
|
||||
|
||||
public function supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
return $this->serializer->supportsDenormalization($data, $type, $format, $context);
|
||||
}
|
||||
|
||||
public function supportsEncoding(string $format, array $context = []): bool
|
||||
{
|
||||
return $this->serializer->supportsEncoding($format, $context);
|
||||
}
|
||||
|
||||
public function supportsDecoding(string $format, array $context = []): bool
|
||||
{
|
||||
return $this->serializer->supportsDecoding($format, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Proxies all method calls to the original serializer.
|
||||
*/
|
||||
public function __call(string $method, array $arguments): mixed
|
||||
{
|
||||
return $this->serializer->{$method}(...$arguments);
|
||||
}
|
||||
|
||||
private function getCaller(string $method, string $interface): array
|
||||
{
|
||||
$trace = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 8);
|
||||
|
||||
$file = $trace[0]['file'];
|
||||
$line = $trace[0]['line'];
|
||||
|
||||
for ($i = 1; $i < 8; ++$i) {
|
||||
if (isset($trace[$i]['class'], $trace[$i]['function'])
|
||||
&& $method === $trace[$i]['function']
|
||||
&& is_a($trace[$i]['class'], $interface, true)
|
||||
) {
|
||||
$file = $trace[$i]['file'] ?? $trace[$i + 1]['file'];
|
||||
$line = $trace[$i]['line'] ?? $trace[$i + 1]['line'];
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$name = str_replace('\\', '/', $file);
|
||||
$name = substr($name, strrpos($name, '/') + 1);
|
||||
|
||||
return compact('name', 'file', 'line');
|
||||
}
|
||||
}
|
||||
72
backend/vendor/symfony/serializer/DependencyInjection/AttributeMetadataPass.php
vendored
Normal file
72
backend/vendor/symfony/serializer/DependencyInjection/AttributeMetadataPass.php
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\Serializer\Exception\MappingException;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
final class AttributeMetadataPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
if (!$container->hasDefinition('serializer.mapping.attribute_loader')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$resolve = $container->getParameterBag()->resolveValue(...);
|
||||
$taggedClasses = [];
|
||||
foreach ($container->getDefinitions() as $id => $definition) {
|
||||
if (!$definition->hasTag('serializer.attribute_metadata')) {
|
||||
continue;
|
||||
}
|
||||
$class = $resolve($definition->getClass());
|
||||
foreach ($definition->getTag('serializer.attribute_metadata') as $attributes) {
|
||||
if ($class !== $for = $attributes['for'] ?? $class) {
|
||||
$this->checkSourceMapsToTarget($container, $class, $for);
|
||||
}
|
||||
|
||||
$taggedClasses[$for][$class] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$taggedClasses) {
|
||||
return;
|
||||
}
|
||||
|
||||
ksort($taggedClasses);
|
||||
|
||||
$container->getDefinition('serializer.mapping.attribute_loader')
|
||||
->replaceArgument(1, array_map('array_keys', $taggedClasses));
|
||||
}
|
||||
|
||||
private function checkSourceMapsToTarget(ContainerBuilder $container, string $source, string $target): void
|
||||
{
|
||||
$source = $container->getReflectionClass($source);
|
||||
$target = $container->getReflectionClass($target);
|
||||
|
||||
foreach ($source->getProperties() as $p) {
|
||||
if ($p->class === $source->name && !($target->hasProperty($p->name) && $target->getProperty($p->name)->class === $target->name)) {
|
||||
throw new MappingException(\sprintf('The property "%s" on "%s" is not present on "%s".', $p->name, $source->name, $target->name));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($source->getMethods() as $m) {
|
||||
if ($m->class === $source->name && !($target->hasMethod($m->name) && $target->getMethod($m->name)->class === $target->name)) {
|
||||
throw new MappingException(\sprintf('The method "%s" on "%s" is not present on "%s".', $m->name, $source->name, $target->name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
244
backend/vendor/symfony/serializer/DependencyInjection/SerializerPass.php
vendored
Normal file
244
backend/vendor/symfony/serializer/DependencyInjection/SerializerPass.php
vendored
Normal file
@@ -0,0 +1,244 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Argument\BoundArgument;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\Serializer\Debug\TraceableEncoder;
|
||||
use Symfony\Component\Serializer\Debug\TraceableNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
|
||||
/**
|
||||
* Adds all services with the tags "serializer.encoder" and "serializer.normalizer" as
|
||||
* encoders and normalizers to the "serializer" service.
|
||||
*
|
||||
* @author Javier Lopez <f12loalf@gmail.com>
|
||||
* @author Robin Chalas <robin.chalas@gmail.com>
|
||||
*/
|
||||
class SerializerPass implements CompilerPassInterface
|
||||
{
|
||||
use PriorityTaggedServiceTrait;
|
||||
|
||||
private const NAME_CONVERTER_METADATA_AWARE_ID = 'serializer.name_converter.metadata_aware';
|
||||
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
if (!$container->hasDefinition('serializer')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$namedSerializers = $container->hasParameter('.serializer.named_serializers')
|
||||
? $container->getParameter('.serializer.named_serializers') : [];
|
||||
|
||||
$this->createNamedSerializerTags($container, 'serializer.normalizer', 'include_built_in_normalizers', $namedSerializers);
|
||||
$this->createNamedSerializerTags($container, 'serializer.encoder', 'include_built_in_encoders', $namedSerializers);
|
||||
|
||||
if (!$normalizers = $this->findAndSortTaggedServices('serializer.normalizer.default', $container)) {
|
||||
throw new RuntimeException('You must tag at least one service as "serializer.normalizer" to use the "serializer" service.');
|
||||
}
|
||||
|
||||
if (!$encoders = $this->findAndSortTaggedServices('serializer.encoder.default', $container)) {
|
||||
throw new RuntimeException('You must tag at least one service as "serializer.encoder" to use the "serializer" service.');
|
||||
}
|
||||
|
||||
$defaultContext = [];
|
||||
if ($container->hasParameter('serializer.default_context')) {
|
||||
$defaultContext = $container->getParameter('serializer.default_context');
|
||||
$container->getParameterBag()->remove('serializer.default_context');
|
||||
$container->getDefinition('serializer')->setArgument('$defaultContext', $defaultContext);
|
||||
}
|
||||
|
||||
/** @var ?string $circularReferenceHandler */
|
||||
$circularReferenceHandler = $container->hasParameter('.serializer.circular_reference_handler')
|
||||
? $container->getParameter('.serializer.circular_reference_handler') : null;
|
||||
|
||||
/** @var ?string $maxDepthHandler */
|
||||
$maxDepthHandler = $container->hasParameter('.serializer.max_depth_handler')
|
||||
? $container->getParameter('.serializer.max_depth_handler') : null;
|
||||
|
||||
$this->bindDefaultContext($container, array_merge($normalizers, $encoders), $defaultContext, $circularReferenceHandler, $maxDepthHandler);
|
||||
|
||||
$this->configureSerializer($container, 'serializer', $normalizers, $encoders, 'default');
|
||||
|
||||
if ($namedSerializers) {
|
||||
$this->configureNamedSerializers($container, $circularReferenceHandler, $maxDepthHandler);
|
||||
}
|
||||
}
|
||||
|
||||
private function createNamedSerializerTags(ContainerBuilder $container, string $tagName, string $configName, array $namedSerializers): void
|
||||
{
|
||||
$serializerNames = array_keys($namedSerializers);
|
||||
$withBuiltIn = array_filter($serializerNames, fn (string $name) => $namedSerializers[$name][$configName] ?? false);
|
||||
|
||||
foreach ($container->findTaggedServiceIds($tagName) as $serviceId => $tags) {
|
||||
$definition = $container->getDefinition($serviceId);
|
||||
|
||||
if (array_any($tags, $closure = fn (array $tag) => (bool) $tag)) {
|
||||
$tags = array_filter($tags, $closure);
|
||||
}
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
$names = (array) ($tag['serializer'] ?? []);
|
||||
|
||||
if (!$names) {
|
||||
$names = ['default'];
|
||||
} elseif (\in_array('*', $names, true)) {
|
||||
$names = array_unique(['default', ...$serializerNames]);
|
||||
}
|
||||
|
||||
if ($tag['built_in'] ?? false) {
|
||||
$names = array_unique(['default', ...$names, ...$withBuiltIn]);
|
||||
}
|
||||
|
||||
unset($tag['serializer'], $tag['built_in']);
|
||||
|
||||
foreach ($names as $name) {
|
||||
$definition->addTag($tagName.'.'.$name, $tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function bindDefaultContext(ContainerBuilder $container, array $services, array $defaultContext, ?string $circularReferenceHandler, ?string $maxDepthHandler): void
|
||||
{
|
||||
foreach ($services as $id) {
|
||||
$definition = $container->getDefinition((string) $id);
|
||||
|
||||
$context = $defaultContext;
|
||||
if (is_a($definition->getClass(), ObjectNormalizer::class, true)) {
|
||||
if (null !== $circularReferenceHandler) {
|
||||
$context += ['circular_reference_handler' => new Reference($circularReferenceHandler)];
|
||||
}
|
||||
if (null !== $maxDepthHandler) {
|
||||
$context += ['max_depth_handler' => new Reference($maxDepthHandler)];
|
||||
}
|
||||
}
|
||||
|
||||
$definition->setBindings(['array $defaultContext' => new BoundArgument($context, false)] + $definition->getBindings());
|
||||
}
|
||||
}
|
||||
|
||||
private function configureSerializer(ContainerBuilder $container, string $id, array $normalizers, array $encoders, string $serializerName): void
|
||||
{
|
||||
if ($container->getParameter('kernel.debug') && $container->hasDefinition('serializer.data_collector')) {
|
||||
foreach ($normalizers as $i => $normalizer) {
|
||||
$normalizers[$i] = $container->register('.debug.serializer.normalizer.'.$normalizer, TraceableNormalizer::class)
|
||||
->setArguments([$normalizer, new Reference('serializer.data_collector'), $serializerName]);
|
||||
}
|
||||
|
||||
foreach ($encoders as $i => $encoder) {
|
||||
$encoders[$i] = $container->register('.debug.serializer.encoder.'.$encoder, TraceableEncoder::class)
|
||||
->setArguments([$encoder, new Reference('serializer.data_collector'), $serializerName]);
|
||||
}
|
||||
}
|
||||
|
||||
$serializerDefinition = $container->getDefinition($id);
|
||||
$serializerDefinition->replaceArgument(0, $normalizers);
|
||||
$serializerDefinition->replaceArgument(1, $encoders);
|
||||
}
|
||||
|
||||
private function configureNamedSerializers(ContainerBuilder $container, ?string $circularReferenceHandler, ?string $maxDepthHandler): void
|
||||
{
|
||||
$defaultSerializerNameConverter = $container->hasParameter('.serializer.name_converter')
|
||||
? $container->getParameter('.serializer.name_converter') : null;
|
||||
|
||||
foreach ($container->getParameter('.serializer.named_serializers') as $serializerName => $config) {
|
||||
$config += ['default_context' => [], 'name_converter' => null];
|
||||
$serializerId = 'serializer.'.$serializerName;
|
||||
|
||||
if (!$normalizers = $this->findAndSortTaggedServices('serializer.normalizer.'.$serializerName, $container)) {
|
||||
throw new RuntimeException(\sprintf('The named serializer "%1$s" requires at least one registered normalizer. Tag the normalizers as "serializer.normalizer" with the "serializer" attribute set to "%1$s".', $serializerName));
|
||||
}
|
||||
|
||||
if (!$encoders = $this->findAndSortTaggedServices('serializer.encoder.'.$serializerName, $container)) {
|
||||
throw new RuntimeException(\sprintf('The named serializer "%1$s" requires at least one registered encoder. Tag the encoders as "serializer.encoder" with the "serializer" attribute set to "%1$s".', $serializerName));
|
||||
}
|
||||
|
||||
$config['name_converter'] = $defaultSerializerNameConverter !== $config['name_converter']
|
||||
? $this->buildChildNameConverterDefinition($container, $config['name_converter'])
|
||||
: self::NAME_CONVERTER_METADATA_AWARE_ID;
|
||||
|
||||
$normalizers = $this->buildChildDefinitions($container, $serializerName, $normalizers, $config);
|
||||
$encoders = $this->buildChildDefinitions($container, $serializerName, $encoders, $config);
|
||||
|
||||
$this->bindDefaultContext($container, array_merge($normalizers, $encoders), $config['default_context'], $circularReferenceHandler, $maxDepthHandler);
|
||||
|
||||
$container->registerChild($serializerId, 'serializer')->setArgument('$defaultContext', $config['default_context']);
|
||||
$container->registerAliasForArgument($serializerId, SerializerInterface::class, $serializerName.'.serializer');
|
||||
$container->registerAliasForArgument($serializerId, SerializerInterface::class, $serializerName);
|
||||
$container->registerAliasForArgument($serializerId, NormalizerInterface::class, $serializerName.'.normalizer');
|
||||
$container->registerAliasForArgument($serializerId, NormalizerInterface::class, $serializerName);
|
||||
$container->registerAliasForArgument($serializerId, DenormalizerInterface::class, $serializerName.'.denormalizer');
|
||||
$container->registerAliasForArgument($serializerId, DenormalizerInterface::class, $serializerName);
|
||||
|
||||
$this->configureSerializer($container, $serializerId, $normalizers, $encoders, $serializerName);
|
||||
|
||||
if ($container->getParameter('kernel.debug') && $container->hasDefinition('debug.serializer')) {
|
||||
$container->registerChild($debugId = 'debug.'.$serializerId, 'debug.serializer')
|
||||
->setDecoratedService($serializerId)
|
||||
->replaceArgument(0, new Reference($debugId.'.inner'))
|
||||
->replaceArgument(2, $serializerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function buildChildNameConverterDefinition(ContainerBuilder $container, ?string $nameConverter): ?string
|
||||
{
|
||||
$childId = self::NAME_CONVERTER_METADATA_AWARE_ID.'.'.ContainerBuilder::hash($nameConverter);
|
||||
|
||||
if (!$container->hasDefinition($childId)) {
|
||||
$childDefinition = $container->registerChild($childId, self::NAME_CONVERTER_METADATA_AWARE_ID.'.abstract');
|
||||
if (null !== $nameConverter) {
|
||||
$childDefinition->addArgument(new Reference($nameConverter));
|
||||
}
|
||||
}
|
||||
|
||||
return $childId;
|
||||
}
|
||||
|
||||
private function buildChildDefinitions(ContainerBuilder $container, string $serializerName, array $services, array $config): array
|
||||
{
|
||||
foreach ($services as &$id) {
|
||||
$childId = $id.'.'.$serializerName;
|
||||
|
||||
$definition = $container->registerChild($childId, (string) $id)
|
||||
->setClass($container->getDefinition((string) $id)->getClass())
|
||||
;
|
||||
|
||||
if (null !== $nameConverterIndex = $this->findNameConverterIndex($container, (string) $id)) {
|
||||
$definition->replaceArgument($nameConverterIndex, new Reference($config['name_converter']));
|
||||
}
|
||||
|
||||
$id = new Reference($childId);
|
||||
}
|
||||
|
||||
return $services;
|
||||
}
|
||||
|
||||
private function findNameConverterIndex(ContainerBuilder $container, string $id): int|string|null
|
||||
{
|
||||
foreach ($container->getDefinition($id)->getArguments() as $index => $argument) {
|
||||
if ($argument instanceof Reference && self::NAME_CONVERTER_METADATA_AWARE_ID === (string) $argument) {
|
||||
return $index;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
83
backend/vendor/symfony/serializer/Encoder/ChainDecoder.php
vendored
Normal file
83
backend/vendor/symfony/serializer/Encoder/ChainDecoder.php
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Encoder;
|
||||
|
||||
use Symfony\Component\Serializer\Exception\RuntimeException;
|
||||
|
||||
/**
|
||||
* Decoder delegating the decoding to a chain of decoders.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
* @author Lukas Kahwe Smith <smith@pooteeweet.org>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class ChainDecoder implements ContextAwareDecoderInterface
|
||||
{
|
||||
/**
|
||||
* @var array<string, array-key>
|
||||
*/
|
||||
private array $decoderByFormat = [];
|
||||
|
||||
/**
|
||||
* @param array<DecoderInterface> $decoders
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly array $decoders = [],
|
||||
) {
|
||||
}
|
||||
|
||||
final public function decode(string $data, string $format, array $context = []): mixed
|
||||
{
|
||||
return $this->getDecoder($format, $context)->decode($data, $format, $context);
|
||||
}
|
||||
|
||||
public function supportsDecoding(string $format, array $context = []): bool
|
||||
{
|
||||
try {
|
||||
$this->getDecoder($format, $context);
|
||||
} catch (RuntimeException) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the decoder supporting the format.
|
||||
*
|
||||
* @throws RuntimeException if no decoder is found
|
||||
*/
|
||||
private function getDecoder(string $format, array $context): DecoderInterface
|
||||
{
|
||||
if (isset($this->decoderByFormat[$format])
|
||||
&& isset($this->decoders[$this->decoderByFormat[$format]])
|
||||
) {
|
||||
return $this->decoders[$this->decoderByFormat[$format]];
|
||||
}
|
||||
|
||||
$cache = true;
|
||||
foreach ($this->decoders as $i => $decoder) {
|
||||
$cache = $cache && !$decoder instanceof ContextAwareDecoderInterface;
|
||||
if ($decoder->supportsDecoding($format, $context)) {
|
||||
if ($cache) {
|
||||
$this->decoderByFormat[$format] = $i;
|
||||
}
|
||||
|
||||
return $decoder;
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException(\sprintf('No decoder found for format "%s".', $format));
|
||||
}
|
||||
}
|
||||
106
backend/vendor/symfony/serializer/Encoder/ChainEncoder.php
vendored
Normal file
106
backend/vendor/symfony/serializer/Encoder/ChainEncoder.php
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Encoder;
|
||||
|
||||
use Symfony\Component\Serializer\Debug\TraceableEncoder;
|
||||
use Symfony\Component\Serializer\Exception\RuntimeException;
|
||||
|
||||
/**
|
||||
* Encoder delegating the decoding to a chain of encoders.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
* @author Lukas Kahwe Smith <smith@pooteeweet.org>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class ChainEncoder implements ContextAwareEncoderInterface
|
||||
{
|
||||
/**
|
||||
* @var array<string, array-key>
|
||||
*/
|
||||
private array $encoderByFormat = [];
|
||||
|
||||
/**
|
||||
* @param array<EncoderInterface> $encoders
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly array $encoders = [],
|
||||
) {
|
||||
}
|
||||
|
||||
final public function encode(mixed $data, string $format, array $context = []): string
|
||||
{
|
||||
return $this->getEncoder($format, $context)->encode($data, $format, $context);
|
||||
}
|
||||
|
||||
public function supportsEncoding(string $format, array $context = []): bool
|
||||
{
|
||||
try {
|
||||
$this->getEncoder($format, $context);
|
||||
} catch (RuntimeException) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the normalization is needed for the given format.
|
||||
*/
|
||||
public function needsNormalization(string $format, array $context = []): bool
|
||||
{
|
||||
$encoder = $this->getEncoder($format, $context);
|
||||
|
||||
if ($encoder instanceof TraceableEncoder) {
|
||||
return $encoder->needsNormalization();
|
||||
}
|
||||
|
||||
if (!$encoder instanceof NormalizationAwareInterface) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($encoder instanceof self) {
|
||||
return $encoder->needsNormalization($format, $context);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the encoder supporting the format.
|
||||
*
|
||||
* @throws RuntimeException if no encoder is found
|
||||
*/
|
||||
private function getEncoder(string $format, array $context): EncoderInterface
|
||||
{
|
||||
if (isset($this->encoderByFormat[$format])
|
||||
&& isset($this->encoders[$this->encoderByFormat[$format]])
|
||||
) {
|
||||
return $this->encoders[$this->encoderByFormat[$format]];
|
||||
}
|
||||
|
||||
$cache = true;
|
||||
foreach ($this->encoders as $i => $encoder) {
|
||||
$cache = $cache && !$encoder instanceof ContextAwareEncoderInterface;
|
||||
if ($encoder->supportsEncoding($format, $context)) {
|
||||
if ($cache) {
|
||||
$this->encoderByFormat[$format] = $i;
|
||||
}
|
||||
|
||||
return $encoder;
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException(\sprintf('No encoder found for format "%s".', $format));
|
||||
}
|
||||
}
|
||||
25
backend/vendor/symfony/serializer/Encoder/ContextAwareDecoderInterface.php
vendored
Normal file
25
backend/vendor/symfony/serializer/Encoder/ContextAwareDecoderInterface.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Encoder;
|
||||
|
||||
/**
|
||||
* Adds the support of an extra $context parameter for the supportsDecoding method.
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
interface ContextAwareDecoderInterface extends DecoderInterface
|
||||
{
|
||||
/**
|
||||
* @param array $context options that decoders have access to
|
||||
*/
|
||||
public function supportsDecoding(string $format, array $context = []): bool;
|
||||
}
|
||||
25
backend/vendor/symfony/serializer/Encoder/ContextAwareEncoderInterface.php
vendored
Normal file
25
backend/vendor/symfony/serializer/Encoder/ContextAwareEncoderInterface.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Encoder;
|
||||
|
||||
/**
|
||||
* Adds the support of an extra $context parameter for the supportsEncoding method.
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
interface ContextAwareEncoderInterface extends EncoderInterface
|
||||
{
|
||||
/**
|
||||
* @param array $context options that encoders have access to
|
||||
*/
|
||||
public function supportsEncoding(string $format, array $context = []): bool;
|
||||
}
|
||||
296
backend/vendor/symfony/serializer/Encoder/CsvEncoder.php
vendored
Normal file
296
backend/vendor/symfony/serializer/Encoder/CsvEncoder.php
vendored
Normal file
@@ -0,0 +1,296 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Encoder;
|
||||
|
||||
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
|
||||
|
||||
/**
|
||||
* Encodes CSV data.
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
* @author Oliver Hoff <oliver@hofff.com>
|
||||
*/
|
||||
class CsvEncoder implements EncoderInterface, DecoderInterface
|
||||
{
|
||||
public const FORMAT = 'csv';
|
||||
public const DELIMITER_KEY = 'csv_delimiter';
|
||||
public const ENCLOSURE_KEY = 'csv_enclosure';
|
||||
/**
|
||||
* @deprecated since Symfony 7.2, to be removed in 8.0
|
||||
*/
|
||||
public const ESCAPE_CHAR_KEY = 'csv_escape_char';
|
||||
public const KEY_SEPARATOR_KEY = 'csv_key_separator';
|
||||
public const HEADERS_KEY = 'csv_headers';
|
||||
public const ESCAPE_FORMULAS_KEY = 'csv_escape_formulas';
|
||||
public const AS_COLLECTION_KEY = 'as_collection';
|
||||
public const NO_HEADERS_KEY = 'no_headers';
|
||||
public const END_OF_LINE = 'csv_end_of_line';
|
||||
public const OUTPUT_UTF8_BOM_KEY = 'output_utf8_bom';
|
||||
|
||||
private const UTF8_BOM = "\xEF\xBB\xBF";
|
||||
|
||||
private const FORMULAS_START_CHARACTERS = ['=', '-', '+', '@', "\t", "\r", "\n"];
|
||||
|
||||
private array $defaultContext = [
|
||||
self::DELIMITER_KEY => ',',
|
||||
self::ENCLOSURE_KEY => '"',
|
||||
self::ESCAPE_CHAR_KEY => '',
|
||||
self::END_OF_LINE => "\n",
|
||||
self::ESCAPE_FORMULAS_KEY => false,
|
||||
self::HEADERS_KEY => [],
|
||||
self::KEY_SEPARATOR_KEY => '.',
|
||||
self::NO_HEADERS_KEY => false,
|
||||
self::AS_COLLECTION_KEY => true,
|
||||
self::OUTPUT_UTF8_BOM_KEY => false,
|
||||
];
|
||||
|
||||
public function __construct(array $defaultContext = [])
|
||||
{
|
||||
if (\array_key_exists(self::ESCAPE_CHAR_KEY, $defaultContext)) {
|
||||
trigger_deprecation('symfony/serializer', '7.2', 'Setting the "csv_escape_char" option is deprecated. The option will be removed in 8.0.');
|
||||
}
|
||||
|
||||
$this->defaultContext = array_merge($this->defaultContext, $defaultContext);
|
||||
}
|
||||
|
||||
public function encode(mixed $data, string $format, array $context = []): string
|
||||
{
|
||||
$handle = fopen('php://temp,', 'w+');
|
||||
|
||||
if (!is_iterable($data)) {
|
||||
$data = [[$data]];
|
||||
} elseif (!$data) {
|
||||
$data = [[]];
|
||||
} else {
|
||||
if ($data instanceof \Traversable) {
|
||||
// Generators can only be iterated once — convert to array to allow multiple traversals
|
||||
$data = iterator_to_array($data);
|
||||
}
|
||||
// Sequential arrays of arrays are considered as collections
|
||||
$i = 0;
|
||||
foreach ($data as $key => $value) {
|
||||
if ($i !== $key || !\is_array($value)) {
|
||||
$data = [$data];
|
||||
break;
|
||||
}
|
||||
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
|
||||
[$delimiter, $enclosure, $escapeChar, $keySeparator, $headers, $escapeFormulas, $outputBom] = $this->getCsvOptions($context);
|
||||
|
||||
foreach ($data as &$value) {
|
||||
$flattened = [];
|
||||
$this->flatten($value, $flattened, $keySeparator, '', $escapeFormulas);
|
||||
$value = $flattened;
|
||||
}
|
||||
unset($value);
|
||||
|
||||
$headers = array_merge(array_values($headers), array_diff($this->extractHeaders($data), $headers));
|
||||
$endOfLine = $context[self::END_OF_LINE] ?? $this->defaultContext[self::END_OF_LINE];
|
||||
|
||||
if (!($context[self::NO_HEADERS_KEY] ?? $this->defaultContext[self::NO_HEADERS_KEY])) {
|
||||
fputcsv($handle, $headers, $delimiter, $enclosure, $escapeChar);
|
||||
if ("\n" !== $endOfLine && 0 === fseek($handle, -1, \SEEK_CUR)) {
|
||||
fwrite($handle, $endOfLine);
|
||||
}
|
||||
}
|
||||
|
||||
$headers = array_fill_keys($headers, '');
|
||||
foreach ($data as $row) {
|
||||
fputcsv($handle, array_replace($headers, $row), $delimiter, $enclosure, $escapeChar);
|
||||
if ("\n" !== $endOfLine && 0 === fseek($handle, -1, \SEEK_CUR)) {
|
||||
fwrite($handle, $endOfLine);
|
||||
}
|
||||
}
|
||||
|
||||
rewind($handle);
|
||||
$value = stream_get_contents($handle);
|
||||
fclose($handle);
|
||||
|
||||
if ($outputBom) {
|
||||
if (!preg_match('//u', $value)) {
|
||||
throw new UnexpectedValueException('You are trying to add a UTF-8 BOM to a non UTF-8 text.');
|
||||
}
|
||||
|
||||
$value = self::UTF8_BOM.$value;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function supportsEncoding(string $format): bool
|
||||
{
|
||||
return self::FORMAT === $format;
|
||||
}
|
||||
|
||||
public function decode(string $data, string $format, array $context = []): mixed
|
||||
{
|
||||
$handle = fopen('php://temp', 'r+');
|
||||
fwrite($handle, $data);
|
||||
rewind($handle);
|
||||
|
||||
if (str_starts_with($data, self::UTF8_BOM)) {
|
||||
fseek($handle, \strlen(self::UTF8_BOM));
|
||||
}
|
||||
|
||||
$headers = null;
|
||||
$nbHeaders = 0;
|
||||
$headerCount = [];
|
||||
$result = [];
|
||||
|
||||
[$delimiter, $enclosure, $escapeChar, $keySeparator, , , , $asCollection] = $this->getCsvOptions($context);
|
||||
|
||||
while (false !== ($cols = fgetcsv($handle, 0, $delimiter, $enclosure, $escapeChar))) {
|
||||
$nbCols = \count($cols);
|
||||
|
||||
if (null === $headers) {
|
||||
$nbHeaders = $nbCols;
|
||||
|
||||
if ($context[self::NO_HEADERS_KEY] ?? $this->defaultContext[self::NO_HEADERS_KEY]) {
|
||||
for ($i = 0; $i < $nbCols; ++$i) {
|
||||
$headers[] = [$i];
|
||||
}
|
||||
$headerCount = array_fill(0, $nbCols, 1);
|
||||
} else {
|
||||
foreach ($cols as $col) {
|
||||
$header = explode($keySeparator, $col ?? '');
|
||||
$headers[] = $header;
|
||||
$headerCount[] = \count($header);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$item = [];
|
||||
for ($i = 0; ($i < $nbCols) && ($i < $nbHeaders); ++$i) {
|
||||
$depth = $headerCount[$i];
|
||||
$arr = &$item;
|
||||
for ($j = 0; $j < $depth; ++$j) {
|
||||
$headerName = $headers[$i][$j];
|
||||
|
||||
if ('' === $headerName) {
|
||||
$headerName = $i;
|
||||
}
|
||||
|
||||
// Handle nested arrays
|
||||
if ($j === ($depth - 1)) {
|
||||
$arr[$headerName] = $cols[$i];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($arr[$headerName])) {
|
||||
$arr[$headerName] = [];
|
||||
}
|
||||
|
||||
$arr = &$arr[$headerName];
|
||||
}
|
||||
}
|
||||
|
||||
$result[] = $item;
|
||||
}
|
||||
fclose($handle);
|
||||
|
||||
if ($asCollection) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (!$result || isset($result[1])) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
// If there is only one data line in the document, return it (the line), the result is not considered as a collection
|
||||
return $result[0];
|
||||
}
|
||||
|
||||
public function supportsDecoding(string $format): bool
|
||||
{
|
||||
return self::FORMAT === $format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flattens an array and generates keys including the path.
|
||||
*/
|
||||
private function flatten(iterable $array, array &$result, string $keySeparator, string $parentKey = '', bool $escapeFormulas = false): void
|
||||
{
|
||||
foreach ($array as $key => $value) {
|
||||
if (is_iterable($value)) {
|
||||
$this->flatten($value, $result, $keySeparator, $parentKey.$key.$keySeparator, $escapeFormulas);
|
||||
} else {
|
||||
if ($escapeFormulas && \in_array(substr((string) $value, 0, 1), self::FORMULAS_START_CHARACTERS, true)) {
|
||||
$result[$parentKey.$key] = "'".$value;
|
||||
} else {
|
||||
// Ensures an actual value is used when dealing with true and false
|
||||
$result[$parentKey.$key] = false === $value ? 0 : (true === $value ? 1 : $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getCsvOptions(array $context): array
|
||||
{
|
||||
$delimiter = $context[self::DELIMITER_KEY] ?? $this->defaultContext[self::DELIMITER_KEY];
|
||||
$enclosure = $context[self::ENCLOSURE_KEY] ?? $this->defaultContext[self::ENCLOSURE_KEY];
|
||||
$escapeChar = $context[self::ESCAPE_CHAR_KEY] ?? $this->defaultContext[self::ESCAPE_CHAR_KEY];
|
||||
$keySeparator = $context[self::KEY_SEPARATOR_KEY] ?? $this->defaultContext[self::KEY_SEPARATOR_KEY];
|
||||
$headers = $context[self::HEADERS_KEY] ?? $this->defaultContext[self::HEADERS_KEY];
|
||||
$escapeFormulas = $context[self::ESCAPE_FORMULAS_KEY] ?? $this->defaultContext[self::ESCAPE_FORMULAS_KEY];
|
||||
$outputBom = $context[self::OUTPUT_UTF8_BOM_KEY] ?? $this->defaultContext[self::OUTPUT_UTF8_BOM_KEY];
|
||||
$asCollection = $context[self::AS_COLLECTION_KEY] ?? $this->defaultContext[self::AS_COLLECTION_KEY];
|
||||
|
||||
if (!\is_array($headers)) {
|
||||
throw new InvalidArgumentException(\sprintf('The "%s" context variable must be an array or null, given "%s".', self::HEADERS_KEY, get_debug_type($headers)));
|
||||
}
|
||||
|
||||
return [$delimiter, $enclosure, $escapeChar, $keySeparator, $headers, $escapeFormulas, $outputBom, $asCollection];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
private function extractHeaders(iterable $data): array
|
||||
{
|
||||
$headers = [];
|
||||
$flippedHeaders = [];
|
||||
|
||||
foreach ($data as $row) {
|
||||
$previousHeader = null;
|
||||
|
||||
foreach ($row as $header => $_) {
|
||||
if (isset($flippedHeaders[$header])) {
|
||||
$previousHeader = $header;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (null === $previousHeader) {
|
||||
$n = \count($headers);
|
||||
} else {
|
||||
$n = $flippedHeaders[$previousHeader] + 1;
|
||||
|
||||
for ($j = \count($headers); $j > $n; --$j) {
|
||||
++$flippedHeaders[$headers[$j] = $headers[$j - 1]];
|
||||
}
|
||||
}
|
||||
|
||||
$headers[$n] = $header;
|
||||
$flippedHeaders[$header] = $n;
|
||||
$previousHeader = $header;
|
||||
}
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
}
|
||||
43
backend/vendor/symfony/serializer/Encoder/DecoderInterface.php
vendored
Normal file
43
backend/vendor/symfony/serializer/Encoder/DecoderInterface.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Encoder;
|
||||
|
||||
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
|
||||
|
||||
/**
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*/
|
||||
interface DecoderInterface
|
||||
{
|
||||
/**
|
||||
* Decodes a string into PHP data.
|
||||
*
|
||||
* @param string $data Data to decode
|
||||
* @param string $format Format name
|
||||
* @param array $context Options that decoders have access to
|
||||
*
|
||||
* The format parameter specifies which format the data is in; valid values
|
||||
* depend on the specific implementation. Authors implementing this interface
|
||||
* are encouraged to document which formats they support in a non-inherited
|
||||
* phpdoc comment.
|
||||
*
|
||||
* @throws UnexpectedValueException
|
||||
*/
|
||||
public function decode(string $data, string $format, array $context = []): mixed;
|
||||
|
||||
/**
|
||||
* Checks whether the deserializer can decode from given format.
|
||||
*
|
||||
* @param string $format Format name
|
||||
*/
|
||||
public function supportsDecoding(string $format): bool;
|
||||
}
|
||||
38
backend/vendor/symfony/serializer/Encoder/EncoderInterface.php
vendored
Normal file
38
backend/vendor/symfony/serializer/Encoder/EncoderInterface.php
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Encoder;
|
||||
|
||||
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
|
||||
|
||||
/**
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*/
|
||||
interface EncoderInterface
|
||||
{
|
||||
/**
|
||||
* Encodes data into the given format.
|
||||
*
|
||||
* @param mixed $data Data to encode
|
||||
* @param string $format Format name
|
||||
* @param array $context Options that normalizers/encoders have access to
|
||||
*
|
||||
* @throws UnexpectedValueException
|
||||
*/
|
||||
public function encode(mixed $data, string $format, array $context = []): string;
|
||||
|
||||
/**
|
||||
* Checks whether the serializer can encode to given format.
|
||||
*
|
||||
* @param string $format Format name
|
||||
*/
|
||||
public function supportsEncoding(string $format): bool;
|
||||
}
|
||||
119
backend/vendor/symfony/serializer/Encoder/JsonDecode.php
vendored
Normal file
119
backend/vendor/symfony/serializer/Encoder/JsonDecode.php
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Encoder;
|
||||
|
||||
use Seld\JsonLint\JsonParser;
|
||||
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
|
||||
use Symfony\Component\Serializer\Exception\UnsupportedException;
|
||||
|
||||
/**
|
||||
* Decodes JSON data.
|
||||
*
|
||||
* @author Sander Coolen <sander@jibber.nl>
|
||||
*/
|
||||
class JsonDecode implements DecoderInterface
|
||||
{
|
||||
/**
|
||||
* True to return the result as an associative array, false for a nested stdClass hierarchy.
|
||||
*/
|
||||
public const ASSOCIATIVE = 'json_decode_associative';
|
||||
|
||||
/**
|
||||
* True to enable seld/jsonlint as a source for more specific error messages when json_decode fails.
|
||||
*/
|
||||
public const DETAILED_ERROR_MESSAGES = 'json_decode_detailed_errors';
|
||||
|
||||
public const OPTIONS = 'json_decode_options';
|
||||
|
||||
/**
|
||||
* Specifies the recursion depth.
|
||||
*/
|
||||
public const RECURSION_DEPTH = 'json_decode_recursion_depth';
|
||||
|
||||
private array $defaultContext = [
|
||||
self::ASSOCIATIVE => false,
|
||||
self::DETAILED_ERROR_MESSAGES => false,
|
||||
self::OPTIONS => 0,
|
||||
self::RECURSION_DEPTH => 512,
|
||||
];
|
||||
|
||||
public function __construct(array $defaultContext = [])
|
||||
{
|
||||
$this->defaultContext = array_merge($this->defaultContext, $defaultContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes data.
|
||||
*
|
||||
* @param string $data The encoded JSON string to decode
|
||||
* @param string $format Must be set to JsonEncoder::FORMAT
|
||||
* @param array $context An optional set of options for the JSON decoder; see below
|
||||
*
|
||||
* The $context array is a simple key=>value array, with the following supported keys:
|
||||
*
|
||||
* json_decode_associative: boolean
|
||||
* If true, returns the object as an associative array.
|
||||
* If false, returns the object as nested stdClass
|
||||
* If not specified, this method will use the default set in JsonDecode::__construct
|
||||
*
|
||||
* json_decode_recursion_depth: integer
|
||||
* Specifies the maximum recursion depth
|
||||
* If not specified, this method will use the default set in JsonDecode::__construct
|
||||
*
|
||||
* json_decode_options: integer
|
||||
* Specifies additional options as per documentation for json_decode
|
||||
*
|
||||
* json_decode_detailed_errors: bool
|
||||
* If true, enables seld/jsonlint as a source for more specific error messages when json_decode fails.
|
||||
* If false or not specified, this method will use default error messages from PHP's json_decode
|
||||
*
|
||||
* @throws NotEncodableValueException
|
||||
*
|
||||
* @see https://php.net/json_decode
|
||||
*/
|
||||
public function decode(string $data, string $format, array $context = []): mixed
|
||||
{
|
||||
$associative = $context[self::ASSOCIATIVE] ?? $this->defaultContext[self::ASSOCIATIVE];
|
||||
$recursionDepth = $context[self::RECURSION_DEPTH] ?? $this->defaultContext[self::RECURSION_DEPTH];
|
||||
$options = $context[self::OPTIONS] ?? $this->defaultContext[self::OPTIONS];
|
||||
|
||||
try {
|
||||
$decodedData = json_decode($data, $associative, $recursionDepth, $options);
|
||||
} catch (\JsonException $e) {
|
||||
throw new NotEncodableValueException($e->getMessage(), 0, $e);
|
||||
}
|
||||
|
||||
if (\JSON_THROW_ON_ERROR & $options) {
|
||||
return $decodedData;
|
||||
}
|
||||
|
||||
if (\JSON_ERROR_NONE === json_last_error()) {
|
||||
return $decodedData;
|
||||
}
|
||||
$errorMessage = json_last_error_msg();
|
||||
|
||||
if (!($context[self::DETAILED_ERROR_MESSAGES] ?? $this->defaultContext[self::DETAILED_ERROR_MESSAGES])) {
|
||||
throw new NotEncodableValueException($errorMessage);
|
||||
}
|
||||
|
||||
if (!class_exists(JsonParser::class)) {
|
||||
throw new UnsupportedException(\sprintf('Enabling "%s" serializer option requires seld/jsonlint. Try running "composer require seld/jsonlint".', self::DETAILED_ERROR_MESSAGES));
|
||||
}
|
||||
|
||||
throw new NotEncodableValueException((new JsonParser())->lint($data)?->getMessage() ?: $errorMessage);
|
||||
}
|
||||
|
||||
public function supportsDecoding(string $format): bool
|
||||
{
|
||||
return JsonEncoder::FORMAT === $format;
|
||||
}
|
||||
}
|
||||
62
backend/vendor/symfony/serializer/Encoder/JsonEncode.php
vendored
Normal file
62
backend/vendor/symfony/serializer/Encoder/JsonEncode.php
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Encoder;
|
||||
|
||||
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
|
||||
|
||||
/**
|
||||
* Encodes JSON data.
|
||||
*
|
||||
* @author Sander Coolen <sander@jibber.nl>
|
||||
*/
|
||||
class JsonEncode implements EncoderInterface
|
||||
{
|
||||
/**
|
||||
* Configure the JSON flags bitmask.
|
||||
*/
|
||||
public const OPTIONS = 'json_encode_options';
|
||||
|
||||
private array $defaultContext = [
|
||||
self::OPTIONS => \JSON_PRESERVE_ZERO_FRACTION,
|
||||
];
|
||||
|
||||
public function __construct(array $defaultContext = [])
|
||||
{
|
||||
$this->defaultContext = array_merge($this->defaultContext, $defaultContext);
|
||||
}
|
||||
|
||||
public function encode(mixed $data, string $format, array $context = []): string
|
||||
{
|
||||
$options = $context[self::OPTIONS] ?? $this->defaultContext[self::OPTIONS];
|
||||
|
||||
try {
|
||||
$encodedJson = json_encode($data, $options);
|
||||
} catch (\JsonException $e) {
|
||||
throw new NotEncodableValueException($e->getMessage(), 0, $e);
|
||||
}
|
||||
|
||||
if (\JSON_THROW_ON_ERROR & $options) {
|
||||
return $encodedJson;
|
||||
}
|
||||
|
||||
if (\JSON_ERROR_NONE !== json_last_error() && (false === $encodedJson || !($options & \JSON_PARTIAL_OUTPUT_ON_ERROR))) {
|
||||
throw new NotEncodableValueException(json_last_error_msg());
|
||||
}
|
||||
|
||||
return $encodedJson;
|
||||
}
|
||||
|
||||
public function supportsEncoding(string $format): bool
|
||||
{
|
||||
return JsonEncoder::FORMAT === $format;
|
||||
}
|
||||
}
|
||||
60
backend/vendor/symfony/serializer/Encoder/JsonEncoder.php
vendored
Normal file
60
backend/vendor/symfony/serializer/Encoder/JsonEncoder.php
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Encoder;
|
||||
|
||||
/**
|
||||
* Encodes JSON data.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*/
|
||||
class JsonEncoder implements EncoderInterface, DecoderInterface
|
||||
{
|
||||
public const FORMAT = 'json';
|
||||
|
||||
protected JsonEncode $encodingImpl;
|
||||
protected JsonDecode $decodingImpl;
|
||||
|
||||
private array $defaultContext = [
|
||||
JsonDecode::ASSOCIATIVE => true,
|
||||
];
|
||||
|
||||
public function __construct(?JsonEncode $encodingImpl = null, ?JsonDecode $decodingImpl = null, array $defaultContext = [])
|
||||
{
|
||||
$this->defaultContext = array_merge($this->defaultContext, $defaultContext);
|
||||
$this->encodingImpl = $encodingImpl ?? new JsonEncode($this->defaultContext);
|
||||
$this->decodingImpl = $decodingImpl ?? new JsonDecode($this->defaultContext);
|
||||
}
|
||||
|
||||
public function encode(mixed $data, string $format, array $context = []): string
|
||||
{
|
||||
$context = array_merge($this->defaultContext, $context);
|
||||
|
||||
return $this->encodingImpl->encode($data, self::FORMAT, $context);
|
||||
}
|
||||
|
||||
public function decode(string $data, string $format, array $context = []): mixed
|
||||
{
|
||||
$context = array_merge($this->defaultContext, $context);
|
||||
|
||||
return $this->decodingImpl->decode($data, self::FORMAT, $context);
|
||||
}
|
||||
|
||||
public function supportsEncoding(string $format): bool
|
||||
{
|
||||
return self::FORMAT === $format;
|
||||
}
|
||||
|
||||
public function supportsDecoding(string $format): bool
|
||||
{
|
||||
return self::FORMAT === $format;
|
||||
}
|
||||
}
|
||||
24
backend/vendor/symfony/serializer/Encoder/NormalizationAwareInterface.php
vendored
Normal file
24
backend/vendor/symfony/serializer/Encoder/NormalizationAwareInterface.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Encoder;
|
||||
|
||||
/**
|
||||
* Defines the interface of encoders that will normalize data themselves.
|
||||
*
|
||||
* Implementing this interface essentially just tells the Serializer that the
|
||||
* data should not be pre-normalized before being passed to this Encoder.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*/
|
||||
interface NormalizationAwareInterface
|
||||
{
|
||||
}
|
||||
540
backend/vendor/symfony/serializer/Encoder/XmlEncoder.php
vendored
Normal file
540
backend/vendor/symfony/serializer/Encoder/XmlEncoder.php
vendored
Normal file
@@ -0,0 +1,540 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Encoder;
|
||||
|
||||
use Symfony\Component\Serializer\Exception\BadMethodCallException;
|
||||
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
|
||||
use Symfony\Component\Serializer\SerializerAwareInterface;
|
||||
use Symfony\Component\Serializer\SerializerAwareTrait;
|
||||
|
||||
/**
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @author John Wards <jwards@whiteoctober.co.uk>
|
||||
* @author Fabian Vogler <fabian@equivalence.ch>
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
* @author Dany Maillard <danymaillard93b@gmail.com>
|
||||
*/
|
||||
class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwareInterface, SerializerAwareInterface
|
||||
{
|
||||
use SerializerAwareTrait;
|
||||
|
||||
public const FORMAT = 'xml';
|
||||
|
||||
public const AS_COLLECTION = 'as_collection';
|
||||
|
||||
/**
|
||||
* An array of ignored XML node types while decoding, each one of the DOM Predefined XML_* constants.
|
||||
*/
|
||||
public const DECODER_IGNORED_NODE_TYPES = 'decoder_ignored_node_types';
|
||||
|
||||
/**
|
||||
* An array of ignored XML node types while encoding, each one of the DOM Predefined XML_* constants.
|
||||
*/
|
||||
public const ENCODER_IGNORED_NODE_TYPES = 'encoder_ignored_node_types';
|
||||
public const ENCODING = 'xml_encoding';
|
||||
public const FORMAT_OUTPUT = 'xml_format_output';
|
||||
|
||||
/**
|
||||
* A bit field of LIBXML_* constants for loading XML documents.
|
||||
*/
|
||||
public const LOAD_OPTIONS = 'load_options';
|
||||
|
||||
/**
|
||||
* A bit field of LIBXML_* constants for saving XML documents.
|
||||
*/
|
||||
public const SAVE_OPTIONS = 'save_options';
|
||||
|
||||
public const REMOVE_EMPTY_TAGS = 'remove_empty_tags';
|
||||
public const ROOT_NODE_NAME = 'xml_root_node_name';
|
||||
public const STANDALONE = 'xml_standalone';
|
||||
public const TYPE_CAST_ATTRIBUTES = 'xml_type_cast_attributes';
|
||||
public const VERSION = 'xml_version';
|
||||
public const CDATA_WRAPPING = 'cdata_wrapping';
|
||||
public const CDATA_WRAPPING_NAME_PATTERN = 'cdata_wrapping_name_pattern';
|
||||
public const CDATA_WRAPPING_PATTERN = 'cdata_wrapping_pattern';
|
||||
public const IGNORE_EMPTY_ATTRIBUTES = 'ignore_empty_attributes';
|
||||
public const PRESERVE_NUMERIC_KEYS = 'preserve_numeric_keys';
|
||||
|
||||
private array $defaultContext = [
|
||||
self::AS_COLLECTION => false,
|
||||
self::DECODER_IGNORED_NODE_TYPES => [\XML_PI_NODE, \XML_COMMENT_NODE],
|
||||
self::ENCODER_IGNORED_NODE_TYPES => [],
|
||||
self::LOAD_OPTIONS => \LIBXML_NONET | \LIBXML_NOBLANKS,
|
||||
self::SAVE_OPTIONS => 0,
|
||||
self::REMOVE_EMPTY_TAGS => false,
|
||||
self::ROOT_NODE_NAME => 'response',
|
||||
self::TYPE_CAST_ATTRIBUTES => true,
|
||||
self::CDATA_WRAPPING => true,
|
||||
self::CDATA_WRAPPING_NAME_PATTERN => false,
|
||||
self::CDATA_WRAPPING_PATTERN => '/[<>&]/',
|
||||
self::IGNORE_EMPTY_ATTRIBUTES => false,
|
||||
self::PRESERVE_NUMERIC_KEYS => false,
|
||||
];
|
||||
|
||||
public function __construct(array $defaultContext = [])
|
||||
{
|
||||
$this->defaultContext = array_merge($this->defaultContext, $defaultContext);
|
||||
}
|
||||
|
||||
public function encode(mixed $data, string $format, array $context = []): string
|
||||
{
|
||||
$encoderIgnoredNodeTypes = $context[self::ENCODER_IGNORED_NODE_TYPES] ?? $this->defaultContext[self::ENCODER_IGNORED_NODE_TYPES];
|
||||
$ignorePiNode = \in_array(\XML_PI_NODE, $encoderIgnoredNodeTypes, true);
|
||||
if ($data instanceof \DOMDocument) {
|
||||
return $this->saveXml($data, $ignorePiNode ? $data->documentElement : null);
|
||||
}
|
||||
|
||||
$xmlRootNodeName = $context[self::ROOT_NODE_NAME] ?? $this->defaultContext[self::ROOT_NODE_NAME];
|
||||
|
||||
$dom = $this->createDomDocument($context);
|
||||
|
||||
if (null !== $data && !\is_scalar($data)) {
|
||||
$root = $dom->createElement($xmlRootNodeName);
|
||||
$dom->appendChild($root);
|
||||
$this->buildXml($root, $data, $format, $context, $xmlRootNodeName);
|
||||
} else {
|
||||
$this->appendNode($dom, $data, $format, $context, $xmlRootNodeName);
|
||||
}
|
||||
|
||||
return $this->saveXml($dom, $ignorePiNode ? $dom->documentElement : null, $context[self::SAVE_OPTIONS] ?? $this->defaultContext[self::SAVE_OPTIONS]);
|
||||
}
|
||||
|
||||
public function decode(string $data, string $format, array $context = []): mixed
|
||||
{
|
||||
if ('' === trim($data)) {
|
||||
throw new NotEncodableValueException('Invalid XML data, it cannot be empty.');
|
||||
}
|
||||
|
||||
$internalErrors = libxml_use_internal_errors(true);
|
||||
libxml_clear_errors();
|
||||
|
||||
$dom = new \DOMDocument();
|
||||
$dom->loadXML($data, $context[self::LOAD_OPTIONS] ?? $this->defaultContext[self::LOAD_OPTIONS]);
|
||||
|
||||
libxml_use_internal_errors($internalErrors);
|
||||
|
||||
if ($error = libxml_get_last_error()) {
|
||||
libxml_clear_errors();
|
||||
|
||||
throw new NotEncodableValueException($error->message);
|
||||
}
|
||||
|
||||
$rootNode = null;
|
||||
$decoderIgnoredNodeTypes = $context[self::DECODER_IGNORED_NODE_TYPES] ?? $this->defaultContext[self::DECODER_IGNORED_NODE_TYPES];
|
||||
foreach ($dom->childNodes as $child) {
|
||||
if (\in_array($child->nodeType, $decoderIgnoredNodeTypes, true)) {
|
||||
continue;
|
||||
}
|
||||
if (\XML_DOCUMENT_TYPE_NODE === $child->nodeType) {
|
||||
throw new NotEncodableValueException('Document types are not allowed.');
|
||||
}
|
||||
if (!$rootNode) {
|
||||
$rootNode = $child;
|
||||
}
|
||||
}
|
||||
|
||||
// todo: throw an exception if the root node name is not correctly configured (bc)
|
||||
|
||||
if ($rootNode->hasChildNodes()) {
|
||||
$data = $this->parseXml($rootNode, $context);
|
||||
if (\is_array($data)) {
|
||||
$data = $this->addXmlNamespaces($data, $rootNode, $dom);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
if (!$rootNode->hasAttributes()) {
|
||||
return $rootNode->nodeValue;
|
||||
}
|
||||
|
||||
$data = array_merge($this->parseXmlAttributes($rootNode, $context), ['#' => $rootNode->nodeValue]);
|
||||
|
||||
return $this->addXmlNamespaces($data, $rootNode, $dom);
|
||||
}
|
||||
|
||||
public function supportsEncoding(string $format): bool
|
||||
{
|
||||
return self::FORMAT === $format;
|
||||
}
|
||||
|
||||
public function supportsDecoding(string $format): bool
|
||||
{
|
||||
return self::FORMAT === $format;
|
||||
}
|
||||
|
||||
final protected function appendXMLString(\DOMNode $node, string $val): bool
|
||||
{
|
||||
if ('' !== $val) {
|
||||
$frag = $node->ownerDocument->createDocumentFragment();
|
||||
$frag->appendXML($val);
|
||||
$node->appendChild($frag);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
final protected function appendText(\DOMNode $node, string $val): bool
|
||||
{
|
||||
$nodeText = $node->ownerDocument->createTextNode($val);
|
||||
$node->appendChild($nodeText);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
final protected function appendCData(\DOMNode $node, string $val): bool
|
||||
{
|
||||
$nodeText = $node->ownerDocument->createCDATASection($val);
|
||||
$node->appendChild($nodeText);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
final protected function appendDocumentFragment(\DOMNode $node, \DOMDocumentFragment $fragment): bool
|
||||
{
|
||||
$node->appendChild($fragment);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
final protected function appendComment(\DOMNode $node, string $data): bool
|
||||
{
|
||||
$node->appendChild($node->ownerDocument->createComment($data));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the name is a valid xml element name.
|
||||
*/
|
||||
final protected function isElementNameValid(string $name): bool
|
||||
{
|
||||
return $name
|
||||
&& !str_contains($name, ' ')
|
||||
&& preg_match('#^[\pL_][\pL0-9._:-]*$#ui', $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the input DOMNode into an array or a string.
|
||||
*/
|
||||
private function parseXml(\DOMNode $node, array $context = []): array|string
|
||||
{
|
||||
$data = $this->parseXmlAttributes($node, $context);
|
||||
|
||||
$value = $this->parseXmlValue($node, $context);
|
||||
|
||||
if (!\count($data)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (!\is_array($value)) {
|
||||
$data['#'] = $value;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
if (1 === \count($value) && key($value)) {
|
||||
$data[key($value)] = current($value);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
foreach ($value as $key => $val) {
|
||||
$data[$key] = $val;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the input DOMNode attributes into an array.
|
||||
*/
|
||||
private function parseXmlAttributes(\DOMNode $node, array $context = []): array
|
||||
{
|
||||
if (!$node->hasAttributes()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$typeCastAttributes = (bool) ($context[self::TYPE_CAST_ATTRIBUTES] ?? $this->defaultContext[self::TYPE_CAST_ATTRIBUTES]);
|
||||
|
||||
foreach ($node->attributes as $attr) {
|
||||
if (!is_numeric($attr->nodeValue) || !$typeCastAttributes || (isset($attr->nodeValue[1]) && '0' === $attr->nodeValue[0] && '.' !== $attr->nodeValue[1])) {
|
||||
$data['@'.$attr->nodeName] = $attr->nodeValue;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (false !== $val = filter_var($attr->nodeValue, \FILTER_VALIDATE_INT)) {
|
||||
$data['@'.$attr->nodeName] = $val;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$data['@'.$attr->nodeName] = (float) $attr->nodeValue;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the input DOMNode value (content and children) into an array or a string.
|
||||
*/
|
||||
private function parseXmlValue(\DOMNode $node, array $context = []): array|string
|
||||
{
|
||||
if (!$node->hasChildNodes()) {
|
||||
return $node->nodeValue;
|
||||
}
|
||||
|
||||
if (1 === $node->childNodes->length && \in_array($node->firstChild->nodeType, [\XML_TEXT_NODE, \XML_CDATA_SECTION_NODE], true)) {
|
||||
return $node->firstChild->nodeValue;
|
||||
}
|
||||
|
||||
$value = [];
|
||||
$decoderIgnoredNodeTypes = $context[self::DECODER_IGNORED_NODE_TYPES] ?? $this->defaultContext[self::DECODER_IGNORED_NODE_TYPES];
|
||||
foreach ($node->childNodes as $subnode) {
|
||||
if (\in_array($subnode->nodeType, $decoderIgnoredNodeTypes, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$val = $this->parseXml($subnode, $context);
|
||||
|
||||
if ('item' === $subnode->nodeName && isset($val['@key'])) {
|
||||
$value[$val['@key']] = $val['#'] ?? $val;
|
||||
} else {
|
||||
$value[$subnode->nodeName][] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
$asCollection = $context[self::AS_COLLECTION] ?? $this->defaultContext[self::AS_COLLECTION];
|
||||
foreach ($value as $key => $val) {
|
||||
if (!$asCollection && \is_array($val) && 1 === \count($val)) {
|
||||
$value[$key] = current($val);
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
private function addXmlNamespaces(array $data, \DOMNode $node, \DOMDocument $document): array
|
||||
{
|
||||
$xpath = new \DOMXPath($document);
|
||||
|
||||
foreach ($xpath->query('namespace::*', $node) as $nsNode) {
|
||||
$data['@'.$nsNode->nodeName] = $nsNode->nodeValue;
|
||||
}
|
||||
|
||||
unset($data['@xmlns:xml']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the data and convert it to DOMElements.
|
||||
*
|
||||
* @throws NotEncodableValueException
|
||||
*/
|
||||
private function buildXml(\DOMNode $parentNode, mixed $data, string $format, array $context, ?string $xmlRootNodeName = null): bool
|
||||
{
|
||||
$append = true;
|
||||
$removeEmptyTags = $context[self::REMOVE_EMPTY_TAGS] ?? $this->defaultContext[self::REMOVE_EMPTY_TAGS] ?? false;
|
||||
$preserveNumericKeys = $context[self::PRESERVE_NUMERIC_KEYS] ?? $this->defaultContext[self::PRESERVE_NUMERIC_KEYS] ?? false;
|
||||
$encoderIgnoredNodeTypes = $context[self::ENCODER_IGNORED_NODE_TYPES] ?? $this->defaultContext[self::ENCODER_IGNORED_NODE_TYPES];
|
||||
|
||||
if (\is_array($data) || ($data instanceof \Traversable && (null === $this->serializer || !$this->serializer->supportsNormalization($data, $format)))) {
|
||||
foreach ($data as $key => $data) {
|
||||
// Ah this is the magic @ attribute types.
|
||||
if (str_starts_with($key, '@') && $this->isElementNameValid($attributeName = substr($key, 1))) {
|
||||
if (!\is_scalar($data)) {
|
||||
$data = $this->serializer->normalize($data, $format, $context);
|
||||
}
|
||||
if (\is_bool($data)) {
|
||||
$data = (int) $data;
|
||||
}
|
||||
|
||||
if ($context[self::IGNORE_EMPTY_ATTRIBUTES] ?? $this->defaultContext[self::IGNORE_EMPTY_ATTRIBUTES]) {
|
||||
if (null === $data || '' === $data) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$parentNode->setAttribute($attributeName, $data);
|
||||
} elseif ('#' === $key) {
|
||||
$append = $this->selectNodeType($parentNode, $data, $format, $context);
|
||||
} elseif ('#comment' === $key) {
|
||||
if (!\in_array(\XML_COMMENT_NODE, $encoderIgnoredNodeTypes, true)) {
|
||||
$append = $this->appendComment($parentNode, $data);
|
||||
}
|
||||
} elseif (\is_array($data) && !is_numeric($key)) {
|
||||
// Is this array fully numeric keys?
|
||||
if (!$preserveNumericKeys && $data && null === array_find_key($data, static fn ($v, $k) => \is_string($k))) {
|
||||
/*
|
||||
* Create nodes to append to $parentNode based on the $key of this array
|
||||
* Produces <xml><item>0</item><item>1</item></xml>
|
||||
* From ["item" => [0,1]];.
|
||||
*/
|
||||
foreach ($data as $subData) {
|
||||
$append = $this->appendNode($parentNode, $subData, $format, $context, $key);
|
||||
}
|
||||
} else {
|
||||
$append = $this->appendNode($parentNode, $data, $format, $context, $key);
|
||||
}
|
||||
} elseif (is_numeric($key) || !$this->isElementNameValid($key)) {
|
||||
$append = $this->appendNode($parentNode, $data, $format, $context, 'item', $key);
|
||||
} elseif (null !== $data || !$removeEmptyTags) {
|
||||
$append = $this->appendNode($parentNode, $data, $format, $context, $key);
|
||||
}
|
||||
}
|
||||
|
||||
return $append;
|
||||
}
|
||||
|
||||
if (\is_object($data)) {
|
||||
if (null === $this->serializer) {
|
||||
throw new BadMethodCallException(\sprintf('The serializer needs to be set to allow "%s()" to be used with object data.', __METHOD__));
|
||||
}
|
||||
|
||||
$data = $this->serializer->normalize($data, $format, $context);
|
||||
if (null !== $data && !\is_scalar($data)) {
|
||||
return $this->buildXml($parentNode, $data, $format, $context, $xmlRootNodeName);
|
||||
}
|
||||
|
||||
// top level data object was normalized into a scalar
|
||||
if (!$parentNode->parentNode->parentNode) {
|
||||
$root = $parentNode->parentNode;
|
||||
$root->removeChild($parentNode);
|
||||
|
||||
return $this->appendNode($root, $data, $format, $context, $xmlRootNodeName);
|
||||
}
|
||||
|
||||
return $this->appendNode($parentNode, $data, $format, $context, 'data');
|
||||
}
|
||||
|
||||
throw new NotEncodableValueException('An unexpected value could not be serialized: '.(!\is_resource($data) ? var_export($data, true) : \sprintf('%s resource', get_resource_type($data))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects the type of node to create and appends it to the parent.
|
||||
*/
|
||||
private function appendNode(\DOMNode $parentNode, mixed $data, string $format, array $context, string $nodeName, ?string $key = null): bool
|
||||
{
|
||||
$dom = $parentNode instanceof \DOMDocument ? $parentNode : $parentNode->ownerDocument;
|
||||
$node = $dom->createElement($nodeName);
|
||||
if (null !== $key) {
|
||||
$node->setAttribute('key', $key);
|
||||
}
|
||||
$appendNode = $this->selectNodeType($node, $data, $format, $context);
|
||||
// we may have decided not to append this node, either in error or if its $nodeName is not valid
|
||||
if ($appendNode) {
|
||||
$parentNode->appendChild($node);
|
||||
}
|
||||
|
||||
return $appendNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a value contains any characters which would require CDATA wrapping.
|
||||
*
|
||||
* @param array<string, mixed> $context
|
||||
*/
|
||||
private function needsCdataWrapping(string $name, string $val, array $context): bool
|
||||
{
|
||||
return ($context[self::CDATA_WRAPPING] ?? $this->defaultContext[self::CDATA_WRAPPING])
|
||||
&& (preg_match($context[self::CDATA_WRAPPING_PATTERN] ?? $this->defaultContext[self::CDATA_WRAPPING_PATTERN], $val)
|
||||
|| (($context[self::CDATA_WRAPPING_NAME_PATTERN] ?? $this->defaultContext[self::CDATA_WRAPPING_NAME_PATTERN]) && preg_match($context[self::CDATA_WRAPPING_NAME_PATTERN] ?? $this->defaultContext[self::CDATA_WRAPPING_NAME_PATTERN], $name))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the value being passed and decide what sort of element to create.
|
||||
*
|
||||
* @throws NotEncodableValueException
|
||||
*/
|
||||
private function selectNodeType(\DOMNode $node, mixed $val, string $format, array $context): bool
|
||||
{
|
||||
if (\is_array($val)) {
|
||||
return $this->buildXml($node, $val, $format, $context);
|
||||
} elseif ($val instanceof \SimpleXMLElement) {
|
||||
$child = $node->ownerDocument->importNode(dom_import_simplexml($val), true);
|
||||
$node->appendChild($child);
|
||||
} elseif ($val instanceof \Traversable) {
|
||||
$this->buildXml($node, $val, $format, $context);
|
||||
} elseif ($val instanceof \DOMNode) {
|
||||
$child = $node->ownerDocument->importNode($val, true);
|
||||
$node->appendChild($child);
|
||||
} elseif (\is_object($val)) {
|
||||
if (null === $this->serializer) {
|
||||
throw new BadMethodCallException(\sprintf('The serializer needs to be set to allow "%s()" to be used with object data.', __METHOD__));
|
||||
}
|
||||
|
||||
return $this->selectNodeType($node, $this->serializer->normalize($val, $format, $context), $format, $context);
|
||||
} elseif (is_numeric($val)) {
|
||||
return $this->appendText($node, is_nan($val) ? 'NAN' : (string) $val);
|
||||
} elseif (\is_string($val) && $this->needsCdataWrapping($node->nodeName, $val, $context)) {
|
||||
return $this->appendCData($node, $val);
|
||||
} elseif (\is_string($val)) {
|
||||
return $this->appendText($node, $val);
|
||||
} elseif (\is_bool($val)) {
|
||||
return $this->appendText($node, (int) $val);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a DOM document, taking serializer options into account.
|
||||
*/
|
||||
private function createDomDocument(array $context): \DOMDocument
|
||||
{
|
||||
$document = new \DOMDocument();
|
||||
|
||||
// Set an attribute on the DOM document specifying, as part of the XML declaration,
|
||||
$xmlOptions = [
|
||||
// nicely formats output with indentation and extra space
|
||||
self::FORMAT_OUTPUT => 'formatOutput',
|
||||
// the version number of the document
|
||||
self::VERSION => 'xmlVersion',
|
||||
// the encoding of the document
|
||||
self::ENCODING => 'encoding',
|
||||
// whether the document is standalone
|
||||
self::STANDALONE => 'xmlStandalone',
|
||||
];
|
||||
foreach ($xmlOptions as $xmlOption => $documentProperty) {
|
||||
if ($contextOption = $context[$xmlOption] ?? $this->defaultContext[$xmlOption] ?? false) {
|
||||
$document->$documentProperty = $contextOption;
|
||||
}
|
||||
}
|
||||
|
||||
return $document;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws NotEncodableValueException
|
||||
*/
|
||||
private function saveXml(\DOMDocument $document, ?\DOMNode $node = null, ?int $options = null): string
|
||||
{
|
||||
$prevErrorHandler = set_error_handler(static function ($type, $message, $file, $line, $context = []) use (&$prevErrorHandler) {
|
||||
if (\E_ERROR === $type || \E_WARNING === $type) {
|
||||
throw new NotEncodableValueException($message);
|
||||
}
|
||||
|
||||
return $prevErrorHandler ? $prevErrorHandler($type, $message, $file, $line, $context) : false;
|
||||
});
|
||||
try {
|
||||
return $document->saveXML($node, $options);
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
}
|
||||
}
|
||||
}
|
||||
101
backend/vendor/symfony/serializer/Encoder/YamlEncoder.php
vendored
Normal file
101
backend/vendor/symfony/serializer/Encoder/YamlEncoder.php
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Encoder;
|
||||
|
||||
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
|
||||
use Symfony\Component\Serializer\Exception\RuntimeException;
|
||||
use Symfony\Component\Yaml\Dumper;
|
||||
use Symfony\Component\Yaml\Exception\ParseException;
|
||||
use Symfony\Component\Yaml\Parser;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
/**
|
||||
* Encodes YAML data.
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class YamlEncoder implements EncoderInterface, DecoderInterface
|
||||
{
|
||||
public const FORMAT = 'yaml';
|
||||
private const ALTERNATIVE_FORMAT = 'yml';
|
||||
|
||||
public const PRESERVE_EMPTY_OBJECTS = 'preserve_empty_objects';
|
||||
|
||||
/**
|
||||
* Override the amount of spaces to use for indentation of nested nodes.
|
||||
*
|
||||
* This option only works in the constructor, not in calls to `encode`.
|
||||
*/
|
||||
public const YAML_INDENTATION = 'yaml_indentation';
|
||||
|
||||
public const YAML_INLINE = 'yaml_inline';
|
||||
/**
|
||||
* Initial indentation for root element.
|
||||
*/
|
||||
public const YAML_INDENT = 'yaml_indent';
|
||||
public const YAML_FLAGS = 'yaml_flags';
|
||||
|
||||
private readonly Dumper $dumper;
|
||||
private readonly Parser $parser;
|
||||
private array $defaultContext = [
|
||||
self::YAML_INLINE => 0,
|
||||
self::YAML_INDENT => 0,
|
||||
self::YAML_FLAGS => 0,
|
||||
];
|
||||
|
||||
public function __construct(?Dumper $dumper = null, ?Parser $parser = null, array $defaultContext = [])
|
||||
{
|
||||
if (!class_exists(Dumper::class)) {
|
||||
throw new RuntimeException('The YamlEncoder class requires the "Yaml" component. Try running "composer require symfony/yaml".');
|
||||
}
|
||||
|
||||
if (!$dumper) {
|
||||
$dumper = \array_key_exists(self::YAML_INDENTATION, $defaultContext) ? new Dumper($defaultContext[self::YAML_INDENTATION]) : new Dumper();
|
||||
}
|
||||
$this->dumper = $dumper;
|
||||
$this->parser = $parser ?? new Parser();
|
||||
unset($defaultContext[self::YAML_INDENTATION]);
|
||||
$this->defaultContext = array_merge($this->defaultContext, $defaultContext);
|
||||
}
|
||||
|
||||
public function encode(mixed $data, string $format, array $context = []): string
|
||||
{
|
||||
$context = array_merge($this->defaultContext, $context);
|
||||
|
||||
if ($context[self::PRESERVE_EMPTY_OBJECTS] ?? false) {
|
||||
$context[self::YAML_FLAGS] |= Yaml::DUMP_OBJECT_AS_MAP;
|
||||
}
|
||||
|
||||
return $this->dumper->dump($data, $context[self::YAML_INLINE], $context[self::YAML_INDENT], $context[self::YAML_FLAGS]);
|
||||
}
|
||||
|
||||
public function supportsEncoding(string $format): bool
|
||||
{
|
||||
return self::FORMAT === $format || self::ALTERNATIVE_FORMAT === $format;
|
||||
}
|
||||
|
||||
public function decode(string $data, string $format, array $context = []): mixed
|
||||
{
|
||||
$context = array_merge($this->defaultContext, $context);
|
||||
|
||||
try {
|
||||
return $this->parser->parse($data, $context[self::YAML_FLAGS]);
|
||||
} catch (ParseException $e) {
|
||||
throw new NotEncodableValueException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
public function supportsDecoding(string $format): bool
|
||||
{
|
||||
return self::FORMAT === $format || self::ALTERNATIVE_FORMAT === $format;
|
||||
}
|
||||
}
|
||||
16
backend/vendor/symfony/serializer/Exception/BadMethodCallException.php
vendored
Normal file
16
backend/vendor/symfony/serializer/Exception/BadMethodCallException.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Exception;
|
||||
|
||||
class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
21
backend/vendor/symfony/serializer/Exception/CircularReferenceException.php
vendored
Normal file
21
backend/vendor/symfony/serializer/Exception/CircularReferenceException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Exception;
|
||||
|
||||
/**
|
||||
* CircularReferenceException.
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class CircularReferenceException extends RuntimeException
|
||||
{
|
||||
}
|
||||
21
backend/vendor/symfony/serializer/Exception/ExceptionInterface.php
vendored
Normal file
21
backend/vendor/symfony/serializer/Exception/ExceptionInterface.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Exception;
|
||||
|
||||
/**
|
||||
* Base exception interface.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
interface ExceptionInterface extends \Throwable
|
||||
{
|
||||
}
|
||||
37
backend/vendor/symfony/serializer/Exception/ExtraAttributesException.php
vendored
Normal file
37
backend/vendor/symfony/serializer/Exception/ExtraAttributesException.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Exception;
|
||||
|
||||
/**
|
||||
* ExtraAttributesException.
|
||||
*
|
||||
* @author Julien DIDIER <julien@didier.io>
|
||||
*/
|
||||
class ExtraAttributesException extends RuntimeException
|
||||
{
|
||||
public function __construct(
|
||||
private readonly array $extraAttributes,
|
||||
?\Throwable $previous = null,
|
||||
) {
|
||||
$msg = \sprintf('Extra attributes are not allowed ("%s" %s unknown).', implode('", "', $extraAttributes), \count($extraAttributes) > 1 ? 'are' : 'is');
|
||||
|
||||
parent::__construct($msg, 0, $previous);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the extra attributes that are not allowed.
|
||||
*/
|
||||
public function getExtraAttributes(): array
|
||||
{
|
||||
return $this->extraAttributes;
|
||||
}
|
||||
}
|
||||
21
backend/vendor/symfony/serializer/Exception/InvalidArgumentException.php
vendored
Normal file
21
backend/vendor/symfony/serializer/Exception/InvalidArgumentException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Exception;
|
||||
|
||||
/**
|
||||
* InvalidArgumentException.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
21
backend/vendor/symfony/serializer/Exception/LogicException.php
vendored
Normal file
21
backend/vendor/symfony/serializer/Exception/LogicException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Exception;
|
||||
|
||||
/**
|
||||
* LogicException.
|
||||
*
|
||||
* @author Lukas Kahwe Smith <smith@pooteeweet.org>
|
||||
*/
|
||||
class LogicException extends \LogicException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
21
backend/vendor/symfony/serializer/Exception/MappingException.php
vendored
Normal file
21
backend/vendor/symfony/serializer/Exception/MappingException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Exception;
|
||||
|
||||
/**
|
||||
* MappingException.
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class MappingException extends RuntimeException
|
||||
{
|
||||
}
|
||||
48
backend/vendor/symfony/serializer/Exception/MissingConstructorArgumentsException.php
vendored
Normal file
48
backend/vendor/symfony/serializer/Exception/MissingConstructorArgumentsException.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Exception;
|
||||
|
||||
/**
|
||||
* @author Maxime VEBER <maxime.veber@nekland.fr>
|
||||
*/
|
||||
class MissingConstructorArgumentsException extends RuntimeException
|
||||
{
|
||||
/**
|
||||
* @param string[] $missingArguments
|
||||
* @param class-string|null $class
|
||||
*/
|
||||
public function __construct(
|
||||
string $message,
|
||||
int $code = 0,
|
||||
?\Throwable $previous = null,
|
||||
private array $missingArguments = [],
|
||||
private ?string $class = null,
|
||||
) {
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getMissingConstructorArguments(): array
|
||||
{
|
||||
return $this->missingArguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class-string|null
|
||||
*/
|
||||
public function getClass(): ?string
|
||||
{
|
||||
return $this->class;
|
||||
}
|
||||
}
|
||||
19
backend/vendor/symfony/serializer/Exception/NotEncodableValueException.php
vendored
Normal file
19
backend/vendor/symfony/serializer/Exception/NotEncodableValueException.php
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Exception;
|
||||
|
||||
/**
|
||||
* @author Christian Flothmann <christian.flothmann@sensiolabs.de>
|
||||
*/
|
||||
class NotEncodableValueException extends UnexpectedValueException
|
||||
{
|
||||
}
|
||||
70
backend/vendor/symfony/serializer/Exception/NotNormalizableValueException.php
vendored
Normal file
70
backend/vendor/symfony/serializer/Exception/NotNormalizableValueException.php
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Exception;
|
||||
|
||||
/**
|
||||
* @author Christian Flothmann <christian.flothmann@sensiolabs.de>
|
||||
*/
|
||||
class NotNormalizableValueException extends UnexpectedValueException
|
||||
{
|
||||
private ?string $currentType = null;
|
||||
private ?array $expectedTypes = null;
|
||||
private ?string $path = null;
|
||||
private bool $useMessageForUser = false;
|
||||
|
||||
/**
|
||||
* @param list<string|\Stringable>|null $expectedTypes
|
||||
*/
|
||||
public function __construct(string $message = '', int $code = 0, ?\Throwable $previous = null, ?string $currentType = null, ?array $expectedTypes = null, ?string $path = null, bool $useMessageForUser = false)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
|
||||
$this->currentType = $currentType;
|
||||
$this->expectedTypes = $expectedTypes ? array_map(strval(...), $expectedTypes) : $expectedTypes;
|
||||
$this->path = $path;
|
||||
$this->useMessageForUser = $useMessageForUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string|\Stringable> $expectedTypes
|
||||
* @param bool $useMessageForUser If the message passed to this exception is something that can be shown
|
||||
* safely to your user. In other words, avoid catching other exceptions and
|
||||
* passing their message directly to this class.
|
||||
*/
|
||||
public static function createForUnexpectedDataType(string $message, mixed $data, array $expectedTypes, ?string $path = null, bool $useMessageForUser = false, int $code = 0, ?\Throwable $previous = null): self
|
||||
{
|
||||
return new self($message, $code, $previous, get_debug_type($data), $expectedTypes, $path, $useMessageForUser);
|
||||
}
|
||||
|
||||
public function getCurrentType(): ?string
|
||||
{
|
||||
return $this->currentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]|null
|
||||
*/
|
||||
public function getExpectedTypes(): ?array
|
||||
{
|
||||
return $this->expectedTypes;
|
||||
}
|
||||
|
||||
public function getPath(): ?string
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function canUseMessageForUser(): ?bool
|
||||
{
|
||||
return $this->useMessageForUser;
|
||||
}
|
||||
}
|
||||
40
backend/vendor/symfony/serializer/Exception/PartialDenormalizationException.php
vendored
Normal file
40
backend/vendor/symfony/serializer/Exception/PartialDenormalizationException.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Exception;
|
||||
|
||||
/**
|
||||
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
||||
*/
|
||||
class PartialDenormalizationException extends UnexpectedValueException
|
||||
{
|
||||
/**
|
||||
* @param NotNormalizableValueException[] $errors
|
||||
*/
|
||||
public function __construct(
|
||||
private mixed $data,
|
||||
private array $errors,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getData(): mixed
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return NotNormalizableValueException[]
|
||||
*/
|
||||
public function getErrors(): array
|
||||
{
|
||||
return $this->errors;
|
||||
}
|
||||
}
|
||||
21
backend/vendor/symfony/serializer/Exception/RuntimeException.php
vendored
Normal file
21
backend/vendor/symfony/serializer/Exception/RuntimeException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Exception;
|
||||
|
||||
/**
|
||||
* RuntimeException.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class RuntimeException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
29
backend/vendor/symfony/serializer/Exception/UnexpectedPropertyException.php
vendored
Normal file
29
backend/vendor/symfony/serializer/Exception/UnexpectedPropertyException.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Exception;
|
||||
|
||||
/**
|
||||
* UnexpectedPropertyException.
|
||||
*
|
||||
* @author Aurélien Pillevesse <aurelienpillevesse@hotmail.fr>
|
||||
*/
|
||||
class UnexpectedPropertyException extends \UnexpectedValueException implements ExceptionInterface
|
||||
{
|
||||
public function __construct(
|
||||
public readonly string $property,
|
||||
?\Throwable $previous = null,
|
||||
) {
|
||||
$msg = \sprintf('Property is not allowed ("%s" is unknown).', $this->property);
|
||||
|
||||
parent::__construct($msg, 0, $previous);
|
||||
}
|
||||
}
|
||||
21
backend/vendor/symfony/serializer/Exception/UnexpectedValueException.php
vendored
Normal file
21
backend/vendor/symfony/serializer/Exception/UnexpectedValueException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Exception;
|
||||
|
||||
/**
|
||||
* UnexpectedValueException.
|
||||
*
|
||||
* @author Lukas Kahwe Smith <smith@pooteeweet.org>
|
||||
*/
|
||||
class UnexpectedValueException extends \UnexpectedValueException implements ExceptionInterface
|
||||
{
|
||||
}
|
||||
21
backend/vendor/symfony/serializer/Exception/UnsupportedException.php
vendored
Normal file
21
backend/vendor/symfony/serializer/Exception/UnsupportedException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Exception;
|
||||
|
||||
/**
|
||||
* UnsupportedException.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class UnsupportedException extends InvalidArgumentException
|
||||
{
|
||||
}
|
||||
19
backend/vendor/symfony/serializer/Exception/UnsupportedFormatException.php
vendored
Normal file
19
backend/vendor/symfony/serializer/Exception/UnsupportedFormatException.php
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Exception;
|
||||
|
||||
/**
|
||||
* @author Konstantin Myakshin <molodchick@gmail.com>
|
||||
*/
|
||||
class UnsupportedFormatException extends NotEncodableValueException
|
||||
{
|
||||
}
|
||||
36
backend/vendor/symfony/serializer/Extractor/ObjectPropertyListExtractor.php
vendored
Normal file
36
backend/vendor/symfony/serializer/Extractor/ObjectPropertyListExtractor.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Extractor;
|
||||
|
||||
use Symfony\Component\PropertyInfo\PropertyListExtractorInterface;
|
||||
|
||||
/**
|
||||
* @author David Maicher <mail@dmaicher.de>
|
||||
*/
|
||||
final class ObjectPropertyListExtractor implements ObjectPropertyListExtractorInterface
|
||||
{
|
||||
private \Closure $objectClassResolver;
|
||||
|
||||
public function __construct(
|
||||
private PropertyListExtractorInterface $propertyListExtractor,
|
||||
?callable $objectClassResolver = null,
|
||||
) {
|
||||
$this->objectClassResolver = ($objectClassResolver ?? 'get_class')(...);
|
||||
}
|
||||
|
||||
public function getProperties(object $object, array $context = []): ?array
|
||||
{
|
||||
$class = ($this->objectClassResolver)($object);
|
||||
|
||||
return $this->propertyListExtractor->getProperties($class, $context);
|
||||
}
|
||||
}
|
||||
25
backend/vendor/symfony/serializer/Extractor/ObjectPropertyListExtractorInterface.php
vendored
Normal file
25
backend/vendor/symfony/serializer/Extractor/ObjectPropertyListExtractorInterface.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Extractor;
|
||||
|
||||
/**
|
||||
* @author David Maicher <mail@dmaicher.de>
|
||||
*/
|
||||
interface ObjectPropertyListExtractorInterface
|
||||
{
|
||||
/**
|
||||
* Gets the list of properties available for the given object.
|
||||
*
|
||||
* @return string[]|null
|
||||
*/
|
||||
public function getProperties(object $object, array $context = []): ?array;
|
||||
}
|
||||
19
backend/vendor/symfony/serializer/LICENSE
vendored
Normal file
19
backend/vendor/symfony/serializer/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2004-present Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
185
backend/vendor/symfony/serializer/Mapping/AttributeMetadata.php
vendored
Normal file
185
backend/vendor/symfony/serializer/Mapping/AttributeMetadata.php
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Mapping;
|
||||
|
||||
use Symfony\Component\PropertyAccess\PropertyPath;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*
|
||||
* @final since Symfony 7.4
|
||||
*/
|
||||
class AttributeMetadata implements AttributeMetadataInterface
|
||||
{
|
||||
private string $name;
|
||||
private array $groups = [];
|
||||
private ?int $maxDepth = null;
|
||||
private ?string $serializedName = null;
|
||||
private ?PropertyPath $serializedPath = null;
|
||||
private bool $ignore = false;
|
||||
|
||||
/**
|
||||
* @var array[] Normalization contexts per group name ("*" applies to all groups)
|
||||
*/
|
||||
private array $normalizationContexts = [];
|
||||
|
||||
/**
|
||||
* @var array[] Denormalization contexts per group name ("*" applies to all groups)
|
||||
*/
|
||||
private array $denormalizationContexts = [];
|
||||
|
||||
public function __construct(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function addGroup(string $group): void
|
||||
{
|
||||
if (!\in_array($group, $this->groups, true)) {
|
||||
$this->groups[] = $group;
|
||||
}
|
||||
}
|
||||
|
||||
public function getGroups(): array
|
||||
{
|
||||
return $this->groups;
|
||||
}
|
||||
|
||||
public function setMaxDepth(?int $maxDepth): void
|
||||
{
|
||||
$this->maxDepth = $maxDepth;
|
||||
}
|
||||
|
||||
public function getMaxDepth(): ?int
|
||||
{
|
||||
return $this->maxDepth;
|
||||
}
|
||||
|
||||
public function setSerializedName(?string $serializedName): void
|
||||
{
|
||||
$this->serializedName = $serializedName;
|
||||
}
|
||||
|
||||
public function getSerializedName(): ?string
|
||||
{
|
||||
return $this->serializedName;
|
||||
}
|
||||
|
||||
public function setSerializedPath(?PropertyPath $serializedPath = null): void
|
||||
{
|
||||
$this->serializedPath = $serializedPath;
|
||||
}
|
||||
|
||||
public function getSerializedPath(): ?PropertyPath
|
||||
{
|
||||
return $this->serializedPath;
|
||||
}
|
||||
|
||||
public function setIgnore(bool $ignore): void
|
||||
{
|
||||
$this->ignore = $ignore;
|
||||
}
|
||||
|
||||
public function isIgnored(): bool
|
||||
{
|
||||
return $this->ignore;
|
||||
}
|
||||
|
||||
public function getNormalizationContexts(): array
|
||||
{
|
||||
return $this->normalizationContexts;
|
||||
}
|
||||
|
||||
public function getNormalizationContextForGroups(array $groups): array
|
||||
{
|
||||
$contexts = [];
|
||||
foreach ($groups as $group) {
|
||||
$contexts[] = $this->normalizationContexts[$group] ?? [];
|
||||
}
|
||||
|
||||
return array_merge($this->normalizationContexts['*'] ?? [], ...$contexts);
|
||||
}
|
||||
|
||||
public function setNormalizationContextForGroups(array $context, array $groups = []): void
|
||||
{
|
||||
if (!$groups) {
|
||||
$this->normalizationContexts['*'] = $context;
|
||||
}
|
||||
|
||||
foreach ($groups as $group) {
|
||||
$this->normalizationContexts[$group] = $context;
|
||||
}
|
||||
}
|
||||
|
||||
public function getDenormalizationContexts(): array
|
||||
{
|
||||
return $this->denormalizationContexts;
|
||||
}
|
||||
|
||||
public function getDenormalizationContextForGroups(array $groups): array
|
||||
{
|
||||
$contexts = [];
|
||||
foreach ($groups as $group) {
|
||||
$contexts[] = $this->denormalizationContexts[$group] ?? [];
|
||||
}
|
||||
|
||||
return array_merge($this->denormalizationContexts['*'] ?? [], ...$contexts);
|
||||
}
|
||||
|
||||
public function setDenormalizationContextForGroups(array $context, array $groups = []): void
|
||||
{
|
||||
if (!$groups) {
|
||||
$this->denormalizationContexts['*'] = $context;
|
||||
}
|
||||
|
||||
foreach ($groups as $group) {
|
||||
$this->denormalizationContexts[$group] = $context;
|
||||
}
|
||||
}
|
||||
|
||||
public function merge(AttributeMetadataInterface $attributeMetadata): void
|
||||
{
|
||||
foreach ($attributeMetadata->getGroups() as $group) {
|
||||
$this->addGroup($group);
|
||||
}
|
||||
|
||||
// Overwrite only if not defined
|
||||
$this->maxDepth ??= $attributeMetadata->getMaxDepth();
|
||||
$this->serializedName ??= $attributeMetadata->getSerializedName();
|
||||
$this->serializedPath ??= $attributeMetadata->getSerializedPath();
|
||||
|
||||
// Overwrite only if both contexts are empty
|
||||
if (!$this->normalizationContexts && !$this->denormalizationContexts) {
|
||||
$this->normalizationContexts = $attributeMetadata->getNormalizationContexts();
|
||||
$this->denormalizationContexts = $attributeMetadata->getDenormalizationContexts();
|
||||
}
|
||||
|
||||
if ($ignore = $attributeMetadata->isIgnored()) {
|
||||
$this->ignore = $ignore;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal since Symfony 7.4, will be replaced by `__serialize()` in 8.0
|
||||
*
|
||||
* @final since Symfony 7.4, will be replaced by `__serialize()` in 8.0
|
||||
*/
|
||||
public function __sleep(): array
|
||||
{
|
||||
return ['name', 'groups', 'maxDepth', 'serializedName', 'serializedPath', 'ignore', 'normalizationContexts', 'denormalizationContexts'];
|
||||
}
|
||||
}
|
||||
112
backend/vendor/symfony/serializer/Mapping/AttributeMetadataInterface.php
vendored
Normal file
112
backend/vendor/symfony/serializer/Mapping/AttributeMetadataInterface.php
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Mapping;
|
||||
|
||||
use Symfony\Component\PropertyAccess\PropertyPath;
|
||||
|
||||
/**
|
||||
* Stores metadata needed for serializing and deserializing attributes.
|
||||
*
|
||||
* Primarily, the metadata stores serialization groups.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
interface AttributeMetadataInterface
|
||||
{
|
||||
/**
|
||||
* Gets the attribute name.
|
||||
*/
|
||||
public function getName(): string;
|
||||
|
||||
/**
|
||||
* Adds this attribute to the given group.
|
||||
*/
|
||||
public function addGroup(string $group): void;
|
||||
|
||||
/**
|
||||
* Gets groups of this attribute.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getGroups(): array;
|
||||
|
||||
/**
|
||||
* Sets the serialization max depth for this attribute.
|
||||
*/
|
||||
public function setMaxDepth(?int $maxDepth): void;
|
||||
|
||||
/**
|
||||
* Gets the serialization max depth for this attribute.
|
||||
*/
|
||||
public function getMaxDepth(): ?int;
|
||||
|
||||
/**
|
||||
* Sets the serialization name for this attribute.
|
||||
*/
|
||||
public function setSerializedName(?string $serializedName): void;
|
||||
|
||||
/**
|
||||
* Gets the serialization name for this attribute.
|
||||
*/
|
||||
public function getSerializedName(): ?string;
|
||||
|
||||
public function setSerializedPath(?PropertyPath $serializedPath): void;
|
||||
|
||||
public function getSerializedPath(): ?PropertyPath;
|
||||
|
||||
/**
|
||||
* Sets if this attribute must be ignored or not.
|
||||
*/
|
||||
public function setIgnore(bool $ignore): void;
|
||||
|
||||
/**
|
||||
* Gets if this attribute is ignored or not.
|
||||
*/
|
||||
public function isIgnored(): bool;
|
||||
|
||||
/**
|
||||
* Merges an {@see AttributeMetadataInterface} with in the current one.
|
||||
*/
|
||||
public function merge(self $attributeMetadata): void;
|
||||
|
||||
/**
|
||||
* Gets all the normalization contexts per group ("*" being the base context applied to all groups).
|
||||
*/
|
||||
public function getNormalizationContexts(): array;
|
||||
|
||||
/**
|
||||
* Gets the computed normalization contexts for given groups.
|
||||
*/
|
||||
public function getNormalizationContextForGroups(array $groups): array;
|
||||
|
||||
/**
|
||||
* Sets the normalization context for given groups.
|
||||
*/
|
||||
public function setNormalizationContextForGroups(array $context, array $groups = []): void;
|
||||
|
||||
/**
|
||||
* Gets all the denormalization contexts per group ("*" being the base context applied to all groups).
|
||||
*/
|
||||
public function getDenormalizationContexts(): array;
|
||||
|
||||
/**
|
||||
* Gets the computed denormalization contexts for given groups.
|
||||
*/
|
||||
public function getDenormalizationContextForGroups(array $groups): array;
|
||||
|
||||
/**
|
||||
* Sets the denormalization context for given groups.
|
||||
*/
|
||||
public function setDenormalizationContextForGroups(array $context, array $groups = []): void;
|
||||
}
|
||||
81
backend/vendor/symfony/serializer/Mapping/ClassDiscriminatorFromClassMetadata.php
vendored
Normal file
81
backend/vendor/symfony/serializer/Mapping/ClassDiscriminatorFromClassMetadata.php
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Mapping;
|
||||
|
||||
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
|
||||
|
||||
/**
|
||||
* @author Samuel Roze <samuel.roze@gmail.com>
|
||||
*/
|
||||
class ClassDiscriminatorFromClassMetadata implements ClassDiscriminatorResolverInterface
|
||||
{
|
||||
private array $mappingForMappedObjectCache = [];
|
||||
|
||||
public function __construct(
|
||||
private readonly ClassMetadataFactoryInterface $classMetadataFactory,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getMappingForClass(string $class): ?ClassDiscriminatorMapping
|
||||
{
|
||||
if ($this->classMetadataFactory->hasMetadataFor($class)) {
|
||||
return $this->classMetadataFactory->getMetadataFor($class)->getClassDiscriminatorMapping();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getMappingForMappedObject(object|string $object): ?ClassDiscriminatorMapping
|
||||
{
|
||||
if ($this->classMetadataFactory->hasMetadataFor($object)) {
|
||||
$metadata = $this->classMetadataFactory->getMetadataFor($object);
|
||||
|
||||
if (null !== $metadata->getClassDiscriminatorMapping()) {
|
||||
return $metadata->getClassDiscriminatorMapping();
|
||||
}
|
||||
}
|
||||
|
||||
$cacheKey = \is_object($object) ? $object::class : $object;
|
||||
if (!\array_key_exists($cacheKey, $this->mappingForMappedObjectCache)) {
|
||||
$this->mappingForMappedObjectCache[$cacheKey] = $this->resolveMappingForMappedObject($object);
|
||||
}
|
||||
|
||||
return $this->mappingForMappedObjectCache[$cacheKey];
|
||||
}
|
||||
|
||||
public function getTypeForMappedObject(object|string $object): ?string
|
||||
{
|
||||
if (null === $mapping = $this->getMappingForMappedObject($object)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $mapping->getMappedObjectType($object);
|
||||
}
|
||||
|
||||
private function resolveMappingForMappedObject(object|string $object): ?ClassDiscriminatorMapping
|
||||
{
|
||||
$reflectionClass = new \ReflectionClass($object);
|
||||
if ($parentClass = $reflectionClass->getParentClass()) {
|
||||
if (null !== ($parentMapping = $this->getMappingForMappedObject($parentClass->getName()))) {
|
||||
return $parentMapping;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($reflectionClass->getInterfaceNames() as $interfaceName) {
|
||||
if (null !== ($interfaceMapping = $this->getMappingForMappedObject($interfaceName))) {
|
||||
return $interfaceMapping;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
70
backend/vendor/symfony/serializer/Mapping/ClassDiscriminatorMapping.php
vendored
Normal file
70
backend/vendor/symfony/serializer/Mapping/ClassDiscriminatorMapping.php
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Mapping;
|
||||
|
||||
/**
|
||||
* @author Samuel Roze <samuel.roze@gmail.com>
|
||||
*/
|
||||
class ClassDiscriminatorMapping
|
||||
{
|
||||
/**
|
||||
* @param array<string, string> $typesMapping
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly string $typeProperty,
|
||||
private array $typesMapping = [],
|
||||
private readonly ?string $defaultType = null,
|
||||
) {
|
||||
uasort($this->typesMapping, static function (string $a, string $b): int {
|
||||
if (is_a($a, $b, true)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (is_a($b, $a, true)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
public function getTypeProperty(): string
|
||||
{
|
||||
return $this->typeProperty;
|
||||
}
|
||||
|
||||
public function getClassForType(string $type): ?string
|
||||
{
|
||||
return $this->typesMapping[$type] ?? null;
|
||||
}
|
||||
|
||||
public function getMappedObjectType(object|string $object): ?string
|
||||
{
|
||||
foreach ($this->typesMapping as $type => $typeClass) {
|
||||
if (is_a($object, $typeClass, true)) {
|
||||
return $type;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getTypesMapping(): array
|
||||
{
|
||||
return $this->typesMapping;
|
||||
}
|
||||
|
||||
public function getDefaultType(): ?string
|
||||
{
|
||||
return $this->defaultType;
|
||||
}
|
||||
}
|
||||
26
backend/vendor/symfony/serializer/Mapping/ClassDiscriminatorResolverInterface.php
vendored
Normal file
26
backend/vendor/symfony/serializer/Mapping/ClassDiscriminatorResolverInterface.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Mapping;
|
||||
|
||||
/**
|
||||
* Knows how to get the class discriminator mapping for classes and objects.
|
||||
*
|
||||
* @author Samuel Roze <samuel.roze@gmail.com>
|
||||
*/
|
||||
interface ClassDiscriminatorResolverInterface
|
||||
{
|
||||
public function getMappingForClass(string $class): ?ClassDiscriminatorMapping;
|
||||
|
||||
public function getMappingForMappedObject(object|string $object): ?ClassDiscriminatorMapping;
|
||||
|
||||
public function getTypeForMappedObject(object|string $object): ?string;
|
||||
}
|
||||
91
backend/vendor/symfony/serializer/Mapping/ClassMetadata.php
vendored
Normal file
91
backend/vendor/symfony/serializer/Mapping/ClassMetadata.php
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Mapping;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*
|
||||
* @final since Symfony 7.4
|
||||
*/
|
||||
class ClassMetadata implements ClassMetadataInterface
|
||||
{
|
||||
private string $name;
|
||||
|
||||
/**
|
||||
* @var AttributeMetadataInterface[]
|
||||
*/
|
||||
private array $attributesMetadata = [];
|
||||
|
||||
private ?\ReflectionClass $reflClass = null;
|
||||
private ?ClassDiscriminatorMapping $classDiscriminatorMapping = null;
|
||||
|
||||
public function __construct(string $class, ?ClassDiscriminatorMapping $classDiscriminatorMapping = null)
|
||||
{
|
||||
$this->name = $class;
|
||||
$this->classDiscriminatorMapping = $classDiscriminatorMapping;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function addAttributeMetadata(AttributeMetadataInterface $attributeMetadata): void
|
||||
{
|
||||
$this->attributesMetadata[$attributeMetadata->getName()] = $attributeMetadata;
|
||||
}
|
||||
|
||||
public function getAttributesMetadata(): array
|
||||
{
|
||||
return $this->attributesMetadata;
|
||||
}
|
||||
|
||||
public function merge(ClassMetadataInterface $classMetadata): void
|
||||
{
|
||||
foreach ($classMetadata->getAttributesMetadata() as $attributeMetadata) {
|
||||
if (isset($this->attributesMetadata[$attributeMetadata->getName()])) {
|
||||
$this->attributesMetadata[$attributeMetadata->getName()]->merge($attributeMetadata);
|
||||
} else {
|
||||
$this->addAttributeMetadata($attributeMetadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getReflectionClass(): \ReflectionClass
|
||||
{
|
||||
return $this->reflClass ??= new \ReflectionClass($this->getName());
|
||||
}
|
||||
|
||||
public function getClassDiscriminatorMapping(): ?ClassDiscriminatorMapping
|
||||
{
|
||||
return $this->classDiscriminatorMapping;
|
||||
}
|
||||
|
||||
public function setClassDiscriminatorMapping(?ClassDiscriminatorMapping $mapping): void
|
||||
{
|
||||
$this->classDiscriminatorMapping = $mapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal since Symfony 7.4, will be replaced by `__serialize()` in 8.0
|
||||
*
|
||||
* @final since Symfony 7.4, will be replaced by `__serialize()` in 8.0
|
||||
*/
|
||||
public function __sleep(): array
|
||||
{
|
||||
return [
|
||||
'name',
|
||||
'attributesMetadata',
|
||||
'classDiscriminatorMapping',
|
||||
];
|
||||
}
|
||||
}
|
||||
57
backend/vendor/symfony/serializer/Mapping/ClassMetadataInterface.php
vendored
Normal file
57
backend/vendor/symfony/serializer/Mapping/ClassMetadataInterface.php
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Mapping;
|
||||
|
||||
/**
|
||||
* Stores metadata needed for serializing and deserializing objects of specific class.
|
||||
*
|
||||
* Primarily, the metadata stores the set of attributes to serialize or deserialize.
|
||||
*
|
||||
* There may only exist one metadata for each attribute according to its name.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
interface ClassMetadataInterface
|
||||
{
|
||||
/**
|
||||
* Returns the name of the backing PHP class.
|
||||
*/
|
||||
public function getName(): string;
|
||||
|
||||
/**
|
||||
* Adds an {@link AttributeMetadataInterface}.
|
||||
*/
|
||||
public function addAttributeMetadata(AttributeMetadataInterface $attributeMetadata): void;
|
||||
|
||||
/**
|
||||
* Gets the list of {@link AttributeMetadataInterface}.
|
||||
*
|
||||
* @return array<string, AttributeMetadataInterface>
|
||||
*/
|
||||
public function getAttributesMetadata(): array;
|
||||
|
||||
/**
|
||||
* Merges a {@link ClassMetadataInterface} in the current one.
|
||||
*/
|
||||
public function merge(self $classMetadata): void;
|
||||
|
||||
/**
|
||||
* Returns a {@link \ReflectionClass} instance for this class.
|
||||
*/
|
||||
public function getReflectionClass(): \ReflectionClass;
|
||||
|
||||
public function getClassDiscriminatorMapping(): ?ClassDiscriminatorMapping;
|
||||
|
||||
public function setClassDiscriminatorMapping(?ClassDiscriminatorMapping $mapping): void;
|
||||
}
|
||||
62
backend/vendor/symfony/serializer/Mapping/Factory/CacheClassMetadataFactory.php
vendored
Normal file
62
backend/vendor/symfony/serializer/Mapping/Factory/CacheClassMetadataFactory.php
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Mapping\Factory;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Serializer\Mapping\ClassMetadataInterface;
|
||||
|
||||
/**
|
||||
* Caches metadata using a PSR-6 implementation.
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class CacheClassMetadataFactory implements ClassMetadataFactoryInterface
|
||||
{
|
||||
use ClassResolverTrait;
|
||||
|
||||
/**
|
||||
* @var array<string, ClassMetadataInterface>
|
||||
*/
|
||||
private array $loadedClasses = [];
|
||||
|
||||
public function __construct(
|
||||
private readonly ClassMetadataFactoryInterface $decorated,
|
||||
private readonly CacheItemPoolInterface $cacheItemPool,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getMetadataFor(string|object $value): ClassMetadataInterface
|
||||
{
|
||||
$class = $this->getClass($value);
|
||||
|
||||
if (isset($this->loadedClasses[$class])) {
|
||||
return $this->loadedClasses[$class];
|
||||
}
|
||||
|
||||
$key = rawurlencode(strtr($class, '\\', '_'));
|
||||
|
||||
$item = $this->cacheItemPool->getItem($key);
|
||||
if ($item->isHit()) {
|
||||
return $this->loadedClasses[$class] = $item->get();
|
||||
}
|
||||
|
||||
$metadata = $this->decorated->getMetadataFor($value);
|
||||
$this->cacheItemPool->save($item->set($metadata));
|
||||
|
||||
return $this->loadedClasses[$class] = $metadata;
|
||||
}
|
||||
|
||||
public function hasMetadataFor(mixed $value): bool
|
||||
{
|
||||
return $this->decorated->hasMetadataFor($value);
|
||||
}
|
||||
}
|
||||
67
backend/vendor/symfony/serializer/Mapping/Factory/ClassMetadataFactory.php
vendored
Normal file
67
backend/vendor/symfony/serializer/Mapping/Factory/ClassMetadataFactory.php
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Mapping\Factory;
|
||||
|
||||
use Symfony\Component\Serializer\Mapping\ClassMetadata;
|
||||
use Symfony\Component\Serializer\Mapping\ClassMetadataInterface;
|
||||
use Symfony\Component\Serializer\Mapping\Loader\LoaderInterface;
|
||||
|
||||
/**
|
||||
* Returns a {@link ClassMetadata}.
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class ClassMetadataFactory implements ClassMetadataFactoryInterface
|
||||
{
|
||||
use ClassResolverTrait;
|
||||
|
||||
/**
|
||||
* @var array<string, ClassMetadataInterface>
|
||||
*/
|
||||
private array $loadedClasses;
|
||||
|
||||
public function __construct(
|
||||
private readonly LoaderInterface $loader,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getMetadataFor(string|object $value): ClassMetadataInterface
|
||||
{
|
||||
$class = $this->getClass($value);
|
||||
|
||||
if (isset($this->loadedClasses[$class])) {
|
||||
return $this->loadedClasses[$class];
|
||||
}
|
||||
|
||||
$classMetadata = new ClassMetadata($class);
|
||||
$this->loader->loadClassMetadata($classMetadata);
|
||||
|
||||
$reflectionClass = $classMetadata->getReflectionClass();
|
||||
|
||||
// Include metadata from the parent class
|
||||
if ($parent = $reflectionClass->getParentClass()) {
|
||||
$classMetadata->merge($this->getMetadataFor($parent->name));
|
||||
}
|
||||
|
||||
// Include metadata from all implemented interfaces
|
||||
foreach ($reflectionClass->getInterfaces() as $interface) {
|
||||
$classMetadata->merge($this->getMetadataFor($interface->name));
|
||||
}
|
||||
|
||||
return $this->loadedClasses[$class] = $classMetadata;
|
||||
}
|
||||
|
||||
public function hasMetadataFor(mixed $value): bool
|
||||
{
|
||||
return \is_object($value) || (\is_string($value) && (class_exists($value) || interface_exists($value, false)));
|
||||
}
|
||||
}
|
||||
73
backend/vendor/symfony/serializer/Mapping/Factory/ClassMetadataFactoryCompiler.php
vendored
Normal file
73
backend/vendor/symfony/serializer/Mapping/Factory/ClassMetadataFactoryCompiler.php
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Mapping\Factory;
|
||||
|
||||
use Symfony\Component\Serializer\Mapping\ClassMetadataInterface;
|
||||
use Symfony\Component\VarExporter\VarExporter;
|
||||
|
||||
trigger_deprecation('symfony/serializer', '7.4', 'The "%s" class is deprecated.', ClassMetadataFactoryCompiler::class);
|
||||
|
||||
/**
|
||||
* @author Fabien Bourigault <bourigaultfabien@gmail.com>
|
||||
*
|
||||
* @deprecated since Symfony 7.4
|
||||
*/
|
||||
final class ClassMetadataFactoryCompiler
|
||||
{
|
||||
/**
|
||||
* @param ClassMetadataInterface[] $classMetadatas
|
||||
*/
|
||||
public function compile(array $classMetadatas): string
|
||||
{
|
||||
return <<<EOF
|
||||
<?php
|
||||
|
||||
// This file has been auto-generated by the Symfony Serializer Component.
|
||||
|
||||
return [{$this->generateDeclaredClassMetadata($classMetadatas)}
|
||||
];
|
||||
EOF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ClassMetadataInterface[] $classMetadatas
|
||||
*/
|
||||
private function generateDeclaredClassMetadata(array $classMetadatas): string
|
||||
{
|
||||
$compiled = '';
|
||||
|
||||
foreach ($classMetadatas as $classMetadata) {
|
||||
$attributesMetadata = [];
|
||||
foreach ($classMetadata->getAttributesMetadata() as $attributeMetadata) {
|
||||
$attributesMetadata[$attributeMetadata->getName()] = [
|
||||
$attributeMetadata->getGroups(),
|
||||
$attributeMetadata->getMaxDepth(),
|
||||
$attributeMetadata->getSerializedName(),
|
||||
$attributeMetadata->getSerializedPath(),
|
||||
];
|
||||
}
|
||||
|
||||
$classDiscriminatorMapping = $classMetadata->getClassDiscriminatorMapping() ? [
|
||||
$classMetadata->getClassDiscriminatorMapping()->getTypeProperty(),
|
||||
$classMetadata->getClassDiscriminatorMapping()->getTypesMapping(),
|
||||
$classMetadata->getClassDiscriminatorMapping()->getDefaultType(),
|
||||
] : null;
|
||||
|
||||
$compiled .= \sprintf("\n'%s' => %s,", $classMetadata->getName(), VarExporter::export([
|
||||
$attributesMetadata,
|
||||
$classDiscriminatorMapping,
|
||||
]));
|
||||
}
|
||||
|
||||
return $compiled;
|
||||
}
|
||||
}
|
||||
45
backend/vendor/symfony/serializer/Mapping/Factory/ClassMetadataFactoryInterface.php
vendored
Normal file
45
backend/vendor/symfony/serializer/Mapping/Factory/ClassMetadataFactoryInterface.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Mapping\Factory;
|
||||
|
||||
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Serializer\Mapping\ClassMetadataInterface;
|
||||
|
||||
/**
|
||||
* Returns a {@see ClassMetadataInterface}.
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
interface ClassMetadataFactoryInterface
|
||||
{
|
||||
/**
|
||||
* If the method was called with the same class name (or an object of that
|
||||
* class) before, the same metadata instance is returned.
|
||||
*
|
||||
* If the factory was configured with a cache, this method will first look
|
||||
* for an existing metadata instance in the cache. If an existing instance
|
||||
* is found, it will be returned without further ado.
|
||||
*
|
||||
* Otherwise, a new metadata instance is created. If the factory was
|
||||
* configured with a loader, the metadata is passed to the
|
||||
* {@link \Symfony\Component\Serializer\Mapping\Loader\LoaderInterface::loadClassMetadata()} method for further
|
||||
* configuration. At last, the new object is returned.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function getMetadataFor(string|object $value): ClassMetadataInterface;
|
||||
|
||||
/**
|
||||
* Checks if class has metadata.
|
||||
*/
|
||||
public function hasMetadataFor(mixed $value): bool;
|
||||
}
|
||||
42
backend/vendor/symfony/serializer/Mapping/Factory/ClassResolverTrait.php
vendored
Normal file
42
backend/vendor/symfony/serializer/Mapping/Factory/ClassResolverTrait.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Mapping\Factory;
|
||||
|
||||
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Resolves a class name.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
trait ClassResolverTrait
|
||||
{
|
||||
/**
|
||||
* Gets a class name for a given class or instance.
|
||||
*
|
||||
* @throws InvalidArgumentException If the class does not exist
|
||||
*/
|
||||
private function getClass(object|string $value): string
|
||||
{
|
||||
if (\is_string($value)) {
|
||||
if (!class_exists($value) && !interface_exists($value, false)) {
|
||||
throw new InvalidArgumentException(\sprintf('The class or interface "%s" does not exist.', $value));
|
||||
}
|
||||
|
||||
return ltrim($value, '\\');
|
||||
}
|
||||
|
||||
return $value::class;
|
||||
}
|
||||
}
|
||||
83
backend/vendor/symfony/serializer/Mapping/Factory/CompiledClassMetadataFactory.php
vendored
Normal file
83
backend/vendor/symfony/serializer/Mapping/Factory/CompiledClassMetadataFactory.php
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Mapping\Factory;
|
||||
|
||||
use Symfony\Component\Serializer\Mapping\AttributeMetadata;
|
||||
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping;
|
||||
use Symfony\Component\Serializer\Mapping\ClassMetadata;
|
||||
use Symfony\Component\Serializer\Mapping\ClassMetadataInterface;
|
||||
|
||||
trigger_deprecation('symfony/serializer', '7.3', 'The "%s" class is deprecated.', CompiledClassMetadataFactory::class);
|
||||
|
||||
/**
|
||||
* @author Fabien Bourigault <bourigaultfabien@gmail.com>
|
||||
*
|
||||
* @deprecated since Symfony 7.3
|
||||
*/
|
||||
final class CompiledClassMetadataFactory implements ClassMetadataFactoryInterface
|
||||
{
|
||||
private array $compiledClassMetadata = [];
|
||||
|
||||
private array $loadedClasses = [];
|
||||
|
||||
public function __construct(
|
||||
string $compiledClassMetadataFile,
|
||||
private readonly ClassMetadataFactoryInterface $classMetadataFactory,
|
||||
) {
|
||||
if (!file_exists($compiledClassMetadataFile)) {
|
||||
throw new \RuntimeException("File \"{$compiledClassMetadataFile}\" could not be found.");
|
||||
}
|
||||
|
||||
$compiledClassMetadata = require $compiledClassMetadataFile;
|
||||
if (!\is_array($compiledClassMetadata)) {
|
||||
throw new \RuntimeException(\sprintf('Compiled metadata must be of the type array, %s given.', \gettype($compiledClassMetadata)));
|
||||
}
|
||||
|
||||
$this->compiledClassMetadata = $compiledClassMetadata;
|
||||
}
|
||||
|
||||
public function getMetadataFor(string|object $value): ClassMetadataInterface
|
||||
{
|
||||
$className = \is_object($value) ? $value::class : $value;
|
||||
|
||||
if (!isset($this->compiledClassMetadata[$className])) {
|
||||
return $this->classMetadataFactory->getMetadataFor($value);
|
||||
}
|
||||
|
||||
if (!isset($this->loadedClasses[$className])) {
|
||||
$classMetadata = new ClassMetadata($className);
|
||||
foreach ($this->compiledClassMetadata[$className][0] as $name => $compiledAttributesMetadata) {
|
||||
$classMetadata->addAttributeMetadata($attributeMetadata = new AttributeMetadata($name));
|
||||
foreach ($compiledAttributesMetadata[0] as $group) {
|
||||
$attributeMetadata->addGroup($group);
|
||||
}
|
||||
$attributeMetadata->setMaxDepth($compiledAttributesMetadata[1]);
|
||||
$attributeMetadata->setSerializedName($compiledAttributesMetadata[2]);
|
||||
}
|
||||
$classMetadata->setClassDiscriminatorMapping($this->compiledClassMetadata[$className][1]
|
||||
? new ClassDiscriminatorMapping(...$this->compiledClassMetadata[$className][1])
|
||||
: null
|
||||
);
|
||||
|
||||
$this->loadedClasses[$className] = $classMetadata;
|
||||
}
|
||||
|
||||
return $this->loadedClasses[$className];
|
||||
}
|
||||
|
||||
public function hasMetadataFor(mixed $value): bool
|
||||
{
|
||||
$className = \is_object($value) ? $value::class : $value;
|
||||
|
||||
return isset($this->compiledClassMetadata[$className]) || $this->classMetadataFactory->hasMetadataFor($value);
|
||||
}
|
||||
}
|
||||
101
backend/vendor/symfony/serializer/Mapping/Loader/AccessorCollisionResolverTrait.php
vendored
Normal file
101
backend/vendor/symfony/serializer/Mapping/Loader/AccessorCollisionResolverTrait.php
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Mapping\Loader;
|
||||
|
||||
use Symfony\Component\Serializer\Attribute\Ignore;
|
||||
|
||||
/**
|
||||
* Provides methods to detect accessor name collisions during serialization.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
trait AccessorCollisionResolverTrait
|
||||
{
|
||||
private function getAttributeNameFromAccessor(\ReflectionClass $class, \ReflectionMethod $method, bool $andMutator): ?string
|
||||
{
|
||||
$methodName = $method->name;
|
||||
|
||||
$i = match ($methodName[0]) {
|
||||
's' => $andMutator && str_starts_with($methodName, 'set') ? 3 : null,
|
||||
'g' => str_starts_with($methodName, 'get') ? 3 : null,
|
||||
'h' => str_starts_with($methodName, 'has') ? 3 : null,
|
||||
'c' => str_starts_with($methodName, 'can') ? 3 : null,
|
||||
'i' => str_starts_with($methodName, 'is') ? 2 : null,
|
||||
default => null,
|
||||
};
|
||||
|
||||
// ctype_lower check to find out if method looks like accessor but actually is not, e.g. hash, cancel
|
||||
if (null === $i || ctype_lower($methodName[$i] ?? 'a') || (!$andMutator && $method->isStatic())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ('s' === $methodName[0] ? !$method->getNumberOfParameters() : ($method->getNumberOfRequiredParameters() || \in_array((string) $method->getReturnType(), ['void', 'never'], true))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$attributeName = substr($methodName, $i);
|
||||
|
||||
if (!$class->hasProperty($attributeName)) {
|
||||
$attributeName = lcfirst($attributeName);
|
||||
}
|
||||
|
||||
return $attributeName;
|
||||
}
|
||||
|
||||
private function hasPropertyForAccessor(\ReflectionClass $class, string $propName): bool
|
||||
{
|
||||
do {
|
||||
if ($class->hasProperty($propName)) {
|
||||
return true;
|
||||
}
|
||||
} while ($class = $class->getParentClass());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function hasAttributeNameCollision(\ReflectionClass $class, string $attributeName, string $methodName): bool
|
||||
{
|
||||
if ($this->hasPropertyForAccessor($class, $attributeName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($class->hasMethod($attributeName)) {
|
||||
$candidate = $class->getMethod($attributeName);
|
||||
if ($candidate->getName() !== $methodName && $this->isReadableAccessorMethod($candidate)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$ucAttributeName = ucfirst($attributeName);
|
||||
foreach (['get', 'is', 'has', 'can'] as $prefix) {
|
||||
$candidateName = $prefix.$ucAttributeName;
|
||||
if ($candidateName === $methodName || !$class->hasMethod($candidateName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->isReadableAccessorMethod($class->getMethod($candidateName))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function isReadableAccessorMethod(\ReflectionMethod $method): bool
|
||||
{
|
||||
return $method->isPublic()
|
||||
&& !$method->isStatic()
|
||||
&& !$method->getAttributes(Ignore::class)
|
||||
&& !$method->getNumberOfRequiredParameters()
|
||||
&& !\in_array((string) $method->getReturnType(), ['void', 'never'], true);
|
||||
}
|
||||
}
|
||||
262
backend/vendor/symfony/serializer/Mapping/Loader/AttributeLoader.php
vendored
Normal file
262
backend/vendor/symfony/serializer/Mapping/Loader/AttributeLoader.php
vendored
Normal file
@@ -0,0 +1,262 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Mapping\Loader;
|
||||
|
||||
use Symfony\Component\Serializer\Attribute\Context;
|
||||
use Symfony\Component\Serializer\Attribute\DiscriminatorMap;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
use Symfony\Component\Serializer\Attribute\Ignore;
|
||||
use Symfony\Component\Serializer\Attribute\MaxDepth;
|
||||
use Symfony\Component\Serializer\Attribute\SerializedName;
|
||||
use Symfony\Component\Serializer\Attribute\SerializedPath;
|
||||
use Symfony\Component\Serializer\Exception\MappingException;
|
||||
use Symfony\Component\Serializer\Mapping\AttributeMetadata;
|
||||
use Symfony\Component\Serializer\Mapping\AttributeMetadataInterface;
|
||||
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping;
|
||||
use Symfony\Component\Serializer\Mapping\ClassMetadataInterface;
|
||||
|
||||
/**
|
||||
* Loader for PHP attributes.
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
* @author Alexander M. Turek <me@derrabus.de>
|
||||
* @author Alexandre Daubois <alex.daubois@gmail.com>
|
||||
*/
|
||||
class AttributeLoader implements LoaderInterface
|
||||
{
|
||||
use AccessorCollisionResolverTrait;
|
||||
|
||||
private const KNOWN_ATTRIBUTES = [
|
||||
DiscriminatorMap::class,
|
||||
Groups::class,
|
||||
Ignore::class,
|
||||
MaxDepth::class,
|
||||
SerializedName::class,
|
||||
SerializedPath::class,
|
||||
Context::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* @param bool|null $allowAnyClass Null is allowed for BC with Symfony <= 6
|
||||
* @param array<class-string, class-string[]> $mappedClasses
|
||||
*/
|
||||
public function __construct(
|
||||
private ?bool $allowAnyClass = true,
|
||||
private array $mappedClasses = [],
|
||||
) {
|
||||
$this->allowAnyClass ??= true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class-string[]
|
||||
*/
|
||||
public function getMappedClasses(): array
|
||||
{
|
||||
return array_keys($this->mappedClasses);
|
||||
}
|
||||
|
||||
public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
|
||||
{
|
||||
if (!$sourceClasses = $this->mappedClasses[$classMetadata->getName()] ??= $this->allowAnyClass ? [$classMetadata->getName()] : []) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$success = false;
|
||||
foreach ($sourceClasses as $sourceClass) {
|
||||
$reflectionClass = $classMetadata->getName() === $sourceClass ? $classMetadata->getReflectionClass() : new \ReflectionClass($sourceClass);
|
||||
$success = $this->doLoadClassMetadata($reflectionClass, $classMetadata) || $success;
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
private function doLoadClassMetadata(\ReflectionClass $reflectionClass, ClassMetadataInterface $classMetadata): bool
|
||||
{
|
||||
$className = $reflectionClass->name;
|
||||
$loaded = false;
|
||||
$classGroups = [];
|
||||
$classContextAttribute = null;
|
||||
|
||||
$attributesMetadata = $classMetadata->getAttributesMetadata();
|
||||
|
||||
foreach ($this->loadAttributes($reflectionClass) as $attribute) {
|
||||
match (true) {
|
||||
$attribute instanceof DiscriminatorMap => $classMetadata->setClassDiscriminatorMapping(new ClassDiscriminatorMapping($attribute->typeProperty, $attribute->mapping, $attribute->defaultType)),
|
||||
$attribute instanceof Groups => $classGroups = $attribute->groups,
|
||||
$attribute instanceof Context => $classContextAttribute = $attribute,
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
foreach ($reflectionClass->getProperties() as $property) {
|
||||
if (!isset($attributesMetadata[$property->name])) {
|
||||
$attributesMetadata[$property->name] = new AttributeMetadata($property->name);
|
||||
$classMetadata->addAttributeMetadata($attributesMetadata[$property->name]);
|
||||
}
|
||||
|
||||
$attributeMetadata = $attributesMetadata[$property->name];
|
||||
if ($property->getDeclaringClass()->name === $className) {
|
||||
if ($classContextAttribute) {
|
||||
$this->setAttributeContextsForGroups($classContextAttribute, $attributeMetadata);
|
||||
}
|
||||
|
||||
foreach ($classGroups as $group) {
|
||||
$attributeMetadata->addGroup($group);
|
||||
}
|
||||
|
||||
foreach ($this->loadAttributes($property) as $attribute) {
|
||||
$loaded = true;
|
||||
|
||||
if ($attribute instanceof Groups) {
|
||||
foreach ($attribute->groups as $group) {
|
||||
$attributeMetadata->addGroup($group);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
match (true) {
|
||||
$attribute instanceof MaxDepth => $attributeMetadata->setMaxDepth($attribute->maxDepth),
|
||||
$attribute instanceof SerializedName => $attributeMetadata->setSerializedName($attribute->serializedName),
|
||||
$attribute instanceof SerializedPath => $attributeMetadata->setSerializedPath($attribute->serializedPath),
|
||||
$attribute instanceof Ignore => $attributeMetadata->setIgnore(true),
|
||||
$attribute instanceof Context => $this->setAttributeContextsForGroups($attribute, $attributeMetadata),
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($reflectionClass->getMethods() as $method) {
|
||||
if ($method->getDeclaringClass()->name !== $className) {
|
||||
continue;
|
||||
}
|
||||
$name = $method->name;
|
||||
|
||||
if (0 === stripos($name, 'get') && $method->getNumberOfRequiredParameters()) {
|
||||
continue; /* matches the BC behavior in `Symfony\Component\Serializer\Normalizer\ObjectNormalizer::extractAttributes` */
|
||||
}
|
||||
|
||||
$attributeName = $this->getAttributeNameFromAccessor($reflectionClass, $method, true);
|
||||
$accessorOrMutator = null !== $attributeName;
|
||||
$hasProperty = $this->hasPropertyForAccessor($method->getDeclaringClass(), $name);
|
||||
$attributeMetadata = null;
|
||||
|
||||
if ($hasProperty || $accessorOrMutator) {
|
||||
if (null === $attributeName || 's' !== $name[0] && $hasProperty && $this->hasAttributeNameCollision($reflectionClass, $attributeName, $name)) {
|
||||
$attributeName = $name;
|
||||
}
|
||||
|
||||
if (isset($attributesMetadata[$attributeName])) {
|
||||
$attributeMetadata = $attributesMetadata[$attributeName];
|
||||
} else {
|
||||
$attributesMetadata[$attributeName] = $attributeMetadata = new AttributeMetadata($attributeName);
|
||||
$classMetadata->addAttributeMetadata($attributeMetadata);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->loadAttributes($method) as $attribute) {
|
||||
if ($attribute instanceof Groups) {
|
||||
if (!$attributeMetadata) {
|
||||
throw new MappingException(\sprintf('Groups on "%s::%s()" cannot be added. Groups can only be added on methods beginning with "get", "is", "has", "can" or "set".', $className, $method->name));
|
||||
}
|
||||
|
||||
foreach ($attribute->groups as $group) {
|
||||
$attributeMetadata->addGroup($group);
|
||||
}
|
||||
} elseif ($attribute instanceof MaxDepth) {
|
||||
if (!$attributeMetadata) {
|
||||
throw new MappingException(\sprintf('MaxDepth on "%s::%s()" cannot be added. MaxDepth can only be added on methods beginning with "get", "is", "has", "can" or "set".', $className, $method->name));
|
||||
}
|
||||
|
||||
$attributeMetadata->setMaxDepth($attribute->maxDepth);
|
||||
} elseif ($attribute instanceof SerializedName) {
|
||||
if (!$attributeMetadata) {
|
||||
throw new MappingException(\sprintf('SerializedName on "%s::%s()" cannot be added. SerializedName can only be added on methods beginning with "get", "is", "has", "can" or "set".', $className, $method->name));
|
||||
}
|
||||
|
||||
$attributeMetadata->setSerializedName($attribute->serializedName);
|
||||
} elseif ($attribute instanceof SerializedPath) {
|
||||
if (!$attributeMetadata) {
|
||||
throw new MappingException(\sprintf('SerializedPath on "%s::%s()" cannot be added. SerializedPath can only be added on methods beginning with "get", "is", "has", "can" or "set".', $className, $method->name));
|
||||
}
|
||||
|
||||
$attributeMetadata->setSerializedPath($attribute->serializedPath);
|
||||
} elseif ($attribute instanceof Ignore) {
|
||||
if ($attributeMetadata) {
|
||||
$attributeMetadata->setIgnore(true);
|
||||
}
|
||||
} elseif ($attribute instanceof Context) {
|
||||
if (!$attributeMetadata) {
|
||||
throw new MappingException(\sprintf('Context on "%s::%s()" cannot be added. Context can only be added on methods beginning with "get", "is", "has", "can" or "set".', $className, $method->name));
|
||||
}
|
||||
|
||||
$this->setAttributeContextsForGroups($attribute, $attributeMetadata);
|
||||
}
|
||||
|
||||
$loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $loaded;
|
||||
}
|
||||
|
||||
private function loadAttributes(\ReflectionMethod|\ReflectionClass|\ReflectionProperty $reflector): iterable
|
||||
{
|
||||
foreach ($reflector->getAttributes() as $attribute) {
|
||||
if ($this->isKnownAttribute($attribute->getName())) {
|
||||
try {
|
||||
yield $attribute->newInstance();
|
||||
} catch (\Error $e) {
|
||||
if (\Error::class !== $e::class) {
|
||||
throw $e;
|
||||
}
|
||||
$on = match (true) {
|
||||
$reflector instanceof \ReflectionClass => ' on class '.$reflector->name,
|
||||
$reflector instanceof \ReflectionMethod => \sprintf(' on "%s::%s()"', $reflector->getDeclaringClass()->name, $reflector->name),
|
||||
$reflector instanceof \ReflectionProperty => \sprintf(' on "%s::$%s"', $reflector->getDeclaringClass()->name, $reflector->name),
|
||||
default => '',
|
||||
};
|
||||
|
||||
throw new MappingException(\sprintf('Could not instantiate attribute "%s"%s.', $attribute->getName(), $on), 0, $e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function setAttributeContextsForGroups(Context $attribute, AttributeMetadataInterface $attributeMetadata): void
|
||||
{
|
||||
$context = $attribute->context;
|
||||
$groups = $attribute->groups;
|
||||
$normalizationContext = $attribute->normalizationContext;
|
||||
$denormalizationContext = $attribute->denormalizationContext;
|
||||
|
||||
if ($normalizationContext || $context) {
|
||||
$attributeMetadata->setNormalizationContextForGroups($normalizationContext ?: $context, $groups);
|
||||
}
|
||||
|
||||
if ($denormalizationContext || $context) {
|
||||
$attributeMetadata->setDenormalizationContextForGroups($denormalizationContext ?: $context, $groups);
|
||||
}
|
||||
}
|
||||
|
||||
private function isKnownAttribute(string $attributeName): bool
|
||||
{
|
||||
foreach (self::KNOWN_ATTRIBUTES as $knownAttribute) {
|
||||
if (is_a($attributeName, $knownAttribute, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
39
backend/vendor/symfony/serializer/Mapping/Loader/FileLoader.php
vendored
Normal file
39
backend/vendor/symfony/serializer/Mapping/Loader/FileLoader.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Mapping\Loader;
|
||||
|
||||
use Symfony\Component\Serializer\Exception\MappingException;
|
||||
|
||||
/**
|
||||
* Base class for all file based loaders.
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
abstract class FileLoader implements LoaderInterface
|
||||
{
|
||||
/**
|
||||
* @param string $file The mapping file to load
|
||||
*
|
||||
* @throws MappingException if the mapping file does not exist or is not readable
|
||||
*/
|
||||
public function __construct(
|
||||
protected string $file,
|
||||
) {
|
||||
if (!is_file($file)) {
|
||||
throw new MappingException(\sprintf('The mapping file "%s" does not exist.', $file));
|
||||
}
|
||||
|
||||
if (!is_readable($file)) {
|
||||
throw new MappingException(\sprintf('The mapping file "%s" is not readable.', $file));
|
||||
}
|
||||
}
|
||||
}
|
||||
64
backend/vendor/symfony/serializer/Mapping/Loader/LoaderChain.php
vendored
Normal file
64
backend/vendor/symfony/serializer/Mapping/Loader/LoaderChain.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Mapping\Loader;
|
||||
|
||||
use Symfony\Component\Serializer\Exception\MappingException;
|
||||
use Symfony\Component\Serializer\Mapping\ClassMetadataInterface;
|
||||
|
||||
/**
|
||||
* Calls multiple {@link LoaderInterface} instances in a chain.
|
||||
*
|
||||
* This class accepts multiple instances of LoaderInterface to be passed to the
|
||||
* constructor. When {@link loadClassMetadata()} is called, the same method is called
|
||||
* in <em>all</em> of these loaders, regardless of whether any of them was
|
||||
* successful or not.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class LoaderChain implements LoaderInterface
|
||||
{
|
||||
/**
|
||||
* Accepts a list of LoaderInterface instances.
|
||||
*
|
||||
* @param LoaderInterface[] $loaders An array of LoaderInterface instances
|
||||
*
|
||||
* @throws MappingException If any of the loaders does not implement LoaderInterface
|
||||
*/
|
||||
public function __construct(private readonly array $loaders)
|
||||
{
|
||||
foreach ($loaders as $loader) {
|
||||
if (!$loader instanceof LoaderInterface) {
|
||||
throw new MappingException(\sprintf('Class "%s" is expected to implement LoaderInterface.', get_debug_type($loader)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function loadClassMetadata(ClassMetadataInterface $metadata): bool
|
||||
{
|
||||
$success = false;
|
||||
|
||||
foreach ($this->loaders as $loader) {
|
||||
$success = $loader->loadClassMetadata($metadata) || $success;
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return LoaderInterface[]
|
||||
*/
|
||||
public function getLoaders(): array
|
||||
{
|
||||
return $this->loaders;
|
||||
}
|
||||
}
|
||||
24
backend/vendor/symfony/serializer/Mapping/Loader/LoaderInterface.php
vendored
Normal file
24
backend/vendor/symfony/serializer/Mapping/Loader/LoaderInterface.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Mapping\Loader;
|
||||
|
||||
use Symfony\Component\Serializer\Mapping\ClassMetadataInterface;
|
||||
|
||||
/**
|
||||
* Loads {@link ClassMetadataInterface}.
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
interface LoaderInterface
|
||||
{
|
||||
public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool;
|
||||
}
|
||||
186
backend/vendor/symfony/serializer/Mapping/Loader/XmlFileLoader.php
vendored
Normal file
186
backend/vendor/symfony/serializer/Mapping/Loader/XmlFileLoader.php
vendored
Normal file
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Mapping\Loader;
|
||||
|
||||
use Symfony\Component\Config\Util\XmlUtils;
|
||||
use Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException;
|
||||
use Symfony\Component\PropertyAccess\PropertyPath;
|
||||
use Symfony\Component\Serializer\Exception\MappingException;
|
||||
use Symfony\Component\Serializer\Mapping\AttributeMetadata;
|
||||
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping;
|
||||
use Symfony\Component\Serializer\Mapping\ClassMetadataInterface;
|
||||
|
||||
/**
|
||||
* Loads XML mapping files.
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class XmlFileLoader extends FileLoader
|
||||
{
|
||||
/**
|
||||
* An array of {@class \SimpleXMLElement} instances.
|
||||
*
|
||||
* @var array<class-string, \SimpleXMLElement>|null
|
||||
*/
|
||||
private ?array $classes = null;
|
||||
|
||||
public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
|
||||
{
|
||||
if (!$this->classes ??= $this->getClassesFromXml()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$attributesMetadata = $classMetadata->getAttributesMetadata();
|
||||
|
||||
if (isset($this->classes[$classMetadata->getName()])) {
|
||||
$xml = $this->classes[$classMetadata->getName()];
|
||||
|
||||
foreach ($xml->attribute as $attribute) {
|
||||
$attributeName = (string) $attribute['name'];
|
||||
|
||||
if (isset($attributesMetadata[$attributeName])) {
|
||||
$attributeMetadata = $attributesMetadata[$attributeName];
|
||||
} else {
|
||||
$attributeMetadata = new AttributeMetadata($attributeName);
|
||||
$classMetadata->addAttributeMetadata($attributeMetadata);
|
||||
}
|
||||
|
||||
foreach ($attribute->group as $group) {
|
||||
$attributeMetadata->addGroup((string) $group);
|
||||
}
|
||||
|
||||
if (isset($attribute['max-depth'])) {
|
||||
$attributeMetadata->setMaxDepth((int) $attribute['max-depth']);
|
||||
}
|
||||
|
||||
if (isset($attribute['serialized-name'])) {
|
||||
$attributeMetadata->setSerializedName((string) $attribute['serialized-name']);
|
||||
}
|
||||
|
||||
if (isset($attribute['serialized-path'])) {
|
||||
try {
|
||||
$attributeMetadata->setSerializedPath(new PropertyPath((string) $attribute['serialized-path']));
|
||||
} catch (InvalidPropertyPathException) {
|
||||
throw new MappingException(\sprintf('The "serialized-path" value must be a valid property path for the attribute "%s" of the class "%s".', $attributeName, $classMetadata->getName()));
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($attribute['ignore'])) {
|
||||
$attributeMetadata->setIgnore(XmlUtils::phpize($attribute['ignore']));
|
||||
}
|
||||
|
||||
foreach ($attribute->context as $node) {
|
||||
$groups = (array) $node->group;
|
||||
$context = $this->parseContext($node->entry);
|
||||
$attributeMetadata->setNormalizationContextForGroups($context, $groups);
|
||||
$attributeMetadata->setDenormalizationContextForGroups($context, $groups);
|
||||
}
|
||||
|
||||
foreach ($attribute->normalization_context as $node) {
|
||||
$groups = (array) $node->group;
|
||||
$context = $this->parseContext($node->entry);
|
||||
$attributeMetadata->setNormalizationContextForGroups($context, $groups);
|
||||
}
|
||||
|
||||
foreach ($attribute->denormalization_context as $node) {
|
||||
$groups = (array) $node->group;
|
||||
$context = $this->parseContext($node->entry);
|
||||
$attributeMetadata->setDenormalizationContextForGroups($context, $groups);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($xml->{'discriminator-map'})) {
|
||||
$mapping = [];
|
||||
foreach ($xml->{'discriminator-map'}->mapping as $element) {
|
||||
$elementAttributes = $element->attributes();
|
||||
$mapping[(string) $elementAttributes->type] = (string) $elementAttributes->class;
|
||||
}
|
||||
|
||||
$classMetadata->setClassDiscriminatorMapping(new ClassDiscriminatorMapping(
|
||||
(string) $xml->{'discriminator-map'}->attributes()->{'type-property'},
|
||||
$mapping,
|
||||
$xml->{'discriminator-map'}->attributes()->{'default-type'} ?? null
|
||||
));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the names of the classes mapped in this file.
|
||||
*
|
||||
* @return class-string[]
|
||||
*/
|
||||
public function getMappedClasses(): array
|
||||
{
|
||||
return array_keys($this->classes ??= $this->getClassesFromXml());
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses an XML File.
|
||||
*
|
||||
* @throws MappingException
|
||||
*/
|
||||
private function parseFile(string $file): \SimpleXMLElement
|
||||
{
|
||||
try {
|
||||
$dom = XmlUtils::loadFile($file, __DIR__.'/schema/dic/serializer-mapping/serializer-mapping-1.0.xsd');
|
||||
} catch (\Exception $e) {
|
||||
throw new MappingException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
|
||||
return simplexml_import_dom($dom);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string, \SimpleXMLElement>
|
||||
*/
|
||||
private function getClassesFromXml(): array
|
||||
{
|
||||
$xml = $this->parseFile($this->file);
|
||||
$classes = [];
|
||||
|
||||
foreach ($xml->class as $class) {
|
||||
$classes[(string) $class['name']] = $class;
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
private function parseContext(\SimpleXMLElement $nodes): array
|
||||
{
|
||||
$context = [];
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
if (\count($node) > 0) {
|
||||
if (\count($node->entry) > 0) {
|
||||
$value = $this->parseContext($node->entry);
|
||||
} else {
|
||||
$value = [];
|
||||
}
|
||||
} else {
|
||||
$value = XmlUtils::phpize($node);
|
||||
}
|
||||
|
||||
if (isset($node['name'])) {
|
||||
$context[(string) $node['name']] = $value;
|
||||
} else {
|
||||
$context[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $context;
|
||||
}
|
||||
}
|
||||
177
backend/vendor/symfony/serializer/Mapping/Loader/YamlFileLoader.php
vendored
Normal file
177
backend/vendor/symfony/serializer/Mapping/Loader/YamlFileLoader.php
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\Mapping\Loader;
|
||||
|
||||
use Symfony\Component\PropertyAccess\Exception\InvalidPropertyPathException;
|
||||
use Symfony\Component\PropertyAccess\PropertyPath;
|
||||
use Symfony\Component\Serializer\Exception\MappingException;
|
||||
use Symfony\Component\Serializer\Mapping\AttributeMetadata;
|
||||
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping;
|
||||
use Symfony\Component\Serializer\Mapping\ClassMetadataInterface;
|
||||
use Symfony\Component\Yaml\Parser;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
/**
|
||||
* YAML File Loader.
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class YamlFileLoader extends FileLoader
|
||||
{
|
||||
private ?Parser $yamlParser = null;
|
||||
|
||||
/**
|
||||
* @var array<class-string, array>
|
||||
*/
|
||||
private ?array $classes = null;
|
||||
|
||||
public function loadClassMetadata(ClassMetadataInterface $classMetadata): bool
|
||||
{
|
||||
if (!$this->classes ??= $this->getClassesFromYaml()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isset($this->classes[$classMetadata->getName()])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$yaml = $this->classes[$classMetadata->getName()];
|
||||
|
||||
if (isset($yaml['attributes']) && \is_array($yaml['attributes'])) {
|
||||
$attributesMetadata = $classMetadata->getAttributesMetadata();
|
||||
|
||||
foreach ($yaml['attributes'] as $attribute => $data) {
|
||||
if (isset($attributesMetadata[$attribute])) {
|
||||
$attributeMetadata = $attributesMetadata[$attribute];
|
||||
} else {
|
||||
$attributeMetadata = new AttributeMetadata($attribute);
|
||||
$classMetadata->addAttributeMetadata($attributeMetadata);
|
||||
}
|
||||
|
||||
if (isset($data['groups'])) {
|
||||
if (!\is_array($data['groups'])) {
|
||||
throw new MappingException(\sprintf('The "groups" key must be an array of strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName()));
|
||||
}
|
||||
|
||||
foreach ($data['groups'] as $group) {
|
||||
if (!\is_string($group)) {
|
||||
throw new MappingException(\sprintf('Group names must be strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName()));
|
||||
}
|
||||
|
||||
$attributeMetadata->addGroup($group);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['max_depth'])) {
|
||||
if (!\is_int($data['max_depth'])) {
|
||||
throw new MappingException(\sprintf('The "max_depth" value must be an integer in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName()));
|
||||
}
|
||||
|
||||
$attributeMetadata->setMaxDepth($data['max_depth']);
|
||||
}
|
||||
|
||||
if (isset($data['serialized_name'])) {
|
||||
if (!\is_string($data['serialized_name']) || '' === $data['serialized_name']) {
|
||||
throw new MappingException(\sprintf('The "serialized_name" value must be a non-empty string in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName()));
|
||||
}
|
||||
|
||||
$attributeMetadata->setSerializedName($data['serialized_name']);
|
||||
}
|
||||
|
||||
if (isset($data['serialized_path'])) {
|
||||
try {
|
||||
$attributeMetadata->setSerializedPath(new PropertyPath((string) $data['serialized_path']));
|
||||
} catch (InvalidPropertyPathException) {
|
||||
throw new MappingException(\sprintf('The "serialized_path" value must be a valid property path in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName()));
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['ignore'])) {
|
||||
if (!\is_bool($data['ignore'])) {
|
||||
throw new MappingException(\sprintf('The "ignore" value must be a boolean in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName()));
|
||||
}
|
||||
|
||||
$attributeMetadata->setIgnore($data['ignore']);
|
||||
}
|
||||
|
||||
foreach ($data['contexts'] ?? [] as $line) {
|
||||
$groups = $line['groups'] ?? [];
|
||||
|
||||
if ($context = $line['context'] ?? false) {
|
||||
$attributeMetadata->setNormalizationContextForGroups($context, $groups);
|
||||
$attributeMetadata->setDenormalizationContextForGroups($context, $groups);
|
||||
}
|
||||
|
||||
if ($context = $line['normalization_context'] ?? false) {
|
||||
$attributeMetadata->setNormalizationContextForGroups($context, $groups);
|
||||
}
|
||||
|
||||
if ($context = $line['denormalization_context'] ?? false) {
|
||||
$attributeMetadata->setDenormalizationContextForGroups($context, $groups);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($yaml['discriminator_map'])) {
|
||||
if (!isset($yaml['discriminator_map']['type_property'])) {
|
||||
throw new MappingException(\sprintf('The "type_property" key must be set for the discriminator map of the class "%s" in "%s".', $classMetadata->getName(), $this->file));
|
||||
}
|
||||
|
||||
if (!isset($yaml['discriminator_map']['mapping'])) {
|
||||
throw new MappingException(\sprintf('The "mapping" key must be set for the discriminator map of the class "%s" in "%s".', $classMetadata->getName(), $this->file));
|
||||
}
|
||||
|
||||
$classMetadata->setClassDiscriminatorMapping(new ClassDiscriminatorMapping(
|
||||
$yaml['discriminator_map']['type_property'],
|
||||
$yaml['discriminator_map']['mapping'],
|
||||
$yaml['discriminator_map']['default_type'] ?? null
|
||||
));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the names of the classes mapped in this file.
|
||||
*
|
||||
* @return class-string[]
|
||||
*/
|
||||
public function getMappedClasses(): array
|
||||
{
|
||||
return array_keys($this->classes ??= $this->getClassesFromYaml());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string, array>
|
||||
*/
|
||||
private function getClassesFromYaml(): array
|
||||
{
|
||||
if (!stream_is_local($this->file)) {
|
||||
throw new MappingException(\sprintf('This is not a local file "%s".', $this->file));
|
||||
}
|
||||
|
||||
$this->yamlParser ??= new Parser();
|
||||
|
||||
$classes = $this->yamlParser->parseFile($this->file, Yaml::PARSE_CONSTANT);
|
||||
|
||||
if (!$classes) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!\is_array($classes)) {
|
||||
throw new MappingException(\sprintf('The file "%s" must contain a YAML array.', $this->file));
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
<?xml version="1.0" ?>
|
||||
|
||||
<xsd:schema xmlns="http://symfony.com/schema/dic/serializer-mapping"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
targetNamespace="http://symfony.com/schema/dic/serializer-mapping"
|
||||
elementFormDefault="qualified">
|
||||
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Symfony Serializer Mapping Schema, version 1.0
|
||||
Authors: Kévin Dunglas, Samuel Roze
|
||||
|
||||
A serializer mapping connects attributes with serialization groups.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
|
||||
<xsd:element name="serializer" type="serializer" />
|
||||
|
||||
<xsd:complexType name="serializer">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The root element of the serializer mapping definition.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:element name="class" type="class" />
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="class">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Contains serialization groups for a single class.
|
||||
|
||||
Nested elements may be class property and/or getter definitions.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:element name="attribute" type="attribute" minOccurs="0" maxOccurs="unbounded" />
|
||||
<xsd:element name="discriminator-map" type="discriminator-map" />
|
||||
</xsd:choice>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="discriminator-map">
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:element name="mapping" type="discriminator-map-mapping" maxOccurs="unbounded" />
|
||||
</xsd:choice>
|
||||
<xsd:attribute name="type-property" type="xsd:string" use="required" />
|
||||
<xsd:attribute name="default-type" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="discriminator-map-mapping">
|
||||
<xsd:attribute name="type" type="xsd:string" use="required" />
|
||||
<xsd:attribute name="class" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="attribute">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
Contains serialization groups and max depth for attributes. The name of the attribute should be given in the "name" option.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:element name="group" type="xsd:string" maxOccurs="unbounded" />
|
||||
<xsd:element name="context" type="context" maxOccurs="unbounded" />
|
||||
<xsd:element name="normalization_context" type="context" maxOccurs="unbounded" />
|
||||
<xsd:element name="denormalization_context" type="context" maxOccurs="unbounded" />
|
||||
</xsd:choice>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
<xsd:attribute name="max-depth">
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:integer">
|
||||
<xsd:minInclusive value="0" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="serialized-name">
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:minLength value="1" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="serialized-path">
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:minLength value="1" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="ignore" type="xsd:boolean" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="context">
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="group" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
|
||||
<xsd:element name="entry" type="context-root-entry" maxOccurs="unbounded" />
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="context-root-entry" mixed="true">
|
||||
<xsd:sequence minOccurs="0">
|
||||
<xsd:element name="entry" type="context-entry" maxOccurs="unbounded" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute type="xsd:string" name="name" use="required" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="context-entry" mixed="true">
|
||||
<xsd:sequence minOccurs="0">
|
||||
<xsd:element name="entry" type="context-entry" maxOccurs="unbounded" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute type="xsd:string" name="name" />
|
||||
</xsd:complexType>
|
||||
|
||||
</xsd:schema>
|
||||
418
backend/vendor/symfony/serializer/Mapping/Loader/schema/serialization.schema.json
vendored
Normal file
418
backend/vendor/symfony/serializer/Mapping/Loader/schema/serialization.schema.json
vendored
Normal file
@@ -0,0 +1,418 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Symfony Serializer Mapping Schema",
|
||||
"description": "JSON schema for Symfony's serialization mapping",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"patternProperties": {
|
||||
"^[A-Za-z0-9\\\\_]+$": {
|
||||
"type": "object",
|
||||
"description": "Class metadata configuration",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"attributes": {
|
||||
"type": "object",
|
||||
"description": "Attribute metadata configurations",
|
||||
"additionalProperties": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"description": "Attribute metadata configuration",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"groups": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Serialization groups for this attribute"
|
||||
},
|
||||
"max_depth": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"description": "Maximum serialization depth for this attribute"
|
||||
},
|
||||
"serialized_name": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"description": "Custom name for serialization"
|
||||
},
|
||||
"serialized_path": {
|
||||
"type": "string",
|
||||
"description": "Property path for serialization (e.g., '[one][two]')"
|
||||
},
|
||||
"ignore": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to ignore this attribute during serialization"
|
||||
},
|
||||
"contexts": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"description": "Context entry with optional groups",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"context": {
|
||||
"$ref": "#/definitions/contextObject"
|
||||
},
|
||||
"normalization_context": {
|
||||
"$ref": "#/definitions/contextObject"
|
||||
},
|
||||
"denormalization_context": {
|
||||
"$ref": "#/definitions/contextObject"
|
||||
},
|
||||
"groups": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Groups this context applies to"
|
||||
}
|
||||
},
|
||||
"anyOf": [
|
||||
{
|
||||
"required": ["context"]
|
||||
},
|
||||
{
|
||||
"required": ["normalization_context"]
|
||||
},
|
||||
{
|
||||
"required": ["denormalization_context"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"description": "Context configurations for this attribute"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "null",
|
||||
"description": "Empty attribute metadata"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"discriminator_map": {
|
||||
"type": "object",
|
||||
"description": "Class discriminator mapping configuration",
|
||||
"additionalProperties": false,
|
||||
"required": ["type_property", "mapping"],
|
||||
"properties": {
|
||||
"type_property": {
|
||||
"type": "string",
|
||||
"description": "Property name used to determine the class type"
|
||||
},
|
||||
"mapping": {
|
||||
"type": "object",
|
||||
"description": "Mapping from type values to class names",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"default_type": {
|
||||
"type": "string",
|
||||
"description": "Default type when no mapping is found"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"contextObject": {
|
||||
"type": "object",
|
||||
"description": "Context object with key-value pairs",
|
||||
"properties": {
|
||||
"circular_reference_limit": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"description": "How many loops of circular reference to allow while normalizing"
|
||||
},
|
||||
"object_to_populate": {
|
||||
"type": "object",
|
||||
"description": "Object to be updated instead of creating a new instance"
|
||||
},
|
||||
"groups": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"description": "Groups containing attributes to (de)normalize"
|
||||
},
|
||||
"attributes": {
|
||||
"type": "object",
|
||||
"description": "Attributes to (de)normalize"
|
||||
},
|
||||
"allow_extra_attributes": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to ignore extra attributes or throw an exception"
|
||||
},
|
||||
"default_constructor_arguments": {
|
||||
"type": "object",
|
||||
"description": "Hashmap of classes containing hashmaps of constructor argument => default value"
|
||||
},
|
||||
"callbacks": {
|
||||
"type": "object",
|
||||
"description": "Hashmap of field name => callable to normalize this field"
|
||||
},
|
||||
"circular_reference_handler": {
|
||||
"type": "object",
|
||||
"description": "Handler to call when a circular reference has been detected"
|
||||
},
|
||||
"ignored_attributes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Attributes to be skipped when normalizing an object tree"
|
||||
},
|
||||
"require_all_properties": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to require all properties to be listed in the input"
|
||||
},
|
||||
"enable_max_depth": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to respect the max depth metadata on fields"
|
||||
},
|
||||
"depth_key_pattern": {
|
||||
"type": "string",
|
||||
"description": "Pattern to keep track of the current depth (must contain exactly two string placeholders)"
|
||||
},
|
||||
"disable_type_enforcement": {
|
||||
"type": "boolean",
|
||||
"description": "Whether verifying types match during denormalization"
|
||||
},
|
||||
"skip_null_values": {
|
||||
"type": "boolean",
|
||||
"description": "Whether fields with the value null should be output during normalization"
|
||||
},
|
||||
"skip_uninitialized_values": {
|
||||
"type": "boolean",
|
||||
"description": "Whether uninitialized typed class properties should be excluded during normalization"
|
||||
},
|
||||
"max_depth_handler": {
|
||||
"type": "object",
|
||||
"description": "Callback to allow to set a value for an attribute when the max depth has been reached"
|
||||
},
|
||||
"exclude_from_cache_keys": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Context keys not relevant to determine which attributes to (de)normalize"
|
||||
},
|
||||
"deep_object_to_populate": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to tell the denormalizer to also populate existing objects on attributes"
|
||||
},
|
||||
"preserve_empty_objects": {
|
||||
"type": "boolean",
|
||||
"description": "Whether an empty object should be kept as an object or converted to a list"
|
||||
},
|
||||
"normalize_visibility": {
|
||||
"type": "integer",
|
||||
"description": "Whether fields should be output based on visibility (PropertyNormalizer)"
|
||||
},
|
||||
"format": {
|
||||
"type": "string",
|
||||
"description": "Format of the date (DateTimeNormalizer)"
|
||||
},
|
||||
"timezone": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "object"
|
||||
}
|
||||
],
|
||||
"description": "Timezone of the date (DateTimeNormalizer)"
|
||||
},
|
||||
"forceTimezone": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to enforce the timezone during denormalization (DateTimeNormalizer)"
|
||||
},
|
||||
"cast": {
|
||||
"enum": ["int", "float"],
|
||||
"description": "Cast type for DateTime (DateTimeNormalizer)"
|
||||
},
|
||||
"encode_options": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"description": "json_encode flags bitmask (JsonEncoder)"
|
||||
},
|
||||
"decode_options": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"description": "json_decode flags bitmask (JsonEncoder)"
|
||||
},
|
||||
"associative": {
|
||||
"type": "boolean",
|
||||
"description": "Whether decoded objects will be given as associative arrays (JsonEncoder)"
|
||||
},
|
||||
"recursion_depth": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"description": "Maximum recursion depth (JsonEncoder)"
|
||||
},
|
||||
"as_collection": {
|
||||
"type": "boolean",
|
||||
"description": "Whether the decoded result should be considered as a collection (XmlEncoder/CsvEncoder)"
|
||||
},
|
||||
"decoder_ignored_node_types": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer"
|
||||
},
|
||||
"description": "Node types to ignore while decoding (XmlEncoder)"
|
||||
},
|
||||
"encoder_ignored_node_types": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer"
|
||||
},
|
||||
"description": "Node types to ignore while encoding (XmlEncoder)"
|
||||
},
|
||||
"encoding": {
|
||||
"type": "string",
|
||||
"description": "DOMDocument encoding (XmlEncoder)"
|
||||
},
|
||||
"format_output": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to encode with indentation and extra space (XmlEncoder)"
|
||||
},
|
||||
"load_options": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"description": "DOMDocument::loadXml options bitmask (XmlEncoder)"
|
||||
},
|
||||
"save_options": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"description": "DOMDocument::saveXml options bitmask (XmlEncoder)"
|
||||
},
|
||||
"remove_empty_tags": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to keep empty nodes (XmlEncoder)"
|
||||
},
|
||||
"root_node_name": {
|
||||
"type": "string",
|
||||
"description": "Name of the root node (XmlEncoder)"
|
||||
},
|
||||
"standalone": {
|
||||
"type": "boolean",
|
||||
"description": "Whether the document will be standalone (XmlEncoder)"
|
||||
},
|
||||
"type_cast_attributes": {
|
||||
"type": "boolean",
|
||||
"description": "Whether casting numeric string attributes to integers or floats (XmlEncoder)"
|
||||
},
|
||||
"version": {
|
||||
"type": "string",
|
||||
"description": "Version number of the document (XmlEncoder)"
|
||||
},
|
||||
"cdata_wrapping": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to wrap strings within CDATA sections (XmlEncoder)"
|
||||
},
|
||||
"cdata_wrapping_pattern": {
|
||||
"type": "string",
|
||||
"description": "Pattern used to evaluate if a CDATA section should be added (XmlEncoder)"
|
||||
},
|
||||
"ignore_empty_attributes": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to ignore empty attributes (XmlEncoder)"
|
||||
},
|
||||
"preserve_numeric_keys": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to preserve numeric keys in array (XmlEncoder)"
|
||||
},
|
||||
"inline_threshold": {
|
||||
"type": "integer",
|
||||
"description": "Threshold to switch to inline YAML (YamlEncoder)"
|
||||
},
|
||||
"indent_level": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"description": "Indentation level (YamlEncoder)"
|
||||
},
|
||||
"flags": {
|
||||
"type": "integer",
|
||||
"description": "Yaml::dump flags bitmask (YamlEncoder)"
|
||||
},
|
||||
"preserved_empty_objects": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to preserve empty objects or convert them to null (YamlEncoder)"
|
||||
},
|
||||
"delimiter": {
|
||||
"type": "string",
|
||||
"maxLength": 1,
|
||||
"description": "Column delimiter character (CsvEncoder)"
|
||||
},
|
||||
"enclosure": {
|
||||
"type": "string",
|
||||
"maxLength": 1,
|
||||
"description": "Field enclosure character (CsvEncoder)"
|
||||
},
|
||||
"escape_char": {
|
||||
"type": "string",
|
||||
"maxLength": 1,
|
||||
"description": "Escape character (CsvEncoder, deprecated)"
|
||||
},
|
||||
"key_separator": {
|
||||
"type": "string",
|
||||
"description": "Key separator when (un)flattening arrays (CsvEncoder)"
|
||||
},
|
||||
"headers": {
|
||||
"type": "array",
|
||||
"description": "Headers (CsvEncoder)"
|
||||
},
|
||||
"escaped_formulas": {
|
||||
"type": "boolean",
|
||||
"description": "Whether formulas should be escaped (CsvEncoder)"
|
||||
},
|
||||
"no_headers": {
|
||||
"type": "boolean",
|
||||
"description": "Whether the input/output is containing headers (CsvEncoder)"
|
||||
},
|
||||
"end_of_line": {
|
||||
"type": "string",
|
||||
"description": "End of line characters (CsvEncoder)"
|
||||
},
|
||||
"output_utf8_bom": {
|
||||
"type": "boolean",
|
||||
"description": "Whether to add the UTF-8 Byte Order Mark (CsvEncoder)"
|
||||
}
|
||||
},
|
||||
"additionalProperties": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
},
|
||||
{
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "object"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
26
backend/vendor/symfony/serializer/NameConverter/AdvancedNameConverterInterface.php
vendored
Normal file
26
backend/vendor/symfony/serializer/NameConverter/AdvancedNameConverterInterface.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Serializer\NameConverter;
|
||||
|
||||
/**
|
||||
* Gives access to the class, the format and the context in the property name converters.
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*
|
||||
* @deprecated since Symfony 7.2, use NameConverterInterface instead
|
||||
*/
|
||||
interface AdvancedNameConverterInterface extends NameConverterInterface
|
||||
{
|
||||
public function normalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string;
|
||||
|
||||
public function denormalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user