304 lines
13 KiB
YAML
304 lines
13 KiB
YAML
|
name: AbstractNormalizer
|
||
|
class_comment: null
|
||
|
dependencies:
|
||
|
- name: CircularReferenceException
|
||
|
type: class
|
||
|
source: Symfony\Component\Serializer\Exception\CircularReferenceException
|
||
|
- name: InvalidArgumentException
|
||
|
type: class
|
||
|
source: Symfony\Component\Serializer\Exception\InvalidArgumentException
|
||
|
- name: LogicException
|
||
|
type: class
|
||
|
source: Symfony\Component\Serializer\Exception\LogicException
|
||
|
- name: MissingConstructorArgumentsException
|
||
|
type: class
|
||
|
source: Symfony\Component\Serializer\Exception\MissingConstructorArgumentsException
|
||
|
- name: NotNormalizableValueException
|
||
|
type: class
|
||
|
source: Symfony\Component\Serializer\Exception\NotNormalizableValueException
|
||
|
- name: RuntimeException
|
||
|
type: class
|
||
|
source: Symfony\Component\Serializer\Exception\RuntimeException
|
||
|
- name: AttributeMetadataInterface
|
||
|
type: class
|
||
|
source: Symfony\Component\Serializer\Mapping\AttributeMetadataInterface
|
||
|
- name: ClassMetadataFactoryInterface
|
||
|
type: class
|
||
|
source: Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface
|
||
|
- name: NameConverterInterface
|
||
|
type: class
|
||
|
source: Symfony\Component\Serializer\NameConverter\NameConverterInterface
|
||
|
- name: SerializerAwareInterface
|
||
|
type: class
|
||
|
source: Symfony\Component\Serializer\SerializerAwareInterface
|
||
|
- name: SerializerAwareTrait
|
||
|
type: class
|
||
|
source: Symfony\Component\Serializer\SerializerAwareTrait
|
||
|
- name: ObjectToPopulateTrait
|
||
|
type: class
|
||
|
source: ObjectToPopulateTrait
|
||
|
- name: SerializerAwareTrait
|
||
|
type: class
|
||
|
source: SerializerAwareTrait
|
||
|
properties: []
|
||
|
methods:
|
||
|
- name: __construct
|
||
|
visibility: public
|
||
|
parameters:
|
||
|
- name: classMetadataFactory
|
||
|
default: 'null'
|
||
|
- name: nameConverter
|
||
|
default: 'null'
|
||
|
- name: defaultContext
|
||
|
default: '[]'
|
||
|
comment: "# * Normalizer implementation.\n# *\n# * @author K\xE9vin Dunglas <dunglas@gmail.com>\n\
|
||
|
# */\n# abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerInterface,\
|
||
|
\ SerializerAwareInterface\n# {\n# use ObjectToPopulateTrait;\n# use SerializerAwareTrait;\n\
|
||
|
# \n# /* constants to configure the context */\n# \n# /**\n# * How many loops\
|
||
|
\ of circular reference to allow while normalizing.\n# *\n# * The default value\
|
||
|
\ of 1 means that when we encounter the same object a\n# * second time, we consider\
|
||
|
\ that a circular reference.\n# *\n# * You can raise this value for special cases,\
|
||
|
\ e.g. in combination with the\n# * max depth setting of the object normalizer.\n\
|
||
|
# */\n# public const CIRCULAR_REFERENCE_LIMIT = 'circular_reference_limit';\n\
|
||
|
# \n# /**\n# * Instead of creating a new instance of an object, update the specified\
|
||
|
\ object.\n# *\n# * If you have a nested structure, child objects will be overwritten\
|
||
|
\ with\n# * new instances unless you set DEEP_OBJECT_TO_POPULATE to true.\n# */\n\
|
||
|
# public const OBJECT_TO_POPULATE = 'object_to_populate';\n# \n# /**\n# * Only\
|
||
|
\ (de)normalize attributes that are in the specified groups.\n# */\n# public const\
|
||
|
\ GROUPS = 'groups';\n# \n# /**\n# * Limit (de)normalize to the specified names.\n\
|
||
|
# *\n# * For nested structures, this list needs to reflect the object tree.\n\
|
||
|
# */\n# public const ATTRIBUTES = 'attributes';\n# \n# /**\n# * If ATTRIBUTES\
|
||
|
\ are specified, and the source has fields that are not part of that list,\n#\
|
||
|
\ * either ignore those attributes (true) or throw an ExtraAttributesException\
|
||
|
\ (false).\n# */\n# public const ALLOW_EXTRA_ATTRIBUTES = 'allow_extra_attributes';\n\
|
||
|
# \n# /**\n# * Hashmap of default values for constructor arguments.\n# *\n# *\
|
||
|
\ The names need to match the parameter names in the constructor arguments.\n\
|
||
|
# */\n# public const DEFAULT_CONSTRUCTOR_ARGUMENTS = 'default_constructor_arguments';\n\
|
||
|
# \n# /**\n# * Hashmap of field name => callable to (de)normalize this field.\n\
|
||
|
# *\n# * The callable is called if the field is encountered with the arguments:\n\
|
||
|
# *\n# * - mixed $attributeValue value of this field\n# * - object|string\
|
||
|
\ $object the whole object being normalized or the object's class being\
|
||
|
\ denormalized\n# * - string $attributeName name of the attribute being\
|
||
|
\ (de)normalized\n# * - string $format the requested format\n#\
|
||
|
\ * - array $context the serialization context\n# */\n# public\
|
||
|
\ const CALLBACKS = 'callbacks';\n# \n# /**\n# * Handler to call when a circular\
|
||
|
\ reference has been detected.\n# *\n# * If you specify no handler, a CircularReferenceException\
|
||
|
\ is thrown.\n# *\n# * The method will be called with ($object, $format, $context)\
|
||
|
\ and its\n# * return value is returned as the result of the normalize call.\n\
|
||
|
# */\n# public const CIRCULAR_REFERENCE_HANDLER = 'circular_reference_handler';\n\
|
||
|
# \n# /**\n# * Skip the specified attributes when normalizing an object tree.\n\
|
||
|
# *\n# * This list is applied to each element of nested structures.\n# *\n# *\
|
||
|
\ Note: The behaviour for nested structures is different from ATTRIBUTES\n# *\
|
||
|
\ for historical reason. Aligning the behaviour would be a BC break.\n# */\n#\
|
||
|
\ public const IGNORED_ATTRIBUTES = 'ignored_attributes';\n# \n# /**\n# * Require\
|
||
|
\ all properties to be listed in the input instead of falling\n# * back to null\
|
||
|
\ for nullable ones.\n# */\n# public const REQUIRE_ALL_PROPERTIES = 'require_all_properties';\n\
|
||
|
# \n# /**\n# * Flag to control whether a non-boolean value should be filtered\
|
||
|
\ using the\n# * filter_var function with the {@see https://www.php.net/manual/fr/filter.filters.validate.php}\n\
|
||
|
# * \\FILTER_VALIDATE_BOOL filter before casting it to a boolean.\n# *\n# * \"\
|
||
|
0\", \"false\", \"off\", \"no\" and \"\" will be cast to false.\n# * \"1\", \"\
|
||
|
true\", \"on\" and \"yes\" will be cast to true.\n# */\n# public const FILTER_BOOL\
|
||
|
\ = 'filter_bool';\n# \n# /**\n# * @internal\n# */\n# protected const CIRCULAR_REFERENCE_LIMIT_COUNTERS\
|
||
|
\ = 'circular_reference_limit_counters';\n# \n# protected array $defaultContext\
|
||
|
\ = [\n# self::ALLOW_EXTRA_ATTRIBUTES => true,\n# self::CIRCULAR_REFERENCE_HANDLER\
|
||
|
\ => null,\n# self::CIRCULAR_REFERENCE_LIMIT => 1,\n# self::IGNORED_ATTRIBUTES\
|
||
|
\ => [],\n# ];\n# \n# /**\n# * Sets the {@link ClassMetadataFactoryInterface}\
|
||
|
\ to use."
|
||
|
- name: isCircularReference
|
||
|
visibility: protected
|
||
|
parameters:
|
||
|
- name: object
|
||
|
- name: '&$context'
|
||
|
comment: '# * Detects if the configured circular reference limit is reached.
|
||
|
|
||
|
# *
|
||
|
|
||
|
# * @throws CircularReferenceException'
|
||
|
- name: handleCircularReference
|
||
|
visibility: protected
|
||
|
parameters:
|
||
|
- name: object
|
||
|
- name: format
|
||
|
default: 'null'
|
||
|
- name: context
|
||
|
default: '[]'
|
||
|
comment: '# * Handles a circular reference.
|
||
|
|
||
|
# *
|
||
|
|
||
|
# * If a circular reference handler is set, it will be called. Otherwise, a
|
||
|
|
||
|
# * {@class CircularReferenceException} will be thrown.
|
||
|
|
||
|
# *
|
||
|
|
||
|
# * @final
|
||
|
|
||
|
# *
|
||
|
|
||
|
# * @throws CircularReferenceException'
|
||
|
- name: getAllowedAttributes
|
||
|
visibility: protected
|
||
|
parameters:
|
||
|
- name: classOrObject
|
||
|
- name: context
|
||
|
- name: attributesAsString
|
||
|
default: 'false'
|
||
|
comment: '# * Gets attributes to normalize using groups.
|
||
|
|
||
|
# *
|
||
|
|
||
|
# * @param bool $attributesAsString If false, return an array of {@link AttributeMetadataInterface}
|
||
|
|
||
|
# *
|
||
|
|
||
|
# * @return string[]|AttributeMetadataInterface[]|bool
|
||
|
|
||
|
# *
|
||
|
|
||
|
# * @throws LogicException if the ''allow_extra_attributes'' context variable
|
||
|
is false and no class metadata factory is provided'
|
||
|
- name: getGroups
|
||
|
visibility: protected
|
||
|
parameters:
|
||
|
- name: context
|
||
|
comment: null
|
||
|
- name: isAllowedAttribute
|
||
|
visibility: protected
|
||
|
parameters:
|
||
|
- name: classOrObject
|
||
|
- name: attribute
|
||
|
- name: format
|
||
|
default: 'null'
|
||
|
- name: context
|
||
|
default: '[]'
|
||
|
comment: '# * Is this attribute allowed?'
|
||
|
- name: prepareForDenormalization
|
||
|
visibility: protected
|
||
|
parameters:
|
||
|
- name: data
|
||
|
comment: '# * Normalizes the given data to an array. It''s particularly useful during
|
||
|
|
||
|
# * the denormalization process.'
|
||
|
- name: getConstructor
|
||
|
visibility: protected
|
||
|
parameters:
|
||
|
- name: '&$data'
|
||
|
- name: class
|
||
|
- name: '&$context'
|
||
|
- name: reflectionClass
|
||
|
- name: allowedAttributes
|
||
|
comment: '# * Returns the method to use to construct an object. This method must
|
||
|
be either
|
||
|
|
||
|
# * the object constructor or static.'
|
||
|
- name: instantiateObject
|
||
|
visibility: protected
|
||
|
parameters:
|
||
|
- name: '&$data'
|
||
|
- name: class
|
||
|
- name: '&$context'
|
||
|
- name: reflectionClass
|
||
|
- name: allowedAttributes
|
||
|
- name: format
|
||
|
default: 'null'
|
||
|
comment: '# * Instantiates an object using constructor parameters when needed.
|
||
|
|
||
|
# *
|
||
|
|
||
|
# * This method also allows to denormalize data into an existing object if
|
||
|
|
||
|
# * it is present in the context with the object_to_populate. This object
|
||
|
|
||
|
# * is removed from the context before being returned to avoid side effects
|
||
|
|
||
|
# * when recursively normalizing an object graph.
|
||
|
|
||
|
# *
|
||
|
|
||
|
# * @throws RuntimeException
|
||
|
|
||
|
# * @throws MissingConstructorArgumentsException'
|
||
|
- name: denormalizeParameter
|
||
|
visibility: protected
|
||
|
parameters:
|
||
|
- name: class
|
||
|
- name: parameter
|
||
|
- name: parameterName
|
||
|
- name: parameterData
|
||
|
- name: context
|
||
|
- name: format
|
||
|
default: 'null'
|
||
|
comment: '# * @internal'
|
||
|
- name: createChildContext
|
||
|
visibility: protected
|
||
|
parameters:
|
||
|
- name: parentContext
|
||
|
- name: attribute
|
||
|
- name: format
|
||
|
comment: '# * @internal'
|
||
|
- name: getAttributeNormalizationContext
|
||
|
visibility: protected
|
||
|
parameters:
|
||
|
- name: object
|
||
|
- name: attribute
|
||
|
- name: context
|
||
|
comment: "# * Validate callbacks set in context.\n# *\n# * @param string $contextType\
|
||
|
\ Used to specify which context is invalid in exceptions\n# *\n# * @throws InvalidArgumentException\n\
|
||
|
# */\n# final protected function validateCallbackContext(array $context, string\
|
||
|
\ $contextType = ''): void\n# {\n# if (!isset($context[self::CALLBACKS])) {\n\
|
||
|
# return;\n# }\n# \n# if (!\\is_array($context[self::CALLBACKS])) {\n# throw new\
|
||
|
\ InvalidArgumentException(\\sprintf('The \"%s\"%s context option must be an array\
|
||
|
\ of callables.', self::CALLBACKS, '' !== $contextType ? \" $contextType\" : ''));\n\
|
||
|
# }\n# \n# foreach ($context[self::CALLBACKS] as $attribute => $callback) {\n\
|
||
|
# if (!\\is_callable($callback)) {\n# throw new InvalidArgumentException(\\sprintf('Invalid\
|
||
|
\ callback found for attribute \"%s\" in the \"%s\"%s context option.', $attribute,\
|
||
|
\ self::CALLBACKS, '' !== $contextType ? \" $contextType\" : ''));\n# }\n# }\n\
|
||
|
# }\n# \n# final protected function applyCallbacks(mixed $value, object|string\
|
||
|
\ $object, string $attribute, ?string $format, array $context): mixed\n# {\n#\
|
||
|
\ /**\n# * @var callable|null\n# */\n# $callback = $context[self::CALLBACKS][$attribute]\
|
||
|
\ ?? $this->defaultContext[self::CALLBACKS][$attribute] ?? null;\n# \n# return\
|
||
|
\ $callback ? $callback($value, $object, $attribute, $format, $context) : $value;\n\
|
||
|
# }\n# \n# final protected function applyFilterBool(\\ReflectionParameter $parameter,\
|
||
|
\ mixed $value, array $context): mixed\n# {\n# if (!($context[self::FILTER_BOOL]\
|
||
|
\ ?? false)) {\n# return $value;\n# }\n# \n# if (!($parameterType = $parameter->getType())\
|
||
|
\ instanceof \\ReflectionNamedType || 'bool' !== $parameterType->getName()) {\n\
|
||
|
# return $value;\n# }\n# \n# return filter_var($value, \\FILTER_VALIDATE_BOOL,\
|
||
|
\ \\FILTER_NULL_ON_FAILURE) ?? $value;\n# }\n# \n# /**\n# * Computes the normalization\
|
||
|
\ context merged with current one. Metadata always wins over global context, as\
|
||
|
\ more specific.\n# *\n# * @internal"
|
||
|
- name: getAttributeDenormalizationContext
|
||
|
visibility: protected
|
||
|
parameters:
|
||
|
- name: class
|
||
|
- name: attribute
|
||
|
- name: context
|
||
|
comment: '# * Computes the denormalization context merged with current one. Metadata
|
||
|
always wins over global context, as more specific.
|
||
|
|
||
|
# *
|
||
|
|
||
|
# * @internal'
|
||
|
- name: getAttributeMetadata
|
||
|
visibility: protected
|
||
|
parameters:
|
||
|
- name: objectOrClass
|
||
|
- name: attribute
|
||
|
comment: '# * @internal'
|
||
|
traits:
|
||
|
- Symfony\Component\Serializer\Exception\CircularReferenceException
|
||
|
- Symfony\Component\Serializer\Exception\InvalidArgumentException
|
||
|
- Symfony\Component\Serializer\Exception\LogicException
|
||
|
- Symfony\Component\Serializer\Exception\MissingConstructorArgumentsException
|
||
|
- Symfony\Component\Serializer\Exception\NotNormalizableValueException
|
||
|
- Symfony\Component\Serializer\Exception\RuntimeException
|
||
|
- Symfony\Component\Serializer\Mapping\AttributeMetadataInterface
|
||
|
- Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface
|
||
|
- Symfony\Component\Serializer\NameConverter\NameConverterInterface
|
||
|
- Symfony\Component\Serializer\SerializerAwareInterface
|
||
|
- Symfony\Component\Serializer\SerializerAwareTrait
|
||
|
- ObjectToPopulateTrait
|
||
|
- SerializerAwareTrait
|
||
|
interfaces:
|
||
|
- NormalizerInterface
|