3v4l.org

run code in 500+ PHP versions simultaneously
<?php function setPrevious(Throwable $e, Throwable $previous): Throwable { $reflection = new ReflectionClass($e); $prop = $reflection->getProperty('previous'); $prop->setAccessible(true); $prop->setValue($e, $previous); return $e; } class SimpleException extends Exception { public function __construct($message) { parent::__construct($message); } } $a = new SimpleException('A'); $b = new SimpleException('B'); $c = new SimpleException('C'); setPrevious($a, $b); setPrevious($a, $c); $e = $a; do { var_dump($e->getMessage()); } while ($e = $e->getPrevious());
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 21
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/0ct5l
function name:  (null)
number of ops:  31
compiled vars:  !0 = $a, !1 = $b, !2 = $c, !3 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   NEW                                                  $4      'SimpleException'
          1        SEND_VAL_EX                                                  'A'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $4
   21     4        NEW                                                  $7      'SimpleException'
          5        SEND_VAL_EX                                                  'B'
          6        DO_FCALL                                          0          
          7        ASSIGN                                                       !1, $7
   22     8        NEW                                                  $10     'SimpleException'
          9        SEND_VAL_EX                                                  'C'
         10        DO_FCALL                                          0          
         11        ASSIGN                                                       !2, $10
   24    12        INIT_FCALL                                                   'setprevious'
         13        SEND_VAR                                                     !0
         14        SEND_VAR                                                     !1
         15        DO_FCALL                                          0          
   25    16        INIT_FCALL                                                   'setprevious'
         17        SEND_VAR                                                     !0
         18        SEND_VAR                                                     !2
         19        DO_FCALL                                          0          
   27    20        ASSIGN                                                       !3, !0
   29    21    >   INIT_FCALL                                                   'var_dump'
         22        INIT_METHOD_CALL                                             !3, 'getMessage'
         23        DO_FCALL                                          0  $16     
         24        SEND_VAR                                                     $16
         25        DO_ICALL                                                     
   30    26        INIT_METHOD_CALL                                             !3, 'getPrevious'
         27        DO_FCALL                                          0  $18     
         28        ASSIGN                                               ~19     !3, $18
         29      > JMPNZ                                                        ~19, ->21
         30    > > RETURN                                                       1

Function setprevious:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0ct5l
function name:  setPrevious
number of ops:  21
compiled vars:  !0 = $e, !1 = $previous, !2 = $reflection, !3 = $prop
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    5     2        NEW                                                  $4      'ReflectionClass'
          3        SEND_VAR_EX                                                  !0
          4        DO_FCALL                                          0          
          5        ASSIGN                                                       !2, $4
    6     6        INIT_METHOD_CALL                                             !2, 'getProperty'
          7        SEND_VAL_EX                                                  'previous'
          8        DO_FCALL                                          0  $7      
          9        ASSIGN                                                       !3, $7
    7    10        INIT_METHOD_CALL                                             !3, 'setAccessible'
         11        SEND_VAL_EX                                                  <true>
         12        DO_FCALL                                          0          
    8    13        INIT_METHOD_CALL                                             !3, 'setValue'
         14        SEND_VAR_EX                                                  !0
         15        SEND_VAR_EX                                                  !1
         16        DO_FCALL                                          0          
    9    17        VERIFY_RETURN_TYPE                                           !0
         18      > RETURN                                                       !0
   10    19*       VERIFY_RETURN_TYPE                                           
         20*     > RETURN                                                       null

End of function setprevious

Class SimpleException:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0ct5l
function name:  __construct
number of ops:  5
compiled vars:  !0 = $message
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
   16     1        INIT_STATIC_METHOD_CALL                                      
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0          
   17     4      > RETURN                                                       null

End of function __construct

End of class SimpleException.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
220.49 ms | 2127 KiB | 16 Q