Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84483 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19698 invoked from network); 9 Mar 2015 19:22:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Mar 2015 19:22:19 -0000 Authentication-Results: pb1.pair.com header.from=pjsturgeon@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pjsturgeon@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.45 as permitted sender) X-PHP-List-Original-Sender: pjsturgeon@gmail.com X-Host-Fingerprint: 209.85.215.45 mail-la0-f45.google.com Received: from [209.85.215.45] ([209.85.215.45:46502] helo=mail-la0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3A/C1-03288-AE2FDF45 for ; Mon, 09 Mar 2015 14:22:19 -0500 Received: by labgm9 with SMTP id gm9so3957087lab.13 for ; Mon, 09 Mar 2015 12:22:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=SaHq1bjIuZjSkHPlk5vaGX98BbOJ4HnEV0xhmbD2PpU=; b=TJsvXCfK0pb5OZhpFgov13TSfVaK9BXNu9kRNAv1xOrwgxBCA3lmt6EF/K14agYsGA 7Jja75u0lJ40GF0IA4xoiTAMy8euk0XlRfJHkfukFm+bVt3SK1vyhtDOoGiU3NkoTLCq rIMZirvCUIxpa4f3gOGQxLTv8NGkHVFFd6h1iDk2n0rEJ3+uIenvQ5aEJzPToHFtrBJT LE6xx3m/++l+zVkA8HmppZSeXNBjVTbZ3Vpz/D6QXZyuhe59w17pbXWOKUeYfh8RqVk8 2nivpdX6f3y7MoVevrnp0YCELAMlDsJpn12lAg2pI+XqxW+zwCT19h66tI0NbNPFr8sa lh9w== MIME-Version: 1.0 X-Received: by 10.112.147.200 with SMTP id tm8mr26960895lbb.71.1425928934708; Mon, 09 Mar 2015 12:22:14 -0700 (PDT) Received: by 10.114.26.34 with HTTP; Mon, 9 Mar 2015 12:22:14 -0700 (PDT) In-Reply-To: References: <010801d055d3$ed5a8fa0$c80faee0$@tutteli.ch> <004d01d05696$9d797410$d86c5c30$@tutteli.ch> <54FA3B69.1050709@gmail.com> Date: Mon, 9 Mar 2015 15:22:14 -0400 Message-ID: To: Matthew Leverton , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Anonymous Classes From: pjsturgeon@gmail.com (Philip Sturgeon) Matthew, On Sun, Mar 8, 2015 at 11:04 PM, Matthew Leverton wrote: >>> $foo = class extends Callback { ... } >>> $bar = new $foo; >> >> Nope, none of that. Wrap that in a function or clone it perhaps. >> > Are you actively against that functionality? (I don't think it's very > useful, but was wondering if you think it's a bad idea for some > reason.) > > I'm not sure what people think it should return. The name of the > anonymous class?? > > e.g., similar to: > > class Foo { } > $foo = 'Foo'; > $fooInstance = new $foo; > > That seems odd to me. It could just return a ReflectionClass object: > > $reflector = class { public function bar() { } }; > $foo = $reflector->newInstance(); > $foo->bar(); > > But I don't know if that would feel out of place. Otherwise, it seems > like it would need to return some sort of "Class" object that could be > typecasted, etc ... but in some ways that's what a ReflectionClass > already is. > > Just throwing that out there. > > Big +1 on the RFC as presented. > > -- > Matthew Leverton Thanks for the example! I would say: Yes, I am actively against that stuff. Firstly, at this time no part of PHP that I know of will smash a reflection object at you unless you specifically interact with the reflection API and ask for it. That in itself is a major nope. Secondly, it am unsure of the uses. you can wrap that in a function or shove it in a named class if you need to create multiple instances of it. Or, as I said, there is clone. If usage of this simple feature starts to show that people feel constrained by not having this extra feature, then I would say we should add that later. I am a big fan of keeping it simple and introducing things as people need them, instead of trying to cover all future use cases. :)