Refactor MagicWordArray::getBaseRegex() to allow code sharing
between Parsoid and core by parameterizing the delimiter and
the presence/absence of capture groups.
Mark a number of methods @internal because they are purely internal
helpers; no one outside core is using:
::getRegex()
::getBaseRegex()
::getVariableRegex()
::getVariableStartToEndRegex()
::getRegexStart()
Code search:
https://codesearch.wmcloud.org/search/?q=-%3E(get(Base%7CVariable%7CVariableStartToEnd%7C)Regex%5C(%7CgetRegexStart%5C()&i=nope&files=&repos=
Moved the regexp 'i' option inside the regexp to allow better code
sharing between the case-sensitive and case-insensitive regexps.
(Foiled to a minor degree by a performance optimization which only
applies the "unicode" flag to the case-insensitive regexp.)
Both regexps are always defined and valid, which saves some additional
tests at use sites.
Change-Id: I17f1b7207db8d2203c904508f3ab8a64b68736a8
It's deprecated in PHP 7.2, may as well replace it now.
I note that, contrary to claims at
https://wiki.php.net/rfc/deprecations_php_7_2#each, none of our uses
were trivially replaceable with foreach.
* wfArrayDiff2_cmp() is processing two arrays by value in parallel.
* MagicWordArray::parseMatch() is doing something funky with the data
structure returned by preg_match().
* HashRing was using it like "nextKey()", replaced with calls to key()
and next().
* FormatMetadata and IndexPager were both using it as a shorter way to
get both key() and current() for the first element in the array. I
suppose a foreach(){ break; } would do the same, but that's confusing.
Bug: T174354
Change-Id: I36169a04c764fdf1bfd6603395111c6fe0aae5eb
Actually php says:
Warning: Compilation failed: two named subpatterns have the same name at
offset 679
The message is not helpful to find the duplicate name inside the
MagicWordArray, because the generated regex is unknown to count the
correct offset.
Try to detect such duplicates and throw an exception with more
information and a stacktrace.
Change-Id: I95dea67da06aa4000d52ac3338c3b865450b3e23