Re: [RFC] Anonymous Classes

From: Date: Tue, 24 Feb 2015 14:20:16 +0000
Subject: Re: [RFC] Anonymous Classes
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-83665@lists.php.net to get a copy of this message
On Tue, Feb 24, 2015 at 9:10 AM, Dmitry Stogov <dmitry@zend.com> wrote: > I think the proposal is a bit incomplete. > It's possible to instantiate an anonymous class, but currently it's not > possible to do with them anything else (assign to variable, pass to > function, etc). Something similar to Closure objects should be introduced. > > Thanks. Dmitry. > > On Tue, Feb 24, 2015 at 4:52 PM, Philip Sturgeon <pjsturgeon@gmail.com> > wrote: 1. You can absolutely assign the instantiated classes to variables. Check out this test in the patch: https://github.com/krakjoe/php-src/compare/anon#diff-25e330fb5a98810de178a5b798102d01R1 2. Why do you say they cannot be passed to a function? I can add a test if you can give me an example of what you're suggesting doesn't work. 3. Not sure why we'd need a Closure-alike object. Anonymous classes are just a class, and classes have all the types and hinting functionality of regular classes. You don't need to implement a class to let people know its a class. Maybe you could expand on that a bit? :)

« previous php.internals (#83665) next »