You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Several function parameters in WordPress can be passed as an associative array or a stdClass. This is an unfortunate result of some legacy functions casting arrays to objects with (object) $array.
The object shape support added in PHPStan 1.10.12 is helpful in this regard, thank you for working on it. It would be great if a shape could be shared in an object and array union to avoid duplicating all the elements of the shape.
Here's how such a parameter can be documented now:
@phpstan-param object{
foo: int,
bar: string,
baz: bool,
}|array{
foo: int,
bar: string,
baz: bool,
} $args
If the shape could be used for a union of object|array it would avoid this duplication.
@phpstan-param (object|array){
foo: int,
bar: string,
baz: bool,
} $args
The text was updated successfully, but these errors were encountered:
tl;dr:
Several function parameters in WordPress can be passed as an associative array or a
stdClass
. This is an unfortunate result of some legacy functions casting arrays to objects with(object) $array
.The object shape support added in PHPStan 1.10.12 is helpful in this regard, thank you for working on it. It would be great if a shape could be shared in an object and array union to avoid duplicating all the elements of the shape.
Here's how such a parameter can be documented now:
If the shape could be used for a union of
object|array
it would avoid this duplication.The text was updated successfully, but these errors were encountered: