Re: Basic Type Alias

From: Date: Fri, 27 Oct 2023 08:50:18 +0000
Subject: Re: Basic Type Alias
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-121483@lists.php.net to get a copy of this message
Why are we reinventing alias syntax? We already have "use" to alias per file: use My\Namespace\MyFancyType as MyNewFancyType; use string|int|bool as MyFancyType; Further, in PHP we specify a type using a colon, not an equal sign, thus this feels more idiomatic to PHP (and less ambiguous): type MyFancyType: string|int|bool; or using existing functionality for creating aliases for types: class_alias('string|int|bool', 'My\Namespace\MyFancyType'); However, type MyFancyType = string|int|bool; immediately makes me think of the consts "string", "int", and "bool" being bitwise-OR'ed together, and not a type. The only hint that we're dealing with types is the type keyword. Robert Landers Software Engineer Utrecht NL

« previous php.internals (#121483) next »