Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:9643 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31863 invoked by uid 1010); 3 May 2004 16:19:17 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 31809 invoked from network); 3 May 2004 16:19:17 -0000 Received: from unknown (HELO smtp-out3.xs4all.nl) (194.109.24.13) by pb1.pair.com with SMTP; 3 May 2004 16:19:17 -0000 Received: from php.net (hetty.xs4all.nl [80.126.21.70]) by smtp-out3.xs4all.nl (8.12.10/8.12.10) with ESMTP id i43GJGdf019519; Mon, 3 May 2004 18:19:16 +0200 (CEST) Message-ID: <40967105.3090001@php.net> Date: Mon, 03 May 2004 18:19:17 +0200 User-Agent: Mozilla Thunderbird 0.5 (X11/20040306) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jochem Maas CC: internals@lists.php.net References: <40966A2A.2080209@iamjochem.com> In-Reply-To: <40966A2A.2080209@iamjochem.com> X-Enigmail-Version: 0.83.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: $this return calling object. From: abies@php.net (Ard Biesheuvel) Ha Jochem, Jochem Maas wrote: > I have discovered behaviour which I imagine is not intended, name > referencing $this in a static method that is called from a from the > method of an instantiated. (see test code below.) > error_reporting(E_ALL & E_STRICT); I'm sure you mean E_ALL | E_STRICT here ... > > Class A { > function test() { > print_r( __CLASS__ );echo "\n"; > print_r( __METHOD__ );echo "\n"; > print_r( $this );echo "\n"; > } > } > > Class B { function test() { A::test(); } } > This behaviour is intentional for methods that are not defined as static. Also, as inherited methods are called using the parent:: syntax, this is the only way to call overridden methods without losing $this from scope along the way. -- Ard