diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-11-15 16:02:24 +0100 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-11-15 16:02:24 +0100 |
commit | 68363f69443e4332b5433a7078cb7fca930a3ebe (patch) | |
tree | e78a44d8d7d56f8adb3582714aa03e5b28ae898f /tests | |
parent | c3d0b71f2fc78f4092cf43d642331706fd1f8e7d (diff) | |
download | nextcloud-server-68363f69443e4332b5433a7078cb7fca930a3ebe.tar.gz nextcloud-server-68363f69443e4332b5433a7078cb7fca930a3ebe.zip |
Fix some more problems with tests under PHP 8.2
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/AppFramework/Http/RequestStream.php | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/tests/lib/AppFramework/Http/RequestStream.php b/tests/lib/AppFramework/Http/RequestStream.php index 3868ed16505..1a99685e340 100644 --- a/tests/lib/AppFramework/Http/RequestStream.php +++ b/tests/lib/AppFramework/Http/RequestStream.php @@ -7,24 +7,26 @@ namespace Test\AppFramework\Http; * Used to simulate php://input for Request tests */ class RequestStream { - protected $position; - protected $varname; + protected int $position = 0; + protected string $varname = ''; + /* @var resource */ + public $context; - public function stream_open($path, $mode, $options, &$opened_path) { + public function stream_open(string $path, string $mode, int $options, ?string &$opened_path): bool { $url = parse_url($path); - $this->varname = $url["host"]; + $this->varname = $url["host"] ?? ''; $this->position = 0; return true; } - public function stream_read($count) { + public function stream_read(int $count): string { $ret = substr($GLOBALS[$this->varname], $this->position, $count); $this->position += strlen($ret); return $ret; } - public function stream_write($data) { + public function stream_write(string $data): int { $left = substr($GLOBALS[$this->varname], 0, $this->position); $right = substr($GLOBALS[$this->varname], $this->position + strlen($data)); $GLOBALS[$this->varname] = $left . $data . $right; @@ -32,15 +34,15 @@ class RequestStream { return strlen($data); } - public function stream_tell() { + public function stream_tell(): int { return $this->position; } - public function stream_eof() { + public function stream_eof(): bool { return $this->position >= strlen($GLOBALS[$this->varname]); } - public function stream_seek($offset, $whence) { + public function stream_seek(int $offset, int $whence = SEEK_SET): bool { switch ($whence) { case SEEK_SET: if ($offset < strlen($GLOBALS[$this->varname]) && $offset >= 0) { @@ -74,7 +76,7 @@ class RequestStream { } } - public function stream_stat() { + public function stream_stat(): array { $size = strlen($GLOBALS[$this->varname]); $time = time(); $data = [ @@ -96,10 +98,10 @@ class RequestStream { //return false; } - public function stream_metadata($path, $option, $var) { + public function stream_metadata(string $path, int $option, $var): bool { if ($option == STREAM_META_TOUCH) { $url = parse_url($path); - $varname = $url["host"]; + $varname = $url["host"] ?? ''; if (!isset($GLOBALS[$varname])) { $GLOBALS[$varname] = ''; } |