doudunyi3796 2012-08-06 09:57
浏览 11

在另一个特征和类中引用相同的特征

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 in MinkDictionary 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条回答 默认 最新

  • doudou3213 2012-08-08 20:37
    关注

    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

    评论

报告相同问题?

悬赏问题

  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)