The closure/anonymous function is missing the native return type declaration. Native return type can help enforce type, which can lead to more readable, reliable code. They ensure that the value is of the specified type at call time, otherwise a TypeError is thrown.
mixed
is forbidden PHP-T1006The mixed
type already includes null
, so specifying mixed
type as a nullable is redundant and doesn't make any sense. PHP lets you typehint properties, parameters, and return values as mixed
which can contain any value.
To fix this issue, it is recommended to drop null
from the nullable mixed
type.