3v4l.org

run code in 500+ PHP versions simultaneously
<?php try { json_encode("\xB1", JSON_THROW_ON_ERROR); } catch (\Throwable $e) { echo "own throw -> ", get_class($e), ", previous: ", $e->getPrevious() ? get_class($e->getPrevious()) : 'null', "\n"; } class Boom implements JsonSerializable { public function jsonSerialize(): mixed { throw new RuntimeException('thrown inside jsonSerialize()'); } } try { json_encode(new Boom(), JSON_THROW_ON_ERROR); } catch (\Throwable $e) { echo "user throw -> ", get_class($e), ", previous: ", $e->getPrevious() ? get_class($e->getPrevious()) : 'null', "\n"; }
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 = 42) Position 1 = 45
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 5
Branch analysis from position: 5
2 jumps found. (Code = 107) Position 1 = 6, Position 2 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 18
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
Found catch point at position: 29
Branch analysis from position: 29
2 jumps found. (Code = 107) Position 1 = 30, Position 2 = -2
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 42
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CtHYH
function name:  (null)
number of ops:  46
compiled vars:  !0 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                                   'json_encode'
          1        SEND_VAL                                                     '%B1'
          2        SEND_VAL                                                     4194304
          3        DO_ICALL                                                     
          4      > JMP                                                          ->21
    5     5  E > > CATCH                                           last         'Throwable'
    7     6    >   ECHO                                                         'own+throw++-%3E+'
    8     7        GET_CLASS                                            ~2      !0
          8        ECHO                                                         ~2
    9     9        ECHO                                                         '%2C+previous%3A+'
   10    10        INIT_METHOD_CALL                                             !0, 'getPrevious'
         11        DO_FCALL                                          0  $3      
         12      > JMPZ                                                         $3, ->18
         13    >   INIT_METHOD_CALL                                             !0, 'getPrevious'
         14        DO_FCALL                                          0  $4      
         15        GET_CLASS                                            ~5      $4
         16        QM_ASSIGN                                            ~6      ~5
         17      > JMP                                                          ->19
         18    >   QM_ASSIGN                                            ~6      'null'
         19    >   ECHO                                                         ~6
   11    20        ECHO                                                         '%0A'
   14    21    >   DECLARE_CLASS                                                'boom'
   21    22        INIT_FCALL                                                   'json_encode'
         23        NEW                                                  $7      'Boom'
         24        DO_FCALL                                          0          
         25        SEND_VAR                                                     $7
         26        SEND_VAL                                                     4194304
         27        DO_ICALL                                                     
         28      > JMP                                                          ->45
   22    29  E > > CATCH                                           last         'Throwable'
   24    30    >   ECHO                                                         'user+throw+-%3E+'
   25    31        GET_CLASS                                            ~10     !0
         32        ECHO                                                         ~10
   26    33        ECHO                                                         '%2C+previous%3A+'
   27    34        INIT_METHOD_CALL                                             !0, 'getPrevious'
         35        DO_FCALL                                          0  $11     
         36      > JMPZ                                                         $11, ->42
         37    >   INIT_METHOD_CALL                                             !0, 'getPrevious'
         38        DO_FCALL                                          0  $12     
         39        GET_CLASS                                            ~13     $12
         40        QM_ASSIGN                                            ~14     ~13
         41      > JMP                                                          ->43
         42    >   QM_ASSIGN                                            ~14     'null'
         43    >   ECHO                                                         ~14
   28    44        ECHO                                                         '%0A'
   29    45    > > RETURN                                                       1

Class Boom:
Function jsonserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/CtHYH
function name:  jsonSerialize
number of ops:  6
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   16     0  E >   NEW                                                  $0      'RuntimeException'
          1        SEND_VAL_EX                                                  'thrown+inside+jsonSerialize%28%29'
          2        DO_FCALL                                          0          
          3      > THROW                                             0          $0
   17     4*       VERIFY_RETURN_TYPE                                           
          5*     > RETURN                                                       null

End of function jsonserialize

End of class Boom.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
148.95 ms | 489 KiB | 9 Q