Re: [RFC] Anonymous Classes
| From: | Philip Sturgeon | Date: | Mon, 09 Mar 2015 00:25:56 +0000 |
| Subject: | Re: [RFC] Anonymous Classes | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-84448@lists.php.net to get a copy of this message | ||
Stanislav,
On Fri, Mar 6, 2015 at 6:42 PM, Stanislav Malyshev <smalyshev@gmail.com> wrote:
> Hi!
> Couple of points to clarify:
>
> 1. Is the new syntax "new class ..." or just "class ..." and new works
> the same? I.e. could you do:
>
> $foo = class extends Callback { ... }
> $bar = new $foo;
Nope, none of that. Wrap that in a function or clone it perhaps.
> 2. What is the scope of the anonymous class? Can it get access to
> parent's variable scope? Private functions?
Works the same as any named class. No new special rules here.
Play around on 3v4l and show me an example of something you don't
like, or make sure it works the way you expect.