3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo {} class Bar { public function firstTypeError ($passed) { $trace = debug_backtrace(); throw new TypeError(__CLASS__ . "::" . __FUNCTION__ . "(): Argument #1 (\$passed) elements must be of type " . Baz::class . ", " . get_debug_Type($passed) . " given, called in " . $trace[0]["file"] . " on line " . $trace[0]["line"]); } public function secondTypeError ($passed) { $trace = debug_backtrace(); throw new TypeError(__CLASS__ . "::" . __FUNCTION__ . "(): Argument #1 (\$passed) elements must be of type " . Baz::class . ", " . get_debug_Type($passed) . " given"); } } class Baz {} $bar = new Bar(); try { $bar->firstTypeError("test"); } catch (TypeError $e) { echo $e->__toString(); } echo "\n\n\n\n"; try { $bar->secondTypeError("test"); } catch (TypeError $e) { echo $e->__toString(); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
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 = 42) Position 1 = 20
Branch analysis from position: 20
Found catch point at position: 16
Branch analysis from position: 16
2 jumps found. (Code = 107) Position 1 = 17, Position 2 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vR4M1
function name:  (null)
number of ops:  21
compiled vars:  !0 = $bar, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   NEW                                              $2      'Bar'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   22     3        INIT_METHOD_CALL                                         !0, 'firstTypeError'
          4        SEND_VAL_EX                                              'test'
          5        DO_FCALL                                      0          
          6      > JMP                                                      ->11
   23     7  E > > CATCH                                       last         'TypeError'
   24     8    >   INIT_METHOD_CALL                                         !1, '__toString'
          9        DO_FCALL                                      0  $6      
         10        ECHO                                                     $6
   27    11    >   ECHO                                                     '%0A%0A%0A%0A'
   30    12        INIT_METHOD_CALL                                         !0, 'secondTypeError'
         13        SEND_VAL_EX                                              'test'
         14        DO_FCALL                                      0          
         15      > JMP                                                      ->20
   31    16  E > > CATCH                                       last         'TypeError'
   32    17    >   INIT_METHOD_CALL                                         !1, '__toString'
         18        DO_FCALL                                      0  $8      
         19        ECHO                                                     $8
   33    20    > > RETURN                                                   1

Class Foo: [no user functions]
Class Bar:
Function firsttypeerror:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/vR4M1
function name:  firstTypeError
number of ops:  21
compiled vars:  !0 = $passed, !1 = $trace
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        INIT_FCALL                                               'debug_backtrace'
          2        DO_ICALL                                         $2      
          3        ASSIGN                                                   !1, $2
    8     4        NEW                                              $4      'TypeError'
          5        INIT_FCALL                                               'get_debug_type'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $5      
          8        CONCAT                                           ~6      'Bar%3A%3AfirstTypeError%28%29%3A+Argument+%231+%28%24passed%29+elements+must+be+of+type+Baz%2C+', $5
          9        CONCAT                                           ~7      ~6, '+given%2C+called+in+'
         10        FETCH_DIM_R                                      ~8      !1, 0
         11        FETCH_DIM_R                                      ~9      ~8, 'file'
         12        CONCAT                                           ~10     ~7, ~9
         13        CONCAT                                           ~11     ~10, '+on+line+'
         14        FETCH_DIM_R                                      ~12     !1, 0
         15        FETCH_DIM_R                                      ~13     ~12, 'line'
         16        CONCAT                                           ~14     ~11, ~13
         17        SEND_VAL_EX                                              ~14
         18        DO_FCALL                                      0          
         19      > THROW                                         0          $4
    9    20*     > RETURN                                                   null

End of function firsttypeerror

Function secondtypeerror:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/vR4M1
function name:  secondTypeError
number of ops:  14
compiled vars:  !0 = $passed, !1 = $trace
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        INIT_FCALL                                               'debug_backtrace'
          2        DO_ICALL                                         $2      
          3        ASSIGN                                                   !1, $2
   13     4        NEW                                              $4      'TypeError'
          5        INIT_FCALL                                               'get_debug_type'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $5      
          8        CONCAT                                           ~6      'Bar%3A%3AsecondTypeError%28%29%3A+Argument+%231+%28%24passed%29+elements+must+be+of+type+Baz%2C+', $5
          9        CONCAT                                           ~7      ~6, '+given'
         10        SEND_VAL_EX                                              ~7
         11        DO_FCALL                                      0          
         12      > THROW                                         0          $4
   14    13*     > RETURN                                                   null

End of function secondtypeerror

End of class Bar.

Class Baz: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.72 ms | 1004 KiB | 15 Q