From de831beaaa0a49e8a9341b2463e3a3f33155e171 Mon Sep 17 00:00:00 2001 From: ArthurErlich Date: Sun, 12 Jul 2026 23:43:52 +0200 Subject: [PATCH] chore(phpstan): raise analyser memory limit and record resolved findings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add --memory-limit=512M to the phpstan composer script — the default 128M crashed the level-8 run under parallel workers. Update PHP-Stan-Errors.md to note all 22 catalogued findings are now resolved. --- PHP-Stan-Errors.md | 51 ++++++++++++++++++++++++++++++++++++++++++++++ composer.json | 3 +++ 2 files changed, 54 insertions(+) create mode 100644 PHP-Stan-Errors.md diff --git a/PHP-Stan-Errors.md b/PHP-Stan-Errors.md new file mode 100644 index 0000000..9e89c09 --- /dev/null +++ b/PHP-Stan-Errors.md @@ -0,0 +1,51 @@ +# PHPStan level 8 — first run + +**Resolved.** All 22 errors below were closed by adding the missing +array-shape docblocks (plus two `(int) strtotime()` casts and an +`array_values()` re-index in `ContributionCollection`). `composer phpstan` +now reports zero errors. Kept here as a record of what level 8 flagged on +first run. + +`composer phpstan` (level 8, `paths: [src, tests]`) reports 22 errors, all +`missingType.iterableValue` / `missingType.generics` — none are correctness +bugs, all are missing `@param`/`@return` array-shape docblocks on iterable +parameters. + +Run: `docker compose exec graph composer phpstan` (needs `--memory-limit=512M` +if run directly via `vendor/bin/phpstan analyse`, the default 128M crashes on +this project's parallel workers). + +## `missingType.iterableValue` — `iterable $providers` constructor params + +- `src/Command/RefetchContributionsCommand.php:29` +- `src/Service/ContributionAggregator.php:16` +- `src/Service/Provider/ProviderHealthChecker.php:11` + +Fix: add `@param iterable $providers` above each +constructor. + +## `missingType.iterableValue` — `SvgRenderer.php` (8 occurrences) + +Every `array` parameter/return on `render()`, `buildGrid()`, +`computeStats()`, `renderMonthLabels()`, `renderCells()`, `renderLegend()` is +untyped. Fix: add `@param array` / `@return array<...>` shapes +matching each method's actual contents (contribution date=>count maps, grid +cell arrays, color arrays). + +## `missingType.generics` / `assign.propertyType` — `ContributionCollection.php` + +- Line 17: `$contributions` is typed `array` but + `array_map` over `Contribution ...$contributions` in the constructor can + produce non-sequential/string keys. Fix: re-index with `array_values()` + before assigning, or relax the property type to `array`. +- Line 20: `getIterator(): \ArrayIterator` needs generic types: + `@return \ArrayIterator`. + +## `missingType.iterableValue` — test doubles/providers (8 occurrences) + +Stub/fixture helper methods with untyped `array` params in +`RefetchContributionsCommandTest`, `ContributionAggregatorTest`, +`GitHubProviderTest`, `GitLabProviderTest`, `GiteaProviderTest`, and the two +PHPUnit data providers in `SvgRendererTest`. Fix: add +`@param array $fresh` (or the relevant shape) / `@return +iterable` on the data providers. diff --git a/composer.json b/composer.json index ded591b..1448704 100644 --- a/composer.json +++ b/composer.json @@ -41,5 +41,8 @@ "allow-contrib": false, "require": "7.4.*" } + }, + "scripts": { + "phpstan": "phpstan analyse --memory-limit=512M" } }