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. Built from https://develop.svn.wordpress.org/trunk@45639 git-svn-id: http://core.svn.wordpress.org/trunk@45450 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -294,7 +294,9 @@ class WP_REST_Request implements ArrayAccess {
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @return array Map containing 'value' and 'parameters' keys.
|
||||
* @return array|null Map containing 'value' and 'parameters' keys
|
||||
* or null when no valid content-type header was
|
||||
* available.
|
||||
*/
|
||||
public function get_content_type() {
|
||||
$value = $this->get_header( 'content-type' );
|
||||
@@ -334,7 +336,7 @@ class WP_REST_Request implements ArrayAccess {
|
||||
$order = array();
|
||||
|
||||
$content_type = $this->get_content_type();
|
||||
if ( $content_type['value'] === 'application/json' ) {
|
||||
if ( isset( $content_type['value'] ) && 'application/json' === $content_type['value'] ) {
|
||||
$order[] = 'JSON';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user