Commit graph

23 commits

Author SHA1 Message Date
Thiemo Kreuz 504db2c46a Add strict PHP 7 type hints to most code
This patch does two things:
* Add strict PHP 7 type hints to most code.
* Narrow the interface of the checkRefsNoReferences() method to not
  require a ParserOptions object any more.

Change-Id: I91c6a2d9b76915d7677a3f735ee8e054c898fcc5
2019-12-02 08:51:42 +01: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
Adam Wight a40b1b10be Extract footnote body rendering
Change-Id: I9537849cbd700d5dc7ec1a53d852d69b0fe0dc35
2019-11-29 16:22:35 +01:00
Thiemo Kreuz f5b9360467 Add test to cover Cite::listToText()
As far as I can see this must (for now) be an integration test because
it is calling wfMessage().

Change-Id: Ic581c38128364990ccf81539996d1dda53bdcda5
2019-11-27 11:59:53 +01:00
Thiemo Kreuz ab3063fee5 Move all code to PSR-4 compatible namespaces
This patch does intentionally not touch any file name. Some of the
file names are a little weird now, e.g. \Cite\Cite. These can more
easily be renamed in later patches.

I used https://codesearch.wmflabs.org/search/?q=new%20Cite%5C( and it
looks like this code is not used anywhere else.

Change-Id: I5f93a224e9cacf45b7a0d68c216a78723364dd96
2019-11-20 17:00:13 +01:00
jenkins-bot 7018e82352 Merge "Extract all error reporting to a CiteErrorReporter" 2019-11-19 15:53:29 +00:00
Thiemo Kreuz 342e231a22 Extract all error reporting to a CiteErrorReporter
Change-Id: Icf61c9a27fd03266c98caf443bb9f00a421e31f6
2019-11-19 14:53:31 +01:00
Thiemo Kreuz 7157c7f494 Add @license to all files
Note this codebase appears to be dual-licensed. Some files mention MIT,
but extension.json and some other files mention GPL.

Since WMDE typically uses GPL, I will continue to mark the files we
created as such.

Change-Id: I126da10f7fb13a6d4c99e96e72d024b2e5ecee06
2019-11-19 11:31:08 +01:00
jenkins-bot 0782f24d31 Merge "Make most existing Cite tests pure unit tests" 2019-11-12 14:44:24 +00:00
Thiemo Kreuz f94b400474 Make most existing Cite tests pure unit tests
1. Most existing CiteTests can be unit tests. They run so much faster
this way.

2. I modified some test cases to cover all trim() in the code.

3. The strict type hint in CiteHooks is removed because the parameter
is not used. Having a hard type hint for what is effectively dead code
makes the code more brittle for changes done outside of this codebase.

Change-Id: I1bff1d6e02d9ef17d5e6b66aeec3ee42bba99cf4
2019-11-12 14:56:40 +01:00
Thiemo Kreuz d8fbbd0037 Remove dependency on PPFrame from Cite class
This fixes a series of issues:
* There is nothing about a "frame" in the Cite class any more.
* There is no addModules() call in the Cite class any more.

Change-Id: I20c814d46c26825c5c07eab0a5586de3a531eee7
2019-11-12 13:06:39 +01:00
jenkins-bot f36be06996 Merge "Add basic unit tests for all 3 hook classes" 2019-11-12 11:38:13 +00:00
Thiemo Kreuz 042a4ecf7a Add basic unit tests for all 3 hook classes
Change-Id: Ib444717465f8dda96c89afd8b2d60336e8bcdeec
2019-11-12 11:11:45 +00:00
Adam Wight 9d706047f3 Rename refines -> extends
Bug: T171581
Change-Id: I42b2d8859f2958357024cbba089715c10712f370
2019-11-12 10:19:17 +00:00
Thiemo Kreuz 818e869b0b More narrow method signatures involving Parser
Change-Id: I2da717b9a8d104644c59a62b49090605c95323d6
2019-11-12 10:24:58 +01:00
jenkins-bot 15a84769b8 Merge "Test cleanup: drop equalTo" 2019-11-11 12:43:04 +00:00
jenkins-bot 62ca80536e Merge "Block all combinations of refines="…" and follows="…"" 2019-11-11 12:37:34 +00:00
Adam Wight bde9e175a8 Test cleanup: drop equalTo
Can use a shortcut where we pass the expected value directly.  Verified
that we're still asserting equality.

Change-Id: I63512488c50e599df23d5dae2a5064218e311e90
2019-11-11 12:57:09 +01:00
Thiemo Kreuz fe385ecc37 Block all combinations of refines="…" and follows="…"
Note it doesn't make a difference if this is behind the feature flag or
not. It should always be forbidden, and in fact is: Either the follows
attribute is unknown, or the combination is forbidden.

Bug: T236256
Change-Id: Iebbb2d1d5bab183ab0590b8a7a7f6e79d319b72c
2019-11-11 12:56:58 +01:00
Adam Wight b7a7457ffd Add page property when parsing book reference
Any time the book referencing attribute is used in a page,
permanently tag that page with the `ref-extends` property, so
that it can be watched and cleaned up if necessary.

Bug: T237531
Change-Id: Ice5d9d8f7a305702cdc7c2a55d4147c4f79b5881
2019-11-11 11:06:31 +01:00
Adam Wight 5ac57def59 refArg parses and returns the refines attribute
Incremental patch which extracts the refines attribute from the tag.
Doing this now to allow the calling function to have responsibility
for doing something with the attribute value.

Bug: T237531
Change-Id: I59bb409bedd8e6ed06268e705e02e8ffb45b1f0e
2019-11-08 12:30:12 +01:00
Thiemo Kreuz 7965659b82 Add dedicated unit test for Cite::refArg()
Again, this is intentionally testing a private method.

Change-Id: I559b88e38f7a7a4128ba0b16ff3de42f2fab2055
2019-11-07 13:14:05 +01:00
Thiemo Kreuz 64c94662f0 Add the first small PHPUnit test for Cite::normalizeKey()
Note this is intentionally testing a private method. As of now, the
code is so heavily entangled, it's not yet possible to test individual
aspects without calling private methods. The plan is to slowly increase
the overall test coverage, and the start restructuring the code as
necessary.

Change-Id: Ib3b01bddaffd0469fb66979c67c8114a5807df6d
2019-11-07 09:23:13 +00:00