Add parameter to API modules to apply change tags to log entries
[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' => [
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',
49 ],
50
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.
56 *
57 * Thus, both first-party and third-party code being used by
58 * your application should be included in this list.
59 */
60 'directory_list' => [
61 'includes/',
62 'languages/',
63 'maintenance/',
64 'mw-config/',
65 'resources/',
66 'skins/',
67 'vendor/',
68 'tests/phan/stubs/',
69 ],
70
71 /**
72 * A file list that defines files that will be excluded
73 * from parsing and analysis and will not be read at all.
74 *
75 * This is useful for excluding hopelessly unanalyzable
76 * files that can't be removed for whatever reason.
77 */
78 'exclude_file_list' => function_exists( 'xcache_get' ) ? [] : [
79 // References xcache which probably isn't installed
80 'includes/libs/objectcache/XCacheBagOStuff.php'
81 ],
82
83 /**
84 * A list of directories holding code that we want
85 * to parse, but not analyze. Also works for individual
86 * files.
87 */
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/'
100 ],
101
102 /**
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.
108 */
109 'backward_compatibility_checks' => false,
110
111 /**
112 * A set of fully qualified class-names for which
113 * a call to parent::__construct() is required
114 */
115 'parent_constructor_required' => [
116 ],
117
118 /**
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.
124 *
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:
128 *
129 * ```php
130 * <?php
131 * function test($arg):int {
132 * return $arg;
133 * }
134 * test("abc");
135 * ```
136 *
137 * This would normally generate:
138 *
139 * ```sh
140 * test.php:3 TypeError return string but `test()` is declared to return int
141 * ```
142 *
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.
148 */
149 'quick_mode' => false,
150
151 /**
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.
156 *
157 * See \Phan\Analysis::shouldVisit for the set of skipped
158 * nodes.
159 */
160 'should_visit_all_nodes' => true,
161
162 /**
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.
167 */
168 'analyze_signature_compatibility' => true,
169
170 // Emit all issues. They are then supressed via
171 // suppress_issue_types, rather than a minimum
172 // severity.
173 "minimum_severity" => 0,
174
175 /**
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.
181 */
182 'allow_missing_properties' => false,
183
184 /**
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.
188 */
189 'null_casts_as_any_type' => true,
190
191 /**
192 * If enabled, scalars (int, float, bool, string, null)
193 * are treated as if they can cast to each other.
194 *
195 * MediaWiki is pretty lax and uses many scalar
196 * types interchangably.
197 */
198 'scalar_implicit_cast' => true,
199
200 /**
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.
205 */
206 'ignore_undeclared_variables_in_global_scope' => false,
207
208 /**
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.
216 */
217 'dead_code_detection' => false,
218
219 /**
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.
227 */
228 'dead_code_detection_prefer_false_negative' => true,
229
230 /**
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.
235 */
236 'read_type_annotations' => true,
237
238 /**
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
244 */
245 'stored_state_file_path' => null,
246
247 /**
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.
251 */
252 'disable_suppression' => false,
253
254 /**
255 * If set to true, we'll dump the AST instead of
256 * analyzing files
257 */
258 'dump_ast' => false,
259
260 /**
261 * If set to a string, we'll dump the fully qualified lowercase
262 * function and method signatures instead of analyzing files.
263 */
264 'dump_signatures_file' => null,
265
266 /**
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
270 */
271 'expand_file_list' => false,
272
273 // Include a progress bar in the output
274 'progress_bar' => false,
275
276 /**
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.
282 */
283 'progress_bar_sample_rate' => 0.005,
284
285 /**
286 * The number of processes to fork off during the analysis
287 * phase.
288 */
289 'processes' => 1,
290
291 /**
292 * Add any issue types (such as 'PhanUndeclaredMethod')
293 * to this black-list to inhibit them from being reported.
294 */
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: 9
341 "PhanUndeclaredStaticMethod",
342 // approximate error count: 79
343 "PhanUndeclaredVariable",
344 ],
345
346 /**
347 * If empty, no filter against issues types will be applied.
348 * If this white-list is non-empty, only issues within the list
349 * will be emitted by Phan.
350 */
351 'whitelist_issue_types' => [
352 // 'PhanAccessMethodPrivate',
353 // 'PhanAccessMethodProtected',
354 // 'PhanAccessNonStaticToStatic',
355 // 'PhanAccessPropertyPrivate',
356 // 'PhanAccessPropertyProtected',
357 // 'PhanAccessSignatureMismatch',
358 // 'PhanAccessSignatureMismatchInternal',
359 // 'PhanAccessStaticToNonStatic',
360 // 'PhanCompatibleExpressionPHP7',
361 // 'PhanCompatiblePHP7',
362 // 'PhanContextNotObject',
363 // 'PhanDeprecatedClass',
364 // 'PhanDeprecatedFunction',
365 // 'PhanDeprecatedProperty',
366 // 'PhanEmptyFile',
367 // 'PhanNonClassMethodCall',
368 // 'PhanNoopArray',
369 // 'PhanNoopClosure',
370 // 'PhanNoopConstant',
371 // 'PhanNoopProperty',
372 // 'PhanNoopVariable',
373 // 'PhanParamRedefined',
374 // 'PhanParamReqAfterOpt',
375 // 'PhanParamSignatureMismatch',
376 // 'PhanParamSignatureMismatchInternal',
377 // 'PhanParamSpecial1',
378 // 'PhanParamSpecial2',
379 // 'PhanParamSpecial3',
380 // 'PhanParamSpecial4',
381 // 'PhanParamTooFew',
382 // 'PhanParamTooFewInternal',
383 // 'PhanParamTooMany',
384 // 'PhanParamTooManyInternal',
385 // 'PhanParamTypeMismatch',
386 // 'PhanParentlessClass',
387 // 'PhanRedefineClass',
388 // 'PhanRedefineClassInternal',
389 // 'PhanRedefineFunction',
390 // 'PhanRedefineFunctionInternal',
391 // 'PhanStaticCallToNonStatic',
392 // 'PhanSyntaxError',
393 // 'PhanTraitParentReference',
394 // 'PhanTypeArrayOperator',
395 // 'PhanTypeArraySuspicious',
396 // 'PhanTypeComparisonFromArray',
397 // 'PhanTypeComparisonToArray',
398 // 'PhanTypeConversionFromArray',
399 // 'PhanTypeInstantiateAbstract',
400 // 'PhanTypeInstantiateInterface',
401 // 'PhanTypeInvalidLeftOperand',
402 // 'PhanTypeInvalidRightOperand',
403 // 'PhanTypeMismatchArgument',
404 // 'PhanTypeMismatchArgumentInternal',
405 // 'PhanTypeMismatchDefault',
406 // 'PhanTypeMismatchForeach',
407 // 'PhanTypeMismatchProperty',
408 // 'PhanTypeMismatchReturn',
409 // 'PhanTypeMissingReturn',
410 // 'PhanTypeNonVarPassByRef',
411 // 'PhanTypeParentConstructorCalled',
412 // 'PhanTypeVoidAssignment',
413 // 'PhanUnanalyzable',
414 // 'PhanUndeclaredClass',
415 // 'PhanUndeclaredClassCatch',
416 // 'PhanUndeclaredClassConstant',
417 // 'PhanUndeclaredClassInstanceof',
418 // 'PhanUndeclaredClassMethod',
419 // 'PhanUndeclaredClassReference',
420 // 'PhanUndeclaredConstant',
421 // 'PhanUndeclaredExtendedClass',
422 // 'PhanUndeclaredFunction',
423 // 'PhanUndeclaredInterface',
424 // 'PhanUndeclaredMethod',
425 // 'PhanUndeclaredProperty',
426 // 'PhanUndeclaredStaticMethod',
427 // 'PhanUndeclaredStaticProperty',
428 // 'PhanUndeclaredTrait',
429 // 'PhanUndeclaredTypeParameter',
430 // 'PhanUndeclaredTypeProperty',
431 // 'PhanUndeclaredVariable',
432 // 'PhanUnreferencedClass',
433 // 'PhanUnreferencedConstant',
434 // 'PhanUnreferencedMethod',
435 // 'PhanUnreferencedProperty',
436 // 'PhanVariableUseClause',
437 ],
438
439 /**
440 * Override to hardcode existence and types of (non-builtin) globals in the global scope.
441 * Class names must be prefixed with '\\'.
442 * (E.g. ['_FOO' => '\\FooClass', 'page' => '\\PageClass', 'userId' => 'int'])
443 */
444 'globals_type_map' => [
445 'IP' => 'string',
446 ],
447
448 // Emit issue messages with markdown formatting
449 'markdown_issue_messages' => false,
450
451 /**
452 * Enable or disable support for generic templated
453 * class types.
454 */
455 'generic_types_enabled' => true,
456
457 // A list of plugin files to execute
458 'plugins' => [
459 ],
460 ];