I have a config file that's included in a function, like this:
function getConnection() {
include 'config.php';
return new Connection($config['host']);
}
The issue is to make Psalm recognize the $config
variable from the config file. Possible? Preferable using array shape notation.
Solved by adding a /** @var ...
annotation above the include line:
function getConnection() {
/** @var array{host: string} $config */
include 'config.php';
return new Connection($config['host']);
}