3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private function customErrorHandler(int $code, string $msg): bool { var_dump(preg_replace('{^(fopen|mkdir)\(.*?\): }', '', $msg)); return true; } protected function write(): void { set_error_handler([$this, 'customErrorHandler']); try { $stream = fopen('logs://userfrosting.log', 'a'); trigger_error('Test test'); } finally { restore_error_handler(); } } public function test() { $this->write(); } } class Bar { public function customErrorHandler(int $code, string $msg): bool { var_dump(preg_replace('{^(fopen|mkdir)\(.*?\): }', '', $msg)); return true; } protected function write(): void { set_error_handler([$this, 'customErrorHandler']); try { $stream = fopen('logs://userfrosting.log', 'a'); trigger_error('Test test'); } finally { restore_error_handler(); } } public function test() { $this->write(); } } class StreamHandler { public $context; public function stream_open(string $path, string $mode, int $options, ?string &$opened_path): bool { $path = str_replace('logs://', '', $path); return @fopen($path, $mode); } } stream_wrapper_register('logs', StreamHandler::class); (new Bar)->test(); (new Foo)->test();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PjtpI
function name:  (null)
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   61     0  E >   INIT_FCALL                                               'stream_wrapper_register'
          1        SEND_VAL                                                 'logs'
          2        SEND_VAL                                                 'StreamHandler'
          3        DO_ICALL                                                 
   63     4        NEW                                              $1      'Bar'
          5        DO_FCALL                                      0          
          6        INIT_METHOD_CALL                                         $1, 'test'
          7        DO_FCALL                                      0          
   64     8        NEW                                              $4      'Foo'
          9        DO_FCALL                                      0          
         10        INIT_METHOD_CALL                                         $4, 'test'
         11        DO_FCALL                                      0          
         12      > RETURN                                                   1

Class Foo:
Function customerrorhandler:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PjtpI
function name:  customErrorHandler
number of ops:  13
compiled vars:  !0 = $code, !1 = $msg
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'preg_replace'
          4        SEND_VAL                                                 '%7B%5E%28fopen%7Cmkdir%29%5C%28.%2A%3F%5C%29%3A+%7D'
          5        SEND_VAL                                                 ''
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $2      
          8        SEND_VAR                                                 $2
          9        DO_ICALL                                                 
    7    10      > RETURN                                                   <true>
    8    11*       VERIFY_RETURN_TYPE                                       
         12*     > RETURN                                                   null

End of function customerrorhandler

Function write:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 162) Position 1 = 16, Position 2 = 15
Branch analysis from position: 16
1 jumps found. (Code = 163) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PjtpI
function name:  write
number of ops:  20
compiled vars:  !0 = $stream
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'set_error_handler'
          1        FETCH_THIS                                       ~1      
          2        INIT_ARRAY                                       ~2      ~1
          3        ADD_ARRAY_ELEMENT                                ~2      'customErrorHandler'
          4        SEND_VAL                                                 ~2
          5        DO_ICALL                                                 
   14     6        INIT_FCALL                                               'fopen'
          7        SEND_VAL                                                 'logs%3A%2F%2Fuserfrosting.log'
          8        SEND_VAL                                                 'a'
          9        DO_ICALL                                         $5      
         10        ASSIGN                                                   !0, $5
   15    11        INIT_FCALL                                               'trigger_error'
         12        SEND_VAL                                                 'Test+test'
         13        DO_ICALL                                                 
   16    14      > FAST_CALL                                                ->16
         15    > > JMP                                                      ->19
   17    16    >   INIT_FCALL                                               'restore_error_handler'
         17        DO_ICALL                                                 
         18      > FAST_RET                                                 
   19    19    > > RETURN                                                   null

End of function write

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PjtpI
function name:  test
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_METHOD_CALL                                         'write'
          1        DO_FCALL                                      0          
   24     2      > RETURN                                                   null

End of function test

End of class Foo.

Class Bar:
Function customerrorhandler:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PjtpI
function name:  customErrorHandler
number of ops:  13
compiled vars:  !0 = $code, !1 = $msg
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   30     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'preg_replace'
          4        SEND_VAL                                                 '%7B%5E%28fopen%7Cmkdir%29%5C%28.%2A%3F%5C%29%3A+%7D'
          5        SEND_VAL                                                 ''
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $2      
          8        SEND_VAR                                                 $2
          9        DO_ICALL                                                 
   32    10      > RETURN                                                   <true>
   33    11*       VERIFY_RETURN_TYPE                                       
         12*     > RETURN                                                   null

End of function customerrorhandler

Function write:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 162) Position 1 = 16, Position 2 = 15
Branch analysis from position: 16
1 jumps found. (Code = 163) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PjtpI
function name:  write
number of ops:  20
compiled vars:  !0 = $stream
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   INIT_FCALL                                               'set_error_handler'
          1        FETCH_THIS                                       ~1      
          2        INIT_ARRAY                                       ~2      ~1
          3        ADD_ARRAY_ELEMENT                                ~2      'customErrorHandler'
          4        SEND_VAL                                                 ~2
          5        DO_ICALL                                                 
   39     6        INIT_FCALL                                               'fopen'
          7        SEND_VAL                                                 'logs%3A%2F%2Fuserfrosting.log'
          8        SEND_VAL                                                 'a'
          9        DO_ICALL                                         $5      
         10        ASSIGN                                                   !0, $5
   40    11        INIT_FCALL                                               'trigger_error'
         12        SEND_VAL                                                 'Test+test'
         13        DO_ICALL                                                 
   41    14      > FAST_CALL                                                ->16
         15    > > JMP                                                      ->19
   42    16    >   INIT_FCALL                                               'restore_error_handler'
         17        DO_ICALL                                                 
         18      > FAST_RET                                                 
   44    19    > > RETURN                                                   null

End of function write

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PjtpI
function name:  test
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   INIT_METHOD_CALL                                         'write'
          1        DO_FCALL                                      0          
   49     2      > RETURN                                                   null

End of function test

End of class Bar.

Class StreamHandler:
Function stream_open:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PjtpI
function name:  stream_open
number of ops:  20
compiled vars:  !0 = $path, !1 = $mode, !2 = $options, !3 = $opened_path
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   57     4        INIT_FCALL                                               'str_replace'
          5        SEND_VAL                                                 'logs%3A%2F%2F'
          6        SEND_VAL                                                 ''
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $4      
          9        ASSIGN                                                   !0, $4
   58    10        BEGIN_SILENCE                                    ~6      
         11        INIT_FCALL                                               'fopen'
         12        SEND_VAR                                                 !0
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                         $7      
         15        END_SILENCE                                              ~6
         16        VERIFY_RETURN_TYPE                                       $7
         17      > RETURN                                                   $7
   59    18*       VERIFY_RETURN_TYPE                                       
         19*     > RETURN                                                   null

End of function stream_open

End of class StreamHandler.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.27 ms | 1453 KiB | 21 Q