Repository navigation
Commit 15e95f3
committed
Menus: Simplify redundant conditions in
Simplifies redundant conditional logic:
1. In `wp_update_nav_menu_object()`: The preceding `if ( ! $_menu || is_wp_error( $_menu ) )` block handles non-existing menu creation and returns, so $_menu is guaranteed truthy. Dropped the redundant `! $_menu` check before `isset( $_menu->term_id )`.
2. In `wp_update_nav_menu_item()`: In the `elseif ( 0 === (int) $args['menu-item-position'] )` block, `$menu_id` is guaranteed non-zero because the preceding `if ( 0 === $menu_id )` block already handled `$menu_id === 0`. Removed the redundant `if ( 0 !== $menu_id )` check.
3. In `wp_map_nav_menu_locations()`: $slug is an alphanumeric theme location key string; comparing non-string types with $slug is strictly always true. Simplified `is_numeric(...) && ... !== $slug` to `! is_string(...)`.
This resolves all `notIdentical.alwaysTrue` and `booleanNot.alwaysFalse` occurrences in `wp-includes/nav-menu.php`.
Developed in WordPress#14931.
Props huzaifaalmesbah.
See #65817.
git-svn-id: https://develop.svn.wordpress.org/trunk@65159 602fd350-edb4-49c9-b593-d223f7449a82wp-includes/nav-menu.php
1 parent 392df19 commit 15e95f3
4 files changed
Lines changed: 4 additions & 44 deletions
File tree
- src/wp-includes
- tests/phpstan/baselines
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
377 | | - | |
| 377 | + | |
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
| |||
458 | 458 | | |
459 | 459 | | |
460 | 460 | | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
| 461 | + | |
466 | 462 | | |
467 | 463 | | |
468 | 464 | | |
| |||
1281 | 1277 | | |
1282 | 1278 | | |
1283 | 1279 | | |
1284 | | - | |
| 1280 | + | |
1285 | 1281 | | |
1286 | 1282 | | |
1287 | 1283 | | |
| |||
1294 | 1290 | | |
1295 | 1291 | | |
1296 | 1292 | | |
1297 | | - | |
| 1293 | + | |
1298 | 1294 | | |
1299 | 1295 | | |
1300 | 1296 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | 26 | | |
37 | 27 | | |
38 | 28 | | |
| |||
0 commit comments