3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ExecutionFailureBuilder { public function build(\Throwable $execption): ExecutionFailureInterface { } public static function flattenExceptionBacktrace(\Throwable $throwable) { $flatten = function(&$value, $key) { if ($value instanceof \Closure) { $closureReflection = new \ReflectionFunction($value); $value = sprintf( '(Closure at %s:%s)', $closureReflection->getFileName(), $closureReflection->getStartLine() ); } elseif (is_object($value)) { $value = sprintf('object(%s)', get_class($value)); } elseif (is_resource($value)) { $value = sprintf('resource(%s)', get_resource_type($value)); } }; do { $trace = $throwable->getTrace(); foreach ($trace as &$call) { array_walk_recursive($call['args'], $flatten); } var_dump($trace); } while($throwable = $throwable->getPrevious()); } } $a = function($b, string $c) { try { throw new Exception(); } catch (Exception $e) { ExecutionFailureBuilder::flattenExceptionBacktrace($e); } }; $b = new class(4, 'rfvtgb') { public function __construct($b, string $c) { try { throw new Exception(); } catch (Exception $e) { ExecutionFailureBuilder::flattenExceptionBacktrace($e); } } }; class Testing { public static function test($b, string $c) { try { throw new Exception(); } catch (Exception $e) { ExecutionFailureBuilder::flattenExceptionBacktrace($e); } } }; $a(3, 'RTYuio', new \stdClass, []); Testing::test(5, 'rfv');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6a5H4
function name:  (null)
number of ops:  21
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F6a5H4%3A38%241'
          1        ASSIGN                                                   !0, ~2
   46     2        DECLARE_ANON_CLASS                               <unknown> 
          3        NEW                                              $5      $4
          4        SEND_VAL_EX                                              4
          5        SEND_VAL_EX                                              'rfvtgb'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $5
   69     8        INIT_DYNAMIC_CALL                                        !0
          9        SEND_VAL_EX                                              3
         10        SEND_VAL_EX                                              'RTYuio'
         11        NEW                                              $8      'stdClass'
         12        DO_FCALL                                      0          
         13        SEND_VAR_NO_REF_EX                                       $8
         14        SEND_VAL_EX                                              <array>
         15        DO_FCALL                                      0          
   70    16        INIT_STATIC_METHOD_CALL                                  'Testing', 'test'
         17        SEND_VAL                                                 5
         18        SEND_VAL                                                 'rfv'
         19        DO_FCALL                                      0          
         20      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F6a5H4%3A13%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 19
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 28
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 38
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
filename:       /in/6a5H4
function name:  {closure}
number of ops:  39
compiled vars:  !0 = $value, !1 = $key, !2 = $closureReflection
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        INSTANCEOF                                               !0, 'Closure'
          3      > JMPZ                                                     ~3, ->19
   15     4    >   NEW                                              $4      'ReflectionFunction'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !2, $4
   16     8        INIT_FCALL                                               'sprintf'
   17     9        SEND_VAL                                                 '%28Closure+at+%25s%3A%25s%29'
   18    10        INIT_METHOD_CALL                                         !2, 'getFileName'
         11        DO_FCALL                                      0  $7      
         12        SEND_VAR                                                 $7
   19    13        INIT_METHOD_CALL                                         !2, 'getStartLine'
         14        DO_FCALL                                      0  $8      
         15        SEND_VAR                                                 $8
         16        DO_ICALL                                         $9      
   16    17        ASSIGN                                                   !0, $9
         18      > JMP                                                      ->38
   21    19    >   TYPE_CHECK                                  256          !0
         20      > JMPZ                                                     ~11, ->28
   22    21    >   INIT_FCALL                                               'sprintf'
         22        SEND_VAL                                                 'object%28%25s%29'
         23        GET_CLASS                                        ~12     !0
         24        SEND_VAL                                                 ~12
         25        DO_ICALL                                         $13     
         26        ASSIGN                                                   !0, $13
         27      > JMP                                                      ->38
   23    28    >   TYPE_CHECK                                  512          !0
         29      > JMPZ                                                     ~15, ->38
   24    30    >   INIT_FCALL                                               'sprintf'
         31        SEND_VAL                                                 'resource%28%25s%29'
         32        INIT_FCALL                                               'get_resource_type'
         33        SEND_VAR                                                 !0
         34        DO_ICALL                                         $16     
         35        SEND_VAR                                                 $16
         36        DO_ICALL                                         $17     
         37        ASSIGN                                                   !0, $17
   26    38    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F6a5H4%3A13%240

