Reputation: 73231
I have this code and get an error reported for the two "undefined" variables
$tables = [
'foo',
'bar',
'baz'
];
foreach ($tables as $table) {
$$table = $this->setUpTables($table, $prefix);
}
$all = $this->getBaz($foo,$bar); // those two are reported as undefined
Is it possible to tell PhpStorm to not report this "error"?
EDIT:
/** @var foo $foo */
/** @var bar $bar */
$all = $this->getBaz($foo,$bar);
Upvotes: 2
Views: 350
Reputation: 14329
Using simpler language features wins in this case, I think. PhpStorm should also have no trouble figuring out which variables are in scope.
$products = $this->setUpTables('products', $prefix);
$excludeRules = $this->setUpTables('excludeRules', $prefix);
$excludedSellers = $this->setUpTables('excludedSellers', $prefix);
$livePricing = $this->setUpTables('livePricing', $prefix);
$all = $this->getProducts($products, $livePricing);
If PhpStorm thinks a variable is out of scope when it is not, you can add this declaration within the scope.
/** @var variableName */
Upvotes: 4