3v4l.org

run code in 300+ PHP versions simultaneously
<?php \spl_autoload_register(function($class) { echo "Autoloader for '$class' called\n"; class_alias(Test::class, $class); return true; }); class Test { static function blubb() { echo static::class, "\n"; } } 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"; if ($this->id === 1) { Lalala::blubb(); } else { Foobar::blubb(); } 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 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 29
Branch analysis from position: 25
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 38
Branch analysis from position: 34
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 49
Branch analysis from position: 45
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 49
2 jumps found. (Code = 43) Position 1 = 55, Position 2 = 59
Branch analysis from position: 55
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GB7Mm
function name:  (null)
number of ops:  60
compiled vars:  !0 = $handle, !1 = $handle2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'spl_autoload_register'
          1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FGB7Mm%3A3%240'
    7     2        SEND_VAL                                                 ~2
          3        DO_ICALL                                                 
   65     4        INIT_FCALL                                               'stream_wrapper_register'
          5        SEND_VAL                                                 'test'
          6        SEND_VAL                                                 'MyStreamWrapper'
          7        DO_ICALL                                                 
   67     8        INIT_FCALL                                               'fopen'
          9        SEND_VAL                                                 'test%3A%2F%2F%2Ffoobar'
         10        SEND_VAL                                                 'r%2B'
         11        DO_ICALL                                         $5      
         12        ASSIGN                                           ~6      !0, $5
         13        TYPE_CHECK                                    4          ~6
         14      > JMPZ                                                     ~7, ->19
   68    15    >   NEW                                              $8      'RuntimeException'
         16        SEND_VAL_EX                                              'Failed+to+open+file'
         17        DO_FCALL                                      0          
         18      > THROW                                         0          $8
   71    19    >   INIT_FCALL                                               'fwrite'
         20        SEND_VAR                                                 !0
         21        SEND_VAL                                                 'test'
         22        DO_ICALL                                         $10     
         23        TYPE_CHECK                                    4          $10
         24      > JMPZ                                                     ~11, ->29
   72    25    >   NEW                                              $12     'RuntimeException'
         26        SEND_VAL_EX                                              'Failed+to+write+to+file'
         27        DO_FCALL                                      0          
         28      > THROW                                         0          $12
   75    29    >   INIT_FCALL                                               'fclose'
         30        SEND_VAR                                                 !0
         31        DO_ICALL                                         $14     
         32        TYPE_CHECK                                    4          $14
         33      > JMPZ                                                     ~15, ->38
   76    34    >   NEW                                              $16     'RuntimeException'
         35        SEND_VAL_EX                                              'Failed+to+close+file'
         36        DO_FCALL                                      0          
         37      > THROW                                         0          $16
   79    38    >   INIT_FCALL                                               'fopen'
         39        SEND_VAL                                                 'test%3A%2F%2F%2Fblubb'
         40        SEND_VAL                                                 'r%2B'
         41        DO_ICALL                                         $18     
         42        ASSIGN                                           ~19     !1, $18
         43        TYPE_CHECK                                    4          ~19
         44      > JMPZ                                                     ~20, ->49
   80    45    >   NEW                                              $21     'RuntimeException'
         46        SEND_VAL_EX                                              'Failed+to+open+file'
         47        DO_FCALL                                      0          
         48      > THROW                                         0          $21
   83    49    >   INIT_FCALL                                               'fwrite'
         50        SEND_VAR                                                 !1
         51        SEND_VAL                                                 'test'
         52        DO_ICALL                                         $23     
         53        TYPE_CHECK                                    4          $23
         54      > JMPZ                                                     ~24, ->59
   84    55    >   NEW                                              $25     'RuntimeException'
         56        SEND_VAL_EX                                              'Failed+to+write+to+file'
         57        DO_FCALL                                      0          
         58      > THROW                                         0          $25
   85    59    > > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FGB7Mm%3A3%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GB7Mm
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ROPE_INIT                                     3  ~2      'Autoloader+for+%27'
          2        ROPE_ADD                                      1  ~2      ~2, !0
          3        ROPE_END                                      2  ~1      ~2, '%27+called%0A'
          4        ECHO                                                     ~1
    5     5        INIT_FCALL                                               'class_alias'
          6        SEND_VAL                                                 'Test'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
    6     9      > RETURN                                                   <true>
    7    10*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FGB7Mm%3A3%240

Class Test:
Function blubb:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GB7Mm
function name:  blubb
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   FETCH_CLASS_NAME                                 ~0      
          1        ECHO                                                     ~0
          2        ECHO                                                     '%0A'
   14     3      > RETURN                                                   null

End of function blubb

End of class Test.

Class MyStreamWrapper:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GB7Mm
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   POST_INC_STATIC_PROP                             ~1      'counter'
          1        ASSIGN_OBJ                                               'id'
          2        OP_DATA                                                  ~1
   26     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/GB7Mm
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
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   30     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
   31     9      > RETURN                                                   <true>
   32    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/GB7Mm
function name:  stream_write
number of ops:  9
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
   36     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
   37     6        STRLEN                                           ~5      !0
          7      > RETURN                                                   ~5
   38     8*     > RETURN                                                   null

End of function stream_write

Function stream_flush:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GB7Mm
function name:  stream_flush
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     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
   44     5        FETCH_OBJ_R                                      ~4      'id'
          6        IS_IDENTICAL                                             ~4, 1
          7      > JMPZ                                                     ~5, ->11
   45     8    >   INIT_STATIC_METHOD_CALL                                  'Lalala', 'blubb'
          9        DO_FCALL                                      0          
         10      > JMP                                                      ->13
   47    11    >   INIT_STATIC_METHOD_CALL                                  'Foobar', 'blubb'
         12        DO_FCALL                                      0          
   50    13    > > RETURN                                                   <true>
   51    14*     > 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/GB7Mm
function name:  stream_close
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     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
   56     5      > RETURN                                                   <true>
   57     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/GB7Mm
function name:  __destruct
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   61     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
   62     5      > RETURN                                                   null

End of function __destruct

End of class MyStreamWrapper.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.1 ms | 1408 KiB | 25 Q