Skip to content

Commit

Permalink
Merge branch '2.x' into 3.x
Browse files Browse the repository at this point in the history
# Conflicts:
#	composer.json
  • Loading branch information
arokettu committed Sep 25, 2021
2 parents 435eb35 + c76b7b2 commit 50188f0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@

## 2.x

### 2.7.1

*Sep 25, 2021*

* Future compatible stream check

### 2.7.0

*Sep 17, 2021*
Expand Down Expand Up @@ -98,6 +104,12 @@

## 1.x

### 1.7.1

*Sep 25, 2021*

* Future compatible stream check

### 1.7.0

*Sep 17, 2021*
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
}
},
"require": {
"php": "^8.1"
"php": "^8.1",
"arokettu/is-resource": "^1.0"
},
"require-dev": {
"ext-gmp": "*",
Expand Down
4 changes: 3 additions & 1 deletion src/Engine/Decoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use SandFox\Bencode\Exceptions\ParseErrorException;
use SandFox\Bencode\Util\IntUtil;

use function Arokettu\IsResource\try_get_resource_type;

/**
* @internal
*/
Expand Down Expand Up @@ -36,7 +38,7 @@ public function __construct(
private \Closure $dictHandler,
private \Closure $bigIntHandler,
) {
if (!\is_resource($this->stream) || get_resource_type($this->stream) !== 'stream') {
if (try_get_resource_type($stream) !== 'stream') {
throw new InvalidArgumentException('Input is not a valid stream');
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/Engine/Encoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
use SandFox\Bencode\Types\DictType;
use SandFox\Bencode\Types\ListType;

use function Arokettu\IsResource\try_get_resource_type;

/**
* @internal
*/
Expand All @@ -28,7 +30,7 @@ public function __construct(
private bool $useJsonSerializable,
private bool $useStringable,
) {
if (!\is_resource($this->stream) || get_resource_type($this->stream) !== 'stream') {
if (try_get_resource_type($this->stream) !== 'stream') {
throw new InvalidArgumentException('Output is not a valid stream');
}
}
Expand Down

0 comments on commit 50188f0

Please sign in to comment.