[PHP] Re: Get name of extending class with static method call

2005-01-12 Thread Torsten Roehr
Jason Barnett [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] The only other solution that comes to mind is a little messy but it lets you get away with no object. Instead of calling the method statically you can use call_user_func_array() with the child class name as a parameter.

Re: [PHP] Re: Get name of extending class with static method call

2005-01-12 Thread Torsten Roehr
Torsten, I also found the following link to be helpful. Check out the user notes from michael at digitalgnosis dot removethis dot com (he did something similar to what I have already suggested, i.e. call_user_func) http://www.php.net/manual/en/language.oop5.static.php Hi Jason, thanks for

Re: [PHP] Re: Get name of extending class with static method call

2005-01-12 Thread Jason Barnett
By tunnelling the call through Porsche's own drive() method debug_backtrace() will contain two traces, one of them with the correct class name. I tried using reflection but reflecting car by using __CLASS__ doesn't give any information about the classes that extend it. So this doesn't work either.

Re: [PHP] Re: Get name of extending class with static method call

2005-01-12 Thread Jochem Maas
Jason Barnett wrote: Indeed! I was actually quite surprised that this wasn't the way __CLASS__ resolved... I had to code it to believe it (and I didn't even do that until after you told us __CLASS__ didn't work!) I would like to thank all of those that cared about my problem and tried to

Re: [PHP] Re: Get name of extending class with static method call

2005-01-12 Thread Jochem Maas
darn, send button again!! (sent too early) Jochem Maas wrote: Jason Barnett wrote: Indeed! I was actually quite surprised that this wasn't the way __CLASS__ resolved... I had to code it to believe it (and I didn't even do that until after you told us __CLASS__ didn't work!) I would like to

Re: [PHP] Re: Get name of extending class with static method call

2005-01-12 Thread Morten Rønseth
Hi, I just tried the example code at http://www.zend.com/lists/php-dev/200307/msg00244.html using PHP 5.0.3 The backtrace doesn't see class b at all, all references to it have vanished into thin air. I spent days trying to solve this on my own until I happened upon this thread - it appears

Re: [PHP] Re: Get name of extending class with static method call

