Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:26289 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 3354 invoked by uid 1010); 31 Oct 2006 20:41:10 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 3338 invoked from network); 31 Oct 2006 20:41:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Oct 2006 20:41:10 -0000 Authentication-Results: pb1.pair.com header.from=jochem@iamjochem.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=jochem@iamjochem.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain iamjochem.com from 194.109.193.121 cause and error) X-PHP-List-Original-Sender: jochem@iamjochem.com X-Host-Fingerprint: 194.109.193.121 mx1.moulin.nl Linux 2.6 Received: from [194.109.193.121] ([194.109.193.121:46066] helo=mx1.moulin.nl) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 43/0E-03994-4E4B7454 for ; Tue, 31 Oct 2006 15:41:10 -0500 Received: from localhost (localhost [127.0.0.1]) by mx1.moulin.nl (Postfix) with ESMTP id ECF621FA838; Tue, 31 Oct 2006 21:41:13 +0100 (CET) X-Virus-Scanned: amavisd-new at moulin.nl Received: from mx1.moulin.nl ([127.0.0.1]) by localhost (mx1.moulin.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YhFV1GP3cQDy; Tue, 31 Oct 2006 21:41:09 +0100 (CET) Received: from [10.0.13.54] (ip129-15-211-87.adsl2.versatel.nl [87.211.15.129]) by mx1.moulin.nl (Postfix) with ESMTP id 3C6101FA7B9; Tue, 31 Oct 2006 21:41:09 +0100 (CET) Message-ID: <4547B4DC.7020507@iamjochem.com> Date: Tue, 31 Oct 2006 21:41:00 +0100 User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 To: Jasper Bryant-Greene CC: evert@rooftopsolutions.nl, internals@lists.php.net References: <4547AE3D.3010706@rooftopsolutions.nl> <4547B12C.1010501@albumltd.co.nz> In-Reply-To: <4547B12C.1010501@albumltd.co.nz> X-Enigmail-Version: 0.94.0.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Using grand-parent constructor From: jochem@iamjochem.com (Jochem Maas) Jasper Bryant-Greene wrote: > adding parent::__construct() in the constructors of both Parent and > Child should do what you want. not only that but you 'should' _always_ really be calling the complete constructor chain (e.g. Gparent < Parent < Child) according to "OO theory" - the thought being that the construction phase is critical to instantiating a class instance, a subclass should be able to rely on the fact that the baseclass definition is completely/correct instantiated when it is created. sounds to me that either your class hierarchy is 'wrong' or there is some code in the Parent ctor that should belopng in some optional (protected?) setup/utility function. just a thought. > > Jasper > > Evert | Rooftop wrote: >> Hi List, >> >> Sorry if this is the wrong list for this kind of stuff.. I'd be happy to >> re-post this to the users mailing list. >> >> With the recent updates that will raise E_STRICT on static calls that >> are non static, how do we properly do the following.. >> >> I have a class named 'GrandParent' a class named 'Parent' and a class >> named 'Child' >> >> GrandParent has a constructor, Parent overrides it and Child does too.. >> What if I want to call GrandParent's constructor from the child? >> >> Most languages allow this through casting the class into the ancestor >> and call then call the method, but I can't do this with PHP, or can I ? >> The other solution (right now) would be GrandParent::__construct(), but >> this is not OOP anymore.. So it seems kind of weird that we get limited >> in functionality, for OOP-ness, but not adding the functionality to >> solve common design problems that we're raised by introducing this.. >> >> Will we get casting in the future? >> >> Evert >> >