2017-09-28 43 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的教條/原則 - 通用庫的問題