Commit graph

56 commits

Author SHA1 Message Date
Reedy
ae031e237e Remove HWLDFWordAccumulator, deprecated in 1.28
Change-Id: I1eb6ba3c4b8b4cbabf26033a27728e42ebcddb23
2019-04-14 14:52:41 +01:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Thiemo Mättig
d14faa6bed Remove auto-generated "Constructor" documentation on constructors
Having such comments is worse than not having them. They add zero
information. But you must read the text to understand there is
nothing you don't already know from the class and the method name.

Change-Id: I994d11e05f202b880390723e148d79c72cca29f0
2017-07-10 10:15:51 +00:00
Erik Bernhardson
d67197fa11 Cleanup some incorrect return annotations
Most of these are simply changing annotations to reflect
reality. If a function can return false to indicate failure
the @return should indicate it.

Some are fixing preg_match calls, preg match returns 1, 0 or false,
but the functions all claim to return booleans.

This is far from all the incorrect return types in mediawiki, there
are around 250 detected by phan, but have to start somewhere.

Change-Id: I1bbdfee6190747bde460f8a7084212ccafe169ef
2016-12-12 10:15:05 -08:00
Max Semenik
dd57ff3cce Rethink diff limits
Now, instead of "if your changed paragraphs are larger than 10Kb, you're
screwed":
* Instead of relying on overall length, estimate complexity after splitting to words
  and taking any equal head and tail out of equation.
* Estimate based on words changed, which better reflects the actual complexity
  of generating a diff.
* New limit is determined scientifically, i.e. "above that number XDebug starts
  complaining about recursion limits reached in Vagrant".

Caveat: if new limits are hit, the consequences are more widespread as all adjacent
changed paragraphs are displayed without word level diffs, as opposed to only the
paragraph that's too long being affected. However, the new limit is much higher and
in wikitext you're supposed to put empty lines between paragraphs anyway, negating
this problem.

Bug: T128697
Change-Id: I4e91c7c40f5afdd116b847a859b8517522302489
2016-06-01 16:30:58 -07:00
Max Semenik
20f066e971 Merge Wikidiff3 into DiffEngine
Change-Id: Ib4d083a5200824e4d032de6921c375e455e77fb2
2016-05-18 01:50:19 +00:00
Max Semenik
7e60f670bf Remove unused stuff from diffs
Change-Id: Ie7d46b9ed290912039c88bbf4548d4c3d97153c9
2016-05-18 01:39:31 +00:00
Max Semenik
1cac442f1f Refactor diffs
* Merge MappedDiff into WordLevelDiff
* Rename <something insane>WordAccumulator into WordAccumulator and namespace
* Better variable names

Change-Id: I5847f2bb89402d0537b9e99cccd24c547ce4e4e2
2016-05-17 18:17:05 -07:00
Max Semenik
e08cd0de84 Make wikidiff3 the only diff engine
In addition to much improved worst-case performance, it also has better
relevance.

Bug: T128896
Change-Id: I3b52c502d7cd5923c5a02942afbe75aba9016148
2016-04-26 13:09:44 -07:00
Ori Livneh
9e867b07b8 Don't quote assert expressions in DairikiDiff
Per HHVM issue 5128, it is not possible to use '$this' in string-literal
assert() expressions. We can either wait for this to be fixed (unlikely to
happen soon, since it involves deep interpreter internals), comment out or
remove the asserts, or simply unquote them, so that they are actual expressions
rather than strings. The downside to this is that assertions will always be
evaluated (but so what, they are extremely cheap), and that when an assertion
fail the error message will simply read 'assert(): Assertion failed in
/path/to/file on line XXX' as opposed to including the expression in the
output. Fair trade, IMO.

See: https://github.com/facebook/hhvm/issues/5128

Bug: T124163
Change-Id: Ib458b1b0c28f8d38e9df427196ae79814f6dc0c2
2016-03-08 18:10:52 -08:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Andrew Harris
0dc4dfca97 Change multiple documentations in DairkiDiff
Currently, multiple TODO tags are over different functions and
classes in DairkiDiff.

Add documentation to five classes and functions in DairkiDiff.

Change-Id: I000b615e929736a71aaa4633a291aab94428117f
2015-12-19 12:32:37 -03:30
Edward Chernenko
bd43acbca6 Fix "Undefined property: DiffEngine::$seq" under HHVM in DairikiDiff.php
Bug: T116266
Change-Id: I94ed1ce946b4c3e757405167d6c4530a5863a220
2015-11-30 17:55:06 +00:00
umherirrender
493f4222cb phpcs: Assignment expression not allowed
Fix some "Assignment expression not allowed"

Found by tests:
https://integration.wikimedia.org/ci/job/mediawiki-core-phpcs/2736/consoleFull

Change-Id: I9bc2eff20a317a74671acd49749bb336a0fd9f67
2015-11-16 20:56:32 +00:00
umherirrender
34659b0b42 Use correct @codingStandardsIgnore in DairikiDiff.php
@codingStandardsIgnoreFile is for whole files, use
@codingStandardsIgnoreStart instead

Also correct a MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.
SingleSpaceBeforeSingleLineComment sniff in the same file

Follows I06cdab4616b5bff47c85152df28f18c861730a23

Change-Id: I75e6e936e2fb4453bd56848ff39cabd92ae171fc
2015-10-14 10:32:17 +00:00
Chad Horohoe
aa21e125a3 Remove obvious function-level profiling
Xhprof generates this data now. Custom profiling of various
sub-function units are kept.

Calls to profiler represented about 3% of page execution
time on Special:BlankPage (1.5% in/out); after this change
it's down to about 0.98% of page execution time.

Change-Id: Id9a1dc9d8f80bbd52e42226b724a1e1213d07af7
2015-01-07 11:14:24 -08:00
Ricordisamoa
12dec5d85d Fix some stuttering in comments and documentation
Change-Id: I9c0088b9aab37335203cad45a1d6fa8ac3f43321
2014-12-17 19:44:10 +00:00
Siebrand Mazeland
f994817f6b Pass phpcs-strict on various files in includes/
These files have all had treatment before, and these occurrences have either
been missed or have been introduced after.

Change-Id: I06cdab4616b5bff47c85152df28f18c861730a23
2014-04-24 21:50:01 +02:00
umherirrender
2000672ac3 Fixed spacing
- Added spaces after if/foreach/catch
- Added new line before end of file
- Added or removed spaces before/after parenthesis, comma
- Added spaces around string concat

Change-Id: I0590070f1b3542108e242730e8d9a3ba9831e94f
2014-03-20 20:37:30 +00:00
Thiemo Mättig
6806400129 Added and updated Doxygen comments in content handler and diff namespaces
Reasons for touching this are:
* "@param type $var" were mixed in a lot of places. Both works but the
  MediaWiki coding conventions suggest that specific order.
* Things like String and Bool aren't objects and shouldn't be uppercase.
* Tried to fill missing types in "@param $var".
* Tried to fill missing descriptions in "@return type" when I could.
* Removed duplicate descriptions if a @see is sufficend.
* Removed useless descriptions ("isUsefull returns true if usefull").
* Removed useless @return void.
* Replaces mixed[] with array (does have the exact same meaning).
* Tried to find better replacements for "varargs", phpDocumentor
  suggest $var,...
* Order should be @since, @param, @throws, @return, @see. This is the
  order Doxygen renders this.

There is always more to do but I think this is already much better
than before. Please feel free to put more change sets on top of mine
or request more changes by adding comments.

Change-Id: I05262ce06caabf79f68772302524ac91bbead1c6
2014-03-06 11:17:41 +01:00
addshore
3d1fba6e72 Add tests for ArrayDiffFormatter and DiffOp
This change also adds some tested getters to
the DiffOp class to improve testability of the class

Change-Id: I26eafd791b9892f565a18d0502474ef9c24f9a29
2014-02-26 22:53:05 +01:00
Max Semenik
44962de1a5 Allow customizing classes inside of diffs
Not every implementation might want them

Change-Id: Id186b71760d59be7e61458bf1f62965a0f2f826c
2013-12-11 23:07:04 +04:00
jenkins-bot
debe941aa8 Merge "Initialise variables and update documentation" 2013-11-20 21:59:27 +00:00
jenkins-bot
424845ad11 Merge "Remove unused private method check()" 2013-11-20 21:56:57 +00:00
jenkins-bot
3edd3c4055 Merge "Abstract declaration must precede visibility declaration" 2013-11-20 21:52:09 +00:00
Siebrand Mazeland
84552a2dd4 Initialise variables and update documentation
Change-Id: Idb242f65801ee79531c2300cf9fcb5b3929f66ab
2013-11-20 20:57:52 +01:00
Siebrand Mazeland
dcb0471e19 Remove unused private method check()
Change-Id: I29381892be9966b92b99cb3b021cc5a9a4be8a80
2013-11-20 20:41:58 +01:00
Siebrand Mazeland
7b94b51088 Abstract declaration must precede visibility declaration
Change-Id: Ic13646c5a5c5b1f80db58740b207f853c7e25ceb
2013-11-20 20:32:53 +01:00
Siebrand Mazeland
f5003767a0 Rename classes DiffOp_* to DiffOp*
Part of program to remove underscores from class names. Checked core and
600+ extensions for occurrences. All uses are in core in core are updated
in this patch. No uses in extensions.

Change-Id: I86b8c6f8702e661554c7b794df09892db94a84d1
2013-11-20 20:28:14 +01:00
Siebrand Mazeland
4da81608c2 Rename class HWLDF_WordAccumulator to HWLDFWordAccumulator
Part of program to remove underscores from class names. Checked core and
600+ extensions for occurrences. All uses are in core in core are updated
in this patch.

Change-Id: Ib3094249ab192db80f1639c5e543ece84c688b9a
2013-11-20 20:24:48 +01:00
Siebrand Mazeland
27edd5708d Avoid function calls in a for loop test part
Change-Id: Ief0976e3d1cd1da7074b1ed6d427153ccc189f18
2013-11-20 20:22:26 +01:00
Siebrand Mazeland
abefd2c07e Update formatting for includes/diff
Change-Id: Id032a32ca6ebea3daf5313a05602c5e98603d983
2013-11-20 20:11:57 +01:00
Max Semenik
c37b4dc964 Refactor diffs
* Move some classes to separate files to avoid having a monstrous file with a
  dozen classes.
* Remove weird underscores from class names.
* Instead of prefixing members with underscores, specify visibility explicitly.
* Rename c_style -> camelCase per coding conventions.
* Throw exceptions instead of fataling out with trigger_error().
* Remove pointless constant used only once.

Change-Id: Icac23c0f6259c73f5fe07f201b83b9c332ba0469
2013-10-30 21:40:06 +04:00
Tim Starling
d1bc243f65 Remove all instances of the word "iff"
It's elitist mathematical jargon. In all cases dealt with here, it adds
no additional meaning compared to "if", beyond what was already obvious
from context. Thus, its only purpose is to smugly demonstrate that the
author attended their second-year mathematics classes, at the expense of
causing confusion for everyone who doesn't have such a background.

If you really think you need to convey extra information beyond what
"if" gives you, the English language contains plenty of devices for doing
so, without resorting to neologisms.

Change-Id: Iae21095d02ec2935c10e94f532235c2671c115b1
2013-10-23 10:56:54 -07:00
Boris Nagaev
c3a13553fa DairikiDiff: Optimise method WordLevelDiff._split()
_split() copied two arrays N times, where N is number of lines in diff.
This was done by $a = array_merge($a, ...);
Instead of doing this, new words are appended to the end of array
using []= syntax.

Bug: 47989
Change-Id: I41338a2a82fbc20d7511f4c79581880febeeeea5
2013-05-16 23:01:09 +00:00
umherirrender
9f14ecf829 Added space after switch/Removed spaces after unset
While at it, added/removed some other spaces in the same files

Change-Id: I84d8001aa123a008807ad5eb76f396aed7c899a4
2013-04-26 16:42:31 +02:00
umherirrender
892ee7a4af Fixed spacing in db/debug/diff/externalstore/objectcache folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: I32a43c547630ce31b6b25cc1bc9eedc50e67b2d7
2013-04-20 22:28:52 +02:00
umherirrender
6c278b6d7e fix some spacing
* Removed spaces around array index
* Removed double spaces or added spaces to begin or end of function
  calls, method signature, conditions or foreachs
* Added braces to one-line ifs
* Changed multi line conditions to one line conditions
* Realigned some arrays

Change-Id: Ia04d2a99d663b07101013c2d53b3b2e872fd9cc3
2013-03-25 22:22:46 +00:00
umherirrender
8764b3aa7c Remove spaces in function signature
Change-Id: I45aea7a7af88cd913b2f485913620a8af0ab2fed
2013-03-18 20:44:43 +01:00
umherirrender
d63121016d fix some spacing
Added/removed spaces around logical/arithmetic operator
Reduced multiple empty lines to one empty line
Removed wrong tabs before comments at end of line
Removed too many spaces in assigments

Change-Id: I2bba4e72f9b5f88c53324d7b70e6042f1aad8f6b
2013-03-07 17:53:21 +01:00
umherirrender
f97a3a4027 fix some spacing
Change-Id: I670a7baf3ba1e70d18346bb00938d518ba2063bd
2013-02-04 19:59:14 +00:00
jenkins-bot
7fbc18e1ba Merge "fix some spacing" 2013-01-27 13:14:56 +00:00
umherirrender
25bc3a0727 The use of function sizeof() is forbidden; use count() instead
From phpcs

Change-Id: I919c8af46a722cd1c14bb8c134400e2ec51160d1
2013-01-26 22:20:04 +01:00
umherirrender
2e8da558ba fix some spacing
Change-Id: Id7eda67a43f9040117edd79fdbeb678f1c3a6da2
2013-01-26 22:11:09 +01:00
Antoine Musso
42a8daaf5a (bug 26280) all files should have GPL header
MediaWiki is licensed under GPL so we should really add the header to
our PHP code unless reusing code licensed differently.

Tested using:
  ack-grep --php -L 'This program is free software' \
    includes/ maintenance/ mw-config/ resources/ skins/

Output the following files:
 includes/ExternalEdit.php (public domain)

Various other licenses:
 includes/json/Services_JSON.php
 includes/libs/CSSMin.php
 includes/libs/IEContentAnalyzer.php
 includes/libs/JavaScriptMinifier.php
 includes/libs/jsminplus.php
 includes/normal/Utf8Case.php
 includes/objectcache/MemcachedClient.php

File autogenerated from a GPL file and Unicode data:
 includes/ZhConversion.php

A few lines coming from stack overflow:
 maintenance/mwdoc-filter.php

Message files do not have any license :-/

Change-Id: I214a988edfa9e2dfcc762612a0f7d47eee8bcb74
2012-11-18 15:34:00 +01:00
umherirrender
82375631c2 Fix tabs inside/between statements/text
This tabs are strange and a space there is better

Change-Id: I0885dff575ee2fcd0668d08fef3226e132c5b319
2012-10-26 18:18:59 +02:00
Christian Aistleitner
0954fc366f Sanitizing already existing use of PHP's assert 2012-03-19 11:14:43 +00:00
Sam Reed
c052fc3b7b Documentation followups from lastnight 2012-02-10 15:37:33 +00:00
Sam Reed
7b25f8231f Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 19:30:01 +00:00
Aaron Schulz
fe728c8b92 Reverted r101244 changes - these are not equivalent and may have been causing the assertion failures people (timo, myself) were getting. 2011-11-09 22:59:09 +00:00