Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce PHP 8.4 support #50

Merged
merged 3 commits into from
Oct 24, 2024
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php-versions: ['8.0', '8.1', '8.2', '8.3']
php-versions: ['8.0', '8.1', '8.2', '8.3', '8.4']

steps:
- name: Checkout
Expand Down Expand Up @@ -41,7 +41,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php-versions: ['8.0', '8.1', '8.2', '8.3']
php-versions: ['8.0', '8.1', '8.2', '8.3', '8.4']

steps:
- name: Checkout
Expand Down
8 changes: 6 additions & 2 deletions lib/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,19 @@ public static function fromString($responseStr)
throw new Exception('Failed to parse HTTP response status line.');
}

// Process the rest of the header lines
/**
* Process the rest of the header lines
*
* @var array<string,array<mixed>>
*/
$headers = [];
foreach ($headerLines as $line) {
if (preg_match("|^([\w-]+):\s+(.+)$|", $line, $m)) {
$hName = ucwords(strtolower($m[1]));
$hValue = $m[2];

if (isset($headers[$hName])) {
if (!\is_array($headers[$hName])) {
if (false === \is_array($headers[$hName])) {
$headers[$hName] = [$headers[$hName]];
}
$headers[$hName][] = $hValue;
Expand Down
11 changes: 11 additions & 0 deletions lib/ParsedUri.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ public function __construct($uri = null)
{
if (\is_string($uri)) {
if (preg_match(self::URI_REGEX, $uri, $matches)) {
/**
* Without the following "hack", PHPStan would throw the following errors (PHP 8.4):
*
* 74 Offset 2 on array{0: string, 1: string, 2: string, ...} in isset() always exists and is not nullable.
* 80 Offset 4 on array{0: string, 1: string, 2: string, ...} in isset() always exists and is not nullable.
* 86 Offset 5 on array{0: string, 1: string, 2: string, ...} in isset() always exists and is not nullable.
*
* @var array<mixed>
*/
$matches = $matches;

if (!empty($matches[1])) {
$this->scheme = isset($matches[2]) ? $matches[2] : '';
}
Expand Down
1 change: 0 additions & 1 deletion lib/Parser/RdfXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ protected function initXMLParser()
xml_set_element_handler($parser, [$this, 'startElementHandler'], [$this, 'endElementHandler']);
xml_set_character_data_handler($parser, [$this, 'cdataHandler']);
xml_set_start_namespace_decl_handler($parser, [$this, 'newNamespaceHandler']);
xml_set_object($parser, $this);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for reference: aa98fe9

$this->xmlParser = $parser;
}
}
Expand Down
Loading