[wp-trac] [WordPress Trac] #61175: Integrate PHPStan into the core development workflow
WordPress Trac
noreply at wordpress.org
Fri Dec 5 15:00:15 UTC 2025
#61175: Integrate PHPStan into the core development workflow
-------------------------------------------------+-------------------------
Reporter: westonruter | Owner: justlevine
Type: enhancement | Status: assigned
Priority: normal | Milestone: Future
| Release
Component: General | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests changes- | Focuses:
requested |
-------------------------------------------------+-------------------------
Comment (by joehoyle):
This may be a tangential point-- but I think relevant to PHPStan:
WordPress's custom format / syntax for marking up array-shapes in phpdoc
AFAIK is not understood by PHPStan (or Psalm, or Phan, or Mago). All these
tools have adopted the syntax:
{{{#!php
<?php
/**
* @param array{
* blockName: string,
* attrs: array<string, mixed>,
* innerBlocks: array<array>,
* innerHTML: string,
* innerContent: array<int, string|null>
* } $block
*/
}}}
As opposed to
{{{#!php
<?php
@return array[] {
@type array ...$0 {
@type string $blockName
@type array $attrs
@type array[] $innerBlocks
}
}
}}}
I'm not that familiar with the history of how WordPress' (current) syntax
came about, but it's a point of difficulty when using static analysis
tools that the types of Core functions is not parse-able by said tools.
I assume one reason the current style was adopted is because each array
key can have a human readable description-- I'm not sure if the
phpstan/psalm/etc format has a way to do that.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61175#comment:54>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list