Skip to content

Convert Behat annotations to PHP attributes in Setup contexts#18816

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

Convert Behat annotations to PHP attributes in Setup contexts#18816
TheMilek merged 1 commit intoSylius:2.3from
loic425:behat-annotations-to-attributes/setup

Conversation

@loic425
Copy link
Copy Markdown
Member

@loic425 loic425 commented Feb 11, 2026

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

Summary by CodeRabbit

  • Chores
    • Modernized test infrastructure by updating Behat test step declarations to use current PHP 8 syntax standards. No changes to functionality or user-facing features.

@loic425 loic425 requested review from a team as code owners February 11, 2026 14:47
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 11, 2026

📝 Walkthrough

Walkthrough

This pull request systematically migrates Behat step definitions across 32 Setup Context files from PHPDoc annotations (@Given, @When, @Then) to PHP 8 attributes (#[Given], #[When], #[Then]), with corresponding import additions. One file (OrderContext) also introduces an optional Channel parameter to a method signature. No functional logic changes occur except for the annotation mechanism modernization and the OrderContext parameter addition.

Changes

Cohort / File(s) Summary
Address, Calendar, Currency, Exchange Rate, Geographical, Locale, Payment Request, Price History, Product Taxon, Shipping Category, Taxonomy, Theme Context
src/Sylius/Behat/Context/Setup/AddressContext.php, CalendarContext.php, CurrencyContext.php, ExchangeRateContext.php, GeographicalContext.php, LocaleContext.php, PaymentRequestContext.php, PriceHistoryContext.php, ProductTaxonContext.php, ShippingCategoryContext.php, TaxonomyContext.php, ThemeContext.php
Replaced PHPDoc @Given annotations with PHP 8 attributes; added Behat\Step\Given imports. Minimal line changes (1–13 lines added/removed per file). Method signatures unchanged.
Admin & User Context
src/Sylius/Behat/Context/Setup/AdminSecurityContext.php, AdminUserContext.php, UserContext.php
Migrated @Given/@when docblock annotations to PHP 8 attributes (#[Given], #[When]). Added Behat\Step\Given and Behat\Step\When imports. All public method signatures remain identical.
Checkout & Shipping Context
src/Sylius/Behat/Context/Setup/CheckoutContext.php, ShippingContext.php
Converted docblock step annotations to PHP 8 attributes. ShippingContext contains 27 added/77 removed lines reflecting extensive attribute migration across numerous step definitions.
Cart, Channel, Promotion Context
src/Sylius/Behat/Context/Setup/CartContext.php, ChannelContext.php, PromotionContext.php
Large-scale annotation migration (12–50 lines added, 80–142 lines removed per file). Added Behat\Step\When imports alongside Given attributes. Step variant coverage expanded in attributes.
Catalog Promotion Context
src/Sylius/Behat/Context/Setup/CatalogPromotionContext.php
Extensive refactoring: 44 lines added, 117 lines removed. Migrated numerous step definitions for catalog promotion scenarios (enable/disable, pricing, date ranges, priority, channel associations) from docblocks to attributes.
Customer, Customer Group, Product Option Context
src/Sylius/Behat/Context/Setup/CustomerContext.php, CustomerGroupContext.php, ProductOptionContext.php
Converted @Given docblock annotations to attributes. Added Given imports. CustomerContext (19 added/42 removed) contains more extensive step definitions; others more compact (5–8 lines changed).
Order Context
src/Sylius/Behat/Context/Setup/OrderContext.php
Notable change: Added optional ?ChannelInterface $channel = null parameter to thereIsCustomerThatPlacedOrder method. Replaced 73 added/167 removed lines of docblock @Given/@when annotations with PHP 8 attributes. Added Behat\Step\When import.
Payment Context
src/Sylius/Behat/Context/Setup/PaymentContext.php
Migrated @Given/@when annotations to attributes; added Behat\Step\When import. Minor internal translation creation adjustment in thisPaymentMethodIsNamedIn method.
Product Attribute & Product Context
src/Sylius/Behat/Context/Setup/ProductAttributeContext.php, ProductContext.php
Largest refactors: 32 added/84 removed (ProductAttributeContext) and 124 added/300 removed (ProductContext). Extensive step definition migrations covering numerous product and attribute scenarios. Added Given and When imports.
Product Association & Product Review Context
src/Sylius/Behat/Context/Setup/ProductAssociationContext.php, ProductReviewContext.php
Converted @Given docblock annotations to PHP 8 attributes. Added Behat\Step\Given imports. ProductReviewContext (11 added/26 removed) shows typical annotation migration scope.
Taxation & Zone Context
src/Sylius/Behat/Context/Setup/TaxationContext.php, ZoneContext.php
Migrated PHPDoc @Given annotations to attributes; added Given imports. TaxationContext also adjusted return types to void on certain methods. ZoneContext (14 added/30 removed) covers zone creation and membership step definitions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Large-scale systematic refactoring affecting 32 files with consistent, homogeneous pattern changes (PHPDoc to attributes migration). While the pattern is repetitive and reduces per-file cognitive load, the sheer number of files, combined with the OrderContext parameter addition and minor logic adjustments in a few files, requires careful verification of annotation correctness and consistency across the codebase.

Possibly related PRs

Suggested labels

DX

Suggested reviewers

  • GSadee
  • TheMilek

Poem

🐰 From old docblock annotations to attributes bright,
Behat contexts leap into PHP 8 light!
Thirty-two files dance in harmony,
Modern syntax blooms—what a sight to see! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 1.64% 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 PR title 'Convert Behat annotations to PHP attributes in Setup contexts' clearly and specifically describes the main change: migrating Behat step definitions from docblock annotations to PHP 8 attributes across Setup context classes.

✏️ 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 11, 2026

❌ Preview Environment deleted from Bunnyshell

Available commands:

  • 🚀 /bns:deploy to redeploy 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.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/Sylius/Behat/Context/Setup/GeographicalContext.php`:
- Around line 53-58: The two legacy `@Given` patterns for the GeographicalContext
method theStoreOperatesIn were not converted to attributes and must be added as
#[Given(...)] above that method; update the method declaration in class
GeographicalContext to include attribute variants for the multi-country pattern
'/^the store operates in "([^"]*)" and "([^"]*)"$/', and for the single-country
/ also pattern '/^the store(?:| also) has country "([^"]*)"$/', so the method
theStoreOperatesIn(string ...$countriesNames): void is annotated with all three
#[Given(...)] attributes matching the original step patterns.
🧹 Nitpick comments (6)
src/Sylius/Behat/Context/Setup/PriceHistoryContext.php (1)

16-17: Imports are not sorted alphabetically.

Behat\Behat\Context\Context should precede Behat\Step\Given lexicographically. This same ordering issue appears in several other files in this PR (AdminSecurityContext, CartContext, PaymentRequestContext, AddressContext).

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)".

src/Sylius/Behat/Context/Setup/AdminSecurityContext.php (1)

16-17: Imports not sorted alphabetically — same issue as noted in PriceHistoryContext.php.

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)".

src/Sylius/Behat/Context/Setup/CartContext.php (1)

16-18: Imports not sorted alphabetically — same issue as noted in other files.

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

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

src/Sylius/Behat/Context/Setup/PaymentRequestContext.php (1)

16-17: Imports not sorted alphabetically — same issue as noted in other files.

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)".

src/Sylius/Behat/Context/Setup/AddressContext.php (1)

16-17: Imports not sorted alphabetically — same issue as noted in other files.

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)".

src/Sylius/Behat/Context/Setup/ChannelContext.php (1)

254-259: Stale/malformed docblock annotation left behind.

Line 255 contains @Whencustomer view shop on :channel channel which appears to be a leftover annotation from the migration. Since this PR converts all Behat annotations to PHP 8 attributes, this residual docblock should be cleaned up. It was never a functional annotation (@When is concatenated with customer), but it should still be removed for consistency.

Suggested fix
-    /**
-     * `@Whencustomer` view shop on :channel channel
-     */
     #[Given('/^I changed my current (channel to "([^"]+)")$/')]
     #[Given('I am in the :channel channel')]
     #[When('/^I change (?:|back )my current (channel to "([^"]+)")$/')]

@loic425 loic425 force-pushed the behat-annotations-to-attributes/setup branch from 1ae7898 to 65ed4f1 Compare February 11, 2026 14:55
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.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@src/Sylius/Behat/Context/Setup/ChannelContext.php`:
- Around line 254-259: Remove the stale/malformed docblock line containing
"@Whencustomer view shop on :channel channel" above the channel-switching method
in ChannelContext; the method already uses PHP 8 attributes (the Given/When
attributes shown) so delete that dead docblock entry to avoid confusion and keep
only the attribute-driven annotations for the channel-related method in
ChannelContext.

In `@src/Sylius/Behat/Context/Setup/ZoneContext.php`:
- Line 83: The turnip step pattern on the Given attribute in ZoneContext uses
the optional group with the space outside (`'the store has (also) a zone
:zoneName'`) which leaves a double space when "also" is absent; update the Given
attribute on the ZoneContext step (the attribute currently showing `'the store
has (also) a zone :zoneName'`) so the leading space is inside the optional group
(e.g. `'the store has( also) a zone :zoneName'`) to ensure both variants match
correctly.
🧹 Nitpick comments (5)
src/Sylius/Behat/Context/Setup/PriceHistoryContext.php (1)

16-17: Imports are not in alphabetical order.

Behat\Behat\Context\Context should come before Behat\Step\Given to satisfy alphabetical ordering.

🔤 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)".

src/Sylius/Behat/Context/Setup/CatalogPromotionContext.php (1)

16-18: Imports are not in alphabetical order.

The Behat\Step\* imports should follow Behat\Behat\Context\Context alphabetically.

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

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

src/Sylius/Behat/Context/Setup/AdminUserContext.php (1)

16-18: Imports are not in alphabetical order.

Same pattern as the other files — Behat\Behat\Context\Context should precede Behat\Step\*.

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

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

src/Sylius/Behat/Context/Setup/TaxationContext.php (1)

16-17: Imports are not in alphabetical order.

🔤 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)".

