Skip to content

Commit 10454be

Browse files
authored
Merge pull request #147 from php-http/fix-phpstan
adjust baseline to reformatted error messages and fix some issues
2 parents 2ccf2c5 + 7ce699a commit 10454be

File tree

7 files changed

+35
-51
lines changed

7 files changed

+35
-51
lines changed

.github/workflows/static.yml

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ jobs:
1515
- name: Checkout code
1616
uses: actions/checkout@v2
1717

18+
- name: Install legacy zend diactoros as we reference that as well
19+
run: composer require "zendframework/zend-diactoros:2.2.1" --no-interaction --no-update
20+
1821
- name: PHPStan
1922
uses: docker://oskarstark/phpstan-ga
2023
env:

composer.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@
3838
"slim/slim": "Used with Slim Framework PSR-7 implementation"
3939
},
4040
"config": {
41-
"sort-packages": true
41+
"sort-packages": true,
42+
"allow-plugins": {
43+
"ergebnis/composer-normalize": true
44+
}
4245
},
4346
"extra": {
4447
"branch-alias": {

phpstan-baseline.neon

+18-49
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,5 @@
11
parameters:
22
ignoreErrors:
3-
-
4-
message: "#^Property Http\\\\Message\\\\Authentication\\\\Header\\:\\:\\$value type has no value type specified in iterable type array\\.$#"
5-
count: 1
6-
path: src/Authentication/Header.php
7-
8-
-
9-
message: "#^Method Http\\\\Message\\\\Authentication\\\\Header\\:\\:__construct\\(\\) has parameter \\$value with no typehint specified\\.$#"
10-
count: 1
11-
path: src/Authentication/Header.php
12-
13-
-
14-
message: "#The Http\\\\Message\\\\Authentication\\\\Matching class is deprecated since version 1.2 and will be removed in 2.0.#"
15-
count: 1
16-
path: src/Authentication/Matching.php
17-
183
-
194
message: "#^Property Http\\\\Message\\\\Authentication\\\\QueryParam\\:\\:\\$params type has no value type specified in iterable type array\\.$#"
205
count: 1
@@ -41,7 +26,7 @@ parameters:
4126
path: src/Builder/ResponseBuilder.php
4227

4328
-
44-
message: "#^Method Http\\\\Message\\\\Cookie\\:\\:createWithoutValidation\\(\\) has no return typehint specified\\.$#"
29+
message: "#^Method Http\\\\Message\\\\Cookie\\:\\:createWithoutValidation\\(\\) has no return type specified\\.$#"
4530
count: 1
4631
path: src/Cookie.php
4732

@@ -56,17 +41,17 @@ parameters:
5641
path: src/Cookie.php
5742

5843
-
59-
message: "#^Method Http\\\\Message\\\\Cookie\\:\\:validateName\\(\\) has no return typehint specified\\.$#"
44+
message: "#^Method Http\\\\Message\\\\Cookie\\:\\:validateName\\(\\) has no return type specified\\.$#"
6045
count: 1
6146
path: src/Cookie.php
6247

6348
-
64-
message: "#^Method Http\\\\Message\\\\Cookie\\:\\:validateValue\\(\\) has no return typehint specified\\.$#"
49+
message: "#^Method Http\\\\Message\\\\Cookie\\:\\:validateValue\\(\\) has no return type specified\\.$#"
6550
count: 1
6651
path: src/Cookie.php
6752

6853
-
69-
message: "#^Method Http\\\\Message\\\\Cookie\\:\\:validateMaxAge\\(\\) has no return typehint specified\\.$#"
54+
message: "#^Method Http\\\\Message\\\\Cookie\\:\\:validateMaxAge\\(\\) has no return type specified\\.$#"
7055
count: 1
7156
path: src/Cookie.php
7257

@@ -86,12 +71,12 @@ parameters:
8671
path: src/CookieJar.php
8772

8873
-
89-
message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:addCookie\\(\\) has no return typehint specified\\.$#"
74+
message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:addCookie\\(\\) has no return type specified\\.$#"
9075
count: 1
9176
path: src/CookieJar.php
9277

9378
-
94-
message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:removeCookie\\(\\) has no return typehint specified\\.$#"
79+
message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:removeCookie\\(\\) has no return type specified\\.$#"
9580
count: 1
9681
path: src/CookieJar.php
9782

@@ -101,22 +86,22 @@ parameters:
10186
path: src/CookieJar.php
10287

10388
-
104-
message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:setCookies\\(\\) has no return typehint specified\\.$#"
89+
message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:setCookies\\(\\) has no return type specified\\.$#"
10590
count: 1
10691
path: src/CookieJar.php
10792

10893
-
109-
message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:addCookies\\(\\) has no return typehint specified\\.$#"
94+
message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:addCookies\\(\\) has no return type specified\\.$#"
11095
count: 1
11196
path: src/CookieJar.php
11297

11398
-
114-
message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:removeCookies\\(\\) has no return typehint specified\\.$#"
99+
message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:removeCookies\\(\\) has no return type specified\\.$#"
115100
count: 1
116101
path: src/CookieJar.php
117102

118103
-
119-
message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:removeMatchingCookies\\(\\) has no return typehint specified\\.$#"
104+
message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:removeMatchingCookies\\(\\) has no return type specified\\.$#"
120105
count: 1
121106
path: src/CookieJar.php
122107

@@ -126,7 +111,7 @@ parameters:
126111
path: src/CookieJar.php
127112

128113
-
129-
message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:clear\\(\\) has no return typehint specified\\.$#"
114+
message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:clear\\(\\) has no return type specified\\.$#"
130115
count: 1
131116
path: src/CookieJar.php
132117

@@ -141,37 +126,27 @@ parameters:
141126
path: src/CookieUtil.php
142127

143128
-
144-
message: "#^Method Http\\\\Message\\\\Encoding\\\\ChunkStream\\:\\:fill\\(\\) has no return typehint specified\\.$#"
129+
message: "#^Method Http\\\\Message\\\\Encoding\\\\ChunkStream\\:\\:fill\\(\\) has no return type specified\\.$#"
145130
count: 1
146131
path: src/Encoding/ChunkStream.php
147132

148-
-
149-
message: "#^Method Http\\\\Message\\\\Encoding\\\\Filter\\\\Chunk\\:\\:filter\\(\\) has parameter \\$consumed with no typehint specified\\.$#"
150-
count: 1
151-
path: src/Encoding/Filter/Chunk.php
152-
153-
-
154-
message: "#^Access to an undefined property Http\\\\Message\\\\Encoding\\\\Filter\\\\Chunk\\:\\:\\$stream\\.$#"
155-
count: 2
156-
path: src/Encoding/Filter/Chunk.php
157-
158133
-
159134
message: "#^Access to an undefined property object\\:\\:\\$datalen\\.$#"
160135
count: 2
161136
path: src/Encoding/Filter/Chunk.php
162137

163138
-
164-
message: "#^Method Http\\\\Message\\\\Encoding\\\\FilteredStream\\:\\:fill\\(\\) has no return typehint specified\\.$#"
139+
message: "#^Method Http\\\\Message\\\\Encoding\\\\FilteredStream\\:\\:fill\\(\\) has no return type specified\\.$#"
165140
count: 1
166141
path: src/Encoding/FilteredStream.php
167142

168143
-
169-
message: "#^Method Http\\\\Message\\\\Encoding\\\\FilteredStream\\:\\:rewind\\(\\) has no return typehint specified\\.$#"
144+
message: "#^Method Http\\\\Message\\\\Encoding\\\\FilteredStream\\:\\:rewind\\(\\) has no return type specified\\.$#"
170145
count: 1
171146
path: src/Encoding/FilteredStream.php
172147

173148
-
174-
message: "#^Method Http\\\\Message\\\\Encoding\\\\FilteredStream\\:\\:seek\\(\\) has no return typehint specified\\.$#"
149+
message: "#^Method Http\\\\Message\\\\Encoding\\\\FilteredStream\\:\\:seek\\(\\) has no return type specified\\.$#"
175150
count: 1
176151
path: src/Encoding/FilteredStream.php
177152

@@ -205,11 +180,6 @@ parameters:
205180
count: 1
206181
path: src/MessageFactory/SlimMessageFactory.php
207182

208-
-
209-
message: "#The Http\\\\Message\\\\RequestMatcher\\\\RegexRequestMatcher class is deprecated since version 1.2 and will be removed in 2.0.#"
210-
count: 1
211-
path: src/RequestMatcher/RegexRequestMatcher.php
212-
213183
-
214184
message: "#^Property Http\\\\Message\\\\RequestMatcher\\\\RequestMatcher\\:\\:\\$methods type has no value type specified in iterable type array\\.$#"
215185
count: 1
@@ -236,7 +206,7 @@ parameters:
236206
path: src/Stream/BufferedStream.php
237207

238208
-
239-
message: "#^Dead catch \\- Exception is already caught by Throwable above\\.$#"
209+
message: "#^Dead catch \\- Exception is already caught#"
240210
count: 1
241211
path: src/Stream/BufferedStream.php
242212

@@ -266,12 +236,12 @@ parameters:
266236
path: src/Stream/BufferedStream.php
267237

268238
-
269-
message: "#^Method Http\\\\Message\\\\Stream\\\\BufferedStream\\:\\:seek\\(\\) has no return typehint specified\\.$#"
239+
message: "#^Method Http\\\\Message\\\\Stream\\\\BufferedStream\\:\\:seek\\(\\) has no return type specified\\.$#"
270240
count: 1
271241
path: src/Stream/BufferedStream.php
272242

273243
-
274-
message: "#^Method Http\\\\Message\\\\Stream\\\\BufferedStream\\:\\:rewind\\(\\) has no return typehint specified\\.$#"
244+
message: "#^Method Http\\\\Message\\\\Stream\\\\BufferedStream\\:\\:rewind\\(\\) has no return type specified\\.$#"
275245
count: 1
276246
path: src/Stream/BufferedStream.php
277247

@@ -294,4 +264,3 @@ parameters:
294264
message: "#^Unreachable statement \\- code above always terminates\\.$#"
295265
count: 1
296266
path: src/UriFactory/SlimUriFactory.php
297-

src/Authentication/Header.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ class Header implements Authentication
1313
private $name;
1414

1515
/**
16-
* @var string|array
16+
* @var string|string[]
1717
*/
1818
private $value;
1919

20+
/**
21+
* @param string|string[] $value
22+
*/
2023
public function __construct(string $name, $value)
2124
{
2225
$this->name = $name;

src/CookieJar.php

+2
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ public function clear()
195195
/**
196196
* {@inheritdoc}
197197
*/
198+
#[\ReturnTypeWillChange]
198199
public function count()
199200
{
200201
return $this->cookies->count();
@@ -203,6 +204,7 @@ public function count()
203204
/**
204205
* {@inheritdoc}
205206
*/
207+
#[\ReturnTypeWillChange]
206208
public function getIterator()
207209
{
208210
return clone $this->cookies;

src/Encoding/Filter/Chunk.php

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class Chunk extends \php_user_filter
1212
/**
1313
* {@inheritdoc}
1414
*/
15+
#[\ReturnTypeWillChange]
1516
public function filter($in, $out, &$consumed, $closing)
1617
{
1718
while ($bucket = stream_bucket_make_writeable($in)) {

src/Stream/BufferedStream.php

+3
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ public function read($length)
203203
if (null === $this->resource) {
204204
throw new \RuntimeException('Cannot read on a detached stream');
205205
}
206+
if ($length < 0) {
207+
throw new \InvalidArgumentException('Can not read a negative amount of bytes');
208+
}
206209

207210
$read = '';
208211

0 commit comments

Comments
 (0)