On Thu, Jan 9, 2020 at 3:28 PM Ralph Schindler <ra...@ralphschindler.com> wrote:
> > > Another small RFC, to allow $object::class syntax: > > > > https://wiki.php.net/rfc/class_name_literal_on_object > > Hi Nikita, > > Glad to see enhancements to ::class. Open questions, given: > > > class Foo {} > > $foo = new Foo; > echo $foo::class; // Foo > > $fooClass = Foo::class; > echo $foo::class; // TypeError b/c string? > Yes, at least per the current proposal. Whether to allow this is listed as an open question. > $fooAnon = new class extends Foo {}; > echo $fooAnon::class; // TypeError or class@anonymous? The same as get_class($fooAnon), which will be of the form "class@anonymous\0SOME_PAYLOAD_HERE". While the part after class@anonymous is cut of when printing in most places, anonymous classes still do have a unique class name. Nikita