WordPress.org

Make WordPress Core

Opened 8 weeks ago

Last modified 7 weeks ago

#52217 new enhancement

Fix code issues identified by PHPStan

Reported by: johnbillion Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: coding-standards Cc:

Description

In #51423 several issues were identified with function argument types that were detected by PHPStan.

There are other issues that PHPStan detects too such as potentially undefined variables, functions called with incorrect number of parameters, access to undefined properties, and more as you increase the level of checking performed.

We can scan core using the level 1 checks and catch quite a few low hanging fruit, and then go from there.

Follow-up task: Consider whether it's beneficial to add PHPStan (or Psalm or Phan) analysis to the build tooling and CI.

Change History (6)

This ticket was mentioned in PR #853 on WordPress/wordpress-develop by johnbillion.


8 weeks ago

  • Keywords has-patch has-unit-tests added

Trac ticket: https://core.trac.wordpress.org/ticket/52217

This introduces config for PHPStan with plenty of exclusions so we can identify real issues that need to be fixed.

#2 @johnbillion
8 weeks ago

  • Keywords has-patch has-unit-tests removed

#3 @jorbin
8 weeks ago

Left one comment about where we put the bootstrap file, otherwise, love this idea.

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

I lean towards yes

#4 @szepe.viktor
8 weeks ago

to add PHPStan (or Psalm or Phan) analysis to the build tooling and CI.

Let's lean towards PHPStan.

written by a PHPStan Advocate

#5 @johnbillion
8 weeks ago

In 49936:

Docs: Corrections and improvements to types used in various docblocks.

See #51800, #52217

#6 @johnbillion
7 weeks ago

In 49946:

Plugins: Replace usage of $this in action and filter parameter docblocks with more appropriate variable names.

See #51800, #52217

Fixes #52243

Note: See TracTickets for help on using tickets.