3v4l.org

run code in 500+ PHP versions simultaneously
<?php /* * php error handler / suppressed deprecation notices * @link https://stackoverflow.com/a/74791189/367456 */ // don't have E_DEPRECATED in reporting on @3v4l.org error_reporting(error_reporting() ^ E_DEPRECATED); // no interest in arguments ini_set('zend.exception_ignore_args', '1'); /* track */ new Deprecations; $mixed = null; $string = @trim($mixed); $html = @htmlspecialchars($mixed, ENT_QUOTES | ENT_HTML5); $forgotten = trim($mixed); class Deprecations { public function __construct($handler = true, $reporter = true) { $reporter && register_shutdown_function(static function () use (&$deprecations) { // stream collected deprecations as JavaScript Object Notation (JSON) Text Sequences on the SAPI diagnostic channel // shutdown handling could condense repeated reports etc. as could the error handler. example material, there must // be no shutdown function at all. foreach ((array)$deprecations as $deprecation) { $error = $deprecation['error']; unset($deprecation['error']); is_object($error) && get_class($error) === ErrorException::class && $error = eval('return ' . substr(ltrim(var_export($error, true), '\\'), 27) . ';'); error_log("\x1E" . json_encode( ['E_DEPRECATED', [...array_values($deprecation), $error['trace'] ?? null]], JSON_UNESCAPED_SLASHES )); } error_log("\x1E"); }); $handler && set_error_handler(static function ($type, $message, $file, $line) use (&$deprecations) { // capture the currently active error reporting level to decide whether // reporting is active (throws) or not (standard PHP error handler) $reporting = error_reporting(); // capture backtraces, your mileage may vary: with many of them, // you may not be interested in the beginning (resource constraints!). $error = new ErrorException($message, $type, $reporting, $file, $line); // capture E_DEPRECATED if ($type === E_DEPRECATED) { $deprecations[] = ['deprecations' => count($deprecations ?: [])] + get_defined_vars(); } if (!($reporting & $type)) { // This error code is not included in error_reporting, so let it fall // through to the standard PHP error handler return false; } // throwing error handler, your mileage may vary, controlled by // error_reporting() / error_reporting (ini) throw $error; }, E_DEPRECATED); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FYhhM
function name:  (null)
number of ops:  28
compiled vars:  !0 = $mixed, !1 = $string, !2 = $html, !3 = $forgotten
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                                   'error_reporting'
          1        INIT_FCALL                                                   'error_reporting'
          2        DO_ICALL                                             $4      
          3        BW_XOR                                               ~5      $4, 8192
          4        SEND_VAL                                                     ~5
          5        DO_ICALL                                                     
   11     6        INIT_FCALL                                                   'ini_set'
          7        SEND_VAL                                                     'zend.exception_ignore_args'
          8        SEND_VAL                                                     '1'
          9        DO_ICALL                                                     
   13    10        NEW                                                  $8      'Deprecations'
         11        DO_FCALL                                          0          
         12        FREE                                                         $8
   15    13        ASSIGN                                                       !0, null
   16    14        BEGIN_SILENCE                                        ~11     
         15        FRAMELESS_ICALL_1                trim                ~12     !0
         16        END_SILENCE                                                  ~11
         17        ASSIGN                                                       !1, ~12
   17    18        BEGIN_SILENCE                                        ~14     
         19        INIT_FCALL                                                   'htmlspecialchars'
         20        SEND_VAR                                                     !0
         21        SEND_VAL                                                     51
         22        DO_ICALL                                             $15     
         23        END_SILENCE                                                  ~14
         24        ASSIGN                                                       !2, $15
   19    25        FRAMELESS_ICALL_1                trim                ~17     !0
         26        ASSIGN                                                       !3, ~17
   71    27      > RETURN                                                       1

Class Deprecations:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
2 jumps found. (Code = 46) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
Branch analysis from position: 9
filename:       /in/FYhhM
function name:  __construct
number of ops:  18
compiled vars:  !0 = $handler, !1 = $reporter, !2 = $deprecations
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   24     0  E >   RECV_INIT                                            !0      <true>
          1        RECV_INIT                                            !1      <true>
   26     2      > JMPZ_EX                                              ~3      !1, ->9
          3    >   INIT_FCALL                                                   'register_shutdown_function'
          4        DECLARE_LAMBDA_FUNCTION                              ~4      [0]
          5        BIND_LEXICAL                                                 ~4, !2
   42     6        SEND_VAL                                                     ~4
   26     7        DO_ICALL                                             $5      
   42     8        BOOL                                                 ~3      $5
   44     9    > > JMPZ_EX                                              ~6      !0, ->17
         10    >   INIT_FCALL                                                   'set_error_handler'
         11        DECLARE_LAMBDA_FUNCTION                              ~7      [1]
         12        BIND_LEXICAL                                                 ~7, !2
   69    13        SEND_VAL                                                     ~7
         14        SEND_VAL                                                     8192
   44    15        DO_ICALL                                             $8      
   69    16        BOOL                                                 ~6      $8
   70    17    > > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 47
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 47
Branch analysis from position: 4
2 jumps found. (Code = 46) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
2 jumps found. (Code = 46) Position 1 = 13, Position 2 = 27
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 27
Branch analysis from position: 12
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
filename:       /in/FYhhM
function name:  {closure:Deprecations::__construct():26}
number of ops:  52
compiled vars:  !0 = $deprecations, !1 = $deprecation, !2 = $error
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   26     0  E >   BIND_STATIC                                                  !0
   30     1        CAST                                              7  ~3      !0
          2      > FE_RESET_R                                           $4      ~3, ->47
          3    > > FE_FETCH_R                                                   $4, !1, ->47
   31     4    >   FETCH_DIM_R                                          ~5      !1, 'error'
          5        ASSIGN                                                       !2, ~5
   32     6        UNSET_DIM                                                    !1, 'error'
   33     7        TYPE_CHECK                                      256  ~7      !2
          8      > JMPZ_EX                                              ~7      ~7, ->12
   34     9    >   GET_CLASS                                            ~8      !2
         10        IS_IDENTICAL                                         ~9      ~8, 'ErrorException'
         11        BOOL                                                 ~7      ~9
         12    > > JMPZ_EX                                              ~7      ~7, ->27
   35    13    >   INIT_FCALL                                                   'ltrim'
         14        INIT_FCALL                                                   'var_export'
         15        SEND_VAR                                                     !2
         16        SEND_VAL                                                     <true>
         17        DO_ICALL                                             $10     
         18        SEND_VAR                                                     $10
         19        SEND_VAL                                                     '%5C'
         20        DO_ICALL                                             $11     
         21        FRAMELESS_ICALL_2                substr              ~12     $11, 27
         22        CONCAT                                               ~13     'return+', ~12
         23        CONCAT                                               ~14     ~13, '%3B'
         24        INCLUDE_OR_EVAL                                      $15     ~14, EVAL
         25        ASSIGN                                               ~16     !2, $15
         26        BOOL                                                 ~7      ~16
   36    27    >   INIT_FCALL                                                   'error_log'
         28        INIT_FCALL                                                   'json_encode'
   37    29        INIT_ARRAY                                           ~17     'E_DEPRECATED'
         30        INIT_FCALL                                                   'array_values'
         31        SEND_VAR                                                     !1
         32        DO_ICALL                                             $18     
         33        INIT_ARRAY                                           ~19     
         34        ADD_ARRAY_UNPACK                                     ~19     $18
         35        FETCH_DIM_IS                                         ~20     !2, 'trace'
         36        COALESCE                                             ~21     ~20
         37        QM_ASSIGN                                            ~21     null
         38        ADD_ARRAY_ELEMENT                                    ~19     ~21
         39        ADD_ARRAY_ELEMENT                                    ~17     ~19
         40        SEND_VAL                                                     ~17
   38    41        SEND_VAL                                                     64
   36    42        DO_ICALL                                             $22     
   38    43        CONCAT                                               ~23     '%1E', $22
         44        SEND_VAL                                                     ~23
   36    45        DO_ICALL                                                     
   30    46      > JMP                                                          ->3
         47    >   FE_FREE                                                      $4
   41    48        INIT_FCALL                                                   'error_log'
         49        SEND_VAL                                                     '%1E'
         50        DO_ICALL                                                     
   42    51      > RETURN                                                       null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 27
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 31
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 27
filename:       /in/FYhhM
function name:  {closure:Deprecations::__construct():44}
number of ops:  33
compiled vars:  !0 = $type, !1 = $message, !2 = $file, !3 = $line, !4 = $deprecations, !5 = $reporting, !6 = $error
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   44     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
          3        RECV                                                 !3      
          4        BIND_STATIC                                                  !4
   47     5        INIT_FCALL                                                   'error_reporting'
          6        DO_ICALL                                             $7      
          7        ASSIGN                                                       !5, $7
   51     8        NEW                                                  $9      'ErrorException'
          9        SEND_VAR_EX                                                  !1
         10        SEND_VAR_EX                                                  !0
         11        SEND_VAR_EX                                                  !5
         12        SEND_VAR_EX                                                  !2
         13        SEND_VAR_EX                                                  !3
         14        DO_FCALL                                          0          
         15        ASSIGN                                                       !6, $9
   54    16        IS_IDENTICAL                                                 !0, 8192
         17      > JMPZ                                                         ~12, ->27
   56    18    >   JMP_SET                                              ~14     !4, ->20
         19        QM_ASSIGN                                            ~14     <array>
         20        COUNT                                                ~15     ~14
         21        INIT_ARRAY                                           ~16     ~15, 'deprecations'
   57    22        INIT_FCALL                                                   'get_defined_vars'
         23        DO_ICALL                                             $17     
         24        ADD                                                  ~18     ~16, $17
   55    25        ASSIGN_DIM                                                   !4
   57    26        OP_DATA                                                      ~18
   60    27    >   BW_AND                                               ~19     !5, !0
         28        BOOL_NOT                                             ~20     ~19
         29      > JMPZ                                                         ~20, ->31
   63    30    > > RETURN                                                       <false>
   68    31    > > THROW                                             0          !6
   69    32*     > RETURN                                                       null

End of Dynamic Function 1

End of function __construct

End of class Deprecations.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
183.43 ms | 1823 KiB | 24 Q