Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32558 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94356 invoked by uid 1010); 2 Oct 2007 17:02:44 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 94340 invoked from network); 2 Oct 2007 17:02:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Oct 2007 17:02:44 -0000 Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.162 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 212.25.124.162 mail.zend.com Windows 2000 SP4, XP SP1 Received: from [212.25.124.162] ([212.25.124.162:20036] helo=mx1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A7/C5-57391-2B972074 for ; Tue, 02 Oct 2007 13:02:43 -0400 Received: from us-ex1.zend.com ([192.168.16.5]) by mx1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 2 Oct 2007 19:02:37 +0200 Received: from [127.0.0.1] ([192.168.16.180]) by us-ex1.zend.com with Microsoft SMTPSVC(6.0.3790.1830); Tue, 2 Oct 2007 09:53:17 -0700 Message-ID: <4702777C.2090406@zend.com> Date: Tue, 02 Oct 2007 09:53:16 -0700 Organization: Zend Technologies User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: Sebastian Bergmann CC: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 02 Oct 2007 16:53:17.0568 (UTC) FILETIME=[BB0C2800:01C80514] Subject: Re: [PHP-DEV] Class Posing From: stas@zend.com (Stanislav Malyshev) > 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. > ?> This looks like factory pattern. What's wrong with implementing it as factory? > 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. I personally don't see much of the use of it in the core, and it definitely adds very "magic" things - you don't know anymore what class you are instantiating when you run "new Foo". My opinion is it belongs to places like "runkit" which do tricks with the language, but I don't see much use for it in the core. Could you explain more why existing pattern won't work for the same? -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com