In the code snippet below, I get type hinting on $contactInfo[0], and again on $order.
I would like the same with logger, which is an object of type \Monolog\Logger, accessed as a member of \psr\container\ContainerInterface
I am using PhpStorm which is warning me that Field 'logger' not found in Psr\Container\ContainerInterface
/**
* @param Order $order
* @param ContactInfo[] $contactInfo
* @var Monolog\Logger $this->container->logger
*/
private function buildCreateOrderJSON(Order $order, $contactInfo)
{
try {
$currentDate = new DateTime();
} catch (Exception $e) {
$this->container->logger->addInfo('Some exception', $e->getMessage());
return;
}
$lastName = $contactInfo[0]->getLastName();
$order->getInvoiceNumber();
}
own code, try adding a @var declaration in the interface for the logger var.@var Monolog\Logger $this->container->logger-- this is simply wrong as you cannot typehint 3rd level entity like that. PHPDoc and PhpStorm allows typehinting only 1st level