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