Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:25204 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1070 invoked by uid 1010); 5 Aug 2006 06:13:04 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 1055 invoked from network); 5 Aug 2006 06:13:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Aug 2006 06:13:04 -0000 Authentication-Results: pb1.pair.com header.from=manchokapitancho@gmail.com; domainkeys=good DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: manchokapitancho@gmail.com X-Host-Fingerprint: 64.233.182.186 nf-out-0910.google.com Linux 2.4/2.6 Received: from ([64.233.182.186:41517] helo=nf-out-0910.google.com) by pb1.pair.com (ecelerity 2.1.1.3 r(11751M)) with ESMTP id 01/9E-49980-EE634D44 for ; Sat, 05 Aug 2006 02:13:04 -0400 Received: by nf-out-0910.google.com with SMTP id p48so1692878nfa for ; Fri, 04 Aug 2006 23:13:00 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=lPr46fNOQkc8q7w+JSyTE7h3wR8Mo2NOupnVcDd9ru3I4uZqkxxcmg51mbp/R+8WKmLITscrkswoFIgfulIQWTrbLN2ynnIBBP3926iglKpVZ00jD0gMcGpkpNe/ki9MibTo6hfmvmDdH8U4EPbzbTMbZ06NLBpu+fUapkcBuKg= Received: by 10.78.140.17 with SMTP id n17mr1831486hud; Fri, 04 Aug 2006 23:13:00 -0700 (PDT) Received: by 10.78.169.10 with HTTP; Fri, 4 Aug 2006 23:12:59 -0700 (PDT) Message-ID: Date: Sat, 5 Aug 2006 09:12:59 +0300 To: internals@lists.php.net In-Reply-To: <44D379E4.4050504@cweiske.de> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_54539_30928540.1154758379988" References: <44D379E4.4050504@cweiske.de> Subject: Re: [PHP-DEV] Method inheritance and parent classes From: manchokapitancho@gmail.com ("Marian Kostadinov") ------=_Part_54539_30928540.1154758379988 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline use self::build() or A::build() for that case 2006/8/4, Christian Weiske : > > 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. > > class A { > function __construct() { > $this->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. > > -- > Regards/MfG, > Christian Weiske > > > > ------=_Part_54539_30928540.1154758379988--