Skip to content

docs(types): array value types and missing PHPDoc tags for PHPStan level 6 (#44, lot A, 1/2) - #45

Merged
ogorzalka merged 1 commit into
mainfrom
chore/phpstan-level6-phpdoc
Dec 2, 2026
Merged

ogorzalka merged 1 commit into
mainfrom
chore/phpstan-level6-phpdoc

Conversation

@ogorzalka

@ogorzalka ogorzalka commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Part of #44, lot A (PHPStan level 6 in PHPDoc), first of two: array value types and missing @return / @param tags. No native signature changes. Apart from comments, the only line added to src is one use import (added by Pint for a docblock).

The analysed level stays at 5. phpstan.neon, phpstan-baseline.neon, .harness.json and api-surface.json are untouched.

PHPStan error counts (measured on 1068350, PHPStan 2.3.4)

Level 6 main this PR
with the current baseline 155 88
without the baseline 203 136

Remaining with the baseline: 77 missingType.generics, 10 missingType.iterableValue, 1 argument.templateType. The second PR handles the generics and lists what cannot move without regenerating the baseline.

Choices

  • Array types are written array<mixed>. It says nothing about the elements, on purpose: Colt's models are extension points, and a narrower type on a property that a subclass redeclares with @var array would be reported in that project's own analysis.
  • PostBuilder::search() documents $term as string|Arrayable|iterable|false|null instead of mixed (needed to resolve the collect() templates). A project passing something else, such as an integer, can now see a static analysis error.
  • Methods that return nothing now say @return void.

What this proves

  • With the baseline removed, the level 5 run gives the same 48 errors as main: same files, identifiers and messages. No baseline entry is retired, reworded or added.
  • composer qa:fast: every gate passed.
  • composer qa: exit 0, every gate that ran passed (280 tests passed, 1 incomplete). Ratchet: PHPStan level 5 and 48 baseline entries unchanged.
  • vendor/bin/rector process --dry-run: nothing to change.
  • pollora/framework (main, 64acf70), whose models extend Colt's: its PHPStan run gives the same output with Colt from main and from this branch (a single unrelated deprecation notice on local PHP 8.5).
  • CI on 5487ace: every check passes (the harness WordPress matrix job is skipped), including Semgrep, mutation testing on changed files, backward compatibility (QA-05) and the framework unit tests downstream. Line coverage 97.37 %.

What it does not prove

  • Semgrep is not installed on the machine used, and the WordPress tests, coverage, mutation and backward compatibility checks were not run locally: they rest on CI.
  • CI does not run the mutation score on the whole code base, only on changed files.
  • The new types are checked by PHPStan against Colt itself only, not against a user project.

@ogorzalka
ogorzalka merged commit 30a0103 into main Dec 2, 2026
17 checks passed
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