Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32552 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33669 invoked by uid 1010); 2 Oct 2007 14:33:38 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 33654 invoked from network); 2 Oct 2007 14:33:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Oct 2007 14:33:38 -0000 Authentication-Results: pb1.pair.com header.from=jared.williams1@ntlworld.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=jared.williams1@ntlworld.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ntlworld.com designates 81.103.221.48 as permitted sender) X-PHP-List-Original-Sender: jared.williams1@ntlworld.com X-Host-Fingerprint: 81.103.221.48 mtaout02-winn.ispmail.ntl.com Solaris 10 (beta) Received: from [81.103.221.48] ([81.103.221.48:11908] helo=mtaout02-winn.ispmail.ntl.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C9/B4-02565-FB652074 for ; Tue, 02 Oct 2007 10:33:37 -0400 Received: from aamtaout03-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout02-winn.ispmail.ntl.com with ESMTP id <20071002143332.YLZZ4.mtaout02-winn.ispmail.ntl.com@aamtaout03-winn.ispmail.ntl.com> for ; Tue, 2 Oct 2007 15:33:32 +0100 Received: from p2 ([82.3.16.111]) by aamtaout03-winn.ispmail.ntl.com with ESMTP id <20071002143332.MQJN26699.aamtaout03-winn.ispmail.ntl.com@p2> for ; Tue, 2 Oct 2007 15:33:32 +0100 To: Date: Tue, 2 Oct 2007 15:33:36 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4073 Thread-Index: AcgE2H3LMvnEkFhWT5+K5wFJxrKE7gAJ9D4g In-Reply-To: Message-ID: <20071002143332.MQJN26699.aamtaout03-winn.ispmail.ntl.com@p2> Subject: RE: [PHP-DEV] Class Posing From: jared.williams1@ntlworld.com ("Jared Williams") References: Ideally think I'd prefer it finer grained... interface A { } class AImpl implements A { } register('A', function() { return new AImpl(); }); register('Foo', function() { return new Bar(); }); $foo = new Foo(); $a = new A(); Would also require functions being values... Which would also be nice. J > -----Original Message----- > From: news [mailto:news@sea.gmane.org] On Behalf Of Sebastian Bergmann > Sent: 02 October 2007 10:33 > To: internals@lists.php.net > Subject: [PHP-DEV] Class Posing > > From [1]: > > Objective-C permits a class to wholly replace another > class within a > program. The replacing class is said to "pose as" the target class. > All messages sent to the target class are then instead received by > the posing class. > > There are several restrictions on which classes can pose: > > * A class may only pose as one of its direct or indirect > superclasses. > > [The other restrictions do not apply to PHP] > > Earlier this year, Johannes implemented class posing for PHP > as follows: > > class Foo {} > class Bar extends Foo {} > > function new_overload($className) > { > if ($className == 'Foo') { > return new Bar; > } > > // ... > } > > $o = new Foo; > // $o is an object of Foo. > > register_new_overload('new_overload'); > > $o = new Foo; > // $o is an object of Bar. > ?> > > We (Johannes, Marcus, Sara, and myself) then discussed where > to put this functionality. Outside of core, there were two > places that both make > sense: pecl/operator and pecl/runkit. > > However, to make this a viable mechanism that can be used in > tools such as PHPUnit (for which I could really use this > functionality), we agreed that it actually belongs into the core. > > Opinions? Needless to say that I would love to see this in > PHP 5.3 ;-) > > -- > [1] http://en.wikipedia.org/wiki/Objective_C#Posing > > -- > Sebastian Bergmann > http://sebastian-bergmann.de/ > GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 > C514 B85B 5D69 > > -- > PHP Internals - PHP Runtime Development Mailing List To > unsubscribe, visit: http://www.php.net/unsub.php >