1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Add consistent array type for predefined constants (#4151)

When running psalm through https://github.com/Roave/infection-static-analysis-plugin, you get a lot of warnings

```
Warning: array_key_exists() expects parameter 2 to be array, null given in /Users/woutersioen/Sites/madewithlove/htaccess/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Sta
tements/Expression/Fetch/ConstFetchAnalyzer.php on line 124
```

This is because the config is instantiated without calling the collectPredefinedConstants method, thus making this a null value.
By adding a default value, we make it not required to call this method before running psalm.
This commit is contained in:
Wouter Sioen 2020-09-07 16:54:29 +02:00 committed by Daniil Gentili
parent 1d4bd84ce4
commit 6db268b56a
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7

View File

@ -550,7 +550,7 @@ class Config
public $after_functionlike_checks = [];
/** @var array<string, mixed> */
private $predefined_constants;
private $predefined_constants = [];
/** @var array<callable-string, bool> */
private $predefined_functions = [];