Skip to content

Commit b46726e

Browse files
committed
Support PSR7 / HTTP Message v2
1 parent 86b3487 commit b46726e

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"vimeo/psalm": "^5.0"
3737
},
3838
"suggest": {
39-
"psr/http-message": "^1.0",
39+
"psr/http-message": "^2.0",
4040
"guzzlehttp/psr7": "^2.4"
4141
},
4242
"scripts": {

test/EndlessCycleStream.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,9 @@ public function detach()
3333
return;
3434
}
3535

36-
/**
37-
* @return null
38-
*/
39-
public function getSize()
36+
public function getSize(): ?int
4037
{
41-
return;
38+
return null;
4239
}
4340

4441
public function tell(): int
@@ -51,12 +48,12 @@ public function eof(): bool
5148
return false;
5249
}
5350

54-
public function isSeekable()
51+
public function isSeekable(): bool
5552
{
5653
return true;
5754
}
5855

59-
public function seek($offset, $whence = SEEK_SET)
56+
public function seek(int $offset, int $whence = SEEK_SET): void
6057
{
6158
switch($whence) {
6259
case SEEK_SET:
@@ -81,7 +78,7 @@ public function isWritable(): bool
8178
return false;
8279
}
8380

84-
public function write($string): int
81+
public function write(string $string): int
8582
{
8683
throw new RuntimeException('Not writeable');
8784
}
@@ -91,7 +88,7 @@ public function isReadable(): bool
9188
return true;
9289
}
9390

94-
public function read($length): string
91+
public function read(int $length): string
9592
{
9693
$this->offset += $length;
9794
return substr(str_repeat($this->toRepeat, (int) ceil($length / strlen($this->toRepeat))), 0, $length);
@@ -102,7 +99,7 @@ public function getContents(): string
10299
throw new RuntimeException('Infinite Stream!');
103100
}
104101

105-
public function getMetadata($key = null): array|null
102+
public function getMetadata(?string $key = null): array|null
106103
{
107104
return $key !== null ? null : [];
108105
}

test/ResourceStream.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function detach()
4545
return $result;
4646
}
4747

48-
public function seek($offset, $whence = SEEK_SET): void
48+
public function seek(int $offset, int $whence = SEEK_SET): void
4949
{
5050
if (!$this->isSeekable()) {
5151
throw new RuntimeException();
@@ -62,7 +62,7 @@ public function isSeekable(): bool
6262
return (bool)$this->getMetadata('seekable');
6363
}
6464

65-
public function getMetadata($key = null)
65+
public function getMetadata(?string $key = null)
6666
{
6767
$metadata = stream_get_meta_data($this->stream);
6868
return $key !== null ? @$metadata[$key] : $metadata;
@@ -95,7 +95,7 @@ public function rewind(): void
9595
$this->seek(0);
9696
}
9797

98-
public function write($string): int
98+
public function write(string $string): int
9999
{
100100
if (!$this->isWritable()) {
101101
throw new RuntimeException();
@@ -119,7 +119,7 @@ public function isWritable(): bool
119119
return preg_match('/[waxc+]/', $mode) === 1;
120120
}
121121

122-
public function read($length): string
122+
public function read(int $length): string
123123
{
124124
if (!$this->isReadable()) {
125125
throw new RuntimeException();

test/ZipStreamTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,12 @@ public function testAddFileFromStreamUnseekableInputWithZeroHeader(): void
355355
);
356356

357357
$streamUnseekable = StreamWrapper::getResource(new class ('test') extends EndlessCycleStream {
358-
public function isSeekable()
358+
public function isSeekable(): bool
359359
{
360360
return false;
361361
}
362362

363-
public function seek($offset, $whence = SEEK_SET)
363+
public function seek(int $offset, int $whence = SEEK_SET): void
364364
{
365365
throw new RuntimeException('Not seekable');
366366
}

0 commit comments

Comments
 (0)