Issues (1)

.phan/config.php (1 issue)

Labels
Severity
1
<?php
2
declare (strict_types = 1);
3
4
use Phan\Issue;
0 ignored issues
show
The type Phan\Issue was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
5
6
/**
7
 * This configuration will be read and overlaid 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
    // Supported values: `'5.6'`, `'7.0'`, `'7.1'`, `'7.2'`, `'7.3'`, `null`.
30
    // If this is set to `null`,
31
    // then Phan assumes the PHP version which is closest to the minor version
32
    // of the php executable used to execute Phan.
33
    //
34
    // Note that the **only** effect of choosing `'5.6'` is to infer that functions removed in php 7.0 exist.
35
    // (See `backward_compatibility_checks` for additional options)
36
    'target_php_version' => null,
37
38
    // Default: true. If this is set to true,
39
    // and target_php_version is newer than the version used to run Phan,
40
    // Phan will act as though functions added in newer PHP versions exist.
41
    //
42
    // NOTE: Currently, this only affects Closure::fromCallable
43
    'pretend_newer_core_functions_exist' => true,
44
45
    // If true, missing properties will be created when
46
    // they are first seen. If false, we'll report an
47
    // error message.
48
    'allow_missing_properties' => false,
49
50
    // Allow null to be cast as any type and for any
51
    // type to be cast to null.
52
    'null_casts_as_any_type' => false,
53
54
    // Allow null to be cast as any array-like type
55
    // This is an incremental step in migrating away from null_casts_as_any_type.
56
    // If null_casts_as_any_type is true, this has no effect.
57
    'null_casts_as_array' => false,
58
59
    // Allow any array-like type to be cast to null.
60
    // This is an incremental step in migrating away from null_casts_as_any_type.
61
    // If null_casts_as_any_type is true, this has no effect.
62
    'array_casts_as_null' => false,
63
64
    // If enabled, Phan will warn if **any** type in a method's object expression
65
    // is definitely not an object,
66
    // or if **any** type in an invoked expression is not a callable.
67
    // Setting this to true will introduce numerous false positives
68
    // (and reveal some bugs).
69
    'strict_method_checking' => true,
70
71
    // If enabled, Phan will warn if **any** type in the argument's type
72
    // cannot be cast to a type in the parameter's expected type.
73
    // Setting this to true will introduce a large number of false positives (and some bugs).
74
    // (For self-analysis, Phan has a large number of suppressions and file-level suppressions,
75
    // due to \ast\Node being difficult to type check)
76
    'strict_param_checking' => true,
77
78
    // If enabled, Phan will warn if **any** type in a property assignment's type
79
    // cannot be cast to a type in the property's expected type.
80
    // Setting this to true will introduce a large number of false positives (and some bugs).
81
    // (For self-analysis, Phan has a large number of suppressions and file-level suppressions,
82
    // due to \ast\Node being difficult to type check)
83
    'strict_property_checking' => true,
84
85
    // If enabled, Phan will warn if **any** type in the return statement's union type
86
    // cannot be cast to a type in the method's declared return type.
87
    // Setting this to true will introduce a large number of false positives (and some bugs).
88
    // (For self-analysis, Phan has a large number of suppressions and file-level suppressions,
89
    // due to \ast\Node being difficult to type check)
90
    'strict_return_checking' => true,
91
92
    // If enabled, scalars (int, float, bool, string, null)
93
    // are treated as if they can cast to each other.
94
    // This does not affect checks of array keys. See scalar_array_key_cast.
95
    'scalar_implicit_cast' => false,
96
97
    // If enabled, any scalar array keys (int, string)
98
    // are treated as if they can cast to each other.
99
    // E.g. array<int,stdClass> can cast to array<string,stdClass> and vice versa.
100
    // Normally, a scalar type such as int could only cast to/from int and mixed.
101
    'scalar_array_key_cast' => false,
102
103
    // If this has entries, scalars (int, float, bool, string, null)
104
    // are allowed to perform the casts listed.
105
    // E.g. ['int' => ['float', 'string'], 'float' => ['int'], 'string' => ['int'], 'null' => ['string']]
106
    // allows casting null to a string, but not vice versa.
107
    // (subset of scalar_implicit_cast)
108
    'scalar_implicit_partial' => [],
109
110
    // If true, seemingly undeclared variables in the global
111
    // scope will be ignored. This is useful for projects
112
    // with complicated cross-file globals that you have no
113
    // hope of fixing.
114
    'ignore_undeclared_variables_in_global_scope' => false,
115
116
    // Backwards Compatibility Checking (This is very slow)
117
    'backward_compatibility_checks' => false,
118
119
    // If true, check to make sure the return type declared
120
    // in the doc-block (if any) matches the return type
121
    // declared in the method signature. This process is
122
    // slow.
123
    'check_docblock_signature_return_type_match' => true,
124
125
    // If true, check to make sure the param types declared
126
    // in the doc-block (if any) matches the param types
127
    // declared in the method signature.
128
    'check_docblock_signature_param_type_match' => true,
129
130
    // (*Requires check_docblock_signature_param_type_match to be true*)
131
    // If true, make narrowed types from phpdoc params override
132
    // the real types from the signature, when real types exist.
133
    // (E.g. allows specifying desired lists of subclasses,
134
    //  or to indicate a preference for non-nullable types over nullable types)
135
    // Affects analysis of the body of the method and the param types passed in by callers.
136
    'prefer_narrowed_phpdoc_param_type' => true,
137
138
    // (*Requires check_docblock_signature_return_type_match to be true*)
139
    // If true, make narrowed types from phpdoc returns override
140
    // the real types from the signature, when real types exist.
141
    // (E.g. allows specifying desired lists of subclasses,
142
    //  or to indicate a preference for non-nullable types over nullable types)
143
    // Affects analysis of return statements in the body of the method and the return types passed in by callers.
144
    'prefer_narrowed_phpdoc_return_type' => true,
145
146
    // If enabled, check all methods that override a
147
    // parent method to make sure its signature is
148
    // compatible with the parent's. This check
149
    // can add quite a bit of time to the analysis.
150
    // This will also check if final methods are overridden, etc.
151
    'analyze_signature_compatibility' => true,
152
153
    // Set this to true to allow contravariance in real parameter types of method overrides (Introduced in php 7.2)
154
    // See https://secure.php.net/manual/en/migration72.new-features.php#migration72.new-features.param-type-widening
155
    // (Users may enable this if analyzing projects that support only php 7.2+)
156
    // This is false by default. (Will warn if real parameter types are omitted in an override)
157
    'allow_method_param_type_widening' => false,
158
159
    // Set this to true to make Phan guess that undocumented parameter types
160
    // (for optional parameters) have the same type as default values
161
    // (Instead of combining that type with `mixed`).
162
    // E.g. `function($x = 'val')` would make Phan infer that $x had a type of `string`, not `string|mixed`.
163
    // Phan will not assume it knows specific types if the default value is false or null.
164
    'guess_unknown_parameter_type_using_default' => false,
165
166
    // This setting maps case insensitive strings to union types.
167
    // This is useful if a project uses phpdoc that differs from the phpdoc2 standard.
168
    // If the corresponding value is the empty string, Phan will ignore that union type
169
    // (E.g. can ignore 'the' in `@return the value`)
170
    // If the corresponding value is not empty, Phan will act as though it saw the corresponding union type
171
    // when the keys show up in a UnionType of @param, @return, @var, @property, etc.
172
    //
173
    // This matches the **entire string**, not parts of the string.
174
    // (E.g. `@return the|null` will still look for a class with the name `the`,
175
    //but `@return the` will be ignored with the below setting)
176
    //
177
    // (These are not aliases, this setting is ignored outside of doc comments).
178
    // (Phan does not check if classes with these names exist)
179
    //
180
    // Example setting: ['unknown' => '', 'number' => 'int|float', 'char' => 'string', 'long' => 'int', 'the' => '']
181
    'phpdoc_type_mapping' => [],
182
183
    // Set to true in order to attempt to detect dead
184
    // (unreferenced) code. Keep in mind that the
185
    // results will only be a guess given that classes,
186
    // properties, constants and methods can be referenced
187
    // as variables (like `$class->$property` or
188
    // `$class->$method()`) in ways that we're unable
189
    // to make sense of.
190
    'dead_code_detection' => false,
191
192
    // Set to true in order to attempt to detect unused variables.
193
    // dead_code_detection will also enable unused variable detection.
194
    'unused_variable_detection' => true,
195
196
    // Set to true in order to force tracking references to elements
197
    // (functions/methods/consts/protected).
198
    // dead_code_detection is another option which also causes references
199
    // to be tracked.
200
    'force_tracking_references' => false,
201
202
    // Enable this to warn about harmless redundant use for classes and namespaces
203
    // such as `use Foo\bar` in namespace Foo.
204
    //
205
    // Note: This does not affect warnings about redundant uses in the global namespace.
206
    'warn_about_redundant_use_namespaced_class' => true,
207
208
    // If true, then run a quick version of checks that takes less time.
209
    // False by default.
210
    'quick_mode' => false,
211
212
    // If true, then before analysis, try to simplify AST into a form
213
    // which improves Phan's type inference in edge cases.
214
    //
215
    // This may conflict with 'dead_code_detection'.
216
    // When this is true, this slows down analysis slightly.
217
    //
218
    // E.g. rewrites `if ($a = value() && $a > 0) {...}`
219
    // into $a = value(); if ($a) { if ($a > 0) {...}}`
220
    'simplify_ast' => true,
221
222
    // If true, Phan will read `class_alias` calls in the global scope,
223
    // then (1) create aliases from the *parsed* files if no class definition was found,
224
    // and (2) emit issues in the global scope if the source or target class is invalid.
225
    // (If there are multiple possible valid original classes for an aliased class name,
226
    //  the one which will be created is unspecified.)
227
    // NOTE: THIS IS EXPERIMENTAL, and the implementation may change.
228
    'enable_class_alias_support' => false,
229
230
    // Enable or disable support for generic templated
231
    // class types.
232
    'generic_types_enabled' => true,
233
234
    // If enabled, warn about throw statement where the exception types
235
    // are not documented in the PHPDoc of functions, methods, and closures.
236
    'warn_about_undocumented_throw_statements' => true,
237
238
    // If enabled (and warn_about_undocumented_throw_statements is enabled),
239
    // warn about function/closure/method calls that have (at)throws
240
    // without the invoking method documenting that exception.
241
    'warn_about_undocumented_exceptions_thrown_by_invoked_functions' => true,
242
243
    // If this is a list, Phan will not warn about lack of documentation of (at)throws
244
    // for any of the listed classes or their subclasses.
245
    // This setting only matters when warn_about_undocumented_throw_statements is true.
246
    // The default is the empty array (Warn about every kind of Throwable)
247
    'exception_classes_with_optional_throws_phpdoc' => [
248
        'LogicException',
249
        'RuntimeException',
250
        'InvalidArgumentException',
251
        'AssertionError',
252
        'TypeError'
253
    ],
254
255
    // Increase this to properly analyze require_once statements
256
    'max_literal_string_type_length' => 1000,
257
258
    // Setting this to true makes the process assignment for file analysis
259
    // as predictable as possible, using consistent hashing.
260
    // Even if files are added or removed, or process counts change,
261
    // relatively few files will move to a different group.
262
    // (use when the number of files is much larger than the process count)
263
    // NOTE: If you rely on Phan parsing files/directories in the order
264
    // that they were provided in this config, don't use this)
265
    // See https://github.com/phan/phan/wiki/Different-Issue-Sets-On-Different-Numbers-of-CPUs
266
    'consistent_hashing_file_order' => false,
267
268
    // Override to hardcode existence and types of (non-builtin) globals.
269
    // Class names should be prefixed with '\\'.
270
    // (E.g. ['_FOO' => '\\FooClass', 'page' => '\\PageClass', 'userId' => 'int'])
271
    'globals_type_map' => [],
272
273
    // The minimum severity level to report on. This can be
274
    // set to Issue::SEVERITY_LOW, Issue::SEVERITY_NORMAL or
275
    // Issue::SEVERITY_CRITICAL.
276
    'minimum_severity' => Issue::SEVERITY_LOW,
277
278
    // Add any issue types (such as 'PhanUndeclaredMethod')
279
    // here to inhibit them from being reported
280
    'suppress_issue_types' => [
281
        // 'PhanUnreferencedClosure',
282
        // 'PhanPluginNoCommentOnProtectedMethod',
283
        // 'PhanPluginDescriptionlessCommentOnProtectedMethod',
284
        // 'PhanPluginNoCommentOnPrivateMethod',
285
        // 'PhanPluginDescriptionlessCommentOnPrivateMethod',
286
        'PhanPluginUnknownArrayMethodParamType',
287
        'PhanPluginUnknownArrayClosureParamType',
288
        'PhanPluginUnknownArrayPropertyType'
289
    ],
290
291
    // If empty, no filter against issues types will be applied.
292
    // If non-empty, only issues within the list will be emitted
293
    // by Phan.
294
    //
295
    // See https://github.com/phan/phan/wiki/Issue-Types-Caught-by-Phan
296
    // for the full list of issues that Phan detects.
297
    //
298
    // Phan is capable of detecting hundreds of types of issues.
299
    // Projects should almost always use `suppress_issue_types` instead.
300
    'whitelist_issue_types' => [
301
        // 'PhanUndeclaredClass',
302
    ],
303
304
    // A regular expression to match files to be excluded
305
    // from parsing and analysis and will not be read at all.
306
    //
307
    // This is useful for excluding groups of test or example
308
    // directories/files, unanalyzable files, or files that
309
    // can't be removed for whatever reason.
310
    // (e.g. '@Test\.php$@', or '@vendor/.*/(tests|Tests)/@')
