Skip to content

Commit e17ff0c

Browse files
committed
minor #20471 Update serializer.rst (daveharding)
This PR was submitted for the 7.2 branch but it was merged into the 6.4 branch instead. Discussion ---------- 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. <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `7.x` for features of unreleased versions). --> Commits ------- 5a43fd2 Update serializer.rst
2 parents 810f06d + 5a43fd2 commit e17ff0c

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)