3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ExceptionHandling { private static $uncaught_exception = null; private static $fatal_error = null; public static function shutdown_callback() { if (defined('GRACEFUL_SHUTDOWN')) { // everything went fine ob_end_flush(); return; } header('Status: 500 Internal Server Error'); include(APP_PATH.'/errors/500.php'); } // turn errors into exceptions public static function exception_error_handler($errno, $errstr, $errfile, $errline) { // hhvm can report fatals as errors. We can not convert them to exceptions, however, because they will // not trigger the exception handler and the stack trace is wrong, anyway. We need to save the errfile and // errline here because they are not available in the shutdown function. // for the errno, see https://github.com/facebook/hhvm/blob/master/hphp/runtime/base/runtime-error.h#L57 if ($errno & (1 << 24)) { self::$fatal_error = array( 'message' => $errstr, 'type' => $errno, 'file' => $errfile, 'line' => $errline ); } if (error_reporting() === 0) { return false; // code used @ to suppress errors } throw new ErrorException($errstr, 0, $errno, $errfile, $errline); } public static function exception_handler($exception) { self::$uncaught_exception = $exception; } /** * @return Exception|null the exception that caused the app to crash, or null if there was none */ public static function get_uncaught_exception() { return self::$uncaught_exception; } /** * Gets the last error that has occurred, be it fatal or non-fatal * @return array with the fields message, type, file and line */ public static function get_last_error() { if (self::$fatal_error) { return self::$fatal_error; } return error_get_last(); } } register_shutdown_function(array('ExceptionHandling', 'shutdown_callback')); set_error_handler(array('ExceptionHandling', "exception_error_handler")); set_exception_handler(array('ExceptionHandling', 'exception_handler')); dklfajelkwa;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/na982
function name:  (null)
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   63     0  E >   INIT_FCALL                                               'register_shutdown_function'
          1        SEND_VAL                                                 <array>
          2        DO_ICALL                                                 
   64     3        INIT_FCALL                                               'set_error_handler'
          4        SEND_VAL                                                 <array>
          5        DO_ICALL                                                 
   65     6        INIT_FCALL                                               'set_exception_handler'
          7        SEND_VAL                                                 <array>
          8        DO_ICALL                                                 
   67     9        FETCH_CONSTANT                                   ~3      'dklfajelkwa'
         10        FREE                                                     ~3
         11      > RETURN                                                   1

Class ExceptionHandling:
Function shutdown_callback:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 5
Branch analysis from position: 2
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/na982
function name:  shutdown_callback
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   DEFINED                                                  'GRACEFUL_SHUTDOWN'
          1      > JMPZ                                                     ~0, ->5
   10     2    >   INIT_FCALL                                               'ob_end_flush'
          3        DO_ICALL                                                 
   11     4      > RETURN                                                   null
   14     5    >   INIT_FCALL                                               'header'
          6        SEND_VAL                                                 'Status%3A+500+Internal+Server+Error'
          7        DO_ICALL                                                 
   15     8        FETCH_CONSTANT                                   ~3      'APP_PATH'
          9        CONCAT                                           ~4      ~3, '%2Ferrors%2F500.php'
         10        INCLUDE_OR_EVAL                                          ~4, INCLUDE
   16    11      > RETURN                                                   null

End of function shutdown_callback

Function exception_error_handler:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 17
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 12
filename:       /in/na982
function name:  exception_error_handler
number of ops:  26
compiled vars:  !0 = $errno, !1 = $errstr, !2 = $errfile, !3 = $errline
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   25     4        BW_AND                                           ~4      !0, 16777216
          5      > JMPZ                                                     ~4, ->12
   27     6    >   INIT_ARRAY                                       ~6      !1, 'message'
   28     7        ADD_ARRAY_ELEMENT                                ~6      !0, 'type'
   29     8        ADD_ARRAY_ELEMENT                                ~6      !2, 'file'
   30     9        ADD_ARRAY_ELEMENT                                ~6      !3, 'line'
   26    10        ASSIGN_STATIC_PROP                                       'fatal_error'
   30    11        OP_DATA                                                  ~6
   34    12    >   INIT_FCALL                                               'error_reporting'
         13        DO_ICALL                                         $7      
         14        IS_IDENTICAL                                             $7, 0
         15      > JMPZ                                                     ~8, ->17
   35    16    > > RETURN                                                   <false>
   38    17    >   NEW                                              $9      'ErrorException'
         18        SEND_VAR_EX                                              !1
         19        SEND_VAL_EX                                              0
         20        SEND_VAR_EX                                              !0
         21        SEND_VAR_EX                                              !2
         22        SEND_VAR_EX                                              !3
         23        DO_FCALL                                      0          
         24      > THROW                                         0          $9
   39    25*     > RETURN                                                   null

End of function exception_error_handler

Function exception_handler:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/na982
function name:  exception_handler
number of ops:  4
compiled vars:  !0 = $exception
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   RECV                                             !0      
   42     1        ASSIGN_STATIC_PROP                                       'uncaught_exception'
          2        OP_DATA                                                  !0
   43     3      > RETURN                                                   null

End of function exception_handler

Function get_uncaught_exception:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/na982
function name:  get_uncaught_exception
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   49     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'uncaught_exception'
          1      > RETURN                                                   ~0
   50     2*     > RETURN                                                   null

End of function get_uncaught_exception

Function get_last_error:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 4
Branch analysis from position: 2
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/na982
function name:  get_last_error
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   57     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'fatal_error'
          1      > JMPZ                                                     ~0, ->4
   58     2    >   FETCH_STATIC_PROP_R          unknown             ~1      'fatal_error'
          3      > RETURN                                                   ~1
   60     4    >   INIT_FCALL                                               'error_get_last'
          5        DO_ICALL                                         $2      
          6      > RETURN                                                   $2
   61     7*     > RETURN                                                   null

End of function get_last_error

End of class ExceptionHandling.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
266.6 ms | 970 KiB | 20 Q