diff --git a/composer.json b/composer.json index 55fd961fb..5a77aea05 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "symfony/process": "^3.0.0", "pimple/pimple": "3.0.2", "nikic/php-parser": "1.4.1", - "icewind/Streams": "0.4.1", + "icewind/Streams": "0.5.2", "swiftmailer/swiftmailer": "@stable", "guzzlehttp/guzzle": "~5.3", "league/flysystem": "1.0.20", diff --git a/composer.lock b/composer.lock index cdafd5c05..323edd09f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "3749a5f91116e837760dac2f5f8564f3", + "content-hash": "7290519d34bd41afe627af2d2eca5db7", "packages": [ { "name": "bantu/ini-get-wrapper", @@ -904,16 +904,16 @@ }, { "name": "icewind/streams", - "version": "0.4.1", + "version": "0.5.2", "source": { "type": "git", "url": "https://github.com/icewind1991/Streams.git", - "reference": "d3620e8dc410c86c2ba55579803679c4e0b289ac" + "reference": "6bfd2fdbd99319f5e010d0a684409189a562cb1e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/icewind1991/Streams/zipball/d3620e8dc410c86c2ba55579803679c4e0b289ac", - "reference": "d3620e8dc410c86c2ba55579803679c4e0b289ac", + "url": "https://api.github.com/repos/icewind1991/Streams/zipball/6bfd2fdbd99319f5e010d0a684409189a562cb1e", + "reference": "6bfd2fdbd99319f5e010d0a684409189a562cb1e", "shasum": "" }, "require": { @@ -941,7 +941,7 @@ } ], "description": "A set of generic stream wrappers", - "time": "2016-06-02T14:37:52+00:00" + "time": "2016-12-02T14:21:23+00:00" }, { "name": "interfasys/lognormalizer", diff --git a/composer/autoload_classmap.php b/composer/autoload_classmap.php index 7b3bf560f..9208fa21d 100644 --- a/composer/autoload_classmap.php +++ b/composer/autoload_classmap.php @@ -612,8 +612,23 @@ 'Icewind\\Streams\\IteratorDirectory' => $vendorDir . '/icewind/streams/src/IteratorDirectory.php', 'Icewind\\Streams\\NullWrapper' => $vendorDir . '/icewind/streams/src/NullWrapper.php', 'Icewind\\Streams\\Path' => $vendorDir . '/icewind/streams/src/Path.php', + 'Icewind\\Streams\\PathWrapper' => $vendorDir . '/icewind/streams/src/PathWrapper.php', 'Icewind\\Streams\\RetryWrapper' => $vendorDir . '/icewind/streams/src/RetryWrapper.php', 'Icewind\\Streams\\SeekableWrapper' => $vendorDir . '/icewind/streams/src/SeekableWrapper.php', + 'Icewind\\Streams\\Tests\\CallbackWrapper' => $vendorDir . '/icewind/streams/tests/CallbackWrapper.php', + 'Icewind\\Streams\\Tests\\DirectoryFilter' => $vendorDir . '/icewind/streams/tests/DirectoryFilter.php', + 'Icewind\\Streams\\Tests\\DirectoryWrapper' => $vendorDir . '/icewind/streams/tests/DirectoryWrapper.php', + 'Icewind\\Streams\\Tests\\DirectoryWrapperDummy' => $vendorDir . '/icewind/streams/tests/DirectoryWrapper.php', + 'Icewind\\Streams\\Tests\\DirectoryWrapperNull' => $vendorDir . '/icewind/streams/tests/DirectoryWrapper.php', + 'Icewind\\Streams\\Tests\\FailWrapper' => $vendorDir . '/icewind/streams/tests/RetryWrapper.php', + 'Icewind\\Streams\\Tests\\IteratorDirectory' => $vendorDir . '/icewind/streams/tests/IteratorDirectory.php', + 'Icewind\\Streams\\Tests\\NullWrapper' => $vendorDir . '/icewind/streams/tests/NullWrapper.php', + 'Icewind\\Streams\\Tests\\PartialWrapper' => $vendorDir . '/icewind/streams/tests/RetryWrapper.php', + 'Icewind\\Streams\\Tests\\PathWrapper' => $vendorDir . '/icewind/streams/tests/PathWrapper.php', + 'Icewind\\Streams\\Tests\\RetryWrapper' => $vendorDir . '/icewind/streams/tests/RetryWrapper.php', + 'Icewind\\Streams\\Tests\\SeekableWrapper' => $vendorDir . '/icewind/streams/tests/SeekableWrapper.php', + 'Icewind\\Streams\\Tests\\UrlCallBack' => $vendorDir . '/icewind/streams/tests/UrlCallBack.php', + 'Icewind\\Streams\\Tests\\Wrapper' => $vendorDir . '/icewind/streams/tests/Wrapper.php', 'Icewind\\Streams\\Url' => $vendorDir . '/icewind/streams/src/Url.php', 'Icewind\\Streams\\UrlCallback' => $vendorDir . '/icewind/streams/src/UrlCallBack.php', 'Icewind\\Streams\\Wrapper' => $vendorDir . '/icewind/streams/src/Wrapper.php', diff --git a/composer/autoload_static.php b/composer/autoload_static.php index 2d68c7771..479311c82 100644 --- a/composer/autoload_static.php +++ b/composer/autoload_static.php @@ -932,8 +932,23 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 'Icewind\\Streams\\IteratorDirectory' => __DIR__ . '/..' . '/icewind/streams/src/IteratorDirectory.php', 'Icewind\\Streams\\NullWrapper' => __DIR__ . '/..' . '/icewind/streams/src/NullWrapper.php', 'Icewind\\Streams\\Path' => __DIR__ . '/..' . '/icewind/streams/src/Path.php', + 'Icewind\\Streams\\PathWrapper' => __DIR__ . '/..' . '/icewind/streams/src/PathWrapper.php', 'Icewind\\Streams\\RetryWrapper' => __DIR__ . '/..' . '/icewind/streams/src/RetryWrapper.php', 'Icewind\\Streams\\SeekableWrapper' => __DIR__ . '/..' . '/icewind/streams/src/SeekableWrapper.php', + 'Icewind\\Streams\\Tests\\CallbackWrapper' => __DIR__ . '/..' . '/icewind/streams/tests/CallbackWrapper.php', + 'Icewind\\Streams\\Tests\\DirectoryFilter' => __DIR__ . '/..' . '/icewind/streams/tests/DirectoryFilter.php', + 'Icewind\\Streams\\Tests\\DirectoryWrapper' => __DIR__ . '/..' . '/icewind/streams/tests/DirectoryWrapper.php', + 'Icewind\\Streams\\Tests\\DirectoryWrapperDummy' => __DIR__ . '/..' . '/icewind/streams/tests/DirectoryWrapper.php', + 'Icewind\\Streams\\Tests\\DirectoryWrapperNull' => __DIR__ . '/..' . '/icewind/streams/tests/DirectoryWrapper.php', + 'Icewind\\Streams\\Tests\\FailWrapper' => __DIR__ . '/..' . '/icewind/streams/tests/RetryWrapper.php', + 'Icewind\\Streams\\Tests\\IteratorDirectory' => __DIR__ . '/..' . '/icewind/streams/tests/IteratorDirectory.php', + 'Icewind\\Streams\\Tests\\NullWrapper' => __DIR__ . '/..' . '/icewind/streams/tests/NullWrapper.php', + 'Icewind\\Streams\\Tests\\PartialWrapper' => __DIR__ . '/..' . '/icewind/streams/tests/RetryWrapper.php', + 'Icewind\\Streams\\Tests\\PathWrapper' => __DIR__ . '/..' . '/icewind/streams/tests/PathWrapper.php', + 'Icewind\\Streams\\Tests\\RetryWrapper' => __DIR__ . '/..' . '/icewind/streams/tests/RetryWrapper.php', + 'Icewind\\Streams\\Tests\\SeekableWrapper' => __DIR__ . '/..' . '/icewind/streams/tests/SeekableWrapper.php', + 'Icewind\\Streams\\Tests\\UrlCallBack' => __DIR__ . '/..' . '/icewind/streams/tests/UrlCallBack.php', + 'Icewind\\Streams\\Tests\\Wrapper' => __DIR__ . '/..' . '/icewind/streams/tests/Wrapper.php', 'Icewind\\Streams\\Url' => __DIR__ . '/..' . '/icewind/streams/src/Url.php', 'Icewind\\Streams\\UrlCallback' => __DIR__ . '/..' . '/icewind/streams/src/UrlCallBack.php', 'Icewind\\Streams\\Wrapper' => __DIR__ . '/..' . '/icewind/streams/src/Wrapper.php', diff --git a/composer/installed.json b/composer/installed.json index b2e877178..1d5f55907 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -1753,49 +1753,6 @@ "minification" ] }, - { - "name": "icewind/streams", - "version": "0.4.1", - "version_normalized": "0.4.1.0", - "source": { - "type": "git", - "url": "https://github.com/icewind1991/Streams.git", - "reference": "d3620e8dc410c86c2ba55579803679c4e0b289ac" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/icewind1991/Streams/zipball/d3620e8dc410c86c2ba55579803679c4e0b289ac", - "reference": "d3620e8dc410c86c2ba55579803679c4e0b289ac", - "shasum": "" - }, - "require": { - "php": ">=5.3" - }, - "require-dev": { - "phpunit/phpunit": "^4.8", - "satooshi/php-coveralls": "v1.0.0" - }, - "time": "2016-06-02T14:37:52+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "Icewind\\Streams\\Tests\\": "tests/", - "Icewind\\Streams\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Robin Appelman", - "email": "icewind@owncloud.com" - } - ], - "description": "A set of generic stream wrappers" - }, { "name": "guzzlehttp/guzzle", "version": "5.3.1", @@ -3044,5 +3001,48 @@ "scss", "stylesheet" ] + }, + { + "name": "icewind/streams", + "version": "0.5.2", + "version_normalized": "0.5.2.0", + "source": { + "type": "git", + "url": "https://github.com/icewind1991/Streams.git", + "reference": "6bfd2fdbd99319f5e010d0a684409189a562cb1e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/icewind1991/Streams/zipball/6bfd2fdbd99319f5e010d0a684409189a562cb1e", + "reference": "6bfd2fdbd99319f5e010d0a684409189a562cb1e", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "^4.8", + "satooshi/php-coveralls": "v1.0.0" + }, + "time": "2016-12-02T14:21:23+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Icewind\\Streams\\Tests\\": "tests/", + "Icewind\\Streams\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Robin Appelman", + "email": "icewind@owncloud.com" + } + ], + "description": "A set of generic stream wrappers" } ] diff --git a/icewind/streams/src/CallbackWrapper.php b/icewind/streams/src/CallbackWrapper.php index c5847b95f..4eef55681 100644 --- a/icewind/streams/src/CallbackWrapper.php +++ b/icewind/streams/src/CallbackWrapper.php @@ -107,6 +107,8 @@ public function stream_close() { $result = parent::stream_close(); if (is_callable($this->closeCallback)) { call_user_func($this->closeCallback); + // prevent further calls by potential PHP 7 GC ghosts + $this->closeCallback = null; } return $result; } diff --git a/icewind/streams/src/Path.php b/icewind/streams/src/Path.php index 46d2156b6..bef9fd5f6 100644 --- a/icewind/streams/src/Path.php +++ b/icewind/streams/src/Path.php @@ -56,7 +56,7 @@ public function wrapPath($path) { protected function register() { if (!$this->registered) { - $this->appendDefaultContent($this->getProtocol(), $this->contextOptions); + $this->appendDefaultContent($this->contextOptions); stream_wrapper_register($this->getProtocol(), $this->class); $this->registered = true; } @@ -71,13 +71,17 @@ protected function unregister() { /** * Add values to the default stream context * - * @param string $key * @param array $values */ - protected function appendDefaultContent($key, $values) { + protected function appendDefaultContent($values) { + if (!is_array(current($values))) { + $values = array($this->getProtocol() => $values); + } $context = stream_context_get_default(); $defaults = stream_context_get_options($context); - $defaults[$key] = $values; + foreach ($values as $key => $value) { + $defaults[$key] = $value; + } stream_context_set_default($defaults); } diff --git a/icewind/streams/src/PathWrapper.php b/icewind/streams/src/PathWrapper.php new file mode 100644 index 000000000..88af7e17b --- /dev/null +++ b/icewind/streams/src/PathWrapper.php @@ -0,0 +1,25 @@ + + * This file is licensed under the Licensed under the MIT license: + * http://opensource.org/licenses/MIT + */ + +namespace Icewind\Streams; + +/** + * A string-like object that maps to an existing stream when opened + */ +class PathWrapper extends NullWrapper { + /** + * @param resource $source + * @return Path|string + */ + public static function getPath($source) { + return new Path(__CLASS__, [ + 'null' => [ + 'source' => $source + ] + ]); + } +} diff --git a/icewind/streams/src/Wrapper.php b/icewind/streams/src/Wrapper.php index 53de2942c..8e52eff9a 100644 --- a/icewind/streams/src/Wrapper.php +++ b/icewind/streams/src/Wrapper.php @@ -53,7 +53,7 @@ protected function loadContext($name) { if (isset($context[$name])) { $context = $context[$name]; } else { - throw new \BadMethodCallException('Invalid context, "callable" options not set'); + throw new \BadMethodCallException('Invalid context, "' . $name . '" options not set'); } if (isset($context['source']) and is_resource($context['source'])) { $this->setSourceStream($context['source']);