Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Emulate PHP 8.3
run: composer config platform.php 8.3.999
if: matrix.php == '8.4'
uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -41,7 +37,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down Expand Up @@ -69,7 +65,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -92,7 +88,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
22 changes: 5 additions & 17 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ parameters:
count: 1
path: src/Builder/ResponseBuilder.php

-
message: "#^Result of \\|\\| is always true\\.$#"
count: 1
path: src/Builder/ResponseBuilder.php

-
message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#"
count: 1
path: src/Builder/ResponseBuilder.php

-
message: "#^Method Http\\\\Message\\\\Cookie\\:\\:createWithoutValidation\\(\\) has no return type specified\\.$#"
count: 1
Expand Down Expand Up @@ -101,14 +91,14 @@ parameters:
path: src/CookieJar.php

-
message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:clear\\(\\) has no return type specified\\.$#"
count: 1
message: "#^Cannot call method .* on mixed\\.$#"
count: 4
path: src/CookieJar.php

-
message: "#^Property Http\\\\Message\\\\CookieUtil\\:\\:\\$dateFormats type has no value type specified in iterable type array\\.$#"
message: "#^Method Http\\\\Message\\\\CookieJar\\:\\:clear\\(\\) has no return type specified\\.$#"
count: 1
path: src/CookieUtil.php
path: src/CookieJar.php

-
message: "#^Method Http\\\\Message\\\\MessageFactory\\\\DiactorosMessageFactory\\:\\:createRequest\\(\\) has parameter \\$headers with no value type specified in iterable type array\\.$#"
Expand Down Expand Up @@ -181,6 +171,4 @@ parameters:
path: src/UriFactory/SlimUriFactory.php

-
message: "#^Call to function array_key_exists\\(\\) with 'chunk' and array<int, string> will always evaluate to false\\.$#"
count: 1
path: src/filters.php
message: '#Trait .* is used zero times and is not analysed#'
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ includes:
- phpstan-baseline.neon

parameters:
treatPhpDocTypesAsCertain: false
level: max
paths:
- src
Expand Down
5 changes: 4 additions & 1 deletion src/CookieUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ final class CookieUtil
* Handles dates as defined by RFC 2616 section 3.3.1, and also some other
* non-standard, but common formats.
*
* @var array
* @var string[]
*/
private static $dateFormats = [
'D, d M y H:i:s T',
Expand All @@ -34,6 +34,9 @@ final class CookieUtil
*/
public static function parseDate($dateValue)
{
if (!is_string($dateValue)) {
throw new \InvalidArgumentException('Date must be of type string, given '.gettype($dateValue));
}
foreach (self::$dateFormats as $dateFormat) {
if (false !== $date = \DateTime::createFromFormat($dateFormat, $dateValue, new \DateTimeZone('GMT'))) {
return $date;
Expand Down
2 changes: 2 additions & 0 deletions src/Encoding/Filter/Chunk.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
public function filter($in, $out, &$consumed, $closing): int
{
while ($bucket = stream_bucket_make_writeable($in)) {
/* @phpstan-ignore argument.type */
$lenbucket = stream_bucket_new($this->stream, dechex($bucket->datalen)."\r\n");

Check failure on line 16 in src/Encoding/Filter/Chunk.php

View workflow job for this annotation

GitHub Actions / PHPStan

Parameter #1 $num of function dechex expects int, mixed given.
stream_bucket_append($out, $lenbucket);

$consumed += $bucket->datalen;

Check failure on line 19 in src/Encoding/Filter/Chunk.php

View workflow job for this annotation

GitHub Actions / PHPStan

Parameter &$consumed by-ref type of method Http\Message\Encoding\Filter\Chunk::filter() expects int, (float|int) given.

Check failure on line 19 in src/Encoding/Filter/Chunk.php

View workflow job for this annotation

GitHub Actions / PHPStan

Binary operation "+=" between (float|int) and mixed results in an error.
stream_bucket_append($out, $bucket);

/* @phpstan-ignore argument.type */
$lenbucket = stream_bucket_new($this->stream, "\r\n");
stream_bucket_append($out, $lenbucket);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Encoding/FilteredStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ public function eof(): bool
protected function fill(): void
{
$readFilterCallback = $this->readFilterCallback;
/* @phpstan-ignore assignOp.invalid */
$this->buffer .= $readFilterCallback($this->stream->read(self::BUFFER_SIZE));

if ($this->stream->eof()) {
/* @phpstan-ignore assignOp.invalid */
$this->buffer .= $readFilterCallback();
}
}
Expand Down
Loading