Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83688 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37257 invoked from network); 24 Feb 2015 19:26:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Feb 2015 19:26:00 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.48 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.220.48 mail-pa0-f48.google.com Received: from [209.85.220.48] ([209.85.220.48:32991] helo=mail-pa0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C3/62-24698-740DCE45 for ; Tue, 24 Feb 2015 14:26:00 -0500 Received: by pabkx10 with SMTP id kx10so38324323pab.0 for ; Tue, 24 Feb 2015 11:25:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=IQuL15Fe3IvHGKEYc4C2xj33NNJnBVPytqv5ykleOOk=; b=mnd0lrCgCb5JxH0zVTawdWiYAgTWC1DKiWeGjwOu3y3zctDX1QcEu1BAUzw8XhI29z qarCZyF4hiKGaCjRxAUSveNzu6rEySBaYsOhxG+oxTfoCfDbrzYqMiBocxPWUmNKQQ8H U9c8+4niM/vP8DRHMqe6em4Oct7fKfnBUs6uxOs1hMAhIa0lcMOl9qx6YUocIBnHiBPN Q2TdqI9G73F2vwnI9+tntVf8raDSOfVdH8m/xJymbW2+zZ0BFLsM9PpR9/vO3FvnSfvg jepc+dhpIBDnCrH1UoDl9SlhtcmFvDxKG1W35c73U7mnpopZD6Ytf0XO++ZAUYG9XVfw +6Rw== X-Received: by 10.66.217.230 with SMTP id pb6mr31557992pac.2.1424805956905; Tue, 24 Feb 2015 11:25:56 -0800 (PST) Received: from Stas-Air.local (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by mx.google.com with ESMTPSA id oq4sm25815367pdb.73.2015.02.24.11.25.55 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Feb 2015 11:25:56 -0800 (PST) Message-ID: <54ECD042.7070800@gmail.com> Date: Tue, 24 Feb 2015 11:25:54 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Dennis Birkholz , internals@lists.php.net References: <54EC8ABD.7040802@birkholz.biz> In-Reply-To: <54EC8ABD.7040802@birkholz.biz> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Anonymous Classes From: smalyshev@gmail.com (Stanislav Malyshev) Hi! > I like the idea of having anonymous classes, it is very helpful during > development to just try something out without having the burden of > creating a new file and a complete class including namespace and use > declarations, etc. I think this particular argument is a bit backwards. In PHP, you certainly don't need to create new file to just introduce a new class. If you're working within a framework that makes it a problem, time to think if the framework you're using is fit for your purposes. But PHP certainly does not impose such limitations. > A great feature of anonymous classes in Java is their ability to access > the private/protected properties of the object they are defined in, > similar to what Closures do in PHP. The thing is, in Java if you access > a variable (without this.), it may be of the current scope, a member of > the current class or a member of the class where the anonymous class was > defined in. In PHP, you have to use $this-> to access class members of That may be a problem to implement, exactly since you need $this in PHP. > Second thing is serialization. PHP closures can not be serialized, does > the same apply for anonymous classes? It would be really nice if such Serializing is not a problem, unserializing would be - as there may be no class for this object to instantiate. -- Stas Malyshev smalyshev@gmail.com