Skip to content

Commit 824711c

Browse files
committed
minor #99 Add return types to fixtures (derrabus)
This PR was merged into the 2.1-dev branch. Discussion ---------- Add return types to fixtures This should hopefully make Symfony's debug class loader happy. Commits ------- f8f70fa Add return types to fixtures
2 parents d558dcd + f8f70fa commit 824711c

File tree

7 files changed

+186
-53
lines changed

7 files changed

+186
-53
lines changed

Diff for: .github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
deprecations: max[self]=0
2020
- php: '8.0'
2121
deps: highest
22+
deprecations: max[indirect]=5
2223

2324
steps:
2425
- name: Checkout code

Diff for: Tests/Fixtures/Message.php

+32-7
Original file line numberDiff line numberDiff line change
@@ -29,63 +29,88 @@ public function __construct($version = '1.1', array $headers = [], StreamInterfa
2929
{
3030
$this->version = $version;
3131
$this->headers = $headers;
32-
$this->body = null === $body ? new Stream() : $body;
32+
$this->body = $body ?? new Stream();
3333
}
3434

35-
public function getProtocolVersion()
35+
public function getProtocolVersion(): string
3636
{
3737
return $this->version;
3838
}
3939

40+
/**
41+
* {@inheritdoc}
42+
*
43+
* @return static
44+
*/
4045
public function withProtocolVersion($version)
4146
{
4247
throw new \BadMethodCallException('Not implemented.');
4348
}
4449

45-
public function getHeaders()
50+
public function getHeaders(): array
4651
{
4752
return $this->headers;
4853
}
4954

50-
public function hasHeader($name)
55+
public function hasHeader($name): bool
5156
{
5257
return isset($this->headers[$name]);
5358
}
5459

55-
public function getHeader($name)
60+
public function getHeader($name): array
5661
{
5762
return $this->hasHeader($name) ? $this->headers[$name] : [];
5863
}
5964

60-
public function getHeaderLine($name)
65+
public function getHeaderLine($name): string
6166
{
6267
return $this->hasHeader($name) ? implode(',', $this->headers[$name]) : '';
6368
}
6469

70+
/**
71+
* {@inheritdoc}
72+
*
73+
* @return static
74+
*/
6575
public function withHeader($name, $value)
6676
{
6777
$this->headers[$name] = (array) $value;
6878

6979
return $this;
7080
}
7181

82+
/**
83+
* {@inheritdoc}
84+
*
85+
* @return static
86+
*/
7287
public function withAddedHeader($name, $value)
7388
{
7489
throw new \BadMethodCallException('Not implemented.');
7590
}
7691

92+
/**
93+
* {@inheritdoc}
94+
*
95+
* @return static
96+
*/
7797
public function withoutHeader($name)
7898
{
7999
unset($this->headers[$name]);
80100

81101
return $this;
82102
}
83103

84-
public function getBody()
104+
public function getBody(): StreamInterface
85105
{
86106
return $this->body;
87107
}
88108

109+
/**
110+
* {@inheritdoc}
111+
*
112+
* @return static
113+
*/
89114
public function withBody(StreamInterface $body)
90115
{
91116
throw new \BadMethodCallException('Not implemented.');

Diff for: Tests/Fixtures/Response.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,20 @@ public function __construct($version = '1.1', array $headers = [], StreamInterfa
2828
$this->statusCode = $statusCode;
2929
}
3030

31-
public function getStatusCode()
31+
public function getStatusCode(): int
3232
{
3333
return $this->statusCode;
3434
}
3535

36+
/**
37+
* @return static
38+
*/
3639
public function withStatus($code, $reasonPhrase = '')
3740
{
3841
throw new \BadMethodCallException('Not implemented.');
3942
}
4043

41-
public function getReasonPhrase()
44+
public function getReasonPhrase(): string
4245
{
4346
throw new \BadMethodCallException('Not implemented.');
4447
}

Diff for: Tests/Fixtures/ServerRequest.php

+69-8
Original file line numberDiff line numberDiff line change
@@ -45,95 +45,156 @@ public function __construct($version = '1.1', array $headers = [], StreamInterfa
4545
$this->attributes = $attributes;
4646
}
4747

48-
public function getRequestTarget()
48+
public function getRequestTarget(): string
4949
{
5050
return $this->requestTarget;
5151
}
5252

53+
/**
54+
* {@inheritdoc}
55+
*
56+
* @return static
57+
*/
5358
public function withRequestTarget($requestTarget)
5459
{
5560
throw new \BadMethodCallException('Not implemented.');
5661
}
5762

58-
public function getMethod()
63+
public function getMethod(): string
5964
{
6065
return $this->method;
6166
}
6267

68+
/**
69+
* {@inheritdoc}
70+
*
71+
* @return static
72+
*/
6373
public function withMethod($method)
6474
{
75+
throw new \BadMethodCallException('Not implemented.');
6576
}
6677

78+
/**
79+
* {@inheritdoc}
80+
*
81+
* @return UriInterface
82+
*/
6783
public function getUri()
6884
{
6985
return $this->uri;
7086
}
7187

88+
/**
89+
* {@inheritdoc}
90+
*
91+
* @return static
92+
*/
7293
public function withUri(UriInterface $uri, $preserveHost = false)
7394
{
7495
throw new \BadMethodCallException('Not implemented.');
7596
}
7697

77-
public function getServerParams()
98+
public function getServerParams(): array
7899
{
79100
return $this->server;
80101
}
81102

82-
public function getCookieParams()
103+
public function getCookieParams(): array
83104
{
84105
return $this->cookies;
85106
}
86107

108+
/**
109+
* {@inheritdoc}
110+
*
111+
* @return static
112+
*/
87113
public function withCookieParams(array $cookies)
88114
{
89115
throw new \BadMethodCallException('Not implemented.');
90116
}
91117

92-
public function getQueryParams()
118+
public function getQueryParams(): array
93119
{
94120
return $this->query;
95121
}
96122

123+
/**
124+
* {@inheritdoc}
125+
*
126+
* @return static
127+
*/
97128
public function withQueryParams(array $query)
98129
{
99130
throw new \BadMethodCallException('Not implemented.');
100131
}
101132

102-
public function getUploadedFiles()
133+
public function getUploadedFiles(): array
103134
{
104135
return $this->uploadedFiles;
105136
}
106137

138+
/**
139+
* {@inheritdoc}
140+
*
141+
* @return static
142+
*/
107143
public function withUploadedFiles(array $uploadedFiles)
108144
{
109145
throw new \BadMethodCallException('Not implemented.');
110146
}
111147

148+
/**
149+
* {@inheritdoc}
150+
*
151+
* @return array|object|null
152+
*/
112153
public function getParsedBody()
113154
{
114155
return $this->data;
115156
}
116157

158+
/**
159+
* {@inheritdoc}
160+
*
161+
* @return static
162+
*/
117163
public function withParsedBody($data)
118164
{
119165
throw new \BadMethodCallException('Not implemented.');
120166
}
121167

122-
public function getAttributes()
168+
public function getAttributes(): array
123169
{
124170
return $this->attributes;
125171
}
126172

173+
/**
174+
* {@inheritdoc}
175+
*
176+
* @return mixed
177+
*/
127178
public function getAttribute($name, $default = null)
128179
{
129-
return isset($this->attributes[$name]) ? $this->attributes[$name] : $default;
180+
return $this->attributes[$name] ?? $default;
130181
}
131182

183+
/**
184+
* {@inheritdoc}
185+
*
186+
* @return static
187+
*/
132188
public function withAttribute($name, $value)
133189
{
134190
throw new \BadMethodCallException('Not implemented.');
135191
}
136192

193+
/**
194+
* {@inheritdoc}
195+
*
196+
* @return static
197+
*/
137198
public function withoutAttribute($name)
138199
{
139200
throw new \BadMethodCallException('Not implemented.');

Diff for: Tests/Fixtures/Stream.php

+21-13
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ public function __construct($stringContent = '')
2626
$this->stringContent = $stringContent;
2727
}
2828

29-
public function __toString()
29+
public function __toString(): string
3030
{
3131
return $this->stringContent;
3232
}
3333

34-
public function close()
34+
public function close(): void
3535
{
3636
}
3737

@@ -40,61 +40,69 @@ public function detach()
4040
return fopen('data://text/plain,'.$this->stringContent, 'r');
4141
}
4242

43-
public function getSize()
43+
public function getSize(): ?int
4444
{
45+
return null;
4546
}
4647

47-
public function tell()
48+
public function tell(): int
4849
{
4950
return 0;
5051
}
5152

52-
public function eof()
53+
public function eof(): bool
5354
{
5455
return $this->eof;
5556
}
5657

57-
public function isSeekable()
58+
public function isSeekable(): bool
5859
{
5960
return true;
6061
}
6162

62-
public function seek($offset, $whence = \SEEK_SET)
63+
public function seek($offset, $whence = \SEEK_SET): void
6364
{
6465
}
6566

66-
public function rewind()
67+
public function rewind(): void
6768
{
6869
$this->eof = false;
6970
}
7071

71-
public function isWritable()
72+
public function isWritable(): bool
7273
{
7374
return false;
7475
}
7576

76-
public function write($string)
77+
public function write($string): int
7778
{
79+
return \strlen($string);
7880
}
7981

80-
public function isReadable()
82+
public function isReadable(): bool
8183
{
8284
return true;
8385
}
8486

85-
public function read($length)
87+
public function read($length): string
8688
{
8789
$this->eof = true;
8890

8991
return $this->stringContent;
9092
}
9193

92-
public function getContents()
94+
public function getContents(): string
9395
{
9496
return $this->stringContent;
9597
}
9698

99+
/**
100+
* {@inheritdoc}
101+
*
102+
* @return mixed
103+
*/
97104
public function getMetadata($key = null)
98105
{
106+
return null;
99107
}
100108
}

0 commit comments

Comments
 (0)