Skip to content

Commit 39bd56b

Browse files
committed
Apply phpstan fixes
1 parent 7f67cd6 commit 39bd56b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/streams.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ function faccept( $stream, string ...$accept ) : ?string {
3636
*
3737
* The cursor is reset to its original position.
3838
*
39-
* @param resource $stream The stream to peek, must be a seekable resource
40-
* @param int $length Up to length number of bytes read.
39+
* @param resource $stream The stream to peek, must be a seekable resource
40+
* @param int $length Up to length number of bytes read.
4141
* @return string The peeked string of up to length bytes
4242
*/
4343
function fpeek( $stream, int $length = 1 ) : string {
4444
if( !is_resource($stream) ) {
4545
throw new \InvalidArgumentException('Stream must be a resource');
4646
}
4747

48-
$buf = fread($stream, $length);
48+
$buf = fread($stream, $length) ?: '';
4949
fseek($stream, 0 - strlen($buf), SEEK_CUR);
5050

5151
return $buf;

test/StreamsTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function test_faccept_BOM() : void {
3232

3333
public function test_faccept_exception() : void {
3434
$this->expectException(\InvalidArgumentException::class);
35+
// @phpstan-ignore-next-line
3536
faccept(123, 'test');
3637
}
3738

@@ -54,6 +55,7 @@ public function test_fpeek_empty() : void {
5455

5556
public function test_fpeek_exception() : void {
5657
$this->expectException(\InvalidArgumentException::class);
58+
// @phpstan-ignore-next-line
5759
fpeek(123, 123);
5860
}
5961

0 commit comments

Comments
 (0)