3v4l.org

run code in 300+ PHP versions simultaneously
<?php $errorHandler = new ErrorHandler; set_error_handler([$errorHandler, 'onError']); foreach (['SORT_REGULAR', 'SORT_NUMERIC', 'SORT_STRING', 'SORT_LOCALE_STRING'] as $sort_mode) { echo $sort_mode . ' - '; try { array_unique([new stdClass, new stdClass], constant($sort_mode)); echo 'works'; if ($errors = $errorHandler->getErrors()) { echo ', but with these errors: ' . PHP_EOL; var_dump($errors); $errorHandler->flush(); } else { echo PHP_EOL; } } catch (Throwable $e) { echo 'fails with the following error:' . PHP_EOL; echo $e->getMessage() . PHP_EOL; } echo PHP_EOL; } class ErrorHandler { private $errors = []; public function onError() { $this->errors[] = func_get_args()[1]; return true; } public function flush() { $this->errors = []; } public function getErrors() { return $this->errors; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 47
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 47
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 37
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
Found catch point at position: 39
Branch analysis from position: 39
2 jumps found. (Code = 107) Position 1 = 40, Position 2 = -2
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
filename:       /in/25YR8
function name:  (null)
number of ops:  49
compiled vars:  !0 = $errorHandler, !1 = $sort_mode, !2 = $errors, !3 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $4      'ErrorHandler'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
    4     3        INIT_FCALL                                               'set_error_handler'
          4        INIT_ARRAY                                       ~7      !0
          5        ADD_ARRAY_ELEMENT                                ~7      'onError'
          6        SEND_VAL                                                 ~7
          7        DO_ICALL                                                 
    6     8      > FE_RESET_R                                       $9      <array>, ->47
          9    > > FE_FETCH_R                                               $9, !1, ->47
    7    10    >   CONCAT                                           ~10     !1, '+-+'
         11        ECHO                                                     ~10
    9    12        INIT_FCALL                                               'array_unique'
         13        NEW                                              $11     'stdClass'
         14        DO_FCALL                                      0          
         15        INIT_ARRAY                                       ~13     $11
         16        NEW                                              $14     'stdClass'
         17        DO_FCALL                                      0          
         18        ADD_ARRAY_ELEMENT                                ~13     $14
         19        SEND_VAL                                                 ~13
         20        INIT_FCALL                                               'constant'
         21        SEND_VAR                                                 !1
         22        DO_ICALL                                         $16     
         23        SEND_VAR                                                 $16
         24        DO_ICALL                                                 
   10    25        ECHO                                                     'works'
   11    26        INIT_METHOD_CALL                                         !0, 'getErrors'
         27        DO_FCALL                                      0  $18     
         28        ASSIGN                                           ~19     !2, $18
         29      > JMPZ                                                     ~19, ->37
   12    30    >   ECHO                                                     '%2C+but+with+these+errors%3A+%0A'
   13    31        INIT_FCALL                                               'var_dump'
         32        SEND_VAR                                                 !2
         33        DO_ICALL                                                 
   14    34        INIT_METHOD_CALL                                         !0, 'flush'
         35        DO_FCALL                                      0          
   11    36      > JMP                                                      ->38
   16    37    >   ECHO                                                     '%0A'
         38    > > JMP                                                      ->45
   18    39  E > > CATCH                                       last         'Throwable'
   19    40    >   ECHO                                                     'fails+with+the+following+error%3A%0A'
   20    41        INIT_METHOD_CALL                                         !3, 'getMessage'
         42        DO_FCALL                                      0  $22     
         43        CONCAT                                           ~23     $22, '%0A'
         44        ECHO                                                     ~23
   22    45    >   ECHO                                                     '%0A'
    6    46      > JMP                                                      ->9
         47    >   FE_FREE                                                  $9
   30    48      > RETURN                                                   1

Class ErrorHandler:
Function onerror:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/25YR8
function name:  onError
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   FUNC_GET_ARGS                                    ~2      
          1        FETCH_DIM_R                                      ~3      ~2, 1
          2        FETCH_OBJ_W                                      $0      'errors'
          3        ASSIGN_DIM                                               $0
          4        OP_DATA                                                  ~3
          5      > RETURN                                                   <true>
          6*     > RETURN                                                   null

End of function onerror

Function flush:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/25YR8
function name:  flush
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   ASSIGN_OBJ                                               'errors'
          1        OP_DATA                                                  <array>
          2      > RETURN                                                   null

End of function flush

Function geterrors:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/25YR8
function name:  getErrors
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   FETCH_OBJ_R                                      ~0      'errors'
          1      > RETURN                                                   ~0
          2*     > RETURN                                                   null

End of function geterrors

End of class ErrorHandler.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.01 ms | 1018 KiB | 17 Q