Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32615 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22529 invoked by uid 1010); 3 Oct 2007 20:48:17 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 22513 invoked from network); 3 Oct 2007 20:48:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Oct 2007 20:48:17 -0000 Authentication-Results: pb1.pair.com header.from=johannes@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 83.243.58.163 as permitted sender) X-PHP-List-Original-Sender: johannes@php.net X-Host-Fingerprint: 83.243.58.163 mail4.netbeat.de Received: from [83.243.58.163] ([83.243.58.163:54015] helo=mail4.netbeat.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 70/03-05854-01004074 for ; Wed, 03 Oct 2007 16:48:17 -0400 Received: (qmail 29295 invoked by uid 507); 3 Oct 2007 20:48:11 -0000 Received: from unknown (HELO ?192.168.1.102?) (postmaster%schlueters.de@82.135.94.254) by mail4.netbeat.de with ESMTPA; 3 Oct 2007 20:48:11 -0000 To: Sebastian Bergmann Cc: internals@lists.php.net In-Reply-To: References: Content-Type: text/plain Date: Wed, 03 Oct 2007 22:48:10 +0200 Message-ID: <1191444490.21871.38.camel@johannes.nop> Mime-Version: 1.0 X-Mailer: Evolution 2.10.3 (2.10.3-4.fc7) Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Class Posing From: johannes@php.net (Johannes =?ISO-8859-1?Q?Schl=FCter?=) Hi, On Tue, 2007-10-02 at 15:54 +0200, Sebastian Bergmann wrote: > Guilherme Blanco schrieb: > > Altho I found this idea really interesting, I have a suggestion for > > it. Instead of use a function to handle new overloads, I suggest a > > magic method, something like __new. > > __new() was what I initially proposed to Johannes but IIRC there were > some performance implications with that. Johannes? The initial implementation Sebastian refers to is a conference hack I did, which was done to see whether it's possible and give Sebastian a thing to test the feature - there wasn't much thinking involved :-) For an extension, which the current implementation is, using the register function is the best approach I see. Else we would have to to the look-up for the __new() function on every object instantiation. The existence of that function can't be cached since it could be defined any time. (While for an extension, used for testing, performance is not #1 prio) If such an feature would become an engine feature one could cache the declaration of __new() during the function declaration - which in that case would, indeed, be the best. But all that are implementation details. The question is: Do we need such a feature inside Core PHP or is an extension overloading ZEND_NEW enough? The only need I see is mocking objects for a unit test. This is usually done on a test system so installing such an extension shouldn't be to hard (especially for somebody who is able to do unit tests using mock objects...) One might also think about taking XDebug's code coverage stuff and the ZEND_NEW overloading and other stuff to build a phpunit extension - but that's no topic for internals :-) johannes