Make WordPress Core


Ignore:
Timestamp:
07/15/2019 06:24:08 AM (6 years ago)
Author:
pento
Message:

Code Modernisation: Fix known instances of array access on data types that can't be accessed as arrays.

PHP 7.4 addes a warning when trying access a null/bool/int/float/resource (everything but array, string and object) as if it were an array.

This change fixes all of these warnings visible in unit tests.

Props jrf.
See #47704.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/class-wp-rest-request.php

    r45304 r45639  
    295295     * @since 4.4.0
    296296     *
    297      * @return array Map containing 'value' and 'parameters' keys.
     297     * @return array|null Map containing 'value' and 'parameters' keys
     298     *                    or null when no valid content-type header was
     299     *                    available.
    298300     */
    299301    public function get_content_type() {
     
    335337
    336338        $content_type = $this->get_content_type();
    337         if ( $content_type['value'] === 'application/json' ) {
     339        if ( isset( $content_type['value'] ) && 'application/json' === $content_type['value'] ) {
    338340            $order[] = 'JSON';
    339341        }
Note: See TracChangeset for help on using the changeset viewer.