Skip to content

Commit 5a43fd2

Browse files
davehardingxabbuh
authored andcommitted
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.
1 parent 810f06d commit 5a43fd2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

serializer.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1789,7 +1789,7 @@ identifier of the next nested object, instead of omitting the property::
17891789
$child = new Person('Joe', $mother);
17901790

17911791
// all callback parameters are optional (you can omit the ones you don't use)
1792-
$maxDepthHandler = function (object $innerObject, object $outerObject, string $attributeName, ?string $format = null, array $context = []): string {
1792+
$maxDepthHandler = function (object $innerObject, object $outerObject, string $attributeName, ?string $format = null, array $context = []): ?string {
17931793
// return only the name of the next person in the tree
17941794
return $innerObject instanceof Person ? $innerObject->getName() : null;
17951795
};

0 commit comments

Comments
 (0)