簡體   English   中英

PSALM:Docblock 定義的類或接口不存在

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM