3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo __FILE__; if (strlen(__FILE__) < 20) { copy(__FILE__, '/tmp/phpng_checkouts_somelongstring-2.0_cli_streamwrap.php'); require_once '/tmp/phpng_checkouts_somelongstring-2.0_cli_streamwrap.php'; return; } class Custom_StreamWrapper { public $context; public static function getPath($url, $mustExist = true) { $parts = explode('://', $url, 2); list($scheme, $path) = $parts; $path = stream_resolve_include_path($path); if (false === $path) { if ($mustExist) { throw new Exception('error'); } // centralize the stream_resolve_include_path logic return self::getPath(dirname($url)) .'/'. basename($url); } return $path; } public function stream_open($path, $mode, $options, &$openedPath) { // Modes 'a', 'c', 'w', 'x' are documented as: "If the file does not exist, attempt to create it" - so detect dir first and add filename if (in_array(substr($mode, 0, 1), array('a', 'c', 'w', 'x'))) $filepath = self::getPath($path, false); if (!isset($filepath)) $filepath = self::getPath($path); if ($options & STREAM_USE_PATH) $openedPath = $filepath; $this->_fp = fopen($filepath, $mode); return (bool)$this->_fp; } public function stream_write($data) { return fwrite($this->_fp, $data); } public function unlink($path) { return unlink(self::getPath($path)); } public function url_stat($path, $flags) { try { if ($flags & STREAM_URL_STAT_LINK) return lstat(self::getPath($path)); else return stat(self::getPath($path)); } catch (Exception $e) { if ($flags & STREAM_URL_STAT_QUIET) return false; throw $e; } } } if (!is_dir('/tmp/cache')) mkdir('/tmp/cache'); set_include_path('/tmp'); stream_wrapper_register('react', 'Custom_StreamWrapper'); file_exists('react://cache/react_unittest_filecache'); file_put_contents('react://cache/react_unittest_filecache', 'waa'); echo 'unlink'; unlink('react://cache/react_unittest_filecache'); file_exists('react://cache/react_unittest_filecache');
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 8
Branch analysis from position: 2
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/YGJNG
function name:  (null)
number of ops:  38
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ECHO                                                     '%2Fin%2FYGJNG'
    5     1      > JMPZ                                                     <true>, ->8
    7     2    >   INIT_FCALL                                               'copy'
          3        SEND_VAL                                                 '%2Fin%2FYGJNG'
          4        SEND_VAL                                                 '%2Ftmp%2Fphpng_checkouts_somelongstring-2.0_cli_streamwrap.php'
          5        DO_ICALL                                                 
    8     6        INCLUDE_OR_EVAL                                          '%2Ftmp%2Fphpng_checkouts_somelongstring-2.0_cli_streamwrap.php', REQUIRE_ONCE
    9     7      > RETURN                                                   null
   82     8    >   INIT_FCALL                                               'is_dir'
          9        SEND_VAL                                                 '%2Ftmp%2Fcache'
         10        DO_ICALL                                         $2      
         11        BOOL_NOT                                         ~3      $2
         12      > JMPZ                                                     ~3, ->16
   83    13    >   INIT_FCALL                                               'mkdir'
         14        SEND_VAL                                                 '%2Ftmp%2Fcache'
         15        DO_ICALL                                                 
   84    16    >   INIT_FCALL                                               'set_include_path'
         17        SEND_VAL                                                 '%2Ftmp'
         18        DO_ICALL                                                 
   86    19        INIT_FCALL                                               'stream_wrapper_register'
         20        SEND_VAL                                                 'react'
         21        SEND_VAL                                                 'Custom_StreamWrapper'
         22        DO_ICALL                                                 
   88    23        INIT_FCALL                                               'file_exists'
         24        SEND_VAL                                                 'react%3A%2F%2Fcache%2Freact_unittest_filecache'
         25        DO_ICALL                                                 
   89    26        INIT_FCALL                                               'file_put_contents'
         27        SEND_VAL                                                 'react%3A%2F%2Fcache%2Freact_unittest_filecache'
         28        SEND_VAL                                                 'waa'
         29        DO_ICALL                                                 
   91    30        ECHO                                                     'unlink'
   92    31        INIT_FCALL                                               'unlink'
         32        SEND_VAL                                                 'react%3A%2F%2Fcache%2Freact_unittest_filecache'
         33        DO_ICALL                                                 
   93    34        INIT_FCALL                                               'file_exists'
         35        SEND_VAL                                                 'react%3A%2F%2Fcache%2Freact_unittest_filecache'
         36        DO_ICALL                                                 
         37      > RETURN                                                   1

Class Custom_StreamWrapper:
Function getpath:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 37
Branch analysis from position: 20
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
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YGJNG
function name:  getPath
number of ops:  39
compiled vars:  !0 = $url, !1 = $mustExist, !2 = $parts, !3 = $scheme, !4 = $path
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <true>
   18     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '%3A%2F%2F'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 2
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !2, $5
   20     8        QM_ASSIGN                                        ~7      !2
          9        FETCH_LIST_R                                     $8      ~7, 0
         10        ASSIGN                                                   !3, $8
         11        FETCH_LIST_R                                     $10     ~7, 1
         12        ASSIGN                                                   !4, $10
         13        FREE                                                     ~7
   22    14        INIT_FCALL                                               'stream_resolve_include_path'
         15        SEND_VAR                                                 !4
         16        DO_ICALL                                         $12     
         17        ASSIGN                                                   !4, $12
   24    18        TYPE_CHECK                                    4          !4
         19      > JMPZ                                                     ~14, ->37
   26    20    > > JMPZ                                                     !1, ->25
   28    21    >   NEW                                              $15     'Exception'
         22        SEND_VAL_EX                                              'error'
         23        DO_FCALL                                      0          
         24      > THROW                                         0          $15
   32    25    >   INIT_STATIC_METHOD_CALL                                  'getPath'
         26        INIT_FCALL                                               'dirname'
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                         $17     
         29        SEND_VAR                                                 $17
         30        DO_FCALL                                      0  $18     
         31        CONCAT                                           ~19     $18, '%2F'
         32        INIT_FCALL                                               'basename'
         33        SEND_VAR                                                 !0
         34        DO_ICALL                                         $20     
         35        CONCAT                                           ~21     ~19, $20
         36      > RETURN                                                   ~21
   35    37    > > RETURN                                                   !4
   36    38*     > RETURN                                                   null

End of function getpath

Function stream_open:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 23
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 26
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
Branch analysis from position: 23
Branch analysis from position: 16
filename:       /in/YGJNG
function name:  stream_open
number of ops:  36
compiled vars:  !0 = $path, !1 = $mode, !2 = $options, !3 = $openedPath, !4 = $filepath
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   41     4        INIT_FCALL                                               'substr'
          5        SEND_VAR                                                 !1
          6        SEND_VAL                                                 0
          7        SEND_VAL                                                 1
          8        DO_ICALL                                         $5      
          9        IN_ARRAY                                                 $5, <array>
         10      > JMPZ                                                     ~6, ->16
   42    11    >   INIT_STATIC_METHOD_CALL                                  'getPath'
         12        SEND_VAR                                                 !0
         13        SEND_VAL                                                 <false>
         14        DO_FCALL                                      0  $7      
         15        ASSIGN                                                   !4, $7
   44    16    >   ISSET_ISEMPTY_CV                                 ~9      !4
         17        BOOL_NOT                                         ~10     ~9
         18      > JMPZ                                                     ~10, ->23
   45    19    >   INIT_STATIC_METHOD_CALL                                  'getPath'
         20        SEND_VAR                                                 !0
         21        DO_FCALL                                      0  $11     
         22        ASSIGN                                                   !4, $11
   47    23    >   BW_AND                                           ~13     !2, 1
         24      > JMPZ                                                     ~13, ->26
   48    25    >   ASSIGN                                                   !3, !4
   50    26    >   INIT_FCALL                                               'fopen'
         27        SEND_VAR                                                 !4
         28        SEND_VAR                                                 !1
         29        DO_ICALL                                         $16     
         30        ASSIGN_OBJ                                               '_fp'
         31        OP_DATA                                                  $16
   51    32        FETCH_OBJ_R                                      ~17     '_fp'
         33        BOOL                                             ~18     ~17
         34      > RETURN                                                   ~18
   52    35*     > 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/YGJNG
function name:  stream_write
number of ops:  8
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   RECV                                             !0      
   56     1        INIT_FCALL                                               'fwrite'
          2        FETCH_OBJ_R                                      ~1      '_fp'
          3        SEND_VAL                                                 ~1
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6      > RETURN                                                   $2
   57     7*     > RETURN                                                   null

End of function stream_write

Function unlink:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YGJNG
function name:  unlink
number of ops:  9
compiled vars:  !0 = $path
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   59     0  E >   RECV                                             !0      
   61     1        INIT_FCALL                                               'unlink'
          2        INIT_STATIC_METHOD_CALL                                  'getPath'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $1      
          5        SEND_VAR                                                 $1
          6        DO_ICALL                                         $2      
          7      > RETURN                                                   $2
   62     8*     > RETURN                                                   null

End of function unlink

Function url_stat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 20
Branch analysis from position: 20
2 jumps found. (Code = 107) Position 1 = 21, Position 2 = -2
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 24
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/YGJNG
function name:  url_stat
number of ops:  26
compiled vars:  !0 = $path, !1 = $flags, !2 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   64     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   68     2        BW_AND                                           ~3      !1, 1
          3      > JMPZ                                                     ~3, ->12
   69     4    >   INIT_FCALL                                               'lstat'
          5        INIT_STATIC_METHOD_CALL                                  'getPath'
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0  $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                         $5      
         10      > RETURN                                                   $5
         11*       JMP                                                      ->19
   71    12    >   INIT_FCALL                                               'stat'
         13        INIT_STATIC_METHOD_CALL                                  'getPath'
         14        SEND_VAR                                                 !0
         15        DO_FCALL                                      0  $6      
         16        SEND_VAR                                                 $6
         17        DO_ICALL                                         $7      
         18      > RETURN                                                   $7
         19*       JMP                                                      ->25
   73    20  E > > CATCH                                       last         'Exception'
   75    21    >   BW_AND                                           ~8      !1, 2
         22      > JMPZ                                                     ~8, ->24
   76    23    > > RETURN                                                   <false>
   77    24    > > THROW                                         0          !2
   79    25*     > RETURN                                                   null

End of function url_stat

End of class Custom_StreamWrapper.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.99 ms | 1412 KiB | 47 Q