Update function signatures in the Layout class to use the union type stdClass|null instead of an optional parameter. The parameters are required and they can be null.
If there is no image data available for a post returned by the WP REST API then these image related functions could be passed a null value, but a value is always passed.
How It Was Tested
[x] Local
[x] Development / staging
How To Test
Create a post with a REST Block, when viewing the post no warnings about optional parameter ordering are thrown.
References
I had to refresh my memory about nullable vs optional.
The types ?string and string|null are identical.
string|null $name is nullable because of the union type.
string|null $name = '' is optional since it has a default value, it can't go before a required parameter.
Related Issues
What Was Accomplished
stdClass|null
instead of an optional parameter. The parameters are required and they can benull
.How It Was Tested
How To Test
References
I had to refresh my memory about nullable vs optional.
?string
andstring|null
are identical.string|null $name
is nullable because of the union type.string|null $name = ''
is optional since it has a default value, it can't go before a required parameter.https://www.php.net/manual/en/functions.arguments.php https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.nullable