Req #30423 [Com]: get_class(self) for static methods
| From: | s at myriapod dot com | Date: | Mon, 27 Dec 2010 16:44:42 +0000 |
| Subject: | Req #30423 [Com]: get_class(self) for static methods | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-157342@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=30423&edit=1
ID: 30423
Comment by: s at myriapod dot com
Reported by: auroraeosrose at hotmail dot com
Summary: get_class(self) for static methods
Status: Wont fix
Type: Feature/Change Request
Package: Feature/Change Request
Operating System: *
PHP Version: 5.*
Assigned To: helly
Block user comment: N
Private report: N
New Comment:
I think this was actually fixed in php 5.3 with the function
get_called_class()
Previous Comments:
------------------------------------------------------------------------
[2004-10-27 20:16:45] auroraeosrose at hotmail dot com
Then this is a won't fix...sigh...wanna set it to that?
------------------------------------------------------------------------
[2004-10-24 01:00:02] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2004-10-16 19:44:08] helly@php.net
If i get you right you want to know to which class the function call was
up to? If that's the answer i can tell you that we won't fix it because
it would require a new global executor variable.
------------------------------------------------------------------------
[2004-10-15 20:18:15] auroraeosrose at hotmail dot com
I don't think you looked closely enough at the example code to
understand what I was asking for. Notice the method I'm calling is the
parent, NOT the child. I need the CHILD name not the PARENT.
I'm extending a class(an abstract one, not that it matters), but need to
be able to get the name of the child class called in a method in the
parent(abstract) class, because any number of classes could extend the
abstract class.
There's a trick to using get_class() to find out this information, if I
call a method normally. I can do get_class($this) inside the method.
HOWEVER, you can't DO that inside a static method, for obvious reasons
there's no $this. I need a way to do a get_class($this) equivalent in a
static method!! - something like get_class(self). Calling
get_parent_class IN the parent class does me no good whatsoever- you
just get false all the time. I already KNOW the parent, I know how to
get the parent, but I need the child!
(Actually, the ideal thing would be to fix get_class() so it returns the
name of the actual class called, right now it returns whatever class the
method happens to be in, and let __CLASS__ be the name of the class the
method is actually in.)
------------------------------------------------------------------------
[2004-10-14 23:19:53] helly@php.net
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Just await 5.0.3, 5.1.0 or the next snaps build....
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/bug.php?id=30423
--
Edit this bug report at http://bugs.php.net/bug.php?id=30423&edit=1