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/cleanupTable.inc',
48 'maintenance/CodeCleanerGlobalsPass.inc',
49 'maintenance/commandLine.inc',
50 'maintenance/sqlite.inc',
51 'maintenance/userDupes.inc',
52 'maintenance/language/checkLanguage.inc',
53 'maintenance/language/languages.inc',
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.
63 * Thus, both first-party and third-party code being used by
64 * your application should be included in this list.
76 * A file list that defines files that will be excluded
77 * from parsing and analysis and will not be read at all.
79 * This is useful for excluding hopelessly unanalyzable
80 * files that can't be removed for whatever reason.
82 'exclude_file_list' => [],
85 * A list of directories holding code that we want
86 * to parse, but not analyze. Also works for individual
89 "exclude_analysis_directory_list" => [
92 // The referenced classes are not available in vendor, only when
93 // included from composer.
95 // Directly references classes that only exist in Translate extension
96 'maintenance/language/',
98 'includes/libs/jsminplus.php',
102 * Backwards Compatibility Checking. This is slow
103 * and expensive, but you should consider running
104 * it before upgrading your version of PHP to a
105 * new version that has backward compatibility
108 'backward_compatibility_checks' => false,
111 * A set of fully qualified class-names for which
112 * a call to parent::__construct() is required
114 'parent_constructor_required' => [
118 * Run a quick version of checks that takes less
119 * time at the cost of not running as thorough
120 * an analysis. You should consider setting this
121 * to true only when you wish you had more issues
122 * to fix in your code base.
124 * In quick-mode the scanner doesn't rescan a function
125 * or a method's code block every time a call is seen.
126 * This means that the problem here won't be detected:
130 * function test($arg):int {
136 * This would normally generate:
139 * test.php:3 TypeError return string but `test()` is declared to return int
142 * The initial scan of the function's code block has no
143 * type information for `$arg`. It isn't until we see
144 * the call and rescan test()'s code block that we can
145 * detect that it is actually returning the passed in
146 * `string` instead of an `int` as declared.
148 'quick_mode' => false,
151 * By default, Phan will not analyze all node types
152 * in order to save time. If this config is set to true,
153 * Phan will dig deeper into the AST tree and do an
154 * analysis on all nodes, possibly finding more issues.
156 * See \Phan\Analysis::shouldVisit for the set of skipped
159 'should_visit_all_nodes' => true,
162 * If enabled, check all methods that override a
163 * parent method to make sure its signature is
164 * compatible with the parent's. This check
165 * can add quite a bit of time to the analysis.
167 'analyze_signature_compatibility' => true,
169 // Emit all issues. They are then suppressed via
170 // suppress_issue_types, rather than a minimum
172 "minimum_severity" => 0,
175 * If true, missing properties will be created when
176 * they are first seen. If false, we'll report an
177 * error message if there is an attempt to write
178 * to a class property that wasn't explicitly
181 'allow_missing_properties' => false,
184 * Allow null to be cast as any type and for any
185 * type to be cast to null. Setting this to false
186 * will cut down on false positives.
188 'null_casts_as_any_type' => true,
191 * If enabled, scalars (int, float, bool, string, null)
192 * are treated as if they can cast to each other.
194 * MediaWiki is pretty lax and uses many scalar
195 * types interchangably.
197 'scalar_implicit_cast' => true,
200 * If true, seemingly undeclared variables in the global
201 * scope will be ignored. This is useful for projects
202 * with complicated cross-file globals that you have no
205 'ignore_undeclared_variables_in_global_scope' => true,
208 * Set to true in order to attempt to detect dead
209 * (unreferenced) code. Keep in mind that the
210 * results will only be a guess given that classes,
211 * properties, constants and methods can be referenced
212 * as variables (like `$class->$property` or
213 * `$class->$method()`) in ways that we're unable
216 'dead_code_detection' => false,
219 * If true, the dead code detection rig will
220 * prefer false negatives (not report dead code) to
221 * false positives (report dead code that is not
222 * actually dead) which is to say that the graph of
223 * references will create too many edges rather than
224 * too few edges when guesses have to be made about
225 * what references what.
227 'dead_code_detection_prefer_false_negative' => true,
230 * If disabled, Phan will not read docblock type
231 * annotation comments (such as for @return, @param,
232 * @var, @suppress, @deprecated) and only rely on
233 * types expressed in code.
235 'read_type_annotations' => true,
238 * If a file path is given, the code base will be
239 * read from and written to the given location in
240 * order to attempt to save some work from being
241 * done. Only changed files will get analyzed if
244 'stored_state_file_path' => null,
247 * Set to true in order to ignore issue suppression.
248 * This is useful for testing the state of your code, but
249 * unlikely to be useful outside of that.
251 'disable_suppression' => false,
254 * If set to true, we'll dump the AST instead of
260 * If set to a string, we'll dump the fully qualified lowercase
261 * function and method signatures instead of analyzing files.
263 'dump_signatures_file' => null,
266 * If true (and if stored_state_file_path is set) we'll
267 * look at the list of files passed in and expand the list
268 * to include files that depend on the given files
270 'expand_file_list' => false,
272 // Include a progress bar in the output
273 'progress_bar' => false,
276 * The probability of actually emitting any progress
277 * bar update. Setting this to something very low
278 * is good for reducing network IO and filling up
279 * your terminal's buffer when running phan on a
282 'progress_bar_sample_rate' => 0.005,
285 * The number of processes to fork off during the analysis
291 * Add any issue types (such as 'PhanUndeclaredMethod')
292 * to this black-list to inhibit them from being reported.
294 'suppress_issue_types' => [
295 // approximate error count: 29
296 "PhanCommentParamOnEmptyParamList",
297 // approximate error count: 33
298 "PhanCommentParamWithoutRealParam",
299 // approximate error count: 8
300 "PhanDeprecatedClass",
301 // approximate error count: 415
302 "PhanDeprecatedFunction",
303 // approximate error count: 25
304 "PhanDeprecatedProperty",
305 // approximate error count: 17
306 "PhanNonClassMethodCall",
307 // approximate error count: 888
308 "PhanParamSignatureMismatch",
309 // approximate error count: 7
310 "PhanParamSignatureMismatchInternal",
311 // approximate error count: 1
312 "PhanParamSignatureRealMismatchTooFewParameters",
313 // approximate error count: 125
315 // approximate error count: 3
316 "PhanParamTooManyInternal",
317 // approximate error count: 1
318 "PhanRedefineFunctionInternal",
319 // approximate error count: 2
320 "PhanTraitParentReference",
321 // approximate error count: 3
322 "PhanTypeComparisonFromArray",
323 // approximate error count: 2
324 "PhanTypeComparisonToArray",
325 // approximate error count: 218
326 "PhanTypeMismatchArgument",
327 // approximate error count: 13
328 "PhanTypeMismatchArgumentInternal",
329 // approximate error count: 5
330 "PhanTypeMismatchDimAssignment",
331 // approximate error count: 2
332 "PhanTypeMismatchDimEmpty",
333 // approximate error count: 1
334 "PhanTypeMismatchDimFetch",
335 // approximate error count: 14
336 "PhanTypeMismatchForeach",
337 // approximate error count: 56
338 "PhanTypeMismatchProperty",
339 // approximate error count: 74
340 "PhanTypeMismatchReturn",
341 // approximate error count: 5
342 "PhanTypeNonVarPassByRef",
343 // approximate error count: 32
344 "PhanUndeclaredConstant",
345 // approximate error count: 233
346 "PhanUndeclaredMethod",
347 // approximate error count: 1224
348 "PhanUndeclaredProperty",
349 // approximate error count: 58
350 "PhanUndeclaredVariableDim",
354 * If empty, no filter against issues types will be applied.
355 * If this white-list is non-empty, only issues within the list
356 * will be emitted by Phan.
358 'whitelist_issue_types' => [
359 // 'PhanAccessMethodPrivate',
360 // 'PhanAccessMethodProtected',
361 // 'PhanAccessNonStaticToStatic',
362 // 'PhanAccessPropertyPrivate',
363 // 'PhanAccessPropertyProtected',
364 // 'PhanAccessSignatureMismatch',
365 // 'PhanAccessSignatureMismatchInternal',
366 // 'PhanAccessStaticToNonStatic',
367 // 'PhanCompatibleExpressionPHP7',
368 // 'PhanCompatiblePHP7',
369 // 'PhanContextNotObject',
370 // 'PhanDeprecatedClass',
371 // 'PhanDeprecatedFunction',
372 // 'PhanDeprecatedProperty',
374 // 'PhanNonClassMethodCall',
376 // 'PhanNoopClosure',
377 // 'PhanNoopConstant',
378 // 'PhanNoopProperty',
379 // 'PhanNoopVariable',
380 // 'PhanParamRedefined',
381 // 'PhanParamReqAfterOpt',
382 // 'PhanParamSignatureMismatch',
383 // 'PhanParamSignatureMismatchInternal',
384 // 'PhanParamSpecial1',
385 // 'PhanParamSpecial2',
386 // 'PhanParamSpecial3',
387 // 'PhanParamSpecial4',
388 // 'PhanParamTooFew',
389 // 'PhanParamTooFewInternal',
390 // 'PhanParamTooMany',
391 // 'PhanParamTooManyInternal',
392 // 'PhanParamTypeMismatch',
393 // 'PhanParentlessClass',
394 // 'PhanRedefineClass',
395 // 'PhanRedefineClassInternal',
396 // 'PhanRedefineFunction',
397 // 'PhanRedefineFunctionInternal',
398 // 'PhanStaticCallToNonStatic',
399 // 'PhanSyntaxError',
400 // 'PhanTraitParentReference',
401 // 'PhanTypeArrayOperator',
402 // 'PhanTypeArraySuspicious',
403 // 'PhanTypeComparisonFromArray',
404 // 'PhanTypeComparisonToArray',
405 // 'PhanTypeConversionFromArray',
406 // 'PhanTypeInstantiateAbstract',
407 // 'PhanTypeInstantiateInterface',
408 // 'PhanTypeInvalidLeftOperand',
409 // 'PhanTypeInvalidRightOperand',
410 // 'PhanTypeMismatchArgument',
411 // 'PhanTypeMismatchArgumentInternal',
412 // 'PhanTypeMismatchDefault',
413 // 'PhanTypeMismatchForeach',
414 // 'PhanTypeMismatchProperty',
415 // 'PhanTypeMismatchReturn',
416 // 'PhanTypeMissingReturn',
417 // 'PhanTypeNonVarPassByRef',
418 // 'PhanTypeParentConstructorCalled',
419 // 'PhanTypeVoidAssignment',
420 // 'PhanUnanalyzable',
421 // 'PhanUndeclaredClass',
422 // 'PhanUndeclaredClassCatch',
423 // 'PhanUndeclaredClassConstant',
424 // 'PhanUndeclaredClassInstanceof',
425 // 'PhanUndeclaredClassMethod',
426 // 'PhanUndeclaredClassReference',
427 // 'PhanUndeclaredConstant',
428 // 'PhanUndeclaredExtendedClass',
429 // 'PhanUndeclaredFunction',
430 // 'PhanUndeclaredInterface',
431 // 'PhanUndeclaredMethod',
432 // 'PhanUndeclaredProperty',
433 // 'PhanUndeclaredStaticMethod',
434 // 'PhanUndeclaredStaticProperty',
435 // 'PhanUndeclaredTrait',
436 // 'PhanUndeclaredTypeParameter',
437 // 'PhanUndeclaredTypeProperty',
438 // 'PhanUndeclaredVariable',
439 // 'PhanUnreferencedClass',
440 // 'PhanUnreferencedConstant',
441 // 'PhanUnreferencedMethod',
442 // 'PhanUnreferencedProperty',
443 // 'PhanVariableUseClause',
447 * Override to hardcode existence and types of (non-builtin) globals in the global scope.
448 * Class names must be prefixed with '\\'.
449 * (E.g. ['_FOO' => '\\FooClass', 'page' => '\\PageClass', 'userId' => 'int'])
451 'globals_type_map' => [
455 // Emit issue messages with markdown formatting
456 'markdown_issue_messages' => false,
459 * Enable or disable support for generic templated
462 'generic_types_enabled' => true,
464 // A list of plugin files to execute