3v4l.org

run code in 300+ PHP versions simultaneously
<?php class FooWrapper { protected $opened = false; public function stream_close() { if (!$this->opened) { throw new \RuntimeException("Closing an unopened stream"); } $this->opened = false; } public function stream_open($path, $mode, $options, &$opened_path) { if ($this->opened) { throw new Exception("opened already"); } if ($path == "foo://foo") { throw new Exception("Foo"); } $this->opened = true; return true; } public function stream_read($count) { return str_repeat('f', $count); } } stream_wrapper_register("foo", "FooWrapper"); try { $foo = fopen("foo://foo", "r"); } catch (Exception $e) { var_dump($e); } try { $f = fopen("foo://bar", "r"); var_dump(fread($f, 10)); fclose($f); } catch (\Exception $e) { var_dump($e); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 10
Branch analysis from position: 10
2 jumps found. (Code = 107) Position 1 = 11, Position 2 = -2
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
Found catch point at position: 30
Branch analysis from position: 30
2 jumps found. (Code = 107) Position 1 = 31, Position 2 = -2
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nrh1L
function name:  (null)
number of ops:  35
compiled vars:  !0 = $foo, !1 = $e, !2 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   INIT_FCALL                                               'stream_wrapper_register'
          1        SEND_VAL                                                 'foo'
          2        SEND_VAL                                                 'FooWrapper'
          3        DO_ICALL                                                 
   29     4        INIT_FCALL                                               'fopen'
          5        SEND_VAL                                                 'foo%3A%2F%2Ffoo'
          6        SEND_VAL                                                 'r'
          7        DO_ICALL                                         $4      
          8        ASSIGN                                                   !0, $4
          9      > JMP                                                      ->14
   30    10  E > > CATCH                                       last         'Exception'
   31    11    >   INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
   35    14    >   INIT_FCALL                                               'fopen'
         15        SEND_VAL                                                 'foo%3A%2F%2Fbar'
         16        SEND_VAL                                                 'r'
         17        DO_ICALL                                         $7      
         18        ASSIGN                                                   !2, $7
   36    19        INIT_FCALL                                               'var_dump'
         20        INIT_FCALL                                               'fread'
         21        SEND_VAR                                                 !2
         22        SEND_VAL                                                 10
         23        DO_ICALL                                         $9      
         24        SEND_VAR                                                 $9
         25        DO_ICALL                                                 
   37    26        INIT_FCALL                                               'fclose'
         27        SEND_VAR                                                 !2
         28        DO_ICALL                                                 
         29      > JMP                                                      ->34
   38    30  E > > CATCH                                       last         'Exception'
   39    31    >   INIT_FCALL                                               'var_dump'
         32        SEND_VAR                                                 !1
         33        DO_ICALL                                                 
   40    34    > > RETURN                                                   1

Class FooWrapper:
Function stream_close:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nrh1L
function name:  stream_close
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   FETCH_OBJ_R                                      ~0      'opened'
          1        BOOL_NOT                                         ~1      ~0
          2      > JMPZ                                                     ~1, ->7
    7     3    >   NEW                                              $2      'RuntimeException'
          4        SEND_VAL_EX                                              'Closing+an+unopened+stream'
          5        DO_FCALL                                      0          
          6      > THROW                                         0          $2
    9     7    >   ASSIGN_OBJ                                               'opened'
          8        OP_DATA                                                  <false>
   10     9      > RETURN                                                   null

End of function stream_close

Function stream_open:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nrh1L
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
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   12     4        FETCH_OBJ_R                                      ~4      'opened'
          5      > JMPZ                                                     ~4, ->10
   13     6    >   NEW                                              $5      'Exception'
          7        SEND_VAL_EX                                              'opened+already'
          8        DO_FCALL                                      0          
          9      > THROW                                         0          $5
   15    10    >   IS_EQUAL                                                 !0, 'foo%3A%2F%2Ffoo'
         11      > JMPZ                                                     ~7, ->16
   16    12    >   NEW                                              $8      'Exception'
         13        SEND_VAL_EX                                              'Foo'
         14        DO_FCALL                                      0          
         15      > THROW                                         0          $8
   18    16    >   ASSIGN_OBJ                                               'opened'
         17        OP_DATA                                                  <true>
   19    18      > RETURN                                                   <true>
   20    19*     > RETURN                                                   null

End of function stream_open

Function stream_read:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nrh1L
function name:  stream_read
number of ops:  7
compiled vars:  !0 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        INIT_FCALL                                               'str_repeat'
          2        SEND_VAL                                                 'f'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
   23     6*     > RETURN                                                   null

End of function stream_read

End of class FooWrapper.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.15 ms | 1396 KiB | 25 Q