當我將 Magento 2.4.3 升級到 2.4.4 時,出現 php8.1 deprecated 功能錯誤。
PHP 致命錯誤:在 Countable 繼承期間:未捕獲的例外:不推薦使用的功能:Composer\Repository\CompositeRepository::count() 的回傳型別應該與 Countable::count(): int 或 #[\ReturnTypeWillChange] 屬性兼容應該用于暫時抑制 /var/www/html/vendor/magento/framework/App/ 中第 180 行的 /var/www/html/vendor/composer/composer/src/Composer/Repository/CompositeRepository.php 中的通知錯誤處理程式.php:61
uj5u.com熱心網友回復:
從 PHP 8.1 開始,您必須修復函式 count() 的回傳型別。我們需要修改2個檔案。
將 public function count() 更改為 public function count(): int
轉到 => \vendor\composer\composer\src\Composer\Repository\ArrayRepository.php(第 277 行)
public function count(): int
{
if (null === $this->packages) {
$this->initialize();
}
return count($this->packages);
}
Goto => vendor\composer\composer\src\Composer\Repository\CompositeRepository.php(第 180 行)
public function count(): int
{
$total = 0;
foreach ($this->repositories as $repository) {
/* @var $repository RepositoryInterface */
$total = $repository->count();
}
return $total;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/476727.html
