Commit a1314bb
committed
Code Modernization: Use
This commit replaces several `foreach` loops that iterate an array, return `true` as soon as an element matches a condition, and otherwise fall through to `false`. That is exactly what PHP 8.4's `array_any()` expresses in a single, more readable call.
WordPress core includes a polyfill for `array_any()` on PHP < 8.4 as of WordPress 6.8, so the change works on every supported PHP version without raising the minimum requirement.
Follow-up to [59783].
Props Soean, mukesh27, SergeyBiryukov.
See #65519.
git-svn-id: https://develop.svn.wordpress.org/trunk@62550 602fd350-edb4-49c9-b593-d223f7449a82array_any() where appropriate.1 parent 859d7fe commit a1314bb
7 files changed
Lines changed: 8 additions & 47 deletions
File tree
- src
- wp-admin/includes
- wp-includes
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3834 | 3834 | | |
3835 | 3835 | | |
3836 | 3836 | | |
3837 | | - | |
3838 | | - | |
3839 | | - | |
3840 | | - | |
3841 | | - | |
3842 | | - | |
3843 | | - | |
| 3837 | + | |
3844 | 3838 | | |
3845 | 3839 | | |
3846 | 3840 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1980 | 1980 | | |
1981 | 1981 | | |
1982 | 1982 | | |
1983 | | - | |
1984 | | - | |
1985 | | - | |
1986 | | - | |
1987 | | - | |
1988 | | - | |
1989 | | - | |
| 1983 | + | |
| 1984 | + | |
1990 | 1985 | | |
1991 | 1986 | | |
1992 | 1987 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1461 | 1461 | | |
1462 | 1462 | | |
1463 | 1463 | | |
1464 | | - | |
1465 | | - | |
1466 | | - | |
1467 | | - | |
1468 | | - | |
1469 | | - | |
1470 | | - | |
| 1464 | + | |
1471 | 1465 | | |
1472 | 1466 | | |
1473 | 1467 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1598 | 1598 | | |
1599 | 1599 | | |
1600 | 1600 | | |
1601 | | - | |
1602 | | - | |
1603 | | - | |
1604 | | - | |
1605 | | - | |
1606 | | - | |
1607 | | - | |
| 1601 | + | |
1608 | 1602 | | |
1609 | 1603 | | |
1610 | 1604 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
850 | 850 | | |
851 | 851 | | |
852 | 852 | | |
853 | | - | |
854 | | - | |
855 | | - | |
856 | | - | |
857 | | - | |
858 | | - | |
| 853 | + | |
859 | 854 | | |
860 | 855 | | |
861 | 856 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
459 | 459 | | |
460 | 460 | | |
461 | 461 | | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
| 462 | + | |
468 | 463 | | |
469 | 464 | | |
470 | 465 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2056 | 2056 | | |
2057 | 2057 | | |
2058 | 2058 | | |
2059 | | - | |
2060 | | - | |
2061 | | - | |
2062 | | - | |
2063 | | - | |
2064 | | - | |
2065 | | - | |
| 2059 | + | |
2066 | 2060 | | |
2067 | 2061 | | |
2068 | 2062 | | |
| |||
0 commit comments