Skip to content

Convert Behat annotations to PHP attributes in Hybrid contexts#18833

Merged
TheMilek merged 1 commit intoSylius:2.3from
loic425:behat-annotations-to-attributes/hybrid
Feb 18, 2026
Merged

Convert Behat annotations to PHP attributes in Hybrid contexts#18833
TheMilek merged 1 commit intoSylius:2.3from
loic425:behat-annotations-to-attributes/hybrid

Conversation

@loic425
Copy link
Copy Markdown
Member

@loic425 loic425 commented Feb 17, 2026

Q A
Branch? 2.3
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Related tickets partially #18822
License MIT

Summary by CodeRabbit

  • Refactor
    • Modernized internal test infrastructure by updating step definitions to use PHP 8 attributes, improving code organization and maintainability.

@loic425 loic425 requested review from a team as code owners February 17, 2026 12:48
@loic425 loic425 mentioned this pull request Feb 17, 2026
27 tasks
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 17, 2026

📝 Walkthrough

Walkthrough

This PR migrates Behat step definitions from docblock annotations to PHP 8 attributes across two test context files. Added imports for Behat\Step\When and Behat\Step\Given, and converted three method annotations from docblock format to modern attribute syntax without altering any functional logic.

Changes

Cohort / File(s) Summary
Behat Step Attribute Migration
src/Sylius/Behat/Context/Hybrid/Setup/CartContext.php
Migrated two @When docblock annotations to PHP 8 #[When()] attributes on iAddProductToTheCartOnTheWebStore() and iCheckItemsInMyCartUsingAPI() methods; added Behat\Step\When import.
Behat Step Attribute Migration
src/Sylius/Behat/Context/Hybrid/Setup/SecurityContext.php
Migrated one @Given docblock annotation to PHP 8 #[Given()] attribute on IAmALoggedInCustomerOnTheApiAndTheUi() method; added Behat\Step\Given import.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

Suggested labels

Maintenance

Suggested reviewers

  • TheMilek
  • GSadee

Poem

🐰 From docblocks old to attributes bright,
The Behat steps now shine with modern light,
PHP 8 brings clarity and grace,
No logic changes, just a cleaner place,
Hopping forward, one refactor at a time! 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: converting Behat annotations from docblocks to PHP 8 attributes in Hybrid context files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 17, 2026

❗ Preview Environment delete from Bunnyshell failed

Check https://github.com/Sylius/Sylius/actions/runs/22131510547 for details.

See: Environment Details

Available commands:

  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/Sylius/Behat/Context/Hybrid/Setup/SecurityContext.php (1)

16-17: Imports are not sorted alphabetically.

Same issue as in CartContext.phpBehat\Behat\Context\Context should come before Behat\Step\Given.

Proposed fix
-use Behat\Step\Given;
 use Behat\Behat\Context\Context;
+use Behat\Step\Given;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type (classes, functions, constants)".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Sylius/Behat/Context/Hybrid/Setup/SecurityContext.php` around lines 16 -
17, Reorder the PHP use imports in SecurityContext so they are alphabetized and
grouped by type: place Behat\Behat\Context\Context before Behat\Step\Given
(i.e., swap the two use statements), matching the same import ordering fix
applied in CartContext.php and following the project's "classes first,
alphabetized" guideline.
src/Sylius/Behat/Context/Hybrid/Setup/CartContext.php (1)

16-17: Imports are not sorted alphabetically.

Behat\Behat\Context\Context should precede Behat\Step\When lexicographically.

Proposed fix
-use Behat\Step\When;
 use Behat\Behat\Context\Context;
+use Behat\Step\When;

As per coding guidelines: "Sort PHP use imports alphabetically and group by type (classes, functions, constants)".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Sylius/Behat/Context/Hybrid/Setup/CartContext.php` around lines 16 - 17,
The import statements are out of alphabetical order: move the
Behat\Behat\Context\Context import so it comes before Behat\Step\When (and
ensure all other `use` statements in CartContext.php are alphabetized and
grouped by type), e.g., reorder the `use` lines in the top of the file so class
imports are sorted lexicographically with `Behat\Behat\Context\Context`
preceding `Behat\Step\When`.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/Sylius/Behat/Context/Hybrid/Setup/CartContext.php`:
- Around line 16-17: The import statements are out of alphabetical order: move
the Behat\Behat\Context\Context import so it comes before Behat\Step\When (and
ensure all other `use` statements in CartContext.php are alphabetized and
grouped by type), e.g., reorder the `use` lines in the top of the file so class
imports are sorted lexicographically with `Behat\Behat\Context\Context`
preceding `Behat\Step\When`.

In `@src/Sylius/Behat/Context/Hybrid/Setup/SecurityContext.php`:
- Around line 16-17: Reorder the PHP use imports in SecurityContext so they are
alphabetized and grouped by type: place Behat\Behat\Context\Context before
Behat\Step\Given (i.e., swap the two use statements), matching the same import
ordering fix applied in CartContext.php and following the project's "classes
first, alphabetized" guideline.

@TheMilek TheMilek merged commit ea0c0aa into Sylius:2.3 Feb 18, 2026
36 checks passed
@loic425 loic425 deleted the behat-annotations-to-attributes/hybrid branch February 25, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants