diff --git a/composer.json b/composer.json index 27df644e5..b367c0112 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "giggsey/libphonenumber-for-php": "^8.12", "guzzlehttp/guzzle": "^7.2", "icewind/searchdav": "^2.0.0", - "icewind/streams": "v0.7.2", + "icewind/streams": "v0.7.4", "league/flysystem": "^1.0", "microsoft/azure-storage-blob": "^1.5", "nextcloud/lognormalizer": "^1.0", diff --git a/composer.lock b/composer.lock index bb51b9eec..d06a20433 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1f3e05d9ba73ccfcdef63d932a860baf", + "content-hash": "db8a9c22e29289400c60e4cb24fd36b4", "packages": [ { "name": "aws/aws-sdk-php", @@ -1462,24 +1462,25 @@ }, { "name": "icewind/streams", - "version": "v0.7.2", + "version": "v0.7.4", "source": { "type": "git", "url": "https://github.com/icewind1991/Streams.git", - "reference": "77d750ccc654c0eda4a41fedb2dbd71053755790" + "reference": "93bce472202d36d9808c30eaa52a1dc72b39e04c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/icewind1991/Streams/zipball/77d750ccc654c0eda4a41fedb2dbd71053755790", - "reference": "77d750ccc654c0eda4a41fedb2dbd71053755790", + "url": "https://api.github.com/repos/icewind1991/Streams/zipball/93bce472202d36d9808c30eaa52a1dc72b39e04c", + "reference": "93bce472202d36d9808c30eaa52a1dc72b39e04c", "shasum": "" }, "require": { - "php": ">=5.6" + "php": ">=7.1" }, "require-dev": { - "php-coveralls/php-coveralls": "v2.1.0", - "phpunit/phpunit": "^5.7" + "friendsofphp/php-cs-fixer": "^2", + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^9" }, "type": "library", "autoload": { @@ -1500,9 +1501,9 @@ "description": "A set of generic stream wrappers", "support": { "issues": "https://github.com/icewind1991/Streams/issues", - "source": "https://github.com/icewind1991/Streams/tree/master" + "source": "https://github.com/icewind1991/Streams/tree/v0.7.4" }, - "time": "2020-04-08T14:59:33+00:00" + "time": "2021-03-12T15:48:22+00:00" }, { "name": "justinrainbow/json-schema", @@ -6042,5 +6043,5 @@ "platform-overrides": { "php": "7.3.0" }, - "plugin-api-version": "2.0.0" + "plugin-api-version": "2.1.0" } diff --git a/composer/InstalledVersions.php b/composer/InstalledVersions.php index bb34f4a83..ffd0e95ff 100644 --- a/composer/InstalledVersions.php +++ b/composer/InstalledVersions.php @@ -32,7 +32,7 @@ class InstalledVersions 'aliases' => array ( ), - 'reference' => '47ef0d3d299f471883102b7bd1712727b9a62d8b', + 'reference' => '1d1f743b8adb5123016837f5d0adcd9414d28bef', 'name' => 'nextcloud/3rdparty', ), 'versions' => @@ -228,12 +228,12 @@ class InstalledVersions ), 'icewind/streams' => array ( - 'pretty_version' => 'v0.7.2', - 'version' => '0.7.2.0', + 'pretty_version' => 'v0.7.4', + 'version' => '0.7.4.0', 'aliases' => array ( ), - 'reference' => '77d750ccc654c0eda4a41fedb2dbd71053755790', + 'reference' => '93bce472202d36d9808c30eaa52a1dc72b39e04c', ), 'justinrainbow/json-schema' => array ( @@ -314,7 +314,7 @@ class InstalledVersions 'aliases' => array ( ), - 'reference' => '47ef0d3d299f471883102b7bd1712727b9a62d8b', + 'reference' => '1d1f743b8adb5123016837f5d0adcd9414d28bef', ), 'nextcloud/lognormalizer' => array ( diff --git a/composer/installed.json b/composer/installed.json index 7bcf9ba56..4d73bc475 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -1515,27 +1515,28 @@ }, { "name": "icewind/streams", - "version": "v0.7.2", - "version_normalized": "0.7.2.0", + "version": "v0.7.4", + "version_normalized": "0.7.4.0", "source": { "type": "git", "url": "https://github.com/icewind1991/Streams.git", - "reference": "77d750ccc654c0eda4a41fedb2dbd71053755790" + "reference": "93bce472202d36d9808c30eaa52a1dc72b39e04c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/icewind1991/Streams/zipball/77d750ccc654c0eda4a41fedb2dbd71053755790", - "reference": "77d750ccc654c0eda4a41fedb2dbd71053755790", + "url": "https://api.github.com/repos/icewind1991/Streams/zipball/93bce472202d36d9808c30eaa52a1dc72b39e04c", + "reference": "93bce472202d36d9808c30eaa52a1dc72b39e04c", "shasum": "" }, "require": { - "php": ">=5.6" + "php": ">=7.1" }, "require-dev": { - "php-coveralls/php-coveralls": "v2.1.0", - "phpunit/phpunit": "^5.7" + "friendsofphp/php-cs-fixer": "^2", + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^9" }, - "time": "2020-04-08T14:59:33+00:00", + "time": "2021-03-12T15:48:22+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -1556,7 +1557,7 @@ "description": "A set of generic stream wrappers", "support": { "issues": "https://github.com/icewind1991/Streams/issues", - "source": "https://github.com/icewind1991/Streams/tree/master" + "source": "https://github.com/icewind1991/Streams/tree/v0.7.4" }, "install-path": "../icewind/streams" }, diff --git a/composer/installed.php b/composer/installed.php index e02d59017..af1522977 100644 --- a/composer/installed.php +++ b/composer/installed.php @@ -6,7 +6,7 @@ 'aliases' => array ( ), - 'reference' => '47ef0d3d299f471883102b7bd1712727b9a62d8b', + 'reference' => '1d1f743b8adb5123016837f5d0adcd9414d28bef', 'name' => 'nextcloud/3rdparty', ), 'versions' => @@ -202,12 +202,12 @@ ), 'icewind/streams' => array ( - 'pretty_version' => 'v0.7.2', - 'version' => '0.7.2.0', + 'pretty_version' => 'v0.7.4', + 'version' => '0.7.4.0', 'aliases' => array ( ), - 'reference' => '77d750ccc654c0eda4a41fedb2dbd71053755790', + 'reference' => '93bce472202d36d9808c30eaa52a1dc72b39e04c', ), 'justinrainbow/json-schema' => array ( @@ -288,7 +288,7 @@ 'aliases' => array ( ), - 'reference' => '47ef0d3d299f471883102b7bd1712727b9a62d8b', + 'reference' => '1d1f743b8adb5123016837f5d0adcd9414d28bef', ), 'nextcloud/lognormalizer' => array ( diff --git a/composer/package-versions-deprecated/src/PackageVersions/Versions.php b/composer/package-versions-deprecated/src/PackageVersions/Versions.php index 1e7f94d8a..9d8c0581b 100644 --- a/composer/package-versions-deprecated/src/PackageVersions/Versions.php +++ b/composer/package-versions-deprecated/src/PackageVersions/Versions.php @@ -54,7 +54,7 @@ final class Versions 'guzzlehttp/psr7' => '1.7.0@53330f47520498c0ae1f61f7e2c90f55690c06a3', 'guzzlehttp/uri-template' => 'v0.2.0@db46525d6d8fee71033b73cc07160f3e5271a8ce', 'icewind/searchdav' => 'v2.0.0@c69806d900c2c9a5954bfabc80178d6eb0d63df4', - 'icewind/streams' => 'v0.7.2@77d750ccc654c0eda4a41fedb2dbd71053755790', + 'icewind/streams' => 'v0.7.4@93bce472202d36d9808c30eaa52a1dc72b39e04c', 'justinrainbow/json-schema' => '5.2.10@2ba9c8c862ecd5510ed16c6340aa9f6eadb4f31b', 'league/flysystem' => '1.1.3@9be3b16c877d477357c015cec057548cf9b2a14a', 'league/mime-type-detection' => '1.7.0@3b9dff8aaf7323590c1d2e443db701eb1f9aa0d3', @@ -120,7 +120,7 @@ final class Versions 'web-auth/cose-lib' => 'v3.3.1@eea6fae63ff5c81bf98c115b1be5f38a69682c16', 'web-auth/metadata-service' => 'v3.3.1@8488d3a832a38cc81c670fce05de1e515c6e64b1', 'web-auth/webauthn-lib' => 'v3.3.1@e411527a41c1013512fccdfce61681eb36484c77', - 'nextcloud/3rdparty' => 'dev-master@47ef0d3d299f471883102b7bd1712727b9a62d8b', + 'nextcloud/3rdparty' => 'dev-master@1d1f743b8adb5123016837f5d0adcd9414d28bef', ); private function __construct() diff --git a/icewind/streams/.gitignore b/icewind/streams/.gitignore index e2a9a5109..a8fa5d4a9 100644 --- a/icewind/streams/.gitignore +++ b/icewind/streams/.gitignore @@ -3,3 +3,4 @@ vendor composer.lock build example.php +*.cache diff --git a/icewind/streams/src/CallbackWrapper.php b/icewind/streams/src/CallbackWrapper.php index be62e3f66..5d78b5a3d 100644 --- a/icewind/streams/src/CallbackWrapper.php +++ b/icewind/streams/src/CallbackWrapper.php @@ -25,27 +25,27 @@ */ class CallbackWrapper extends Wrapper { /** - * @var callable + * @var callable|null */ protected $readCallback; /** - * @var callable + * @var callable|null */ protected $writeCallback; /** - * @var callable + * @var callable|null */ protected $closeCallback; /** - * @var callable + * @var callable|null */ protected $readDirCallBack; /** - * @var callable + * @var callable|null */ protected $preCloseCallback; @@ -63,11 +63,11 @@ class CallbackWrapper extends Wrapper { */ public static function wrap($source, $read = null, $write = null, $close = null, $readDir = null, $preClose = null) { $context = [ - 'source' => $source, - 'read' => $read, - 'write' => $write, - 'close' => $close, - 'readDir' => $readDir, + 'source' => $source, + 'read' => $read, + 'write' => $write, + 'close' => $close, + 'readDir' => $readDir, 'preClose' => $preClose, ]; return self::wrapSource($source, $context); diff --git a/icewind/streams/src/CountWrapper.php b/icewind/streams/src/CountWrapper.php index d02434012..b3346209a 100644 --- a/icewind/streams/src/CountWrapper.php +++ b/icewind/streams/src/CountWrapper.php @@ -64,7 +64,7 @@ public static function wrap($source, $callback) { throw new \InvalidArgumentException('Invalid or missing callback'); } return self::wrapSource($source, [ - 'source' => $source, + 'source' => $source, 'callback' => $callback ]); } diff --git a/icewind/streams/src/File.php b/icewind/streams/src/File.php index 252b7b897..9662414a7 100644 --- a/icewind/streams/src/File.php +++ b/icewind/streams/src/File.php @@ -15,7 +15,7 @@ interface File { * @param string $path * @param string $mode * @param int $options - * @param string &$opened_path + * @param string $opened_path * @return bool */ public function stream_open($path, $mode, $options, &$opened_path); @@ -28,19 +28,19 @@ public function stream_open($path, $mode, $options, &$opened_path); public function stream_seek($offset, $whence = SEEK_SET); /** - * @return int + * @return int|false */ public function stream_tell(); /** * @param int $count - * @return string + * @return string|false */ public function stream_read($count); /** * @param string $data - * @return int + * @return int|false */ public function stream_write($data); @@ -59,7 +59,7 @@ public function stream_set_option($option, $arg1, $arg2); public function stream_truncate($size); /** - * @return array + * @return array|false */ public function stream_stat(); diff --git a/icewind/streams/src/HashWrapper.php b/icewind/streams/src/HashWrapper.php index 0628d8bc7..616c2fe50 100644 --- a/icewind/streams/src/HashWrapper.php +++ b/icewind/streams/src/HashWrapper.php @@ -23,16 +23,15 @@ namespace Icewind\Streams; - abstract class HashWrapper extends Wrapper { /** - * @var callable + * @var callable|null */ private $callback; /** - * @var resource + * @var resource|\HashContext */ private $hashContext; @@ -48,7 +47,7 @@ abstract class HashWrapper extends Wrapper { */ public static function wrap($source, $hash, $callback) { $context = [ - 'hash' => $hash, + 'hash' => $hash, 'callback' => $callback, ]; return self::wrapSource($source, $context); @@ -76,5 +75,4 @@ public function stream_close() { } return parent::stream_close(); } - -} \ No newline at end of file +} diff --git a/icewind/streams/src/IteratorDirectory.php b/icewind/streams/src/IteratorDirectory.php index 057c1992f..a3872ddf4 100644 --- a/icewind/streams/src/IteratorDirectory.php +++ b/icewind/streams/src/IteratorDirectory.php @@ -42,7 +42,7 @@ protected function loadContext($name = null) { $context = parent::loadContext($name); if (isset($context['iterator'])) { $this->iterator = $context['iterator']; - } else if (isset($context['array'])) { + } elseif (isset($context['array'])) { $this->iterator = new \ArrayIterator($context['array']); } else { throw new \BadMethodCallException('Invalid context, iterator or array not set'); @@ -101,7 +101,7 @@ public static function wrap($source) { $options = [ 'iterator' => $source ]; - } else if (is_array($source)) { + } elseif (is_array($source)) { $options = [ 'array' => $source ]; diff --git a/icewind/streams/src/SeekableWrapper.php b/icewind/streams/src/SeekableWrapper.php index f7abbc514..f131e7530 100644 --- a/icewind/streams/src/SeekableWrapper.php +++ b/icewind/streams/src/SeekableWrapper.php @@ -63,7 +63,7 @@ public function stream_read($count) { public function stream_seek($offset, $whence = SEEK_SET) { if ($whence === SEEK_SET) { $target = $offset; - } else if ($whence === SEEK_CUR) { + } elseif ($whence === SEEK_CUR) { $current = ftell($this->cache); $target = $current + $offset; } else { diff --git a/icewind/streams/src/Url.php b/icewind/streams/src/Url.php index d6822608a..38cbbdd89 100644 --- a/icewind/streams/src/Url.php +++ b/icewind/streams/src/Url.php @@ -22,7 +22,7 @@ public function dir_opendir($path, $options); * @param string $path * @param string $mode * @param int $options - * @param string &$opened_path + * @param string $opened_path * @return bool */ public function stream_open($path, $mode, $options, &$opened_path); @@ -50,7 +50,7 @@ public function rename($source, $target); public function rmdir($path, $options); /** - * @param string + * @param string $path * @return bool */ public function unlink($path); @@ -58,7 +58,7 @@ public function unlink($path); /** * @param string $path * @param int $flags - * @return array + * @return array|false */ public function url_stat($path, $flags); } diff --git a/icewind/streams/src/UrlCallback.php b/icewind/streams/src/UrlCallback.php index 02dca15f9..09ba2aefe 100644 --- a/icewind/streams/src/UrlCallback.php +++ b/icewind/streams/src/UrlCallback.php @@ -48,17 +48,25 @@ class UrlCallback extends Wrapper implements Url { * * @throws \BadMethodCallException */ - public static function wrap($source, $fopen = null, $opendir = null, $mkdir = null, $rename = null, $rmdir = null, - $unlink = null, $stat = null) { + public static function wrap( + $source, + $fopen = null, + $opendir = null, + $mkdir = null, + $rename = null, + $rmdir = null, + $unlink = null, + $stat = null + ) { return new Path(static::class, [ - 'source' => $source, - 'fopen' => $fopen, + 'source' => $source, + 'fopen' => $fopen, 'opendir' => $opendir, - 'mkdir' => $mkdir, - 'rename' => $rename, - 'rmdir' => $rmdir, - 'unlink' => $unlink, - 'stat' => $stat + 'mkdir' => $mkdir, + 'rename' => $rename, + 'rmdir' => $rmdir, + 'unlink' => $unlink, + 'stat' => $stat ]); } diff --git a/icewind/streams/src/Wrapper.php b/icewind/streams/src/Wrapper.php index abadab4dc..03d0b2025 100644 --- a/icewind/streams/src/Wrapper.php +++ b/icewind/streams/src/Wrapper.php @@ -62,14 +62,13 @@ public function stream_write($data) { public function stream_set_option($option, $arg1, $arg2) { switch ($option) { case STREAM_OPTION_BLOCKING: - stream_set_blocking($this->source, $arg1); - break; + return stream_set_blocking($this->source, (bool)$arg1); case STREAM_OPTION_READ_TIMEOUT: - stream_set_timeout($this->source, $arg1, $arg2); - break; + return stream_set_timeout($this->source, $arg1, $arg2); case STREAM_OPTION_WRITE_BUFFER: - stream_set_write_buffer($this->source, $arg1); + return stream_set_write_buffer($this->source, $arg1) === 0; } + return false; } public function stream_truncate($size) { @@ -93,7 +92,9 @@ public function stream_eof() { } public function stream_close() { - return fclose($this->source); + if (is_resource($this->source)) { + return fclose($this->source); + } } public function dir_readdir() { diff --git a/icewind/streams/src/WrapperHandler.php b/icewind/streams/src/WrapperHandler.php index 72dc71485..52a02feb1 100644 --- a/icewind/streams/src/WrapperHandler.php +++ b/icewind/streams/src/WrapperHandler.php @@ -21,8 +21,10 @@ namespace Icewind\Streams; - class WrapperHandler { + /** @var resource $context */ + protected $context; + const NO_SOURCE_DIR = 1; /** diff --git a/icewind/streams/src/WriteHashWrapper.php b/icewind/streams/src/WriteHashWrapper.php index 854845ad1..279d9fd10 100644 --- a/icewind/streams/src/WriteHashWrapper.php +++ b/icewind/streams/src/WriteHashWrapper.php @@ -34,4 +34,4 @@ public function stream_write($data) { $this->updateHash($data); return parent::stream_write($data); } -} \ No newline at end of file +}