Monolog v3.4 VS Code Intelliphense persistent 'Expected Type' error

55 views Asked by At

I am trying to use monolog version 3.4 with PHP and taking the simple 'getting started' code from the github description.

Intelliphense on VSCode is complaining about the StreamHandler invocation

This is the code that I am testing:

use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Monolog\Level;

define('APP_ROOT', __DIR__ . DIRECTORY_SEPARATOR);

$log = new Logger('Rachio');
$streamhandler = new StreamHandler(APP_ROOT . 'app.log', Level::Warning);
$log->pushHandler($streamhandler);

$log->info('Foo');
$log->warning('Bar');
$log->error('This is a log error!');

Intelliphense in VSCode gives a warning on the line where "new StreamHandler" is called:

Expected type 'Monolog\Handler\HandlerInterface'. Found 'Monolog\Handler\StreamHandler'.intelephense(1006)

The code runs fine but the intelliphense error won't go away which leaves the file flagged all the time as having a problem.

I have tried Composer dump-autoload and rebuilding the indexes in vscode but they make no difference to the error.

This is on Windows 10 if that may be relevant

Any help would be appreciated

0

There are 0 answers