Make WordPress Core


Ignore:
Timestamp:
12/22/2025 11:12:59 PM (5 months ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Replace some isset() ternary checks with null coalescing.

Since PHP 7.0 introduced the null coalescing operator, and WordPress now requires at least PHP 7.2.24, isset( $var ) ? $var : null ternary checks can be safely replaced with the more concise $var ?? null syntax.

As some new code using the null coalescing operator has already been introduced into core in recent releases, this commit continues with the code modernization by implementing incremental changes for easier review.

Props seanwei, getsyash, krupalpanchal, wildworks, jorbin, SergeyBiryukov.
Fixes #63430. See #58874.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-comment-query.php

    r61105 r61403  
    950950        $clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $pieces ), &$this ) );
    951951
    952         $fields  = isset( $clauses['fields'] ) ? $clauses['fields'] : '';
    953         $join    = isset( $clauses['join'] ) ? $clauses['join'] : '';
    954         $where   = isset( $clauses['where'] ) ? $clauses['where'] : '';
    955         $orderby = isset( $clauses['orderby'] ) ? $clauses['orderby'] : '';
    956         $limits  = isset( $clauses['limits'] ) ? $clauses['limits'] : '';
    957         $groupby = isset( $clauses['groupby'] ) ? $clauses['groupby'] : '';
     952        $fields  = $clauses['fields'] ?? '';
     953        $join    = $clauses['join'] ?? '';
     954        $where   = $clauses['where'] ?? '';
     955        $orderby = $clauses['orderby'] ?? '';
     956        $limits  = $clauses['limits'] ?? '';
     957        $groupby = $clauses['groupby'] ?? '';
    958958
    959959        $this->filtered_where_clause = $where;
Note: See TracChangeset for help on using the changeset viewer.