3v4l.org

run code in 300+ PHP versions simultaneously
<?php class StreamFilter extends php_user_filter { public function filter($in, $out, &$consumed, $closing) { var_dump('FILTERING!'); while ($bucket = stream_bucket_make_writeable($in)) ; if ($closing || feof($this->stream)) { $streamUri = substr(stream_get_meta_data($this->stream)['uri'], strlen('php://filter/read=asd/resource=')); //$buffer = strtoupper(file_get_contents($streamUri)); $buffer = 'HA'; $bucket = stream_bucket_new($this->stream, $buffer); stream_bucket_append($out, $bucket); return PSFS_PASS_ON; } return PSFS_FEED_ME; } } stream_filter_register('asd', 'StreamFilter'); function shut() { $stream = 'php://filter/read=asd/resource=/home/vagrant/test-register-shutdown-function/test.txt'; $stream = 'php://filter/read=asd/resource=https://dirty.ru/robots.txt'; var_dump(file_get_contents($stream)); //$stream = 'php://filter/read=string.toupper/resource=/home/vagrant/test-register-shutdown-function/test.txt'; //var_dump(file_get_contents($stream)); } register_shutdown_function('shut'); /* class A { public function __destruct() { } } new A(); */ die;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/Yjm5O
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   INIT_FCALL                                               'stream_filter_register'
          1        SEND_VAL                                                 'asd'
          2        SEND_VAL                                                 'StreamFilter'
          3        DO_ICALL                                                 
   40     4        INIT_FCALL                                               'register_shutdown_function'
          5        SEND_VAL                                                 'shut'
          6        DO_ICALL                                                 
   53     7      > EXIT                                                     
          8*     > RETURN                                                   1

Function shut:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Yjm5O
function name:  shut
number of ops:  9
compiled vars:  !0 = $stream
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   ASSIGN                                                   !0, 'php%3A%2F%2Ffilter%2Fread%3Dasd%2Fresource%3D%2Fhome%2Fvagrant%2Ftest-register-shutdown-function%2Ftest.txt'
   33     1        ASSIGN                                                   !0, 'php%3A%2F%2Ffilter%2Fread%3Dasd%2Fresource%3Dhttps%3A%2F%2Fdirty.ru%2Frobots.txt'
   34     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'file_get_contents'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        SEND_VAR                                                 $3
          7        DO_ICALL                                                 
   38     8      > RETURN                                                   null

End of function shut

Class StreamFilter:
Function filter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 8
Branch analysis from position: 13
2 jumps found. (Code = 47) Position 1 = 14, Position 2 = 19
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 42
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
Branch analysis from position: 8
filename:       /in/Yjm5O
function name:  filter
number of ops:  44
compiled vars:  !0 = $in, !1 = $out, !2 = $consumed, !3 = $closing, !4 = $bucket, !5 = $streamUri, !6 = $buffer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
    7     4        INIT_FCALL                                               'var_dump'
          5        SEND_VAL                                                 'FILTERING%21'
          6        DO_ICALL                                                 
    9     7      > JMP                                                      ->8
          8    >   INIT_FCALL                                               'stream_bucket_make_writeable'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $8      
         11        ASSIGN                                           ~9      !4, $8
         12      > JMPNZ                                                    ~9, ->8
   11    13    > > JMPNZ_EX                                         ~10     !3, ->19
         14    >   INIT_FCALL                                               'feof'
         15        FETCH_OBJ_R                                      ~11     'stream'
         16        SEND_VAL                                                 ~11
         17        DO_ICALL                                         $12     
         18        BOOL                                             ~10     $12
         19    > > JMPZ                                                     ~10, ->42
   12    20    >   INIT_FCALL                                               'substr'
         21        INIT_FCALL                                               'stream_get_meta_data'
         22        FETCH_OBJ_R                                      ~13     'stream'
         23        SEND_VAL                                                 ~13
         24        DO_ICALL                                         $14     
         25        FETCH_DIM_R                                      ~15     $14, 'uri'
         26        SEND_VAL                                                 ~15
         27        SEND_VAL                                                 31
         28        DO_ICALL                                         $16     
         29        ASSIGN                                                   !5, $16
   16    30        ASSIGN                                                   !6, 'HA'
   18    31        INIT_FCALL                                               'stream_bucket_new'
         32        FETCH_OBJ_R                                      ~19     'stream'
         33        SEND_VAL                                                 ~19
         34        SEND_VAR                                                 !6
         35        DO_ICALL                                         $20     
         36        ASSIGN                                                   !4, $20
   19    37        INIT_FCALL                                               'stream_bucket_append'
         38        SEND_VAR                                                 !1
         39        SEND_VAR                                                 !4
         40        DO_ICALL                                                 
   21    41      > RETURN                                                   2
   24    42    > > RETURN                                                   1
   25    43*     > RETURN                                                   null

End of function filter

End of class StreamFilter.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.08 ms | 1400 KiB | 33 Q