#34804 [Com]: More information about class methods

From: Date: Wed, 11 Jan 2006 20:35:08 +0000
Subject: #34804 [Com]: More information about class methods
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-91779@lists.php.net to get a copy of this message
ID: 34804 Comment by: kvesteri at cc dot hut dot fi Reported By: toomuchphp-phpbugs at yahoo dot com Status: Open Bug Type: Feature/Change Request Operating System: Any PHP Version: 5.1.0RC1 New Comment: There should definetly be atleast constant __INHERITED_BY__. This new constant would allow many wonderful things like a generic singleton class and an efficient implementation of the martin fowler's Active Record pattern. Previous Comments: ------------------------------------------------------------------------ [2005-10-10 10:12:46] toomuchphp-phpbugs at yahoo dot com Description: ------------ Inside any class method, there are as many as 3 related class and it would be useful to have all of them as magic constants, and also in the debug_backtrace function. Currently only __CLASS__ is available (the name of the direct owner of the method). It would be good to know the name of the child class (if the method was called as part of a child class), and the name of the calling class if the method was called statically (the same as get_class($this) inside a static method). This information would be most useful in the debug_backtrace() array. debug_backtrace() was recently modified to report the direct owner class name rather than the inheriting class' name (see bug #30828) but it would really be more helpful in debugging to have all three possible class names available. Reproduce code: --------------- class A { function A() { echo 'direct owner: '.__CLASS__."\n"; echo 'called as part of: '.__INHERITED_BY__."\n"; echo 'called by instance of: '.__STATIC_CALLER__."\n"; } } class B extends A { } class C { function __construct() { B::A(); } } new C(); Expected result: ---------------- direct owner: A called as part of: B called by instance of: C ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34804&edit=1

« previous php.bugs (#91779) next »