[英]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
出現以下錯誤:
詩篇:UndefinedDocblockClass:Docblock 定義的類或接口 Some\\Space\\Utility\\T 不存在
問題是該函數是靜態的。 這是正確的解決方案:
/**
* Some method
*
* @psalm-template T
* @psalm-param iterable<int, T> $data
*
* @psalm-return Collection<int, T>
*/
模板必須在方法上定義。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.