From 5e10227d766e92c8cbbe9d35e16b80c1ba4348cd Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 21 Mar 2021 12:41:04 +0000 Subject: [PATCH] Coding Standards: Use strict comparison for return type checks in a few functions: * `get_bookmark()` * `get_comment()` * `get_post()` * `get_children()` * `wp_get_recent_posts()` * `wp_get_post_revision()` * `wp_get_nav_menu_items()` Follow-up to [45710] for `get_term()`, [48507] for `wpdb::get_row()` and `wpdb::get_results()`. See #52627. Built from https://develop.svn.wordpress.org/trunk@50558 git-svn-id: http://core.svn.wordpress.org/trunk@50171 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/bookmark.php | 6 +++--- wp-includes/comment.php | 6 +++--- wp-includes/nav-menu.php | 6 ++++-- wp-includes/post.php | 12 ++++++------ wp-includes/revision.php | 6 +++--- wp-includes/version.php | 2 +- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/wp-includes/bookmark.php b/wp-includes/bookmark.php index b9cfc63765..674269e23b 100644 --- a/wp-includes/bookmark.php +++ b/wp-includes/bookmark.php @@ -53,11 +53,11 @@ function get_bookmark( $bookmark, $output = OBJECT, $filter = 'raw' ) { $_bookmark = sanitize_bookmark( $_bookmark, $filter ); - if ( OBJECT == $output ) { + if ( OBJECT === $output ) { return $_bookmark; - } elseif ( ARRAY_A == $output ) { + } elseif ( ARRAY_A === $output ) { return get_object_vars( $_bookmark ); - } elseif ( ARRAY_N == $output ) { + } elseif ( ARRAY_N === $output ) { return array_values( get_object_vars( $_bookmark ) ); } else { return $_bookmark; diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 94f60dfaef..91672c1a13 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -218,11 +218,11 @@ function get_comment( $comment = null, $output = OBJECT ) { */ $_comment = apply_filters( 'get_comment', $_comment ); - if ( OBJECT == $output ) { + if ( OBJECT === $output ) { return $_comment; - } elseif ( ARRAY_A == $output ) { + } elseif ( ARRAY_A === $output ) { return $_comment->to_array(); - } elseif ( ARRAY_N == $output ) { + } elseif ( ARRAY_N === $output ) { return array_values( $_comment->to_array() ); } return $_comment; diff --git a/wp-includes/nav-menu.php b/wp-includes/nav-menu.php index 547ca7f709..50f43f955d 100644 --- a/wp-includes/nav-menu.php +++ b/wp-includes/nav-menu.php @@ -758,14 +758,16 @@ function wp_get_nav_menu_items( $menu, $args = array() ) { $items = array_filter( $items, '_is_valid_nav_menu_item' ); } - if ( ARRAY_A == $args['output'] ) { + if ( ARRAY_A === $args['output'] ) { $items = wp_list_sort( $items, array( $args['output_key'] => 'ASC', ) ); - $i = 1; + + $i = 1; + foreach ( $items as $k => $item ) { $items[ $k ]->{$args['output_key']} = $i++; } diff --git a/wp-includes/post.php b/wp-includes/post.php index d543c4176e..b17f254653 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -677,15 +677,15 @@ function get_children( $args = '', $output = OBJECT ) { $kids[ $child->ID ] = $children[ $key ]; } - if ( OBJECT == $output ) { + if ( OBJECT === $output ) { return $kids; - } elseif ( ARRAY_A == $output ) { + } elseif ( ARRAY_A === $output ) { $weeuns = array(); foreach ( (array) $kids as $kid ) { $weeuns[ $kid->ID ] = get_object_vars( $kids[ $kid->ID ] ); } return $weeuns; - } elseif ( ARRAY_N == $output ) { + } elseif ( ARRAY_N === $output ) { $babes = array(); foreach ( (array) $kids as $kid ) { $babes[ $kid->ID ] = array_values( get_object_vars( $kids[ $kid->ID ] ) ); @@ -788,9 +788,9 @@ function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) { $_post = $_post->filter( $filter ); - if ( ARRAY_A == $output ) { + if ( ARRAY_A === $output ) { return $_post->to_array(); - } elseif ( ARRAY_N == $output ) { + } elseif ( ARRAY_N === $output ) { return array_values( $_post->to_array() ); } @@ -3692,7 +3692,7 @@ function wp_get_recent_posts( $args = array(), $output = ARRAY_A ) { $results = get_posts( $parsed_args ); // Backward compatibility. Prior to 3.1 expected posts to be returned in array. - if ( ARRAY_A == $output ) { + if ( ARRAY_A === $output ) { foreach ( $results as $key => $result ) { $results[ $key ] = get_object_vars( $result ); } diff --git a/wp-includes/revision.php b/wp-includes/revision.php index 6fc288888d..a1aad16812 100644 --- a/wp-includes/revision.php +++ b/wp-includes/revision.php @@ -371,12 +371,12 @@ function wp_get_post_revision( &$post, $output = OBJECT, $filter = 'raw' ) { return null; } - if ( OBJECT == $output ) { + if ( OBJECT === $output ) { return $revision; - } elseif ( ARRAY_A == $output ) { + } elseif ( ARRAY_A === $output ) { $_revision = get_object_vars( $revision ); return $_revision; - } elseif ( ARRAY_N == $output ) { + } elseif ( ARRAY_N === $output ) { $_revision = array_values( get_object_vars( $revision ) ); return $_revision; } diff --git a/wp-includes/version.php b/wp-includes/version.php index a64327b032..491d14a249 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.8-alpha-50557'; +$wp_version = '5.8-alpha-50558'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.