Merge "resourceloader: Remove redundant var-freeing in addScript()"
[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 // Per composer.json, PHPUnit 6 is used for PHP 7.0+, PHPUnit 4 otherwise.
42 // Load the interface for the version of PHPUnit that isn't installed.
43 // Phan only supports PHP 7.0+ (and not HHVM), so we only need to stub PHPUnit 4.
44 class_exists( PHPUnit_TextUI_Command::class ) ? [] : [ 'tests/phan/stubs/phpunit4.php' ],
45 class_exists( ProfilerExcimer::class ) ? [] : [ 'tests/phan/stubs/excimer.php' ],
46 [
47 'maintenance/7zip.inc',
48 'maintenance/cleanupTable.inc',
49 'maintenance/CodeCleanerGlobalsPass.inc',
50 'maintenance/commandLine.inc',
51 'maintenance/sqlite.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 '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 ],
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 suppressed 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' => true,
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: 29
297 "PhanCommentParamOnEmptyParamList",
298 // approximate error count: 33
299 "PhanCommentParamWithoutRealParam",
300 // approximate error count: 8
301 "PhanDeprecatedClass",
302 // approximate error count: 415
303 "PhanDeprecatedFunction",
304 // approximate error count: 25
305 "PhanDeprecatedProperty",
306 // approximate error count: 17
307 "PhanNonClassMethodCall",
308 // approximate error count: 888
309 "PhanParamSignatureMismatch",
310 // approximate error count: 7
311 "PhanParamSignatureMismatchInternal",
312 // approximate error count: 1
313 "PhanParamSignatureRealMismatchTooFewParameters",
314 // approximate error count: 125
315 "PhanParamTooMany",
316 // approximate error count: 3
317 "PhanParamTooManyInternal",
318 // approximate error count: 2
319 "PhanTraitParentReference",
320 // approximate error count: 3
321 "PhanTypeComparisonFromArray",
322 // approximate error count: 2
323 "PhanTypeComparisonToArray",
324 // approximate error count: 218
325 "PhanTypeMismatchArgument",
326 // approximate error count: 13
327 "PhanTypeMismatchArgumentInternal",
328 // approximate error count: 5
329 "PhanTypeMismatchDimAssignment",
330 // approximate error count: 2
331 "PhanTypeMismatchDimEmpty",
332 // approximate error count: 1
333 "PhanTypeMismatchDimFetch",
334 // approximate error count: 14
335 "PhanTypeMismatchForeach",
336 // approximate error count: 56
337 "PhanTypeMismatchProperty",
338 // approximate error count: 74
339 "PhanTypeMismatchReturn",
340 // approximate error count: 5
341 "PhanTypeNonVarPassByRef",
342 // approximate error count: 32
343 "PhanUndeclaredConstant",
344 // approximate error count: 233
345 "PhanUndeclaredMethod",
346 // approximate error count: 1224
347 "PhanUndeclaredProperty",
348 // approximate error count: 58
349 "PhanUndeclaredVariableDim",
350 ],
351
352 /**
353 * If empty, no filter against issues types will be applied.
354 * If this white-list is non-empty, only issues within the list
355 * will be emitted by Phan.
356 */
357 'whitelist_issue_types' => [
358 // 'PhanAccessMethodPrivate',
359 // 'PhanAccessMethodProtected',
360 // 'PhanAccessNonStaticToStatic',
361 // 'PhanAccessPropertyPrivate',
362 // 'PhanAccessPropertyProtected',
363 // 'PhanAccessSignatureMismatch',
364 // 'PhanAccessSignatureMismatchInternal',
365 // 'PhanAccessStaticToNonStatic',
366 // 'PhanCompatibleExpressionPHP7',
367 // 'PhanCompatiblePHP7',
368 // 'PhanContextNotObject',
369 // 'PhanDeprecatedClass',
370 // 'PhanDeprecatedFunction',
371 // 'PhanDeprecatedProperty',
372 // 'PhanEmptyFile',
373 // 'PhanNonClassMethodCall',
374 // 'PhanNoopArray',
375 // 'PhanNoopClosure',
376 // 'PhanNoopConstant',
377 // 'PhanNoopProperty',
378 // 'PhanNoopVariable',
379 // 'PhanParamRedefined',
380 // 'PhanParamReqAfterOpt',
381 // 'PhanParamSignatureMismatch',
382 // 'PhanParamSignatureMismatchInternal',
383 // 'PhanParamSpecial1',
384 // 'PhanParamSpecial2',
385 // 'PhanParamSpecial3',
386 // 'PhanParamSpecial4',
387 // 'PhanParamTooFew',
388 // 'PhanParamTooFewInternal',
389 // 'PhanParamTooMany',
390 // 'PhanParamTooManyInternal',
391 // 'PhanParamTypeMismatch',
392 // 'PhanParentlessClass',
393 // 'PhanRedefineClass',
394 // 'PhanRedefineClassInternal',
395 // 'PhanRedefineFunction',
396 // 'PhanRedefineFunctionInternal',
397 // 'PhanStaticCallToNonStatic',
398 // 'PhanSyntaxError',
399 // 'PhanTraitParentReference',
400 // 'PhanTypeArrayOperator',
401 // 'PhanTypeArraySuspicious',
402 // 'PhanTypeComparisonFromArray',
403 // 'PhanTypeComparisonToArray',
404 // 'PhanTypeConversionFromArray',
405 // 'PhanTypeInstantiateAbstract',
406 // 'PhanTypeInstantiateInterface',
407 // 'PhanTypeInvalidLeftOperand',
408 // 'PhanTypeInvalidRightOperand',
409 // 'PhanTypeMismatchArgument',
410 // 'PhanTypeMismatchArgumentInternal',
411 // 'PhanTypeMismatchDefault',
412 // 'PhanTypeMismatchForeach',
413 // 'PhanTypeMismatchProperty',
414 // 'PhanTypeMismatchReturn',
415 // 'PhanTypeMissingReturn',
416 // 'PhanTypeNonVarPassByRef',
417 // 'PhanTypeParentConstructorCalled',
418 // 'PhanTypeVoidAssignment',
419 // 'PhanUnanalyzable',
420 // 'PhanUndeclaredClass',
421 // 'PhanUndeclaredClassCatch',
422 // 'PhanUndeclaredClassConstant',
423 // 'PhanUndeclaredClassInstanceof',
424 // 'PhanUndeclaredClassMethod',
425 // 'PhanUndeclaredClassReference',
426 // 'PhanUndeclaredConstant',
427 // 'PhanUndeclaredExtendedClass',
428 // 'PhanUndeclaredFunction',
429 // 'PhanUndeclaredInterface',
430 // 'PhanUndeclaredMethod',
431 // 'PhanUndeclaredProperty',
432 // 'PhanUndeclaredStaticMethod',
433 // 'PhanUndeclaredStaticProperty',
434 // 'PhanUndeclaredTrait',
435 // 'PhanUndeclaredTypeParameter',
436 // 'PhanUndeclaredTypeProperty',
437 // 'PhanUndeclaredVariable',
438 // 'PhanUnreferencedClass',
439 // 'PhanUnreferencedConstant',
440 // 'PhanUnreferencedMethod',
441 // 'PhanUnreferencedProperty',
442 // 'PhanVariableUseClause',
443 ],
444
445 /**
446 * Override to hardcode existence and types of (non-builtin) globals in the global scope.
447 * Class names must be prefixed with '\\'.
448 * (E.g. ['_FOO' => '\\FooClass', 'page' => '\\PageClass', 'userId' => 'int'])
449 */
450 'globals_type_map' => [
451 'IP' => 'string',
452 ],
453
454 // Emit issue messages with markdown formatting
455 'markdown_issue_messages' => false,
456
457 /**
458 * Enable or disable support for generic templated
459 * class types.
460 */
461 'generic_types_enabled' => true,
462
463 // A list of plugin files to execute
464 'plugins' => [
465 ],
466 ];