Skip to content

Commit b0d95e3

Browse files
h4kunapionl
authored andcommitted
feat(psr/http-message): prepare forward compatibility
1 parent f3a62f8 commit b0d95e3

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"juststeveking/uri-builder": "^2.0",
1717
"php-http/discovery": "^1.14",
1818
"psr/http-client": "^1.0.1",
19-
"psr/http-message": "^1.0.1",
19+
"psr/http-message": "^1.0.1 || ^2.0",
2020
"wrkflow/php-get-typed-value": "^0.8.2"
2121
},
2222
"require-dev": {

src/Testing/Responses/ResponseMock.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace WrkFlow\ApiSdkBuilder\Testing\Responses;
66

7+
use Psr\Http\Message\MessageInterface;
78
use Psr\Http\Message\ResponseInterface;
89
use Psr\Http\Message\StreamInterface;
910

@@ -21,85 +22,85 @@ public function __construct(
2122
$this->body = is_string($body) ? new StringStream($body) : $body;
2223
}
2324

24-
public function getProtocolVersion()
25+
public function getProtocolVersion(): string
2526
{
2627
return $this->version;
2728
}
2829

29-
public function withProtocolVersion($version)
30+
public function withProtocolVersion(string $version): MessageInterface
3031
{
3132
$this->version = $version;
3233

3334
return $this;
3435
}
3536

36-
public function getHeaders()
37+
public function getHeaders(): array
3738
{
3839
return $this->headers;
3940
}
4041

41-
public function hasHeader($name)
42+
public function hasHeader(string $name): bool
4243
{
4344
return array_key_exists($name, $this->headers);
4445
}
4546

46-
public function getHeader($name)
47+
public function getHeader(string $name): array
4748
{
4849
return $this->headers[$name];
4950
}
5051

51-
public function getHeaderLine($name)
52+
public function getHeaderLine(string $name): string
5253
{
5354
return implode(',', $this->headers[$name] ?? []);
5455
}
5556

56-
public function withHeader($name, $value)
57+
public function withHeader(string $name, $value): MessageInterface
5758
{
5859
$this->headers[$name] = [$value];
5960

6061
return $this;
6162
}
6263

63-
public function withAddedHeader($name, $value)
64+
public function withAddedHeader(string $name, $value): MessageInterface
6465
{
6566
$this->headers[$name][] = $value;
6667

6768
return $this;
6869
}
6970

70-
public function withoutHeader($name)
71+
public function withoutHeader(string $name): MessageInterface
7172
{
7273
unset($this->headers[$name]);
7374

7475
return $this;
7576
}
7677

77-
public function getBody()
78+
public function getBody(): StreamInterface
7879
{
7980
return $this->body;
8081
}
8182

82-
public function withBody(StreamInterface $body)
83+
public function withBody(StreamInterface $body): MessageInterface
8384
{
8485
$this->body = $body;
8586

8687
return $this;
8788
}
8889

89-
public function getStatusCode()
90+
public function getStatusCode(): int
9091
{
9192
return $this->statusCode;
9293
}
9394

94-
public function withStatus($code, $reasonPhrase = '')
95+
public function withStatus(int $code, string $reasonPhrase = ''): ResponseInterface
9596
{
9697
$this->statusCode = $code;
9798
$this->reasonPhrase = $reasonPhrase;
9899

99100
return $this;
100101
}
101102

102-
public function getReasonPhrase()
103+
public function getReasonPhrase(): string
103104
{
104105
return $this->reasonPhrase;
105106
}

src/Testing/Responses/StringStream.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function rewind(): void
2727
throw new Exception('Not seekable');
2828
}
2929

30-
public function getContents()
30+
public function getContents(): string
3131
{
3232
return $this->__toString();
3333
}
@@ -41,32 +41,32 @@ public function detach()
4141
return null;
4242
}
4343

44-
public function getSize()
44+
public function getSize(): ?int
4545
{
4646
return null;
4747
}
4848

49-
public function isReadable()
49+
public function isReadable(): bool
5050
{
5151
return true;
5252
}
5353

54-
public function isWritable()
54+
public function isWritable(): bool
5555
{
5656
return true;
5757
}
5858

59-
public function isSeekable()
59+
public function isSeekable(): bool
6060
{
6161
return true;
6262
}
6363

64-
public function eof()
64+
public function eof(): bool
6565
{
6666
return false;
6767
}
6868

69-
public function tell()
69+
public function tell(): int
7070
{
7171
return $this->offset;
7272
}
@@ -76,12 +76,12 @@ public function seek($offset, $whence = SEEK_SET): void
7676
$this->offset = $offset;
7777
}
7878

79-
public function read($length)
79+
public function read($length): string
8080
{
8181
return substr($this->string, $this->offset, $length);
8282
}
8383

84-
public function write($string)
84+
public function write($string): int
8585
{
8686
$this->string .= $string;
8787

0 commit comments

Comments
 (0)