Home > database >  Undefined type 'Psr\Log\LoggerInterface'
Undefined type 'Psr\Log\LoggerInterface'

Time:12-22

I am looking for a solution to this problem i use php 7.4 , this error in SMTP.php in phpMailer folder my code :

 //Is this a PSR-3 logger?
    if ($this->Debugoutput instanceof \Psr\Log\LoggerInterface) {
        $this->Debugoutput->debug($str);
        return;
    }

this error : Undefined type 'Psr\Log\LoggerInterface

CodePudding user response:

It seems like Visual Studio Code does not see your vendor folder or you dont installed the psr/log package via composer.

try to run the command

composer require psr/log

in order to get the PSR-3 Interfaces

CodePudding user response:

That should not be an error in the first place. When using instanceOf, the class you are checking for dos not need to exist, just as it does not need to exist in use statements either. For example:

$a = 1;
if ($a instanceOf \Cocktails\Gin\Tonic) {
    echo 'true';
} else {
    echo 'false';
}
exit;

This will simply display false, and not generate an error even though the class it's looking for is not defined - it simply means that the instanceOf check will fail for a different reason.

  • Related