Commit graph

9 commits

Author SHA1 Message Date
Reedy
7c346c1d01 TestFileEditor: Fix string interpolation
Bug: T314096
Change-Id: Id689bf648f64e27585907ecf04a36d23b28b684e
2022-11-04 17:03:38 -06:00
Umherirrender
c7c531778e tests/parser: Add documentation for class properties
Also add missing properties

Change-Id: Ia2443348a40fc46afb9133c997db7120461373f4
2022-06-01 20:57:09 +02:00
Thiemo Kreuz
e2a2a393f9 Move property initialisation out of the constructor
When the value is a constant, the initialization can be done
way up together with the property declaration. I believe
this makes the code easier to read because it's not spread
out so much.

Change-Id: I5af482feccb746c144c0f318e119165cf5a56cbe
2022-01-27 18:50:58 +00:00
Tim Starling
9c3c0b704b Use array_fill_keys() instead of array_flip() if that reflects the developer's intention
array_fill_keys() was introduced in PHP 5.2.0 and works like
array_flip() except that it does only one thing (copying keys) instead
of two things (copying keys and values). That makes it faster and more
obvious.

When array_flip() calls were paired, I left them as is, because that
pattern is too cute. I couldn't kill something so cute.

Sometimes it was hard to figure out whether the values in array_flip()
result were used. That's the point of this change. If you use
array_fill_keys(), the intention is obvious.

Change-Id: If8d340a8bc816a15afec37e64f00106ae45e10ed
2021-06-15 00:11:10 +00:00
C. Scott Ananian
f5bf2f23b7 Parser: remove leftover "transparent hook" code
Followup-To: I8384f47bbcde7604efa41b83db0dbc4f429219a8
Change-Id: I6da8cefad8bc70631277f9b7bd5d1af5474259ab
2020-01-28 20:10:20 -05:00
Thiemo Kreuz
a0770d278b Rewrite confusing loop in TestFileEditor helper class
I had to write a little test to understand what this loop is supposed
to do: All it really does is counting the number of consecutive empty
lines in the $this->lines array, starting at the offset $this->pos.

The only edge-case is when the array does not contain anything but empty
lines. In this case, the last empty line is skipped. This is because
explode( …, "\n\n\n" ) returns 4 elements, but we want to count the
number of newline characters, which is 3.

Change-Id: I74ae1ed6ba0a8d65a92a1dd07f681fd7ae4221b4
2019-11-11 10:29:18 +01:00
Huji Lee
e74bfe13f6 Require indentation of CASE statements in PHP code
Bug: T182546
Change-Id: I91a9555893a08e4ec58da97c6cc4d1e70000ff6b
2017-12-10 22:07:50 -05:00
Kunal Mehta
1deada4f7f parser test editor: Fix emitting of !! hooks
The first newline was missing so a block like:
 !! hooks
 source
 !! endhooks

would turn into:
 !! hookssource
 !! endhooks

Change-Id: I2a4c5e52050d55fb0c9b4f5d0494eb00e34b233c
2017-01-31 03:12:15 +00:00
Tim Starling
d831844364 Parser test file editor
Add editTests.php, which provides an interactive interface to the
parser tests, with semi-automated editing.

Change-Id: I1a20d007ba4627d562a16c03849bbad7aec0e516
2016-10-28 16:15:59 +11:00