From dddc912fd63aa5982ff6da2249300c2127ca6992 Mon Sep 17 00:00:00 2001 From: Daimona Eaytoy Date: Sun, 15 Sep 2019 15:22:08 +0200 Subject: [PATCH] Update docblocks for methods potentially returning null These were discovered by setting `null_casts_as_any_type` to true in phan, and filtering by `PhanTypeMismatchReturnNullable`. Of course there are others, some of which are false positives, but we cannot suppress them now (or the UnusedSuppressionPlugin will complain). Change-Id: Ia8443e575c22f47a6d8c63038f4e7ac36815fc27 --- includes/EditPage.php | 2 +- includes/GlobalFunctions.php | 3 ++- includes/WebRequest.php | 2 +- includes/actions/SpecialPageAction.php | 3 +++ includes/api/ApiQueryQueryPage.php | 2 +- includes/import/WikiImporter.php | 3 ++- includes/parser/CoreParserFunctions.php | 2 +- includes/site/MediaWikiSite.php | 2 +- includes/site/Site.php | 2 +- 9 files changed, 13 insertions(+), 8 deletions(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index c346b750d9..02c395e9b2 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -2742,7 +2742,7 @@ ERROR; * content. * * @param Content|null|bool|string $content - * @return string The editable text form of the content. + * @return string|false|null The editable text form of the content. * * @throws MWException If $content is not an instance of TextContent and * $this->allowNonTextContent is not true. diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 38daab5c32..3b4e657f75 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1816,10 +1816,11 @@ function mimeTypeMatch( $type, $avail ) { * * @param array $cprefs Client's acceptable type list * @param array $sprefs Server's offered types - * @return string + * @return string|null * * @todo FIXME: Doesn't handle params like 'text/plain; charset=UTF-8' * XXX: generalize to negotiate other stuff + * @todo The function appears unused. Is it worth to keep? */ function wfNegotiateType( $cprefs, $sprefs ) { $combine = []; diff --git a/includes/WebRequest.php b/includes/WebRequest.php index a48d0325ee..c94e8d4e23 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -547,7 +547,7 @@ class WebRequest { * * @param string $name * @param array|null $default Option default (or null) - * @return array Array of ints + * @return int[]|null */ public function getIntArray( $name, $default = null ) { $val = $this->getArray( $name, $default ); diff --git a/includes/actions/SpecialPageAction.php b/includes/actions/SpecialPageAction.php index 8a231cbe5f..56be456cac 100644 --- a/includes/actions/SpecialPageAction.php +++ b/includes/actions/SpecialPageAction.php @@ -35,6 +35,9 @@ class SpecialPageAction extends FormlessAction { 'editchangetags' => 'EditTags', ]; + /** + * @inheritDoc + */ public function getName() { $request = $this->getRequest(); $actionName = $request->getVal( 'action', 'view' ); diff --git a/includes/api/ApiQueryQueryPage.php b/includes/api/ApiQueryQueryPage.php index 26c17c59b8..12e908ff11 100644 --- a/includes/api/ApiQueryQueryPage.php +++ b/includes/api/ApiQueryQueryPage.php @@ -61,7 +61,7 @@ class ApiQueryQueryPage extends ApiQueryGeneratorBase { * @param string $name * @return QueryPage */ - private function getSpecialPage( $name ) { + private function getSpecialPage( $name ) : QueryPage { $qp = $this->specialPageFactory->getPage( $name ); if ( !$qp ) { self::dieDebug( diff --git a/includes/import/WikiImporter.php b/includes/import/WikiImporter.php index 0d1cc6804a..6eba4f3a3a 100644 --- a/includes/import/WikiImporter.php +++ b/includes/import/WikiImporter.php @@ -33,7 +33,8 @@ use MediaWiki\MediaWikiServices; * @ingroup SpecialPage */ class WikiImporter { - private $reader = null; + /** @var XMLReader */ + private $reader; private $foreignNamespaces = null; private $mLogItemCallback, $mUploadCallback, $mRevisionCallback, $mPageCallback; private $mSiteInfoCallback, $mPageOutCallback; diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index e1f4f38a59..b803241956 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -1121,7 +1121,7 @@ class CoreParserFunctions { * @param Parser $parser * @param Title $title * @param string $vary ParserOuput vary-* flag - * @return Revision + * @return Revision|null * @since 1.23 */ private static function getCachedRevisionObject( $parser, $title, $vary ) { diff --git a/includes/site/MediaWikiSite.php b/includes/site/MediaWikiSite.php index 14c9a7315d..3e2a9a2b40 100644 --- a/includes/site/MediaWikiSite.php +++ b/includes/site/MediaWikiSite.php @@ -176,7 +176,7 @@ class MediaWikiSite extends Site { * * @param string|bool $pageName Page name or false (default: false) * - * @return string + * @return string|bool|null */ public function getPageUrl( $pageName = false ) { $url = $this->getLinkPath(); diff --git a/includes/site/Site.php b/includes/site/Site.php index bcf8b32b88..10711a6fbb 100644 --- a/includes/site/Site.php +++ b/includes/site/Site.php @@ -365,7 +365,7 @@ class Site implements Serializable { * * @param bool|string $pageName * - * @return string|bool + * @return string|bool|null */ public function getPageUrl( $pageName = false ) { $url = $this->getLinkPath(); -- 2.20.1