Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:25200 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 65681 invoked by uid 1010); 4 Aug 2006 17:05:36 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 65666 invoked from network); 4 Aug 2006 17:05:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Aug 2006 17:05:35 -0000 X-PHP-List-Original-Sender: cweiske@cweiske.de X-Host-Fingerprint: 80.237.146.62 cweiske.de Linux 2.4/2.6 Received: from ([80.237.146.62:46569] helo=mail.cweiske.de) by pb1.pair.com (ecelerity 2.1.1.3 r(11751M)) with ESMTP id FF/8D-63329-FA973D44 for ; Fri, 04 Aug 2006 12:45:35 -0400 Received: from [192.168.3.2] (p54B9AF6D.dip0.t-ipconnect.de [84.185.175.109]) by mail.cweiske.de (Postfix) with ESMTP id A11873F8A003 for ; Fri, 4 Aug 2006 18:45:32 +0200 (CEST) Message-ID: <44D379E4.4050504@cweiske.de> Date: Fri, 04 Aug 2006 18:46:28 +0200 User-Agent: My own hands[TM] Mnenhy/0.7.4.0 MIME-Version: 1.0 To: internals@lists.php.net X-Enigmail-Version: 0.94.0.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigEEA270258799C7E742824FF5" Subject: Method inheritance and parent classes From: cweiske@cweiske.de (Christian Weiske) --------------enigEEA270258799C7E742824FF5 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hello all, I recently had a problem that could be solved, but in an ugly way: Class B extended Class A. Both classes define a method with the same name. B called A's constructor, and A called $this->method(). This executed B::method(), not A::method() as you would expect it. build(); } function build() { echo "buildA "; } } class B extends A { function __construct() { parent::__construct(); $this->build(); } function build() { echo "buildB "; } } new B(); ?> output is: "buildB buildB " expected would be: "buildA buildB " I suggest changing the behavior of php to never call methods of classes that are added by subclasses, only own ones or inherited ones. --=20 Regards/MfG, Christian Weiske --------------enigEEA270258799C7E742824FF5 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) iD8DBQFE03nlFMhaCCTq+CMRAm3dAJ9GH65+rzNHRz02QI7LC7YTLYDf+gCg3J0p a8cxqOOd8RgC9rPIJbndDuo= =H79h -----END PGP SIGNATURE----- --------------enigEEA270258799C7E742824FF5--