function AbstractNormalizerContextBuilder::withAttributes
Configures attributes to (de)normalize.
For nested structures, this list needs to reflect the object tree.
Eg: ['foo', 'bar', 'object' => ['baz']]
Parameters
array<string|array>|null $attributes:
Throws
File
-
vendor/
symfony/ serializer/ Context/ Normalizer/ AbstractNormalizerContextBuilder.php, line 84
Class
- AbstractNormalizerContextBuilder
- A helper providing autocompletion for available AbstractNormalizer options.
Namespace
Symfony\Component\Serializer\Context\NormalizerCode
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);
}