1--TEST-- 2bug 40459 - Test whether the constructor of the user-space stream wrapper is called when stream functions are called 3--INI-- 4allow_url_fopen=1 5--FILE-- 6<?php 7// Test whether the constructor of the user-space stream wrapper is called when stream functions are called 8class testwrapper { 9 public $context; 10 private $constructorCalled = false; 11 function __construct() { 12 $this->constructorCalled = true; 13 } 14 15 function stream_open($path, $mode, $options, &$opened_path) 16 { 17 echo $this->constructorCalled ? 'yes' : 'no'; 18 return true; 19 } 20 21 function url_stat($url, $flags) 22 { 23 echo $this->constructorCalled ? 'yes' : 'no'; 24 return array(); 25 } 26 27 function unlink($url) 28 { 29 echo $this->constructorCalled ? 'yes' : 'no'; 30 } 31 32 function rename($from, $to) 33 { 34 echo $this->constructorCalled ? 'yes' : 'no'; 35 } 36 37 function mkdir($dir, $mode, $options) 38 { 39 echo $this->constructorCalled ? 'yes' : 'no'; 40 } 41 42 function rmdir($dir, $options) 43 { 44 echo $this->constructorCalled ? 'yes' : 'no'; 45 } 46 47 function dir_opendir($url, $options) 48 { 49 echo $this->constructorCalled ? 'yes' : 'no'; 50 return TRUE; 51 } 52 function stream_metadata() 53 { 54 echo $this->constructorCalled ? 'yes' : 'no'; 55 return TRUE; 56 } 57} 58 59stream_wrapper_register('test', 'testwrapper', STREAM_IS_URL); 60 61echo 'stream_open: '; 62fopen('test://test', 'r'); 63echo "\n"; 64 65echo 'url_stat: '; 66stat('test://test'); 67echo "\n"; 68 69echo 'dir_opendir: '; 70opendir('test://test'); 71echo "\n"; 72 73echo 'rmdir: '; 74rmdir('test://test'); 75echo "\n"; 76 77echo 'mkdir: '; 78mkdir('test://test'); 79echo "\n"; 80 81echo 'rename: '; 82rename('test://test', 'test://test2'); 83echo "\n"; 84 85echo 'unlink: '; 86unlink('test://test'); 87echo "\n"; 88 89echo 'touch: '; 90touch('test://test', time()); 91echo "\n"; 92 93 94 95?> 96--EXPECT-- 97stream_open: yes 98url_stat: yes 99dir_opendir: yes 100rmdir: yes 101mkdir: yes 102rename: yes 103unlink: yes 104touch: yes 105