From 82a350a5c719cc83aa22382201683a68a2629f2a Mon Sep 17 00:00:00 2001 From: flashwave Date: Fri, 15 Sep 2023 22:44:36 +0000 Subject: [PATCH] Allow file resource in Bencode encoder. --- VERSION | 2 +- src/Serialisation/Bencode.php | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index 966fa8e..a3a5ea5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2309.152202 +0.2309.152244 diff --git a/src/Serialisation/Bencode.php b/src/Serialisation/Bencode.php index ea42f42..4aa93e9 100644 --- a/src/Serialisation/Bencode.php +++ b/src/Serialisation/Bencode.php @@ -1,11 +1,13 @@ seek(0); - } + } elseif(is_resource($input)) + $input = new GenericStream($input); + elseif(!($input instanceof Stream)) + throw new InvalidArgumentException('$input must be a string, an Index Stream or a file resource.'); if($depth < 1) throw new RuntimeException('Maximum depth reached, structure is too dense.');