Re: Object Type Casting Reloaded

From: Date: Tue, 23 Apr 2019 13:39:58 +0000
Subject: Re: Object Type Casting Reloaded
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-105357@lists.php.net to get a copy of this message
On 23/04/2019 13:32, Benjamin Morel wrote:
Aw. I did not think about a possible conflict here, thanks for bringing this up!
It keeps coming back to the feature we've all been praying to the PHP Gods for... generics. function cast<type T>(object $obj): T { if ($obj instanceof T) {
    return $obj;
} throw new InvalidArgumentException('Cast expected ' . T); } $x = cast<App.Object>($obj); -- Mark Randall

« previous php.internals (#105357) next »