From 4694d0c150c7c516cb39cb0ee174a270614409bf Mon Sep 17 00:00:00 2001 From: Adrien Dupuis Date: Thu, 8 Feb 2024 11:52:10 +0100 Subject: [PATCH] Fix baseUri scheme related error Since (#1931) and PHP 8, an error occurs when raml2html extracts baseUri scheme. PHP Deprecated: mb_strtoupper(): Passing null to parameter #1 ($string) of type string is deprecated in tools/raml2html/vendor/raml-org/raml-php-parser/src/ApiDefinition.php on line 813 --- tools/raml2html/composer.json | 3 ++- tools/raml2html/patches/ApiDefinition.php.patch | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tools/raml2html/patches/ApiDefinition.php.patch diff --git a/tools/raml2html/composer.json b/tools/raml2html/composer.json index d39e716036..07e47581f2 100644 --- a/tools/raml2html/composer.json +++ b/tools/raml2html/composer.json @@ -42,7 +42,8 @@ "raml-org/raml-php-parser": { "Array of scalars": "https://github.com/raml-org/raml-php-parser/commit/d2e58eac1705a8cf2be43ed3d482006e67e4ef2d.patch", "No available type list in type not found exception": "https://github.com/raml-org/raml-php-parser/commit/d54af98b9bd6d2400bbdd1c186e9b86c2dd88c83.patch", - "Fix warnings and depreciations for PHP 8.1": "https://patch-diff.githubusercontent.com/raw/raml-org/raml-php-parser/pull/180.patch" + "Fix warnings and depreciations for PHP 8.1": "https://patch-diff.githubusercontent.com/raw/raml-org/raml-php-parser/pull/180.patch", + "Fix baseUri misuse": "patches/ApiDefinition.php.patch" } } } diff --git a/tools/raml2html/patches/ApiDefinition.php.patch b/tools/raml2html/patches/ApiDefinition.php.patch new file mode 100644 index 0000000000..7dfdbb8558 --- /dev/null +++ b/tools/raml2html/patches/ApiDefinition.php.patch @@ -0,0 +1,17 @@ +Index: tools/raml2html/vendor/raml-org/raml-php-parser/src/ApiDefinition.php +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/src/ApiDefinition.php b/src/ApiDefinition.php +--- a/src/ApiDefinition.php ++++ b/src/ApiDefinition.php (date 1707386266597) +@@ -810,7 +810,7 @@ + + private function setProtocolsFromBaseUri(): void + { +- $schema = \mb_strtoupper(\parse_url($this->baseUri, PHP_URL_SCHEME)); ++ $schema = \mb_strtoupper(\parse_url($this->baseUri, PHP_URL_SCHEME) ?? ''); + + $this->protocols = empty($schema) ? [self::PROTOCOL_HTTPS, self::PROTOCOL_HTTP] : [$schema]; + }