X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=.phan%2Fconfig.php;h=fc775fe5fe5ba3998b0bebca165dd9823909eb51;hb=4f14ae08eafe5067b7bed2e6de2addad56f132a7;hp=29729ae1c70a5f9c03700c8fdf27229e2e5eb0c8;hpb=6bd6b9cb4958936d1b6e3e2a30cf64973aade72d;p=lhc%2Fweb%2Fwiklou.git diff --git a/.phan/config.php b/.phan/config.php index 29729ae1c7..fc775fe5fe 100644 --- a/.phan/config.php +++ b/.phan/config.php @@ -32,21 +32,36 @@ $cfg['file_list'] = array_merge( class_exists( PHPUnit_TextUI_Command::class ) ? [] : [ '.phan/stubs/phpunit4.php' ], class_exists( ProfilerExcimer::class ) ? [] : [ '.phan/stubs/excimer.php' ], [ - 'maintenance/cleanupTable.inc', - 'maintenance/CodeCleanerGlobalsPass.inc', - 'maintenance/commandLine.inc', - 'maintenance/sqlite.inc', - 'maintenance/userDupes.inc', - 'maintenance/language/checkLanguage.inc', - 'maintenance/language/languages.inc', + // This makes constants and globals known to Phan before processing all other files. + // You can check the parser order with --dump-parsed-file-list + 'includes/Defines.php', + // @todo This isn't working yet, see globals_type_map below + // 'includes/DefaultSettings.php', + // 'includes/Setup.php', ] ); +$cfg['exclude_file_list'] = array_merge( + $cfg['exclude_file_list'], + [ + // This file has invalid PHP syntax + 'vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.inc', + ] +); + +$cfg['analyzed_file_extensions'] = array_merge( + $cfg['analyzed_file_extensions'] ?? [ 'php' ], + [ 'inc' ] +); + $cfg['autoload_internal_extension_signatures'] = [ + 'dom' => '.phan/internal_stubs/dom.phan_php', 'imagick' => '.phan/internal_stubs/imagick.phan_php', + 'intl' => '.phan/internal_stubs/intl.phan_php', 'memcached' => '.phan/internal_stubs/memcached.phan_php', 'oci8' => '.phan/internal_stubs/oci8.phan_php', 'pcntl' => '.phan/internal_stubs/pcntl.phan_php', + 'pgsql' => '.phan/internal_stubs/pgsql.phan_php', 'redis' => '.phan/internal_stubs/redis.phan_php', 'sockets' => '.phan/internal_stubs/sockets.phan_php', 'sqlsrv' => '.phan/internal_stubs/sqlsrv.phan_php', @@ -65,7 +80,7 @@ $cfg['directory_list'] = [ $cfg['exclude_analysis_directory_list'] = [ 'vendor/', - '.phan/stubs/', + '.phan/', // The referenced classes are not available in vendor, only when // included from composer. 'includes/composer/', @@ -73,36 +88,56 @@ $cfg['exclude_analysis_directory_list'] = [ 'maintenance/language/', // External class 'includes/libs/jsminplus.php', + // External class + 'includes/libs/objectcache/utils/MemcachedClient.php', ]; +// NOTE: If you're facing an issue which you cannot easily fix, DO NOT add it here. Suppress it +// either in-line with @phan-suppress-next-line and similar, at block-level (via @suppress), or at +// file-level (with @phan-file-suppress), so that it stays enabled for the rest of the codebase. $cfg['suppress_issue_types'] = array_merge( $cfg['suppress_issue_types'], [ - // approximate error count: 22 - "PhanAccessMethodInternal", // approximate error count: 19 - "PhanParamReqAfterOpt", + "PhanParamReqAfterOpt", // False positives with nullables (phan issue #3159). Use real nullables + //after dropping HHVM // approximate error count: 110 - "PhanParamTooMany", - // approximate error count: 63 - "PhanTypeArraySuspicious", - // approximate error count: 88 - "PhanTypeInvalidDimOffset", - // approximate error count: 60 + "PhanParamTooMany", // False positives with variargs. Unsuppress after dropping HHVM + + // approximate error count: 45 "PhanTypeMismatchArgument", - // approximate error count: 36 - "PhanUndeclaredConstant", - // approximate error count: 219 - "PhanUndeclaredMethod", - // approximate error count: 752 + // approximate error count: 693 "PhanUndeclaredProperty", - // approximate error count: 53 - "PhanUndeclaredVariableDim", ] ); +// This helps a lot in discovering bad code, but unfortunately it will always fail for +// hooks + pass by reference, see phan issue #2943. +// @todo Enable when the issue above is resolved and we update our config! +$cfg['redundant_condition_detection'] = false; + $cfg['ignore_undeclared_variables_in_global_scope'] = true; +// @todo It'd be great if we could just make phan read these from DefaultSettings, to avoid +// duplicating the types. $cfg['globals_type_map'] = array_merge( $cfg['globals_type_map'], [ 'IP' => 'string', 'wgGalleryOptions' => 'array', 'wgDummyLanguageCodes' => 'string[]', + 'wgNamespaceProtection' => 'array', + 'wgNamespaceAliases' => 'array', + 'wgLockManagers' => 'array[]', + 'wgForeignFileRepos' => 'array[]', + 'wgDefaultUserOptions' => 'array', + 'wgSkipSkins' => 'string[]', + 'wgLogTypes' => 'string[]', + 'wgLogNames' => 'array', + 'wgLogHeaders' => 'array', + 'wgLogActionsHandlers' => 'array', + 'wgPasswordPolicy' => 'array>', + 'wgVirtualRestConfig' => 'array', + 'wgWANObjectCaches' => 'array[]', + 'wgLocalInterwikis' => 'string[]', + 'wgDebugLogGroups' => 'string|false|array{destination:string,sample?:int,level:int}', + 'wgCookiePrefix' => 'string|false', + 'wgOut' => 'OutputPage', + 'wgExtraNamespaces' => 'string[]', ] ); return $cfg;