Issue: Currently the format for nullable function parameters is as
follows: fn(?int $param)
; this makes little visual sense from an
outside perspective. What does the ?
mean? PHP does not have a ?
data type; it is very visually ambiguous.
Suggestion: fn(null|int $param)
. This uses the same syntax format
that other logic constructs in the language use as well as being very
explicit to the data types allowed for the parameter. For the moment
only null|{one other data type}
would be the goal of the RFC;
however in future iterations multiple data types could be allowed.
Gauge initial interest in a alteratio of this type, thanks for your time.
David E.
Issue: Currently the format for nullable function parameters is as
follows:fn(?int $param)
; this makes little visual sense from an
outside perspective. What does the?
mean? PHP does not have a?
data type; it is very visually ambiguous.Suggestion:
fn(null|int $param)
. This uses the same syntax format
that other logic constructs in the language use as well as being very
explicit to the data types allowed for the parameter. For the moment
onlynull|{one other data type}
would be the goal of the RFC;
however in future iterations multiple data types could be allowed.Gauge initial interest in a alteratio of this type, thanks for your time.
There has already been the union type RFC[1], which has recently been
declined.
[1] https://wiki.php.net/rfc/union_types
--
Christoph M. Becker