Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49558 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87777 invoked from network); 2 Sep 2010 17:29:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Sep 2010 17:29:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=etienne@immomigsa.ch; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=colder@php.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain immomigsa.ch from 94.103.100.39 cause and error) X-PHP-List-Original-Sender: etienne@immomigsa.ch X-Host-Fingerprint: 94.103.100.39 mailer.immomigsa.ch Linux 2.6 Received: from [94.103.100.39] ([94.103.100.39:54191] helo=mailer.immomigsa.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C6/B5-40118-8EEDF7C4 for ; Thu, 02 Sep 2010 13:29:13 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by mailer.immomigsa.ch (Postfix) with ESMTP id F02D14B626A1 for ; Thu, 2 Sep 2010 19:29:09 +0200 (CEST) X-Virus-Scanned: amavisd-new at immomigsa.ch Received: from mailer.immomigsa.ch ([127.0.0.1]) by localhost (mailer.immomigsa.ch [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id smqFC6K9HLLc for ; Thu, 2 Sep 2010 19:29:05 +0200 (CEST) Received: from croustillant.local (79-158.105-92.cust.bluewin.ch [92.105.158.79]) by mailer.immomigsa.ch (Postfix) with ESMTPA id 3D5794B62696 for ; Thu, 2 Sep 2010 19:29:05 +0200 (CEST) Received: by croustillant.local (Postfix, from userid 501) id 9846212AFACB; Thu, 2 Sep 2010 19:29:04 +0200 (CEST) Date: Thu, 2 Sep 2010 19:29:04 +0200 To: internals@lists.php.net Message-ID: <20100902172904.GC31219@croustillant.local> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Subject: Re: [PHP-DEV] zend_register_class() overwrites ce->create_object with parent_ce->create_object? From: colder@php.net (Etienne Kneuss) On Sep 02 18:04:12, Michael Wallner wrote: > If I define a descendant class, I *obviously* know what create_object should > do, as this should only effect internal classes. So could anybody please > explain to me why the parent's create_object is enforced? > > It causes to write hacks like: > > ---8<--- > zend_class_entry *ce; > zend_object_value (*__create_object)(zend_class_entry *ce TSRMLS_DC); > > INIT_CLASS_ENTRY(ce, "classname", php_my_method_entry); > ce.create_object = php_my_object_new; > /* hack starts here */ > __create_object = parent_ce->create_object; > parent_ce->create_object = php_my_object_new; > php_my_class_entry = zend_register_internal_class_ex(&ce, parent_ce, NULL TSRMLS_CC); > parent->create_object = __create_object; > --->8--- Why can't you simply overwrite it afterwards? Just like it's done in SPL: http://php-og.mgdm.net/opengrok/xref/PHP_5_3/ext/spl/spl_functions.c#41 Best, > > If this limitation is there without a really good reason, I'd like to get rid of it. > > Thanks, > Mike > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > -- Etienne Kneuss