Commit graph

6 commits

Author SHA1 Message Date
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