Skip to content

Commit 463bc00

Browse files
authored
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 921dcb5 commit 463bc00

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

serializer.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1774,7 +1774,7 @@ identifier of the next nested object, instead of omitting the property::
17741774
$child = new Person('Joe', $mother);
17751775

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

0 commit comments

Comments
 (0)