Merge "Skin: Make skins aware of their registered skin name"
[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: 8
299 "PhanDeprecatedClass",
300 // approximate error count: 415
301 "PhanDeprecatedFunction",
302 // approximate error count: 25
303 "PhanDeprecatedProperty",
304 // approximate error count: 11
305 "PhanParamReqAfterOpt",
306 // approximate error count: 888
307 "PhanParamSignatureMismatch",
308 // approximate error count: 7
309 "PhanParamSignatureMismatchInternal",
310 // approximate error count: 125
311 "PhanParamTooMany",
312 // approximate error count: 3
313 "PhanParamTooManyInternal",
314 // approximate error count: 1
315 "PhanRedefineFunctionInternal",
316 // approximate error count: 2
317 "PhanTraitParentReference",
318 // approximate error count: 3
319 "PhanTypeComparisonFromArray",
320 // approximate error count: 3
321 "PhanTypeInvalidRightOperand",
322 // approximate error count: 218
323 "PhanTypeMismatchArgument",
324 // approximate error count: 13
325 "PhanTypeMismatchArgumentInternal",
326 // approximate error count: 14
327 "PhanTypeMismatchForeach",
328 // approximate error count: 56
329 "PhanTypeMismatchProperty",
330 // approximate error count: 74
331 "PhanTypeMismatchReturn",
332 // approximate error count: 11
333 "PhanTypeMissingReturn",
334 // approximate error count: 5
335 "PhanTypeNonVarPassByRef",
336 // approximate error count: 32
337 "PhanUndeclaredConstant",
338 // approximate error count: 233
339 "PhanUndeclaredMethod",
340 // approximate error count: 1224
341 "PhanUndeclaredProperty",
342 // approximate error count: 3
343 "PhanUndeclaredStaticMethod",
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 ];