Convert Behat annotations to PHP attributes in Domain contexts#18811
Convert Behat annotations to PHP attributes in Domain contexts#18811TheMilek merged 2 commits intoSylius:2.3from
Conversation
📝 WalkthroughWalkthroughMigrates Behat step registrations from PHPDoc annotations to PHP 8 attributes across multiple Behat context files and updates Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
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 deleted from BunnyshellAvailable commands:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@rector.php`:
- Around line 8-15: The config uses the removed
SetList::BEHAT_ANNOTATIONS_TO_ATTRIBUTES constant; update the RectorConfig setup
to stop passing that set to withSets and instead call withAttributesSets(behat:
true) (or withAttributesSets() to enable all) after your withSets call — modify
the RectorConfig::configure() chain (remove
SetList::BEHAT_ANNOTATIONS_TO_ATTRIBUTES from the array passed to withSets and
append ->withAttributesSets(behat: true)) to use the Rector 2.0.0 attributes
API.
In `@src/Sylius/Behat/Context/Domain/ManagingProductsContext.php`:
- Line 17: Remove the obsolete Doctrine\DBAL\DBALException import and branch and
update the catch to use only the current DBAL exception: delete the use
Doctrine\DBAL\DBALException; import and remove the
class_exists('\Doctrine\DBAL\DBALException') branch, then change the catch in
ManagingProductsContext (currently catch (DBALException|\Doctrine\DBAL\Exception
$exception)) to catch (\Doctrine\DBAL\Exception $exception) so only the DBAL 3.x
exception class is referenced.
🧹 Nitpick comments (11)
src/Sylius/Behat/Context/Domain/ManagingShippingMethodsContext.php (1)
16-18: Imports are not sorted alphabetically.Per coding guidelines,
useimports should be sorted alphabetically.Behat\Behat\Context\Contextshould come beforeBehat\Step\*, andThenbeforeWhen.Proposed fix
-use Behat\Step\When; -use Behat\Step\Then; use Behat\Behat\Context\Context; +use Behat\Step\Then; +use Behat\Step\When;This same import ordering issue applies to the other context files in this PR (
ManagingOrdersContext.php,ManagingPriceHistoryContext.php,ManagingPromotionCouponsContext.php,ManagingPromotionsContext.php). As per coding guidelines: "Sort PHPuseimports alphabetically and group by type."src/Sylius/Behat/Context/Domain/ManagingOrdersContext.php (1)
16-19: Imports are not sorted alphabetically.Same issue as in
ManagingShippingMethodsContext.php. TheBehat\Step\*imports should come afterBehat\Behat\Context\Context, and should be orderedGiven,Then,When.Proposed fix
-use Behat\Step\When; -use Behat\Step\Then; -use Behat\Step\Given; use Behat\Behat\Context\Context; +use Behat\Step\Given; +use Behat\Step\Then; +use Behat\Step\When;As per coding guidelines: "Sort PHP
useimports alphabetically and group by type."src/Sylius/Behat/Context/Domain/ManagingShipmentsContext.php (1)
16-17: Imports are not sorted alphabetically.
Behat\Behat\Context\Contextshould precedeBehat\Step\Then.Proposed fix
-use Behat\Step\Then; use Behat\Behat\Context\Context; +use Behat\Step\Then;As per coding guidelines: "Sort PHP
useimports alphabetically and group by type."src/Sylius/Behat/Context/Domain/ManagingPaymentsContext.php (1)
16-17: Imports are not sorted alphabetically.Same issue —
Behat\Behat\Context\Contextshould come beforeBehat\Step\Then. As per coding guidelines: "Sort PHPuseimports alphabetically and group by type."src/Sylius/Behat/Context/Domain/ManagingPriceHistoryContext.php (1)
16-18: Imports are not sorted alphabetically.Same issue. Should be
Behat\Behat\Context\Context,Behat\Step\Then,Behat\Step\When. As per coding guidelines: "Sort PHPuseimports alphabetically and group by type."src/Sylius/Behat/Context/Domain/ManagingPromotionCouponsContext.php (1)
16-18: Imports are not sorted alphabetically.Same issue. Should be
Behat\Behat\Context\Context,Behat\Step\Then,Behat\Step\When. As per coding guidelines: "Sort PHPuseimports alphabetically and group by type."src/Sylius/Behat/Context/Domain/ManagingPromotionsContext.php (1)
16-18: Imports are not sorted alphabetically.Same issue. Should be
Behat\Behat\Context\Context,Behat\Step\Then,Behat\Step\When. As per coding guidelines: "Sort PHPuseimports alphabetically and group by type."src/Sylius/Behat/Context/Domain/SecurityContext.php (1)
16-17: Imports are not sorted alphabetically.
Behat\Behat\Context\Contextshould precedeBehat\Step\Givenlexicographically.Proposed fix
-use Behat\Step\Given; use Behat\Behat\Context\Context; +use Behat\Step\Given;As per coding guidelines: "Sort PHP
useimports alphabetically and group by type (classes, functions, constants)".src/Sylius/Behat/Context/Domain/NotificationContext.php (1)
16-17: Imports are not sorted alphabetically.Same as
SecurityContext.php—Behat\Behat\Context\Contextshould come beforeBehat\Step\Then.Proposed fix
-use Behat\Step\Then; use Behat\Behat\Context\Context; +use Behat\Step\Then;As per coding guidelines: "Sort PHP
useimports alphabetically and group by type (classes, functions, constants)".src/Sylius/Behat/Context/Domain/CartContext.php (1)
16-18: Imports are not sorted alphabetically.
Behat\Behat\Context\Contextshould be listed beforeBehat\Step\GivenandBehat\Step\Then.Proposed fix
-use Behat\Step\Given; -use Behat\Step\Then; use Behat\Behat\Context\Context; +use Behat\Step\Given; +use Behat\Step\Then;As per coding guidelines: "Sort PHP
useimports alphabetically and group by type (classes, functions, constants)".src/Sylius/Behat/Context/Domain/ManagingProductsContext.php (1)
16-19: Imports are not sorted alphabetically and Behat/Doctrine imports are interleaved.The four import statements are in a jumbled order. They should be sorted lexicographically.
Proposed fix
-use Behat\Step\When; -use Doctrine\DBAL\DBALException; -use Behat\Step\Then; use Behat\Behat\Context\Context; +use Behat\Step\Then; +use Behat\Step\When; +use Doctrine\DBAL\DBALException;As per coding guidelines: "Sort PHP
useimports alphabetically and group by type (classes, functions, constants)".
8ca5186 to
0921823
Compare
| $this->productVariantRepository->remove($productVariant); | ||
| /** @phpstan-ignore-next-line */ | ||
| } catch (\Doctrine\DBAL\DBALException|\Doctrine\DBAL\Exception $exception) { | ||
| } catch (DBALException $exception) { |
There was a problem hiding this comment.
\Doctrine\DBAL\DBALException does not exist anymore in minimal doctrine requirements we have now.
Smaller version of #18810 only applied on Domain contexts.
Summary by CodeRabbit