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