Commit graph

16 commits

Author SHA1 Message Date
C. Scott Ananian
5fbfda654a MagicWordArray: mark ::get*Regex*() as @internal, add some options
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
2020-11-25 12:46:47 -05:00
DannyS712
2e3bdb3498 Miscellaneous documentation updates
Update references from .txt to .md when files have moved, a few other
tweaks, no changes to code.

Change-Id: I0bfd38c47b9fb0fc11ae98a0a674af66fb4c5a84
2020-02-16 04:38:38 +00:00
James D. Forrester
0958a0bce4 Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNull
Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
2020-01-10 14:17:13 -08:00
Daimona Eaytoy
b5f0d61ee4 Fix new phan errors, part 8
Bug: T231636
Change-Id: I61852ba55362ab9ae8cc8c1ab6b27565ce1d08e7
2019-10-22 10:09:13 +02:00
Daimona Eaytoy
cae0110e5a Fix new phan errors, part 1
First part, mostly doc-only.

Bug: T231636
Change-Id: Id59f585740fa5bfb53c257287121f51a30de38fe
2019-10-11 15:04:04 +00:00
Umherirrender
e3c1f72bc9 Improve return types in class MagicWordArray
Change-Id: I63ff4f52d8459ab19dd774ef1dee8435f1eb5cae
2019-06-03 17:52:47 +02:00
Fomafix
8a314d9b43 Simplify by using ?: operator
Change-Id: I2851cc51c9e05dd0599733be5af39e19f12b52e2
2019-04-15 15:05:00 +02:00
Thiemo Kreuz
2540c29b20 Use the ?? feature instead of isset() where it makes sense
Change-Id: I3a54f36b33d99ef3ff4c63e32e7dfcbcfc296135
2019-03-24 22:40:49 +01:00
Aryeh Gregor
6142859029 Update MagicWord to use ContentLanguage
Bug: T200246
Change-Id: I9f17142d25bc851c973bebe27e6cbc5be8b70729
2018-08-01 10:39:33 +00:00
Aryeh Gregor
5a16d92e04 Update MagicWordArray to use MagicWordFactory
Bug: T200247
Change-Id: Ie5a60b81382d7299beadc691fe4d27e931ebe0ed
2018-07-31 21:40:21 +03:00
Brad Jorsch
2c34fd6e0e Replace uses of each()
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
2017-09-20 09:51:28 -04:00
jenkins-bot
3e88f9fa2a Merge "Get better error message for duplicate names in MagicWordArray" 2017-08-29 18:50:11 +00:00
Umherirrender
a9007e8baf Add missing & to @param documentation to match functon call
Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
2017-08-11 18:47:46 +02:00
Umherirrender
a6f4ec848e Get better error message for duplicate names in MagicWordArray
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
2017-08-11 14:26:20 +00:00
addshore
2ff9e66986 Add access modifiers to MagicWordArray.php
Change-Id: Ib5fe0fd22a6f24142f1e87338298c1bdef45cc4a
2016-03-01 10:56:55 +00:00
addshore
26cd337c2e Move MagicWordArray class to own file
Change-Id: I9ba602da77f1c8d4270d8ae10d03e82a3197e5b1
2016-03-01 10:49:29 +00:00