2017-09-28 41 views
1

我与php7.1的新功能,允许在一个项目的Symfony 3返回可空类型的工作,但我有一个实体使用此当一个问题:PHP 7.1学说代理发行可空类型

<?php 
// .... 
public function getCreatedBy(): ?string 
{ 
    return $this->createdBy; 
} 

当我使用这个功能我有这样的错误:

Type error: Return value of 
Proxies\\__CG__\\NS\\ModulesBundle\\Entity\\Account::getCreatedBy() 
must be of the type string, null returned 

我抽放一脸的类与Symfony的自动生成的代码,我发现这一点:

<?php 
// ... 
public function getCreatedBy(): string 
{ 

    $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCreatedBy', []); 

    return parent::getCreatedBy(); 
} 

如您所见,该类型不可为空。

有人可以帮助我吗?谢谢

+0

您是否清除了缓存? – svgrafov

+0

是的,我清除了缓存 –

+1

这是与学说相关的问题,而不是Symfony本身。 –

回答

1

我修正了从版本2.6升级到版本2.8的教条/原则 - 通用库的问题