3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Serializable_Exception extends Exception { protected $serialized_backtrace; public function __sleep() { // If we just serialize, we lose the backtrace info completely // But we may well want to log or inspect this string later... if ( is_null($this->serialized_backtrace) ) { $this->serialized_backtrace = $this->getTraceAsString(); } return array_keys(get_object_vars($this)); } public function enhancedGetTraceAsString() { if ( isset($this->serialized_backtrace) ) { return $this->serialized_backtrace; } else { return parent::getTraceAsString(); } } } function foo($x) { throw new Serializable_Exception; } try { foo( new SimpleXMLElement('<test />') ); } catch ( Exception $e ) { echo $e->enhancedGetTraceAsString(); echo "\n -- \n"; echo unserialize( serialize($e) )->enhancedGetTraceAsString(); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 7
Branch analysis from position: 7
2 jumps found. (Code = 107) Position 1 = 8, Position 2 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IHPI5
function name:  (null)
number of ops:  22
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   INIT_FCALL                                               'foo'
          1        NEW                                              $1      'SimpleXMLElement'
          2        SEND_VAL_EX                                              '%3Ctest+%2F%3E'
          3        DO_FCALL                                      0          
          4        SEND_VAR                                                 $1
          5        DO_FCALL                                      0          
          6      > JMP                                                      ->21
   36     7  E > > CATCH                                       last         'Exception'
   37     8    >   INIT_METHOD_CALL                                         !0, 'enhancedGetTraceAsString'
          9        DO_FCALL                                      0  $4      
         10        ECHO                                                     $4
   38    11        ECHO                                                     '%0A+--+%0A'
   39    12        INIT_FCALL                                               'unserialize'
         13        INIT_FCALL                                               'serialize'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                         $5      
         16        SEND_VAR                                                 $5
         17        DO_ICALL                                         $6      
         18        INIT_METHOD_CALL                                         $6, 'enhancedGetTraceAsString'
         19        DO_FCALL                                      0  $7      
         20        ECHO                                                     $7
   40    21    > > RETURN                                                   1

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/IHPI5
function name:  foo
number of ops:  5
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   30     1        NEW                                              $1      'Serializable_Exception'
          2        DO_FCALL                                      0          
          3      > THROW                                         0          $1
   31     4*     > RETURN                                                   null

End of function foo

Class Serializable_Exception:
Function __sleep:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/IHPI5
function name:  __sleep
number of ops:  16
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   FETCH_OBJ_R                                      ~0      'serialized_backtrace'
          1        TYPE_CHECK                                    2          ~0
          2      > JMPZ                                                     ~1, ->7
   12     3    >   INIT_METHOD_CALL                                         'getTraceAsString'
          4        DO_FCALL                                      0  $3      
          5        ASSIGN_OBJ                                               'serialized_backtrace'
          6        OP_DATA                                                  $3
   15     7    >   INIT_FCALL                                               'array_keys'
          8        INIT_FCALL                                               'get_object_vars'
          9        FETCH_THIS                                       ~4      
         10        SEND_VAL                                                 ~4
         11        DO_ICALL                                         $5      
         12        SEND_VAR                                                 $5
         13        DO_ICALL                                         $6      
         14      > RETURN                                                   $6
   16    15*     > RETURN                                                   null

End of function __sleep

Function enhancedgettraceasstring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 5
Branch analysis from position: 2
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IHPI5
function name:  enhancedGetTraceAsString
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   ISSET_ISEMPTY_PROP_OBJ                                   'serialized_backtrace'
          1      > JMPZ                                                     ~0, ->5
   21     2    >   FETCH_OBJ_R                                      ~1      'serialized_backtrace'
          3      > RETURN                                                   ~1
   20     4*       JMP                                                      ->8
   24     5    >   INIT_STATIC_METHOD_CALL                                  'getTraceAsString'
          6        DO_FCALL                                      0  $2      
          7      > RETURN                                                   $2
   26     8*     > RETURN                                                   null

End of function enhancedgettraceasstring

End of class Serializable_Exception.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
249.32 ms | 1010 KiB | 18 Q