311
    'exclude_file_regex' => '@^vendor/.*/(tests?|Tests?)/@',
312
313
    // Enable this to enable checks of require/include statements referring to valid paths.
314
    'enable_include_path_checks' => true,
315
316
    // A list of include paths to check when checking if `require_once`, `include`, etc. are valid.
317
    //
318
    // To refer to the directory of the file being analyzed, use `'.'`
319
    // To refer to the project root directory, you must use \Phan\Config::getProjectRootDirectory()
320
    //
321
    // (E.g. `['.', \Phan\Config::getProjectRootDirectory() . '/src/folder-added-to-include_path']`)
322
    'include_paths' => ['.'],
323
324
    // Enable this to warn about the use of relative paths in `require_once`, `include`, etc.
325
    // Relative paths are harder to reason about, and opcache may have issues with relative paths in edge cases.
326
    'warn_about_relative_include_statement' => true,
327
328
    // The number of processes to fork off during the analysis
329
    // phase.
330
    'processes' => 1,
331
332
    // A list of directories that should be parsed for class and
333
    // method information. After excluding the directories
334
    // defined in exclude_analysis_directory_list, the remaining
335
    // files will be statically analyzed for errors.
336
    //
337
    // Thus, both first-party and third-party code being used by
338
    // your application should be included in this list.
