PHP7致命错误:......的声明必须兼容

时间:2016-08-22 10:45:47

标签: neo4j php-7

我已经安装了PHP 7,并且已经设置了https://github.com/graphaware/reco4php的演示示例,但是遇到了以下错误。我对PHP 7不太熟悉,有人能帮帮我吗?

Fatal error: Declaration of GraphAware\Reco4PHP\Demo\Github\RecommendationEngine::discoveryEngines() must be compatible with GraphAware\Reco4PHP\Engine\RecommendationEngine::discoveryEngines(): array in /var/www/html/reco-fresh/_demo/github/RecommendationEngine.php on line 5

类: RecommendationEngine.php包含以下代码 -

namespace GraphAware\Reco4PHP\Demo\Github;

class RecommendationEngine extends \GraphAware\Reco4PHP\Engine\BaseRecommendationEngine
{
    public function discoveryEngines()
    {
        return array(
            new FollowedByFollowers(),
            new SameContribution()
        );
    }    
}

界面: RecommendationEngine

namespace GraphAware\Reco4PHP\Engine;

use GraphAware\Common\Type\Node;
use GraphAware\Reco4PHP\Context\Context;
use GraphAware\Reco4PHP\Persistence\DatabaseService;

interface RecommendationEngine
{
    public function name() : string;

    public function discoveryEngines() : array;
}

抽象类: - BaseRecommendationEngine

namespace GraphAware\Reco4PHP\Engine;

use GraphAware\Reco4PHP\Context\Context;
use GraphAware\Reco4PHP\Executor\RecommendationExecutor;
use GraphAware\Reco4PHP\Filter\BlackListBuilder;
use GraphAware\Reco4PHP\Filter\Filter;
use GraphAware\Reco4PHP\Persistence\DatabaseService;
use GraphAware\Common\Type\Node;
use GraphAware\Reco4PHP\Post\PostProcessor;
use GraphAware\Reco4PHP\Result\Recommendations;
use Psr\Log\LoggerInterface;

abstract class BaseRecommendationEngine implements RecommendationEngine
{
    private $databaseService;

    private $recommendationExecutor;

    public function discoveryEngines() : array
    {
        return array();
    }
}

1 个答案:

答案 0 :(得分:0)

您可以在此处找到问题的答案:Neo4j - Graphaware reco4php - Problem with namespaces

扩展类时,应在函数定义后指定“返回”的类型:

public function name() : string 
{
return "rated_by_others";
}