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]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php