src/Sylius/Behat/Context/Setup/ProductAttributeContext.php (1)

16-18: Imports are not in alphabetical order.

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

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

* @Given the store also has a zone :zoneName with code :code
* @Given the store has a zone :zoneName with code :code and priority :priority
*/
#[Given('the store has (also) a zone :zoneName')]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Incorrect optional-group spacing in turnip pattern — will fail to match the non-"also" variant.

The pattern 'the store has (also) a zone :zoneName' leaves a double space when the optional (also) is absent, producing the store has⎵⎵a zone. The leading space should be inside the parentheses so it is omitted together with the word.

Compare with ProductAttributeContext.php Line 56 which correctly uses 'the store has( also) a :type product attribute ...'.

🐛 Proposed fix
-    #[Given('the store has (also) a zone :zoneName')]
+    #[Given('the store has( also) a zone :zoneName')]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#[Given('the store has (also) a zone :zoneName')]
#[Given('the store has( also) a zone :zoneName')]
🤖 Prompt for AI Agents
In `@src/Sylius/Behat/Context/Setup/ZoneContext.php` at line 83, The turnip step
pattern on the Given attribute in ZoneContext uses the optional group with the
space outside (`'the store has (also) a zone :zoneName'`) which leaves a double
space when "also" is absent; update the Given attribute on the ZoneContext step
(the attribute currently showing `'the store has (also) a zone :zoneName'`) so
the leading space is inside the optional group (e.g. `'the store has( also) a
zone :zoneName'`) to ensure both variants match correctly.

