Suppress PhanUndeclaredProperty for custom properties and phan bugs
authorDaimona Eaytoy <daimona.wiki@gmail.com>
Sat, 7 Sep 2019 13:06:50 +0000 (15:06 +0200)
committerDaimona Eaytoy <daimona.wiki@gmail.com>
Sat, 14 Sep 2019 13:22:54 +0000 (13:22 +0000)
And remove the issue from the exclusions list.

Bug: T231636
Change-Id: Iee73ddb554e354abe52d13dcfc453f9a15bb8877

12 files changed:
.phan/config.php
includes/OutputPage.php
includes/Status.php
includes/api/ApiComparePages.php
includes/htmlform/HTMLFormField.php
includes/media/DjVuHandler.php
includes/resourceloader/ResourceLoaderImage.php
includes/specials/SpecialTags.php
includes/specials/forms/PreferencesFormOOUI.php
includes/title/MediaWikiTitleCodec.php
includes/utils/AvroValidator.php
maintenance/findDeprecated.php

index fc775fe..b1ca2a7 100644 (file)
@@ -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
index 9dbbf13..79b343e 100644 (file)
@@ -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 ) {
index 76b905e..932fd2a 100644 (file)
@@ -115,6 +115,7 @@ class Status extends StatusValue {
         * ]
         *
         * @return Status[]
+        * @suppress PhanUndeclaredProperty Status vs StatusValue
         */
        public function splitByErrorType() {
                list( $errorsOnlyStatus, $warningsOnlyStatus ) = parent::splitByErrorType();
index c4a97de..6e788d5 100644 (file)
@@ -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;
index 048abbb..b55b652 100644 (file)
@@ -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 ) ) {
index 3b904e8..d54dd6b 100644 (file)
@@ -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 ) ) {
index 6497543..43ebfbf 100644 (file)
@@ -337,6 +337,7 @@ class ResourceLoaderImage {
                // Reattach all direct children of the `<svg>` root node to the `<g>` 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 `<title>` node
                                $titleNode = $node;
index 2c8d432..34665dd 100644 (file)
@@ -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();
index b1bfd0b..445f0c3 100644 (file)
@@ -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 ) {
index 3bd66d4..3ebb443 100644 (file)
@@ -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 ) ) {
index f3a8810..77ea3d9 100644 (file)
@@ -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 ) {
index d4f9c2d..03035f7 100644 (file)
@@ -20,6 +20,7 @@
  *
  * @file
  * @ingroup Maintenance
+ * @phan-file-suppress PhanUndeclaredProperty Lots of custom properties
  */
 
 require_once __DIR__ . '/Maintenance.php';