#33657 [Opn->WFx]: Function to determine whether a method is called statically

From: Date: Tue, 12 Jul 2005 10:37:21 +0000
Subject: #33657 [Opn->WFx]: Function to determine whether a method is called statically
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-81724@lists.php.net to get a copy of this message
ID: 33657 Updated by: derick@php.net Reported By: tonvandenheuvel at gmail dot com -Status: Open +Status: Wont fix Bug Type: Feature/Change Request Operating System: Linux PHP Version: 4.4.0 New Comment: You should never have to test if a function is static or not - if you have to your design is broken. Previous Comments: ------------------------------------------------------------------------ [2005-07-12 12:17:56] tonvandenheuvel at gmail dot com Description: ------------ Currently, I'm using this function to determine whether a function is called statically: function IsCalledStatically() { $debugBt = debug_backtrace(); return $debugBt[1]['type'] == '::'; } Having to rely on the debugger is not very efficient here. Other methods checking whether $this is set are not fool proof in a situation where a class' method is called statically from another class method where $this is defined (possibly within the same class!). ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33657&edit=1

« previous php.bugs (#81724) next »