Merge "RCFilters: Change tooltip messages for view buttons"
[lhc/web/wiklou.git] / tests / phan / config.php
1 <?php
2
3 use \Phan\Config;
4
5 // If xdebug is enabled, we need to increase the nesting level for phan
6 ini_set( 'xdebug.max_nesting_level', 1000 );
7
8 /**
9 * This configuration will be read and overlayed on top of the
10 * default configuration. Command line arguments will be applied
11 * after this file is read.
12 *
13 * @see src/Phan/Config.php
14 * See Config for all configurable options.
15 *
16 * A Note About Paths
17 * ==================
18 *
19 * Files referenced from this file should be defined as
20 *
21 * ```
22 * Config::projectPath('relative_path/to/file')
23 * ```
24 *
25 * where the relative path is relative to the root of the
26 * project which is defined as either the working directory
27 * of the phan executable or a path passed in via the CLI
28 * '-d' flag.
29 */
30 return [
31 /**
32 * A list of individual files to include in analysis
33 * with a path relative to the root directory of the
34 * project. directory_list won't find .inc files so
35 * we augment it here.
36 */
37 'file_list' => array_merge(
38 function_exists( 'register_postsend_function' ) ? [] : [ 'tests/phan/stubs/hhvm.php' ],
39 function_exists( 'wikidiff2_do_diff' ) ? [] : [ 'tests/phan/stubs/wikidiff.php' ],
40 function_exists( 'tideways_enable' ) ? [] : [ 'tests/phan/stubs/tideways.php' ],
41 class_exists( PEAR::class ) ? [] : [ 'tests/phan/stubs/mail.php' ],
42 class_exists( Memcached::class ) ? [] : [ 'tests/phan/stubs/memcached.php' ],
43 [
44 'maintenance/7zip.inc',
45 'maintenance/backup.inc',
46 'maintenance/backupPrefetch.inc',
47 'maintenance/cleanupTable.inc',
48 'maintenance/CodeCleanerGlobalsPass.inc',
49 'maintenance/commandLine.inc',
50 'maintenance/importImages.inc',
51 'maintenance/sqlite.inc',
52 'maintenance/userDupes.inc',
53 'maintenance/userOptions.inc',
54 'maintenance/language/checkLanguage.inc',
55 'maintenance/language/languages.inc',
56 ]
57 ),
58
59 /**
60 * A list of directories that should be parsed for class and
61 * method information. After excluding the directories
62 * defined in exclude_analysis_directory_list, the remaining
63 * files will be statically analyzed for errors.
64 *
65 * Thus, both first-party and third-party code being used by
66 * your application should be included in this list.
67 */
68 'directory_list' => [
69 'includes/',
70 'languages/',
71 'maintenance/',
72 'mw-config/',
73 'resources/',
74 'skins/',
75 'vendor/',
76 ],
77
78 /**
79 * A file list that defines files that will be excluded
80 * from parsing and analysis and will not be read at all.
81 *
82 * This is useful for excluding hopelessly unanalyzable
83 * files that can't be removed for whatever reason.
84 */
85 'exclude_file_list' => [],
86
87 /**
88 * A list of directories holding code that we want
89 * to parse, but not analyze. Also works for individual
90 * files.
91 */
92 "exclude_analysis_directory_list" => [
93 'vendor/',
94 'tests/phan/stubs/',
95 // The referenced classes are not available in vendor, only when
96 // included from composer.
97 'includes/composer/',
98 // Directly references classes that only exist in Translate extension
99 'maintenance/language/',
100 // External class
101 'includes/libs/jsminplus.php',
102 // separate repositories
103 'skins/',
104 ],
105
106 /**
107 * Backwards Compatibility Checking. This is slow
108 * and expensive, but you should consider running
109 * it before upgrading your version of PHP to a
110 * new version that has backward compatibility
111 * breaks.
112 */
113 'backward_compatibility_checks' => false,
114
115 /**
116 * A set of fully qualified class-names for which
117 * a call to parent::__construct() is required
118 */
119 'parent_constructor_required' => [
120 ],
121
122 /**
123 * Run a quick version of checks that takes less
124 * time at the cost of not running as thorough
125 * an analysis. You should consider setting this
126 * to true only when you wish you had more issues
127 * to fix in your code base.
128 *
129 * In quick-mode the scanner doesn't rescan a function
130 * or a method's code block every time a call is seen.
131 * This means that the problem here won't be detected:
132 *
133 * ```php
134 * <?php
135 * function test($arg):int {
136 * return $arg;
137 * }
138 * test("abc");
139 * ```
140 *
141 * This would normally generate:
142 *
143 * ```sh
144 * test.php:3 TypeError return string but `test()` is declared to return int
145 * ```
146 *
147 * The initial scan of the function's code block has no
148 * type information for `$arg`. It isn't until we see
149 * the call and rescan test()'s code block that we can
150 * detect that it is actually returning the passed in
151 * `string` instead of an `int` as declared.
152 */
153 'quick_mode' => false,
154
155 /**
156 * By default, Phan will not analyze all node types
157 * in order to save time. If this config is set to true,
158 * Phan will dig deeper into the AST tree and do an
159 * analysis on all nodes, possibly finding more issues.
160 *
161 * See \Phan\Analysis::shouldVisit for the set of skipped
162 * nodes.
163 */
164 'should_visit_all_nodes' => true,
165
166 /**
167 * If enabled, check all methods that override a
168 * parent method to make sure its signature is
169 * compatible with the parent's. This check
170 * can add quite a bit of time to the analysis.
171 */
172 'analyze_signature_compatibility' => true,
173
174 // Emit all issues. They are then suppressed via
175 // suppress_issue_types, rather than a minimum
176 // severity.
177 "minimum_severity" => 0,
178
179 /**
180 * If true, missing properties will be created when
181 * they are first seen. If false, we'll report an
182 * error message if there is an attempt to write
183 * to a class property that wasn't explicitly
184 * defined.
185 */
186 'allow_missing_properties' => false,
187
188 /**
189 * Allow null to be cast as any type and for any
190 * type to be cast to null. Setting this to false
191 * will cut down on false positives.
192 */
193 'null_casts_as_any_type' => true,
194
195 /**
196 * If enabled, scalars (int, float, bool, string, null)
197 * are treated as if they can cast to each other.
198 *
199 * MediaWiki is pretty lax and uses many scalar
200 * types interchangably.
201 */
202 'scalar_implicit_cast' => true,
203
204 /**
205 * If true, seemingly undeclared variables in the global
206 * scope will be ignored. This is useful for projects
207 * with complicated cross-file globals that you have no
208 * hope of fixing.
209 */
210 'ignore_undeclared_variables_in_global_scope' => true,
211
212 /**
213 * Set to true in order to attempt to detect dead
214 * (unreferenced) code. Keep in mind that the
215 * results will only be a guess given that classes,
216 * properties, constants and methods can be referenced
217 * as variables (like `$class->$property` or
218 * `$class->$method()`) in ways that we're unable
219 * to make sense of.
220 */
221 'dead_code_detection' => false,
222
223 /**
224 * If true, the dead code detection rig will
225 * prefer false negatives (not report dead code) to
226 * false positives (report dead code that is not
227 * actually dead) which is to say that the graph of
228 * references will create too many edges rather than
229 * too few edges when guesses have to be made about
230 * what references what.
231 */
232 'dead_code_detection_prefer_false_negative' => true,
233
234 /**
235 * If disabled, Phan will not read docblock type
236 * annotation comments (such as for @return, @param,
237 * @var, @suppress, @deprecated) and only rely on
238 * types expressed in code.
239 */
240 'read_type_annotations' => true,
241
242 /**
243 * If a file path is given, the code base will be
244 * read from and written to the given location in
245 * order to attempt to save some work from being
246 * done. Only changed files will get analyzed if
247 * the file is read
248 */
249 'stored_state_file_path' => null,
250
251 /**
252 * Set to true in order to ignore issue suppression.
253 * This is useful for testing the state of your code, but
254 * unlikely to be useful outside of that.
255 */
256 'disable_suppression' => false,
257
258 /**
259 * If set to true, we'll dump the AST instead of
260 * analyzing files
261 */
262 'dump_ast' => false,
263
264 /**
265 * If set to a string, we'll dump the fully qualified lowercase
266 * function and method signatures instead of analyzing files.
267 */
268 'dump_signatures_file' => null,
269
270 /**
271 * If true (and if stored_state_file_path is set) we'll
272 * look at the list of files passed in and expand the list
273 * to include files that depend on the given files
274 */
275 'expand_file_list' => false,
276
277 // Include a progress bar in the output
278 'progress_bar' => false,
279
280 /**
281 * The probability of actually emitting any progress
282 * bar update. Setting this to something very low
283 * is good for reducing network IO and filling up
284 * your terminal's buffer when running phan on a
285 * remote host.
286 */
287 'progress_bar_sample_rate' => 0.005,
288
289 /**
290 * The number of processes to fork off during the analysis
291 * phase.
292 */
293 'processes' => 1,
294
295 /**
296 * Add any issue types (such as 'PhanUndeclaredMethod')
297 * to this black-list to inhibit them from being reported.
298 */
299 'suppress_issue_types' => [
300 // approximate error count: 8
301 "PhanDeprecatedClass",
302 // approximate error count: 415
303 "PhanDeprecatedFunction",
304 // approximate error count: 25
305 "PhanDeprecatedProperty",
306 // approximate error count: 11
307 "PhanParamReqAfterOpt",
308 // approximate error count: 888
309 "PhanParamSignatureMismatch",
310 // approximate error count: 7
311 "PhanParamSignatureMismatchInternal",
312 // approximate error count: 125
313 "PhanParamTooMany",
314 // approximate error count: 3
315 "PhanParamTooManyInternal",
316 // approximate error count: 1
317 "PhanRedefineFunctionInternal",
318 // approximate error count: 2
319 "PhanTraitParentReference",
320 // approximate error count: 3
321 "PhanTypeComparisonFromArray",
322 // approximate error count: 3
323 "PhanTypeInvalidRightOperand",
324 // approximate error count: 218
325 "PhanTypeMismatchArgument",
326 // approximate error count: 13
327 "PhanTypeMismatchArgumentInternal",
328 // approximate error count: 14
329 "PhanTypeMismatchForeach",
330 // approximate error count: 56
331 "PhanTypeMismatchProperty",
332 // approximate error count: 74
333 "PhanTypeMismatchReturn",
334 // approximate error count: 11
335 "PhanTypeMissingReturn",
336 // approximate error count: 5
337 "PhanTypeNonVarPassByRef",
338 // approximate error count: 32
339 "PhanUndeclaredConstant",
340 // approximate error count: 233
341 "PhanUndeclaredMethod",
342 // approximate error count: 1224
343 "PhanUndeclaredProperty",
344 // approximate error count: 3
345 "PhanUndeclaredStaticMethod",
346 ],
347
348 /**
349 * If empty, no filter against issues types will be applied.
350 * If this white-list is non-empty, only issues within the list
351 * will be emitted by Phan.
352 */
353 'whitelist_issue_types' => [
354 // 'PhanAccessMethodPrivate',
355 // 'PhanAccessMethodProtected',
356 // 'PhanAccessNonStaticToStatic',
357 // 'PhanAccessPropertyPrivate',
358 // 'PhanAccessPropertyProtected',
359 // 'PhanAccessSignatureMismatch',
360 // 'PhanAccessSignatureMismatchInternal',
361 // 'PhanAccessStaticToNonStatic',
362 // 'PhanCompatibleExpressionPHP7',
363 // 'PhanCompatiblePHP7',
364 // 'PhanContextNotObject',
365 // 'PhanDeprecatedClass',
366 // 'PhanDeprecatedFunction',
367 // 'PhanDeprecatedProperty',
368 // 'PhanEmptyFile',
369 // 'PhanNonClassMethodCall',
370 // 'PhanNoopArray',
371 // 'PhanNoopClosure',
372 // 'PhanNoopConstant',
373 // 'PhanNoopProperty',
374 // 'PhanNoopVariable',
375 // 'PhanParamRedefined',
376 // 'PhanParamReqAfterOpt',
377 // 'PhanParamSignatureMismatch',
378 // 'PhanParamSignatureMismatchInternal',
379 // 'PhanParamSpecial1',
380 // 'PhanParamSpecial2',
381 // 'PhanParamSpecial3',
382 // 'PhanParamSpecial4',
383 // 'PhanParamTooFew',
384 // 'PhanParamTooFewInternal',
385 // 'PhanParamTooMany',
386 // 'PhanParamTooManyInternal',
387 // 'PhanParamTypeMismatch',
388 // 'PhanParentlessClass',
389 // 'PhanRedefineClass',
390 // 'PhanRedefineClassInternal',
391 // 'PhanRedefineFunction',
392 // 'PhanRedefineFunctionInternal',
393 // 'PhanStaticCallToNonStatic',
394 // 'PhanSyntaxError',
395 // 'PhanTraitParentReference',
396 // 'PhanTypeArrayOperator',
397 // 'PhanTypeArraySuspicious',
398 // 'PhanTypeComparisonFromArray',
399 // 'PhanTypeComparisonToArray',
400 // 'PhanTypeConversionFromArray',
401 // 'PhanTypeInstantiateAbstract',
402 // 'PhanTypeInstantiateInterface',
403 // 'PhanTypeInvalidLeftOperand',
404 // 'PhanTypeInvalidRightOperand',
405 // 'PhanTypeMismatchArgument',
406 // 'PhanTypeMismatchArgumentInternal',
407 // 'PhanTypeMismatchDefault',
408 // 'PhanTypeMismatchForeach',
409 // 'PhanTypeMismatchProperty',
410 // 'PhanTypeMismatchReturn',
411 // 'PhanTypeMissingReturn',
412 // 'PhanTypeNonVarPassByRef',
413 // 'PhanTypeParentConstructorCalled',
414 // 'PhanTypeVoidAssignment',
415 // 'PhanUnanalyzable',
416 // 'PhanUndeclaredClass',
417 // 'PhanUndeclaredClassCatch',
418 // 'PhanUndeclaredClassConstant',
419 // 'PhanUndeclaredClassInstanceof',
420 // 'PhanUndeclaredClassMethod',
421 // 'PhanUndeclaredClassReference',
422 // 'PhanUndeclaredConstant',
423 // 'PhanUndeclaredExtendedClass',
424 // 'PhanUndeclaredFunction',
425 // 'PhanUndeclaredInterface',
426 // 'PhanUndeclaredMethod',
427 // 'PhanUndeclaredProperty',
428 // 'PhanUndeclaredStaticMethod',
429 // 'PhanUndeclaredStaticProperty',
430 // 'PhanUndeclaredTrait',
431 // 'PhanUndeclaredTypeParameter',
432 // 'PhanUndeclaredTypeProperty',
433 // 'PhanUndeclaredVariable',
434 // 'PhanUnreferencedClass',
435 // 'PhanUnreferencedConstant',
436 // 'PhanUnreferencedMethod',
437 // 'PhanUnreferencedProperty',
438 // 'PhanVariableUseClause',
439 ],
440
441 /**
442 * Override to hardcode existence and types of (non-builtin) globals in the global scope.
443 * Class names must be prefixed with '\\'.
444 * (E.g. ['_FOO' => '\\FooClass', 'page' => '\\PageClass', 'userId' => 'int'])
445 */
446 'globals_type_map' => [
447 'IP' => 'string',
448 ],
449
450 // Emit issue messages with markdown formatting
451 'markdown_issue_messages' => false,
452
453 /**
454 * Enable or disable support for generic templated
455 * class types.
456 */
457 'generic_types_enabled' => true,
458
459 // A list of plugin files to execute
460 'plugins' => [
461 ],
462 ];