[wp-trac] [WordPress Trac] #52217: Fix code issues identified by PHPStan
WordPress Trac
noreply at wordpress.org
Mon Jul 19 19:48:11 UTC 2021
#52217: Fix code issues identified by PHPStan
-------------------------+-------------------------------
Reporter: johnbillion | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: 5.9
Component: General | Version:
Severity: normal | Resolution:
Keywords: has-patch | Focuses: coding-standards
-------------------------+-------------------------------
Comment (by johnbillion):
Thanks for the comments! I'll go through the comments on the PR shortly
and respond there, but I just wanted to say that ''any'' additional
tooling or testing we introduce into WordPress will require significant
configuration and, as evidenced by the phpstan.neon.dist file in my PR, a
significant number of exceptions. This should not be a reason to discount
introducing tooling that can identify bugs.
As Viktor mentioned, PHPStan has a specific solution for introducing its
analysis into a legacy codebase. You can generate a baseline report which
represents the current state of the project, and then you can configure
the level of checking for any newly introduced code. Docs:
https://phpstan.org/user-guide/baseline.
PHPStan works great on strictly typed codebases but it does much more than
type checking. In fact it doesn't do any type checking until you configure
it to use level 3 or higher. At level 1, which I've used in my PR, it
checks for unknown symbols, wrong numbers of arguments, and undefined
variables. Docs: https://phpstan.org/user-guide/rule-levels.
All of the errors that are flagged by PHPStan at level 0 and 1 are
legitimate code errors that need to be fixed. Only once you move into
level 2 and above does it tackle errors that are based on the validity of
type hints, return types, and PHPDoc tag types.
Ticket #51423 is a rabbit hole. This ticket is much more narrowly focused.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/52217#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list