问题
PHP seems to be trying to compile the same trait twice.
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();
}
}
The compilation fails with a Fatal Error:
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.
The problem is that both OrderDictionary
and FeatureContext
are using methods from MinkDictionary
. That's why I added use MinkDictionary
in OrderDictionary
. Is this not allowed? If you comment that out, then everything works, but the editor is showing a lot of unresolved methods - it doesn't know where they are coming from.
回答1:
of course it compiles the same trait twice, because you "use" MinkDictionary twice in class FeatureContext - first in the class itself and second via OrderDictionary.
just remove the "use MinkDictionary" statement from the FeatureContext class
来源:https://stackoverflow.com/questions/11826064/referencing-the-same-trait-in-another-trait-and-class