From a034dc05d2b8dbd13640acf7a270ac85050d752b Mon Sep 17 00:00:00 2001 From: Konrad Abicht Date: Fri, 12 Jul 2024 11:24:26 +0200 Subject: [PATCH 1/3] Tests.yml: added 8.4 as test target --- .github/workflows/Tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml index 24bf72e5..fb368d35 100644 --- a/.github/workflows/Tests.yml +++ b/.github/workflows/Tests.yml @@ -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 @@ -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 From aa98fe930c933a4e2ca3b8ec99258627806c21fb Mon Sep 17 00:00:00 2001 From: Konrad Abicht Date: Thu, 24 Oct 2024 14:19:25 +0200 Subject: [PATCH 2/3] Parser/RdfXml: removed xml_set_object call Usage of xml_set_object is deprecated in PHP 8.4 in favor of using xml_set_* functions with string method names. Because we already do that the xml_set_object call could be removed without any problems. Link to the offical deprecation information for PHP 8.4: https://wiki.php.net/rfc/deprecations_php_8_4#xml_set_object_and_xml_set_handler_with_string_method_names --- lib/Parser/RdfXml.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Parser/RdfXml.php b/lib/Parser/RdfXml.php index b5822500..e8f3422c 100644 --- a/lib/Parser/RdfXml.php +++ b/lib/Parser/RdfXml.php @@ -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); $this->xmlParser = $parser; } } From 9a75ca2a61f3b4373ccc7766f5be70b680cf25d2 Mon Sep 17 00:00:00 2001 From: Konrad Abicht Date: Thu, 24 Oct 2024 14:40:20 +0200 Subject: [PATCH 3/3] "fixed" a few PHPStan errors --- lib/Http/Response.php | 8 ++++++-- lib/ParsedUri.php | 11 +++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/Http/Response.php b/lib/Http/Response.php index 57651fe3..db93db2c 100644 --- a/lib/Http/Response.php +++ b/lib/Http/Response.php @@ -298,7 +298,11 @@ 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> + */ $headers = []; foreach ($headerLines as $line) { if (preg_match("|^([\w-]+):\s+(.+)$|", $line, $m)) { @@ -306,7 +310,7 @@ public static function fromString($responseStr) $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; diff --git a/lib/ParsedUri.php b/lib/ParsedUri.php index a9f9efe2..4cdfdc41 100644 --- a/lib/ParsedUri.php +++ b/lib/ParsedUri.php @@ -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 + */ + $matches = $matches; + if (!empty($matches[1])) { $this->scheme = isset($matches[2]) ? $matches[2] : ''; }