comparison vendor/guzzlehttp/psr7/src/StreamWrapper.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
36 } else { 36 } else {
37 throw new \InvalidArgumentException('The stream must be readable, ' 37 throw new \InvalidArgumentException('The stream must be readable, '
38 . 'writable, or both.'); 38 . 'writable, or both.');
39 } 39 }
40 40
41 return fopen('guzzle://stream', $mode, null, stream_context_create([ 41 return fopen('guzzle://stream', $mode, null, self::createStreamContext($stream));
42 }
43
44 /**
45 * Creates a stream context that can be used to open a stream as a php stream resource.
46 *
47 * @param StreamInterface $stream
48 *
49 * @return resource
50 */
51 public static function createStreamContext(StreamInterface $stream)
52 {
53 return stream_context_create([
42 'guzzle' => ['stream' => $stream] 54 'guzzle' => ['stream' => $stream]
43 ])); 55 ]);
44 } 56 }
45 57
46 /** 58 /**
47 * Registers the stream wrapper if needed 59 * Registers the stream wrapper if needed
48 */ 60 */
92 $this->stream->seek($offset, $whence); 104 $this->stream->seek($offset, $whence);
93 105
94 return true; 106 return true;
95 } 107 }
96 108
109 public function stream_cast($cast_as)
110 {
111 $stream = clone($this->stream);
112
113 return $stream->detach();
114 }
115
97 public function stream_stat() 116 public function stream_stat()
98 { 117 {
99 static $modeMap = [ 118 static $modeMap = [
100 'r' => 33060, 119 'r' => 33060,
120 'rb' => 33060,
101 'r+' => 33206, 121 'r+' => 33206,
102 'w' => 33188 122 'w' => 33188,
123 'wb' => 33188
103 ]; 124 ];
104 125
105 return [ 126 return [
106 'dev' => 0, 127 'dev' => 0,
107 'ino' => 0, 128 'ino' => 0,
116 'ctime' => 0, 137 'ctime' => 0,
117 'blksize' => 0, 138 'blksize' => 0,
118 'blocks' => 0 139 'blocks' => 0
119 ]; 140 ];
120 } 141 }
142
143 public function url_stat($path, $flags)
144 {
145 return [
146 'dev' => 0,
147 'ino' => 0,
148 'mode' => 0,
149 'nlink' => 0,
150 'uid' => 0,
151 'gid' => 0,
152 'rdev' => 0,
153 'size' => 0,
154 'atime' => 0,
155 'mtime' => 0,
156 'ctime' => 0,
157 'blksize' => 0,
158 'blocks' => 0
159 ];
160 }
121 } 161 }