Skip to content

re #96 raise PHPStan to level 8, zero baseline (completes #96)#114

Merged
tonydspaniard merged 1 commit into
masterfrom
chore/96-burndown-level8
May 28, 2026
Merged

re #96 raise PHPStan to level 8, zero baseline (completes #96)#114
tonydspaniard merged 1 commit into
masterfrom
chore/96-burndown-level8

Conversation

@tonydspaniard
Copy link
Copy Markdown
Member

Summary

Final step of #96: raises phpstan.neon.dist level 7 → 8 and fixes all 35 new findings at root cause across 11 packages. No baseline; PHPStan [OK] at level 8.

Level 8 is null-safety (method.nonObject, return.type, argument.type from nullable/mixed flows). Representative fixes:

  • Map::get()/remove() typed with @template TDefault@return TValue|TDefault, so the optional-default fallback is expressed honestly (TValue|null when no default) instead of a false non-null @return TValue. Behaviour unchanged (body still returns the default).
  • preg_replace string|null returns coalesced to the original input (Inflector, Pluralizer, Validator/CreditCardRule/IbanRule sanitize()).
  • PdoSessionAdapterAwareTrait extracts createConnection(): PDO so getConnection() provably returns non-null; DigestSignatureValidator returns false for unknown users; SDK emitters narrow ?SchemaType via a local !== null guard; IpRule/FiltersRunner null guards; HttpNotFoundException typed string $message.

#96 complete

This completes the static-analysis program:

  • Level 8 with no baseline file.
  • The only ignoreErrors remaining are documented, justified exceptions: ext-* stubs, public-API mixin traits, the intentional Cookie/CollectionTrait adapter-storage design, and Cycle's loose-union getRepository generic.

Test plan

  • composer stan (level 8, no baseline) — [OK] No errors
  • composer cs (cache-free) — clean
  • vendor/bin/rector process --dry-run (full) — clean
  • composer test — 5555 tests; only pre-existing local MongoSessionHandlerTest env errors (CI loads ext-mongodb)

Raise phpstan.neon.dist level 7 -> 8 and fix all 35 new findings at root
cause across 11 packages (parallel sub-agents + central verification). No
baseline; PHPStan [OK] at level 8. Full suite green (only the pre-existing
ext-mongodb-absent MongoSessionHandlerTest errors).

Level 8 is null-safety: method.nonObject, return.type, argument.type from
nullable/mixed flows. Representative fixes:
- Map::get()/remove() typed @template TDefault -> @return TValue|TDefault, so
  the optional-default fallback is expressed honestly (TValue|null with no
  default) instead of a false non-null @return TValue.
- preg_replace string|null returns coalesced to the original input (Inflector,
  Pluralizer, Validator/CreditCard/Iban sanitize()).
- PdoSessionAdapterAwareTrait extracts createConnection(): PDO so getConnection()
  provably returns non-null; DigestSignatureValidator returns false for unknown
  users; SDK emitters narrow ?SchemaType via a local !== null guard.
- IpRule/FiltersRunner null guards; HttpNotFoundException typed string $message.

This completes the #96 program: level 8 with no baseline file. The only
remaining ignoreErrors are documented, justified exceptions (ext-* stubs,
public-API mixin traits, the intentional Cookie/CollectionTrait adapter-storage
design, and Cycle's loose-union getRepository generic).
@tonydspaniard tonydspaniard merged commit 19caf71 into master May 28, 2026
3 checks passed
@tonydspaniard tonydspaniard deleted the chore/96-burndown-level8 branch May 28, 2026 10:49
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