小编Chr*_*ois的帖子

Visual Studio Code PHP Intelephense 收到错误

我正在使用 Visual Studio Code 和 Intelephense 处理一个 Symfony 4 项目。

Intelephense 得到的错误不是。有一些例子:

未定义的方法 'uasort'。

此错误对应于此代码:

// Collection creation of seasons used in the periods 
$seasons = new ArrayCollection();
$sortedSeasons = new ArrayCollection();
    
//Search seasons used by periods
foreach ($advert->getPeriods() as $period) 
{
    $season = $period->getSeason();
    if (! $seasons->contains($season)) 
    {
        $seasons->add($season);
    }
}
    
// Sort seasons by ascending cost 
$iterator = $seasons->getIterator();
$iterator->uasort(function ($a, $b) {
    return $a->getCost() <=> $b->getCost();
});
Run Code Online (Sandbox Code Playgroud)

另一个例子:

未定义的方法“getAdvertMinPrice”。

$minPrices = $this->getDoctrine()->getRepository(Price::class)->getAdvertMinPrice($advert);
Run Code Online (Sandbox Code Playgroud)

但是,该方法存在于 PriceRepository 中:

<?php
namespace …
Run Code Online (Sandbox Code Playgroud)

php error-handling symfony4

7
推荐指数
3
解决办法
1万
查看次数

标签 统计

error-handling ×1

php ×1

symfony4 ×1