From 3a16c74b6b17ac2709984e43c986cb403129e23f Mon Sep 17 00:00:00 2001 From: Nicolas Peugnet Date: Sun, 11 Jan 2026 16:51:48 +0100 Subject: [PATCH] Fix running phpstan with newer PHP versions (e.g. 8.4) phpstan 1.8 cannot run properly with PHP 8.4, but newer versions in the 1.x branch do, thus we change the requirement to phpstan ^1.9, to allow version up to 2.0 (excluding). Newer phpstan versions now detect common errors in regexes: Ignored error #Template type T of function resolve[()]{2} is not referenced in a parameter.# has an unescaped '()' which leads to ignoring all errors. Use '\(\)' instead. Ignored error #^Unsafe usage of new static[()]{2}.$# has an unescaped '()' which leads to ignoring all errors. Use '\(\)' instead. So these regexes are also fixed by using non-evaluated string litterals and escaping the parenthesis as recommended instead of using a weird trick with the brackets. --- php-packages/phpstan/composer.json | 2 +- php-packages/phpstan/phpstan-baseline.neon | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/php-packages/phpstan/composer.json b/php-packages/phpstan/composer.json index 0509ab5272..bfff874e67 100644 --- a/php-packages/phpstan/composer.json +++ b/php-packages/phpstan/composer.json @@ -4,7 +4,7 @@ "minimum-stability": "dev", "license": "MIT", "require": { - "phpstan/phpstan": ">=1.8.11 < 1.9.0", + "phpstan/phpstan": "^1.9", "nunomaduro/larastan": "^1.0" }, "autoload": { diff --git a/php-packages/phpstan/phpstan-baseline.neon b/php-packages/phpstan/phpstan-baseline.neon index c6fbed8ed6..b7b405cc1f 100644 --- a/php-packages/phpstan/phpstan-baseline.neon +++ b/php-packages/phpstan/phpstan-baseline.neon @@ -9,12 +9,12 @@ parameters: reportUnmatched: false # We ignore this because resolve can either take a class name as the generic return type or just a binding name. - - message: "#Template type T of function resolve[()]{2} is not referenced in a parameter.#" + - message: '#Template type T of function resolve\(\) is not referenced in a parameter.#' reportUnmatched: false # We ignore new static errors because we want extensibility. # @TODO: needs discussion. - - message: "#^Unsafe usage of new static[()]{2}.$#" + - message: '#^Unsafe usage of new static\(\).$#' reportUnmatched: false # ConnectionInterface lacks methods that exist in the implementation,