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

WordPress Trac noreply at wordpress.org
Sun Jul 13 10:18:33 UTC 2025


#61175: Integrate PHPStan into the core development workflow
--------------------------------------+-------------------------
 Reporter:  westonruter               |       Owner:  justlevine
     Type:  enhancement               |      Status:  assigned
 Priority:  normal                    |   Milestone:  6.9
Component:  General                   |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+-------------------------

Comment (by justlevine):

 For all the lovely folks coming here from the
 [https://make.wordpress.org/core/2025/07/11/proposal-phpstan-in-the-
 wordpress-core-development-workflow/ Make/Core proposal] here's a quick
 summary of where things stand:

 1. This ''ticket'' proposes adding PHPStan to the development workflow:
   - in an incremental fashion
   - without unnecessary refactoring
   - without unnecessarily disrupting existing WPCS

 2. [https://github.com/WordPress/wordpress-
 develop/pull/7619#issuecomment-2904464413 PR #7619] is a ''proof of
 concept'' demonstrating how it can be done.
   - It proposes a structure for the base config, and using both
 allowlisted errors + "baselines" of existing errors to make incremental
 progress.
   - It manually splits the existing baselines of tech-debt by
 [https://github.com/justlevine/wordpress-
 develop/tree/feat/phpstan/tests/phpstan/baseline individual PHPStan
 level], so proposal reviewers can get a better feel of what sort of errors
 each level addresses, and to help visualize the in-parallel remediation
 efforts (tracked in #63268).

 3. What's still needed:
    - Determine what PHPStan level to use when scanning ''new'' code. (I
 used level 6 because my goal was visualization, but there's level 7+
 errors that can't be baselined)
    - Review the baselines for those levels, and decide if that rule should
 be ignored for ''new'' code or stay in the baseline. (E.g. if there's
 something that conflicts with existing WPCS).
    - Finalize the config + squash the baseline.
    - Document:
      - using PHPStan (linting, ignoring/remediating, cli)
      - maintaining the PHPStan config (for committers/component
 maintainers)
      - the process for adopting stricter PHPStan rules/levels in the
 future

 4. What's beyond the scope:
    - Fixing PHPStan errors in existing code (they are baselined until each
 one is explicitly ignored or remediated)
    - Updating WPCS to take advantage of PHPStan features and/or changes to
 our PHPDoc parser to accommodate. (There's no reason to delay the
 immediate value that PHPStan offers without those features by trying to
 reach consensus on that can of worms)

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


More information about the wp-trac mailing list