From c814d40130126e90644de4a805a11eb9aa57428b Mon Sep 17 00:00:00 2001 From: Thomas Baccelli Date: Fri, 26 Jun 2026 16:20:11 +0200 Subject: [PATCH] feat: behat 4.x compatibility --- composer.json | 2 +- features/bootstrap/MathsContext.php | 15 ++++++--------- src/Controller/Cli/CodeCoverageController.php | 3 ++- src/Extension.php | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 2397591..575f3d5 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "require": { "php": "^8.3", "composer-runtime-api": "^2.0", - "behat/behat": "^3.27", + "behat/behat": "^3.27||^4.0", "composer/semver": "^3.0", "phpunit/php-code-coverage": "^12.3||^13.0||^14.0", "symfony/config": "^5.4.45||^6.4.24||^7.3", diff --git a/features/bootstrap/MathsContext.php b/features/bootstrap/MathsContext.php index 88ac633..c4a54df 100644 --- a/features/bootstrap/MathsContext.php +++ b/features/bootstrap/MathsContext.php @@ -5,6 +5,9 @@ declare(strict_types=1); use Behat\Behat\Context\Context; +use Behat\Step\Given; +use Behat\Step\Then; +use Behat\Step\When; use PHPUnit\Framework\Assert; class MathsContext implements Context @@ -15,26 +18,20 @@ class MathsContext implements Context private $result; - /** - * @Given /^I have two variables A=(\d+) and B=(\d+)$/ - */ + #[Given('/^I have two variables A=(\d+) and B=(\d+)$/')] public function iHaveTwoVariablesAAndB(int $a, int $b): void { $this->a = $a; $this->b = $b; } - /** - * @When /^I add A and B$/ - */ + #[When('/^I add A and B$/')] public function iAddAAndB(): void { $this->result = $this->a + $this->b; } - /** - * @Then /^the result should be (\d+)$/ - */ + #[Then('/^the result should be (\d+)$/')] public function theResultShouldBe(int $arg1): void { Assert::assertEquals($arg1, $this->result); diff --git a/src/Controller/Cli/CodeCoverageController.php b/src/Controller/Cli/CodeCoverageController.php index 52bef4a..aaf1b5f 100644 --- a/src/Controller/Cli/CodeCoverageController.php +++ b/src/Controller/Cli/CodeCoverageController.php @@ -22,7 +22,8 @@ public function configure(Command $command): void /** * @codeCoverageIgnore */ - public function execute(InputInterface $input, OutputInterface $output): void + public function execute(InputInterface $input, OutputInterface $output): ?int { + return null; } } diff --git a/src/Extension.php b/src/Extension.php index 71bc9e2..9341cb2 100644 --- a/src/Extension.php +++ b/src/Extension.php @@ -204,7 +204,7 @@ public function configure(ArrayNodeDefinition $builder): void ->end(); } - public function getConfigKey() + public function getConfigKey(): string { return 'code_coverage'; }