Skip to content

Conversation

@absumo
Copy link
Contributor

@absumo absumo commented Aug 8, 2025

Summary by Sourcery

Refactor the CreateCommand class to use Symfony’s invokable command signature with attribute-based arguments and update Symfony dependencies to version 7.3.

Enhancements:

  • Refactor CreateCommand to be invokable and declare arguments with Symfony’s #[Argument] attributes instead of configure/execute methods
  • Switch MessageBusInterface injection to readonly properties and remove manual Input/Output dependencies

Build:

  • Bump Symfony package versions in composer.json from ^7.2 to ^7.3

@sourcery-ai
Copy link

sourcery-ai bot commented Aug 8, 2025

Reviewer's Guide

This PR refactors the CreateCommand class to leverage Symfony Console’s invokable command pattern with attribute-based argument mapping, makes the message bus dependency readonly, and bumps all Symfony package versions from ^7.2 to ^7.3.

Sequence diagram for CreateCommand invokable execution

sequenceDiagram
    actor User
    participant Console as Symfony Console
    participant CreateCommand
    participant Validator as ValidatorInterface
    participant Bus as MessageBusInterface
    User->>Console: Run create:user command with email and roles
    Console->>CreateCommand: __invoke(io, email, roles)
    CreateCommand->>Validator: validate(CreateUser)
    Validator-->>CreateCommand: ConstraintViolationList
    alt No validation errors
        CreateCommand->>Bus: dispatch(CreateUser)
        Bus-->>CreateCommand: (dispatch result)
        CreateCommand-->>Console: return SUCCESS
    else Validation errors
        CreateCommand-->>Console: display errors
        CreateCommand-->>Console: return FAILURE
    end
Loading

Class diagram for refactored CreateCommand

classDiagram
    class CreateCommand {
        <<Symfony\Component\Console\Command\Command>>
        +__construct(MessageBusInterface messageBus, ValidatorInterface validator)
        +__invoke(SymfonyStyle io, string email, array roles = ['ROLE_USER']) : int
        -messageBus : MessageBusInterface (readonly)
        -validator : ValidatorInterface (readonly)
    }
    class CreateUser {
        +email : string
        +roles : array
    }
    CreateCommand ..> CreateUser : uses
    CreateCommand ..> MessageBusInterface
    CreateCommand ..> ValidatorInterface
    CreateCommand ..> SymfonyStyle
Loading

File-Level Changes

Change Details Files
Refactor CreateCommand to use Symfony Console invokable command pattern
  • Replaced execute() with __invoke() injecting SymfonyStyle and typed arguments
  • Added AsCommand and Argument attributes, removed configure(), InputInterface/InputOutput imports
  • Changed messageBus property to readonly in the constructor
src/Command/User/CreateCommand.php
Upgrade Symfony package versions to ^7.3
  • Updated all symfony/* dependency versions in composer.json
  • Refreshed composer.lock to match the new versions
composer.json
composer.lock

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @absumo - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@absumo absumo merged commit e0d0d0f into main Aug 11, 2025
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.

3 participants