Last modified: 2011-04-17 08:00:38 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T30511, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 28511 - Cleanup use of {} for string character access
Cleanup use of {} for string character access
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
1.18.x
All All
: Low trivial (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-04-12 13:00 UTC by Chad H.
Modified: 2011-04-17 08:00 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Chad H. 2011-04-12 13:00:32 UTC
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.
Comment 1 Krinkle 2011-04-12 20:46:47 UTC
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
Comment 2 Chad H. 2011-04-12 21:18:08 UTC
(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 :)
Comment 3 Alexandre Emsenhuber [IAlex] 2011-04-17 08:00:38 UTC
Done in r86251.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links