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