Inspections say: Method ... not found, but why?

Hello

In normal cases this is right. But in the follow-thing is a problem to display this:
$ldbl = new $lctable();
$ladata = $ldbl->getOneWhere($pcfield." = '".$pcvalue."'"); // > getOnwWhere not  found (can i set to off to check this?)

Anybody have an idea?

2 comments

Hi Raffael,

Inspections say: Method ... not found, but why?

What do you mean "why"?

This is your code: $ldbl = new $lctable(); -- you are creating instance of UNKNOWN (to me and IDE) class -- you are creating it via variable instead of providing class name directly. There is nothing wrong with this -- just IDE is not THAT advanced to interpret such situations (especially if value of such variable is set during runtime only). During runtime it works just fine (the nature of PHP), but how should I or PhpStorm know what class should be there?

The solution -- add typehint via PHPDoc comment for that local variable, for example:

/** @var MyTable $ldbl */

$ldbl = new $lctable();

0

Yes this is that what i search :)

Thanks for help.

0

Please sign in to leave a comment.