Make WordPress Core


Ignore:
Timestamp:
11/22/2024 07:17:35 PM (7 weeks ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Explicitly return null instead of coercing void.

This addresses two instances where a function that is documented as returning {someType}|null doesn't explicitly return null.

Affected functions:

  • array_key_first()
  • WP_REST_Posts_Controller::handle_terms()

Follow-up to [38832], [52038].

Props justlevine.
See #52217.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/compat.php

    r59043 r59453  
    416416     */
    417417    function array_key_first( array $array ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.arrayFound
     418        if ( empty( $array ) ) {
     419            return null;
     420        }
     421
    418422        foreach ( $array as $key => $value ) {
    419423            return $key;
Note: See TracChangeset for help on using the changeset viewer.