Issues (28)

.phan/config.php (1 issue)

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