Simplify Block::getBy and Block::getByName
[lhc/web/wiklou.git] / tests / phan / config.php
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
21 $cfg = require __DIR__ . '/../../vendor/mediawiki/mediawiki-phan-config/src/config.php';
22
23 $cfg['file_list'] = array_merge(
24 $cfg['file_list'],
25 function_exists( 'register_postsend_function' ) ? [] : [ 'tests/phan/stubs/hhvm.php' ],
26 function_exists( 'wikidiff2_do_diff' ) ? [] : [ 'tests/phan/stubs/wikidiff.php' ],
27 function_exists( 'tideways_enable' ) ? [] : [ 'tests/phan/stubs/tideways.php' ],
28 class_exists( PEAR::class ) ? [] : [ 'tests/phan/stubs/mail.php' ],
29 class_exists( Memcached::class ) ? [] : [ 'tests/phan/stubs/memcached.php' ],
30 // Per composer.json, PHPUnit 6 is used for PHP 7.0+, PHPUnit 4 otherwise.
31 // Load the interface for the version of PHPUnit that isn't installed.
32 // Phan only supports PHP 7.0+ (and not HHVM), so we only need to stub PHPUnit 4.
33 class_exists( PHPUnit_TextUI_Command::class ) ? [] : [ 'tests/phan/stubs/phpunit4.php' ],
34 class_exists( ProfilerExcimer::class ) ? [] : [ 'tests/phan/stubs/excimer.php' ],
35 [
36 'maintenance/7zip.inc',
37 'maintenance/cleanupTable.inc',
38 'maintenance/CodeCleanerGlobalsPass.inc',
39 'maintenance/commandLine.inc',
40 'maintenance/sqlite.inc',
41 'maintenance/userDupes.inc',
42 'maintenance/language/checkLanguage.inc',
43 'maintenance/language/languages.inc',
44 ]
45 );
46
47 $cfg['directory_list'] = [
48 'includes/',
49 'languages/',
50 'maintenance/',
51 'mw-config/',
52 'resources/',
53 'vendor/',
54 ];
55
56 $cfg['exclude_analysis_directory_list'] = [
57 'vendor/',
58 'tests/phan/stubs/',
59 // The referenced classes are not available in vendor, only when
60 // included from composer.
61 'includes/composer/',
62 // Directly references classes that only exist in Translate extension
63 'maintenance/language/',
64 // External class
65 'includes/libs/jsminplus.php',
66 ];
67
68 $cfg['suppress_issue_types'] = array_merge( $cfg['suppress_issue_types'], [
69 // approximate error count: 29
70 "PhanCommentParamOnEmptyParamList",
71 // approximate error count: 33
72 "PhanCommentParamWithoutRealParam",
73 // approximate error count: 17
74 "PhanNonClassMethodCall",
75 // approximate error count: 888
76 "PhanParamSignatureMismatch",
77 // approximate error count: 7
78 "PhanParamSignatureMismatchInternal",
79 // approximate error count: 1
80 "PhanParamSignatureRealMismatchTooFewParameters",
81 // approximate error count: 125
82 "PhanParamTooMany",
83 // approximate error count: 3
84 "PhanParamTooManyInternal",
85 // approximate error count: 2
86 "PhanTraitParentReference",
87 // approximate error count: 3
88 "PhanTypeComparisonFromArray",
89 // approximate error count: 2
90 "PhanTypeComparisonToArray",
91 // approximate error count: 218
92 "PhanTypeMismatchArgument",
93 // approximate error count: 13
94 "PhanTypeMismatchArgumentInternal",
95 // approximate error count: 5
96 "PhanTypeMismatchDimAssignment",
97 // approximate error count: 2
98 "PhanTypeMismatchDimEmpty",
99 // approximate error count: 1
100 "PhanTypeMismatchDimFetch",
101 // approximate error count: 14
102 "PhanTypeMismatchForeach",
103 // approximate error count: 56
104 "PhanTypeMismatchProperty",
105 // approximate error count: 74
106 "PhanTypeMismatchReturn",
107 // approximate error count: 5
108 "PhanTypeNonVarPassByRef",
109 // approximate error count: 32
110 "PhanUndeclaredConstant",
111 // approximate error count: 233
112 "PhanUndeclaredMethod",
113 // approximate error count: 1224
114 "PhanUndeclaredProperty",
115 // approximate error count: 58
116 "PhanUndeclaredVariableDim",
117 ] );
118
119 $cfg['ignore_undeclared_variables_in_global_scope'] = true;
120 $cfg['globals_type_map']['IP'] = 'string';
121
122 return $cfg;