Author: Theodore Brown (theodorejb)
Committer: GitHub (web-flow)
Pusher: sy-records
Date: 2026-11-16T10:52:35+08:00

Commit: 
https://github.com/php/web-php/commit/ace610e16c21d2c9407bcce42f849a550dfe3df2
Raw diff: 
https://github.com/php/web-php/commit/ace610e16c21d2c9407bcce42f849a550dfe3df2.diff

Fix PHPStan errors in PHP 8.0-8.5 release page `common.php` (#2060)

* 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.

* 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.

Changed paths:
  M  phpstan-baseline.neon
  M  public/releases/8.0/common.php
  M  public/releases/8.1/common.php
  M  public/releases/8.2/common.php
  M  public/releases/8.3/common.php
  M  public/releases/8.4/common.php
  M  public/releases/8.5/common.php


Diff:

diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 76015cb70f..3b721a990e 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -2082,120 +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 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.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')) {
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<int|string, string> $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')) {

Reply via email to