Marco Deleu 

> On 19 Mar 2024, at 14:51, Ilija Tovilo <tovilo.il...@gmail.com> wrote:
> 
> Hi Robert
> 
>> On Tue, Mar 19, 2024 at 5:24 PM Robert Landers <landers.rob...@gmail.com> 
>> wrote:
>> 
>> I've been thinking about this as an RFC for awhile, but with generics
>> being far off (if at all), I'd like to propose a useful idea: reusing
>> the AS keyword in a different context.
>> 
>> Example:
>> 
>> $x = $attributeReflection->newInstance() as MyAttribute;
>> 
>> This would essentially perform the following code:
>> 
>> assert(($x = $attributeReflection->newInstance()) instanceof MyAttribute);
> 
> See https://wiki.php.net/rfc/pattern-matching#throwing_alternative. I
> believe this idea would combine nicely with pattern matching. It has
> many more uses there than just simple class type matching, and could
> even be used for things like destructuring.
> 
> Ilija

That looks like a PHP dream. Has there been any work regarding that?

Reply via email to