From: Kunal Mehta Date: Fri, 22 Mar 2019 01:12:50 +0000 (-0700) Subject: Fix/suppress misc phan errors (#2) X-Git-Tag: 1.34.0-rc.0~2136^2 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=7bd9073c4b9d14a31a8a3b539fcbb9b3877d824d;p=lhc%2Fweb%2Fwiklou.git Fix/suppress misc phan errors (#2) * Title: phan false positive * McrUndoAction: fixed improper use of @param * UploadSourceAdapter: fixed wrong type * XmlTypeCheck: Use null so phan doesn't think we're trying to call the function '' * Database: phan false positive * SpecialBlock: Use phan's advanced type documentation so phan knows specifically what's being returned * ChangesListSpecialPage: phan false positive * BatchRowUpdate: Have default callback take a parameter so phan doesn't think too many arguments are being passed * MimeAnalyzer: left FIXME for relying on PHP 7.1 unpack() signature * LanguageConverter: Specify types for $mTables since phan couldn't determine it automatically * preprocessorFuzzTest: Implement User::load() method signature Change-Id: I08080ab636c5fe67ea6a4e14b2212d7523606e21 --- diff --git a/.phan/config.php b/.phan/config.php index 2c0035ea04..e0395cb2d3 100644 --- a/.phan/config.php +++ b/.phan/config.php @@ -81,33 +81,19 @@ $cfg['suppress_issue_types'] = array_merge( $cfg['suppress_issue_types'], [ "PhanCommentParamWithoutRealParam", // approximate error count: 2 "PhanCompatibleNegativeStringOffset", - // approximate error count: 1 - "PhanEmptyFQSENInCallable", - // approximate error count: 1 - "PhanInvalidCommentForDeclarationType", - // approximate error count: 6 - "PhanNonClassMethodCall", // approximate error count: 21 "PhanParamReqAfterOpt", - // approximate error count: 27 + // approximate error count: 26 "PhanParamSignatureMismatch", // approximate error count: 4 "PhanParamSignatureMismatchInternal", - // approximate error count: 1 - "PhanParamSignatureRealMismatchTooFewParameters", - // approximate error count: 1 - "PhanParamSuspiciousOrder", // approximate error count: 127 "PhanParamTooMany", // approximate error count: 2 - "PhanParamTooManyCallable", - // approximate error count: 1 - "PhanParamTooManyInternal", - // approximate error count: 2 "PhanPluginDuplicateExpressionBinaryOp", // approximate error count: 2 "PhanTraitParentReference", - // approximate error count: 27 + // approximate error count: 26 "PhanTypeArraySuspicious", // approximate error count: 33 "PhanTypeArraySuspiciousNullable", @@ -133,7 +119,7 @@ $cfg['suppress_issue_types'] = array_merge( $cfg['suppress_issue_types'], [ "PhanTypeInvalidRightOperandOfIntegerOp", // approximate error count: 152 "PhanTypeMismatchArgument", - // approximate error count: 28 + // approximate error count: 27 "PhanTypeMismatchArgumentInternal", // approximate error count: 1 "PhanTypeMismatchBitwiseBinaryOperands", @@ -143,7 +129,7 @@ $cfg['suppress_issue_types'] = array_merge( $cfg['suppress_issue_types'], [ "PhanTypeMismatchDimFetch", // approximate error count: 10 "PhanTypeMismatchForeach", - // approximate error count: 77 + // approximate error count: 78 "PhanTypeMismatchProperty", // approximate error count: 88 "PhanTypeMismatchReturn", @@ -171,7 +157,7 @@ $cfg['suppress_issue_types'] = array_merge( $cfg['suppress_issue_types'], [ "PhanUndeclaredVariableAssignOp", // approximate error count: 55 "PhanUndeclaredVariableDim", - // approximate error count: 4 + // approximate error count: 3 "PhanUnextractableAnnotationElementName", // approximate error count: 4 "PhanUnextractableAnnotationSuffix", diff --git a/includes/Title.php b/includes/Title.php index d517b851e5..3d54750cea 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -731,6 +731,7 @@ class Title implements LinkTarget, IDBAccessObject { // Allow unicode if a single high-bit character appears $r0 = sprintf( '\x%02x', $ord0 ); $allowUnicode = true; + // @phan-suppress-next-line PhanParamSuspiciousOrder false positive } elseif ( strpos( '-\\[]^', $d0 ) !== false ) { $r0 = '\\' . $d0; } else { diff --git a/includes/actions/McrUndoAction.php b/includes/actions/McrUndoAction.php index b0f89dcf85..e9de84675a 100644 --- a/includes/actions/McrUndoAction.php +++ b/includes/actions/McrUndoAction.php @@ -30,7 +30,7 @@ class McrUndoAction extends FormAction { protected $undo = 0, $undoafter = 0, $cur = 0; - /** @param RevisionRecord|null */ + /** @var RevisionRecord|null */ protected $curRev = null; public function getName() { diff --git a/includes/htmlform/OOUIHTMLForm.php b/includes/htmlform/OOUIHTMLForm.php index 738db0966b..e21d783fcc 100644 --- a/includes/htmlform/OOUIHTMLForm.php +++ b/includes/htmlform/OOUIHTMLForm.php @@ -145,6 +145,10 @@ class OOUIHTMLForm extends HTMLForm { [ 'class' => 'mw-htmlform-submit-buttons' ], "\n$buttons" ) . "\n"; } + /** + * @inheritDoc + * @return OOUI\PanelLayout + */ protected function wrapFieldSetSection( $legend, $section, $attributes, $isRoot ) { // to get a user visible effect, wrap the fieldset into a framed panel layout $layout = new OOUI\PanelLayout( [ diff --git a/includes/import/UploadSourceAdapter.php b/includes/import/UploadSourceAdapter.php index ccacbe4a7c..7ac895c9d3 100644 --- a/includes/import/UploadSourceAdapter.php +++ b/includes/import/UploadSourceAdapter.php @@ -32,7 +32,7 @@ class UploadSourceAdapter { /** @var array */ public static $sourceRegistrations = []; - /** @var string */ + /** @var ImportSource */ private $mSource; /** @var string */ diff --git a/includes/libs/mime/MimeAnalyzer.php b/includes/libs/mime/MimeAnalyzer.php index e08da6155d..413fb2a15e 100644 --- a/includes/libs/mime/MimeAnalyzer.php +++ b/includes/libs/mime/MimeAnalyzer.php @@ -806,6 +806,8 @@ EOT; if ( $eocdrPos !== false ) { $this->logger->info( __METHOD__ . ": ZIP signature present in $file\n" ); // Check if it really is a ZIP file, make sure the EOCDR is at the end (T40432) + // FIXME: unpack()'s third argument was added in PHP 7.1 + // @phan-suppress-next-line PhanParamTooManyInternal $commentLength = unpack( "n", $tail, $eocdrPos + 20 )[0]; if ( $eocdrPos + 22 + $commentLength !== strlen( $tail ) ) { $this->logger->info( __METHOD__ . ": ZIP EOCDR not at end. Not a ZIP file." ); diff --git a/includes/libs/mime/XmlTypeCheck.php b/includes/libs/mime/XmlTypeCheck.php index 746f3f5382..0b523916cb 100644 --- a/includes/libs/mime/XmlTypeCheck.php +++ b/includes/libs/mime/XmlTypeCheck.php @@ -72,7 +72,7 @@ class XmlTypeCheck { * Additional parsing options */ private $parserOptions = [ - 'processing_instruction_handler' => '', + 'processing_instruction_handler' => null, 'external_dtd_handler' => '', 'dtd_handler' => '', 'require_safe_dtd' => true diff --git a/includes/libs/rdbms/database/Database.php b/includes/libs/rdbms/database/Database.php index 27392050ce..a839946285 100644 --- a/includes/libs/rdbms/database/Database.php +++ b/includes/libs/rdbms/database/Database.php @@ -3580,6 +3580,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware list( $phpCallback ) = $callback; $this->clearFlag( self::DBO_TRX ); // make each query its own transaction try { + // @phan-suppress-next-line PhanParamTooManyCallable call_user_func( $phpCallback, $trigger, $this ); } catch ( Exception $ex ) { call_user_func( $this->errorLogger, $ex ); diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index 82bc84dc59..9e7e21d06d 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -1072,6 +1072,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { $filterDefinition = $this->transformFilterDefinition( $filterDefinition ); } + // @phan-suppress-next-line PhanNonClassMethodCall $this->registerFilterGroup( new $className( $groupDefinition ) ); } } diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index b558d5ec4f..155d6a48f6 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -620,6 +620,7 @@ class SpecialBlock extends FormSpecialPage { * the HTMLForm * @param WebRequest|null $request Optionally try and get data from a request too * @return array [ User|string|null, Block::TYPE_ constant|null ] + * @phan-return array{0:User|string|null,1:int|null} */ public static function getTargetAndType( $par, WebRequest $request = null ) { $i = 0; diff --git a/includes/utils/BatchRowUpdate.php b/includes/utils/BatchRowUpdate.php index f42b5a072a..f2bc6150a8 100644 --- a/includes/utils/BatchRowUpdate.php +++ b/includes/utils/BatchRowUpdate.php @@ -77,7 +77,7 @@ class BatchRowUpdate { $this->reader = $reader; $this->writer = $writer; $this->generator = $generator; - $this->output = function () { + $this->output = function ( $text ) { }; // nop } diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index 8aa7c87a9e..c5ff9d65a7 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -60,7 +60,13 @@ class LanguageConverter { public $mVariantFallbacks; public $mVariantNames; public $mTablesLoaded = false; + + /** + * @var ReplacementArray[] + * @phan-var array + */ public $mTables; + // 'bidirectional' 'unidirectional' 'disable' for each variant public $mManualLevel; diff --git a/maintenance/preprocessorFuzzTest.php b/maintenance/preprocessorFuzzTest.php index d5d27ad8ce..8df01e66fb 100644 --- a/maintenance/preprocessorFuzzTest.php +++ b/maintenance/preprocessorFuzzTest.php @@ -239,7 +239,7 @@ class PPFuzzTest { class PPFuzzUser extends User { public $ppfz_test, $mDataLoaded; - function load() { + function load( $flags = null ) { if ( $this->mDataLoaded ) { return; }