php - 类型错误 : Too few arguments to function

标签 php symfony symfony-3.2

services.yml 位于 src/EliteFifa/MatchBundle/Resources/services.yml

parameters:
    # repositories
    match_repository.class:             EliteFifa\MatchBundle\Repository\MatchRepository
    match_repository.factory_argument:  'MatchBundle:Match'

# services
match_service.class:                EliteFifa\MatchBundle\Service\MatchService

services:
    # services
    elite_fifa.match_service:
        class: %match_service.class%
        arguments:
          - '@elite_fifa.match_repository'
          - '@=service("form.factory")'
          - '@elite_fifa.standing_service'

.

class MatchService
{
    /**
     * @var MatchRepository
     */
    private $matchRepository;

    /**
     * @var FormFactory
     */
    private $formFactory;

    /**
     * @var StandingService
     */
    private $standingService;

    /**
     * @param MatchRepository $matchRepository
     * @param FormFactory $formFactory
     * @parma StandingService $standingService
     */
    public function __construct(
        MatchRepository $matchRepository,
        FormFactory $formFactory,
        StandingService $standingService)
    {
        $this->matchRepository = $matchRepository;
        $this->formFactory = $formFactory;
        $this->standingService = $standingService;
    }

Symfony 突然停止识别其他参数,我添加了 - '@elite_fifa.standing_servicee' 但出现以下错误:

Type error: Too few arguments to function EliteFifa\MatchBundle\Service\Mat chService::__construct(), 2 passed in /home/owner/Desktop/Workspace/EFL/var /cache/dev/appDevDebugProjectContainer.php on line 1128 and exactly 3 expected

我试过清除缓存,但也没用。

最佳答案

尝试用'@form.factory'替换'@=service("form.factory")'

parameters:
    # repositories
    match_repository.class:             EliteFifa\MatchBundle\Repository\MatchRepository
    match_repository.factory_argument:  'MatchBundle:Match'

# services
match_service.class:                EliteFifa\MatchBundle\Service\MatchService

services:
    # services
    elite_fifa.match_service:
        class: %match_service.class%
        arguments:
          - '@elite_fifa.match_repository'
          - '@form.factory'
          - '@elite_fifa.standing_service'

关于php - 类型错误 : Too few arguments to function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46749928/

相关文章:

symfony - FOS/用户 bundle ProxyManager\配置错误

php - Mac OS X 上的 php.ini 文件配置

php - 在 Laravel 中解密在 MySQL 中使用 AES_ENCRYPT 加密的数据

symfony - Doctrine (Symfony 2.0.x) createBuilder 一对多 - 不知道如何获取正确的实体

php - 在 Symfony2 中直接使用库而不是包

php - "assets"下无法识别的选项 "framework",symfony 3

PHP 在 If/Else 中回显 MySQL 值

php - 将 php 回显到 google map javascript

symfony - Sulu:添加新的locatlistation导致权限错误

symfony - 使用 NormalizerAwareTrait 的 Normalizer 空引用