Re: Re: Basic Type Alias
| From: | Aleksander Machniak | Date: | Sat, 28 Oct 2023 07:03:58 +0000 |
| Subject: | Re: Re: Basic Type Alias | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-121490@lists.php.net to get a copy of this message | ||
On 27.10.2023 22:42, Oladoyinbo Vincent wrote:
Your typedef is essentially just a trait. One new keyword less. What would be missing is direct access to type. If we indeed allow type inside a class/trait, then natural syntax becomes the one used for const/var. I think your syntax 2 is the worst anyway. Syntax 3 (use-as) will not gonna fly as we already have use-as in a conflicting use for classes, unless you change it to "use type string|null as NullableString". I think Syntax 1 makes most sense, especially considering a case of long list of "subtypes" that could be class names with namespace. Types should also support visibility (public|protected|private) when in class/trait context. -- Aleksander Machniak Kolab Groupware Developer [https://kolab.org] Roundcube Webmail Developer [https://roundcube.net] ---------------------------------------------------- PGP: 19359DC1 # Blog: https://kolabian.wordpress.comnamespace Package; typedef MyTypes { type Numeric: int|float|null; type Chars: string|null; type Result: bool|null; }use Package\MyTypes; class Hello { use MyTypes; public function A(Numeric $id, Chars $message): Result { } }