Skip to content

Commit

Permalink
Coding Standards: Use strict comparison for return type checks in a f…
Browse files Browse the repository at this point in the history
…ew 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@50558 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Mar 21, 2021
1 parent eea4f30 commit 05566e9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/wp-includes/bookmark.php
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/wp-includes/comment.php
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions src/wp-includes/nav-menu.php
Expand Up @@ -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++;
}
Expand Down
12 changes: 6 additions & 6 deletions src/wp-includes/post.php
Expand Up @@ -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 ] ) );
Expand Down Expand Up @@ -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() );
}

Expand Down Expand Up @@ -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 );
}
Expand Down
6 changes: 3 additions & 3 deletions src/wp-includes/revision.php
Expand Up @@ -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;
}
Expand Down

0 comments on commit 05566e9

Please sign in to comment.