From 7734e07af16930ada91ee942c381f98a4875609f Mon Sep 17 00:00:00 2001 From: Jan Nedbal Date: Fri, 14 Mar 2025 15:55:42 +0100 Subject: [PATCH 1/4] Changing debug refs not to invalidate result cache --- composer.json | 2 +- composer.lock | 17 ++++++++++------- rules.neon | 2 ++ src/Provider/ReflectionUsageProvider.php | 4 ++-- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index e056d04b..6c2d5553 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ ], "require": { "php": "^7.4 || ^8.0", - "phpstan/phpstan": "^2.1.7" + "phpstan/phpstan": "2.1.x-dev" }, "require-dev": { "composer-runtime-api": "^2.0", diff --git a/composer.lock b/composer.lock index aec789e5..7a640377 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3db2a7de56d94f1fafe36b2922a91afd", + "content-hash": "dc67d62a2208f0dcd091a47fc84c315a", "packages": [ { "name": "phpstan/phpstan", - "version": "2.1.7", + "version": "2.1.x-dev", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "12567f91a74036d56ba0af6d56c8e73ac0e8d850" + "reference": "cbdfae609210e70809d738547e2c2bb9764bf9df" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/12567f91a74036d56ba0af6d56c8e73ac0e8d850", - "reference": "12567f91a74036d56ba0af6d56c8e73ac0e8d850", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/cbdfae609210e70809d738547e2c2bb9764bf9df", + "reference": "cbdfae609210e70809d738547e2c2bb9764bf9df", "shasum": "" }, "require": { @@ -26,6 +26,7 @@ "conflict": { "phpstan/phpstan-shim": "*" }, + "default-branch": true, "bin": [ "phpstan", "phpstan.phar" @@ -62,7 +63,7 @@ "type": "github" } ], - "time": "2025-03-05T13:43:55+00:00" + "time": "2025-03-14T14:24:50+00:00" } ], "packages-dev": [ @@ -5999,7 +6000,9 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": { + "phpstan/phpstan": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/rules.neon b/rules.neon index 5b574a63..abed804d 100644 --- a/rules.neon +++ b/rules.neon @@ -121,6 +121,8 @@ services: parameters: + parametersNotInvalidatingCache: + - parameters.shipmonkDeadCode.debug.usagesOf shipmonkDeadCode: trackMixedAccess: null reportTransitivelyDeadMethodAsSeparateError: false diff --git a/src/Provider/ReflectionUsageProvider.php b/src/Provider/ReflectionUsageProvider.php index a5f9a211..ffab0591 100644 --- a/src/Provider/ReflectionUsageProvider.php +++ b/src/Provider/ReflectionUsageProvider.php @@ -107,7 +107,7 @@ private function extractConstantsUsedByReflection( } if (($methodName === 'getConstant' || $methodName === 'getReflectionConstant') && count($args) === 1) { - $firstArg = $args[array_key_first($args)]; // @phpstan-ignore offsetAccess.notFound + $firstArg = $args[array_key_first($args)]; foreach ($scope->getType($firstArg->value)->getConstantStrings() as $constantString) { $usedConstants[] = $this->createConstantUsage($node, $scope, $genericReflection->getName(), $constantString->getValue()); @@ -138,7 +138,7 @@ private function extractMethodsUsedByReflection( } if ($methodName === 'getMethod' && count($args) === 1) { - $firstArg = $args[array_key_first($args)]; // @phpstan-ignore offsetAccess.notFound + $firstArg = $args[array_key_first($args)]; foreach ($scope->getType($firstArg->value)->getConstantStrings() as $constantString) { $usedMethods[] = $this->createMethodUsage($node, $scope, $genericReflection->getName(), $constantString->getValue()); From 1e4790f044f03f2dcc62a3babb590c2cfcd3f95d Mon Sep 17 00:00:00 2001 From: Jan Nedbal Date: Fri, 14 Mar 2025 16:00:11 +0100 Subject: [PATCH 2/4] One more --- rules.neon | 1 + 1 file changed, 1 insertion(+) diff --git a/rules.neon b/rules.neon index abed804d..e75713c5 100644 --- a/rules.neon +++ b/rules.neon @@ -123,6 +123,7 @@ services: parameters: parametersNotInvalidatingCache: - parameters.shipmonkDeadCode.debug.usagesOf + - parameters.shipmonkDeadCode.reportTransitivelyDeadMethodAsSeparateError shipmonkDeadCode: trackMixedAccess: null reportTransitivelyDeadMethodAsSeparateError: false From 3a0b7110dc71a7244ef45c3cb59bfc15e744dcaf Mon Sep 17 00:00:00 2001 From: Jan Nedbal Date: Fri, 14 Mar 2025 16:03:16 +0100 Subject: [PATCH 3/4] Readme: mention instant rerun --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index bdfaeacb..cb8c3c78 100644 --- a/README.md +++ b/README.md @@ -390,6 +390,9 @@ App\User\Entity\Address::__construct If you set up `editorUrl` [parameter](https://phpstan.org/user-guide/output-format#opening-file-in-an-editor), you can click on the usages to open it in your IDE. +> [!TIP] +> You can change the list of debug references without affecting result cache, so rerun is instant! + ## Future scope: - Dead class property detection - Dead class detection From c1f8c505283510f4501d361ecb8b9ef568b86f43 Mon Sep 17 00:00:00 2001 From: Jan Nedbal Date: Mon, 24 Mar 2025 10:26:04 +0100 Subject: [PATCH 4/4] Use tagged PHPStan version --- composer.json | 2 +- composer.lock | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 6c2d5553..6dfe787d 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ ], "require": { "php": "^7.4 || ^8.0", - "phpstan/phpstan": "2.1.x-dev" + "phpstan/phpstan": "^2.1.9" }, "require-dev": { "composer-runtime-api": "^2.0", diff --git a/composer.lock b/composer.lock index 7a640377..f243dea8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "dc67d62a2208f0dcd091a47fc84c315a", + "content-hash": "c99cce62513777890267fe702e9f35a4", "packages": [ { "name": "phpstan/phpstan", - "version": "2.1.x-dev", + "version": "2.1.10", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "cbdfae609210e70809d738547e2c2bb9764bf9df" + "reference": "051a3b6b9b80df4ba3a7f801a8b53ad7d8f1c15f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/cbdfae609210e70809d738547e2c2bb9764bf9df", - "reference": "cbdfae609210e70809d738547e2c2bb9764bf9df", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/051a3b6b9b80df4ba3a7f801a8b53ad7d8f1c15f", + "reference": "051a3b6b9b80df4ba3a7f801a8b53ad7d8f1c15f", "shasum": "" }, "require": { @@ -26,7 +26,6 @@ "conflict": { "phpstan/phpstan-shim": "*" }, - "default-branch": true, "bin": [ "phpstan", "phpstan.phar" @@ -63,7 +62,7 @@ "type": "github" } ], - "time": "2025-03-14T14:24:50+00:00" + "time": "2025-03-23T14:57:55+00:00" } ], "packages-dev": [ @@ -6000,9 +5999,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "phpstan/phpstan": 20 - }, + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": {