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