Convert Behat annotations to PHP attributes in Transform contexts#18846
Conversation
📝 WalkthroughWalkthroughSystematically migrates Behat Transform annotations across 35 context files from PHPDoc-style Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
❗ Preview Environment delete from Bunnyshell failedCheck https://github.com/Sylius/Sylius/actions/runs/22173636242 for details. See: Environment Details Available commands:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (17)
src/Sylius/Behat/Context/Transform/ShippingCategoryContext.php (2)
31-42:getShippingCategoryByNameis missing a parameter type and a return type.♻️ Proposed fix
- public function getShippingCategoryByName($shippingCategoryName) + public function getShippingCategoryByName(string $shippingCategoryName): ShippingCategoryInterfaceYou will also need to add the corresponding
useimport forShippingCategoryInterface.As per coding guidelines, "Add type declarations for all properties, arguments, and return values in PHP code."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Context/Transform/ShippingCategoryContext.php` around lines 31 - 42, Add explicit types to the getShippingCategoryByName method: declare the parameter as string and the return type as ShippingCategoryInterface (i.e., change signature to getShippingCategoryByName(string $shippingCategoryName): ShippingCategoryInterface) and ensure you add the corresponding use import for ShippingCategoryInterface at the top of the file; keep the internal logic unchanged but rely on type hints for safety and clarity.
21-21:ShippingCategoryContextis the only class in the PR not declaredfinal.All other context classes in this PR use
final. This pre-existing gap stands out now that the class is being touched.♻️ Proposed fix
-class ShippingCategoryContext implements Context +final class ShippingCategoryContext implements ContextAs per coding guidelines, "Use
finalfor all PHP classes, except entities and repositories."🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Context/Transform/ShippingCategoryContext.php` at line 21, The ShippingCategoryContext class should be declared final to match the project's coding guidelines and other context classes; update the class declaration for ShippingCategoryContext (the class named ShippingCategoryContext implementing Context) to add the final keyword so it becomes a final class.src/Sylius/Behat/Context/Transform/CountryContext.php (1)
36-47:getCountryByNameis missing a parameter type and return type.♻️ Proposed fix
- public function getCountryByName($countryName) + public function getCountryByName(string $countryName): CountryInterfaceYou will also need to add
use Sylius\Component\Addressing\Model\CountryInterface;.As per coding guidelines, "Add type declarations for all properties, arguments, and return values in PHP code."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Context/Transform/CountryContext.php` around lines 36 - 47, The getCountryByName method lacks argument and return type declarations; update its signature to public function getCountryByName(string $countryName): CountryInterface (and add use Sylius\Component\Addressing\Model\CountryInterface;) so the $countryName parameter is typed and the method returns CountryInterface, leaving the body intact (keep calls to $this->countryNameConverter->convertToCode and $this->countryRepository->findOneBy and the Assert::notNull check).src/Sylius/Behat/Context/Transform/AdminUserContext.php (1)
41-45:getLoggedAdminUseris missing a return type.♻️ Proposed fix
- public function getLoggedAdminUser() + public function getLoggedAdminUser(): AdminUserInterfaceAs per coding guidelines, "Add type declarations for all properties, arguments, and return values in PHP code."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Context/Transform/AdminUserContext.php` around lines 41 - 45, getLoggedAdminUser lacks a return type declaration; update the method signature to declare the concrete return type returned by $this->sharedStorage->get('administrator') (for example add ": AdminUserInterface" or ": UserInterface" as appropriate), import that interface at the top of the file, and adjust the return if necessary to ensure it always returns that type (or use a nullable type like ": ?AdminUserInterface" only if sharedStorage can return null).src/Sylius/Behat/Context/Transform/ProductContext.php (2)
50-53:getProductsByNamesis missing a return type.♻️ Proposed fix
- public function getProductsByNames(...$productsNames) + public function getProductsByNames(string ...$productsNames): arrayAs per coding guidelines, "Add type declarations for all properties, arguments, and return values in PHP code."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Context/Transform/ProductContext.php` around lines 50 - 53, getProductsByNames lacks a PHP return type declaration; update its signature to declare types (e.g. type-hint the variadic parameter as string ...$productsNames if appropriate) and add an explicit return type (e.g. : array) so the method becomes strongly typed; keep the body using getProductByName($productName) unchanged but ensure the declared return type matches the actual returned collection (use a more specific array of Product/ ProductInterface in a docblock if you need finer-grained typing).
35-46:getProductByNameis missing a parameter type and return type.♻️ Proposed fix
- public function getProductByName($productName) + public function getProductByName(string $productName): ProductInterfaceAdd the corresponding
useimport forProductInterface.As per coding guidelines, "Add type declarations for all properties, arguments, and return values in PHP code."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Context/Transform/ProductContext.php` around lines 35 - 46, The getProductByName function lacks type hints: add a string type for the $productName parameter and declare the return type as ProductInterface; also add a use statement for ProductInterface and ensure the method returns ProductInterface (not just mixed) — update the method signature (getProductByName) to accept string $productName and return ProductInterface and keep the body using $this->productRepository->findByName($productName, $this->locale) and the Assert check unchanged.src/Sylius/Behat/Context/Transform/DateTimeContext.php (1)
25-28: Missing type declarations; prefer\DateTimeImmutableover\DateTime.
getDatehas no parameter or return type, and returns a mutable\DateTimeinstance. Modern PHP 8.2+ practice (and Sylius convention) favours\DateTimeImmutablefor value objects.♻️ Suggested fix
- public function getDate($date) + public function getDate(string $date): \DateTimeImmutable { - return new \DateTime($date); + return new \DateTimeImmutable($date); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Context/Transform/DateTimeContext.php` around lines 25 - 28, The getDate method in DateTimeContext lacks type hints and returns a mutable \DateTime; change its signature to accept a string and return an immutable instance by updating function getDate(string $date): \DateTimeImmutable and instantiate and return new \DateTimeImmutable($date) inside the method so callers get typed, immutable date values.src/Sylius/Behat/Context/Transform/ProductAssociationTypeContext.php (1)
30-30: Missing parameter and return type declarations.
getProductAssociationTypeByNamehas no type on its parameter or return value. Per coding guidelines, all arguments and return values should have type declarations.♻️ Suggested fix
- public function getProductAssociationTypeByName($productAssociationTypeName) + public function getProductAssociationTypeByName(string $productAssociationTypeName): ProductAssociationTypeInterfaceYou'll also need to add the corresponding
useimport forProductAssociationTypeInterface.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Context/Transform/ProductAssociationTypeContext.php` at line 30, Update the signature of getProductAssociationTypeByName to declare the parameter type and return type (e.g. change to accept string $productAssociationTypeName and return ?ProductAssociationTypeInterface or ProductAssociationTypeInterface depending on whether null is possible), add the corresponding use import for ProductAssociationTypeInterface at the top of the file, and adjust any callers if required to handle the declared return type.src/Sylius/Behat/Context/Transform/ProductOptionContext.php (1)
30-30: Missing parameter and return type declarations.Same pre-existing gap as other transform methods in this PR:
getProductOptionByNamelacks a typed parameter and return type.♻️ Suggested fix
- public function getProductOptionByName($productOptionName) + public function getProductOptionByName(string $productOptionName): ProductOptionInterfaceAdd the corresponding
useimport forProductOptionInterface.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Context/Transform/ProductOptionContext.php` at line 30, Update the getProductOptionByName method to declare its parameter and return types: change the signature of getProductOptionByName($productOptionName) to accept a string and return ProductOptionInterface (e.g. getProductOptionByName(string $productOptionName): ProductOptionInterface), and add the corresponding use import for ProductOptionInterface at the top of the file so the type is resolved.src/Sylius/Behat/Context/Transform/UserContext.php (2)
27-30:getLoggedUser()is missing a return type.Per coding guidelines, return types should always be declared. The method returns whatever is stored under the
'user'key, which is presumably a typed user object from shared storage.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Context/Transform/UserContext.php` around lines 27 - 30, The method getLoggedUser() lacks an explicit return type; update its signature to declare the correct return type (e.g., the UserInterface or concrete User class used by sharedStorage) so the method returns that type instead of an untyped value; locate the getLoggedUser method in UserContext and change its declaration to include the appropriate return type matching the object stored under sharedStorage->get('user').
20-20:UserContextshould be declaredfinal.Every sibling context class in this PR (and across the
Transform/directory) usesfinal class. The coding guidelines requirefinalfor all non-entity/non-repository classes.♻️ Suggested fix
-class UserContext implements Context +final class UserContext implements Context🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Context/Transform/UserContext.php` at line 20, The UserContext class declaration should be marked final to match project conventions; update the class header "class UserContext implements Context" to "final class UserContext implements Context" so the class is non-extendable, and run tests/PHPCS to ensure no other style changes are required; keep all existing methods and imports unchanged.src/Sylius/Behat/Context/Transform/CustomerGroupContext.php (1)
30-30: Missing parameter and return type declarations.
getCustomerGroupByNamehas no typed parameter or return value. Should bestringfor the parameter and aCustomerGroupInterface(or equivalent) for the return.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Context/Transform/CustomerGroupContext.php` at line 30, Update the method signature for getCustomerGroupByName to add a typed parameter and return type: change the parameter to string and add a return type of CustomerGroupInterface (or the project’s equivalent interface), and ensure the appropriate use/import for CustomerGroupInterface is added at the top of the file; keep the method body unchanged except for any necessary assertions/casts to satisfy the new type hints.src/Sylius/Behat/Context/Transform/ZoneMemberContext.php (2)
16-17:useimports are not in alphabetical order.
Behat\Behat\Context\Context(Behat<Transformation) should precedeBehat\Transformation\Transform. As per coding guidelines, PHPuseimports must be sorted alphabetically.♻️ Proposed fix
-use Behat\Transformation\Transform; use Behat\Behat\Context\Context; +use Behat\Transformation\Transform;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Context/Transform/ZoneMemberContext.php` around lines 16 - 17, The two PHP use imports in ZoneMemberContext are out of alphabetical order; reorder them so Behat\Behat\Context\Context comes before Behat\Transformation\Transform (i.e., sort the use statements alphabetically) to comply with the project's import-ordering rule — update the use block containing "use Behat\Transformation\Transform" and "use Behat\Behat\Context\Context" accordingly.
36-36: Add missing type declarations to the three untyped public Transform methods.
getCountryTypeZoneMemberByName,getProvinceTypeZoneMemberByName, andgetZoneTypeZoneMemberByNameall lack parameter and return type declarations, while the sibling methodgetCountryTypeZoneMembersByNamesalready declares them.ZoneMemberInterfaceis already imported. As per coding guidelines, all PHP arguments and return values must have type declarations.♻️ Proposed fix
- public function getCountryTypeZoneMemberByName($name) + public function getCountryTypeZoneMemberByName(string $name): ZoneMemberInterface - public function getProvinceTypeZoneMemberByName($name) + public function getProvinceTypeZoneMemberByName(string $name): ZoneMemberInterface - public function getZoneTypeZoneMemberByName($name) + public function getZoneTypeZoneMemberByName(string $name): ZoneMemberInterfaceAlso applies to: 54-54, 62-62
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Context/Transform/ZoneMemberContext.php` at line 36, Add strict type declarations to the three untyped public Transform methods: change the parameter for getCountryTypeZoneMemberByName, getProvinceTypeZoneMemberByName, and getZoneTypeZoneMemberByName to string $name and add a return type of ZoneMemberInterface; ensure the methods import/use ZoneMemberInterface (as in the sibling getCountryTypeZoneMembersByNames) and update any docblocks to reflect the typed signature.src/Sylius/Behat/Context/Transform/TaxonContext.php (1)
16-17:useimports are not in alphabetical order.Same issue as in
ZoneMemberContext.php:Behat\Behat\Context\Contextmust come beforeBehat\Transformation\Transform. As per coding guidelines, PHPuseimports must be sorted alphabetically.♻️ Proposed fix
-use Behat\Transformation\Transform; use Behat\Behat\Context\Context; +use Behat\Transformation\Transform;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Context/Transform/TaxonContext.php` around lines 16 - 17, Reorder the PHP use imports in TaxonContext.php so they are alphabetized: place Behat\Behat\Context\Context before Behat\Transformation\Transform (same change as in ZoneMemberContext.php). Update the import block where Context and Transform are declared to follow alphabetical ordering to satisfy the coding guidelines.src/Sylius/Behat/Context/Transform/PromotionContext.php (2)
16-17:useimports are not in alphabetical order.Same issue as the other files in this PR:
Behat\Behat\Context\Contextmust precedeBehat\Transformation\Transform. As per coding guidelines, PHPuseimports must be sorted alphabetically.♻️ Proposed fix
-use Behat\Transformation\Transform; use Behat\Behat\Context\Context; +use Behat\Transformation\Transform;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Context/Transform/PromotionContext.php` around lines 16 - 17, The file's PHP use imports are out of alphabetical order; swap the two use statements so Behat\Behat\Context\Context comes before Behat\Transformation\Transform in PromotionContext.php—i.e., update the use declarations for Context and Transform in the PromotionContext class so they are sorted alphabetically.
33-33: Add missing type declarations to both public Transform methods.
getPromotionByNameandgetPromotionCouponByCodehave no parameter or return type declarations. The respective return types (PromotionInterface/PromotionCouponInterface) would also need to be added to theuseblock. As per coding guidelines, all PHP arguments and return values must carry type declarations.♻️ Proposed fix (parameter types; return types need their respective interface imports)
- public function getPromotionByName($promotionName) + public function getPromotionByName(string $promotionName): PromotionInterface - public function getPromotionCouponByCode($promotionCouponCode) + public function getPromotionCouponByCode(string $promotionCouponCode): PromotionCouponInterfaceAlso applies to: 48-48
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Sylius/Behat/Context/Transform/PromotionContext.php` at line 33, Both public transform methods lack parameter and return type hints: add string $promotionName and string $couponCode parameter types and declare return types PromotionInterface for getPromotionByName and PromotionCouponInterface for getPromotionCouponByCode; also import those interfaces in the use block (PromotionInterface, PromotionCouponInterface) and adjust any nullable/exception behavior to match the new signatures. Locate the methods getPromotionByName and getPromotionCouponByCode and update their signatures accordingly and add the two interface imports at the top of the file.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/Sylius/Behat/Context/Transform/ShippingCategoryContext.php`:
- Around line 16-17: The two PHP use statements are alphabetized incorrectly in
ShippingCategoryContext; swap the order so Behat\Behat\Context\Context appears
before Behat\Transformation\Transform (i.e., ensure the use imports list has
Context then Transform), and apply the same alphabetical reorder to the other
seven files in this PR to match CartContext.php and the project's import sorting
guideline.
---
Duplicate comments:
In `@src/Sylius/Behat/Context/Transform/AdminUserContext.php`:
- Around line 16-17: Reorder the use statements in AdminUserContext.php so they
follow the project's import ordering convention (match
ShippingCategoryContext.php) by placing Behat\Behat\Context\Context before
Behat\Transformation\Transform; update the import order for the symbols Context
and Transform accordingly to satisfy the linter/PSR ordering.
In `@src/Sylius/Behat/Context/Transform/CountryContext.php`:
- Around line 16-17: The import statements in CountryContext are out of the
project's canonical order; reorder the use statements so
Behat\Behat\Context\Context appears before Behat\Transformation\Transform
(consistent with the ordering used in ShippingCategoryContext and
PSR‑12/alphabetical grouping), i.e., update the use block in the CountryContext
class to place the Context import above the Transform import.
In `@src/Sylius/Behat/Context/Transform/ExchangeRateContext.php`:
- Around line 16-17: Fix the import ordering in ExchangeRateContext by
reordering the use statements so they match the project's import style (same
order used in ShippingCategoryContext): place Behat\Behat\Context\Context before
Behat\Transformation\Transform and ensure the import block around the
ExchangeRateContext class uses the same grouping/ordering convention as the
other context files.
In `@src/Sylius/Behat/Context/Transform/ProductContext.php`:
- Around line 16-17: Reorder the use statements in ProductContext.php to match
the project's import ordering (same fix as ShippingCategoryContext.php): place
"use Behat\Behat\Context\Context;" before "use Behat\Transformation\Transform;"
so the imports are consistently ordered (third-party/namespace grouping and
alphabetical), and ensure there are no duplicate or stray import lines.
In `@src/Sylius/Behat/Context/Transform/ProvinceContext.php`:
- Around line 16-17: Reorder the use statements in ProvinceContext.php to match
the ordering used in ShippingCategoryContext.php: place "use
Behat\Behat\Context\Context;" before "use Behat\Transformation\Transform;" (keep
one use per line and consistent sorting), ensuring the ProvinceContext class
imports are consistently ordered.
In `@src/Sylius/Behat/Context/Transform/ShopUserContext.php`:
- Around line 16-17: Reorder the use statements in ShopUserContext so they match
the ordering used in ShippingCategoryContext: place "use
Behat\Behat\Context\Context;" before "use Behat\Transformation\Transform;".
Update the imports at the top of the ShopUserContext class (the use declarations
referencing Transform and Context) so they follow that ordering.
---
Nitpick comments:
In `@src/Sylius/Behat/Context/Transform/AdminUserContext.php`:
- Around line 41-45: getLoggedAdminUser lacks a return type declaration; update
the method signature to declare the concrete return type returned by
$this->sharedStorage->get('administrator') (for example add ":
AdminUserInterface" or ": UserInterface" as appropriate), import that interface
at the top of the file, and adjust the return if necessary to ensure it always
returns that type (or use a nullable type like ": ?AdminUserInterface" only if
sharedStorage can return null).
In `@src/Sylius/Behat/Context/Transform/CountryContext.php`:
- Around line 36-47: The getCountryByName method lacks argument and return type
declarations; update its signature to public function getCountryByName(string
$countryName): CountryInterface (and add use
Sylius\Component\Addressing\Model\CountryInterface;) so the $countryName
parameter is typed and the method returns CountryInterface, leaving the body
intact (keep calls to $this->countryNameConverter->convertToCode and
$this->countryRepository->findOneBy and the Assert::notNull check).
In `@src/Sylius/Behat/Context/Transform/CustomerGroupContext.php`:
- Line 30: Update the method signature for getCustomerGroupByName to add a typed
parameter and return type: change the parameter to string and add a return type
of CustomerGroupInterface (or the project’s equivalent interface), and ensure
the appropriate use/import for CustomerGroupInterface is added at the top of the
file; keep the method body unchanged except for any necessary assertions/casts
to satisfy the new type hints.
In `@src/Sylius/Behat/Context/Transform/DateTimeContext.php`:
- Around line 25-28: The getDate method in DateTimeContext lacks type hints and
returns a mutable \DateTime; change its signature to accept a string and return
an immutable instance by updating function getDate(string $date):
\DateTimeImmutable and instantiate and return new \DateTimeImmutable($date)
inside the method so callers get typed, immutable date values.
In `@src/Sylius/Behat/Context/Transform/ProductAssociationTypeContext.php`:
- Line 30: Update the signature of getProductAssociationTypeByName to declare
the parameter type and return type (e.g. change to accept string
$productAssociationTypeName and return ?ProductAssociationTypeInterface or
ProductAssociationTypeInterface depending on whether null is possible), add the
corresponding use import for ProductAssociationTypeInterface at the top of the
file, and adjust any callers if required to handle the declared return type.
In `@src/Sylius/Behat/Context/Transform/ProductContext.php`:
- Around line 50-53: getProductsByNames lacks a PHP return type declaration;
update its signature to declare types (e.g. type-hint the variadic parameter as
string ...$productsNames if appropriate) and add an explicit return type (e.g. :
array) so the method becomes strongly typed; keep the body using
getProductByName($productName) unchanged but ensure the declared return type
matches the actual returned collection (use a more specific array of Product/
ProductInterface in a docblock if you need finer-grained typing).
- Around line 35-46: The getProductByName function lacks type hints: add a
string type for the $productName parameter and declare the return type as
ProductInterface; also add a use statement for ProductInterface and ensure the
method returns ProductInterface (not just mixed) — update the method signature
(getProductByName) to accept string $productName and return ProductInterface and
keep the body using $this->productRepository->findByName($productName,
$this->locale) and the Assert check unchanged.
In `@src/Sylius/Behat/Context/Transform/ProductOptionContext.php`:
- Line 30: Update the getProductOptionByName method to declare its parameter and
return types: change the signature of getProductOptionByName($productOptionName)
to accept a string and return ProductOptionInterface (e.g.
getProductOptionByName(string $productOptionName): ProductOptionInterface), and
add the corresponding use import for ProductOptionInterface at the top of the
file so the type is resolved.
In `@src/Sylius/Behat/Context/Transform/PromotionContext.php`:
- Around line 16-17: The file's PHP use imports are out of alphabetical order;
swap the two use statements so Behat\Behat\Context\Context comes before
Behat\Transformation\Transform in PromotionContext.php—i.e., update the use
declarations for Context and Transform in the PromotionContext class so they are
sorted alphabetically.
- Line 33: Both public transform methods lack parameter and return type hints:
add string $promotionName and string $couponCode parameter types and declare
return types PromotionInterface for getPromotionByName and
PromotionCouponInterface for getPromotionCouponByCode; also import those
interfaces in the use block (PromotionInterface, PromotionCouponInterface) and
adjust any nullable/exception behavior to match the new signatures. Locate the
methods getPromotionByName and getPromotionCouponByCode and update their
signatures accordingly and add the two interface imports at the top of the file.
In `@src/Sylius/Behat/Context/Transform/ShippingCategoryContext.php`:
- Around line 31-42: Add explicit types to the getShippingCategoryByName method:
declare the parameter as string and the return type as ShippingCategoryInterface
(i.e., change signature to getShippingCategoryByName(string
$shippingCategoryName): ShippingCategoryInterface) and ensure you add the
corresponding use import for ShippingCategoryInterface at the top of the file;
keep the internal logic unchanged but rely on type hints for safety and clarity.
- Line 21: The ShippingCategoryContext class should be declared final to match
the project's coding guidelines and other context classes; update the class
declaration for ShippingCategoryContext (the class named ShippingCategoryContext
implementing Context) to add the final keyword so it becomes a final class.
In `@src/Sylius/Behat/Context/Transform/TaxonContext.php`:
- Around line 16-17: Reorder the PHP use imports in TaxonContext.php so they are
alphabetized: place Behat\Behat\Context\Context before
Behat\Transformation\Transform (same change as in ZoneMemberContext.php). Update
the import block where Context and Transform are declared to follow alphabetical
ordering to satisfy the coding guidelines.
In `@src/Sylius/Behat/Context/Transform/UserContext.php`:
- Around line 27-30: The method getLoggedUser() lacks an explicit return type;
update its signature to declare the correct return type (e.g., the UserInterface
or concrete User class used by sharedStorage) so the method returns that type
instead of an untyped value; locate the getLoggedUser method in UserContext and
change its declaration to include the appropriate return type matching the
object stored under sharedStorage->get('user').
- Line 20: The UserContext class declaration should be marked final to match
project conventions; update the class header "class UserContext implements
Context" to "final class UserContext implements Context" so the class is
non-extendable, and run tests/PHPCS to ensure no other style changes are
required; keep all existing methods and imports unchanged.
In `@src/Sylius/Behat/Context/Transform/ZoneMemberContext.php`:
- Around line 16-17: The two PHP use imports in ZoneMemberContext are out of
alphabetical order; reorder them so Behat\Behat\Context\Context comes before
Behat\Transformation\Transform (i.e., sort the use statements alphabetically) to
comply with the project's import-ordering rule — update the use block containing
"use Behat\Transformation\Transform" and "use Behat\Behat\Context\Context"
accordingly.
- Line 36: Add strict type declarations to the three untyped public Transform
methods: change the parameter for getCountryTypeZoneMemberByName,
getProvinceTypeZoneMemberByName, and getZoneTypeZoneMemberByName to string $name
and add a return type of ZoneMemberInterface; ensure the methods import/use
ZoneMemberInterface (as in the sibling getCountryTypeZoneMembersByNames) and
update any docblocks to reflect the typed signature.
| use Behat\Transformation\Transform; | ||
| use Behat\Behat\Context\Context; |
There was a problem hiding this comment.
use imports are not in alphabetical order — swap lines 16 and 17.
Behat\Behat\Context\Context must precede Behat\Transformation\Transform alphabetically (Behat < Transformation). CartContext.php in the same PR already has the correct order. This same transposition was applied to all 7 other files changed in this PR except CartContext.php; each needs the same fix.
♻️ Proposed fix
-use Behat\Transformation\Transform;
use Behat\Behat\Context\Context;
+use Behat\Transformation\Transform;As per coding guidelines, "Sort PHP use imports alphabetically and group by type (classes, functions, constants)."
📝 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.
| use Behat\Transformation\Transform; | |
| use Behat\Behat\Context\Context; | |
| use Behat\Behat\Context\Context; | |
| use Behat\Transformation\Transform; |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/Sylius/Behat/Context/Transform/ShippingCategoryContext.php` around lines
16 - 17, The two PHP use statements are alphabetized incorrectly in
ShippingCategoryContext; swap the order so Behat\Behat\Context\Context appears
before Behat\Transformation\Transform (i.e., ensure the use imports list has
Context then Transform), and apply the same alphabetical reorder to the other
seven files in this PR to match CartContext.php and the project's import sorting
guideline.
Summary by CodeRabbit