Add phan configuration

Depends-On: I09a0c0a786b687997e61344847f8af08b20cebf2
Change-Id: I9500232fb524e884d6cb15f2bdda10835df35ad4
This commit is contained in:
Kunal Mehta 2018-02-24 18:41:50 -08:00
parent 677d4e932c
commit e99e181303
9 changed files with 28 additions and 3 deletions

1
.gitignore vendored
View file

@ -23,3 +23,4 @@ project.index
## Sublime
sublime-*
sftp-config.json
tests/phan/issues

View file

@ -3,7 +3,8 @@
"jakub-onderka/php-parallel-lint": "0.9.2",
"jakub-onderka/php-console-highlighter": "0.3.2",
"mediawiki/mediawiki-codesniffer": "16.0.1",
"mediawiki/minus-x": "0.3.1"
"mediawiki/minus-x": "0.3.1",
"mediawiki/mediawiki-phan-config": "0.1.0"
},
"scripts": {
"fix": [

View file

@ -2,6 +2,7 @@
use MediaWiki\Linker\LinkTarget;
use MediaWiki\MediaWikiServices;
use Wikimedia\Rdbms\Database;
/**
* GadgetRepo implementation where each gadget has a page in
@ -99,6 +100,9 @@ class GadgetDefinitionNamespaceRepo extends GadgetRepo {
$gadget = $this->wanCache->getWithSetCallback(
$key,
self::CACHE_TTL,
/**
* @suppress PhanTypeMismatchArgument
*/
function ( $old, &$ttl, array &$setOpts ) use ( $id ) {
$setOpts += Database::getCacheSetOptions( wfGetDB( DB_REPLICA ) );
$title = Title::makeTitleSafe( NS_GADGET_DEFINITION, $id );
@ -153,7 +157,7 @@ class GadgetDefinitionNamespaceRepo extends GadgetRepo {
}
/**
* @param strng $id
* @param string $id
* @return string
*/
private function getGadgetCacheKey( $id ) {

View file

@ -239,6 +239,7 @@ class GadgetHooks {
* @param string $summary
* @throws Exception
* @return bool
* @suppress PhanUndeclaredMethod
*/
public static function onEditFilterMergedContent( $context, $content, $status, $summary ) {
$title = $context->getTitle();

View file

@ -12,6 +12,12 @@ class MediaWikiGadgetsDefinitionRepo extends GadgetRepo {
private $definitionCache;
/**
* @param string $id
*
* @return Gadget
* @throws InvalidArgumentException
*/
public function getGadget( $id ) {
$gadgets = $this->loadGadgets();
if ( !isset( $gadgets[$id] ) ) {

View file

@ -24,6 +24,9 @@
* @author Niharika Kohli <niharika@wikimedia.org>
*/
use Wikimedia\Rdbms\IDatabase;
use Wikimedia\Rdbms\ResultWrapper;
/**
* Special:GadgetUsage - Lists all the gadgets on the wiki along with number of users.
* @ingroup SpecialPage

View file

@ -16,7 +16,7 @@ class SpecialGadgets extends SpecialPage {
/**
* Main execution function
* @param array $par Parameters passed to the page
* @param string $par Parameters passed to the page
*/
public function execute( $par ) {
$parts = explode( '/', $par );

View file

@ -84,6 +84,7 @@ class GadgetDefinitionContent extends JsonContent {
* all fields filled out, populating defaults as necessary.
*
* @return array
* @suppress PhanUndeclaredMethod
*/
public function getAssocArray() {
$info = wfObjectToArray( $this->getData()->getValue() );

8
tests/phan/config.php Normal file
View file

@ -0,0 +1,8 @@
<?php
$cfg = require __DIR__ . '/../../vendor/mediawiki/mediawiki-phan-config/src/config.php';
$cfg['suppress_issue_types'][] = 'PhanDeprecatedFunction';
// Namespace constants
$cfg['file_list'][] = 'Gadgets.namespaces.php';
return $cfg;