Page MenuHomePhabricator

Cleanup use of {} for string character access
Closed, ResolvedPublic

Description

Right now, we use {} in a small handful of places to access particular characters in a string. This was and remains valid in PHP. However, for the time PHP6 was on the table, this syntax was deprecated. Who knows when PHP might decide to deprecated it again.

Our coding style prefers [], and for consistency we should stick with one or the other. Since {} was at one time deprecated and may be again, let's use the former.

Biggest offenders:
json/Services_JSON.php
normal/UtfNormal.php

I think \$[a-z_]+[a-z0-9_]*\{ catches them all with just a few false positives in the language files you can rule out.


Version: 1.18.x
Severity: trivial

Details

Reference
bz28511

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 11:25 PM
bzimport set Reference to bz28511.
bzimport added a subscriber: Unknown Object (MLST).

See also:
http://php.net/manual/en/language.types.string.php#language.types.string.substr

A quick svn-search brought up a few more:

  • ./includes/MacBinary.php : L113, L145, ...
  • ./includes/parser/DateFormatter.php : L330
  • ./includes/filerepo/ForeignAPIFile.php : L197
  • ./includes/specials/SpecialUserrights.php : L320
  • ./includes/normal/UtfNormalUtil.php: L96
  • ./includes/WebRequest.php: L529

(In reply to comment #1)

A quick svn-search brought up a few more:

  • ./includes/MacBinary.php : L113, L145, ...
  • ./includes/parser/DateFormatter.php : L330
  • ./includes/filerepo/ForeignAPIFile.php : L197
  • ./includes/specials/SpecialUserrights.php : L320
  • ./includes/normal/UtfNormalUtil.php: L96
  • ./includes/WebRequest.php: L529

Yeah I noticed those, they just aren't the biggest offenders :)