Repository navigation
Commit 4293f64
committed
Code Quality: Fix the
The `$args` parameter was documented as accepting only an array, even though a deprecated integer number of posts is still accepted. PHPStan therefore concluded that the deprecated branch could never run, and reported the value passed to `absint()` there as an unresolvable type. Documenting the integer form, as was done for `wp_get_typography_font_size_value()` in r64163, empties the `argument.unresolvableType` baseline, so it is removed.
For static analysis the integer is narrowed to `positive-int`, since `absint()` silently turns a negative number into a positive count and `0` falls back to the `posts_per_page` option. A hash now documents the arguments whose defaults differ from those of `get_posts()`.
At level 10 the parsed arguments could not be passed to `get_posts()`, because the inline `@var` typed only `fields`. It now types the keys that `get_posts()` documents. Instead of being asserted to be `null`, `fields` is limited to `''` or `'all'`, since a caller asking for IDs would make `get_object_vars()` throw a `TypeError` with the default `ARRAY_A` output. The `include` and `exclude` defaults become empty arrays to match their documented type, which has no runtime effect.
Developed in #15450.
Follow-up to r62648, r63024, r64163.
Props mukesh27, westonruter.
See #66739.
git-svn-id: https://develop.svn.wordpress.org/trunk@65783 602fd350-edb4-49c9-b593-d223f7449a82$args types of wp_get_recent_posts().1 parent 20f9614 commit 4293f64
2 files changed
Lines changed: 31 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4708 | 4708 | | |
4709 | 4709 | | |
4710 | 4710 | | |
4711 | | - | |
4712 | | - | |
4713 | | - | |
4714 | | - | |
| 4711 | + | |
| 4712 | + | |
| 4713 | + | |
| 4714 | + | |
| 4715 | + | |
| 4716 | + | |
| 4717 | + | |
| 4718 | + | |
| 4719 | + | |
| 4720 | + | |
| 4721 | + | |
| 4722 | + | |
| 4723 | + | |
| 4724 | + | |
| 4725 | + | |
| 4726 | + | |
4715 | 4727 | | |
4716 | 4728 | | |
4717 | 4729 | | |
| 4730 | + | |
| 4731 | + | |
| 4732 | + | |
| 4733 | + | |
| 4734 | + | |
| 4735 | + | |
| 4736 | + | |
| 4737 | + | |
| 4738 | + | |
| 4739 | + | |
| 4740 | + | |
| 4741 | + | |
4718 | 4742 | | |
4719 | 4743 | | |
4720 | 4744 | | |
| |||
4734 | 4758 | | |
4735 | 4759 | | |
4736 | 4760 | | |
4737 | | - | |
4738 | | - | |
| 4761 | + | |
| 4762 | + | |
4739 | 4763 | | |
4740 | 4764 | | |
4741 | 4765 | | |
4742 | 4766 | | |
4743 | 4767 | | |
4744 | 4768 | | |
4745 | 4769 | | |
4746 | | - | |
| 4770 | + | |
4747 | 4771 | | |
4748 | 4772 | | |
4749 | 4773 | | |
| |||
This file was deleted.
0 commit comments