From 797e56dee53348cd098c0475929b81abb11b249d Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Mon, 25 Mar 2024 11:59:32 +0400 Subject: [PATCH] modifs.mineures sans commentaires --- src/cli/ArgsParser.php | 1 + src/cli/DynamicCommand.php | 1 + src/os/IOException.php | 2 +- src/os/file/FileWriter.php | 2 +- src/os/file/Stream.php | 18 +++++++++--------- src/os/file/_File.php | 2 +- src/os/path.php | 2 +- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/cli/ArgsParser.php b/src/cli/ArgsParser.php index f2a5adb..3fe2ea2 100644 --- a/src/cli/ArgsParser.php +++ b/src/cli/ArgsParser.php @@ -2,6 +2,7 @@ namespace nur\sery\cli; use nulib\str; +use nur\A; use nur\sery\php\func; use nur\sery\ref\cli\ref_args; use nur\sery\values\akey; diff --git a/src/cli/DynamicCommand.php b/src/cli/DynamicCommand.php index 8734efb..7d24b3f 100644 --- a/src/cli/DynamicCommand.php +++ b/src/cli/DynamicCommand.php @@ -1,6 +1,7 @@ file = $file; $this->mode = $mode; $fd = $this->open(); diff --git a/src/os/file/Stream.php b/src/os/file/Stream.php index 63b1f46..0dceba4 100644 --- a/src/os/file/Stream.php +++ b/src/os/file/Stream.php @@ -78,7 +78,7 @@ class Stream extends AbstractIterator implements IReader, IWriter { function fstat(bool $reload=false): array { if ($this->stat === null || $reload) { $fd = $this->getResource(); - $this->stat = IOException::ensure_value(fstat($fd), $this->throwOnError); + $this->stat = IOException::ensure_valid(fstat($fd), $this->throwOnError); } return $this->stat; } @@ -90,7 +90,7 @@ class Stream extends AbstractIterator implements IReader, IWriter { /** @throws IOException */ function ftell(): int { $fd = $this->getResource(); - return IOException::ensure_value(ftell($fd), $this->throwOnError); + return IOException::ensure_valid(ftell($fd), $this->throwOnError); } /** @@ -99,7 +99,7 @@ class Stream extends AbstractIterator implements IReader, IWriter { */ function fseek(int $offset, int $whence=SEEK_SET): int { $fd = $this->getResource(); - IOException::ensure_value(fseek($fd, $offset, $whence), $this->throwOnError, -1); + IOException::ensure_valid(fseek($fd, $offset, $whence), $this->throwOnError, -1); return $this->ftell(); } @@ -137,7 +137,7 @@ class Stream extends AbstractIterator implements IReader, IWriter { /** @throws IOException */ function fread(int $length): string { $fd = $this->getResource(); - return IOException::ensure_value(fread($fd, $length), $this->throwOnError); + return IOException::ensure_valid(fread($fd, $length), $this->throwOnError); } /** @@ -155,7 +155,7 @@ class Stream extends AbstractIterator implements IReader, IWriter { /** @throws IOException */ function fpassthru(): int { $fd = $this->getResource(); - return IOException::ensure_value(fpassthru($fd), $this->throwOnError); + return IOException::ensure_valid(fpassthru($fd), $this->throwOnError); } /** @@ -214,7 +214,7 @@ class Stream extends AbstractIterator implements IReader, IWriter { $useLocking = $this->useLocking; if ($useLocking && !$lockedByCanRead) $this->lock(LOCK_SH); try { - return IOException::ensure_value(stream_get_contents($this->fd), $this->throwOnError); + return IOException::ensure_valid(stream_get_contents($this->fd), $this->throwOnError); } finally { if ($useLocking) $this->unlock($close); elseif ($close) $this->close(); @@ -249,20 +249,20 @@ class Stream extends AbstractIterator implements IReader, IWriter { $fd = $this->getResource(); if ($length === null) $r = fwrite($fd, $data); else $r = fwrite($fd, $data, $length); - return IOException::ensure_value($r, $this->throwOnError); + return IOException::ensure_valid($r, $this->throwOnError); } /** @throws IOException */ function fflush(): self { $fd = $this->getResource(); - IOException::ensure_value(fflush($fd), $this->throwOnError); + IOException::ensure_valid(fflush($fd), $this->throwOnError); return $this; } /** @throws IOException */ function ftruncate(int $size): self { $fd = $this->getResource(); - IOException::ensure_value(ftruncate($fd, $size), $this->throwOnError); + IOException::ensure_valid(ftruncate($fd, $size), $this->throwOnError); return $this; } diff --git a/src/os/file/_File.php b/src/os/file/_File.php index 349a9f3..7e4ebfa 100644 --- a/src/os/file/_File.php +++ b/src/os/file/_File.php @@ -16,7 +16,7 @@ abstract class _File extends Stream { protected $mode; protected function open() { - return IOException::ensure_value(@fopen($this->file, $this->mode)); + return IOException::ensure_valid(@fopen($this->file, $this->mode)); } function getResource() { diff --git a/src/os/path.php b/src/os/path.php index 0a11003..64e3ccd 100644 --- a/src/os/path.php +++ b/src/os/path.php @@ -123,7 +123,7 @@ class path { static final function realpath($path): ?string { if ($path === null || $path === false) return null; $path = strval($path); - return IOException::ensure_value(realpath($path)); + return IOException::ensure_valid(realpath($path)); } /**