From e99e181303ad92f45b4d74a5c2ee84ae693b830c Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Sat, 24 Feb 2018 18:41:50 -0800 Subject: [PATCH] Add phan configuration Depends-On: I09a0c0a786b687997e61344847f8af08b20cebf2 Change-Id: I9500232fb524e884d6cb15f2bdda10835df35ad4 --- .gitignore | 1 + composer.json | 3 ++- includes/GadgetDefinitionNamespaceRepo.php | 6 +++++- includes/GadgetHooks.php | 1 + includes/MediaWikiGadgetsDefinitionRepo.php | 6 ++++++ includes/SpecialGadgetUsage.php | 3 +++ includes/SpecialGadgets.php | 2 +- includes/content/GadgetDefinitionContent.php | 1 + tests/phan/config.php | 8 ++++++++ 9 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 tests/phan/config.php diff --git a/.gitignore b/.gitignore index 7b293a6e..d994054d 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ project.index ## Sublime sublime-* sftp-config.json +tests/phan/issues diff --git a/composer.json b/composer.json index 02dda6e8..6d676750 100644 --- a/composer.json +++ b/composer.json @@ -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": [ diff --git a/includes/GadgetDefinitionNamespaceRepo.php b/includes/GadgetDefinitionNamespaceRepo.php index 5746d894..fdecee80 100644 --- a/includes/GadgetDefinitionNamespaceRepo.php +++ b/includes/GadgetDefinitionNamespaceRepo.php @@ -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 ) { diff --git a/includes/GadgetHooks.php b/includes/GadgetHooks.php index 312cb4f5..e7f232e4 100644 --- a/includes/GadgetHooks.php +++ b/includes/GadgetHooks.php @@ -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(); diff --git a/includes/MediaWikiGadgetsDefinitionRepo.php b/includes/MediaWikiGadgetsDefinitionRepo.php index 47157623..84c84b6c 100644 --- a/includes/MediaWikiGadgetsDefinitionRepo.php +++ b/includes/MediaWikiGadgetsDefinitionRepo.php @@ -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] ) ) { diff --git a/includes/SpecialGadgetUsage.php b/includes/SpecialGadgetUsage.php index 79cb77ca..7e6d8d1a 100644 --- a/includes/SpecialGadgetUsage.php +++ b/includes/SpecialGadgetUsage.php @@ -24,6 +24,9 @@ * @author Niharika Kohli */ +use Wikimedia\Rdbms\IDatabase; +use Wikimedia\Rdbms\ResultWrapper; + /** * Special:GadgetUsage - Lists all the gadgets on the wiki along with number of users. * @ingroup SpecialPage diff --git a/includes/SpecialGadgets.php b/includes/SpecialGadgets.php index 6ddffef3..9f8c9066 100644 --- a/includes/SpecialGadgets.php +++ b/includes/SpecialGadgets.php @@ -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 ); diff --git a/includes/content/GadgetDefinitionContent.php b/includes/content/GadgetDefinitionContent.php index cede38db..0a7b2d9d 100644 --- a/includes/content/GadgetDefinitionContent.php +++ b/includes/content/GadgetDefinitionContent.php @@ -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() ); diff --git a/tests/phan/config.php b/tests/phan/config.php new file mode 100644 index 00000000..c2deb7dc --- /dev/null +++ b/tests/phan/config.php @@ -0,0 +1,8 @@ +