Skip to content

Add tips to the rule errors - #363

Merged
michielgerritsen merged 1 commit into
masterfrom
feature/167-rule-error-tips
Nov 27, 2026
Merged

michielgerritsen merged 1 commit into
masterfrom
feature/167-rule-error-tips

Conversation

@michielgerritsen

Copy link
Copy Markdown
Contributor

Fixes #167. Each of the five rules now emits a RuleErrorBuilder::tip() explaining why the rule fired and how to fix the code, with links to the service-contracts devdocs and the extdn sniff doc where one exists. The five rule tests assert the tip texts, so a changed or dropped tip fails the suite. Tips never enter baselines, ignoreErrors matching, or checkstyle output, so existing consumer configurations keep working after an upgrade. Verified on PHPStan 2.2.14 and 2.3.7: full suite green, composer analyze and cs-check clean.

Each of the five rules now emits a RuleErrorBuilder tip explaining
why the rule fired and how to fix the code: inject the collection
factory, use the entity's repository (with a devdocs link), pass a
Collection subclass to getCollectionMock(), inject the resource
model, or set the block template via layout XML or constructor data.

The rule tests assert the tips, so a changed or dropped tip fails
the suite.
@shochdoerfer

Copy link
Copy Markdown
Member

@michielgerritsen you should have taken over a lot sooner :) Great work!

Happy to see the extension is still kicking (more than 5K installs in the last 24 hours says packagist).

michielgerritsen added a commit that referenced this pull request Nov 21, 2026
Bumping the floor to ^2.2 would hold the next release back from
every consumer still resolving PHPStan 2.0/2.1. The only reason for
the bump was the test suite itself: it mocked MutatingScope, which
those releases declare final. The test mocks plain Scope again and
the Scope&DependencyTracker analyze error that PHPStan >= 2.3
reports for that mock is ignored in phpstan.neon, with
reportUnmatched off because older releases never emit it.

The compat floor leg moves from 2.2.0 to 2.0.0, so the full
advertised range is executed: verified locally on 2.0.0 (including
the rule tip assertions from #363) and 2.3.7, 114 tests green on
both, analyze clean on 2.2.14 and 2.3.7.
@michielgerritsen

Copy link
Copy Markdown
Contributor Author

Haha thanks @shochdoerfer!

@michielgerritsen

Copy link
Copy Markdown
Contributor Author

Closing and reopening to rebuild the merge ref against master, which now includes #364, so this PR runs the new compat and real-codebase checks.

@michielgerritsen
michielgerritsen merged commit f5e4896 into master Nov 27, 2026
16 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.

Feature Request: Add tips for rule errors

2 participants