Method not found in class e.g. Doctrine DBAL
Hi
I am getting Method not found errors when using Silex in PHPStorm. This is primarily
occurring fro Class methods where an instance of the class is accessed from a closure
or stored in an appliaction variable.
For example $app['db'] references an instance of the Doctrine DBAL connection.
If I use $app['db']->prepare($sql); in my code the call to prepare is flagged as
Method not found in class. Is there a way to make PHPStorm recognize that "prepare()"
is a method of the Doctrine DBAL. I have tried including use statements for the
Silex DoctrineServiceProvider and Doctrine DBAL classes but the classes remain greyed out
in the use statement.
DaveC49?:|
请先登录再写评论。
Hi there,
1) IDE does not know what type each of the array elements are. In other words -- IDE does not know that $app['db'] is an instance of Doctrine DBAL
2) ATM you *cannot* give type hint for individual array keys. You can only do it to ordinary variables or class fields, which is rather inconvenient, e.g.
Similar SO question: http://stackoverflow.com/a/14636723/783119
Thanks Andriy,
I suspected that would be the case but there is always hope.