Add PHPStan static analysis#34
Merged
Merged
Conversation
The boilerplate showcases plugin tooling best practice but has had no static analysis since an earlier Psalm setup was removed, leaving only a stray export-ignore behind. Add PHPStan with the WordPress extension (auto-registered via phpstan/extension-installer) and a composer "phpstan" script. Analysis covers src/ and the main plugin file at the highest level, passing with no baseline and no ignores. The views/ and config/ templates are excluded because they depend on variables injected into their scope at runtime, which PHPStan cannot see.
Level 9's checkExplicitMixed rejects the untyped boundary of config-driven code: the BrightNucleus Config accessors return mixed by design, so the settings registration landing in the plugin-correctness branch would fail at max. Level 8 keeps every other strictness and the reasoning is recorded in the config for future revisiting.
…GaryJones/phpstan # Conflicts: # composer.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The boilerplate has lacked static analysis since an earlier Psalm setup was removed (a stray
psalm.xmlexport-ignore is all that remains). This adds PHPStan with the WordPress extension, auto-registered throughphpstan/extension-installer, plus acomposer phpstanscript. Analysis runs at level 8 with no baseline and no ignores. Level 9 would addcheckExplicitMixed, which rejects the untyped boundary of config-driven code — the BrightNucleus Config accessors returnmixedby design — so 8 is the honest ceiling, with the reasoning recorded in the config. Theviews/andconfig/templates are excluded as they rely on variables injected into their scope at runtime. The change is cleanly declinable. This PR is stacked on #40 (both touch adjacentcomposer.jsonlines, so the conflict is resolved here in a merge commit); it retargets to main automatically once #40 merges.