Hello Internals,

I’d like to request your comments on type aliases (not to be confused with 
typedefs) at https://wiki.php.net/rfc/typed-aliases

TL;DR (it’s actually rather short):

Following the same syntax as other use'ing statements, you can alias a type:

use type int|float as Number;

function sum(Number $a, Number $b): Number { return $a + $b; }

You can also include types, with some restrictions:

include types 'math-types.php';

function sum(Number $a, Number $b): Number { return $a + $b; }

These are compile-time replacements that serve to make code more readable and 
reduce repetition with no runtime overhead. Type aliases follow the same 
scoping rules as other use imports.

— Rob

Reply via email to