Skip to content

Commit

Permalink
Merge pull request #181 from laminas/renovate/lock-file-maintenance
Browse files Browse the repository at this point in the history
Lock file maintenance, Upgrade Psalm to 5.20.x
  • Loading branch information
Xerkus authored Feb 16, 2024
2 parents f2bc1ca + c87721d commit 74cfb9a
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 112 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
"http-interop/http-factory-tests": "^0.9.0",
"laminas/laminas-coding-standard": "~2.5.0",
"php-http/psr7-integration-tests": "^1.3",
"phpunit/phpunit": "^9.5.28",
"phpunit/phpunit": "^9.6.16",
"psalm/plugin-phpunit": "^0.18.4",
"vimeo/psalm": "^5.17"
"vimeo/psalm": "^5.22.1"
},
"provide": {
"psr/http-factory-implementation": "^1.1 || ^2.0",
Expand Down
160 changes: 74 additions & 86 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/AbstractSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected static function splitStream(StreamInterface $stream): array
continue;
}

if (! $currentHeader) {
if ($currentHeader === false) {
throw Exception\DeserializationException::forInvalidHeader();
}

Expand Down
4 changes: 2 additions & 2 deletions src/CallbackStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function tell(): int
*/
public function eof(): bool
{
return empty($this->callback);
return $this->callback === null;
}

/**
Expand Down Expand Up @@ -149,7 +149,7 @@ public function read(int $length): string
public function getContents(): string
{
$callback = $this->detach();
$contents = $callback ? $callback() : '';
$contents = $callback !== null ? $callback() : '';
return (string) $contents;
}

Expand Down
4 changes: 2 additions & 2 deletions src/RequestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public function withUri(UriInterface $uri, bool $preserveHost = false): RequestI
}

$host = $uri->getHost();
if ($uri->getPort()) {
if ($uri->getPort() !== null) {
$host .= ':' . $uri->getPort();
}

Expand Down Expand Up @@ -294,7 +294,7 @@ private function setMethod(string $method): void
private function getHostFromUri(): string
{
$host = $this->uri->getHost();
$host .= $this->uri->getPort() ? ':' . $this->uri->getPort() : '';
$host .= $this->uri->getPort() !== null ? ':' . $this->uri->getPort() : '';
return $host;
}
}
12 changes: 6 additions & 6 deletions src/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,11 @@ public function isWritable(): bool
$meta = stream_get_meta_data($this->resource);
$mode = $meta['mode'];

return strstr($mode, 'x')
|| strstr($mode, 'w')
|| strstr($mode, 'c')
|| strstr($mode, 'a')
|| strstr($mode, '+');
return strstr($mode, 'x') !== false
|| strstr($mode, 'w') !== false
|| strstr($mode, 'c') !== false
|| strstr($mode, 'a') !== false
|| strstr($mode, '+') !== false;
}

/**
Expand Down Expand Up @@ -251,7 +251,7 @@ public function isReadable(): bool
$meta = stream_get_meta_data($this->resource);
$mode = $meta['mode'];

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

/**
Expand Down
10 changes: 6 additions & 4 deletions src/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ class UploadedFile implements UploadedFileInterface

private bool $moved = false;

/** @var null|StreamInterface */
private $stream;
private ?StreamInterface $stream = null;

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

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

$sapi = PHP_SAPI;
switch (true) {
case empty($sapi) || str_starts_with($sapi, 'cli') || str_starts_with($sapi, 'phpdbg') || ! $this->file:
case empty($sapi)
|| str_starts_with($sapi, 'cli')
|| str_starts_with($sapi, 'phpdbg')
|| $this->file === null:
// Non-SAPI environment, or no filename present
$this->writeFile($targetPath);

Expand Down
6 changes: 3 additions & 3 deletions src/UriFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static function createFromSapi(array $server, array $headers): Uri
[$host, $port] = self::marshalHostAndPort($server, $headers);
if (! empty($host)) {
$uri = $uri->withHost($host);
if (! empty($port)) {
if ($port !== null) {
$uri = $uri->withPort($port);
}
}
Expand Down Expand Up @@ -115,7 +115,7 @@ private static function getHeaderFromArray(string $name, array $headers, $defaul
* Marshal the host and port from the PHP environment.
*
* @param array<string, string|list<string>> $headers
* @return array{string, int|null} Array of two items, host and port,
* @return array{0:string, 1:int|null} Array of two items, host and port,
* in that order (can be passed to a list() operation).
*/
private static function marshalHostAndPort(array $server, array $headers): array
Expand Down Expand Up @@ -162,7 +162,7 @@ private static function marshalHostAndPort(array $server, array $headers): array
private static function marshalIpv6HostAndPort(array $server, ?int $port): array
{
$host = '[' . (string) $server['SERVER_ADDR'] . ']';
$port = $port ?: 80;
$port = $port ?? 80;
$portSeparatorPos = strrpos($host, ':');

if (false === $portSeparatorPos) {
Expand Down
10 changes: 5 additions & 5 deletions test/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private function fetchIanaStatusCodes(): DOMDocument
}
}
if ($ianaHttpStatusCodes) {
if (! getenv('ALWAYS_REFRESH_IANA_HTTP_STATUS_CODES')) {
if (getenv('ALWAYS_REFRESH_IANA_HTTP_STATUS_CODES') === 'false') {
// use cached codes
return $ianaHttpStatusCodes;
}
Expand All @@ -82,7 +82,7 @@ private function fetchIanaStatusCodes(): DOMDocument

$updatedQueryResult = $xpath->query('//ns:updated');
if ($updatedQueryResult !== false && $updatedQueryResult->length > 0) {
$updated = $updatedQueryResult->item(0)?->nodeValue ?: '';
$updated = $updatedQueryResult->item(0)?->nodeValue ?? '';
$updated = strtotime($updated);
}
}
Expand All @@ -91,7 +91,7 @@ private function fetchIanaStatusCodes(): DOMDocument
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT, 'PHP Curl');
if ($updated) {
if ($updated !== null) {
$ifModifiedSince = sprintf(
'If-Modified-Since: %s',
gmdate('D, d M Y H:i:s \G\M\T', $updated)
Expand Down Expand Up @@ -142,8 +142,8 @@ public function ianaCodesReasonPhrasesProvider(): array
continue;
}

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

if (in_array($description, ['Unassigned', '(Unused)'], true)) {
continue;
Expand Down
3 changes: 2 additions & 1 deletion test/StreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use function fwrite;
use function imagecreate;
use function is_resource;
use function is_string;
use function shmop_open;
use function stream_get_meta_data;
use function sys_get_temp_dir;
Expand All @@ -51,7 +52,7 @@ protected function setUp(): void

protected function tearDown(): void
{
if ($this->tmpnam && file_exists($this->tmpnam)) {
if (is_string($this->tmpnam) && file_exists($this->tmpnam)) {
unlink($this->tmpnam);
}
}
Expand Down

0 comments on commit 74cfb9a

Please sign in to comment.