@loic425 loic425 force-pushed the behat-annotations-to-attributes/setup branch from 65ed4f1 to 78e2e04 Compare February 11, 2026 15:27
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.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@src/Sylius/Behat/Context/Setup/OrderContext.php`:
- Around line 16-18: The import ordering is incorrect: move the use statement
for Behat\Step\When so imports are alphabetized and grouped by type — place
Behat\Step\Given before Behat\Step\When and ensure Behat\Behat\Context\Context
sits in the correct alphabetical position among class imports; adjust the three
use lines (Behat\Step\When, Behat\Behat\Context\Context, Behat\Step\Given) so
they are sorted alphabetically to match the project's import ordering rules.

In `@src/Sylius/Behat/Context/Setup/ProductAssociationContext.php`:
- Line 16: Imports in ProductAssociationContext are out of alphabetical order:
place the Behat\Behat\Context\Context import before Behat\Step\Given; update the
import block in the ProductAssociationContext class accordingly and apply the
same fix to other Setup context files mentioned (CurrencyContext, ThemeContext,
TaxationContext) so that "Behat\Behat\Context\Context" precedes
"Behat\Step\Given" in each file's use statements.
🧹 Nitpick comments (12)
src/Sylius/Behat/Context/Setup/CustomerGroupContext.php (1)

16-17: Imports are not in alphabetical order.

Behat\Behat\Context\Context should precede Behat\Step\Given alphabetically.

Suggested 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)".

src/Sylius/Behat/Context/Setup/PaymentRequestContext.php (1)

16-17: Import statements are not sorted alphabetically.

Behat\Behat\Context\Context should precede Behat\Step\Given alphabetically.

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)".

src/Sylius/Behat/Context/Setup/ProductReviewContext.php (1)

16-17: Imports are not sorted alphabetically.

Behat\Behat\Context\Context should precede 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)".

src/Sylius/Behat/Context/Setup/CustomerContext.php (1)

16-17: Import order: Behat\Step\Given should come after Behat\Behat\Context\Context.

As per coding guidelines, use imports should be sorted alphabetically. Behat\Behat\... comes before Behat\Step\....

Proposed fix
-use Behat\Step\Given;
 use Behat\Behat\Context\Context;
+use Behat\Step\Given;
 use Doctrine\Persistence\ObjectManager;
src/Sylius/Behat/Context/Setup/ProductTaxonContext.php (1)

16-17: Imports are not sorted alphabetically.

Behat\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)".

src/Sylius/Behat/Context/Setup/TaxationContext.php (1)

16-17: Import Behat\Step\Given should come after Behat\Behat\Context\Context for alphabetical ordering.

As per coding guidelines, use imports should be sorted alphabetically. Behat\Behat\Context\Context sorts before Behat\Step\Given.

Proposed fix
-use Behat\Step\Given;
 use Behat\Behat\Context\Context;
+use Behat\Step\Given;
 use Doctrine\Persistence\ObjectManager;
src/Sylius/Behat/Context/Setup/CatalogPromotionContext.php (1)

16-18: Import order: Behat\Step\When should come after Behat\Step\Given.

The newly added When import was placed before Behat\Behat\Context\Context, breaking alphabetical order.

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

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

src/Sylius/Behat/Context/Setup/ChannelContext.php (1)

16-18: Import Behat\Step\When is placed out of alphabetical order.

Behat\Step\When (line 16) should come after Behat\Behat\Context\Context and Behat\Step\Given to maintain alphabetical sorting per project conventions.

Proposed fix
-use Behat\Step\When;
 use Behat\Behat\Context\Context;
 use Behat\Step\Given;
+use Behat\Step\When;
src/Sylius/Behat/Context/Setup/AdminSecurityContext.php (1)

16-17: Import order: Behat\Step\Given should come after Behat\Behat\Context\Context.

Alphabetically, Behat\Behat precedes Behat\Step.

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)".

src/Sylius/Behat/Context/Setup/AddressContext.php (1)

16-17: Same import ordering issue: Behat\Step\Given should follow Behat\Behat\Context\Context.

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)".

src/Sylius/Behat/Context/Setup/CurrencyContext.php (1)

16-17: Same import ordering issue as in the other files.

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)".

src/Sylius/Behat/Context/Setup/UserContext.php (1)

16-17: Import is out of alphabetical order.

Behat\Behat\Context\Context should come before Behat\Step\Given to maintain alphabetical sorting.

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)".

Comment on lines +16 to 18
use Behat\Step\When;
use Behat\Behat\Context\Context;
use Behat\Step\Given;
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Feb 11, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Import When is out of alphabetical order.

Behat\Step\When should be placed after Behat\Step\Given (line 18), not before Behat\Behat\Context\Context.

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

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

🤖 Prompt for AI Agents
In `@src/Sylius/Behat/Context/Setup/OrderContext.php` around lines 16 - 18, The
import ordering is incorrect: move the use statement for Behat\Step\When so
imports are alphabetized and grouped by type — place Behat\Step\Given before
Behat\Step\When and ensure Behat\Behat\Context\Context sits in the correct
alphabetical position among class imports; adjust the three use lines
(Behat\Step\When, Behat\Behat\Context\Context, Behat\Step\Given) so they are
sorted alphabetically to match the project's import ordering rules.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yep, indeed, but with the amount of files, I prefer to wait for the github job for the linter execution.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@loic425, that sounds like a good approach! With the number of files being updated in this PR, letting the automated linter handle the import ordering across all of them will be more efficient and consistent. The CI job should catch and fix these ordering issues uniformly. 👍


🧠 Learnings used
Learnt from: CR
Repo: Sylius/Sylius PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-23T14:27:12.477Z
Learning: Applies to src/Sylius/Behat/Context/**/*Context.php : Behat context files should be placed in `src/Sylius/Behat/Context/` directory

Learnt from: CR
Repo: Sylius/Sylius PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-23T14:27:12.477Z
Learning: Applies to features/**/*.feature : Follow Given-When-Then pattern strictly in Behat scenarios

Learnt from: CR
Repo: Sylius/Sylius PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-23T14:27:12.477Z
Learning: Applies to **/*.php : Sort PHP `use` imports alphabetically and group by type (classes, functions, constants)


namespace Sylius\Behat\Context\Setup;

use Behat\Step\Given;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

cat -n src/Sylius/Behat/Context/Setup/ProductAssociationContext.php | sed -n '1,25p'

Repository: Sylius/Sylius

Length of output: 1063


🏁 Script executed:

# Check for other instances of the same pattern
rg -n 'use Behat\\Step\\' --type=php -B2 -A2 src/Sylius/Behat/Context/ | head -100

Repository: Sylius/Sylius

Length of output: 7512


Sort imports alphabetically: Behat\Behat\Context\Context should precede Behat\Step\Given.

Lines 16–17 violate alphabetical ordering. Since Behat\Behat... comes before Behat\Step... alphabetically, Behat\Behat\Context\Context must be placed first.

This pattern appears across multiple Setup context files in this PR (CurrencyContext, ThemeContext, TaxationContext). Consider fixing all instances.

Proposed fix
-use Behat\Step\Given;
 use Behat\Behat\Context\Context;
+use Behat\Step\Given;
 use Doctrine\Persistence\ObjectManager;
🤖 Prompt for AI Agents
In `@src/Sylius/Behat/Context/Setup/ProductAssociationContext.php` at line 16,
Imports in ProductAssociationContext are out of alphabetical order: place the
Behat\Behat\Context\Context import before Behat\Step\Given; update the import
block in the ProductAssociationContext class accordingly and apply the same fix
to other Setup context files mentioned (CurrencyContext, ThemeContext,
TaxationContext) so that "Behat\Behat\Context\Context" precedes
"Behat\Step\Given" in each file's use statements.

@TheMilek TheMilek merged commit c033184 into Sylius:2.3 Feb 11, 2026
36 checks passed
@loic425 loic425 mentioned this pull request Feb 12, 2026
27 tasks
@loic425 loic425 deleted the behat-annotations-to-attributes/setup branch February 25, 2026 13:07
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