3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ErrorHandler { /*** The core: how to redact only sensitive parts *** ****************************************************/ // Redacting values happens either per key in an array element or name in an object property... public static $sMatchIndex= '#pass|time#i'; // ...or per function name. Both are PCRE patterns to match just any text. public static $sMatchFunction= '#connect$|login#i'; // Should every STRING data type be hidden? This is set anew per iterated stack trace function. private static $bRedactAllStrings= FALSE; // Handle a variable as per its data type, so an array or an object is recursively checked against // STRINGs, too. Side effect: make STRINGs look like literals. This method should be used on: // - every array element value, // - every object property value, // - optionally on every array element key (to later distinguish numeric indexes from textual). public static function as_per_type ( $vValue // Variable of any data type. , &$sType // Recognized data type; is needed later, too. , $vKey= '' // Potential array index to test for password-like name. ) { $sType= gettype( $vValue ); switch( $sType ) { case 'array': // Each key and value can have different data types. return self:: recurse_array( $vValue ); case 'object': // Each property can have different data types. return self:: recurse_object( $vValue ); case 'string': // Either all STRING values should be redacted, or the key has a name hinting for a password. if( self:: $bRedactAllStrings ) { return '**REDACTED_PER_FUNCTION**'; } else if( $vKey&& preg_match( self:: $sMatchIndex, $vKey ) ) { return '**REDACTED_PER_INDEX**'; } else return "'$vValue'"; // Original text, but as literal. default: // BOOLEAN, INTEGER, DOUBLE, RESOURCE, NULL and others: won't have passwords. return $vValue; } } // Handle a class instance's properties as per their data types, which can be arrays or objects again. public static function recurse_object ( $oInput // Object with any properties. ) { $aObj= get_object_vars( $oInput ); // Get all property names as array. $aOutput= array(); foreach( $aObj as $iObj=> $vObj ) { $vValue= self:: as_per_type( $oInput-> $iObj, $sType, $iObj ); $aOutput["$iObj ($sType)"]= $vValue; // Array key hints at value data type. } return $aOutput; } // Handle all array elements as per their data types, which can be objects or arrays again. public static function recurse_array ( $aInput // Array with any elements. ) { $aOutput= array(); foreach( $aInput as $iKey=> $vValue ) { $sKey= self:: as_per_type( $iKey, $sTypeKey ); // Element keys need no redaction... $sValue= self:: as_per_type( $vValue, $sTypeValue, $iKey ); // ...but values do. // Objects are converted to arrays by us, loosing the information of which class they were. // So we append the class name to the type hint in the array element key. if( $sTypeValue== 'object' ) $sTypeValue.= ' '. get_class( $vValue ); $aOutput["$sKey ($sTypeValue)"]= $sValue; // Array key hints at value data type. } return $aOutput; } // Parse the stack trace to redact potentially sensitive texts. public static function redact_backtrace ( $aTrace // Stack trace array to be parsed. ) { foreach( $aTrace as $iFunc=> $aFunc ) { self:: $bRedactAllStrings= FALSE; // Yet this is no sensitive function being called. // If this is a class instance we only need to redact by property name. if( isset( $aFunc['object'] ) ) { $aTrace[$iFunc]['object']= self:: recurse_object( $aTrace[$iFunc]['object'] ); } // Should the function's name match we'll recursively redact ANY string. if( isset( $aFunc['function'] ) ) { self:: $bRedactAllStrings= preg_match( self:: $sMatchFunction, $aFunc['function'] ); } // Now parse all parameters to potentially redact chosen ones. if( isset( $aFunc['args'] ) ) { $aTrace[$iFunc]['args']= self:: recurse_array( $aTrace[$iFunc]['args'] ); } } return $aTrace; } /*** Functional example: seeing the redacted data *** ****************************************************/ // Write log messages to wherever we want to. private static $bHeadersSent= FALSE; public static function err_log ( $aLog // Array to be saved. ) { if( !self:: $bHeadersSent ) { header( 'content-type: text/plain' ); // Don't let browser interpret output as HTML, preserve spaces. self:: $bHeadersSent= TRUE; // Only send header once. } print_r( $aLog ); // Imagine this being our log file. } /*** Demo: actually handling errors to get stack traces *** **********************************************************/ // Handler for uncaught errors. public static function err_handler ( $iError // See https://www.php.net/manual/en/errorfunc.constants.php , $sText // Error message. , $sFile // PHP file which was parsed. , $iLine // Line of error in PHP file. ) { // First one is this function, and we won't need this ever $aTrace= debug_backtrace(); unset( $aTrace[0] ); self:: err_log ( array ( 'where' => 'Error handler' , 'file' => $sFile , 'line' => $iLine , 'code' => $iError , 'msg' => $sText , 'trace' => self:: redact_backtrace( $aTrace ) ) ); } // Handler for uncaught exceptions. public static function exc_handler ( $e // Exception ) { self:: err_log ( array ( 'where' => 'Exception handler' , 'file' => $e-> getFile() , 'line' => $e-> getLine() , 'code' => $e-> getCode() , 'msg' => $e-> getMessage() , 'trace' => self:: redact_backtrace( $e-> getTrace() ) , 'class' => get_class( $e ) ) ); } } // For register_shutdown_function() a stack trace is not available. set_error_handler ( array( 'ErrorHandler', 'err_handler' ), E_ALL ); set_exception_handler ( array( 'ErrorHandler', 'exc_handler' ) ); /*** Demo: creating errors *** *****************************/ class Example { public $iNumber = 12345; // Integers won't be redacted. public $sPassword = 'secret'; // The property name should hint at a password. public $sInfo = 'a password?'; // No chance to identify this as password. public function login( $sUser, $sPass ) { echo( array() ); // Notice: Array to string conversion. } public function test( $a, $b ) { $this-> login( 'username', 'password' ); // Deeper nesting, recognition by function name. unset( $a['obj'] ); // Seeing the object once is enough for demonstration purposes. 1/ 0; // Error: Division by zero. 1+ $x; // Error: Undefined variable. throw new Exception( 'TestException' ); // Unhandled exception. } } // Building a rather complex parameter, using as many data types as possible. $aFirst= array ( 'string' => 'Text' , 'int' => 42 , 'float' => 3.1415 , 'bool' => TRUE , 'array' => array ( 'key' => 'value' , 'db_password' => 'adminadmin' // Array in array: should be redacted as per key text. ) , 'obj' => new DateTime // So we get an actual class instance. , 'pass' => '12345' // Should be redacted as per key text. , 110 => 'ordinal index' ); // Simple parameter: array with ordinal indexes only. $aSecond= array ( 'no index identifying a password' , 'username' ); // Outcome: // WHERE | REDACTION // --------------------------------|---------- // Example-> login() | // - $oTest-> sPassword | Index // - $sUser (1st function param) | Function // - $sPass (2nd function param) | Function // Example-> test() | // - $oTest-> sPassword | Index // - $a['array']['db_password'] | Index // - $a['obj']-> timezone | Index // - $a['pass'] | Index $oTest= new Example; $oTest-> test( $aFirst, $aSecond );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fKQAc
function name:  (null)
number of ops:  27
compiled vars:  !0 = $aFirst, !1 = $aSecond, !2 = $oTest
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  173     0  E >   INIT_FCALL                                               'set_error_handler'
          1        SEND_VAL                                                 <array>
          2        SEND_VAL                                                 32767
          3        DO_ICALL                                                 
  174     4        INIT_FCALL                                               'set_exception_handler'
          5        SEND_VAL                                                 <array>
          6        DO_ICALL                                                 
  204     7        INIT_ARRAY                                       ~5      'Text', 'string'
  205     8        ADD_ARRAY_ELEMENT                                ~5      42, 'int'
  206     9        ADD_ARRAY_ELEMENT                                ~5      3.1415, 'float'
  204    10        ADD_ARRAY_ELEMENT                                ~5      <true>, 'bool'
         11        ADD_ARRAY_ELEMENT                                ~5      <array>, 'array'
  212    12        NEW                                              $6      'DateTime'
         13        DO_FCALL                                      0          
         14        ADD_ARRAY_ELEMENT                                ~5      $6, 'obj'
  213    15        ADD_ARRAY_ELEMENT                                ~5      '12345', 'pass'
  214    16        ADD_ARRAY_ELEMENT                                ~5      'ordinal+index', 110
  203    17        ASSIGN                                                   !0, ~5
  218    18        ASSIGN                                                   !1, <array>
  236    19        NEW                                              $10     'Example'
         20        DO_FCALL                                      0          
         21        ASSIGN                                                   !2, $10
  237    22        INIT_METHOD_CALL                                         !2, 'test'
         23        SEND_VAR_EX                                              !0
         24        SEND_VAR_EX                                              !1
         25        DO_FCALL                                      0          
         26      > RETURN                                                   1

Class ErrorHandler:
Function as_per_type:
Finding entry points
Branch analysis from position: 0
5 jumps found. (Code = 188) Position 1 = 13, Position 2 = 17, Position 3 = 21, Position 4 = 39, Position 5 = 6
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 46) Position 1 = 26, Position 2 = 32
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 35
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 21
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 21
Branch analysis from position: 17
Branch analysis from position: 13
filename:       /in/fKQAc
function name:  as_per_type
number of ops:  41
compiled vars:  !0 = $vValue, !1 = $sType, !2 = $vKey
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      ''
   27     3        GET_TYPE                                         ~3      !0
          4        ASSIGN                                                   !1, ~3
   28     5      > SWITCH_STRING                                            !1, [ 'array':->13, 'object':->17, 'string':->21, ], ->39
   29     6    >   IS_EQUAL                                                 !1, 'array'
          7      > JMPNZ                                                    ~5, ->13
   32     8    >   IS_EQUAL                                                 !1, 'object'
          9      > JMPNZ                                                    ~5, ->17
   35    10    >   IS_EQUAL                                                 !1, 'string'
         11      > JMPNZ                                                    ~5, ->21
         12    > > JMP                                                      ->39
   30    13    >   INIT_STATIC_METHOD_CALL                                  'recurse_array'
         14        SEND_VAR_EX                                              !0
         15        DO_FCALL                                      0  $6      
         16      > RETURN                                                   $6
   33    17    >   INIT_STATIC_METHOD_CALL                                  'recurse_object'
         18        SEND_VAR_EX                                              !0
         19        DO_FCALL                                      0  $7      
         20      > RETURN                                                   $7
   36    21    >   FETCH_STATIC_PROP_R          unknown             ~8      'bRedactAllStrings'
         22      > JMPZ                                                     ~8, ->25
   37    23    > > RETURN                                                   '%2A%2AREDACTED_PER_FUNCTION%2A%2A'
   36    24*       JMP                                                      ->39
   39    25    > > JMPZ_EX                                          ~9      !2, ->32
         26    >   INIT_FCALL                                               'preg_match'
         27        FETCH_STATIC_PROP_R          unknown             ~10     'sMatchIndex'
         28        SEND_VAL                                                 ~10
         29        SEND_VAR                                                 !2
         30        DO_ICALL                                         $11     
         31        BOOL                                             ~9      $11
         32    > > JMPZ                                                     ~9, ->35
   40    33    > > RETURN                                                   '%2A%2AREDACTED_PER_INDEX%2A%2A'
   39    34*       JMP                                                      ->39
   42    35    >   ROPE_INIT                                     3  ~13     '%27'
         36        ROPE_ADD                                      1  ~13     ~13, !0
         37        ROPE_END                                      2  ~12     ~13, '%27'
         38      > RETURN                                                   ~12
   45    39    > > RETURN                                                   !0
   47    40*     > RETURN                                                   null

