3v4l.org

run code in 300+ PHP versions simultaneously
<?php class sf extends php_user_filter { function onCreate() { //var_dump($this); } function filter($in, $out, &$consumed, $closing) { var_dump(func_get_args()); if(!$closing) { $bucket = stream_bucket_make_writeable($in); $bucket->data = 'A'.$bucket->data.'B'; //var_dump($bucket, $closing); /*while ($bucket = stream_bucket_make_writeable($in)) { */ $consumed += $bucket->datalen; stream_bucket_prepend($out, $bucket); return PSFS_PASS_ON; } else { return PSFS_FEED_ME; } } } $r = fopen('php://memory', 'wb+'); stream_filter_register('sf', 'sf' ); stream_filter_append($r, 'sf', STREAM_FILTER_READ); fwrite($r, 'lol'); rewind($r); var_dump(fread($r, 1024)); //echo fread($r, 2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k3HWj
function name:  (null)
number of ops:  29
compiled vars:  !0 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   INIT_FCALL                                               'fopen'
          1        SEND_VAL                                                 'php%3A%2F%2Fmemory'
          2        SEND_VAL                                                 'wb%2B'
          3        DO_ICALL                                         $1      
          4        ASSIGN                                                   !0, $1
   30     5        INIT_FCALL                                               'stream_filter_register'
          6        SEND_VAL                                                 'sf'
          7        SEND_VAL                                                 'sf'
          8        DO_ICALL                                                 
   33     9        INIT_FCALL                                               'stream_filter_append'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 'sf'
         12        SEND_VAL                                                 1
         13        DO_ICALL                                                 
   35    14        INIT_FCALL                                               'fwrite'
         15        SEND_VAR                                                 !0
         16        SEND_VAL                                                 'lol'
         17        DO_ICALL                                                 
   36    18        INIT_FCALL                                               'rewind'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                                 
   37    21        INIT_FCALL                                               'var_dump'
         22        INIT_FCALL                                               'fread'
         23        SEND_VAR                                                 !0
         24        SEND_VAL                                                 1024
         25        DO_ICALL                                         $7      
         26        SEND_VAR                                                 $7
         27        DO_ICALL                                                 
   38    28      > RETURN                                                   1

Class sf:
Function oncreate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k3HWj
function name:  onCreate
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E > > RETURN                                                   null

End of function oncreate

Function filter:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 27
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k3HWj
function name:  filter
number of ops:  29
compiled vars:  !0 = $in, !1 = $out, !2 = $consumed, !3 = $closing, !4 = $bucket
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
    9     4        INIT_FCALL                                               'var_dump'
          5        FUNC_GET_ARGS                                    ~5      
          6        SEND_VAL                                                 ~5
          7        DO_ICALL                                                 
   10     8        BOOL_NOT                                         ~7      !3
          9      > JMPZ                                                     ~7, ->27
   11    10    >   INIT_FCALL                                               'stream_bucket_make_writeable'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $8      
         13        ASSIGN                                                   !4, $8
   12    14        FETCH_OBJ_R                                      ~11     !4, 'data'
         15        CONCAT                                           ~12     'A', ~11
         16        CONCAT                                           ~13     ~12, 'B'
         17        ASSIGN_OBJ                                               !4, 'data'
         18        OP_DATA                                                  ~13
   16    19        FETCH_OBJ_R                                      ~14     !4, 'datalen'
         20        ASSIGN_OP                                     1          !2, ~14
   17    21        INIT_FCALL                                               'stream_bucket_prepend'
         22        SEND_VAR                                                 !1
         23        SEND_VAR                                                 !4
         24        DO_ICALL                                                 
   20    25      > RETURN                                                   2
         26*       JMP                                                      ->28
   22    27    > > RETURN                                                   1
   24    28*     > RETURN                                                   null

End of function filter

End of class sf.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.88 ms | 1400 KiB | 31 Q