From d12a875229250f3368eaf2295b7fd87b7dd51810 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Fri, 8 Oct 2021 11:24:15 +0200 Subject: [PATCH] Update icewind/streams to 0.7.5 Signed-off-by: Vincent Petry --- composer.json | 2 +- composer.lock | 21 ++++++++------- composer/installed.json | 21 ++++++++------- composer/installed.php | 10 +++---- .../src/PackageVersions/Versions.php | 4 +-- icewind/streams/.gitignore | 1 + icewind/streams/.scrutinizer.yml | 13 ---------- icewind/streams/src/CallbackWrapper.php | 20 +++++++------- icewind/streams/src/CountWrapper.php | 2 +- icewind/streams/src/File.php | 10 +++---- icewind/streams/src/HashWrapper.php | 10 +++---- icewind/streams/src/IteratorDirectory.php | 4 +-- icewind/streams/src/SeekableWrapper.php | 2 +- icewind/streams/src/Url.php | 6 ++--- icewind/streams/src/UrlCallback.php | 26 ++++++++++++------- icewind/streams/src/Wrapper.php | 13 +++++----- icewind/streams/src/WrapperHandler.php | 8 +++--- icewind/streams/src/WriteHashWrapper.php | 2 +- 18 files changed, 87 insertions(+), 88 deletions(-) delete mode 100644 icewind/streams/.scrutinizer.yml diff --git a/composer.json b/composer.json index 42aeee816..c6b9ad7c0 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.5", "league/flysystem": "^1.0", "microsoft/azure-storage-blob": "^1.5", "nextcloud/lognormalizer": "^1.0", diff --git a/composer.lock b/composer.lock index 5b7db2621..36674b0d6 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": "4d4217a542dabeb47e9bb783dee9a10d", + "content-hash": "a9accd4099809e3c525713a5db3e25f9", "packages": [ { "name": "aws/aws-sdk-php", @@ -1462,24 +1462,25 @@ }, { "name": "icewind/streams", - "version": "v0.7.2", + "version": "v0.7.5", "source": { "type": "git", "url": "https://github.com/icewind1991/Streams.git", - "reference": "77d750ccc654c0eda4a41fedb2dbd71053755790" + "reference": "0c6aae16ebdadb257f0bd089c1e1e4cf5e20ddc2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/icewind1991/Streams/zipball/77d750ccc654c0eda4a41fedb2dbd71053755790", - "reference": "77d750ccc654c0eda4a41fedb2dbd71053755790", + "url": "https://api.github.com/repos/icewind1991/Streams/zipball/0c6aae16ebdadb257f0bd089c1e1e4cf5e20ddc2", + "reference": "0c6aae16ebdadb257f0bd089c1e1e4cf5e20ddc2", "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.5" }, - "time": "2020-04-08T14:59:33+00:00" + "time": "2021-06-14T14:02:48+00:00" }, { "name": "justinrainbow/json-schema", diff --git a/composer/installed.json b/composer/installed.json index aee4cd6c7..d68041198 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -1519,27 +1519,28 @@ }, { "name": "icewind/streams", - "version": "v0.7.2", - "version_normalized": "0.7.2.0", + "version": "v0.7.5", + "version_normalized": "0.7.5.0", "source": { "type": "git", "url": "https://github.com/icewind1991/Streams.git", - "reference": "77d750ccc654c0eda4a41fedb2dbd71053755790" + "reference": "0c6aae16ebdadb257f0bd089c1e1e4cf5e20ddc2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/icewind1991/Streams/zipball/77d750ccc654c0eda4a41fedb2dbd71053755790", - "reference": "77d750ccc654c0eda4a41fedb2dbd71053755790", + "url": "https://api.github.com/repos/icewind1991/Streams/zipball/0c6aae16ebdadb257f0bd089c1e1e4cf5e20ddc2", + "reference": "0c6aae16ebdadb257f0bd089c1e1e4cf5e20ddc2", "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-06-14T14:02:48+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -1560,7 +1561,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.5" }, "install-path": "../icewind/streams" }, diff --git a/composer/installed.php b/composer/installed.php index 292edc667..7409dda28 100644 --- a/composer/installed.php +++ b/composer/installed.php @@ -5,7 +5,7 @@ 'type' => 'library', 'install_path' => __DIR__ . '/../', 'aliases' => array(), - 'reference' => 'ef4cdf00dddf9c92618e72e117c144e97112ccc4', + 'reference' => '2fa8874509eebddd763d530c85d05a37aadf2e07', 'name' => 'nextcloud/3rdparty', 'dev' => false, ), @@ -200,12 +200,12 @@ 'dev_requirement' => false, ), 'icewind/streams' => array( - 'pretty_version' => 'v0.7.2', - 'version' => '0.7.2.0', + 'pretty_version' => 'v0.7.5', + 'version' => '0.7.5.0', 'type' => 'library', 'install_path' => __DIR__ . '/../icewind/streams', 'aliases' => array(), - 'reference' => '77d750ccc654c0eda4a41fedb2dbd71053755790', + 'reference' => '0c6aae16ebdadb257f0bd089c1e1e4cf5e20ddc2', 'dev_requirement' => false, ), 'justinrainbow/json-schema' => array( @@ -286,7 +286,7 @@ 'type' => 'library', 'install_path' => __DIR__ . '/../', 'aliases' => array(), - 'reference' => 'ef4cdf00dddf9c92618e72e117c144e97112ccc4', + 'reference' => '2fa8874509eebddd763d530c85d05a37aadf2e07', 'dev_requirement' => false, ), 'nextcloud/lognormalizer' => array( diff --git a/composer/package-versions-deprecated/src/PackageVersions/Versions.php b/composer/package-versions-deprecated/src/PackageVersions/Versions.php index 2dabc48f2..372900c4e 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.5@0c6aae16ebdadb257f0bd089c1e1e4cf5e20ddc2', 'justinrainbow/json-schema' => '5.2.10@2ba9c8c862ecd5510ed16c6340aa9f6eadb4f31b', 'league/flysystem' => '1.1.3@9be3b16c877d477357c015cec057548cf9b2a14a', 'league/mime-type-detection' => '1.7.0@3b9dff8aaf7323590c1d2e443db701eb1f9aa0d3', @@ -119,7 +119,7 @@ final class Versions 'web-auth/cose-lib' => 'v3.3.9@ed172d2dc1a6b87b5c644c07c118cd30c1b3819b', 'web-auth/metadata-service' => 'v3.3.9@8488d3a832a38cc81c670fce05de1e515c6e64b1', 'web-auth/webauthn-lib' => 'v3.3.9@04b98ee3d39cb79dad68a7c15c297c085bf66bfe', - 'nextcloud/3rdparty' => 'dev-master@ef4cdf00dddf9c92618e72e117c144e97112ccc4', + 'nextcloud/3rdparty' => 'dev-master@2fa8874509eebddd763d530c85d05a37aadf2e07', ); 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/.scrutinizer.yml b/icewind/streams/.scrutinizer.yml deleted file mode 100644 index 0c7c78622..000000000 --- a/icewind/streams/.scrutinizer.yml +++ /dev/null @@ -1,13 +0,0 @@ -build: - nodes: - analysis: - tests: - override: - - php-scrutinizer-run -tools: - php_sim: true - php_pdepend: true - php_analyzer: true -filter: - excluded_paths: - - 'tests/*' 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..258e3ec83 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; /** @@ -55,7 +57,7 @@ private static function buildContext($protocol, $context, $source) { * @param string|null $class deprecated, class is now automatically generated * @return bool|resource */ - protected static function wrapSource($source, $context = [], $protocol = null, $class = null) { + protected static function wrapSource($source, $context = [], $protocol = null, $class = null, $mode = 'r+') { if ($class === null) { $class = static::class; } @@ -70,7 +72,7 @@ protected static function wrapSource($source, $context = [], $protocol = null, $ if (self::isDirectoryHandle($source)) { return opendir($protocol . '://', $context); } else { - return fopen($protocol . '://', 'r+', false, $context); + return fopen($protocol . '://', $mode, false, $context); } } finally { stream_wrapper_unregister($protocol); 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 +}