Skip to content

Add Docblock Check CI for @param/@return array types - #8469

Open
TomasVotruba wants to merge 5 commits into
mainfrom
tv-docblock-check-ci
Open

Add Docblock Check CI for @param/@return array types#8469
TomasVotruba wants to merge 5 commits into
mainfrom
tv-docblock-check-ci

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Adds a CI job that spots inaccurate array docblock types (Type[], string[], ...) by checking them against real runtime values while the test suite runs.

What it does

  • Installs rectorphp/honestype via go install
  • Instruments src and rules: injects an element-type check for every single-dimension @param T[] / @return T[]
  • Runs fastunit over tests rules-tests utils/phpstan/tests to collect mismatches
  • Restores the sources, renders a Checkstyle report, and annotates the PR via reviewdog

Instrumentation is behavior-neutral: calls are guarded with function_exists, only real arrays are inspected (generators are left untouched), and unresolvable class types (e.g. @template params) are skipped. Verified against the full laravel/framework suite with error/failure counts identical to an uninstrumented baseline.

Current findings on this codebase

  • src/PhpParser/NodeTraverser/RectorNodeTraverser.php - @param Node[] / @return Node[] contain null at runtime
  • src/PhpParser/Printer/BetterStandardPrinter.php - @param Node[] contains null
  • src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php - @param Stmt[] contains a nested array

The job reports as warnings and does not fail the build.

@TomasVotruba
TomasVotruba force-pushed the tv-docblock-check-ci branch 4 times, most recently from 3c363c0 to 598304f Compare September 8, 2026 21:34
Runs honestype: instruments src and rules, collects docblock type
mismatches while the test suite runs, then lists them PHPStan-style and
fails the job when any are found. Also fixes one surfaced mismatch:
configure() @PARAM is string[], matching its Assert::allString and list values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant