From 4b8da5e1a6be8fd995bc644d9b15d85fc5377809 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sun, 20 Jul 2025 22:04:28 +0800 Subject: [PATCH 1/3] Update phpstan/phpstan to version 2.x Bumped the phpstan/phpstan dependency from ^1.0 to ^2.0 in composer.json to use the latest major version for improved static analysis. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c93d3c2..74e70d6 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "hyperf/devtool": "3.1.*", "hyperf/testing": "3.1.*", "mockery/mockery": "^1.0", - "phpstan/phpstan": "^1.0", + "phpstan/phpstan": "^2.0", "swoole/ide-helper": "dev-master" }, "autoload": { From 9147df195172cddf3b7ac9fd1a4607c32fd0c341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=93=AD=E6=98=95?= <715557344@qq.com> Date: Sat, 7 Mar 2026 10:34:50 +0800 Subject: [PATCH 2/3] Update --- composer.json | 5 +++-- phpstan.neon.dist | 15 +++------------ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index 403df5e..a474b30 100644 --- a/composer.json +++ b/composer.json @@ -52,6 +52,7 @@ "hyperf/testing": "3.2.*", "mockery/mockery": "^1.0", "phpstan/phpstan": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", "swoole/ide-helper": "dev-master" }, "autoload": { @@ -73,7 +74,7 @@ "optimize-autoloader": true, "sort-packages": true }, - "extra": [], + "extra": {}, "scripts": { "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" @@ -81,7 +82,7 @@ "post-autoload-dump": [ "rm -rf runtime/container" ], - "analyse": "phpstan analyse --memory-limit 512M", + "analyse": "phpstan analyse --memory-limit 1G", "cs-fix": "php-cs-fixer fix $1", "start": "php ./bin/hyperf.php start", "test": "co-phpunit --prepend test/bootstrap.php --colors=always", diff --git a/phpstan.neon.dist b/phpstan.neon.dist index c28cea5..d1a136d 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -4,8 +4,10 @@ # vendor/bin/phpstan analyse app --memory-limit 200M -l 0 # includes: + - vendor/phpstan/phpstan-strict-rules/rules.neon # 需要执行 composer require phpstan/phpstan-deprecation-rules --dev # - vendor/phpstan/phpstan-deprecation-rules/rules.neon + parameters: level: 0 paths: @@ -18,15 +20,4 @@ parameters: minimumNumberOfJobsPerProcess: 2 ignoreErrors: - '#Static call to instance method Hyperf\\HttpServer\\Router\\Router::[a-zA-Z0-9\\_]+\(\)#' - - '#Static call to instance method Hyperf\\DbConnection\\Db::[a-zA-Z0-9\\_]+\(\)#' - -services: - # When using `match` to match enum, the enumeration must be completely overwritten - - class: PHPStan\Rules\Comparison\MatchExpressionRule - arguments: - checkAlwaysTrueStrictComparison: %checkAlwaysTrueStrictComparison% - disableUnreachable: %featureToggles.disableUnreachableBranchesRules% - reportAlwaysTrueInLastCondition: %reportAlwaysTrueInLastCondition% - treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% - tags: - - phpstan.rules.rule + - '#Static call to instance method Hyperf\\DbConnection\\Db::[a-zA-Z0-9\\_]+\(\)#' \ No newline at end of file From 7d0fb94ddc842ea5ab9366ca6d2c790a63894008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=93=AD=E6=98=95?= <715557344@qq.com> Date: Sat, 7 Mar 2026 11:21:52 +0800 Subject: [PATCH 3/3] Update phpstan.neon.dist --- phpstan.neon.dist | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index d1a136d..358baf4 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -20,4 +20,12 @@ parameters: minimumNumberOfJobsPerProcess: 2 ignoreErrors: - '#Static call to instance method Hyperf\\HttpServer\\Router\\Router::[a-zA-Z0-9\\_]+\(\)#' - - '#Static call to instance method Hyperf\\DbConnection\\Db::[a-zA-Z0-9\\_]+\(\)#' \ No newline at end of file + - '#Static call to instance method Hyperf\\DbConnection\\Db::[a-zA-Z0-9\\_]+\(\)#' + +services: + # When using `match` to match enum, the enumeration must be completely overwritten + - class: PHPStan\Rules\Comparison\MatchExpressionRule + arguments: + treatPhpDocTypesAsCertain: %treatPhpDocTypesAsCertain% + tags: + - phpstan.rules.rule \ No newline at end of file