End of function as_per_type

Function recurse_object:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 23
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 23
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/fKQAc
function name:  recurse_object
number of ops:  26
compiled vars:  !0 = $oInput, !1 = $aObj, !2 = $aOutput, !3 = $vObj, !4 = $iObj, !5 = $vValue, !6 = $sType
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   RECV                                             !0      
   53     1        INIT_FCALL                                               'get_object_vars'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $7      
          4        ASSIGN                                                   !1, $7
   54     5        ASSIGN                                                   !2, <array>
   55     6      > FE_RESET_R                                       $10     !1, ->23
          7    > > FE_FETCH_R                                       ~11     $10, !3, ->23
          8    >   ASSIGN                                                   !4, ~11
   56     9        INIT_STATIC_METHOD_CALL                                  'as_per_type'
         10        FETCH_OBJ_R                                      ~13     !0, !4
         11        SEND_VAL                                                 ~13
         12        SEND_REF                                                 !6
         13        SEND_VAR                                                 !4
         14        DO_FCALL                                      0  $14     
         15        ASSIGN                                                   !5, $14
   57    16        ROPE_INIT                                     4  ~17     !4
         17        ROPE_ADD                                      1  ~17     ~17, '+%28'
         18        ROPE_ADD                                      2  ~17     ~17, !6
         19        ROPE_END                                      3  ~16     ~17, '%29'
         20        ASSIGN_DIM                                               !2, ~16
         21        OP_DATA                                                  !5
   55    22      > JMP                                                      ->7
         23    >   FE_FREE                                                  $10
   60    24      > RETURN                                                   !2
   61    25*     > RETURN                                                   null

End of function recurse_object

Function recurse_array:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 28
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 28
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 21
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/fKQAc
function name:  recurse_array
number of ops:  31
compiled vars:  !0 = $aInput, !1 = $aOutput, !2 = $vValue, !3 = $iKey, !4 = $sKey, !5 = $sTypeKey, !6 = $sValue, !7 = $sTypeValue
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   64     0  E >   RECV                                             !0      
   67     1        ASSIGN                                                   !1, <array>
   68     2      > FE_RESET_R                                       $9      !0, ->28
          3    > > FE_FETCH_R                                       ~10     $9, !2, ->28
          4    >   ASSIGN                                                   !3, ~10
   69     5        INIT_STATIC_METHOD_CALL                                  'as_per_type'
          6        SEND_VAR                                                 !3
          7        SEND_REF                                                 !5
          8        DO_FCALL                                      0  $12     
          9        ASSIGN                                                   !4, $12
   70    10        INIT_STATIC_METHOD_CALL                                  'as_per_type'
         11        SEND_VAR                                                 !2
         12        SEND_REF                                                 !7
         13        SEND_VAR                                                 !3
         14        DO_FCALL                                      0  $14     
         15        ASSIGN                                                   !6, $14
   74    16        IS_EQUAL                                                 !7, 'object'
         17      > JMPZ                                                     ~16, ->21
         18    >   GET_CLASS                                        ~17     !2
         19        CONCAT                                           ~18     '+', ~17
         20        ASSIGN_OP                                     8          !7, ~18
   76    21    >   ROPE_INIT                                     4  ~21     !4
         22        ROPE_ADD                                      1  ~21     ~21, '+%28'
         23        ROPE_ADD                                      2  ~21     ~21, !7
         24        ROPE_END                                      3  ~20     ~21, '%29'
         25        ASSIGN_DIM                                               !1, ~20
         26        OP_DATA                                                  !6
   68    27      > JMP                                                      ->3
         28    >   FE_FREE                                                  $9
   79    29      > RETURN                                                   !1
   80    30*     > RETURN                                                   null

End of function recurse_array

Function redact_backtrace:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 37
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 37
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 16
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 26
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 36
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 36
Branch analysis from position: 26
Branch analysis from position: 16
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/fKQAc
function name:  redact_backtrace
number of ops:  40
compiled vars:  !0 = $aTrace, !1 = $aFunc, !2 = $iFunc
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   83     0  E >   RECV                                             !0      
   86     1      > FE_RESET_R                                       $3      !0, ->37
          2    > > FE_FETCH_R                                       ~4      $3, !1, ->37
          3    >   ASSIGN                                                   !2, ~4
   87     4        ASSIGN_STATIC_PROP                                       'bRedactAllStrings'
          5        OP_DATA                                                  <false>
   90     6        ISSET_ISEMPTY_DIM_OBJ                         0          !1, 'object'
          7      > JMPZ                                                     ~7, ->16
   91     8    >   INIT_STATIC_METHOD_CALL                                  'recurse_object'
          9        FETCH_DIM_R                                      ~10     !0, !2
         10        FETCH_DIM_R                                      ~11     ~10, 'object'
         11        SEND_VAL                                                 ~11
         12        DO_FCALL                                      0  $12     
         13        FETCH_DIM_W                                      $8      !0, !2
         14        ASSIGN_DIM                                               $8, 'object'
         15        OP_DATA                                                  $12
   95    16    >   ISSET_ISEMPTY_DIM_OBJ                         0          !1, 'function'
         17      > JMPZ                                                     ~13, ->26
   96    18    >   INIT_FCALL                                               'preg_match'
         19        FETCH_STATIC_PROP_R          unknown             ~15     'sMatchFunction'
         20        SEND_VAL                                                 ~15
         21        FETCH_DIM_R                                      ~16     !1, 'function'
         22        SEND_VAL                                                 ~16
         23        DO_ICALL                                         $17     
         24        ASSIGN_STATIC_PROP                                       'bRedactAllStrings'
         25        OP_DATA                                                  $17
  100    26    >   ISSET_ISEMPTY_DIM_OBJ                         0          !1, 'args'
         27      > JMPZ                                                     ~18, ->36
  101    28    >   INIT_STATIC_METHOD_CALL                                  'recurse_array'
         29        FETCH_DIM_R                                      ~21     !0, !2
         30        FETCH_DIM_R                                      ~22     ~21, 'args'
         31        SEND_VAL                                                 ~22
         32        DO_FCALL                                      0  $23     
         33        FETCH_DIM_W                                      $19     !0, !2
         34        ASSIGN_DIM                                               $19, 'args'
         35        OP_DATA                                                  $23
   86    36    > > JMP                                                      ->2
         37    >   FE_FREE                                                  $3
  105    38      > RETURN                                                   !0
  106    39*     > RETURN                                                   null

