Concept: 7.1 nullable function parameter format ...

php.internals

David (Dj) Eddy

9 years ago
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.

Christoph Becker

9 years ago
On 14.09.2016 at 17:10, David (Dj) Eddy wrote:
> 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.
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