339
    'directory_list' => [
340
        'src',
341
        // 'tests',
342
        'vendor'
343
    ],
344
345
    // List of case-insensitive file extensions supported by Phan.
346
    // (e.g. php, html, htm)
347
    'analyzed_file_extensions' => ['php'],
348
349
    // A directory list that defines files that will be excluded
350
    // from static analysis, but whose class and method
351
    // information should be included.
352
    //
353
    // Generally, you'll want to include the directories for
354
    // third-party code (such as 'vendor/') in this list.
355
    //
356
    // n.b.: If you'd like to parse but not analyze 3rd
357
    //       party code, directories containing that code
358
    //       should be added to the `directory_list` as
359
    //       to `exclude_analysis_directory_list`.
360
    'exclude_analysis_directory_list' => [
361
        'tests/',
362
        'vendor/'
363
    ],
364
365
    // By default, Phan will log error messages to stdout if PHP is using options that slow the analysis.
366
    // (e.g. PHP is compiled with --enable-debug or when using XDebug)
367
    'skip_slow_php_options_warning' => false,
368
369
    // Set this to false to emit PhanUndeclaredFunction issues for internal functions that Phan has signatures for,
370
    // but aren't available in the codebase, or the internal functions used to run phan
371
    // (may lead to false positives if an extension isn't loaded)
