【问题标题】:symfony2 service extends another classsymfony2 服务扩展了另一个类
【发布时间】:2012-11-23 10:26:20
【问题描述】:

在收到新任务之前,我已经写好了班级服务。我需要扩展我的服务..

我有:

namespace Trucking\MainBundle\Service;
use Trucking\MainBundle\classes\Scan;

    class ScanService  {

        public function scan() { 
          // code
        }
    }

我已经升级了服务

namespace Trucking\MainBundle\Service;
use Trucking\MainBundle\classes\Scan;

class ScanService extends Scan\Process\Process  {

    public function scan(Scan\IScanVirtual $virtual) { 
        $virtual->start($this);
    }
}

Services.yml

scan_storage:
  class : Trucking\MainBundle\Service\ScanService
  arguments: [path,container,movetime,checkpoint]

我有一个错误:

message":"运行时注意事项:Trucking\MainBundle\Service
\ScanService::scan() 的声明应与

Trucking\MainBundle\classes\Scan\Process\Process 的声明兼容::scan() 在 C:\webserver\symfony\src\Trucking\MainBundle\Service
\ScanService.php 第 11 行","class":"ErrorException","trace":[{"namespace":" ","short_class":"","class":"","type":"","function":"","

ScanService.php 第 11 行:

ScanService extends Scan\Process\Process

【问题讨论】:

    标签: symfony php


    【解决方案1】:

    ScanService 中的scan() 具有不同数量的Process 参数(或不同的访问级别)。这是纯 PHP,与 Symfony 无关。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-14
      • 2013-04-09
      相关资源
      最近更新 更多