当我升级Magento 2.4.4时,我将获得弃用的功能:返回composer \ repository \ compositerepository :: count()

发布于 2025-01-23 17:17:09 字数 321 浏览 0 评论 0 原文

当我将Magento 2.4.3升级为2.4.4时,我遇到了php8.1弃用功能错误。

php致命错误:在可数的继承期间:未熟悉的异常:弃用功能:Composer \ Repository \ CompositerePository \ CompositerePository :: Count()应与可计数:: count():int():int():应使用在/var/www/html/vendor/composer/composer/src/composer/repository/repositority/compositerepository.php中暂时抑制通知errirhandler.php:61

When I upgraded Magento 2.4.3 to 2.4.4, I got a php8.1 deprecated functionality error.

PHP Fatal error: During inheritance of Countable: Uncaught Exception: Deprecated Functionality: Return type of Composer\Repository\CompositeRepository::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/vendor/composer/composer/src/Composer/Repository/CompositeRepository.php on line 180 in /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

人疚 2025-01-30 17:17:09

从PHP 8.1开始,您必须修复函数count()的返回类型。我们需要修改2个文件。

将公共功能计数()更改为公共功能count():int

goto => \ vendor \ composer \ composer \ src \ composer \ repository \ arrayrepository.php(第277列)

public function count(): int
{
    if (null === $this->packages) {
        $this->initialize();
    }

    return count($this->packages);
}

goto =>供应商\ composer \ composer \ src \ composer \ copository \ compositerepository.php(第180行)

public function count(): int
{
    $total = 0;
    foreach ($this->repositories as $repository) {
        /* @var $repository RepositoryInterface */
        $total += $repository->count();
    }

    return $total;
}

As of PHP 8.1, you have to fix the return type of the functions count(). We need to modify 2 files.

Change public function count() to public function count(): int

Goto => \vendor\composer\composer\src\Composer\Repository\ArrayRepository.php (line 277)

public function count(): int
{
    if (null === $this->packages) {
        $this->initialize();
    }

    return count($this->packages);
}

Goto => vendor\composer\composer\src\Composer\Repository\CompositeRepository.php (line 180)

public function count(): int
{
    $total = 0;
    foreach ($this->repositories as $repository) {
        /* @var $repository RepositoryInterface */
        $total += $repository->count();
    }

    return $total;
}
尐籹人 2025-01-30 17:17:09

我以这种方式解决了(作曲家2.3.5):

Composer2要求Magento/Composer-root-Update-Plugin〜2.0 -no-update

copser2 Update>使用“使用”

Updating dependencies
Lock file operations: 0 installs, 2 updates, 0 removals
  - Upgrading composer/composer (2.1.0 => 2.2.18)
  - Upgrading magento/composer-root-update-plugin (1.1.2 => 2.0.2)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 2 updates, 0 removals
  - Downloading composer/composer (2.2.18)
Gathering patches for root package.
Gathering patches for dependencies. This might take a minute.
  - Upgrading composer/composer (2.1.0 => 2.2.18): Extracting archive
  - Upgrading magento/composer-root-update-plugin (1.1.2 => 2.0.2): Extracting archive

使用“ require-dev“从Magento 2.4.4 Composer.json

“ require-dev”:{
“诱人的框架/艾尔·帕普尼”:“ 〜1.5.0”,
“ dealerDirect/phpcodesniffer-compososer-installer”:“^0.7.0”,
“ friendsofphp/php-cs-fixer”:“ 〜3.3.0”,
“ lusitanian/oauth”:“ 〜0.8.10”,
“ Magento/Magento编码标准”:“*”,
“ Magento/Magento2功能测试框架”:“^3.7”,
“ pdept/pdepend”:“ 〜2.10.0”,,
“ phpmd/phpmd”:“^2.9.1”,
“ phpstan/phpstan”:“ 〜1.2.0”,,
“ phpunit/phpunit”:“ 〜9.5.0”,,
“塞巴斯蒂安/phpcpd”:“^6.0.3”,
“ Squizlabs/php_codesniffer”:“ 〜3.6.0”,
“ Symfony/Finder”:“^5.2”
}

I solved in this way (by composer 2.3.5):

composer2 require magento/composer-root-update-plugin ~2.0 --no-update

composer2 update

Updating dependencies
Lock file operations: 0 installs, 2 updates, 0 removals
  - Upgrading composer/composer (2.1.0 => 2.2.18)
  - Upgrading magento/composer-root-update-plugin (1.1.2 => 2.0.2)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 2 updates, 0 removals
  - Downloading composer/composer (2.2.18)
Gathering patches for root package.
Gathering patches for dependencies. This might take a minute.
  - Upgrading composer/composer (2.1.0 => 2.2.18): Extracting archive
  - Upgrading magento/composer-root-update-plugin (1.1.2 => 2.0.2): Extracting archive

Using the "require-dev" libs taken from Magento 2.4.4 composer.json https://github.com/magento/magento2/blob/2.4.4/composer.json

"require-dev": {
"allure-framework/allure-phpunit": "~1.5.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
"friendsofphp/php-cs-fixer": "~3.3.0",
"lusitanian/oauth": "~0.8.10",
"magento/magento-coding-standard": "*",
"magento/magento2-functional-testing-framework": "^3.7",
"pdepend/pdepend": "~2.10.0",
"phpmd/phpmd": "^2.9.1",
"phpstan/phpstan": "~1.2.0",
"phpunit/phpunit": "~9.5.0",
"sebastian/phpcpd": "^6.0.3",
"squizlabs/php_codesniffer": "~3.6.0",
"symfony/finder": "^5.2"
}

冷默言语 2025-01-30 17:17:09

只需更新Composer.json带有此包装的JON

"require": {
    "magento/composer-dependency-version-audit-plugin": "~0.1",
    "magento/composer-root-update-plugin": "^2.0",  
},

,还需要使用最新的作曲家矿山(2.3.10)

just update the composer.json with this packages in require

"require": {
    "magento/composer-dependency-version-audit-plugin": "~0.1",
    "magento/composer-root-update-plugin": "^2.0",  
},

Also, Use latest composer mine was ( 2.3.10)

冧九 2025-01-30 17:17:09

不用担心。我面临着Silimar问题,并通过更新作曲家包来解决。

作曲家需要作曲家/作曲家:〜2.2.0 -W

No worries. I was facing silimar issue and fixed by updating the composer package.

composer require composer/composer:~2.2.0 -W

迷途知返 2025-01-30 17:17:09

最有可能的问题是,您尚未将所有Dev-Requires更新到2.4.4的最后一次。事实证明,如果没有更新,则这些锁定作曲家/作曲家模块为2.0.x。

The most likely issue is that you haven't updated all your dev-requires to the lastest from 2.4.4. It turns out these lock the composer/composer module to 2.0.x if they aren't updated.

朱染 2025-01-30 17:17:09

只需将作曲家更新为版本2.3.9-在此版本中,计数方法包含类型

Just update composer to version 2.3.9 - in this version count method contains type

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文