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