2005-01-12 Thread Torsten Roehr
Morten Rønseth [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, I just tried the example code at http://www.zend.com/lists/php-dev/200307/msg00244.html using PHP 5.0.3 The backtrace doesn't see class b at all, all references to it have vanished into thin air. I spent days

Re: [PHP] Re: Get name of extending class with static method call

2005-01-12 Thread M. Sokolewicz
Torsten Roehr wrote: Morten Rønseth [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, I just tried the example code at http://www.zend.com/lists/php-dev/200307/msg00244.html using PHP 5.0.3 The backtrace doesn't see class b at all, all references to it have vanished into thin air. I

Re: [PHP] Re: Get name of extending class with static method call

2005-01-12 Thread Mehdi Achour
Because it's a change, that should be reverted, or documented. didou M. Sokolewicz wrote: Torsten Roehr wrote: Morten Rønseth [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, I just tried the example code at http://www.zend.com/lists/php-dev/200307/msg00244.html using PHP 5.0.3 The

Re: [PHP] Re: Get name of extending class with static method call

2005-01-12 Thread Jochem Maas
Morten Rønseth wrote: Hi, I just tried the example code at http://www.zend.com/lists/php-dev/200307/msg00244.html using PHP 5.0.3 The backtrace doesn't see class b at all, all references to it have vanished into thin air. as a side note - using a function like debug_backtrace() seems to be a

Re: [PHP] Re: Get name of extending class with static method call

2005-01-12 Thread Jochem Maas
Mehdi Achour wrote: Because it's a change, that should be reverted, or documented. don't top post - its bad form and many people ignore topposts. Mehdi is right to say that debug_backtrace() has changed - but so has the whole engine - I don't think that function was ever meant to be used in the

Re: [PHP] Re: Get name of extending class with static method call

2005-01-12 Thread Morten Rønseth
Jochem Maas wrote: Morten Rønseth wrote: Hi, I just tried the example code at http://www.zend.com/lists/php-dev/200307/msg00244.html using PHP 5.0.3 The backtrace doesn't see class b at all, all references to it have vanished into thin air. as a side note - using a function like

Re: [PHP] Re: Get name of extending class with static method call

2005-01-12 Thread Morten Rønseth
Jochem Maas wrote: Mehdi Achour wrote: Because it's a change, that should be reverted, or documented. don't top post - its bad form and many people ignore topposts. Mehdi is right to say that debug_backtrace() has changed - but so has the whole engine - I don't think that function was ever meant

[PHP] Re: Get name of extending class with static method call

2005-01-11 Thread M. Sokolewicz
try using __CLASS__ Torsten Roehr wrote: Hi list, in PHP4 it was possible to get the name of the calling class with debug_bcktrace(). Unfortunately this behaviour has been changed in PHP5. I didn't find a solution in the archives. Is there *any* way to get the name of the calling class?: class Car

[PHP] Re: Get name of extending class with static method call

2005-01-11 Thread Jason Barnett
M. Sokolewicz wrote: try using __CLASS__ Torsten Roehr wrote: This is a good suggestion but I wonder... Torsten do you have a large heirarchy of parent classes or just one parent? E.g. Car - Sports Car - Porsche. More importantly will __CLASS__ resolve to the class name that you need... If

[PHP] Re: Get name of extending class with static method call

2005-01-11 Thread Torsten Roehr
Jason Barnett [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] M. Sokolewicz wrote: try using __CLASS__ Torsten Roehr wrote: This is a good suggestion but I wonder... Torsten do you have a large heirarchy of parent classes or just one parent? E.g. Car - Sports Car - Porsche.

[PHP] Re: Get name of extending class with static method call

2005-01-11 Thread Jason Barnett
__CLASS__ contains the name of the class the method is in. In my sample it would be 'Car' and not 'Porsche'. What I don't understand is why the behaviour of debug_backtrace() has been changed!?! Regards, Torsten I have no idea why the behaviour changed (I didn't really use the function before,

Re: [PHP] Re: Get name of extending class with static method call

2005-01-11 Thread Christopher Fulton
This should work for you then(maybe...i don't have php5 on my system, so it may not, but i think it would. http://us4.php.net/manual/en/function.get-class.php class Car { function drive() { return get_class($this); } } class Porshe { } $foo = new Porshe();

Re: [PHP] Re: Get name of extending class with static method call

2005-01-11 Thread Daniel Schierbeck
Christopher Fulton wrote: This should work for you then(maybe...i don't have php5 on my system, so it may not, but i think it would. http://us4.php.net/manual/en/function.get-class.php class Car { function drive() { return get_class($this); } } class Porshe { }

Re: [PHP] Re: Get name of extending class with static method call

2005-01-11 Thread Jason Barnett
Christopher Fulton wrote: This should work for you then(maybe...i don't have php5 on my system, so it may not, but i think it would. http://us4.php.net/manual/en/function.get-class.php class Car { function drive() { return get_class($this); } } class Porshe { }

Re: [PHP] Re: Get name of extending class with static method call

2005-01-11 Thread M. Sokolewicz
Daniel Schierbeck wrote: Christopher Fulton wrote: This should work for you then(maybe...i don't have php5 on my system, so it may not, but i think it would. http://us4.php.net/manual/en/function.get-class.php class Car { function drive() { return get_class($this);

Re: [PHP] Re: Get name of extending class with static method call

2005-01-11 Thread Rory Browne
I was kinda thinking about all that too, for a project I'm currently doing, in that I wanted to be able to create a singleton, without having to put the singleton code in each class. The only hack I could think of was to use debug_backtrace() to get the line of source that contained the call, and