From 5a43fd2da07b1bdd2b8e048d619da1ccdeb94a6f Mon Sep 17 00:00:00 2001 From: David Harding Date: Fri, 13 Dec 2024 12:39:15 +0000 Subject: [PATCH] Update serializer.rst The $maxDepthHandler function might return NULL, but the return type is set to : string, which causes a TypeError to be thrown. This change allows the $maxDepthHandler function to return null, by changing the return type to : ?string for this example. --- serializer.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serializer.rst b/serializer.rst index 4a4a934ca01..47ea5b66c60 100644 --- a/serializer.rst +++ b/serializer.rst @@ -1789,7 +1789,7 @@ identifier of the next nested object, instead of omitting the property:: $child = new Person('Joe', $mother); // all callback parameters are optional (you can omit the ones you don't use) - $maxDepthHandler = function (object $innerObject, object $outerObject, string $attributeName, ?string $format = null, array $context = []): string { + $maxDepthHandler = function (object $innerObject, object $outerObject, string $attributeName, ?string $format = null, array $context = []): ?string { // return only the name of the next person in the tree return $innerObject instanceof Person ? $innerObject->getName() : null; };