3v4l.org

run code in 300+ PHP versions simultaneously
<?php function previous_handler(Throwable $e) { printf("This is the PREVIOUS handler for %s\n", $e->getMessage()); } //------------ class Configurator { public static function setupPhpErrorListener(): void { $controller = new PhpErrorController(); $controller->usePreviousExceptionHandler(set_exception_handler([$controller, 'onException'])); } } class PhpErrorController { private $previous = null; public function usePreviousExceptionHandler(?callable $previous): void { $this->previous = $previous; } public function onException(Throwable $throwable): void { printf("This is the WONOLOG handler for %s\n", $throwable->getMessage()); if ($this->previous === null) { throw $throwable; } ($this->previous)($throwable); } } //------------ set_exception_handler('previous_handler'); Configurator::setupPhpErrorListener(); throw new Exception('Test exception');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/jme3m
function name:  (null)
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   INIT_FCALL                                               'set_exception_handler'
          1        SEND_VAL                                                 'previous_handler'
          2        DO_ICALL                                                 
   48     3        INIT_STATIC_METHOD_CALL                                  'Configurator', 'setupPhpErrorListener'
          4        DO_FCALL                                      0          
   50     5        NEW                                              $2      'Exception'
          6        SEND_VAL_EX                                              'Test+exception'
          7        DO_FCALL                                      0          
          8      > THROW                                         0          $2
          9*     > RETURN                                                   1

Function previous_handler:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jme3m
function name:  previous_handler
number of ops:  8
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'printf'
          2        SEND_VAL                                                 'This+is+the+PREVIOUS+handler+for+%25s%0A'
          3        INIT_METHOD_CALL                                         !0, 'getMessage'
          4        DO_FCALL                                      0  $1      
          5        SEND_VAR                                                 $1
          6        DO_ICALL                                                 
    6     7      > RETURN                                                   null

End of function previous_handler

Class Configurator:
Function setupphperrorlistener:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jme3m
function name:  setupPhpErrorListener
number of ops:  12
compiled vars:  !0 = $controller
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $1      'PhpErrorController'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   16     3        INIT_METHOD_CALL                                         !0, 'usePreviousExceptionHandler'
          4        INIT_FCALL                                               'set_exception_handler'
          5        INIT_ARRAY                                       ~4      !0
          6        ADD_ARRAY_ELEMENT                                ~4      'onException'
          7        SEND_VAL                                                 ~4
          8        DO_ICALL                                         $5      
          9        SEND_VAR_NO_REF_EX                                       $5
         10        DO_FCALL                                      0          
   17    11      > RETURN                                                   null

End of function setupphperrorlistener

End of class Configurator.

Class PhpErrorController:
Function usepreviousexceptionhandler:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jme3m
function name:  usePreviousExceptionHandler
number of ops:  4
compiled vars:  !0 = $previous
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
   26     1        ASSIGN_OBJ                                               'previous'
          2        OP_DATA                                                  !0
   27     3      > RETURN                                                   null

End of function usepreviousexceptionhandler

Function onexception:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jme3m
function name:  onException
number of ops:  16
compiled vars:  !0 = $throwable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   31     1        INIT_FCALL                                               'printf'
          2        SEND_VAL                                                 'This+is+the+WONOLOG+handler+for+%25s%0A'
          3        INIT_METHOD_CALL                                         !0, 'getMessage'
          4        DO_FCALL                                      0  $1      
          5        SEND_VAR                                                 $1
          6        DO_ICALL                                                 
   33     7        FETCH_OBJ_R                                      ~3      'previous'
          8        TYPE_CHECK                                    2          ~3
          9      > JMPZ                                                     ~4, ->11
   34    10    > > THROW                                         0          !0
   37    11    >   FETCH_OBJ_R                                      ~5      'previous'
         12        INIT_DYNAMIC_CALL                                        ~5
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0          
   39    15      > RETURN                                                   null

End of function onexception

End of class PhpErrorController.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.35 ms | 1432 KiB | 15 Q