[wp-trac] [WordPress Trac] #61175: Integrate PHPStan into the core development workflow

WordPress Trac noreply at wordpress.org
Wed May 8 22:32:49 UTC 2024


#61175: Integrate PHPStan into the core development workflow
-------------------------+-------------------------
 Reporter:  westonruter  |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  6.6
Component:  General      |    Version:
 Severity:  normal       |   Keywords:  needs-patch
  Focuses:               |
-------------------------+-------------------------
 [https://phpstan.org/ PHPStan] is a vital static analysis tool for
 identifying bugs in code. Previously it has been used to identify problems
 in core by manually running PHPStan on the core codebase:

 * #58852
 * #57782
 * #51423
 * #52217
 * #59653

 As @johnbillion suggests in #52217:

 > Consider whether it's beneficial to add PHPStan (or Psalm or Phan)
 analysis to the build tooling and CI.

 I suggest we incorporate PHPStan now into the workflow with a populated
 [https://phpstan.org/user-guide/baseline baseline] that captures all of
 the existing issues and ignores them so that everything doesn't have to be
 fixed up front. This baseline will then allow new issues to be reported as
 they are introduced in the codebase, again without having to fix
 everything up-front.

 We can start with either [https://phpstan.org/user-guide/rule-levels rule
 level] 0 or 1 and then go from there as we fix issues in the codebase. It
 may not make sense to implement the highest levels.

 For reference, the Performance team has implemented PHPStan as part of the
 Performance Lab codebase and there have been separate PRs fixing issues
 for each level ([https://github.com/WordPress/performance/pull/1198 1],
 [https://github.com/WordPress/performance/pull/1199 2],
 [https://github.com/WordPress/performance/pull/1200 3],
 [https://github.com/WordPress/performance/pull/1201 4],
 [https://github.com/WordPress/performance/pull/1202 5],
 [https://github.com/WordPress/performance/pull/1203 6],
 [https://github.com/WordPress/performance/pull/1205 7]). It is remarkable
 how effective it is at identifying problems.

 PHPStan should be run alongside PHPCS in GHA and locally as part of the
 pre-commit checks.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61175>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list