-
-
Notifications
You must be signed in to change notification settings - Fork 612
Description
Behat has full support for PHP 8 Attributes since version 3.10.0.
For example, this means that instead of
/**
* @Given something
*/
public function something() {}
it is now possible to write
#[Given('something')]
public function something() {}
and the same goes for When, Then and all hooks (BeforeScenario et al).
However, when generating snippets1 Behat will use Annotations instead of Attributes.
Behat should be able to generate snippets using Attributes instead of Annotions when applicable (ie on PHP >= 8). Note that when generating a snippet with an Attribute that Attribute should also be used in the class where it's added, otherwise it won't work.
Since Behat supports PHP7.2+ at the time of writing it still needs to support generating snippets with Annotations, but it could default to Attributes when PHP >=8 is detected for example. This could also be an option, but I'm unsure if that is worth it. It feels like something that would be OK te enforce, since the entire ecosystem is moving away from Annotations to Attributes anyway. Curently features/snippets.feature tests for output with Annotations. Those scenarios could be run with a new tag @php7 similar to the already existing @php8 to prevent them from being checked on PHP8. And then the same scenarios but updated using attributes could be added with @php8 tags.
1 A snippet can be generated when at the end of a run Behat has detected undefined steps. It can add a skeleton of the step to a feature context.