You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
$environment->getContext triggers the Psalm issue UndefinedInterfaceMethod #141
the PHPStorm issue "Potentially polymorphic call. The code may be inoperable depending on the actual class instance passed as the argument"
Indeed, the method getContext() is not necessarily present in every possible Environment interface implementation since it is not declared in this interface. Actually it is declared in InitializedContextEnvironment only.
This might be solved by improving types based on the different scopes. The BeforeScenarioScope is guaranteed to get an environment implementing Behat\Behat\Context\Environment\ContextEnvironment, and I think even an InitializedContextEnvironment for that one (for BeforeSuite, that might not be an InitializedContextEnvironment, but it would still be a ContextEnvironment)
getContext public method is available only in specific ContextEnvironment implementations as it's not listed on the interface. FriendsOfBehat/SymfonyExtension implements that interface as well and provides getContext method additionally, but there's still no guarantee any other implementation will have that method.
Activity
stof commentedon Sep 22, 2021
This might be solved by improving types based on the different scopes. The
BeforeScenarioScopeis guaranteed to get an environment implementingBehat\Behat\Context\Environment\ContextEnvironment, and I think even an InitializedContextEnvironment for that one (forBeforeSuite, that might not be an InitializedContextEnvironment, but it would still be a ContextEnvironment)pamil commentedon Dec 13, 2021
getContextpublic method is available only in specificContextEnvironmentimplementations as it's not listed on the interface.FriendsOfBehat/SymfonyExtensionimplements that interface as well and providesgetContextmethod additionally, but there's still no guarantee any other implementation will have that method.