Function %00%7Bclosure%7D%2Fin%2F6a5H4%3A38%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
Found catch point at position: 6
Branch analysis from position: 6
2 jumps found. (Code = 107) Position 1 = 7, Position 2 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6a5H4
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $b, !1 = $c, !2 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   40     2        NEW                                              $3      'Exception'
          3        DO_FCALL                                      0          
          4      > THROW                                         0          $3
          5*       JMP                                                      ->10
   41     6  E > > CATCH                                       last         'Exception'
   42     7    >   INIT_STATIC_METHOD_CALL                                  'ExecutionFailureBuilder', 'flattenExceptionBacktrace'
          8        SEND_VAR                                                 !2
          9        DO_FCALL                                      0          
   44    10      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F6a5H4%3A38%241

Class ExecutionFailureBuilder:
Function build:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6a5H4
function name:  build
number of ops:  3
compiled vars:  !0 = $execption
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    9     1        VERIFY_RETURN_TYPE                                       
          2      > RETURN                                                   null

End of function build

Function flattenexceptionbacktrace:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
2 jumps found. (Code = 126) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 3
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
Branch analysis from position: 14
filename:       /in/6a5H4
function name:  flattenExceptionBacktrace
number of ops:  23
compiled vars:  !0 = $throwable, !1 = $flatten, !2 = $trace, !3 = $call
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   13     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F6a5H4%3A13%240'
          2        ASSIGN                                                   !1, ~4
   29     3    >   INIT_METHOD_CALL                                         !0, 'getTrace'
          4        DO_FCALL                                      0  $6      
          5        ASSIGN                                                   !2, $6
   30     6      > FE_RESET_RW                                      $8      !2, ->14
          7    > > FE_FETCH_RW                                              $8, !3, ->14
   31     8    >   INIT_FCALL                                               'array_walk_recursive'
          9        FETCH_DIM_W                                      $9      !3, 'args'
         10        SEND_REF                                                 $9
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                                 
   30    13      > JMP                                                      ->7
         14    >   FE_FREE                                                  $8
   33    15        INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                                 
   34    18        INIT_METHOD_CALL                                         !0, 'getPrevious'
         19        DO_FCALL                                      0  $12     
         20        ASSIGN                                           ~13     !0, $12
         21      > JMPNZ                                                    ~13, ->3
   35    22    > > RETURN                                                   null

End of function flattenexceptionbacktrace

End of class ExecutionFailureBuilder.

Class class@anonymous:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
Found catch point at position: 6
Branch analysis from position: 6
2 jumps found. (Code = 107) Position 1 = 7, Position 2 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6a5H4
function name:  __construct
number of ops:  11
compiled vars:  !0 = $b, !1 = $c, !2 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   50     2        NEW                                              $3      'Exception'
          3        DO_FCALL                                      0          
          4      > THROW                                         0          $3
          5*       JMP                                                      ->10
   51     6  E > > CATCH                                       last         'Exception'
   52     7    >   INIT_STATIC_METHOD_CALL                                  'ExecutionFailureBuilder', 'flattenExceptionBacktrace'
          8        SEND_VAR                                                 !2
          9        DO_FCALL                                      0          
   54    10      > RETURN                                                   null

End of function __construct

End of class class@anonymous.

Class Testing:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
Found catch point at position: 6
Branch analysis from position: 6
2 jumps found. (Code = 107) Position 1 = 7, Position 2 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6a5H4
function name:  test
number of ops:  11
compiled vars:  !0 = $b, !1 = $c, !2 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   59     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   62     2        NEW                                              $3      'Exception'
          3        DO_FCALL                                      0          
          4      > THROW                                         0          $3
          5*       JMP                                                      ->10
   63     6  E > > CATCH                                       last         'Exception'
   64     7    >   INIT_STATIC_METHOD_CALL                                  'ExecutionFailureBuilder', 'flattenExceptionBacktrace'
          8        SEND_VAR                                                 !2
          9        DO_FCALL                                      0          
   66    10      > RETURN                                                   null

End of function test

End of class Testing.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
183.04 ms | 1408 KiB | 21 Q