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.
2.4 KiB
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:29src/Service/ContributionAggregator.php:16src/Service/Provider/ProviderHealthChecker.php:11
Fix: add @param iterable<ProviderInterface> $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<string, int> / @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:
$contributionsis typedarray<int, Contribution>butarray_mapoverContribution ...$contributionsin the constructor can produce non-sequential/string keys. Fix: re-index witharray_values()before assigning, or relax the property type toarray<array-key, Contribution>. - Line 20:
getIterator(): \ArrayIteratorneeds generic types:@return \ArrayIterator<int, Contribution>.
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<string, int> $fresh (or the relevant shape) / @return iterable<string, array{...}> on the data providers.