Re: Re: Basic Type Alias
| From: | Mönôme Epson | Date: | Fri, 26 Jan 2024 02:53:16 +0000 |
| Subject: | Re: Re: Basic Type Alias | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-122259@lists.php.net to get a copy of this message | ||
Hello,
I took the time to read you. Very interesting discussion.
I'm also interested in the type definition.
Because these two functions are equivalent:
> function foo(?int $baz) {}
> function foo(null|int $baz) {}
We could imagine a personalized null-safety type.
> typedef Refutable as null|false|NAN|INF; // I'm not sure that NAN and INF
are types
> typedef UserId as Refutable ! int;// Refutable is the type of null-safety
> function zoo(UserId $id) {} // $id is (int)
> function noo(?UserId $id) {}// $id is (null|false|NAN|INF|int)
Do you plan to use enum cases as type ?
enum MyEnum{ case Foo = 1; case Zoo = 2;}
use enum MyEnum::Foo as MyFoo;// syntaxe error
typedef Mamamia MyFoo|MyEnum::Zoo