Skip to content

Fix duplicate parameter and template tags and shapes of generic arrays - #497

Open
danog wants to merge 5 commits into
php-stubs:masterfrom
danog:duplicate-and-invalid-tags
Open

danog wants to merge 5 commits into
php-stubs:masterfrom
danog:duplicate-and-invalid-tags

Conversation

@danog

@danog danog commented Oct 20, 2026 •

Copy link
Copy Markdown

Builds on #498 (please merge that first). Only the generator changes; no core tag is removed.

  • array<K, V>{…} and T[]{…} from hash notations (a parse error in PHPStan, so the tag was ignored) become unsealed shapes that keep core's key and value types, e.g. array{in_footer?: bool, fetchpriority?: 'auto'|'low'|'high', ...<string, string|bool>}. The string stripping no longer runs inside <…>, which had turned core's array<string, string|bool> into array<string, bool>. Nested lists (array[][]) become array<int|string, array<array-key, array{…}>>.
  • A @phpstan-param generated from a hash notation gives way to the functionMap's param of the same name (add_settings_field, get_categories), and functionMap @phpstan-param/@phpstan-template tags give way to core's own (stripslashes_from_strings_only), like Preserve existing phpstan-return tags when applying function map #498 does for returns.
  • functionMap: the missing of in WP_Dependencies::query's @phpstan-template TStatus, and a @phpstan-return for WP_Image_Editor::get_output_format(), whose core @return is invalid.

PHPStan parse errors in the stubs go from 8 to 1 (a SimplePie @internal comment). Left as is: wpdb::prepare documents $args twice in core.

https://claude.ai/code/session_01WNSb29tptiTQoc44Tk7XZW

@szepeviktor

Copy link
Copy Markdown
Member

Buon giorno Daniil!
Thank you for your PR.

Could you modify/fix the existing mechanism?

@danog

danog commented Oct 20, 2026

Copy link
Copy Markdown
Author

Sure, sorry, hang on

@szepeviktor

Copy link
Copy Markdown
Member

Please see #498 before you continue.

danog added 2 commits October 20, 2026 13:08
Map parameters replace the ones generated from the hash notation, and map
parameters and templates do not duplicate the ones written in core, like
map return types since php-stubs#498.

PHPStan doesn't support shapes of generic arrays (array<K, V>{...}), so
they become unsealed shapes (array{..., ...<K, V>}), and the string type
of args parameters is only removed from the top-level union. Lists of
lists of shapes are nested generic arrays.

Claude-Session: https://claude.ai/code/session_01WNSb29tptiTQoc44Tk7XZW
@danog
danog force-pushed the duplicate-and-invalid-tags branch from c97d7a3 to ce912e0 Compare October 20, 2026 11:26
@danog danog changed the title Remove duplicate tags and fix array shapes of generic array types Fix duplicate parameter and template tags and shapes of generic arrays Oct 20, 2026
@szepeviktor

Copy link
Copy Markdown
Member

The dilemma: our types or core types.
Please wait for Weston.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants