Skip to content

Chore: Bump PHPStan to level 7#246

Merged
loks0n merged 1 commit intomainfrom
chore/phpstan-level-7
Apr 24, 2026
Merged

Chore: Bump PHPStan to level 7#246
loks0n merged 1 commit intomainfrom
chore/phpstan-level-7

Conversation

@loks0n
Copy link
Copy Markdown
Contributor

@loks0n loks0n commented Apr 24, 2026

Summary

  • Adds generic array annotations (array<K, V>) and missing return types across src/ and tests/ to clear level 6.
  • Fixes a handful of unchecked string|false / resource|false call sites (file_get_contents, json_encode, ob_get_contents, opendir, Swoole rawContent) for level 7.
  • Bumps phpstan.neon from level 5 → 7.

Behaviour

No change on the happy path. The only runtime-visible changes are in previously-broken error paths: opendir() failure now throws instead of passing false into readdir(); FPM getHeader() joins array-valued headers with , instead of returning an array despite a : string return type.

Test plan

  • vendor/bin/phpstan analyse — clean at level 7
  • vendor/bin/pint --test — passes
  • CI on PR

🤖 Generated with Claude Code

Adds generic array annotations and return types throughout src/ and
tests/ to satisfy level 6, then hardens a handful of unchecked
`string|false` / `resource|false` call sites for level 7.

Behaviour is unchanged on the happy path; the only runtime-visible
changes are in previously-broken error paths (e.g. opendir() returning
false, getHeader() on array-valued headers).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

k6 benchmark

Throughput Requests Fail rate p50 p95
7958 req/s 557161 0% 4.68 ms 12.36 ms

@loks0n loks0n merged commit 288c943 into main Apr 24, 2026
9 checks passed
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 24, 2026

Greptile Summary

This PR bumps PHPStan from level 5 to level 7 across src/ and tests/, adding generic array annotations, explicit : void return types, and guards for string|false return sites (file_get_contents, json_encode, ob_get_contents, Swoole rawContent). The two runtime-visible behavior changes — opendir() now throws on failure instead of passing false to readdir(), and FPM getHeader() now joins multi-value headers with ', ' instead of returning an array — are both corrections of previously broken error paths.

Confidence Score: 5/5

Safe to merge — changes are confined to type annotations and previously-broken error paths with no impact on the happy path.

All findings are P2 or below. The annotation-only changes are mechanical and consistent. The two behavioral fixes (opendir throw, FPM header join) are improvements over the prior broken behavior and are documented in the PR description.

No files require special attention.

Important Files Changed

Filename Overview
phpstan.neon PHPStan level bumped from 5 to 7; no structural issues.
src/Http/Adapter/FPM/Request.php getHeader() now joins array-valued headers with ', '; file_get_contents fallback to '' added; array generic annotations updated.
src/Http/Files.php opendir() failure now throws an Exception instead of silently passing false to readdir().
src/Http/Response.php json_encode failure now falls back to '' via ?:; getHeaders() return type relaxed to string
src/Http/Adapter/Swoole/Request.php rawContent() result guarded with ?: '' to handle false return from Swoole.
src/Http/Adapter/Swoole/Server.php start() return value dropped (now void); onRequest/onStart/start get :void; settings @param annotated.
src/Http/Request.php Array generics added to all @var/@return/@param; parseContentRange return type narrowed to a typed tuple; file_get_contents guarded.
src/Http/Route.php $pathParams inner value type corrected from string to int (positions), consistent with Router::preparePath() return type.
src/Http/View.php ob_get_contents() fallback to '' added; array generics updated for params and filters.
tests/e2e/Client.php return type narrowed to array; empty-method guard added; @param order in docblock corrected to match actual signature.

Reviews (1): Last reviewed commit: "Chore: Bump PHPStan to level 7" | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant