Commit graph

24 commits

Author SHA1 Message Date
addshore
a756f82851 Update phan issues & estimated counts
Since the last update there is a total of 550 less issues.
744 removed and 194 added in various places.
(roughly)

Change-Id: I0431773973c146e1492de72d869f6d33de4084e8
2017-06-30 14:10:04 +01:00
Antoine Musso
7671b2b71e Drop in replacement of eval.php based on psysh
eval.php is meant to eval() commands in MediaWiki global scope. We had
at least a couple attempts to move it to a regular Maintenance script.

As noted on the revert commit b475e930 r54839, using a Maintenance
script drop us in the callee function scope instead of the global scope
which is a hard requirement.

http://psysh.org/ is a Read-Eval-Print-Loop with color highlight, modern
code and more.

Add maintenance/shell.php script as MediaWikiShell class.

Passing command from stdin is supported.
Execution is forked for graceful handling of PHP fatal errors.
Colors!!
Support the undocumented '-d' arguments from eval.php:
  0 set $wgDebugLogFile to stdout. Eval.php used /dev/stdout, make it
    php://stdout in the new script.
  1 additionally set DBO_DEBUG on all the database load balancer servers

PHP globals have to be whitelisted which is not supported out of the box
by Psy. Upon request, the author of PsySh, Justin Hileman, kindly
provided a pass to inject globals (with the exceptions of super
globals). He agreed for code reuse:
    https://github.com/bobthecow/psysh/issues/353
The code was added to maintenance/CodeCleanerGlobalsPass.inc

Note that this is not a perfect simulation of global scope (but pretty
close): variables declared in the shell which did not exist before
won't be global unless the 'global' keword is used.

Example usage:

$ php maintenance/shell.php

>>> $wgFullyInitialised
=> true

>>> $hashar = User::newFromName( 'hashar' )
=> User {#274
     +mId: null,
     +mName: "Hashar",
     ...

>>> ls --long --all $h
<descriptive output of all object properties/methods>

Bug: T117661
Signed-off-by: Justin Hileman <justin@justinhileman.info>
Signed-off-by: Gergő Tisza <tgr.huwiki@gmail.com>
Change-Id: I3d6d42e138d3cc4a0aaafdd7f5f97cb17d8b8cb3
2017-02-13 08:34:38 +00:00
addshore
d8d408503c PHAN: Add tideways stub
Used in Xhprof

Change-Id: I9f208bbaa0799d194dbef61cad851995020a5d17
2017-01-30 16:25:59 +00:00
addshore
9252dff64b PHAN: load stubs from phpstorm-stubs library
Also add a single small stub for the Memcached class
constructor that is slightly wrong in the phpstorm
stubs library.

jetbrains/phpstorm-stubs has been added to packagist via:
https://github.com/JetBrains/phpstorm-stubs/pull/149

Change-Id: I1bca7390d1dc24c38d65c1c8968f356326ff4636
2017-01-30 16:25:47 +00:00
jenkins-bot
96491f80d3 Merge "PHAN: conditionally load stubs" 2017-01-23 18:11:43 +00:00
addshore
d9c717c089 PHAN: conditionally load stubs
Change-Id: I6f78c573468a393d82927d614df5bceda86a9e9c
2017-01-23 17:40:09 +01:00
Erik Bernhardson
e5b8bf4942 Un-blacklist PhanUndeclaredVariable
Undeclared variables are a very common error type that we want to catch
as often as possible. To avoid needing to refactor a variety of global
level code (mostly in old-style maintenance scripts) this ignores
undeclared variables in global scope. This is still a good improvement
over what was happening previously.

Change-Id: I50b41d571724244552074b9408abbdf6160aca59
2017-01-18 13:07:39 -08:00
WMDE-Fisch
7e32cbb6c3 Fixed typo in comment
Change-Id: I58dba2018a20c34537222ba7711a39c75855be52
2017-01-04 14:49:26 +00:00
Leszek Manicki
cb4bb23df6 Remove unused static methods in LanguageConverter subclasses
It seems LanguageConverter::parseManualRule was removed by
69dbeb97f1 (2008),
and LanguageConverter::parserConvert by
c568220e61 (2010),
so it seems safe and reasonable to remove their implementations
from few remaining language-specific Converter classes.

Change-Id: I7092f5c8856723fabd2b1f99944451344feb5711
2017-01-03 15:13:51 +01:00
jenkins-bot
c496cb3ff9 Merge "Remove unused Phan exception" 2016-12-19 21:31:03 +00:00
Max Semenik
0b2e6272b8 Remove unused Phan exception
Change-Id: Ib578336abfed02c8dce9ccb47ab22220ddcee856
2016-12-18 04:48:10 -08:00
Max Semenik
633e638cae Fix type annotation
Change-Id: I8996a7617c4723c9c4ff8f91d0f3767c9e67dd28
2016-12-16 17:11:51 -08:00
Max Semenik
d4f3e554d7 Decrease the number of 'function says it should return something' errors
Change-Id: Ib5115fe5bbaa67d8a6e54cc3ba1ba7020e239e11
2016-12-15 16:05:52 -08:00
Max Semenik
f23a964170 Fix type annotations
Change-Id: Ib72c98358b2f0b3b73b6f105adea47346373d46d
2016-12-15 14:11:12 -08:00
Erik Bernhardson
41f9c933b3 Fix two instances of calling function with too few args
At one point SearchIndexFieldDefinition was updated to require the
engine to be passed in, but it seems that update was missed here.

BackupDumper::loadPlugin() requires the second argument, set it to
the empty string to keep current behaviour.

Change-Id: Ifbd8fc4870ff63b2d338f8bb4d251d7a3477b989
2016-12-15 13:24:40 -08:00
Erik Bernhardson
2e8923079b Correct DatabaseSqlite::unionQueries annotation
The annotation was claiming string, but it's very obvious from
the usage the it should be string[].

Change-Id: I99849a338971590ca68dfb175b2458ad5ebc0df2
2016-12-15 11:22:03 -08:00
jenkins-bot
457d5b702c Merge "Fix parameter type docs" 2016-12-14 19:41:20 +00:00
jenkins-bot
ffd5f40293 Merge "Document type of LogEntry::isPatrollable property" 2016-12-14 19:30:11 +00:00
Leszek Manicki
95b9d82a3a Fix parameter type docs
Changes:
 - uses int instead of number as param and return value type,
 - uses stdClass instead of stdObject
 - fixes ResourceLoaderClientHtml constructor's $target param type:
   it is string|null, not an array (previously misspelled as "aray")
 - changes the type of references to XML parser in XMP lib to resource
   instead of not existing XMLParser

Change-Id: I98c363ebc6658d1f4dcabad97a9a92f3fcd7ea8c
2016-12-14 17:01:47 +01:00
Leszek Manicki
584fd0c75b Document type of LogEntry::isPatrollable property
Change-Id: I557b92f25f15f57123af329c79ef1752025aedf3
2016-12-14 16:09:34 +01:00
Leszek Manicki
29737562b2 Fix assigning void return value to a variable
Change-Id: I1e675d121938c5b6b7f8165681c645154e3a70d0
2016-12-14 11:07:42 +01:00
Erik Bernhardson
3becc477a9 Add script to support per-line @suppress annotations in Phan
Adds the functionality of per-line @suppress annotations. Phan already
supports per-class or per-method annotations, but does not have any
per-line support due to the PHP AST only returning comments that are
class/property/method level docblocks.

This is a bit of a hack, but get's the job done. Removes the
PhanTypeInvalidLeftOperand issue from blacklist and suppresses it
to demonstrate the supression works as expected.

Change-Id: I5066b3b431fb69175a711ee366e95f31c7c47639
2016-12-13 11:54:10 -08:00
Erik Bernhardson
5c6c93c76d Adjust phan to allow for making progress strengthening analysis
With phan set to only report critical errors it will be quite hard
to cleanup the code base to the point where we are running stronger
analysis. Instead of setting minimimum severity to critical, set
minimum severity to low and suppress all existing issues.

This will allow developers to choose an issue type from the list, fix
it, and update the config.php to report on the issue in the future.

Change-Id: I2771a4ff37f43cca215b939ed7d82f137d72cea6
2016-12-13 11:21:17 -08:00
Erik Bernhardson
f5b4bd19b2 Add configuration for running etsy/phan against core
Adds the necessary configuration and stubs for phan static analysis to
run against mediawiki core. A variety of fixes have been applied to core
recently such with this current configuration we are completely passing,
except for one issue with a bug in Phan (https://github.com/etsy/phan/issues/286)

In it's current configuration Phan will detect fatal errors trying to
access non existant classes, undefined method calls, and other errors.
The analysis can be expanded as we cleanup more of the codebase.  This
is in preparation for working on getting the CI to run phan as part of
the review process. I have found phan to be usefull in CirrusSearch
(although with stricter config) for catching bugs and I think it could
help in core as well.

We arn't too far from being able to disable `null_casts_as_any_type`,
there are only a few classes that need adjusting. Lots more work needs
to be done to reduce `minimum_severity` from 10 to 5 (normal) or
0 (low).

Change-Id: Iafd55b1380f37d7b0d195eed081f8042166690e8
2016-12-07 20:04:01 -08:00