How to setup for array associated with object?
dexcell opened this issue · 2 comments
Hi,
I have a var called $app
, its a class \Silex\Application
that implements ArrayAccess
.
then inside that $app
array there is twig
key which is an object of \Twig\Environment
So in source code i use it like this
$app['twig']->render('stuff');
How to enable auto completion for $app['twig']
to show render
function?
How to setup this in .phpstorm.meta.php
?
Thanks
Hi. ArrayAccess
completion is not supported.
See #102
Need a PR or something for this feature.
You could possibly trick the plugin into thinking that $app
is an associative array by doing something like this:
/** @var $app = ['twig' => new \Twig\Environment()] */
$app = new \Silex\Application();
The plugin will consider $app
type a union of associative array and class instance in such case if I remember right how it works.
This PSALM annotation should probably work as well:
/** @var \Silex\Application|array{twig: \Twig\Environment} $app */
$app = something();