Repository navigation
Commit 88f65d1
Docs: Bring the types from php-stubs/wordpress-stubs' function map into core.
php-stubs/wordpress-stubs, from which every plugin's static analysis takes its view of core, applies a map of PHPStan types on top of core's docblocks when it generates the stubs: conditional return types, narrowed parameters, templates, purity and a few class-level annotations. szepeviktor/phpstan-wordpress dropped its own return type extensions in favor of that map. Each entry is a type core could carry itself, and one carried here reaches core's own analysis, the stubs, and every plugin from one place.
This adds the map's entries to the docblocks of the 290 functions, methods, properties and classes it names, as `@phpstan-` tags. An entry is left out where core already carries a `@phpstan-return` or template for the symbol, where the parameter or return is documented with hash notation that `HashNotationVisitor` derives a shape from, or where the symbol lives in Gutenberg. A few entries were wrong for core and are adjusted or dropped: `add_shortcode()` callbacks receive a string rather than an array when a shortcode has no attributes, `_get_list_table()` accepts a `WP_Screen` as well as a name, `get_tag_regex()` and `wp_get_inline_script_tag()` do return an empty string, `wp_update_comment()` returns the row count `wpdb::update()` does, `size_format()` and `get_tags()` are stated in terms of what core's parameter and `get_terms()` types allow, `get_html_split_regex()`, `block_version()` and `wp_is_uuid()` are not pure, and the `WP_REST_Request` generics report every offset assignment in core as an error and are not adopted.
Five calls the new types show to be passing something other than the documented value are corrected: `wp_upload_bits()` and `add_option()` are given the value their deprecated parameter documents, `iframe_header()` is no longer given a deprecated argument, `switch_to_blog()` is given the site ID as an int, and `get_term_to_edit()` documents the `WP_Term` it returns.
The baselines lose 53 entries the new types resolve, including every `parameter.defaultValue` and `method.nonObject` error, and gain 8: seven reworded, and one `WP_Term_Query::populate_terms()` assignment on what `get_term()` may return that is worth a look of its own.
Co-authored-by: Pascal Birchler <pascal.birchler@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013QJ9RphuttTR7cS5G4mU211 parent c60fe94 commit 88f65d1
89 files changed
Lines changed: 921 additions & 284 deletions
File tree
- src
- wp-admin
- includes
- wp-includes
- block-supports
- l10n
- tests/phpstan/baselines
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| 29 | + | |
| 30 | + | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
| |||
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
59 | 66 | | |
60 | 67 | | |
61 | 68 | | |
| |||
122 | 129 | | |
123 | 130 | | |
124 | 131 | | |
| 132 | + | |
| 133 | + | |
125 | 134 | | |
126 | 135 | | |
127 | 136 | | |
| |||
170 | 179 | | |
171 | 180 | | |
172 | 181 | | |
| 182 | + | |
| 183 | + | |
173 | 184 | | |
174 | 185 | | |
175 | 186 | | |
| |||
296 | 307 | | |
297 | 308 | | |
298 | 309 | | |
| 310 | + | |
| 311 | + | |
299 | 312 | | |
300 | 313 | | |
301 | 314 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
| |||
47 | 51 | | |
48 | 52 | | |
49 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
50 | 57 | | |
51 | 58 | | |
52 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
| |||
54 | 58 | | |
55 | 59 | | |
56 | 60 | | |
| 61 | + | |
| 62 | + | |
57 | 63 | | |
58 | 64 | | |
59 | 65 | | |
| |||
310 | 316 | | |
311 | 317 | | |
312 | 318 | | |
| 319 | + | |
| 320 | + | |
313 | 321 | | |
314 | 322 | | |
315 | 323 | | |
| |||
1169 | 1177 | | |
1170 | 1178 | | |
1171 | 1179 | | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
1172 | 1187 | | |
1173 | 1188 | | |
1174 | 1189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
319 | 319 | | |
320 | 320 | | |
321 | 321 | | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
322 | 325 | | |
323 | 326 | | |
324 | 327 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
635 | 635 | | |
636 | 636 | | |
637 | 637 | | |
638 | | - | |
| 638 | + | |
639 | 639 | | |
640 | 640 | | |
641 | 641 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
20 | 29 | | |
21 | 30 | | |
22 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1238 | 1238 | | |
1239 | 1239 | | |
1240 | 1240 | | |
| 1241 | + | |
| 1242 | + | |
1241 | 1243 | | |
1242 | 1244 | | |
1243 | 1245 | | |
| |||
1316 | 1318 | | |
1317 | 1319 | | |
1318 | 1320 | | |
| 1321 | + | |
| 1322 | + | |
1319 | 1323 | | |
1320 | 1324 | | |
1321 | 1325 | | |
| |||
1349 | 1353 | | |
1350 | 1354 | | |
1351 | 1355 | | |
| 1356 | + | |
| 1357 | + | |
1352 | 1358 | | |
1353 | 1359 | | |
1354 | 1360 | | |
| |||
1638 | 1644 | | |
1639 | 1645 | | |
1640 | 1646 | | |
| 1647 | + | |
| 1648 | + | |
1641 | 1649 | | |
1642 | 1650 | | |
1643 | 1651 | | |
| |||
1932 | 1940 | | |
1933 | 1941 | | |
1934 | 1942 | | |
| 1943 | + | |
| 1944 | + | |
1935 | 1945 | | |
1936 | 1946 | | |
1937 | 1947 | | |
| |||
3014 | 3024 | | |
3015 | 3025 | | |
3016 | 3026 | | |
| 3027 | + | |
| 3028 | + | |
3017 | 3029 | | |
3018 | 3030 | | |
3019 | 3031 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
211 | 216 | | |
212 | 217 | | |
213 | 218 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1257 | 1257 | | |
1258 | 1258 | | |
1259 | 1259 | | |
| 1260 | + | |
| 1261 | + | |
1260 | 1262 | | |
1261 | 1263 | | |
1262 | 1264 | | |
| |||
0 commit comments