From 4b9bb3266a537e59b10a2932f05dca47333420fc Mon Sep 17 00:00:00 2001 From: Marek Hajer Date: Mon, 29 Feb 2016 21:18:30 +0100 Subject: [PATCH] SafeStream: unregister protocols in cleaner way [Closes #6] --- src/SafeStream/SafeStream.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/SafeStream/SafeStream.php b/src/SafeStream/SafeStream.php index cce379c..2f8c449 100644 --- a/src/SafeStream/SafeStream.php +++ b/src/SafeStream/SafeStream.php @@ -50,9 +50,10 @@ class SafeStream */ public static function register() { - @stream_wrapper_unregister('safe'); // old protocol - stream_wrapper_register('safe', __CLASS__); - @stream_wrapper_unregister(self::PROTOCOL); // intentionally @ + foreach (array_intersect(stream_get_wrappers(), array('safe', self::PROTOCOL)) as $name) { + stream_wrapper_unregister($name); + } + stream_wrapper_register('safe', __CLASS__); // old protocol return stream_wrapper_register(self::PROTOCOL, __CLASS__); }