End of function redact_backtrace

Function err_log:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/fKQAc
function name:  err_log
number of ops:  13
compiled vars:  !0 = $aLog
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  115     0  E >   RECV                                             !0      
  118     1        FETCH_STATIC_PROP_R          unknown             ~1      'bHeadersSent'
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ                                                     ~2, ->9
  119     4    >   INIT_FCALL                                               'header'
          5        SEND_VAL                                                 'content-type%3A+text%2Fplain'
          6        DO_ICALL                                                 
  120     7        ASSIGN_STATIC_PROP                                       'bHeadersSent'
          8        OP_DATA                                                  <true>
  123     9    >   INIT_FCALL                                               'print_r'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                                 
  124    12      > RETURN                                                   null

End of function err_log

Function err_handler:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fKQAc
function name:  err_handler
number of ops:  21
compiled vars:  !0 = $iError, !1 = $sText, !2 = $sFile, !3 = $iLine, !4 = $aTrace
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  132     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
  139     4        INIT_FCALL                                               'debug_backtrace'
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !4, $5
  140     7        UNSET_DIM                                                !4, 0
  142     8        INIT_STATIC_METHOD_CALL                                  'err_log'
  144     9        INIT_ARRAY                                       ~7      'Error+handler', 'where'
  145    10        ADD_ARRAY_ELEMENT                                ~7      !2, 'file'
  146    11        ADD_ARRAY_ELEMENT                                ~7      !3, 'line'
  147    12        ADD_ARRAY_ELEMENT                                ~7      !0, 'code'
  148    13        ADD_ARRAY_ELEMENT                                ~7      !1, 'msg'
  149    14        INIT_STATIC_METHOD_CALL                                  'redact_backtrace'
         15        SEND_VAR                                                 !4
         16        DO_FCALL                                      0  $8      
         17        ADD_ARRAY_ELEMENT                                ~7      $8, 'trace'
         18        SEND_VAL                                                 ~7
  142    19        DO_FCALL                                      0          
  152    20      > RETURN                                                   null

End of function err_handler

Function exc_handler:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fKQAc
function name:  exc_handler
number of ops:  26
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  155     0  E >   RECV                                             !0      
  158     1        INIT_STATIC_METHOD_CALL                                  'err_log'
  160     2        INIT_ARRAY                                       ~1      'Exception+handler', 'where'
  161     3        INIT_METHOD_CALL                                         !0, 'getFile'
          4        DO_FCALL                                      0  $2      
          5        ADD_ARRAY_ELEMENT                                ~1      $2, 'file'
  162     6        INIT_METHOD_CALL                                         !0, 'getLine'
          7        DO_FCALL                                      0  $3      
          8        ADD_ARRAY_ELEMENT                                ~1      $3, 'line'
  163     9        INIT_METHOD_CALL                                         !0, 'getCode'
         10        DO_FCALL                                      0  $4      
         11        ADD_ARRAY_ELEMENT                                ~1      $4, 'code'
  164    12        INIT_METHOD_CALL                                         !0, 'getMessage'
         13        DO_FCALL                                      0  $5      
         14        ADD_ARRAY_ELEMENT                                ~1      $5, 'msg'
  165    15        INIT_STATIC_METHOD_CALL                                  'redact_backtrace'
         16        INIT_METHOD_CALL                                         !0, 'getTrace'
         17        DO_FCALL                                      0  $6      
         18        SEND_VAR                                                 $6
         19        DO_FCALL                                      0  $7      
         20        ADD_ARRAY_ELEMENT                                ~1      $7, 'trace'
  166    21        GET_CLASS                                        ~8      !0
         22        ADD_ARRAY_ELEMENT                                ~1      ~8, 'class'
         23        SEND_VAL                                                 ~1
  158    24        DO_FCALL                                      0          
  169    25      > RETURN                                                   null

End of function exc_handler

End of class ErrorHandler.

Class Example:
Function login:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fKQAc
function name:  login
number of ops:  4
compiled vars:  !0 = $sUser, !1 = $sPass
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  186     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  187     2        ECHO                                                     <array>
  188     3      > RETURN                                                   null

End of function login

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/fKQAc
function name:  test
number of ops:  16
compiled vars:  !0 = $a, !1 = $b, !2 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  190     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  191     2        INIT_METHOD_CALL                                         'login'
          3        SEND_VAL_EX                                              'username'
          4        SEND_VAL_EX                                              'password'
          5        DO_FCALL                                      0          
  193     6        UNSET_DIM                                                !0, 'obj'
  195     7        DIV                                              ~4      1, 0
          8        FREE                                                     ~4
  196     9        ADD                                              ~5      1, !2
         10        FREE                                                     ~5
  197    11        NEW                                              $6      'Exception'
         12        SEND_VAL_EX                                              'TestException'
         13        DO_FCALL                                      0          
         14      > THROW                                         0          $6
  198    15*     > RETURN                                                   null

End of function test

End of class Example.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.56 ms | 1031 KiB | 20 Q