WikiPageFactory: Improve phan suppressions

Use @phan-var annotation instead of multiple suppressions

Change-Id: Ieb49c3c7838f8ef638c9215c0ae04d7e1048b3cd
This commit is contained in:
Ammarpad 2022-04-12 06:27:09 +01:00
parent 10a33e00d3
commit c14ba07591
2 changed files with 2 additions and 5 deletions

View file

@ -19,7 +19,7 @@ interface WikiPageFactoryHook {
* @since 1.35
*
* @param Title $title Title of the page
* @param WikiPage &$page Variable to set the created WikiPage to
* @param WikiPage|null &$page Variable to set the created WikiPage to
* @return bool|void True or no return value to continue or false to abort
*/
public function onWikiPageFactory( $title, &$page );

View file

@ -65,24 +65,21 @@ class WikiPageFactory {
// TODO: remove the need for casting to Title. We'll have to create a new hook to
// replace the WikiPageFactory hook.
$title = Title::castFromPageIdentity( $pageIdentity );
'@phan-var Title $title';
$page = null;
// @phan-suppress-next-line PhanTypeMismatchArgument castFrom does not return null here
if ( !$this->wikiPageFactoryHookRunner->onWikiPageFactory( $title, $page ) ) {
return $page;
}
switch ( $ns ) {
case NS_FILE:
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
$page = new WikiFilePage( $title );
break;
case NS_CATEGORY:
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
$page = new WikiCategoryPage( $title );
break;
default:
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable castFrom does not return null here
$page = new WikiPage( $title );
}