Page MenuHomePhabricator

Docker: phan does not work
Open, Needs TriagePublicBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):

  • Install Mediawiki in Docker, following DEVELOPERS.md
  • Bring up with docker-compose
  • Run docker exec mediawiki "vendor/bin/phan -d . --long-progress-bar --allow-polyfill-parser"

(Note: composer phan cannot be used, as php-ast isn't installed)

(Note 2: composer test works to run parallel-lint and phpcs)

What happens?:

Phan fails with

includes/Rest/Handler/CompareHandler.php:162 PhanParamTooManyInternal Call with 3 arg(s) to \wikidiff2_inline_json_diff() which only takes 0 arg(s). This is an ArgumentCountError for internal functions in PHP 8.0+.
includes/Setup.php:188 PhanSuspiciousValueComparisonInGlobalScope Suspicious attempt to compare $wgArticlePath of type '/wiki/$1' to false of type false with operator '===' in the global scope (likely a false positive)
includes/diff/TextSlotDiffRenderer.php:209 PhanParamTooManyInternal Call with 4 arg(s) to \wikidiff2_do_diff() which only takes 0 arg(s). This is an ArgumentCountError for internal functions in PHP 8.0+.
includes/diff/TextSlotDiffRenderer.php:217 PhanParamTooManyInternal Call with 3 arg(s) to \wikidiff2_do_diff() which only takes 0 arg(s). This is an ArgumentCountError for internal functions in PHP 8.0+.
includes/diff/TextSlotDiffRenderer.php:277 PhanParamTooManyInternal Call with 3 arg(s) to \wikidiff2_inline_diff() which only takes 0 arg(s). This is an ArgumentCountError for internal functions in PHP 8.0+.
includes/language/LanguageConverter.php:851 PhanPluginInvalidPregRegex Call to \preg_match was passed an invalid regex '/<script.*?>.*?<\\/script>(*SKIP)(*FAIL)|<style.*?>.*?<\\/style>(*SKIP)(*FAIL)|<(?:[^>=]*+(?>[^>=]*+=\\s*+(?:"[^"]*"|\'[^\']*\'|[^\'">\\s]*+))*+[^>=]*+>|.*+)(*SKIP)(*FAIL)|-\\{': No ending delimiter '/' found
includes/libs/objectcache/wancache/WANObjectCache.php:1741 PhanUselessBinaryAddRight Addition of array{since:float,version:?mixed,staleTTL:0|mixed,lockTSE:-1|mixed,creating:bool,walltime:mixed} + array{} (['since'=>($setOpts['since'] ?? $preCallbackTime),'version'=>$version,'staleTTL'=>$staleTTL,'lockTSE'=>$lockTSE,'creating'=>($curValue === false),'walltime'=>$walltime] + $setOpts) is probably unnecessary. Array fields from the left hand side will be used instead of each of the fields from the right hand side
includes/libs/objectcache/wancache/WANObjectCache.php:1742 UnusedPluginSuppression Plugin BuiltinSuppressionPlugin suppresses issue PhanUselessBinaryAddRight on this line but this suppression is unused or suppressed elsewhere
languages/Language.php:2782 PhanPluginInvalidPregRegex Call to \preg_replace_callback was passed an invalid regex '/^([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)|[ \\-\\(\\)\\}\\{\\.,\\?!]([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)': No ending delimiter '/' found
[debug] Restarted process exited 1

Alternatively, running phan for an extension with cd extension/ProofreadPage && vendor/bin/phan -d . --allow-polyfill-parser --long-progress-bar results in thousands of errors like:

includes/Api/ApiQueryProofread.php:11 PhanUndeclaredExtendedClass Class extends undeclared class \ApiQueryBase
includes/Api/ApiQueryProofread.php:20 PhanUndeclaredMethod Call to undeclared method \ProofreadPage\Api\ApiQueryProofread::getPageSet
includes/Api/ApiQueryProofread.php:21 PhanUndeclaredMethod Call to undeclared method \ProofreadPage\Api\ApiQueryProofread::getResult
includes/Api/ApiQueryProofread.php:50 PhanUndeclaredMethod Call to undeclared method \ProofreadPage\Api\ApiQueryProofread::msg
includes/Api/ApiQueryProofreadInfo.php:14 PhanUndeclaredExtendedClass Class extends undeclared class \ApiQueryBase
includes/Api/ApiQueryProofreadInfo.php:20 PhanUndeclaredTypeParameter Parameter $query has undeclared type \ApiQuery
includes/Api/ApiQueryProofreadInfo.php:21 PhanUndeclaredClass Reference to undeclared class \ApiQueryBase

What should have happened instead?:

Phan should run and complete without errors. Not being able to do this makes it extremely frusdtrating to try to submit patches and creates very noisy Gerrit reviews.

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc: current master branch