| @@ -79,16 +79,22 @@ | ||
| 79 | 79 | |
| 80 | 80 | public function testException() | 
| 81 | 81 |      { | 
| 82 | -        try { | |
| 82 | + try | |
| 83 | +        { | |
| 83 | 84 |              fopen('spiral://non-exists', 'rb'); | 
| 84 | -        } catch (\Throwable $e) { | |
| 85 | + } | |
| 86 | + catch (\Throwable $e) | |
| 87 | +        { | |
| 85 | 88 |              $this->assertStringContainsString('failed to open stream', $e->getMessage()); | 
| 86 | 89 | } | 
| 87 | 90 | |
| 88 | 91 | |
| 89 | -        try { | |
| 92 | + try | |
| 93 | +        { | |
| 90 | 94 |              filemtime('spiral://non-exists'); | 
| 91 | -        } catch (\Throwable $e) { | |
| 95 | + } | |
| 96 | + catch (\Throwable $e) | |
| 97 | +        { | |
| 92 | 98 |              $this->assertStringContainsString('stat failed', $e->getMessage()); | 
| 93 | 99 | } | 
| 94 | 100 | } | 
| @@ -71,7 +71,8 @@ discard block | ||
| 71 | 71 | */ | 
| 72 | 72 | public function stream_open($path, $mode, $options, &$opened_path) | 
| 73 | 73 |      { | 
| 74 | -        if (!isset(self::$uris[$path])) { | |
| 74 | + if (!isset(self::$uris[$path])) | |
| 75 | +        { | |
| 75 | 76 | return false; | 
| 76 | 77 | } | 
| 77 | 78 | |
| @@ -155,7 +156,8 @@ discard block | ||
| 155 | 156 | */ | 
| 156 | 157 | public function url_stat($path, $flags) | 
| 157 | 158 |      { | 
| 158 | -        if (!isset(self::$uris[$path])) { | |
| 159 | + if (!isset(self::$uris[$path])) | |
| 160 | +        { | |
| 159 | 161 | return null; | 
| 160 | 162 | } | 
| 161 | 163 | |
| @@ -171,12 +173,15 @@ discard block | ||
| 171 | 173 | private function getStreamStats(StreamInterface $stream) | 
| 172 | 174 |      { | 
| 173 | 175 | $mode = $this->mode; | 
| 174 | -        if (empty($mode)) { | |
| 175 | -            if ($stream->isReadable()) { | |
| 176 | + if (empty($mode)) | |
| 177 | +        { | |
| 178 | + if ($stream->isReadable()) | |
| 179 | +            { | |
| 176 | 180 | $mode = 'r'; | 
| 177 | 181 | } | 
| 178 | 182 | |
| 179 | -            if ($stream->isWritable()) { | |
| 183 | + if ($stream->isWritable()) | |
| 184 | +            { | |
| 180 | 185 | $mode = !empty($mode) ? 'r+' : 'w'; | 
| 181 | 186 | } | 
| 182 | 187 | } | 
| @@ -203,7 +208,8 @@ discard block | ||
| 203 | 208 | */ | 
| 204 | 209 | public static function register() | 
| 205 | 210 |      { | 
| 206 | -        if (self::$registered) { | |
| 211 | + if (self::$registered) | |
| 212 | +        { | |
| 207 | 213 | return; | 
| 208 | 214 | } | 
| 209 | 215 | |
| @@ -219,7 +225,8 @@ discard block | ||
| 219 | 225 | */ | 
| 220 | 226 | public static function has($file) | 
| 221 | 227 |      { | 
| 222 | -        if ($file instanceof StreamInterface) { | |
| 228 | + if ($file instanceof StreamInterface) | |
| 229 | +        { | |
| 223 | 230 | $file = 'spiral://' . spl_object_hash($file); | 
| 224 | 231 | } | 
| 225 | 232 | |
| @@ -237,15 +244,18 @@ discard block | ||
| 237 | 244 | public static function getResource(StreamInterface $stream) | 
| 238 | 245 |      { | 
| 239 | 246 | $mode = null; | 
| 240 | -        if ($stream->isReadable()) { | |
| 247 | + if ($stream->isReadable()) | |
| 248 | +        { | |
| 241 | 249 | $mode = 'r'; | 
| 242 | 250 | } | 
| 243 | 251 | |
| 244 | -        if ($stream->isWritable()) { | |
| 252 | + if ($stream->isWritable()) | |
| 253 | +        { | |
| 245 | 254 | $mode = !empty($mode) ? 'r+' : 'w'; | 
| 246 | 255 | } | 
| 247 | 256 | |
| 248 | -        if (empty($mode)) { | |
| 257 | + if (empty($mode)) | |
| 258 | +        { | |
| 249 | 259 |              throw new WrapperException("Stream is not available in read or write modes"); | 
| 250 | 260 | } | 
| 251 | 261 | |
| @@ -276,7 +286,8 @@ discard block | ||
| 276 | 286 | */ | 
| 277 | 287 | public static function release($file) | 
| 278 | 288 |      { | 
| 279 | -        if ($file instanceof StreamInterface) { | |
| 289 | + if ($file instanceof StreamInterface) | |
| 290 | +        { | |
| 280 | 291 | $file = 'spiral://' . spl_object_hash($file); | 
| 281 | 292 | } | 
| 282 | 293 | |