PHP似乎試圖編譯兩次相同的特徵。在另一個特徵和類中引用相同的特徵
use Behat\MinkExtension\Context\MinkDictionary;
class FeatureContext
{
use MinkDictionary, OrderDictionary;
}
use Behat\MinkExtension\Context\MinkDictionary;
trait OrderDictionary
{
//if you comment out this line, everything works, but methodFromMinkTrait is
//unresolved
use MinkDictionary;
public function myMethod($element, $text)
{
//some method that uses methods from MinkDictionary
return $this->methodFromMinkTrait();
}
}
編譯失敗了致命錯誤:
Fatal error: Trait method setMink has not been applied, because there are collisions with other trait methods on LunchTime\DeliveryBundle\Features\Context\FeatureContext
setMink
method is only defined inMinkDictionary
trait.
的問題是,無論OrderDictionary
和FeatureContext
利用MinkDictionary
方法。這就是爲什麼我在OrderDictionary
中加入use MinkDictionary
。這是不允許的?如果你評論這一點,那麼一切正常,但編輯正在展示許多未解決的方法 - 它不知道它們來自哪裏。
去掉「使用MinkDictionary」聲明所有你想知道的特徵都是在這裏:http://www.xpertdeveloper.com/2011/11/trait-in-php/ – jrfish 2012-08-08 20:41:53