Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83667 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92288 invoked from network); 24 Feb 2015 14:34:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Feb 2015 14:34:37 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.173 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.220.173 mail-vc0-f173.google.com Received: from [209.85.220.173] ([209.85.220.173:64278] helo=mail-vc0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AF/72-10521-CFB8CE45 for ; Tue, 24 Feb 2015 09:34:37 -0500 Received: by mail-vc0-f173.google.com with SMTP id hy4so10087075vcb.4 for ; Tue, 24 Feb 2015 06:34:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=NffEJdPgCrJyf6BB83g85zTYzY9oMVVw+/bhiHu4Jbc=; b=KPZmGjGA218B1ATMbuCkkSVw49tepVS9GTRMMTw2VBUNYMEFiEef7GWw2CoE7Cf0W9 1bLrITvs3JX/c8BDt6y4IwxPEOZrxgz1Q54ahYO72VWZYDVWpVmHK77hOJHrY8NI2jfT xzzeR5Ry5VWGfKwasxQXmyOWre5jIq5MdpDbWUD7C7oCR6e/jrvOlv9ScmF2fU4DDlhw 0Epbe6HBpG9veSR1omJigpKUJjJHCNb+R8bvNhnKsRz6Za7hhIsUVe62SJCkiXPbBQ0O 1sIRP/4RA76vpL7GMN/dFbo281KvabjauIuqKSAIh9Uz6cTOSeomwk+5+fxqZm9pgDJY 5yBA== X-Gm-Message-State: ALoCoQn4YADNGhZG8CTtrkLNo+NcSEDO+9TreDNjTRrE/8Q/3lPLMDfavsVQDdg9i9DSQoeEeSrf87+Y1DahxR5PmHkTM2njTIscLj0XOru4rRa7NiwNwnRPuF8iUsoioGbU/XAv62N5TGEOe3iF7gH2Vqk+47rKVQ== MIME-Version: 1.0 X-Received: by 10.52.72.5 with SMTP id z5mr15576546vdu.78.1424788473455; Tue, 24 Feb 2015 06:34:33 -0800 (PST) Received: by 10.52.113.231 with HTTP; Tue, 24 Feb 2015 06:34:33 -0800 (PST) In-Reply-To: References: Date: Tue, 24 Feb 2015 18:34:33 +0400 Message-ID: To: Philip Sturgeon , PHP Internals Content-Type: multipart/alternative; boundary=20cf307d0138d73bfd050fd66a6b Subject: Re: [PHP-DEV] [RFC] Anonymous Classes From: dmitry@zend.com (Dmitry Stogov) --20cf307d0138d73bfd050fd66a6b Content-Type: text/plain; charset=UTF-8 On Tue, Feb 24, 2015 at 5:19 PM, Philip Sturgeon wrote: > 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. > > 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 > > In tests you assign instantiated objects. $a = new class {...}; $b = new class {...}; I'm talking about classes as first class objects. $c = class {...}; $a = new $c; $b = new $c; > 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? :) > I tried it in the example above. Also, classes may be useful without objects at all (just static properties and methods). $c = class {...}; $c::static_foo(); Thanks. Dmitry. --20cf307d0138d73bfd050fd66a6b--