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
And auto-fix all errors.
The `<exclude-pattern>` stanzas are now included in the default ruleset
and don't need to be repeated.
Change-Id: I928af549dc88ac2c6cb82058f64c7c7f3111598a
Undeclared variables are a very common error type that we want to catch
as often as possible. To avoid needing to refactor a variety of global
level code (mostly in old-style maintenance scripts) this ignores
undeclared variables in global scope. This is still a good improvement
over what was happening previously.
Change-Id: I50b41d571724244552074b9408abbdf6160aca59
A protected version of explode is factored out as
`StringUtils::delimiterExplode`, since it will be used in follow-up
patches in this series. The `delimiterExplode` implementation creates
an intermediate array of the exploded results, which is reasonable as
the number of image options is small; but since an Iterator is
returned the implementation can be upgraded in the future (at the cost
of additional complexity) to avoid this. The additional code in that
case would be similar to ExplodeIterator.
Bug: T146305
Change-Id: I1327685e9e8c07ef476dceaa6f6dae4ba40989ef
* Removed fallback code from Language, the associated data file
(Utf8Case.ser), and the code to generate that data file.
* Removed comment in LanguageFi that "mb_substr has a compatibility
function in GlobalFunctions.php".
* Removed check for mbstring in bench_utf8_title_check.php.
* In the tests for StringUtils::isUtf8():
* Removed separate test for the non-mbstring code path.
* Removed mentions of mbstring from function names and assertion
messages, since mb_check_encoding() is now always used.
* Also updated the comment in StringUtils::isUtf8() referring to
PHP 5.3, which is no longer supported in MediaWiki, to indicate
that the same issue also exists in old versions of HHVM. (If
we don't have to support 3.4 or older, then the function could
be deprecated and removed if desired.)
Follows-up 943563062f.
Change-Id: I55e5cd534b849c6ea06a7fadacbbf34a12d87ebe
In the age when we require PHP 5.5, pretending that mbstring emulation
is not slow and silly is silly.
Bug: T129435
Change-Id: Ic8235c9da9a926df63ec7388900c44eab454eebe
* 55313f4e almost got it right, but missed the str_replacing table
headings.
* Thankfully, this was doubly broken before that patch since the
StringUtils::explodeMarkup would have skipped the || which would
go on to be explode by table cell attribute parsing. The test case
provided would look like,
<table>
<tr>
<th class="">|">ha</div> ho
</th></tr></table>
Suffice it to say, noone is using this in production.
* Note that we can't just entity encode the ! since that would break
style attributes with !important.
* Also note, Parsoid already gets this right.
* Adds a StringUtils::replaceMarkup
Change-Id: Iab3ae4518fcb307b795d57eece420ba48af0a3bf
* Code blocks must be indented by 4 spaces (so 5 in total from the star).
* Code blocks are only supported in descriptions, and for some reason the first
line is separate from the description, so there must be an additional line of
text between the summary and the code block since it can't be the first thing
in a description.
* Fix regex confusion with comment syntax due to "/*\/".
To verify these findings, use:
$ php maintenance/mwdocgen.php --file includes/libs/StringUtils.php
And check the output warnings and generated html pages.
Change-Id: I259b87c0bf3b48a95df0108eb6ee799c25b2853f