Hi,

Not really, too.

<?php
class a {
    static public function foo() {
        print_r(debug_backtrace());
    }
}

class b extends a {}

a::foo();
b::foo();
?>
Array
(
    [0] => Array
        (
            [file] => -
            [line] => 8
            [function] => foo
            [class] => a
            [type] => ::
            [args] => Array
                (
                )

        )

)
Array
(
    [0] => Array
        (
            [file] => -
            [line] => 8
            [function] => foo
            [class] => a
            [type] => ::
            [args] => Array
                (
                )

        )

)

in both cases it tells [class] => a, so one still needs to extend the
foo()-Method:

<?php
class a {
    static public function foo() {
        print_r(debug_backtrace());
    }
}

class b extends a {
    static public function foo() {
        parent::foo();
    }
}

a::foo();
b::foo();
?>
Array
(
    [0] => Array
        (
            [file] => -
            [line] => 15
            [function] => foo
            [class] => a
            [type] => ::
            [args] => Array
                (
                )

        )

)
Array
(
    [0] => Array
        (
            [file] => -
            [line] => 11
            [function] => foo
            [class] => a
            [type] => ::
            [args] => Array
                (
                )

        )

    [1] => Array
        (
            [file] => -
            [line] => 16
            [function] => foo
            [class] => b
            [type] => ::
            [args] => Array
                (
                )

        )

)

Asyou can see at $bt = debug_backtrace(); $bt[1]['class'] the name is
available - but only if the function wasextended like in the example....

johannes

Sara Golemon wrote:

> debug_backtrace();
> 
> Not the prettiest solution, but a reliable one nonetheless.
> 
> -Sara
> 
> "Johannes Schlueter" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> Hi,
>>
>> Andrey Hristov wrote:
>> > echo get_class($this).'::'.__FUNCTION__ (when there is an instance of
> the
>> > class) but AFAIK in your case with static calls there is no solution.
>>
>> Is there some way to add a function (or some other magic thing) that
>> works with static calls and call it a bug fix, so it can be in 5.0? If
>> not: Is there a way to implement it and add it as a new feature with
>> PHP5.1? Lately I needed such a thing while building some kind of
>> framework. I
> solved
>> it by adding a function to my extended class which passes it's __CLASS__
> as
>> an additional paramter to my base function - I don't really like it that
>> way ;-)
>>
>> johannes

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to