372
    // If this is true(default), then Phan will not warn.
373
    // Also see 'autoload_internal_extension_signatures' for an alternative way to fix this type of issue.
374
    'ignore_undeclared_functions_with_known_signatures' => false,
375
376
    'plugin_config' => [
377
        // A list of 1 or more PHP binaries (Absolute path or program name found in $PATH)
378
        // to use to analyze your files with PHP's native `--syntax-check`.
379
        //
380
        // This can be used to simultaneously run PHP's syntax checks with multiple PHP versions.
381
        // e.g. `'plugin_config' => ['php_native_syntax_check_binaries' => ['php72', 'php70', 'php56']]`
382
        // if all of those programs can be found in $PATH
383
384
        // 'php_native_syntax_check_binaries' => [PHP_BINARY],
385
386
        // The maximum number of `php --syntax-check` processes to run at any point in time (Minimum: 1).
387
        // This may be temporarily higher if php_native_syntax_check_binaries has more elements than this process count.
388
        'php_native_syntax_check_max_processes' => 4,
389
390
        // blacklist of methods to warn about for HasPHPDocPlugin
391
        'has_phpdoc_method_ignore_regex' => '@^Phan\\\\Tests\\\\.*::(test.*|.*Provider)$@',
392
    ],
393
394
    // A list of plugin files to execute
