1
0

chore: upgrade PHPStan to 2.x and add unused-public dead code detection

- Upgrade phpstan/phpstan 1.12 → 2.1
- Add tomasvotruba/unused-public 2.2 for automatic dead code detection
- Generate baseline (486 existing findings) to keep CI green
- Remove stale @phpstan-ignore annotation in login page (ternary.alwaysFalse)
- New code is fully checked against PHPStan 2 + unused-public rules

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-14 09:02:43 +02:00
parent 94b746ddf8
commit a736566071
5 changed files with 2804 additions and 29 deletions

View File

@@ -22,9 +22,10 @@
"mintyphp/tools": "*",
"mintyphp/debugger": "*",
"phpunit/phpunit": "*",
"phpstan/phpstan": "^1.9",
"phpstan/phpstan": "^2.1",
"icanhazstring/composer-unused": "^0.9.6",
"friendsofphp/php-cs-fixer": "^3.66"
"friendsofphp/php-cs-fixer": "^3.66",
"tomasvotruba/unused-public": "^2.2"
},
"autoload-dev": {
"psr-4": {

104
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "0926942d029bad48009daddfa3a97395",
"content-hash": "0191d3acf35a8d4f2200f7efb11283a6",
"packages": [
{
"name": "bacon/bacon-qr-code",
@@ -2708,20 +2708,15 @@
},
{
"name": "phpstan/phpstan",
"version": "1.12.19",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "c42ba9bab7a940ed00092ecb1c77bad98896d789"
},
"version": "2.1.47",
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/c42ba9bab7a940ed00092ecb1c77bad98896d789",
"reference": "c42ba9bab7a940ed00092ecb1c77bad98896d789",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/79015445d8bd79e62b29140f12e5bfced1dcca65",
"reference": "79015445d8bd79e62b29140f12e5bfced1dcca65",
"shasum": ""
},
"require": {
"php": "^7.2|^8.0"
"php": "^7.4|^8.0"
},
"conflict": {
"phpstan/phpstan-shim": "*"
@@ -2762,7 +2757,7 @@
"type": "github"
}
],
"time": "2025-02-19T15:42:21+00:00"
"time": "2026-04-13T15:49:08+00:00"
},
{
"name": "phpunit/php-code-coverage",
@@ -5298,16 +5293,16 @@
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.33.0",
"version": "v1.34.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "a3cc8b044a6ea513310cbd48ef7333b384945638"
"reference": "141046a8f9477948ff284fa65be2095baafb94f2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638",
"reference": "a3cc8b044a6ea513310cbd48ef7333b384945638",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/141046a8f9477948ff284fa65be2095baafb94f2",
"reference": "141046a8f9477948ff284fa65be2095baafb94f2",
"shasum": ""
},
"require": {
@@ -5357,7 +5352,7 @@
"portable"
],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.33.0"
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.34.0"
},
"funding": [
{
@@ -5377,7 +5372,7 @@
"type": "tidelift"
}
],
"time": "2024-09-09T11:45:10+00:00"
"time": "2026-04-10T16:19:22+00:00"
},
{
"name": "symfony/polyfill-intl-grapheme",
@@ -6575,17 +6570,74 @@
"time": "2024-03-03T12:36:25+00:00"
},
{
"name": "webmozart/assert",
"version": "2.1.5",
"name": "tomasvotruba/unused-public",
"version": "2.2.0",
"source": {
"type": "git",
"url": "https://github.com/webmozarts/assert.git",
"reference": "79155f94852fa27e2f73b459f6503f5e87e2c188"
"url": "https://github.com/TomasVotruba/unused-public.git",
"reference": "ec82a9a1e3216eb5db174430a740ad8d9ac1dfc2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webmozarts/assert/zipball/79155f94852fa27e2f73b459f6503f5e87e2c188",
"reference": "79155f94852fa27e2f73b459f6503f5e87e2c188",
"url": "https://api.github.com/repos/TomasVotruba/unused-public/zipball/ec82a9a1e3216eb5db174430a740ad8d9ac1dfc2",
"reference": "ec82a9a1e3216eb5db174430a740ad8d9ac1dfc2",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0",
"phpstan/phpstan": "^2.1.33",
"webmozart/assert": "^1.11|^2.0"
},
"type": "phpstan-extension",
"extra": {
"phpstan": {
"includes": [
"config/extension.neon"
]
}
},
"autoload": {
"psr-4": {
"TomasVotruba\\UnusedPublic\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Detect unused public properties, constants and methods in your code",
"keywords": [
"phpstan-extension",
"static analysis"
],
"support": {
"issues": "https://github.com/TomasVotruba/unused-public/issues",
"source": "https://github.com/TomasVotruba/unused-public/tree/2.2.0"
},
"funding": [
{
"url": "https://www.paypal.me/rectorphp",
"type": "custom"
},
{
"url": "https://github.com/tomasvotruba",
"type": "github"
}
],
"time": "2026-01-07T22:23:06+00:00"
},
{
"name": "webmozart/assert",
"version": "2.3.0",
"source": {
"type": "git",
"url": "https://github.com/webmozarts/assert.git",
"reference": "eb0d790f735ba6cff25c683a85a1da0eadeff9e4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webmozarts/assert/zipball/eb0d790f735ba6cff25c683a85a1da0eadeff9e4",
"reference": "eb0d790f735ba6cff25c683a85a1da0eadeff9e4",
"shasum": ""
},
"require": {
@@ -6632,9 +6684,9 @@
],
"support": {
"issues": "https://github.com/webmozarts/assert/issues",
"source": "https://github.com/webmozarts/assert/tree/2.1.5"
"source": "https://github.com/webmozarts/assert/tree/2.3.0"
},
"time": "2026-02-18T14:09:36+00:00"
"time": "2026-04-11T10:33:05+00:00"
},
{
"name": "webmozart/glob",
@@ -6695,5 +6747,5 @@
"php": "^8.5"
},
"platform-dev": {},
"plugin-api-version": "2.9.0"
"plugin-api-version": "2.6.0"
}

View File

@@ -119,7 +119,6 @@ $resolveLoginCandidates = static function (string $inputEmail) use ($userReadRep
if ($tenantSlug === '') {
continue;
}
/** @phpstan-ignore ternary.alwaysFalse ($discovery is set to true inside the !$tenants branch that also reassigns $tenants) */
$methods = $discovery
? ($discoveryMethodsByTenantId[$tenantId] ?? ['local' => false, 'microsoft' => false, 'microsoft_reason' => '', 'ldap' => false, 'ldap_reason' => ''])
: $tenantSsoService->resolveTenantLoginMethods($tenantId);

2719
phpstan-baseline.neon Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,7 @@
includes:
- vendor/tomasvotruba/unused-public/config/extension.neon
- phpstan-baseline.neon
parameters:
level: 5
phpVersion: 80499