Issue #3254331 by paulocs, longwave: [Symfony 6] Add "array|string|int|float|bool|\ArrayObject|null" to all Normalizer classes that implement the method ::normalize()
parent
77bd32e38f
commit
00ad1d7572
|
@ -66,7 +66,7 @@ class ContentEntityNormalizer extends NormalizerBase {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($entity, $format = NULL, array $context = []) {
|
public function normalize($entity, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
$context += [
|
$context += [
|
||||||
'account' => NULL,
|
'account' => NULL,
|
||||||
'included_fields' => NULL,
|
'included_fields' => NULL,
|
||||||
|
|
|
@ -63,7 +63,7 @@ class EntityReferenceItemNormalizer extends FieldItemNormalizer implements UuidR
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($field_item, $format = NULL, array $context = []) {
|
public function normalize($field_item, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
// If this is not a fieldable entity, let the parent implementation handle
|
// If this is not a fieldable entity, let the parent implementation handle
|
||||||
// it, only fieldable entities are supported as embedded resources.
|
// it, only fieldable entities are supported as embedded resources.
|
||||||
if (!$this->targetEntityIsFieldable($field_item)) {
|
if (!$this->targetEntityIsFieldable($field_item)) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ class FieldItemNormalizer extends NormalizerBase {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($field_item, $format = NULL, array $context = []) {
|
public function normalize($field_item, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
// The values are wrapped in an array, and then wrapped in another array
|
// The values are wrapped in an array, and then wrapped in another array
|
||||||
// keyed by field name so that field items can be merged by the
|
// keyed by field name so that field items can be merged by the
|
||||||
// FieldNormalizer. This is necessary for the EntityReferenceItemNormalizer
|
// FieldNormalizer. This is necessary for the EntityReferenceItemNormalizer
|
||||||
|
|
|
@ -18,7 +18,7 @@ class FieldNormalizer extends SerializationFieldNormalizer {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($field_items, $format = NULL, array $context = []) {
|
public function normalize($field_items, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
$normalized_field_items = [];
|
$normalized_field_items = [];
|
||||||
|
|
||||||
// Get the field definition.
|
// Get the field definition.
|
||||||
|
|
|
@ -20,7 +20,7 @@ class DataNormalizer extends NormalizerBase {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
assert($object instanceof Data);
|
assert($object instanceof Data);
|
||||||
$cacheable_normalizations = array_map(function ($resource) use ($format, $context) {
|
$cacheable_normalizations = array_map(function ($resource) use ($format, $context) {
|
||||||
return $this->serializer->normalize($resource, $format, $context);
|
return $this->serializer->normalize($resource, $format, $context);
|
||||||
|
|
|
@ -74,7 +74,7 @@ abstract class EntityDenormalizerBase extends NormalizerBase implements Denormal
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
throw new \LogicException('This method should never be called.');
|
throw new \LogicException('This method should never be called.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ class EntityReferenceFieldNormalizer extends FieldNormalizer {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($field, $format = NULL, array $context = []) {
|
public function normalize($field, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
assert($field instanceof EntityReferenceFieldItemListInterface);
|
assert($field instanceof EntityReferenceFieldItemListInterface);
|
||||||
// Build the relationship object based on the Entity Reference and normalize
|
// Build the relationship object based on the Entity Reference and normalize
|
||||||
// that object instead.
|
// that object instead.
|
||||||
|
|
|
@ -59,7 +59,7 @@ class FieldItemNormalizer extends NormalizerBase implements DenormalizerInterfac
|
||||||
* cacheability in mind, and hence bubbles cacheability out of band. This must
|
* cacheability in mind, and hence bubbles cacheability out of band. This must
|
||||||
* catch it, and pass it to the value object that JSON:API uses.
|
* catch it, and pass it to the value object that JSON:API uses.
|
||||||
*/
|
*/
|
||||||
public function normalize($field_item, $format = NULL, array $context = []) {
|
public function normalize($field_item, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
assert($field_item instanceof FieldItemInterface);
|
assert($field_item instanceof FieldItemInterface);
|
||||||
/** @var \Drupal\Core\TypedData\TypedDataInterface $property */
|
/** @var \Drupal\Core\TypedData\TypedDataInterface $property */
|
||||||
$values = [];
|
$values = [];
|
||||||
|
|
|
@ -30,7 +30,7 @@ class FieldNormalizer extends NormalizerBase implements DenormalizerInterface {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($field, $format = NULL, array $context = []) {
|
public function normalize($field, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
/** @var \Drupal\Core\Field\FieldItemListInterface $field */
|
/** @var \Drupal\Core\Field\FieldItemListInterface $field */
|
||||||
$normalized_items = $this->normalizeFieldItems($field, $format, $context);
|
$normalized_items = $this->normalizeFieldItems($field, $format, $context);
|
||||||
assert($context['resource_object'] instanceof ResourceObject);
|
assert($context['resource_object'] instanceof ResourceObject);
|
||||||
|
|
|
@ -48,7 +48,7 @@ class HttpExceptionNormalizer extends NormalizerBase {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
$cacheability = new CacheableMetadata();
|
$cacheability = new CacheableMetadata();
|
||||||
$cacheability->addCacheableDependency($object);
|
$cacheability->addCacheableDependency($object);
|
||||||
return new HttpExceptionNormalizerValue($cacheability, static::rasterizeValueRecursive($this->buildErrorObjects($object)));
|
return new HttpExceptionNormalizerValue($cacheability, static::rasterizeValueRecursive($this->buildErrorObjects($object)));
|
||||||
|
|
|
@ -172,7 +172,7 @@ class JsonApiDocumentTopLevelNormalizer extends NormalizerBase implements Denorm
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
assert($object instanceof JsonApiDocumentTopLevel);
|
assert($object instanceof JsonApiDocumentTopLevel);
|
||||||
$data = $object->getData();
|
$data = $object->getData();
|
||||||
$document['jsonapi'] = CacheableNormalization::permanent([
|
$document['jsonapi'] = CacheableNormalization::permanent([
|
||||||
|
|
|
@ -90,7 +90,7 @@ class LinkCollectionNormalizer extends NormalizerBase {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
assert($object instanceof LinkCollection);
|
assert($object instanceof LinkCollection);
|
||||||
$normalized = [];
|
$normalized = [];
|
||||||
/** @var \Drupal\jsonapi\JsonApiResource\Link $link */
|
/** @var \Drupal\jsonapi\JsonApiResource\Link $link */
|
||||||
|
|
|
@ -20,7 +20,7 @@ class RelationshipNormalizer extends NormalizerBase {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
assert($object instanceof Relationship);
|
assert($object instanceof Relationship);
|
||||||
return CacheableNormalization::aggregate([
|
return CacheableNormalization::aggregate([
|
||||||
'data' => $this->serializer->normalize($object->getData(), $format, $context),
|
'data' => $this->serializer->normalize($object->getData(), $format, $context),
|
||||||
|
|
|
@ -48,7 +48,7 @@ class ResourceIdentifierNormalizer extends NormalizerBase implements Denormalize
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
assert($object instanceof ResourceIdentifier);
|
assert($object instanceof ResourceIdentifier);
|
||||||
$normalization = [
|
$normalization = [
|
||||||
'type' => $object->getTypeName(),
|
'type' => $object->getTypeName(),
|
||||||
|
|
|
@ -54,7 +54,7 @@ class ResourceObjectNormalizer extends NormalizerBase {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
assert($object instanceof ResourceObject);
|
assert($object instanceof ResourceObject);
|
||||||
// If the fields to use were specified, only output those field values.
|
// If the fields to use were specified, only output those field values.
|
||||||
$context['resource_object'] = $object;
|
$context['resource_object'] = $object;
|
||||||
|
|
|
@ -57,7 +57,7 @@ final class Serializer extends SymfonySerializer {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($data, $format = NULL, array $context = []) {
|
public function normalize($data, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
if ($this->selfSupportsNormalization($data, $format, $context)) {
|
if ($this->selfSupportsNormalization($data, $format, $context)) {
|
||||||
return parent::normalize($data, $format, $context);
|
return parent::normalize($data, $format, $context);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ class StringNormalizer extends NormalizerBase implements DenormalizerInterface {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
return str_replace('super', 'NOT', $object->getValue());
|
return str_replace('super', 'NOT', $object->getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ class TraversableObjectNormalizer extends NormalizerBase {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
return $object->property;
|
return $object->property;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ class StringNormalizer extends FieldItemNormalizer implements DenormalizerInterf
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
$data = parent::normalize($object, $format, $context);
|
$data = parent::normalize($object, $format, $context);
|
||||||
$data['value'] = str_replace('super', 'NOT', $data['value']);
|
$data['value'] = str_replace('super', 'NOT', $data['value']);
|
||||||
return $data;
|
return $data;
|
||||||
|
|
|
@ -25,7 +25,7 @@ class ComplexDataNormalizer extends NormalizerBase {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
$attributes = [];
|
$attributes = [];
|
||||||
// $object will not always match $supportedInterfaceOrClass.
|
// $object will not always match $supportedInterfaceOrClass.
|
||||||
// @see \Drupal\serialization\Normalizer\EntityNormalizer
|
// @see \Drupal\serialization\Normalizer\EntityNormalizer
|
||||||
|
|
|
@ -17,7 +17,7 @@ class ConfigEntityNormalizer extends EntityNormalizer {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
return static::getDataWithoutInternals($object->toArray());
|
return static::getDataWithoutInternals($object->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ class ContentEntityNormalizer extends EntityNormalizer {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($entity, $format = NULL, array $context = []) {
|
public function normalize($entity, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
$context += [
|
$context += [
|
||||||
'account' => NULL,
|
'account' => NULL,
|
||||||
];
|
];
|
||||||
|
|
|
@ -37,7 +37,7 @@ class DateTimeIso8601Normalizer extends DateTimeNormalizer {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($datetime, $format = NULL, array $context = []) {
|
public function normalize($datetime, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
assert($datetime instanceof DateTimeIso8601);
|
assert($datetime instanceof DateTimeIso8601);
|
||||||
$field_item = $datetime->getParent();
|
$field_item = $datetime->getParent();
|
||||||
// @todo Remove this in https://www.drupal.org/project/drupal/issues/2958416.
|
// @todo Remove this in https://www.drupal.org/project/drupal/issues/2958416.
|
||||||
|
|
|
@ -54,7 +54,7 @@ class DateTimeNormalizer extends NormalizerBase implements DenormalizerInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($datetime, $format = NULL, array $context = []) {
|
public function normalize($datetime, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
assert($datetime instanceof DateTimeInterface);
|
assert($datetime instanceof DateTimeInterface);
|
||||||
$drupal_date_time = $datetime->getDateTime();
|
$drupal_date_time = $datetime->getDateTime();
|
||||||
if ($drupal_date_time === NULL) {
|
if ($drupal_date_time === NULL) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ class EntityReferenceFieldItemNormalizer extends FieldItemNormalizer {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($field_item, $format = NULL, array $context = []) {
|
public function normalize($field_item, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
$values = parent::normalize($field_item, $format, $context);
|
$values = parent::normalize($field_item, $format, $context);
|
||||||
|
|
||||||
$this->normalizeRootReferenceValue($values, $field_item);
|
$this->normalizeRootReferenceValue($values, $field_item);
|
||||||
|
|
|
@ -23,7 +23,7 @@ class ListNormalizer extends NormalizerBase {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
$attributes = [];
|
$attributes = [];
|
||||||
foreach ($object as $fieldItem) {
|
foreach ($object as $fieldItem) {
|
||||||
$attributes[] = $this->serializer->normalize($fieldItem, $format, $context);
|
$attributes[] = $this->serializer->normalize($fieldItem, $format, $context);
|
||||||
|
|
|
@ -17,7 +17,7 @@ class MarkupNormalizer extends NormalizerBase {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
return (string) $object;
|
return (string) $object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class NullNormalizer extends NormalizerBase {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class PrimitiveDataNormalizer extends NormalizerBase {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
// Add cacheability if applicable.
|
// Add cacheability if applicable.
|
||||||
$this->addCacheableDependency($context, $object);
|
$this->addCacheableDependency($context, $object);
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ class TimestampItemNormalizer extends FieldItemNormalizer {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
return parent::normalize($object, $format, $context) + [
|
return parent::normalize($object, $format, $context) + [
|
||||||
// 'format' is not a property on Timestamp objects. This is present to
|
// 'format' is not a property on Timestamp objects. This is present to
|
||||||
// assist consumers of this data.
|
// assist consumers of this data.
|
||||||
|
|
|
@ -17,7 +17,7 @@ class TypedDataNormalizer extends NormalizerBase {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
$this->addCacheableDependency($context, $object);
|
$this->addCacheableDependency($context, $object);
|
||||||
$value = $object->getValue();
|
$value = $object->getValue();
|
||||||
// Support for stringable value objects: avoid numerous custom normalizers.
|
// Support for stringable value objects: avoid numerous custom normalizers.
|
||||||
|
|
|
@ -18,7 +18,7 @@ class TextItemSillyNormalizer extends FieldItemNormalizer {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
$data = parent::normalize($object, $format, $context);
|
$data = parent::normalize($object, $format, $context);
|
||||||
$data['value'] .= '::silly_suffix';
|
$data['value'] .= '::silly_suffix';
|
||||||
return $data;
|
return $data;
|
||||||
|
|
|
@ -19,7 +19,7 @@ class BooleanNormalizer extends NormalizerBase implements DenormalizerInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
return $object->getValue() ? '👍' : '👎';
|
return $object->getValue() ? '👍' : '👎';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ class BooleanItemNormalizer extends FieldItemNormalizer implements DenormalizerI
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
$data = parent::normalize($object, $format, $context);
|
$data = parent::normalize($object, $format, $context);
|
||||||
$data['value'] = $data['value'] ? '👍' : '👎';
|
$data['value'] = $data['value'] ? '👍' : '👎';
|
||||||
return $data;
|
return $data;
|
||||||
|
|
|
@ -14,21 +14,9 @@ class SerializationTestNormalizer implements NormalizerInterface {
|
||||||
protected static $format = 'serialization_test';
|
protected static $format = 'serialization_test';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalizes an object into a set of arrays/scalars.
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @param object $object
|
|
||||||
* Object to normalize.
|
|
||||||
* @param string|null $format
|
|
||||||
* (optional) Format the normalization result will be encoded as. Defaults
|
|
||||||
* to NULL
|
|
||||||
* @param array $context
|
|
||||||
* (optional) The context data. Defaults to an empty array.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
* An array containing a normalized representation of $object, appropriate
|
|
||||||
* for encoding to the requested format.
|
|
||||||
*/
|
*/
|
||||||
public function normalize($object, $format = NULL, array $context = []) {
|
public function normalize($object, $format = NULL, array $context = []): array|string|int|float|bool|\ArrayObject|NULL {
|
||||||
$normalized = (array) $object;
|
$normalized = (array) $object;
|
||||||
// Add identifying value that can be used to verify that the expected
|
// Add identifying value that can be used to verify that the expected
|
||||||
// normalizer was invoked.
|
// normalizer was invoked.
|
||||||
|
|
Loading…
Reference in New Issue