我正在使用 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)