From a1554efd5d1181d266271084acd208706331749a Mon Sep 17 00:00:00 2001 From: Theodore Brown Date: Sun, 15 Nov 2026 15:23:48 -0600 Subject: [PATCH 1/2] Fix PHPStan errors in PHP 8.4 and 8.5 release page common.php Add parameter types to message() and handle filter_var() returning false instead of passing it to htmlspecialchars(), then remove the corresponding baseline entries. I already applied this fix to the PHP 8.6 common.php on Sergey's branch. --- phpstan-baseline.neon | 42 ---------------------------------- public/releases/8.4/common.php | 6 ++--- public/releases/8.5/common.php | 9 +++++--- 3 files changed, 9 insertions(+), 48 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 76015cb70f..1bacb12c5d 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -2154,48 +2154,6 @@ parameters: count: 1 path: public/releases/8.3/common.php - - - message: '#^Function releases\\php84\\message\(\) has parameter \$code with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: public/releases/8.4/common.php - - - - message: '#^Function releases\\php84\\message\(\) has parameter \$language with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: public/releases/8.4/common.php - - - - message: '#^Parameter \#1 \$string of function htmlspecialchars expects string, string\|false given\.$#' - identifier: argument.type - count: 1 - path: public/releases/8.4/common.php - - - - message: '#^Function releases\\php85\\message\(\) has parameter \$code with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: public/releases/8.5/common.php - - - - message: '#^Function releases\\php85\\message\(\) has parameter \$interpolations with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: public/releases/8.5/common.php - - - - message: '#^Function releases\\php85\\message\(\) has parameter \$language with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: public/releases/8.5/common.php - - - - message: '#^Parameter \#1 \$string of function htmlspecialchars expects string, string\|false given\.$#' - identifier: argument.type - count: 1 - path: public/releases/8.5/common.php - - message: '#^Function formatDate\(\) has no return type specified\.$#' identifier: missingType.return diff --git a/public/releases/8.4/common.php b/public/releases/8.4/common.php index 28c42ddfcf..b2b195835d 100644 --- a/public/releases/8.4/common.php +++ b/public/releases/8.4/common.php @@ -22,8 +22,8 @@ function common_header(string $description): void { global $MYSITE, $lang; - $meta_image_path = \htmlspecialchars( - \filter_var($MYSITE . 'images/php8/php_8_4_released.png', \FILTER_VALIDATE_URL)); + $meta_image_url = \filter_var($MYSITE . 'images/php8/php_8_4_released.png', \FILTER_VALIDATE_URL); + $meta_image_path = $meta_image_url === false ? '' : \htmlspecialchars($meta_image_url); $meta_description = \htmlspecialchars($description); $languages = []; @@ -54,7 +54,7 @@ function common_header(string $description): void { ]); } -function message($code, $language = 'en'): string +function message(string $code, string $language = 'en'): string { $original = require __DIR__ . '/languages/en.php'; if (($language !== 'en') && file_exists(__DIR__ . '/languages/' . $language . '.php')) { diff --git a/public/releases/8.5/common.php b/public/releases/8.5/common.php index 8243912c60..45d58dc8c7 100644 --- a/public/releases/8.5/common.php +++ b/public/releases/8.5/common.php @@ -22,8 +22,8 @@ function common_header(string $description): void { global $MYSITE, $lang; - $meta_image_path = \htmlspecialchars( - \filter_var($MYSITE . 'images/php8/php_8_5_released.png', \FILTER_VALIDATE_URL)); + $meta_image_url = \filter_var($MYSITE . 'images/php8/php_8_5_released.png', \FILTER_VALIDATE_URL); + $meta_image_path = $meta_image_url === false ? '' : \htmlspecialchars($meta_image_url); $meta_description = \htmlspecialchars($description); $languages = []; @@ -54,7 +54,10 @@ function common_header(string $description): void { ]); } -function message($code, $language = 'en', array $interpolations = []): string +/** + * @param array $interpolations + */ +function message(string $code, string $language = 'en', array $interpolations = []): string { $original = require __DIR__ . '/languages/en.php'; if (($language !== 'en') && file_exists(__DIR__ . '/languages/' . $language . '.php')) { From f89ec756af803623f98b6352eeac967d766fcee4 Mon Sep 17 00:00:00 2001 From: Theodore Brown Date: Sun, 15 Nov 2026 15:38:02 -0600 Subject: [PATCH 2/2] Fix PHPStan errors in PHP 8.0-8.3 release page common.php Apply the same fixes as for 8.4 and 8.5: add parameter types to message() and handle filter_var() returning false, then remove the corresponding baseline entries. --- phpstan-baseline.neon | 72 ---------------------------------- public/releases/8.0/common.php | 6 +-- public/releases/8.1/common.php | 6 +-- public/releases/8.2/common.php | 6 +-- public/releases/8.3/common.php | 6 +-- 5 files changed, 12 insertions(+), 84 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 1bacb12c5d..3b721a990e 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -2082,78 +2082,6 @@ parameters: count: 1 path: public/quickref.php - - - message: '#^Function releases\\php80\\message\(\) has parameter \$code with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: public/releases/8.0/common.php - - - - message: '#^Function releases\\php80\\message\(\) has parameter \$language with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: public/releases/8.0/common.php - - - - message: '#^Parameter \#1 \$string of function htmlspecialchars expects string, string\|false given\.$#' - identifier: argument.type - count: 1 - path: public/releases/8.0/common.php - - - - message: '#^Function releases\\php81\\message\(\) has parameter \$code with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: public/releases/8.1/common.php - - - - message: '#^Function releases\\php81\\message\(\) has parameter \$language with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: public/releases/8.1/common.php - - - - message: '#^Parameter \#1 \$string of function htmlspecialchars expects string, string\|false given\.$#' - identifier: argument.type - count: 1 - path: public/releases/8.1/common.php - - - - message: '#^Function releases\\php82\\message\(\) has parameter \$code with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: public/releases/8.2/common.php - - - - message: '#^Function releases\\php82\\message\(\) has parameter \$language with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: public/releases/8.2/common.php - - - - message: '#^Parameter \#1 \$string of function htmlspecialchars expects string, string\|false given\.$#' - identifier: argument.type - count: 1 - path: public/releases/8.2/common.php - - - - message: '#^Function releases\\php83\\message\(\) has parameter \$code with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: public/releases/8.3/common.php - - - - message: '#^Function releases\\php83\\message\(\) has parameter \$language with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: public/releases/8.3/common.php - - - - message: '#^Parameter \#1 \$string of function htmlspecialchars expects string, string\|false given\.$#' - identifier: argument.type - count: 1 - path: public/releases/8.3/common.php - - message: '#^Function formatDate\(\) has no return type specified\.$#' identifier: missingType.return diff --git a/public/releases/8.0/common.php b/public/releases/8.0/common.php index 5b48919a96..7d88fbc41a 100644 --- a/public/releases/8.0/common.php +++ b/public/releases/8.0/common.php @@ -24,8 +24,8 @@ function common_header(string $description): void { global $MYSITE, $lang; - $meta_image_path = \htmlspecialchars( - \filter_var($MYSITE . 'images/php8/php_8_released.png', \FILTER_VALIDATE_URL)); + $meta_image_url = \filter_var($MYSITE . 'images/php8/php_8_released.png', \FILTER_VALIDATE_URL); + $meta_image_path = $meta_image_url === false ? '' : \htmlspecialchars($meta_image_url); $meta_description = \htmlspecialchars($description); $languages = []; @@ -56,7 +56,7 @@ function common_header(string $description): void { ]); } -function message($code, $language = 'en'): string +function message(string $code, string $language = 'en'): string { $original = require __DIR__ . '/languages/en.php'; if (($language !== 'en') && file_exists(__DIR__ . '/languages/' . $language . '.php')) { diff --git a/public/releases/8.1/common.php b/public/releases/8.1/common.php index 30cf00b61e..0c1bbb0411 100644 --- a/public/releases/8.1/common.php +++ b/public/releases/8.1/common.php @@ -20,8 +20,8 @@ function common_header(string $description): void { global $MYSITE, $lang; - $meta_image_path = \htmlspecialchars( - \filter_var($MYSITE . 'images/php8/php_8_1_released.png', \FILTER_VALIDATE_URL)); + $meta_image_url = \filter_var($MYSITE . 'images/php8/php_8_1_released.png', \FILTER_VALIDATE_URL); + $meta_image_path = $meta_image_url === false ? '' : \htmlspecialchars($meta_image_url); $meta_description = \htmlspecialchars($description); $languages = []; @@ -52,7 +52,7 @@ function common_header(string $description): void { ]); } -function message($code, $language = 'en'): string +function message(string $code, string $language = 'en'): string { $original = require __DIR__ . '/languages/en.php'; if (($language !== 'en') && file_exists(__DIR__ . '/languages/' . $language . '.php')) { diff --git a/public/releases/8.2/common.php b/public/releases/8.2/common.php index c8c34c5850..09ec829ee5 100644 --- a/public/releases/8.2/common.php +++ b/public/releases/8.2/common.php @@ -20,8 +20,8 @@ function common_header(string $description): void { global $MYSITE, $lang; - $meta_image_path = \htmlspecialchars( - \filter_var($MYSITE . 'images/php8/php_8_2_released.png', \FILTER_VALIDATE_URL)); + $meta_image_url = \filter_var($MYSITE . 'images/php8/php_8_2_released.png', \FILTER_VALIDATE_URL); + $meta_image_path = $meta_image_url === false ? '' : \htmlspecialchars($meta_image_url); $meta_description = \htmlspecialchars($description); $languages = []; @@ -52,7 +52,7 @@ function common_header(string $description): void { ]); } -function message($code, $language = 'en'): string +function message(string $code, string $language = 'en'): string { $original = require __DIR__ . '/languages/en.php'; if (($language !== 'en') && file_exists(__DIR__ . '/languages/' . $language . '.php')) { diff --git a/public/releases/8.3/common.php b/public/releases/8.3/common.php index e2432aac95..fce76dd85f 100644 --- a/public/releases/8.3/common.php +++ b/public/releases/8.3/common.php @@ -20,8 +20,8 @@ function common_header(string $description): void { global $MYSITE, $lang; - $meta_image_path = \htmlspecialchars( - \filter_var($MYSITE . 'images/php8/php_8_3_released.png', \FILTER_VALIDATE_URL)); + $meta_image_url = \filter_var($MYSITE . 'images/php8/php_8_3_released.png', \FILTER_VALIDATE_URL); + $meta_image_path = $meta_image_url === false ? '' : \htmlspecialchars($meta_image_url); $meta_description = \htmlspecialchars($description); $languages = []; @@ -52,7 +52,7 @@ function common_header(string $description): void { ]); } -function message($code, $language = 'en'): string +function message(string $code, string $language = 'en'): string { $original = require __DIR__ . '/languages/en.php'; if (($language !== 'en') && file_exists(__DIR__ . '/languages/' . $language . '.php')) {