Repository navigation
Commit 933e2cb
committed
Docs: Add PHPStan types for optional callback parameters.
The `add_*_page()` functions and the `Custom_Background` and `Custom_Image_Header` constructors default their callback to an empty string, and plugins as well as core pass `null` to them, neither of which a plain `callable` allows. Their callbacks are now documented as `''|(callable(): mixed)|null`, since the page and header hooks invoke them without arguments. The type is written out at each use rather than declared as a global alias, as aliases defined only for core's own analysis are lost to anyone analyzing against core's source or the stubs generated from it.
The deprecated third parameter of `unregister_setting()` is narrowed to its default of an empty string, in the same way as other unused deprecated parameters, so that static analysis flags callers still passing a sanitize callback. The callbacks of `register_activation_hook()`, `register_deactivation_hook()`, `register_uninstall_hook()`, and `add_feed()` are documented with the arguments core calls them with.
This resolves every entry in the `parameter.defaultValue` PHPStan baseline, so that baseline is removed.
Developed in #13890.
Follow-up to r63020, r64163, r64756.
Props swissspidy, marian1, westonruter.
See #65817.
git-svn-id: https://develop.svn.wordpress.org/trunk@64793 602fd350-edb4-49c9-b593-d223f7449a821 parent a844bea commit 933e2cb
9 files changed
Lines changed: 174 additions & 238 deletions
File tree
- src
- wp-admin/includes
- wp-includes
- tests/phpstan/baselines
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | 54 | | |
56 | 55 | | |
57 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
29 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
| |||
43 | 47 | | |
44 | 48 | | |
45 | 49 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
50 | 57 | | |
51 | 58 | | |
52 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
29 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
| |||
51 | 55 | | |
52 | 56 | | |
53 | 57 | | |
54 | | - | |
55 | | - | |
56 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
57 | 65 | | |
58 | 66 | | |
59 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1427 | 1427 | | |
1428 | 1428 | | |
1429 | 1429 | | |
1430 | | - | |
1431 | | - | |
1432 | | - | |
1433 | | - | |
1434 | | - | |
1435 | | - | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
1436 | 1436 | | |
| 1437 | + | |
| 1438 | + | |
1437 | 1439 | | |
1438 | 1440 | | |
1439 | 1441 | | |
| |||
1460 | 1462 | | |
1461 | 1463 | | |
1462 | 1464 | | |
1463 | | - | |
1464 | | - | |
1465 | | - | |
1466 | | - | |
1467 | | - | |
1468 | | - | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
1469 | 1471 | | |
| 1472 | + | |
| 1473 | + | |
1470 | 1474 | | |
1471 | 1475 | | |
1472 | 1476 | | |
| |||
0 commit comments