Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 66
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2declare( strict_types = 1 );
3
4/**
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 */
22
23use MediaWikiPhanConfig\MediaWikiConfigBuilder;
24
25require_once __DIR__ . '/base-config-functions.php';
26
27// TODO: Use \Phan\Config::projectPath()
28$IP = getenv( 'MW_INSTALL_PATH' ) !== false
29    ? getenv( 'MW_INSTALL_PATH' )
30    : '../..';
31
32$VP = getenv( 'MW_VENDOR_PATH' ) !== false
33    ? getenv( 'MW_VENDOR_PATH' )
34    : $IP;
35
36$baseCfg = new MediaWikiConfigBuilder( $IP );
37setBaseOptions( $baseCfg );
38
39$baseCfg
40    ->setDirectoryList( [
41        'includes/',
42        'src/',
43        'maintenance/',
44        '.phan/stubs/',
45        $IP . '/includes',
46        $IP . '/languages',
47        $IP . '/maintenance',
48        $IP . '/.phan/stubs/',
49        $VP . '/vendor',
50    ], MediaWikiConfigBuilder::SET_WITH_DIR_FILTER )
51    ->setExcludedDirectoryList( [
52        '.phan/stubs/',
53        $IP . '/includes',
54        $IP . '/languages',
55        $IP . '/maintenance',
56        $IP . '/.phan/stubs/',
57        $VP . '/vendor',
58    ] )
59    // We need to set this here, or phan will assume this to be the same as the
60    // target PHP version in projects where composer.json does not specify
61    // a minimum version.
62    ->setMinimumPHPVersion( '8.3' )
63    ->suppressIssueTypes(
64        // Deprecation warnings
65        'PhanDeprecatedFunction',
66        'PhanDeprecatedClass',
67        'PhanDeprecatedClassConstant',
68        'PhanDeprecatedFunctionInternal',
69        'PhanDeprecatedInterface',
70        'PhanDeprecatedProperty',
71        'PhanDeprecatedTrait',
72
73        // https://github.com/phan/phan/issues/3420
74        'PhanAccessClassConstantInternal',
75        'PhanAccessClassInternal',
76        'PhanAccessConstantInternal',
77        'PhanAccessMethodInternal',
78        'PhanAccessPropertyInternal',
79    )
80    ->addGlobalsWithTypes( [
81        'wgContLang' => '\\MediaWiki\\Language\\Language',
82        'wgParser' => '\\MediaWiki\\Parser\\Parser',
83        'wgTitle' => '\\MediaWiki\\Title\\Title',
84        'wgMemc' => '\\Wikimedia\\ObjectCache\\BagOStuff',
85        'wgUser' => '\\MediaWiki\\User\\User',
86        'wgConf' => '\\MediaWiki\\Config\\SiteConfiguration',
87        'wgLang' => '\\MediaWiki\\Language\\Language',
88        'wgOut' => '\\MediaWiki\\Output\\OutputPage',
89        'wgRequest' => '\\MediaWiki\\Request\\WebRequest',
90    ] )
91    ->addExceptionClassesWithOptionalThrowsPHPDoc( [
92        'ErrorPageError',
93        '\\MediaWiki\\Rest\\HttpException',
94        '\\MediaWiki\\Maintenance\\MaintenanceFatalError',
95        // TODO: Remove when the class is dropped (T86704)
96        'MWException',
97    ] )
98    ->enableTaintCheck( $VP );
99
100// BC: We're not ready to use the ConfigBuilder everywhere
101return $baseCfg->make();