= 80000 ) { // Exclude PHP 8.0 polyfills if PHP 8.0+ is running $cfg['exclude_file_list'] = array_merge( $cfg['exclude_file_list'], [ 'vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php', 'vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php', 'vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php', 'vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php', 'vendor/symfony/polyfill-php80/Resources/stubs/ValueError.php', ] ); } $cfg['autoload_internal_extension_signatures'] = [ 'excimer' => '.phan/internal_stubs/excimer.php', 'imagick' => '.phan/internal_stubs/imagick.phan_php', 'memcached' => '.phan/internal_stubs/memcached.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', 'tideways_xhprof' => '.phan/internal_stubs/tideways_xhprof.phan_php', 'wikidiff2' => '.phan/internal_stubs/wikidiff.php' ]; $cfg['directory_list'] = [ 'includes/', 'languages/', 'maintenance/', 'mw-config/', 'resources/', 'tests/common/', 'tests/parser/', 'tests/phpunit/mocks/', // Do NOT add .phan/stubs/ here: stubs are conditionally loaded in file_list ]; // Include only direct production dependencies in vendor/ // Omit dev dependencies and most indirect dependencies $composerJson = json_decode( file_get_contents( __DIR__ . '/../composer.json' ), true ); $directDeps = []; foreach ( $composerJson['require'] as $dep => $version ) { $parts = explode( '/', $dep ); if ( count( $parts ) === 2 ) { $directDeps[] = $dep; } } // This is a list of all composer packages that are referenced by core but // are not listed as requirements in composer.json. $indirectDeps = [ 'composer/spdx-licenses', 'doctrine/dbal', 'doctrine/sql-formatter', 'guzzlehttp/psr7', 'pear/net_url2', 'pear/pear-core-minimal', 'phpunit/phpunit', 'psr/http-message', 'seld/jsonlint', 'wikimedia/testing-access-wrapper', 'wikimedia/zest-css', ]; foreach ( [ ...$directDeps, ...$indirectDeps ] as $dep ) { $cfg['directory_list'][] = "vendor/$dep"; } $cfg['exclude_analysis_directory_list'] = [ 'vendor/', '.phan/', 'tests/phpunit/', // Generated documentation stub for configuration variables. 'includes/config-vars.php', // 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', // External class 'includes/libs/objectcache/utils/MemcachedClient.php', // File may be valid, but may contain numerous "errors" such as iterating over an // empty array due to the version checking in T246594 not being currently used. 'includes/PHPVersionCheck.php', ]; // Do not use aliases in core. // Use the correct name, because we don't need backward compatibility $cfg['enable_class_alias_support'] = false; $cfg['ignore_undeclared_variables_in_global_scope'] = true; // @todo It'd be great if we could just make phan read these from config-schema.php, to avoid // duplicating the types. config-schema.php has JSON types though, not PHP types. // @todo As we are removing access to global variables from the code base, // remove them from here as well, so phan complains when something tries to use them. $cfg['globals_type_map'] = array_merge( $cfg['globals_type_map'], [ 'IP' => 'string', 'wgTitle' => 'MediaWiki\Title\Title', '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', 'wgLocalInterwikis' => 'string[]', 'wgDebugLogGroups' => 'string|false|array{destination:string,sample?:int,level:int}', 'wgCookiePrefix' => 'string|false', 'wgOut' => 'OutputPage', 'wgExtraNamespaces' => 'string[]', ] ); // Include a local config file if it exists if ( file_exists( __DIR__ . '/local-config.php' ) ) { require __DIR__ . '/local-config.php'; } return $cfg;