Skip to content

chore: analyse the PHP samples of the user guide with PHPStan - #10779

Open
paulbalandan wants to merge 4 commits into
codeigniter4:developfrom
paulbalandan:docs-samples-phpstan
Open

paulbalandan wants to merge 4 commits into
codeigniter4:developfrom
paulbalandan:docs-samples-phpstan

Conversation

@paulbalandan

@paulbalandan paulbalandan commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Description
The PHP samples in the user guide are style-checked, but not for correctness. Some called methods or constants that do not exist, or had signatures that did not match the class they extend.

This adds php admin/lint-docs-samples.php --phpstan, which analyses the samples with PHPStan using the root configuration (or --phpstan-config). Errors are reported against the page and line, with working editor links.

  • admin/docs-phpstan-baseline.php holds the exceptions. The general ignores at the top are written by hand. The baseline part, the samples to skip and the errors ignored per sample, is written by php admin/lint-docs-samples.php --generate-baseline.
  • The PHPStan workflow runs the check, and fails when the baseline is out of date.
  • contributing/documentation.md describes both commands.
  • The second commit fixes what the check found: missing types, wrong calls and constants, and a few outdated samples.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

Comment thread admin/docs-phpstan-baseline.php Resolved
@paulbalandan
paulbalandan force-pushed the docs-samples-phpstan branch 2 times, most recently from 763a29c to 780f2c4 Compare November 18, 2026 14:27

This branch has not been deployed

No deployments
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.

2 participants