Having the following:
$a = array(1,2,3);
foreach($a as $b)
{
// ...
}
In the above code, PHP Tools is capable of detecting $b as being type int.
In more complex scenarios, it isn't.
I've tried to use PHPDoc syntax in different locations with no success. Consider this more realistic scenario:
$it = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($rootDir),
RecursiveIteratorIterator::SELF_FIRST);
/** @var $path SplFileInfo */
foreach($it as $path)
{
// ...
}
Above did not help to get $path recognized as SplFileInfo type. It is still recognized as mixed.
I've also tried
foreach($it as /** @var SplFileInfo */ $path)
{
// ...
}
Or
foreach($it as
/** @var SplFileInfo */
$path
)
{
// ...
}
But PHP Tools still see it as mixed only.
I usually end up with this:
foreach($it as $_path)
{
/** @var SplFileInfo */
$path = $_path;
// ...
}
But having to write this extra PHPDoc comment and the extra variable keeps slowing me down.
Question
Any possibility for me to tell PHP Tools the real data type for $path?