On 27.10.2023 22:42, Oladoyinbo Vincent wrote:
```php
namespace Package;
typedef MyTypes {
type Numeric: int|float|null;
type Chars: string|null;
type Result: bool|null;
}
```
```php
use Package\MyTypes;
class Hello {
use MyTypes;
public function A(Numeric $id, Chars $message): Result
{
}
}
```
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.com
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php