Stub sealed array excluding valid cases - #485
Merged
Merged
Conversation
Fix two WordPress function where a shortened list of array arguments gives the wrong sealed array
Member
|
@PeterSmith8nss I am so sorry. There is no |
Contributor
Author
|
Latest commit has add_settings_field $args defined as 'args' => 'array{label_for?:string,class?:string,...}' which matches the definition: And include "label_for" |
Member
IanDelMar
reviewed
Sep 1, 2026
| 'get_calendar' => ['($args is array{display: false, ...} ? string : void)'], | ||
| 'get_category_parents' => [null, 'deprecated' => 'array{}'], | ||
| 'get_categories' => ["(\$args is array{fields: 'count', ...} ? list<numeric-string> : (\$args is array{fields: 'names'|'slugs', ...} ? list<string> : (\$args is array{fields: 'id=>name'|'id=>slug', ...} ? array<int, string> : (\$args is array{fields: 'id=>parent', ...} ? array<int, int> : (\$args is array{fields: 'ids'|'tt_ids', ...} ? list<int> : array<int, \WP_Term>)))))", 'args' => 'array{taxonomy?:string,...}'], | ||
| 'get_categories' => ["(\$args is array{fields: 'count', ...} ? list<numeric-string> : (\$args is array{fields: 'names'|'slugs', ...} ? list<string> : (\$args is array{fields: 'id=>name'|'id=>slug', ...} ? array<int, string> : (\$args is array{fields: 'id=>parent', ...} ? array<int, int> : (\$args is array{fields: 'ids'|'tt_ids', ...} ? list<int> : array<int, \WP_Term>)))))", 'args' => 'string|array{taxonomy?:string,...}'], |
Contributor
There was a problem hiding this comment.
php-stubs/wordpress-stubs typically does not allow query strings.
wordpress-stubs/src/Visitor.php
Lines 576 to 578 in 3945703
This was referenced Sep 2, 2026
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Array shapes generated for standard stubs are treated as sealed arrays by PHPStan 2,2. In some cases, the stub generator does not allow for all the elements that are allowed in those arrays, e.g. they are incorrectly sealed.
Two examples:
I've modified the function map as follows: