Commit graph

7 commits

Author SHA1 Message Date
Kevin Israel
93fc424fc1 StringUtils: Deprecate Replacer classes
The Replacer classes were added in 1.9, when MediaWiki supported PHP 5.0
and 5.1. They were designed to be used with preg_replace_callback() and
StringUtils::delimiterReplaceCallback(). Now that Closures exist in PHP
5.3 and newer, there is no need to define a class for this purpose.

All existing Replacer subclasses are simple enough that their few uses
can easily be replaced with Closures, without making the code harder to
understand. In fact, the code probably becomes easier to understand, as
what each match is replaced with becomes more obvious -- no need to
refer to a separate class.

MediaWiki code search finds no uses in extensions. Thus, these classes
are hard deprecated immediately.

Change-Id: I441c21689909fb06a1ea07a305259eeb82cb2345
2018-07-12 10:25:59 -07:00
Brad Jorsch
fb3ae6fbe3 Replace use of &$this
Use of &$this doesn't work in PHP 7.1. For callbacks to methods like
array_map() it's completely unnecessary, while for hooks we still need
to pass a reference and so we need to copy $this into a local variable.

Bug: T153505
Change-Id: I8bbb26e248cd6f213fd0e7460d6d6935a3f9e468
2017-01-31 23:01:54 -05:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Ricordisamoa
4f72efe8d8 Remove excess newlines at the end of files
Many of them added with commit 776c865077

Change-Id: I481b15c45ead1f5f482e120cb40ea8f3297543cf
2015-09-27 00:02:05 +02:00
Kunal Mehta
60a92d256a replacers: Make Replacer abstract, and add abstract Replacer::replace()
Change-Id: Ib00dc8585e8ba599491e51e0b99a8667c3b4cd63
2015-01-28 20:49:57 -08:00
Kunal Mehta
1b05ff21bc replacers: Set explicit visiblity on functions
Change-Id: I4f35ea9b4bd2503bc612dc25dc8d34fc5ca040a0
2015-01-28 20:46:13 -08:00
Kunal Mehta
2659a67054 Move "Replacers" into includes/libs/replacers/
Split into separate files while we're at it

Change-Id: I0bba4dcea686de088bd96964833fe6fb649a41e9
2015-01-28 20:42:25 -08:00