395
    // NOTE: values can be the base name without the extension for plugins bundled with Phan (E.g. 'AlwaysReturnPlugin')
396
    // or relative/absolute paths to the plugin (Relative to the project root).
397
    'plugins' => [
398
        'AlwaysReturnPlugin',
399
        'DollarDollarPlugin',
400
        'UnreachableCodePlugin',
401
        'DuplicateArrayKeyPlugin',
402
        'PregRegexCheckerPlugin',
403
        'PrintfCheckerPlugin',
404
        'PHPUnitAssertionPlugin',  // analyze assertSame/assertInstanceof/assertTrue/assertFalse
405
        'UseReturnValuePlugin',
406
407
        // UnknownElementTypePlugin warns about unknown types in element signatures.
408
        'UnknownElementTypePlugin',
409
        'DuplicateExpressionPlugin',
410
        // warns about carriage returns("\r"), trailing whitespace, and tabs in PHP files.
411
        'WhitespacePlugin',
412
        ////////////////////////////////////////////////////////////////////////
413
        // Plugins for Phan's self-analysis
414
        ////////////////////////////////////////////////////////////////////////
415
416
        'NoAssertPlugin',
417
418
        'HasPHPDocPlugin',
419
420
        // This should only be enabled if the code being analyzed contains Phan plugins.
421
        // '.phan/plugins/PhanSelfCheckPlugin.php',
422
423
        ////////////////////////////////////////////////////////////////////////
424
        // End plugins for Phan's self-analysis
425
        ////////////////////////////////////////////////////////////////////////
426
427
        // 'SleepCheckerPlugin' is useful for projects which heavily use the __sleep() method.
428
        // InvokePHPNativeSyntaxCheckPlugin invokes 'php --no-php-ini --syntax-check ${abs_path_to_analyzed_file}.php'
429
        // and reports any error messages.
430
        // Using this can cause phan's overall analysis time to more than double.
431
        // 'InvokePHPNativeSyntaxCheckPlugin',
432
433
        // Marks PHPUnit test case subclasses and test cases as referenced code.
434
        // This is only useful for runs when dead code detection is enabled.
435
        'PHPUnitNotDeadCodePlugin',
436
437
        // NOTE: This plugin only produces correct results when
438
        //       Phan is run on a single core (-j1).
439
        // 'UnusedSuppressionPlugin',
440
    ],
441
];
442