3v4l.org

run code in 500+ PHP versions simultaneously
<?php function setPrevious(Throwable $e, Throwable $previous): Throwable { return (function () use ($e, $previous) { $e->previous = $previous; return $e; })->call($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/4scuq
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
-----------------------------------------------------------------------------------------
   19     0  E >   NEW                                                  $4      'SimpleException'
          1        SEND_VAL_EX                                                  'A'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $4
   20     4        NEW                                                  $7      'SimpleException'
          5        SEND_VAL_EX                                                  'B'
          6        DO_FCALL                                          0          
          7        ASSIGN                                                       !1, $7
   21     8        NEW                                                  $10     'SimpleException'
          9        SEND_VAL_EX                                                  'C'
         10        DO_FCALL                                          0          
         11        ASSIGN                                                       !2, $10
   23    12        INIT_FCALL                                                   'setprevious'
         13        SEND_VAR                                                     !0
         14        SEND_VAR                                                     !1
         15        DO_FCALL                                          0          
   24    16        INIT_FCALL                                                   'setprevious'
         17        SEND_VAR                                                     !0
         18        SEND_VAR                                                     !2
         19        DO_FCALL                                          0          
   26    20        ASSIGN                                                       !3, !0
   28    21    >   INIT_FCALL                                                   'var_dump'
         22        INIT_METHOD_CALL                                             !3, 'getMessage'
         23        DO_FCALL                                          0  $16     
         24        SEND_VAR                                                     $16
         25        DO_ICALL                                                     
   29    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/4scuq
function name:  setPrevious
number of ops:  12
compiled vars:  !0 = $e, !1 = $previous
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    5     2        DECLARE_LAMBDA_FUNCTION                              ~2      [0]
          3        BIND_LEXICAL                                                 ~2, !0
          4        BIND_LEXICAL                                                 ~2, !1
    8     5        INIT_METHOD_CALL                                             ~2, 'call'
          6        SEND_VAR_EX                                                  !0
          7        DO_FCALL                                          0  $3      
          8        VERIFY_RETURN_TYPE                                           $3
          9      > RETURN                                                       $3
    9    10*       VERIFY_RETURN_TYPE                                           
         11*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4scuq
function name:  {closure:setPrevious():5}
number of ops:  6
compiled vars:  !0 = $e, !1 = $previous
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   BIND_STATIC                                                  !0
          1        BIND_STATIC                                                  !1
    6     2        ASSIGN_OBJ                                                   !0, 'previous'
          3        OP_DATA                                                      !1
    7     4      > RETURN                                                       !0
    8     5*     > RETURN                                                       null

End of Dynamic Function 0

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/4scuq
function name:  __construct
number of ops:  5
compiled vars:  !0 = $message
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   RECV                                                 !0      
   15     1        INIT_STATIC_METHOD_CALL                                      
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0          
   16     4      > RETURN                                                       null

End of function __construct

End of class SimpleException.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
147.06 ms | 2066 KiB | 16 Q