Make WordPress Core


Ignore:
Timestamp:
08/03/2019 08:20:42 PM (5 years ago)
Author:
jorbin
Message:

PHP 7.4 compatibility fix / accessing arrays/string using curly brace syntax

PHP used to allow both square brackets and curly braces to be used interchangeably for accessing array elements and string offsets. The curly bracket syntax is only allowed in a limited set of cases and can be confusing for people not used to it.
PHP 7.4 will deprecate the curly brace syntax for accessing array elements and string offsets and it is expected that support will be completely removed in PHP 8.0.
Ref: https://wiki.php.net/rfc/deprecate_curly_braces_array_access

See #47751.
Props jrf.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-ftp.php

    r45424 r45730  
    186186            if ($lcount<8) return '';
    187187            $b = array();
    188             $b['isdir'] = $lucifer[0]{0} === "d";
    189             $b['islink'] = $lucifer[0]{0} === "l";
     188            $b['isdir'] = $lucifer[0][0] === "d";
     189            $b['islink'] = $lucifer[0][0] === "l";
    190190            if ( $b['isdir'] )
    191191                $b['type'] = 'd';
Note: See TracChangeset for help on using the changeset viewer.