Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33284 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 911 invoked by uid 1010); 19 Nov 2007 06:11:03 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 896 invoked from network); 19 Nov 2007 06:11:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Nov 2007 06:11:02 -0000 Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 76.96.30.64 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 76.96.30.64 qmta07.emeryville.ca.mail.comcast.net Received: from [76.96.30.64] ([76.96.30.64:39906] helo=QMTA07.emeryville.ca.mail.comcast.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 30/DD-31009-5F821474 for ; Mon, 19 Nov 2007 01:11:02 -0500 Received: from OMTA11.emeryville.ca.mail.comcast.net ([76.96.30.36]) by QMTA07.emeryville.ca.mail.comcast.net with comcast id ENud1Y0040mlR8U0A0XV00; Mon, 19 Nov 2007 06:11:02 +0000 Received: from earth.ufp ([71.228.13.89]) by OMTA11.emeryville.ca.mail.comcast.net with comcast id EWB11Y0021vH2xB0800000; Mon, 19 Nov 2007 06:11:02 +0000 X-Authority-Analysis: v=1.0 c=1 a=nVmK11NPAAAA:8 a=kSxYkulIxkO8YEPKEEsA:9 a=_4WJcTeXmd7MqtlqoTUA:7 a=xXrAmABXwdqKWAOet2FxR-w-phAA:4 a=FHBbIDN7CdwA:10 a=OKOUxLlJrqkA:10 Received: from localhost (localhost [127.0.0.1]) by earth.ufp (Postfix) with ESMTP id 50536D8314 for ; Mon, 19 Nov 2007 00:10:58 -0600 (CST) Received: from earth.ufp ([127.0.0.1]) by localhost (earth.ufp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Qg5qoRYIZ4au for ; Mon, 19 Nov 2007 00:10:58 -0600 (CST) Received: from vulcan.ufp (vulcan.ufp [192.168.42.4]) by earth.ufp (Postfix) with ESMTP id 35728D8312 for ; Mon, 19 Nov 2007 00:10:48 -0600 (CST) To: internals@lists.php.net Date: Mon, 19 Nov 2007 00:11:37 -0600 User-Agent: KMail/1.9.6 (enterprise 0.20070907.709405) References: <1195140437.23612.5.camel@sbarrow-desktop> <1195450232.12342.25.camel@sams-room> In-Reply-To: <1195450232.12342.25.camel@sams-room> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <200711190011.37405.larry@garfieldtech.com> Subject: Re: [PHP-DEV] Multiple class inheritance From: larry@garfieldtech.com (Larry Garfield) (Sorry, hit reply too soon.) Or, alternatively, you can mostly implement "friend" functions of a sort: http://www.garfieldtech.com/blog/php-magic-call but they have a performance penalty: http://www.garfieldtech.com/blog/magic-benchmarks On Sunday 18 November 2007, Sam Barrow wrote: > What is the general opinion on multiple class inheritance. I have a need > for it. I have objects for all user input fields. > > $username = new field ; > $username -> name = 'username' ; > $username -> maxLen = 32 ; > > I have three types of fields. Fields that are automatically put in the > database, such as timestamps, fields that are inputted but not stored, > such as "confirm password", and fields that are inputted by the user AND > stored in the database, such as username and password. > > Now i have 3 classes: > > - abstractField (has methods and properties that apply to all fields). > - inputField, extends abstractField (has methods and properties for > display of input form elements and labels). > - dbField, extends abstractField (has methods for storing and retrieving > in db, etc.). > > However for fields that are inputted AND stored in the db, i need to > extend both inputField and dbField. > > - inputDbField extends inputField, dbField. > > Sure, there may be quick hacks to do this, but the only proper way seems > to be to extend both classes, and I don't want to duplicate any code > (dbField and inputField are both pretty big, and any modifications will > also have to be replicated). > > And no, I don't want to use interfaces. Interfaces will barely do > anything for me, I'll still have to duplicate my method bodies, and > properties. -- Larry Garfield AIM: LOLG42 larry@garfieldtech.com ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson