3v4l.org

run code in 300+ 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:  32
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        INIT_FCALL                                               'trim'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $12     
         18        END_SILENCE                                              ~11
         19        ASSIGN                                                   !1, $12
   17    20        BEGIN_SILENCE                                    ~14     
         21        INIT_FCALL                                               'htmlspecialchars'
         22        SEND_VAR                                                 !0
         23        SEND_VAL                                                 51
         24        DO_ICALL                                         $15     
         25        END_SILENCE                                              ~14
         26        ASSIGN                                                   !2, $15
   19    27        INIT_FCALL                                               'trim'
         28        SEND_VAR                                                 !0
         29        DO_ICALL                                         $17     
         30        ASSIGN                                                   !3, $17
   71    31      > 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 = 50
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 50
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 = 30
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 30
Branch analysis from position: 12
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
filename:       /in/FYhhM
function name:  {closure}
number of ops:  55
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, ->50
          3    > > FE_FETCH_R                                               $4, !1, ->50
   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, ->30
   35    13    >   INIT_FCALL                                               'substr'
         14        INIT_FCALL                                               'ltrim'
         15        INIT_FCALL                                               'var_export'
         16        SEND_VAR                                                 !2
         17        SEND_VAL                                                 <true>
         18        DO_ICALL                                         $10     
         19        SEND_VAR                                                 $10
         20        SEND_VAL                                                 '%5C'
         21        DO_ICALL                                         $11     
         22        SEND_VAR                                                 $11
         23        SEND_VAL                                                 27
         24        DO_ICALL                                         $12     
         25        CONCAT                                           ~13     'return+', $12
         26        CONCAT                                           ~14     ~13, '%3B'
         27        INCLUDE_OR_EVAL                                  $15     ~14, EVAL
         28        ASSIGN                                           ~16     !2, $15
         29        BOOL                                             ~7      ~16
   36    30    >   INIT_FCALL                                               'error_log'
         31        INIT_FCALL                                               'json_encode'
   37    32        INIT_ARRAY                                       ~17     'E_DEPRECATED'
         33        INIT_FCALL                                               'array_values'
         34        SEND_VAR                                                 !1
         35        DO_ICALL                                         $18     
         36        INIT_ARRAY                                       ~19     
         37        ADD_ARRAY_UNPACK                                 ~19     $18
         38        FETCH_DIM_IS                                     ~20     !2, 'trace'
         39        COALESCE                                         ~21     ~20
         40        QM_ASSIGN                                        ~21     null
         41        ADD_ARRAY_ELEMENT                                ~19     ~21
         42        ADD_ARRAY_ELEMENT                                ~17     ~19
         43        SEND_VAL                                                 ~17
   38    44        SEND_VAL                                                 64
   36    45        DO_ICALL                                         $22     
   38    46        CONCAT                                           ~23     '%1E', $22
         47        SEND_VAL                                                 ~23
   36    48        DO_ICALL                                                 
   30    49      > JMP                                                      ->3
         50    >   FE_FREE                                                  $4
   41    51        INIT_FCALL                                               'error_log'
         52        SEND_VAL                                                 '%1E'
         53        DO_ICALL                                                 
   42    54      > 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}
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.0.0


preferences:
163.11 ms | 1480 KiB | 26 Q