Meta override for psr-11 container based on classes (not constants)
After a while dealing around with the advanced metadata I give up and ask you for helping me out.
Instead of using a constant (which works perfectly) I try to use the class-attribute as the key. So my .phpstorm.meta.php looks like this:
<?php
namespace PHPSTORM_META {
override(\Psr\Container\ContainerInterface::get(),
map([
\Logger::class => \Psr\Log\LoggerInterface::class,
'' => '@Class' ])
);
}
The code inside my script is:
$this->container->get(\Logger::class)->info('foobar');
$this->container implements the PSR Container Interface and this works well. But the \Logger::class seems not to be a valid key for the IDE. Instead of receiving the list of functions from the LoggerInterface, there is nothing.
I know that I could easily use an additional variable to my file-scope (where I use the get-method) in my code as a workaround. But this looks not so charming to me knowing, that PHPStorm is supporting constants and not so complex cases.
Please sign in to leave a comment.
Hi there,
If I'm getting it all correctly then it's https://youtrack.jetbrains.com/issue/WI-51632 which is not yet supported.
Please watch that ticket (star/vote/comment) to get notified on any progress.
Thanks for helping. The workaround works ;)