3 // If xdebug is enabled, we need to increase the nesting level for phan
4 ini_set( 'xdebug.max_nesting_level', 1000 );
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.
11 * @see src/Phan/Config.php
12 * See Config for all configurable options.
17 * Files referenced from this file should be defined as
20 * Config::projectPath('relative_path/to/file')
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
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
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' ],
46 'maintenance/7zip.inc',
47 'maintenance/backup.inc',
48 'maintenance/cleanupTable.inc',
49 'maintenance/CodeCleanerGlobalsPass.inc',
50 'maintenance/commandLine.inc',
51 'maintenance/importImages.inc',
52 'maintenance/sqlite.inc',
53 'maintenance/userDupes.inc',
54 'maintenance/userOptions.inc',
55 'maintenance/language/checkLanguage.inc',
56 'maintenance/language/languages.inc',
61 * A list of directories that should be parsed for class and
62 * method information. After excluding the directories
63 * defined in exclude_analysis_directory_list, the remaining
64 * files will be statically analyzed for errors.
66 * Thus, both first-party and third-party code being used by
67 * your application should be included in this list.
80 * A file list that defines files that will be excluded
81 * from parsing and analysis and will not be read at all.
83 * This is useful for excluding hopelessly unanalyzable
84 * files that can't be removed for whatever reason.
86 'exclude_file_list' => [],
89 * A list of directories holding code that we want
90 * to parse, but not analyze. Also works for individual
93 "exclude_analysis_directory_list" => [
96 // The referenced classes are not available in vendor, only when
97 // included from composer.
99 // Directly references classes that only exist in Translate extension
100 'maintenance/language/',
102 'includes/libs/jsminplus.php',
103 // separate repositories
108 * Backwards Compatibility Checking. This is slow
109 * and expensive, but you should consider running
110 * it before upgrading your version of PHP to a
111 * new version that has backward compatibility
114 'backward_compatibility_checks' => false,
117 * A set of fully qualified class-names for which
118 * a call to parent::__construct() is required
120 'parent_constructor_required' => [
124 * Run a quick version of checks that takes less
125 * time at the cost of not running as thorough
126 * an analysis. You should consider setting this
127 * to true only when you wish you had more issues
128 * to fix in your code base.
130 * In quick-mode the scanner doesn't rescan a function
131 * or a method's code block every time a call is seen.
132 * This means that the problem here won't be detected:
136 * function test($arg):int {
142 * This would normally generate:
145 * test.php:3 TypeError return string but `test()` is declared to return int
148 * The initial scan of the function's code block has no
149 * type information for `$arg`. It isn't until we see
150 * the call and rescan test()'s code block that we can
151 * detect that it is actually returning the passed in
152 * `string` instead of an `int` as declared.
154 'quick_mode' => false,
157 * By default, Phan will not analyze all node types
158 * in order to save time. If this config is set to true,
159 * Phan will dig deeper into the AST tree and do an
160 * analysis on all nodes, possibly finding more issues.
162 * See \Phan\Analysis::shouldVisit for the set of skipped
165 'should_visit_all_nodes' => true,
168 * If enabled, check all methods that override a
169 * parent method to make sure its signature is
170 * compatible with the parent's. This check
171 * can add quite a bit of time to the analysis.
173 'analyze_signature_compatibility' => true,
175 // Emit all issues. They are then suppressed via
176 // suppress_issue_types, rather than a minimum
178 "minimum_severity" => 0,
181 * If true, missing properties will be created when
182 * they are first seen. If false, we'll report an
183 * error message if there is an attempt to write
184 * to a class property that wasn't explicitly
187 'allow_missing_properties' => false,
190 * Allow null to be cast as any type and for any
191 * type to be cast to null. Setting this to false
192 * will cut down on false positives.
194 'null_casts_as_any_type' => true,
197 * If enabled, scalars (int, float, bool, string, null)
198 * are treated as if they can cast to each other.
200 * MediaWiki is pretty lax and uses many scalar
201 * types interchangably.
203 'scalar_implicit_cast' => true,
206 * If true, seemingly undeclared variables in the global
207 * scope will be ignored. This is useful for projects
208 * with complicated cross-file globals that you have no
211 'ignore_undeclared_variables_in_global_scope' => true,
214 * Set to true in order to attempt to detect dead
215 * (unreferenced) code. Keep in mind that the
216 * results will only be a guess given that classes,
217 * properties, constants and methods can be referenced
218 * as variables (like `$class->$property` or
219 * `$class->$method()`) in ways that we're unable
222 'dead_code_detection' => false,
225 * If true, the dead code detection rig will
226 * prefer false negatives (not report dead code) to
227 * false positives (report dead code that is not
228 * actually dead) which is to say that the graph of
229 * references will create too many edges rather than
230 * too few edges when guesses have to be made about
231 * what references what.
233 'dead_code_detection_prefer_false_negative' => true,
236 * If disabled, Phan will not read docblock type
237 * annotation comments (such as for @return, @param,
238 * @var, @suppress, @deprecated) and only rely on
239 * types expressed in code.
241 'read_type_annotations' => true,
244 * If a file path is given, the code base will be
245 * read from and written to the given location in
246 * order to attempt to save some work from being
247 * done. Only changed files will get analyzed if
250 'stored_state_file_path' => null,
253 * Set to true in order to ignore issue suppression.
254 * This is useful for testing the state of your code, but
255 * unlikely to be useful outside of that.
257 'disable_suppression' => false,
260 * If set to true, we'll dump the AST instead of
266 * If set to a string, we'll dump the fully qualified lowercase
267 * function and method signatures instead of analyzing files.
269 'dump_signatures_file' => null,
272 * If true (and if stored_state_file_path is set) we'll
273 * look at the list of files passed in and expand the list
274 * to include files that depend on the given files
276 'expand_file_list' => false,
278 // Include a progress bar in the output
279 'progress_bar' => false,
282 * The probability of actually emitting any progress
283 * bar update. Setting this to something very low
284 * is good for reducing network IO and filling up
285 * your terminal's buffer when running phan on a
288 'progress_bar_sample_rate' => 0.005,
291 * The number of processes to fork off during the analysis
297 * Add any issue types (such as 'PhanUndeclaredMethod')
298 * to this black-list to inhibit them from being reported.
300 'suppress_issue_types' => [
301 // approximate error count: 29
302 "PhanCommentParamOnEmptyParamList",
303 // approximate error count: 33
304 "PhanCommentParamWithoutRealParam",
305 // approximate error count: 8
306 "PhanDeprecatedClass",
307 // approximate error count: 415
308 "PhanDeprecatedFunction",
309 // approximate error count: 25
310 "PhanDeprecatedProperty",
311 // approximate error count: 17
312 "PhanNonClassMethodCall",
313 // approximate error count: 11
314 "PhanParamReqAfterOpt",
315 // approximate error count: 888
316 "PhanParamSignatureMismatch",
317 // approximate error count: 7
318 "PhanParamSignatureMismatchInternal",
319 // approximate error count: 1
320 "PhanParamSignatureRealMismatchTooFewParameters",
321 // approximate error count: 125
323 // approximate error count: 1
324 "PhanParamTooManyCallable",
325 // approximate error count: 3
326 "PhanParamTooManyInternal",
327 // approximate error count: 1
328 "PhanRedefineFunctionInternal",
329 // approximate error count: 2
330 "PhanTraitParentReference",
331 // approximate error count: 3
332 "PhanTypeComparisonFromArray",
333 // approximate error count: 2
334 "PhanTypeComparisonToArray",
335 // approximate error count: 3
336 "PhanTypeInvalidRightOperand",
337 // approximate error count: 1
338 "PhanTypeMagicVoidWithReturn",
339 // approximate error count: 218
340 "PhanTypeMismatchArgument",
341 // approximate error count: 13
342 "PhanTypeMismatchArgumentInternal",
343 // approximate error count: 6
344 "PhanTypeMismatchDeclaredParam",
345 // approximate error count: 111
346 "PhanTypeMismatchDeclaredParamNullable",
347 // approximate error count: 1
348 "PhanTypeMismatchDefault",
349 // approximate error count: 5
350 "PhanTypeMismatchDimAssignment",
351 // approximate error count: 2
352 "PhanTypeMismatchDimEmpty",
353 // approximate error count: 1
354 "PhanTypeMismatchDimFetch",
355 // approximate error count: 14
356 "PhanTypeMismatchForeach",
357 // approximate error count: 56
358 "PhanTypeMismatchProperty",
359 // approximate error count: 74
360 "PhanTypeMismatchReturn",
361 // approximate error count: 11
362 "PhanTypeMissingReturn",
363 // approximate error count: 5
364 "PhanTypeNonVarPassByRef",
365 // approximate error count: 1
366 "PhanUndeclaredClassInCallable",
367 // approximate error count: 32
368 "PhanUndeclaredConstant",
369 // approximate error count: 233
370 "PhanUndeclaredMethod",
371 // approximate error count: 1224
372 "PhanUndeclaredProperty",
373 // approximate error count: 3
374 "PhanUndeclaredStaticMethod",
375 // approximate error count: 11
376 "PhanUndeclaredTypeReturnType",
377 // approximate error count: 27
378 "PhanUndeclaredVariable",
379 // approximate error count: 58
380 "PhanUndeclaredVariableDim",
384 * If empty, no filter against issues types will be applied.
385 * If this white-list is non-empty, only issues within the list
386 * will be emitted by Phan.
388 'whitelist_issue_types' => [
389 // 'PhanAccessMethodPrivate',
390 // 'PhanAccessMethodProtected',
391 // 'PhanAccessNonStaticToStatic',
392 // 'PhanAccessPropertyPrivate',
393 // 'PhanAccessPropertyProtected',
394 // 'PhanAccessSignatureMismatch',
395 // 'PhanAccessSignatureMismatchInternal',
396 // 'PhanAccessStaticToNonStatic',
397 // 'PhanCompatibleExpressionPHP7',
398 // 'PhanCompatiblePHP7',
399 // 'PhanContextNotObject',
400 // 'PhanDeprecatedClass',
401 // 'PhanDeprecatedFunction',
402 // 'PhanDeprecatedProperty',
404 // 'PhanNonClassMethodCall',
406 // 'PhanNoopClosure',
407 // 'PhanNoopConstant',
408 // 'PhanNoopProperty',
409 // 'PhanNoopVariable',
410 // 'PhanParamRedefined',
411 // 'PhanParamReqAfterOpt',
412 // 'PhanParamSignatureMismatch',
413 // 'PhanParamSignatureMismatchInternal',
414 // 'PhanParamSpecial1',
415 // 'PhanParamSpecial2',
416 // 'PhanParamSpecial3',
417 // 'PhanParamSpecial4',
418 // 'PhanParamTooFew',
419 // 'PhanParamTooFewInternal',
420 // 'PhanParamTooMany',
421 // 'PhanParamTooManyInternal',
422 // 'PhanParamTypeMismatch',
423 // 'PhanParentlessClass',
424 // 'PhanRedefineClass',
425 // 'PhanRedefineClassInternal',
426 // 'PhanRedefineFunction',
427 // 'PhanRedefineFunctionInternal',
428 // 'PhanStaticCallToNonStatic',
429 // 'PhanSyntaxError',
430 // 'PhanTraitParentReference',
431 // 'PhanTypeArrayOperator',
432 // 'PhanTypeArraySuspicious',
433 // 'PhanTypeComparisonFromArray',
434 // 'PhanTypeComparisonToArray',
435 // 'PhanTypeConversionFromArray',
436 // 'PhanTypeInstantiateAbstract',
437 // 'PhanTypeInstantiateInterface',
438 // 'PhanTypeInvalidLeftOperand',
439 // 'PhanTypeInvalidRightOperand',
440 // 'PhanTypeMismatchArgument',
441 // 'PhanTypeMismatchArgumentInternal',
442 // 'PhanTypeMismatchDefault',
443 // 'PhanTypeMismatchForeach',
444 // 'PhanTypeMismatchProperty',
445 // 'PhanTypeMismatchReturn',
446 // 'PhanTypeMissingReturn',
447 // 'PhanTypeNonVarPassByRef',
448 // 'PhanTypeParentConstructorCalled',
449 // 'PhanTypeVoidAssignment',
450 // 'PhanUnanalyzable',
451 // 'PhanUndeclaredClass',
452 // 'PhanUndeclaredClassCatch',
453 // 'PhanUndeclaredClassConstant',
454 // 'PhanUndeclaredClassInstanceof',
455 // 'PhanUndeclaredClassMethod',
456 // 'PhanUndeclaredClassReference',
457 // 'PhanUndeclaredConstant',
458 // 'PhanUndeclaredExtendedClass',
459 // 'PhanUndeclaredFunction',
460 // 'PhanUndeclaredInterface',
461 // 'PhanUndeclaredMethod',
462 // 'PhanUndeclaredProperty',
463 // 'PhanUndeclaredStaticMethod',
464 // 'PhanUndeclaredStaticProperty',
465 // 'PhanUndeclaredTrait',
466 // 'PhanUndeclaredTypeParameter',
467 // 'PhanUndeclaredTypeProperty',
468 // 'PhanUndeclaredVariable',
469 // 'PhanUnreferencedClass',
470 // 'PhanUnreferencedConstant',
471 // 'PhanUnreferencedMethod',
472 // 'PhanUnreferencedProperty',
473 // 'PhanVariableUseClause',
477 * Override to hardcode existence and types of (non-builtin) globals in the global scope.
478 * Class names must be prefixed with '\\'.
479 * (E.g. ['_FOO' => '\\FooClass', 'page' => '\\PageClass', 'userId' => 'int'])
481 'globals_type_map' => [
485 // Emit issue messages with markdown formatting
486 'markdown_issue_messages' => false,
489 * Enable or disable support for generic templated
492 'generic_types_enabled' => true,
494 // A list of plugin files to execute