Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83665 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88790 invoked from network); 24 Feb 2015 14:20:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Feb 2015 14:20:21 -0000 Authentication-Results: pb1.pair.com smtp.mail=pjsturgeon@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pjsturgeon@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.174 as permitted sender) X-PHP-List-Original-Sender: pjsturgeon@gmail.com X-Host-Fingerprint: 209.85.217.174 mail-lb0-f174.google.com Received: from [209.85.217.174] ([209.85.217.174:44732] helo=mail-lb0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E0/D1-10521-3A88CE45 for ; Tue, 24 Feb 2015 09:20:20 -0500 Received: by lbiz12 with SMTP id z12so24940949lbi.11 for ; Tue, 24 Feb 2015 06:20:16 -0800 (PST) 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=O8bdi12EdNI+2UvWTTSK/FQuFjCbRcbiQGJ/PIDBeFs=; b=a3lddTwnAoGcLP0yONf8wL4sjTk2hRjbILeCw5v0y98KwwA7V2ssHrM0f9318XDRkx paQzYekbnTI89TpSErRGK3wnFyqNuF90F+vf6jQ664qlqUFcnJpF3zufoZ0U0GtK1jYa lwjMS1uxJR0AtyePiLGXstFaEyC82jTwKN2XaIGOGi6bneHvlrNuA/lLvAGS/48QRK61 J31naXOv3yuJ/X1+zALeGiNR0BPygg1Fz+aPM0KqDUe98ToAwC1rvjlYoeFUFN2ToyoJ 2uAc2lqbp9DHn7dJWMwOWiXzs2E5PJmhc9SMXGVPlhFgwlotwsp8Qm3iEBOyjMh72su9 ez9A== MIME-Version: 1.0 X-Received: by 10.112.73.65 with SMTP id j1mr14364363lbv.87.1424787616162; Tue, 24 Feb 2015 06:20:16 -0800 (PST) Received: by 10.114.26.34 with HTTP; Tue, 24 Feb 2015 06:20:16 -0800 (PST) In-Reply-To: References: Date: Tue, 24 Feb 2015 09:20:16 -0500 Message-ID: To: PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Anonymous Classes From: pjsturgeon@gmail.com (Philip Sturgeon) On Tue, Feb 24, 2015 at 9:10 AM, Dmitry Stogov 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 > 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? :)