类型错误:函数参数太少

时间:2017-10-14 22:27:09

标签: 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',但收到以下错误:

  

类型错误:函数参数太少   EliteFifa \ MatchBundle \ Service \ Mat chService :: __ construct(),2   传入/ home / owner / Desktop / Workspace / EFL / var   /cache/dev/appDevDebugProjectContainer.php在1128行,正好是3   预期

我已经尝试清除缓存,但这也不起作用。

1 个答案:

答案 0 :(得分:0)

尝试将'@=service("form.factory")'替换为'@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'