With .phpstorm.meta.php
you can overwrite the return type of your class methods. For example:
// .phpstorm.meta.php
namespace PHPSTORM_META
{
$STATIC_METHOD_TYPES = [
\Acme\Node::closest('') => [
"" == "@",
],
];
}
The example above lets PhpStorm understand the return of $node->closest(SomeNodeType::class)
is an instance of SomeNodeType
.
However, my question is how to make PhpStorm understand that a function returns an array of instances of a given type.
For example:
$node->findAllOfType(SomeNodeType::class)
would return an array of SomeNodeType
instances (normally one would use SomeNodeType[]
if it would not be dynamic).
Attempts to use "@[]"
or "@Iterator"
instead of "@"
, in the above code example, failed.
答案 0 :(得分:2)
那只是not supported ...除非您可以尝试手动列出所有可能的类型而不是使用单一通用规则(可能在理论上工作 - 抱歉,我自己没试过。)
https://youtrack.jetbrains.com/issue/WI-27832 - 观看相关的门票(星级/投票/评论)以获得有关任何进展的通知。