0

我正在尝试将 2019 年开发的现有 dockerized Symfony 项目从 4.4.19/PHP7 更新到 4.4.37/PHP8

因此,我使用 Symfony4 的最新版本创建了一个新的空项目,并安装了所有第三方包,所以我确信我会得到每个包的最新版本。

当我运行一个执行一些 ES 调用的控制器时,我有这个错误:

App\Elasticsearch\Moteur::__construct(): Argument #3 ($paginateur) must be of type 
Knp\Component\Pager\Paginator, PaginatorInterface_82dac15 given, 
called in /app/var/cache/dev/ContainerHcDzXdA/getMoteurService.php on line 11

这是 sevices.yaml :

...
services:
    App\Elasticsearch\Moteur:
        autowire: false
        arguments:
            - '@fos_elastica.finder.ass_etablissement.etablissement'
            - '@fos_elastica.index.ass_etablissement.etablissement'
            - '@knp_paginator'
            - '@session'
...

这是 Moteur 类的构造函数:

namespace App\Elasticsearch;

use Knp\Component\Pager\Paginator;
...
final class Moteur
{
    ...
    public function __construct(
        TransformedFinder $finder,
        Type $index,
        Paginator $paginateur,
        SessionInterface $session
    ) {
        $this->finder = $finder;
        $this->index = $index;
        $this->paginateur = $paginateur;
        $this->session = $session;
    }

我不明白为什么错误消息在谈论 PaginatorInterface !

我认为这是一个捆绑版本的问题,但找不到我应该更新什么,我应该使用女巫版本!

这是更新之前的旧 composer.json:

"require": {
        "php": "^7.1.3",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "beberlei/doctrineextensions": "^1.0",
        "cocur/slugify": "^3.0",
        "cravler/maxmind-geoip-bundle": "dev-master",
        "doctrine/doctrine-bundle": "^1.6.10",
        "doctrine/orm": "^2.5.11",
        "eightpoints/guzzle-bundle": "^7.2",
        "fig/link-util": "^1.1",
        "friendsofsymfony/ckeditor-bundle": "^2.0",
        "friendsofsymfony/elastica-bundle": "^5.0",
        "friendsofsymfony/jsrouting-bundle": "^2.1",
        "gemorroj/archive7z": "^4.0",
        "geocoder-php/chain-provider": "^4.0",
        "geocoder-php/free-geoip-provider": "^4.0",
        "geocoder-php/geo-plugin-provider": "^4.0",
        "geocoder-php/host-ip-provider": "^4.0",
        "geocoder-php/nominatim-provider": "^4.1",
        "gregurco/guzzle-bundle-cache-plugin": "^1.0",
        "jaybizzle/crawler-detect": "^1.2",
        "knplabs/knp-gaufrette-bundle": "^0.7.1",
        "knplabs/knp-paginator-bundle": "^2.7",
        "knplabs/knp-time-bundle": "^1.8",
        "league/csv": "^9.1",
        "league/flysystem-sftp": "^1.0",
        "liip/imagine-bundle": "^2.3",
        "mjaschen/phpgeo": "^2.0",
        "oro/doctrine-extensions": "^1.3",
        "php-http/guzzle6-adapter": "^1.1",
        "php-http/message": "^1.6",
        "phpoffice/phpspreadsheet": "^1.17",
        "predis/predis": "^1.1",
        "presta/sitemap-bundle": "^1.5",
        "sensio/framework-extra-bundle": "^5.1",
        "sensiolabs/security-checker": "^4.1",
        "snc/redis-bundle": "^2.0",
        "stof/doctrine-extensions-bundle": "^1.3",
        "symfony/asset": "*",
        "symfony/config": "4.4.*",
        "symfony/console": "*",
        "symfony/flex": "^1.1",
        "symfony/form": "*",
        "symfony/framework-bundle": "*",
        "symfony/lock": "*",
        "symfony/monolog-bundle": "^3.2",
        "symfony/proxy-manager-bridge": "*",
        "symfony/security-bundle": "*",
        "symfony/swiftmailer-bundle": "^3.2",
        "symfony/twig-bundle": "*",
        "symfony/validator": "*",
        "symfony/web-link": "4.4.*",
        "symfony/webpack-encore-bundle": "^1.0",
        "symfony/yaml": "*",
        "twig/extensions": "^1.5",
        "vich/uploader-bundle": "^1.8",
        "willdurand/geocoder-bundle": "^5.1",
        "zendframework/zend-feed": "^2.9"
    }
...

这是更新后的新版本:

"require": {
        "php": ">=7.1.3",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "beberlei/doctrineextensions": "^1.3",
        "cocur/slugify": "^4.1",
        "doctrine/annotations": "^1.0",
        "doctrine/doctrine-bundle": "^2.5",
        "doctrine/doctrine-migrations-bundle": "^3.2",
        "doctrine/orm": "^2.11",
        "eightpoints/guzzle-bundle": "^8.3",
        "fig/link-util": "^1.1",
        "friendsofsymfony/ckeditor-bundle": "^2.4",
        "friendsofsymfony/elastica-bundle": "5.*",
        "friendsofsymfony/jsrouting-bundle": "^2.8",
        "gemorroj/archive7z": "^5.3",
        "geocoder-php/chain-provider": "^4.4",
        "geocoder-php/free-geoip-provider": "^4.4",
        "geocoder-php/geo-plugin-provider": "^4.2",
        "geocoder-php/host-ip-provider": "^4.3",
        "geocoder-php/nominatim-provider": "^5.5",
        "jaybizzle/crawler-detect": "^1.2",
        "knplabs/knp-gaufrette-bundle": "^0.7.1",
        "knplabs/knp-paginator-bundle": "^5.8",
        "knplabs/knp-time-bundle": "^1.18",
        "league/csv": "^9.7",
        "league/flysystem-sftp": "^2.4",
        "liip/imagine-bundle": "^2.7",
        "mhujer/breadcrumbs-bundle": "^1.5",
        "mjaschen/phpgeo": "^4.0",
        "nyholm/psr7": "^1.5",
        "oro/doctrine-extensions": "^2.0",
        "php-http/guzzle6-adapter": "^2.0",
        "php-http/message": "^1.13",
        "phpdocumentor/reflection-docblock": "^5.3",
        "phpoffice/phpspreadsheet": "^1.22",
        "predis/predis": "^1.1",
        "presta/sitemap-bundle": "^3.3",
        "sensio/framework-extra-bundle": "^6.2",
        "sensiolabs/security-checker": "^6.0",
        "snc/redis-bundle": "^3.6",
        "stof/doctrine-extensions-bundle": "^1.7",
        "symfony/asset": "4.4.*",
        "symfony/config": "4.4.*",
        "symfony/console": "4.4.*",
        "symfony/dotenv": "4.4.*",
        "symfony/expression-language": "4.4.*",
        "symfony/flex": "^1.18",
        "symfony/form": "4.4.*",
        "symfony/framework-bundle": "4.4.*",
        "symfony/http-client": "4.4.*",
        "symfony/intl": "4.4.*",
        "symfony/lock": "4.4.*",
        "symfony/mailer": "4.4.*",
        "symfony/monolog-bundle": "^3.7",
        "symfony/process": "4.4.*",
        "symfony/property-access": "4.4.*",
        "symfony/property-info": "4.4.*",
        "symfony/proxy-manager-bridge": "4.4.*",
        "symfony/security-bundle": "4.4.*",
        "symfony/serializer": "4.4.*",
        "symfony/swiftmailer-bundle": "^3.5",
        "symfony/translation": "4.4.*",
        "symfony/twig-bundle": "4.4.*",
        "symfony/validator": "4.4.*",
        "symfony/web-link": "4.4.*",
        "symfony/webpack-encore-bundle": "^1.14",
        "symfony/yaml": "4.4.*",
        "twig/extra-bundle": "^3.3",
        "twig/twig": "2.14.11",
        "vich/uploader-bundle": "^1.19",
        "willdurand/geocoder-bundle": "^5.16"
    }
...
4

1 回答 1

0

我像这样更改了 __constructor:

...
use Knp\Component\Pager\PaginatorInterface;
...
    public function __construct(
...
        PaginatorInterface $paginateur,

就是这样!

但是我还是不明白原因!!

PS:更新 symfony/dependency-injection 后出现此错误

于 2022-02-25T17:41:41.343 回答