Skip to content

Commit 74cfb9a

Browse files
authored
Merge pull request #181 from laminas/renovate/lock-file-maintenance
Lock file maintenance, Upgrade Psalm to 5.20.x
2 parents f2bc1ca + c87721d commit 74cfb9a

10 files changed

+103
-112
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
"http-interop/http-factory-tests": "^0.9.0",
4747
"laminas/laminas-coding-standard": "~2.5.0",
4848
"php-http/psr7-integration-tests": "^1.3",
49-
"phpunit/phpunit": "^9.5.28",
49+
"phpunit/phpunit": "^9.6.16",
5050
"psalm/plugin-phpunit": "^0.18.4",
51-
"vimeo/psalm": "^5.17"
51+
"vimeo/psalm": "^5.22.1"
5252
},
5353
"provide": {
5454
"psr/http-factory-implementation": "^1.1 || ^2.0",

composer.lock

Lines changed: 74 additions & 86 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/AbstractSerializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ protected static function splitStream(StreamInterface $stream): array
9999
continue;
100100
}
101101

102-
if (! $currentHeader) {
102+
if ($currentHeader === false) {
103103
throw Exception\DeserializationException::forInvalidHeader();
104104
}
105105

src/CallbackStream.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function tell(): int
8484
*/
8585
public function eof(): bool
8686
{
87-
return empty($this->callback);
87+
return $this->callback === null;
8888
}
8989

9090
/**
@@ -149,7 +149,7 @@ public function read(int $length): string
149149
public function getContents(): string
150150
{
151151
$callback = $this->detach();
152-
$contents = $callback ? $callback() : '';
152+
$contents = $callback !== null ? $callback() : '';
153153
return (string) $contents;
154154
}
155155

src/RequestTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public function withUri(UriInterface $uri, bool $preserveHost = false): RequestI
252252
}
253253

254254
$host = $uri->getHost();
255-
if ($uri->getPort()) {
255+
if ($uri->getPort() !== null) {
256256
$host .= ':' . $uri->getPort();
257257
}
258258

@@ -294,7 +294,7 @@ private function setMethod(string $method): void
294294
private function getHostFromUri(): string
295295
{
296296
$host = $this->uri->getHost();
297-
$host .= $this->uri->getPort() ? ':' . $this->uri->getPort() : '';
297+
$host .= $this->uri->getPort() !== null ? ':' . $this->uri->getPort() : '';
298298
return $host;
299299
}
300300
}

src/Stream.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,11 @@ public function isWritable(): bool
210210
$meta = stream_get_meta_data($this->resource);
211211
$mode = $meta['mode'];
212212

213-
return strstr($mode, 'x')
214-
|| strstr($mode, 'w')
215-
|| strstr($mode, 'c')
216-
|| strstr($mode, 'a')
217-
|| strstr($mode, '+');
213+
return strstr($mode, 'x') !== false
214+
|| strstr($mode, 'w') !== false
215+
|| strstr($mode, 'c') !== false
216+
|| strstr($mode, 'a') !== false
217+
|| strstr($mode, '+') !== false;
218218
}
219219

220220
/**
@@ -251,7 +251,7 @@ public function isReadable(): bool
251251
$meta = stream_get_meta_data($this->resource);
252252
$mode = $meta['mode'];
253253

254-
return strstr($mode, 'r') || strstr($mode, '+');
254+
return strstr($mode, 'r') !== false || strstr($mode, '+') !== false;
255255
}
256256

257257
/**

src/UploadedFile.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ class UploadedFile implements UploadedFileInterface
5050

5151
private bool $moved = false;
5252

53-
/** @var null|StreamInterface */
54-
private $stream;
53+
private ?StreamInterface $stream = null;
5554

5655
/**
5756
* @param string|resource|StreamInterface $streamOrFile
@@ -72,7 +71,7 @@ public function __construct(
7271
$this->stream = new Stream($streamOrFile);
7372
}
7473

75-
if (! $this->file && ! $this->stream) {
74+
if ($this->file === null && $this->stream === null) {
7675
if (! $streamOrFile instanceof StreamInterface) {
7776
throw new Exception\InvalidArgumentException('Invalid stream or file provided for UploadedFile');
7877
}
@@ -150,7 +149,10 @@ public function moveTo(string $targetPath): void
150149

151150
$sapi = PHP_SAPI;
152151
switch (true) {
153-
case empty($sapi) || str_starts_with($sapi, 'cli') || str_starts_with($sapi, 'phpdbg') || ! $this->file:
152+
case empty($sapi)
153+
|| str_starts_with($sapi, 'cli')
154+
|| str_starts_with($sapi, 'phpdbg')
155+
|| $this->file === null:
154156
// Non-SAPI environment, or no filename present
155157
$this->writeFile($targetPath);
156158

src/UriFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static function createFromSapi(array $server, array $headers): Uri
6060
[$host, $port] = self::marshalHostAndPort($server, $headers);
6161
if (! empty($host)) {
6262
$uri = $uri->withHost($host);
63-
if (! empty($port)) {
63+
if ($port !== null) {
6464
$uri = $uri->withPort($port);
6565
}
6666
}
@@ -115,7 +115,7 @@ private static function getHeaderFromArray(string $name, array $headers, $defaul
115115
* Marshal the host and port from the PHP environment.
116116
*
117117
* @param array<string, string|list<string>> $headers
118-
* @return array{string, int|null} Array of two items, host and port,
118+
* @return array{0:string, 1:int|null} Array of two items, host and port,
119119
* in that order (can be passed to a list() operation).
120120
*/
121121
private static function marshalHostAndPort(array $server, array $headers): array
@@ -162,7 +162,7 @@ private static function marshalHostAndPort(array $server, array $headers): array
162162
private static function marshalIpv6HostAndPort(array $server, ?int $port): array
163163
{
164164
$host = '[' . (string) $server['SERVER_ADDR'] . ']';
165-
$port = $port ?: 80;
165+
$port = $port ?? 80;
166166
$portSeparatorPos = strrpos($host, ':');
167167

168168
if (false === $portSeparatorPos) {

test/ResponseTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private function fetchIanaStatusCodes(): DOMDocument
7373
}
7474
}
7575
if ($ianaHttpStatusCodes) {
76-
if (! getenv('ALWAYS_REFRESH_IANA_HTTP_STATUS_CODES')) {
76+
if (getenv('ALWAYS_REFRESH_IANA_HTTP_STATUS_CODES') === 'false') {
7777
// use cached codes
7878
return $ianaHttpStatusCodes;
7979
}
@@ -82,7 +82,7 @@ private function fetchIanaStatusCodes(): DOMDocument
8282

8383
$updatedQueryResult = $xpath->query('//ns:updated');
8484
if ($updatedQueryResult !== false && $updatedQueryResult->length > 0) {
85-
$updated = $updatedQueryResult->item(0)?->nodeValue ?: '';
85+
$updated = $updatedQueryResult->item(0)?->nodeValue ?? '';
8686
$updated = strtotime($updated);
8787
}
8888
}
@@ -91,7 +91,7 @@ private function fetchIanaStatusCodes(): DOMDocument
9191
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
9292
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
9393
curl_setopt($ch, CURLOPT_USERAGENT, 'PHP Curl');
94-
if ($updated) {
94+
if ($updated !== null) {
9595
$ifModifiedSince = sprintf(
9696
'If-Modified-Since: %s',
9797
gmdate('D, d M Y H:i:s \G\M\T', $updated)
@@ -142,8 +142,8 @@ public function ianaCodesReasonPhrasesProvider(): array
142142
continue;
143143
}
144144

145-
$value = $valueQueryResult->item(0)?->nodeValue ?: '';
146-
$description = $descriptionQueryResult->item(0)?->nodeValue ?: '';
145+
$value = $valueQueryResult->item(0)?->nodeValue ?? '';
146+
$description = $descriptionQueryResult->item(0)?->nodeValue ?? '';
147147

148148
if (in_array($description, ['Unassigned', '(Unused)'], true)) {
149149
continue;

test/StreamTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use function fwrite;
2828
use function imagecreate;
2929
use function is_resource;
30+
use function is_string;
3031
use function shmop_open;
3132
use function stream_get_meta_data;
3233
use function sys_get_temp_dir;
@@ -51,7 +52,7 @@ protected function setUp(): void
5152

5253
protected function tearDown(): void
5354
{
54-
if ($this->tmpnam && file_exists($this->tmpnam)) {
55+
if (is_string($this->tmpnam) && file_exists($this->tmpnam)) {
5556
unlink($this->tmpnam);
5657
}
5758
}

0 commit comments

Comments
 (0)