3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
21 $cfg = require __DIR__
. '/../vendor/mediawiki/mediawiki-phan-config/src/config.php';
23 $cfg['file_list'] = array_merge(
25 function_exists( 'register_postsend_function' ) ?
[] : [ '.phan/stubs/hhvm.php' ],
26 function_exists( 'wikidiff2_do_diff' ) ?
[] : [ '.phan/stubs/wikidiff.php' ],
27 class_exists( PEAR
::class ) ?
[] : [ '.phan/stubs/mail.php' ],
28 defined( 'PASSWORD_ARGON2I' ) ?
[] : [ '.phan/stubs/password.php' ],
29 // Per composer.json, PHPUnit 6 is used for PHP 7.0+, PHPUnit 4 otherwise.
30 // Load the interface for the version of PHPUnit that isn't installed.
31 // Phan only supports PHP 7.0+ (and not HHVM), so we only need to stub PHPUnit 4.
32 class_exists( PHPUnit_TextUI_Command
::class ) ?
[] : [ '.phan/stubs/phpunit4.php' ],
33 class_exists( ProfilerExcimer
::class ) ?
[] : [ '.phan/stubs/excimer.php' ],
35 // This makes constants and globals known to Phan before processing all other files.
36 // You can check the parser order with --dump-parsed-file-list
37 'includes/Defines.php',
38 // @todo This isn't working yet, see globals_type_map below
39 // 'includes/DefaultSettings.php',
40 // 'includes/Setup.php',
44 $cfg['exclude_file_list'] = array_merge(
45 $cfg['exclude_file_list'],
47 // This file has invalid PHP syntax
48 'vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.inc',
52 $cfg['analyzed_file_extensions'] = array_merge(
53 $cfg['analyzed_file_extensions'] ??
[ 'php' ],
57 $cfg['autoload_internal_extension_signatures'] = [
58 'dom' => '.phan/internal_stubs/dom.phan_php',
59 'imagick' => '.phan/internal_stubs/imagick.phan_php',
60 'intl' => '.phan/internal_stubs/intl.phan_php',
61 'memcached' => '.phan/internal_stubs/memcached.phan_php',
62 'oci8' => '.phan/internal_stubs/oci8.phan_php',
63 'pcntl' => '.phan/internal_stubs/pcntl.phan_php',
64 'pgsql' => '.phan/internal_stubs/pgsql.phan_php',
65 'redis' => '.phan/internal_stubs/redis.phan_php',
66 'sockets' => '.phan/internal_stubs/sockets.phan_php',
67 'sqlsrv' => '.phan/internal_stubs/sqlsrv.phan_php',
68 'tideways' => '.phan/internal_stubs/tideways.phan_php',
71 $cfg['directory_list'] = [
81 $cfg['exclude_analysis_directory_list'] = [
84 // The referenced classes are not available in vendor, only when
85 // included from composer.
87 // Directly references classes that only exist in Translate extension
88 'maintenance/language/',
90 'includes/libs/jsminplus.php',
92 'includes/libs/objectcache/utils/MemcachedClient.php',
95 // NOTE: If you're facing an issue which you cannot easily fix, DO NOT add it here. Suppress it
96 // either in-line with @phan-suppress-next-line and similar, at block-level (via @suppress), or at
97 // file-level (with @phan-file-suppress), so that it stays enabled for the rest of the codebase.
98 $cfg['suppress_issue_types'] = array_merge( $cfg['suppress_issue_types'], [
99 // approximate error count: 19
100 "PhanParamReqAfterOpt", // False positives with nullables (phan issue #3159). Use real nullables
101 //after dropping HHVM
102 // approximate error count: 110
103 "PhanParamTooMany", // False positives with variargs. Unsuppress after dropping HHVM
105 // approximate error count: 45
106 "PhanTypeMismatchArgument",
109 // This helps a lot in discovering bad code, but unfortunately it will always fail for
110 // hooks + pass by reference, see phan issue #2943.
111 // @todo Enable when the issue above is resolved and we update our config!
112 $cfg['redundant_condition_detection'] = false;
114 // Do not use aliases in core.
115 // Use the correct name, because we don't need backward compatibility
116 $cfg['enable_class_alias_support'] = false;
118 $cfg['ignore_undeclared_variables_in_global_scope'] = true;
119 // @todo It'd be great if we could just make phan read these from DefaultSettings, to avoid
120 // duplicating the types.
121 $cfg['globals_type_map'] = array_merge( $cfg['globals_type_map'], [
123 'wgGalleryOptions' => 'array',
124 'wgDummyLanguageCodes' => 'string[]',
125 'wgNamespaceProtection' => 'array<string,string|string[]>',
126 'wgNamespaceAliases' => 'array<string,int>',
127 'wgLockManagers' => 'array[]',
128 'wgForeignFileRepos' => 'array[]',
129 'wgDefaultUserOptions' => 'array',
130 'wgSkipSkins' => 'string[]',
131 'wgLogTypes' => 'string[]',
132 'wgLogNames' => 'array<string,string>',
133 'wgLogHeaders' => 'array<string,string>',
134 'wgLogActionsHandlers' => 'array<string,class-string>',
135 'wgPasswordPolicy' => 'array<string,array<string,string|array>>',
136 'wgVirtualRestConfig' => 'array<string,array>',
137 'wgWANObjectCaches' => 'array[]',
138 'wgLocalInterwikis' => 'string[]',
139 'wgDebugLogGroups' => 'string|false|array{destination:string,sample?:int,level:int}',
140 'wgCookiePrefix' => 'string|false',
141 'wgOut' => 'OutputPage',
142 'wgExtraNamespaces' => 'string[]',