Re: [RFC] Callable Types

From: Date: Fri, 22 Apr 2016 14:55:15 +0000
Subject: Re: [RFC] Callable Types
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-92645@lists.php.net to get a copy of this message
Levi Morrison wrote on 22/04/2016 15:39:
It would also allow for a general type-aliasing mechanism for single names. This feature has been asked for in the past but I can't remember the use-cases so this example is not very good:
One use I've seen is for making the "semantic type" of a scalar more obvious. I'd quite like to be able to do this: type timestamp = int; function format_date(timestamp $foo) { ... } Any integer is a valid Unix timestamp, so you don't even need domain types in this case, although those would be even better: type age = int { min: 0 }; type day_of_month = int { min: 1; max: 31 }; Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#92645) next »