3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyStreamWrapper { static $counter = 1; private $id; public function __construct() { $this->id = self::$counter++; } public function stream_open($path, $mode, $options, &$opened_path) { echo "({$this->id}) stream_open()\n"; return true; } public function stream_write($data) { echo "({$this->id}) stream_write()\n"; return \strlen($data); } public function stream_flush() { echo "({$this->id}) stream_flush()\n"; return true; } public function stream_close() { echo "({$this->id}) stream_close()\n"; return true; } public function __destruct() { echo "({$this->id}) __destruct()\n"; } } \stream_wrapper_register('test', MyStreamWrapper::class); if (($handle = \fopen('test:///foobar', 'r+')) === false) { throw new \RuntimeException("Failed to open file"); } if (\fwrite($handle, 'test') === false) { throw new \RuntimeException("Failed to write to file"); } if (\fclose($handle) === false) { throw new \RuntimeException("Failed to close file"); } if (($handle2 = \fopen('test:///blubb', 'r+')) === false) { throw new \RuntimeException("Failed to open file"); } if (\fwrite($handle2, 'test') === false) { throw new \RuntimeException("Failed to write to file"); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 25
Branch analysis from position: 21
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 34
Branch analysis from position: 30
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 45
Branch analysis from position: 41
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 51, Position 2 = 55
Branch analysis from position: 51
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 55
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CMItP
function name:  (null)
number of ops:  56
compiled vars:  !0 = $handle, !1 = $handle2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   INIT_FCALL                                               'stream_wrapper_register'
          1        SEND_VAL                                                 'test'
          2        SEND_VAL                                                 'MyStreamWrapper'
          3        DO_ICALL                                                 
   46     4        INIT_FCALL                                               'fopen'
          5        SEND_VAL                                                 'test%3A%2F%2F%2Ffoobar'
          6        SEND_VAL                                                 'r%2B'
          7        DO_ICALL                                         $3      
          8        ASSIGN                                           ~4      !0, $3
          9        TYPE_CHECK                                    4          ~4
         10      > JMPZ                                                     ~5, ->15
   47    11    >   NEW                                              $6      'RuntimeException'
         12        SEND_VAL_EX                                              'Failed+to+open+file'
         13        DO_FCALL                                      0          
         14      > THROW                                         0          $6
   50    15    >   INIT_FCALL                                               'fwrite'
         16        SEND_VAR                                                 !0
         17        SEND_VAL                                                 'test'
         18        DO_ICALL                                         $8      
         19        TYPE_CHECK                                    4          $8
         20      > JMPZ                                                     ~9, ->25
   51    21    >   NEW                                              $10     'RuntimeException'
         22        SEND_VAL_EX                                              'Failed+to+write+to+file'
         23        DO_FCALL                                      0          
         24      > THROW                                         0          $10
   54    25    >   INIT_FCALL                                               'fclose'
         26        SEND_VAR                                                 !0
         27        DO_ICALL                                         $12     
         28        TYPE_CHECK                                    4          $12
         29      > JMPZ                                                     ~13, ->34
   55    30    >   NEW                                              $14     'RuntimeException'
         31        SEND_VAL_EX                                              'Failed+to+close+file'
         32        DO_FCALL                                      0          
         33      > THROW                                         0          $14
   58    34    >   INIT_FCALL                                               'fopen'
         35        SEND_VAL                                                 'test%3A%2F%2F%2Fblubb'
         36        SEND_VAL                                                 'r%2B'
         37        DO_ICALL                                         $16     
         38        ASSIGN                                           ~17     !1, $16
         39        TYPE_CHECK                                    4          ~17
         40      > JMPZ                                                     ~18, ->45
   59    41    >   NEW                                              $19     'RuntimeException'
         42        SEND_VAL_EX                                              'Failed+to+open+file'
         43        DO_FCALL                                      0          
         44      > THROW                                         0          $19
   62    45    >   INIT_FCALL                                               'fwrite'
         46        SEND_VAR                                                 !1
         47        SEND_VAL                                                 'test'
         48        DO_ICALL                                         $21     
         49        TYPE_CHECK                                    4          $21
         50      > JMPZ                                                     ~22, ->55
   63    51    >   NEW                                              $23     'RuntimeException'
         52        SEND_VAL_EX                                              'Failed+to+write+to+file'
         53        DO_FCALL                                      0          
         54      > THROW                                         0          $23
   64    55    > > RETURN                                                   1

Class MyStreamWrapper:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CMItP
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   POST_INC_STATIC_PROP                             ~1      'counter'
          1        ASSIGN_OBJ                                               'id'
          2        OP_DATA                                                  ~1
   12     3      > RETURN                                                   null

End of function __construct

Function stream_open:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CMItP
function name:  stream_open
number of ops:  11
compiled vars:  !0 = $path, !1 = $mode, !2 = $options, !3 = $opened_path
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   16     4        ROPE_INIT                                     3  ~6      '%28'
          5        FETCH_OBJ_R                                      ~4      'id'
          6        ROPE_ADD                                      1  ~6      ~6, ~4
          7        ROPE_END                                      2  ~5      ~6, '%29+stream_open%28%29%0A'
          8        ECHO                                                     ~5
   17     9      > RETURN                                                   <true>
   18    10*     > RETURN                                                   null

End of function stream_open

Function stream_write:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CMItP
function name:  stream_write
number of ops:  9
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   22     1        ROPE_INIT                                     3  ~3      '%28'
          2        FETCH_OBJ_R                                      ~1      'id'
          3        ROPE_ADD                                      1  ~3      ~3, ~1
          4        ROPE_END                                      2  ~2      ~3, '%29+stream_write%28%29%0A'
          5        ECHO                                                     ~2
   23     6        STRLEN                                           ~5      !0
          7      > RETURN                                                   ~5
   24     8*     > RETURN                                                   null

End of function stream_write

Function stream_flush:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CMItP
function name:  stream_flush
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   ROPE_INIT                                     3  ~2      '%28'
          1        FETCH_OBJ_R                                      ~0      'id'
          2        ROPE_ADD                                      1  ~2      ~2, ~0
          3        ROPE_END                                      2  ~1      ~2, '%29+stream_flush%28%29%0A'
          4        ECHO                                                     ~1
   29     5      > RETURN                                                   <true>
   30     6*     > RETURN                                                   null

End of function stream_flush

Function stream_close:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CMItP
function name:  stream_close
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   ROPE_INIT                                     3  ~2      '%28'
          1        FETCH_OBJ_R                                      ~0      'id'
          2        ROPE_ADD                                      1  ~2      ~2, ~0
          3        ROPE_END                                      2  ~1      ~2, '%29+stream_close%28%29%0A'
          4        ECHO                                                     ~1
   35     5      > RETURN                                                   <true>
   36     6*     > RETURN                                                   null

End of function stream_close

Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CMItP
function name:  __destruct
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   ROPE_INIT                                     3  ~2      '%28'
          1        FETCH_OBJ_R                                      ~0      'id'
          2        ROPE_ADD                                      1  ~2      ~2, ~0
          3        ROPE_END                                      2  ~1      ~2, '%29+__destruct%28%29%0A'
          4        ECHO                                                     ~1
   41     5      > RETURN                                                   null

End of function __destruct

End of class MyStreamWrapper.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.72 ms | 1408 KiB | 21 Q