From e7186d68bd0e79610b150e92c2235ef496aaf185 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Thu, 21 Mar 2019 16:59:32 -0700 Subject: [PATCH] Upgrade to newer phan MediaWiki core now runs phan 1.2.6, bringing in nearly 2+ years of upstream fixes. Configuration was moved from `tests/phan` to `.phan/`. The legacy bash wrapper script is still kept in the repository in its own location for any extensions that are still using it. It should be removed before 1.33 is released. Since there's a lot of new issues being flagged, all currently failing issues are suppressed, and will be fixed in follow-up patches. We're dropping the jetbrains/phpstorm-stubs repository in favor of just the minimal stubs we need. Stubs for PHP extensions are kept in the new `.phan/internal_stubs` directory, since they're in a slightly different format than normal stubs. Normal stubs are kept in `.phan/stubs`. wikidiff2 and excimer are kept with these since we're also the upstream for them. Change-Id: I3fe437befa17f4fbaf97aa6271f659b56021f396 --- .phan/config.php | 201 ++++++ .phan/internal_stubs/memcached.phan_php | 180 ++++++ .phan/internal_stubs/oci8.phan_php | 589 ++++++++++++++++++ .phan/internal_stubs/sqlsrv.phan_php | 276 ++++++++ .phan/internal_stubs/tideways.phan_php | 28 + {tests/phan => .phan}/stubs/README | 0 {tests/phan => .phan}/stubs/excimer.php | 3 + {tests/phan => .phan}/stubs/hhvm.php | 2 + {tests/phan => .phan}/stubs/mail.php | 0 .phan/stubs/password.php | 11 + {tests/phan => .phan}/stubs/phpunit4.php | 0 {tests/phan => .phan}/stubs/wikidiff.php | 0 composer.json | 3 +- .../cache/localisation/LocalisationCache.php | 1 - includes/installer/Installer.php | 2 +- .../filebackend/FileBackendMultiWrite.php | 3 - tests/phan/config.php | 122 ---- tests/phan/stubs/memcached.php | 16 - tests/phan/stubs/tideways.php | 12 - 19 files changed, 1292 insertions(+), 157 deletions(-) create mode 100644 .phan/config.php create mode 100644 .phan/internal_stubs/memcached.phan_php create mode 100644 .phan/internal_stubs/oci8.phan_php create mode 100644 .phan/internal_stubs/sqlsrv.phan_php create mode 100644 .phan/internal_stubs/tideways.phan_php rename {tests/phan => .phan}/stubs/README (100%) rename {tests/phan => .phan}/stubs/excimer.php (95%) rename {tests/phan => .phan}/stubs/hhvm.php (95%) rename {tests/phan => .phan}/stubs/mail.php (100%) create mode 100644 .phan/stubs/password.php rename {tests/phan => .phan}/stubs/phpunit4.php (100%) rename {tests/phan => .phan}/stubs/wikidiff.php (100%) delete mode 100644 tests/phan/config.php delete mode 100644 tests/phan/stubs/memcached.php delete mode 100644 tests/phan/stubs/tideways.php diff --git a/.phan/config.php b/.phan/config.php new file mode 100644 index 0000000000..52d5d99442 --- /dev/null +++ b/.phan/config.php @@ -0,0 +1,201 @@ + '.phan/internal_stubs/memcached.phan_php', + 'oci8' => '.phan/internal_stubs/oci8.phan_php', + 'sqlsrv' => '.phan/internal_stubs/sqlsrv.phan_php', + 'tideways' => '.phan/internal_stubs/tideways.phan_php', +]; + +$cfg['directory_list'] = [ + 'includes/', + 'languages/', + 'maintenance/', + 'mw-config/', + 'resources/', + 'vendor/', + '.phan/stubs/', +]; + +$cfg['exclude_analysis_directory_list'] = [ + 'vendor/', + '.phan/stubs/', + // The referenced classes are not available in vendor, only when + // included from composer. + 'includes/composer/', + // Directly references classes that only exist in Translate extension + 'maintenance/language/', + // External class + 'includes/libs/jsminplus.php', +]; + +$cfg['suppress_issue_types'] = array_merge( $cfg['suppress_issue_types'], [ + // approximate error count: 18 + "PhanAccessMethodInternal", + // approximate error count: 17 + "PhanCommentParamOnEmptyParamList", + // approximate error count: 30 + "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 + "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 + "PhanPluginDuplicateConditionalNullCoalescing", + // approximate error count: 1 + "PhanPluginDuplicateConditionalTernaryDuplication", + // approximate error count: 2 + "PhanPluginDuplicateExpressionBinaryOp", + // approximate error count: 2 + "PhanTraitParentReference", + // approximate error count: 27 + "PhanTypeArraySuspicious", + // approximate error count: 33 + "PhanTypeArraySuspiciousNullable", + // approximate error count: 26 + "PhanTypeComparisonFromArray", + // approximate error count: 2 + "PhanTypeComparisonToArray", + // approximate error count: 1 + "PhanTypeConversionFromArray", + // approximate error count: 2 + "PhanTypeExpectedObjectOrClassName", + // approximate error count: 7 + "PhanTypeExpectedObjectPropAccess", + // approximate error count: 3 + "PhanTypeInstantiateAbstract", + // approximate error count: 1 + "PhanTypeInvalidCallableArraySize", + // approximate error count: 62 + "PhanTypeInvalidDimOffset", + // approximate error count: 10 + "PhanTypeInvalidExpressionArrayDestructuring", + // approximate error count: 1 + "PhanTypeInvalidLeftOperand", + // approximate error count: 7 + "PhanTypeInvalidLeftOperandOfIntegerOp", + // approximate error count: 2 + "PhanTypeInvalidRightOperand", + // approximate error count: 2 + "PhanTypeInvalidRightOperandOfIntegerOp", + // approximate error count: 1 + "PhanTypeMagicVoidWithReturn", + // approximate error count: 152 + "PhanTypeMismatchArgument", + // approximate error count: 28 + "PhanTypeMismatchArgumentInternal", + // approximate error count: 1 + "PhanTypeMismatchBitwiseBinaryOperands", + // approximate error count: 1 + "PhanTypeMismatchDeclaredParam", + // approximate error count: 2 + "PhanTypeMismatchDimEmpty", + // approximate error count: 29 + "PhanTypeMismatchDimFetch", + // approximate error count: 10 + "PhanTypeMismatchForeach", + // approximate error count: 77 + "PhanTypeMismatchProperty", + // approximate error count: 88 + "PhanTypeMismatchReturn", + // approximate error count: 43 + "PhanTypeMissingReturn", + // approximate error count: 1 + "PhanTypeNoAccessiblePropertiesForeach", + // approximate error count: 4 + "PhanTypeNonVarPassByRef", + // approximate error count: 12 + "PhanTypeObjectUnsetDeclaredProperty", + // approximate error count: 9 + "PhanTypeSuspiciousNonTraversableForeach", + // approximate error count: 3 + "PhanTypeSuspiciousStringExpression", + // approximate error count: 22 + "PhanUndeclaredConstant", + // approximate error count: 3 + "PhanUndeclaredInvokeInCallable", + // approximate error count: 242 + "PhanUndeclaredMethod", + // approximate error count: 847 + "PhanUndeclaredProperty", + // approximate error count: 1 + "PhanUndeclaredTypeReturnType", + // approximate error count: 3 + "PhanUndeclaredTypeThrowsType", + // approximate error count: 2 + "PhanUndeclaredVariableAssignOp", + // approximate error count: 55 + "PhanUndeclaredVariableDim", + // approximate error count: 4 + "PhanUnextractableAnnotationElementName", + // approximate error count: 4 + "PhanUnextractableAnnotationSuffix", +] ); + +$cfg['ignore_undeclared_variables_in_global_scope'] = true; +$cfg['globals_type_map']['IP'] = 'string'; + +return $cfg; diff --git a/.phan/internal_stubs/memcached.phan_php b/.phan/internal_stubs/memcached.phan_php new file mode 100644 index 0000000000..8a85bafe39 --- /dev/null +++ b/.phan/internal_stubs/memcached.phan_php @@ -0,0 +1,180 @@ +readFromQueue( $queue ); $wgAutoloadClasses += $data['autoload']; - /** @suppress PhanUndeclaredVariable $wgHooks is set by DefaultSettings */ + // @phan-suppress-next-line PhanUndeclaredVariable $wgHooks is set by DefaultSettings $hooksWeWant = $wgHooks['LoadExtensionSchemaUpdates'] ?? []; if ( isset( $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'] ) ) { diff --git a/includes/libs/filebackend/FileBackendMultiWrite.php b/includes/libs/filebackend/FileBackendMultiWrite.php index 655a71048c..9524155d6b 100644 --- a/includes/libs/filebackend/FileBackendMultiWrite.php +++ b/includes/libs/filebackend/FileBackendMultiWrite.php @@ -87,9 +87,6 @@ class FileBackendMultiWrite extends FileBackend { * This will apply such updates post-send for web requests. Note that * any checks from "syncChecks" are still synchronous. * - * Bogus warning - * @suppress PhanAccessMethodProtected - * * @param array $config * @throws FileBackendError */ diff --git a/tests/phan/config.php b/tests/phan/config.php deleted file mode 100644 index a4654c3227..0000000000 --- a/tests/phan/config.php +++ /dev/null @@ -1,122 +0,0 @@ -