From 9e8bb4defe791f41e56b98193a4399d7083c5ee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1chym=20Tou=C5=A1ek?= Date: Fri, 6 Mar 2020 21:06:39 +0100 Subject: [PATCH] Use short list syntax (#40) --- src/EioDriver.php | 20 ++++++++++---------- src/ParallelDriver.php | 2 +- src/UvDriver.php | 10 +++++----- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/EioDriver.php b/src/EioDriver.php index 880977d..d1435f9 100644 --- a/src/EioDriver.php +++ b/src/EioDriver.php @@ -64,7 +64,7 @@ final class EioDriver implements Driver private function onOpenHandle(array $openArr, $result, $req): void { - list($mode, $path, $deferred) = $openArr; + [$mode, $path, $deferred] = $openArr; if ($result === -1) { $deferred->fail(new FilesystemException(\eio_get_last_error($req))); @@ -79,7 +79,7 @@ final class EioDriver implements Driver private function onOpenFtruncate(array $openArr, $result, $req): void { - list($fh, $mode, $path, $deferred) = $openArr; + [$fh, $mode, $path, $deferred] = $openArr; if ($result === -1) { $deferred->fail(new FilesystemException(\eio_get_last_error($req))); @@ -91,7 +91,7 @@ final class EioDriver implements Driver private function onOpenFstat(array $openArr, $result, $req): void { - list($fh, $mode, $path, $deferred) = $openArr; + [$fh, $mode, $path, $deferred] = $openArr; if ($result === -1) { $deferred->fail(new FilesystemException(\eio_get_last_error($req))); } else { @@ -122,7 +122,7 @@ final class EioDriver implements Driver private function onStat(array $data, $result, $req): void { - list($deferred, $path) = $data; + [$deferred, $path] = $data; if ($result === -1) { $deferred->resolve(null); } else { @@ -379,7 +379,7 @@ final class EioDriver implements Driver private function onUnlink(array $data, $result, $req): void { - list($deferred, $path) = $data; + [$deferred, $path] = $data; if ($result === -1) { $deferred->fail(new FilesystemException(\eio_get_last_error($req))); @@ -449,7 +449,7 @@ final class EioDriver implements Driver private function onRmdir(array $data, $result, $req): void { - list($deferred, $path) = $data; + [$deferred, $path] = $data; if ($result === -1) { $deferred->fail(new FilesystemException(\eio_get_last_error($req))); @@ -559,7 +559,7 @@ final class EioDriver implements Driver private function onGetFstat(array $fhAndPromisor, $result, $req): void { - list($fh, $deferred) = $fhAndPromisor; + [$fh, $deferred] = $fhAndPromisor; if ($result === -1) { $deferred->fail(new FilesystemException(\eio_get_last_error($req))); @@ -574,7 +574,7 @@ final class EioDriver implements Driver private function onGetRead(array $fhAndPromisor, $result, $req): void { - list($fh, $deferred) = $fhAndPromisor; + [$fh, $deferred] = $fhAndPromisor; \eio_close($fh); @@ -605,7 +605,7 @@ final class EioDriver implements Driver private function onPutOpen(array $data, $result, $req): void { - list($contents, $deferred) = $data; + [$contents, $deferred] = $data; if ($result === -1) { $deferred->fail(new FilesystemException(\eio_get_last_error($req))); @@ -621,7 +621,7 @@ final class EioDriver implements Driver private function onPutWrite(array $fhAndPromisor, $result, $req): void { - list($fh, $deferred) = $fhAndPromisor; + [$fh, $deferred] = $fhAndPromisor; \eio_close($fh); diff --git a/src/ParallelDriver.php b/src/ParallelDriver.php index fd73e85..fe12420 100644 --- a/src/ParallelDriver.php +++ b/src/ParallelDriver.php @@ -34,7 +34,7 @@ final class ParallelDriver implements Driver return call(function () use ($path, $mode) { $worker = $this->pool->getWorker(); try { - list($id, $size, $mode) = yield $worker->enqueue(new Internal\FileTask("fopen", [$path, $mode])); + [$id, $size, $mode] = yield $worker->enqueue(new Internal\FileTask("fopen", [$path, $mode])); } catch (TaskException $exception) { throw new FilesystemException("Could not open file", $exception); } catch (WorkerException $exception) { diff --git a/src/UvDriver.php b/src/UvDriver.php index 28cd68e..d3e6a40 100644 --- a/src/UvDriver.php +++ b/src/UvDriver.php @@ -60,7 +60,7 @@ final class UvDriver implements Driver if ($fh) { $this->onOpenHandle($fh, $openArr); } else { - list(, $path, $deferred) = $openArr; + [, $path, $deferred] = $openArr; $deferred->fail(new FilesystemException( "Failed opening file handle to $path" )); @@ -93,14 +93,14 @@ final class UvDriver implements Driver private function onOpenHandle($fh, array $openArr): void { - list($mode) = $openArr; + [$mode] = $openArr; if ($mode[0] === "w") { \uv_fs_ftruncate($this->loop, $fh, $length = 0, function ($fh) use ($openArr): void { if ($fh) { $this->finalizeHandle($fh, $size = 0, $openArr); } else { - list(, $path, $deferred) = $openArr; + [, $path, $deferred] = $openArr; $deferred->fail(new FilesystemException( "Failed truncating file $path" )); @@ -112,7 +112,7 @@ final class UvDriver implements Driver StatCache::set($openArr[1], $stat); $this->finalizeHandle($fh, $stat["size"], $openArr); } else { - list(, $path, $deferred) = $openArr; + [, $path, $deferred] = $openArr; $deferred->fail(new FilesystemException( "Failed reading file size from open handle pointing to $path" )); @@ -123,7 +123,7 @@ final class UvDriver implements Driver private function finalizeHandle($fh, $size, array $openArr): void { - list($mode, $path, $deferred) = $openArr; + [$mode, $path, $deferred] = $openArr; $handle = new UvFile($this->driver, $this->poll, $fh, $path, $mode, $size); $deferred->resolve($handle); }