Using a Behat sub-context class I need to call a method from the main context, e.g. $this->getMainContext()->fooBar()
. PhpStorm quite reasonably warns me that fooBar()
doesn't exist, because it expects getMainContext()
to return an ExtendedContextInterface
, not my concrete FeatureContext
.
Is there a way to annotate my sub-class to tell PhpStorm that getMainContext()
actually returns my concrete class?
One solution is to override getMainContext()
just to have a method on which to add my own PHPDoc, thus specifying a different return type, but adding a method just to get nicer code sense in an IDE is horrid.
BTW, I know this is all a bit hacky and that theoretically my sub-context shouldn't depend upon my main context having a particular concrete implementation; in reality though Behat doesn't make that practical.