From 3439c0007376adfddea2de9be105a37938aead56 Mon Sep 17 00:00:00 2001 From: Daimona Eaytoy Date: Sat, 7 Sep 2019 15:06:50 +0200 Subject: [PATCH] Suppress PhanUndeclaredProperty for custom properties and phan bugs And remove the issue from the exclusions list. Bug: T231636 Change-Id: Iee73ddb554e354abe52d13dcfc453f9a15bb8877 --- .phan/config.php | 2 -- includes/OutputPage.php | 1 + includes/Status.php | 1 + includes/api/ApiComparePages.php | 2 ++ includes/htmlform/HTMLFormField.php | 1 + includes/media/DjVuHandler.php | 2 ++ includes/resourceloader/ResourceLoaderImage.php | 1 + includes/specials/SpecialTags.php | 8 ++++++++ includes/specials/forms/PreferencesFormOOUI.php | 2 ++ includes/title/MediaWikiTitleCodec.php | 1 + includes/utils/AvroValidator.php | 2 +- maintenance/findDeprecated.php | 1 + 12 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.phan/config.php b/.phan/config.php index fc775fe5fe..b1ca2a73f0 100644 --- a/.phan/config.php +++ b/.phan/config.php @@ -104,8 +104,6 @@ $cfg['suppress_issue_types'] = array_merge( $cfg['suppress_issue_types'], [ // approximate error count: 45 "PhanTypeMismatchArgument", - // approximate error count: 693 - "PhanUndeclaredProperty", ] ); // This helps a lot in discovering bad code, but unfortunately it will always fail for diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 9dbbf139de..79b343eb3b 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1598,6 +1598,7 @@ class OutputPage extends ContextSource { * @param ParserOptions|null $options Either the ParserOption to use or null to only get the * current ParserOption object. This parameter is deprecated since 1.31. * @return ParserOptions + * @suppress PhanUndeclaredProperty For isBogus */ public function parserOptions( $options = null ) { if ( $options !== null ) { diff --git a/includes/Status.php b/includes/Status.php index 76b905eca4..932fd2a650 100644 --- a/includes/Status.php +++ b/includes/Status.php @@ -115,6 +115,7 @@ class Status extends StatusValue { * ] * * @return Status[] + * @suppress PhanUndeclaredProperty Status vs StatusValue */ public function splitByErrorType() { list( $errorsOnlyStatus, $warningsOnlyStatus ) = parent::splitByErrorType(); diff --git a/includes/api/ApiComparePages.php b/includes/api/ApiComparePages.php index c4a97def97..6e788d550d 100644 --- a/includes/api/ApiComparePages.php +++ b/includes/api/ApiComparePages.php @@ -252,6 +252,7 @@ class ApiComparePages extends ApiBase { ); if ( $row ) { $rev = $this->revisionStore->newRevisionFromArchiveRow( $row ); + // @phan-suppress-next-line PhanUndeclaredProperty $rev->isArchive = true; } } @@ -620,6 +621,7 @@ class ApiComparePages extends ApiBase { } } + // @phan-suppress-next-line PhanUndeclaredProperty if ( !empty( $rev->isArchive ) ) { $this->getMain()->setCacheMode( 'private' ); $vals["{$prefix}archive"] = true; diff --git a/includes/htmlform/HTMLFormField.php b/includes/htmlform/HTMLFormField.php index 048abbbf49..b55b65287d 100644 --- a/includes/htmlform/HTMLFormField.php +++ b/includes/htmlform/HTMLFormField.php @@ -657,6 +657,7 @@ abstract class HTMLFormField { * @param OOUI\Widget $inputField * @param array $config * @return OOUI\FieldLayout|OOUI\ActionFieldLayout + * @suppress PhanUndeclaredProperty Only some subclasses declare mClassWithButton */ protected function getFieldLayoutOOUI( $inputField, $config ) { if ( isset( $this->mClassWithButton ) ) { diff --git a/includes/media/DjVuHandler.php b/includes/media/DjVuHandler.php index 3b904e8418..d54dd6bc05 100644 --- a/includes/media/DjVuHandler.php +++ b/includes/media/DjVuHandler.php @@ -240,6 +240,7 @@ class DjVuHandler extends ImageHandler { * @param File|FSFile $image * @param string $path * @return DjVuImage + * @suppress PhanUndeclaredProperty Custom property */ function getDjVuImage( $image, $path ) { if ( !$image ) { @@ -290,6 +291,7 @@ class DjVuHandler extends ImageHandler { * @param File $image * @param bool $gettext DOCUMENT (Default: false) * @return bool|SimpleXMLElement + * @suppress PhanUndeclaredProperty Custom property */ public function getMetaTree( $image, $gettext = false ) { if ( $gettext && isset( $image->djvuTextTree ) ) { diff --git a/includes/resourceloader/ResourceLoaderImage.php b/includes/resourceloader/ResourceLoaderImage.php index 6497543f56..43ebfbfe30 100644 --- a/includes/resourceloader/ResourceLoaderImage.php +++ b/includes/resourceloader/ResourceLoaderImage.php @@ -337,6 +337,7 @@ class ResourceLoaderImage { // Reattach all direct children of the `` root node to the `` wrapper while ( $root->firstChild ) { $node = $root->firstChild; + // @phan-suppress-next-line PhanUndeclaredProperty False positive if ( !$titleNode && $node->nodeType === XML_ELEMENT_NODE && $node->tagName === 'title' ) { // Remember the first encountered `` node $titleNode = $node; diff --git a/includes/specials/SpecialTags.php b/includes/specials/SpecialTags.php index 2c8d43297d..34665dd99e 100644 --- a/includes/specials/SpecialTags.php +++ b/includes/specials/SpecialTags.php @@ -381,6 +381,7 @@ class SpecialTags extends SpecialPage { $form = HTMLForm::factory( 'ooui', $fields, $this->getContext() ); $form->setAction( $this->getPageTitle( 'delete' )->getLocalURL() ); + // @phan-suppress-next-line PhanUndeclaredProperty $form->tagAction = 'delete'; // custom property on HTMLForm object $form->setSubmitCallback( [ $this, 'processTagForm' ] ); $form->setSubmitTextMsg( 'tags-delete-submit' ); @@ -433,6 +434,7 @@ class SpecialTags extends SpecialPage { $form = HTMLForm::factory( 'ooui', $fields, $this->getContext() ); $form->setAction( $this->getPageTitle( $actionStr )->getLocalURL() ); + // @phan-suppress-next-line PhanUndeclaredProperty $form->tagAction = $actionStr; $form->setSubmitCallback( [ $this, 'processTagForm' ] ); // tags-activate-submit, tags-deactivate-submit @@ -441,6 +443,12 @@ class SpecialTags extends SpecialPage { $form->show(); } + /** + * @param array $data + * @param HTMLForm $form + * @return bool + * @suppress PhanUndeclaredProperty $form->tagAction + */ public function processTagForm( array $data, HTMLForm $form ) { $context = $form->getContext(); $out = $context->getOutput(); diff --git a/includes/specials/forms/PreferencesFormOOUI.php b/includes/specials/forms/PreferencesFormOOUI.php index b1bfd0bb32..445f0c36eb 100644 --- a/includes/specials/forms/PreferencesFormOOUI.php +++ b/includes/specials/forms/PreferencesFormOOUI.php @@ -111,6 +111,8 @@ class PreferencesFormOOUI extends OOUIHTMLForm { function filterDataForSubmit( $data ) { foreach ( $this->mFlatFields as $fieldname => $field ) { if ( $field instanceof HTMLNestedFilterable ) { + // @phan-suppress-next-next-line PhanUndeclaredProperty All HTMLForm fields have mParams, + // but the instanceof confuses phan, which doesn't support intersections $info = $field->mParams; $prefix = $info['prefix'] ?? $fieldname; foreach ( $field->filterDataForSubmit( $data[$fieldname] ) as $key => $value ) { diff --git a/includes/title/MediaWikiTitleCodec.php b/includes/title/MediaWikiTitleCodec.php index 3bd66d40c6..3ebb4430ec 100644 --- a/includes/title/MediaWikiTitleCodec.php +++ b/includes/title/MediaWikiTitleCodec.php @@ -237,6 +237,7 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser { * @param LinkTarget $title * * @return string + * @suppress PhanUndeclaredProperty */ public function getPrefixedText( LinkTarget $title ) { if ( !isset( $title->prefixedText ) ) { diff --git a/includes/utils/AvroValidator.php b/includes/utils/AvroValidator.php index f3a8810a98..77ea3d9d4c 100644 --- a/includes/utils/AvroValidator.php +++ b/includes/utils/AvroValidator.php @@ -34,7 +34,7 @@ class AvroValidator { * @return string|string[] An error or list of errors in the * provided $datum. When no errors exist the empty array is * returned. - * @suppress PhanUndeclaredMethod + * @suppress PhanUndeclaredMethod,PhanUndeclaredProperty */ public static function getErrors( AvroSchema $schema, $datum ) { switch ( $schema->type ) { diff --git a/maintenance/findDeprecated.php b/maintenance/findDeprecated.php index d4f9c2d0c7..03035f756a 100644 --- a/maintenance/findDeprecated.php +++ b/maintenance/findDeprecated.php @@ -20,6 +20,7 @@ * * @file * @ingroup Maintenance + * @phan-file-suppress PhanUndeclaredProperty Lots of custom properties */ require_once __DIR__ . '/Maintenance.php'; -- 2.20.1