1

I'm designing a simple exception handler to use in my PHP projects. One of the things that always bugged me is the poor stack trace which truncates arguments etc. So I decided to use the getTrace()-method to parse the array in a more usable string.
Doing so works fine, but I noticed that static method calls are not represented correctly:

getTrace():

#3 /system/session.php(38): Session->__construct()
#2 /system/session.php(126): Session->instance()

getTraceAsString():

#1 /system/session.php(38): Session->__construct()
#2 /system/session.php(126): Session::instance()

...where Session might look like so:

class Session(){
  public static function instance(){}
  public function __construct(){}
}

Seems like the scope resolution operator (::) is replaced by the object operator (->) no matter what by getTrace().

Why is that so? Can I do something about it, is there a parameter I'm lacking?

Moritz Friedrich
  • 1,371
  • 20
  • 38

1 Answers1

0

Found it! When using Stack Overflow answers you should read carefully sometimes.

The original answer uses sprintf() to replace the class with the following:

...
isset($frame['class']) ? $frame['class'] . '->' : '',
...

where it should be:

...
isset($frame['class']) ? $frame['class'] . $frame['type'] : '',
...
Community
  • 1
  • 1
Moritz Friedrich
  • 1,371
  • 20
  • 38