mirror of
https://codeberg.org/icewind/streams.git
synced 2026-06-04 00:54:08 +02:00
Better cleanup of registered streams
This commit is contained in:
parent
214a31bc98
commit
99ecfc5287
4 changed files with 26 additions and 7 deletions
|
|
@ -16,14 +16,21 @@ class NullWrapper extends Wrapper {
|
|||
*
|
||||
* @param resource $source
|
||||
* @return resource
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public static function wrap($source) {
|
||||
stream_wrapper_register('null', '\Icewind\Streams\NullWrapper');
|
||||
$context = stream_context_create(array(
|
||||
'null' => array(
|
||||
'source' => $source)
|
||||
));
|
||||
$wrapped = fopen('null://', 'r+', false, $context);
|
||||
stream_wrapper_register('null', '\Icewind\Streams\NullWrapper');
|
||||
try {
|
||||
$wrapped = fopen('null://', 'r+', false, $context);
|
||||
} catch (\BadMethodCallException $e) {
|
||||
stream_wrapper_unregister('null');
|
||||
throw $e;
|
||||
}
|
||||
stream_wrapper_unregister('null');
|
||||
return $wrapped;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue