[wp-trac] [WordPress Trac] #53540: Use $image[0] instead of $image['0'] in media file

WordPress Trac noreply at wordpress.org
Wed Nov 17 16:40:29 UTC 2021


#53540: Use $image[0] instead of $image['0'] in media file
--------------------------------------+-----------------------
 Reporter:  chintan1896               |       Owner:  antpb
     Type:  defect (bug)              |      Status:  assigned
 Priority:  normal                    |   Milestone:  5.9
Component:  Media                     |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch good-first-bug  |     Focuses:
--------------------------------------+-----------------------

Comment (by costdev):

 Here's a link to confirm that this change will still work:
 https://3v4l.org/L7aNL

 This change is worth making for the following reasons:
 - **Readability** - When scanning code, single- or double-quoted array
 keys will read as associative arrays at first glance. This change makes it
 immediately clear that this is a numeric array.

 - **Performance** - See the "Time with string|int" results in the output
 of the link above.

 - **Consistency** - Numeric keys should be written as integers.

 - **Cross-version PHP support** - As shown in the link above, this change
 will work across PHP versions.

 IMO, this patch is ready for `commit` in time for Beta 1 today.

 Any other occurrences of numeric `string` keys in core should be removed
 in a follow-up ticket.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53540#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list