Commit graph

120 commits

Author SHA1 Message Date
Adam Wight f24f77d4c4 Fix comments
Change-Id: Ie99f172bf555af4e2c51928152043d12ea735d76
2019-11-29 23:01:07 +01:00
Adam Wight ffedf86a19 Clean up text and name conditionals
The "no key" error should have been unreachable, but I'm afraid that
null `$text` and empty string `$text` were reporting slightly different errors.

Unfortunately, we still have to care about `$text = '0'` because PHP, so
the expressions don't reduce to `if ( !$text ...`

Change-Id: Id1028611ec3bc462dca413f31f7f59637bd7cc7b
2019-11-29 19:26:12 +00:00
Thiemo Kreuz 22627f074d Make the normalizeKey() method private
There was a call in the API that was *not* using normalizeKey(). Now
that the API is gone, we can inline this.

This patch also contains a bunch of cleanups that might already been
resolved in the previous patches.

Change-Id: Id3767b5830268c8cfe9c10efabfa4a31e9dafeb8
2019-11-29 19:02:48 +01:00
jenkins-bot 50ccd05def Merge "Render nested references" 2019-11-29 15:19:50 +00:00
Thiemo Kreuz f8affe8eee Remove redundant variable names from @var docs
Change-Id: I5ba2f1041d3d6770c58f496482d2799bb24786be
2019-11-29 14:37:58 +01:00
Thiemo Kreuz 13598ba11e Render nested references
Forked from Icd933fc983.

Bugs and unimplemented features are documented as TODOs in the parser test
fixtures.

Bug: T237241
Change-Id: I9427e025ea0bcf2fa24fd539a775429cc64767cc
2019-11-29 13:40:34 +01:00
Adam Wight 44cbc60d40 Count extends refs
Has no effect, this is a "safe" split from I9427e025ea0.

Change-Id: I842673cd1226ec5c9248d8f069766a00a7c27f35
2019-11-28 02:10:28 +01:00
Adam Wight ab78df8d5c Wire extends into ReferenceStack
Takes no action, just shuttle the value between functions.

(Split from I9427e025ea0)

Change-Id: I271043e9161835f3278098787bf58b50ed93c892
2019-11-28 02:10:11 +01:00
Adam Wight 249982e353 Rewrite loop in ReferenceStack
Change-Id: I3bdf26fd14573abdcad989c7ebfea48e49ef42aa
2019-11-27 17:13:44 +00:00
Thiemo Kreuz f00b21943b Minor fixups to the ReferenceStack class
Change-Id: Ie7d72b13f987443c0e118fb9ac0f0af016f00392
2019-11-27 18:13:22 +01:00
Adam Wight b30340ba2b Clean up pushRef
This is motivated by I9427e025e, which demonstrates that the existing
logic was hard to integrate into.  There's a lot of redundant expressions
which make the function difficult to read, and code paths which have
less effect than they appear to.

Change-Id: Ida9612d1457f2593647b8fc02930d2e9ae824814
2019-11-27 16:40:51 +01:00
Thiemo Kreuz 0013943a4a Rewrite argument parsing and use for both <ref> & <references>
We realized the trim() are not needed. This does not leave much behind
in the existing refArg() method, except that it checks for unknown keys.

I tried a few strategies and ended using the pretty new possibility to
have keys in list(), as well as use [] instead of list(). Both is
supported since PHP 7.1.

Change-Id: I569bfa14e68b64402519bd39022c197553881dde
2019-11-27 14:01:52 +01:00
Thiemo Kreuz 04f784bc02 Remove non-existing property from ReferenceStack
Change-Id: Id789897dd92c7692e36f54b828c097820ab46b43
2019-11-27 12:57:55 +01:00
Thiemo Kreuz a6a16f0703 Update and increase ReferenceStack test coverage
Functional changes:
* hasGroup() will return false when a group exists, but is empty. This
  is in line with what other methods like getGroups() already do.
  Shouldn't have any effect on the existing code, but feels more clean
  and consistent.
* getGroupRefs() won't fail any more when asked for an unknown group.

Tests:
* Add missing @covers for the constructor.
* Simplify test setup by always returning a spy. All tests need it
  anyway.
* Cover 3 more methods.

Change-Id: Ie93e9af6258b757d842b30b0b059344733aad434
2019-11-27 11:08:00 +01:00
Adam Wight 97746db93c More specific function signature
Change-Id: Id1d21b9abdb11bbf441650ea0a1cccc8b258d598
2019-11-26 18:27:16 +01:00
Adam Wight ec091fe906 Reorder keys
This doesn't make any functional difference, but helps minimize later
patch Ida9612d14

Change-Id: Ice89bad02e077437d0df6fa9f51f90b4cab4837c
2019-11-26 17:06:01 +01:00
Adam Wight 38d7c09495 Tweak comment
This makes it show up nicely in my IDE.

Change-Id: Ic203a9dcb83c96c3324996e183b4dfc239f65eca
2019-11-26 17:03:40 +01:00
Adam Wight 55099a7b0c Remove impossible condition
Numeric `$name` is caught during validation.

Change-Id: Id1c3e6717af38b0b1393c135732e084d261b53f6
2019-11-26 16:43:21 +01:00
Adam Wight d1e0e6309b Add some comments
Change-Id: I012ad6cc52dc65f1b329febdc8e6441ac03c6463
2019-11-26 11:07:48 +01:00
Adam Wight 8453e3ecd7 Extract stack and state to a new class
Most of this state is used to manage interactions with other state,
and encapsulation allows us to hide data structures and access behind
self-explanatory function names.

The interface is still much wider than I'd like, but it can be improved in
future work.

There is one small behavior change in here: in the `follows` edge case
demonstrated by I3bdf26fd14, we prepend if the splice point cannot be
used because it has a non-numeric key.  I believe this was the original
intention of the logic, and is how the numeric case behaves.  I've verified
that when array_splice throws a warning about non-numeric key, it fails to
add anything to the original array, so the broken follows ref disappeared.

Bug: T237241
Change-Id: I091a0b71ee9aa78e841c2e328018e886a7217715
2019-11-25 14:06:32 +01:00