Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 76
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2/**
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.
7 *
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.
12 *
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
17 *
18 * @file
19 */
20
21use MediaWikiPhanConfig\MediaWikiConfigBuilder;
22
23require_once __DIR__ . '/base-config-functions.php';
24
25// Replace \\ by / for windows users to let exclude work correctly
26$DIR = str_replace( '\\', '/', __DIR__ );
27
28// TODO: Use \Phan\Config::projectPath()
29$IP = getenv( 'MW_INSTALL_PATH' ) !== false
30    // Replace \\ by / for windows users to let exclude work correctly
31    ? str_replace( '\\', '/', getenv( 'MW_INSTALL_PATH' ) )
32    : '../..';
33
34$VP = getenv( 'MW_VENDOR_PATH' ) !== false
35    // Replace \\ by / for windows users to let exclude work correctly
36    ? str_replace( '\\', '/', getenv( 'MW_VENDOR_PATH' ) )
37    : $IP;
38
39$baseCfg = new MediaWikiConfigBuilder( $IP );
40setBaseOptions( $DIR, $baseCfg );
41
42$baseCfg
43    ->setDirectoryList( filterDirs( [
44        'includes/',
45        'src/',
46        'maintenance/',
47        '.phan/stubs/',
48        $IP . '/includes',
49        $IP . '/languages',
50        $IP . '/maintenance',
51        $IP . '/.phan/stubs/',
52        $VP . '/vendor',
53    ] ) )
54    ->setExcludedDirectoryList( [
55        '.phan/stubs/',
56        $IP . '/includes',
57        $IP . '/languages',
58        $IP . '/maintenance',
59        $IP . '/.phan/stubs/',
60        $VP . '/vendor',
61
62    ] )
63    ->setSuppressedIssuesList( [
64        // Deprecation warnings
65        'PhanDeprecatedFunction',
66        'PhanDeprecatedClass',
67        'PhanDeprecatedClassConstant',
68        'PhanDeprecatedFunctionInternal',
69        'PhanDeprecatedInterface',
70        'PhanDeprecatedProperty',
71        'PhanDeprecatedTrait',
72
73        // Covered by codesniffer
74        'PhanUnreferencedUseNormal',
75        'PhanUnreferencedUseFunction',
76        'PhanUnreferencedUseConstant',
77        'PhanDuplicateUseNormal',
78        'PhanDuplicateUseFunction',
79        'PhanDuplicateUseConstant',
80        'PhanUseNormalNoEffect',
81        'PhanUseNormalNamespacedNoEffect',
82        'PhanUseFunctionNoEffect',
83        'PhanUseConstantNoEffect',
84        'PhanDeprecatedCaseInsensitiveDefine',
85
86        // https://github.com/phan/phan/issues/3420
87        'PhanAccessClassConstantInternal',
88        'PhanAccessClassInternal',
89        'PhanAccessConstantInternal',
90        'PhanAccessMethodInternal',
91        'PhanAccessPropertyInternal',
92
93        // These are quite PHP8-specific
94        'PhanParamNameIndicatingUnused',
95        'PhanParamNameIndicatingUnusedInClosure',
96        'PhanProvidingUnusedParameter',
97
98        // Would probably have many false positives
99        'PhanPluginMixedKeyNoKey',
100    ] )
101    ->addGlobalsWithTypes( [
102        'wgContLang' => '\\Language',
103        'wgParser' => '\\Parser',
104        'wgTitle' => '\\MediaWiki\\Title\\Title',
105        'wgMemc' => '\\BagOStuff',
106        'wgUser' => '\\User',
107        'wgConf' => file_exists( "$IP/includes/config/SiteConfiguration.php" )
108            ? '\\MediaWiki\\Config\\SiteConfiguration' : '\\SiteConfiguration',
109        'wgLang' => '\\Language',
110        'wgOut' => '\\MediaWiki\\Output\\OutputPage',
111        'wgRequest' => file_exists( "$IP/includes/Request/WebRequest.php" )
112            ? '\\MediaWiki\\Request\\WebRequest' : '\\WebRequest',
113    ] )
114    ->enableTaintCheck( $DIR, $VP );
115
116// BC: We're not ready to use the ConfigBuilder everywhere
117return $baseCfg->make();