Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:17369 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88620 invoked by uid 1010); 21 Jul 2005 20:09:49 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 88604 invoked from network); 21 Jul 2005 20:09:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Jul 2005 20:09:49 -0000 X-Host-Fingerprint: 84.56.92.55 dsl-084-056-092-055.arcor-ip.net Received: from ([84.56.92.55:20630] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.0 beta r(6227M)) with SMTP id 8F/8F-33635-D0100E24 for ; Thu, 21 Jul 2005 16:09:49 -0400 Message-ID: <8F.8F.33635.D0100E24@pb1.pair.com> To: internals@lists.php.net Date: Thu, 21 Jul 2005 22:09:45 +0200 User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: de-DE, de, en-us, en MIME-Version: 1.0 References: <42DFCA59.6090108@caedmon.net> In-Reply-To: <42DFCA59.6090108@caedmon.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Posted-By: 84.56.92.55 Subject: Re: [PHP-DEV] $this availability inside static-functions From: lists@sebastianmendel.de (Sebastian Mendel) Sean Coates schrieb: >> how can i check if a method is called statically when called from inside >> another object? (without debug_bactrace()) > > type="own">http://blog.phpdoc.info/archives/4-Schizophrenic-Methods.html > > Short answer: > $isStatic = !(isset($this) && get_class($this) == __CLASS__); i know this hack, but it does not work, if the statically called method is from the same class as the calling object class foo { function bar() { if ( isset( $this ) && get_class( $this ) == __CLASS__ ) { return 'not static'; } return 'static'; } function bar2() { return foo::bar(); } } // returns 'static' echo foo::bar(); // returns 'not static' but should be 'static' $foo = new foo; echo $foo->bar2(); -- Sebastian Mendel www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com www.sf.net/projects/phpdatetime www.sf.net/projects/phptimesheet