docs
docs copied to clipboard
Use null instead of boolean in serialize_payload_fields to prevent fatal error
https://github.com/api-platform/core/blob/5503d65e8ad6535539ac4f6b1bcc89962457bc98/src/Serializer/AbstractConstraintViolationListNormalizer.php#L35 constructor accepts either null or array, but not boolean.
When boolean is used, we get the following error:
Argument 2 passed to ApiPlatform\Core\Hydra\Serializer\ConstraintViolationListNormalizer::__construct() must be of the type array or null, boolean given, called in /app/var/cache/dev/Container1ozwx3I/srcApp_KernelDevDebugContainer.php on line 848</p>
Hm.. I should have think better.
We can't pass null as well, because of this check
https://github.com/api-platform/core/blob/5503d65e8ad6535539ac4f6b1bcc89962457bc98/src/Serializer/AbstractConstraintViolationListNormalizer.php#L69
Then, my advice is leave only case with passing array of keys like
validator:
serialize_payload_fields: [a, b]
Boolean and null are not allowed.
Alternative - refactor constructor to accept mixed types: array and bool
Wouldn't it better to normalize null values in the Configuration class?