PSALM:文档块定义 class 或接口不存在

PSALM: Docblock-defined class or interface does not exist

我有以下代码:

namespace Some\Space\Utility;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;

/**
 * @psalm-template T
 */
class SomeAdapter
{
    /**
     * Some method
     *
     * @psalm-param iterable<int, T> $data
     *
     * @psalm-return Collection<int, T>
     */
    public static function doSomething($data): Collection
    {
        if (is_array($data)) {
            $data = new ArrayCollection($data);
        }

        return $data;
    }
}

可能我遗漏了一些东西,但我收到了 @psalm-param 的以下错误:

psalm: UndefinedDocblockClass: Docblock-defined class or interface Some\Space\Utility\T does not exist

问题是函数是静态的。这是正确的解决方案:

    /**
     * Some method
     *
     * @psalm-template T
     * @psalm-param iterable<int, T> $data
     *
     * @psalm-return Collection<int, T>
     */

必须在方法上定义模板。