Skip to content

Refactor module templates to remove Response action args and use response() helper #496

Closed

Description

@armanist

Summary

Module template controller and middleware code still includes many method signatures with injected Response $response. We should reduce signature clutter by using the response() helper inside methods where appropriate.

Context

Inventory in src/Module/Templates found 78 methods with Response $response:

  • Controllers (runtime templates): 42
  • Controllers (OpenApi abstract templates): 17
  • Middlewares (runtime templates): 19

Proposed Implementation Order

  1. Controller runtime templates first

    • Remove Response $response from controller action method signatures.
    • Initialize local $response = response(); inside each affected action.
    • Keep return types unchanged.
  2. OpenApi abstract templates second

    • Update OpenApi abstract controller signatures to match runtime controller signatures.
    • Ensure generated classes remain signature-compatible.
  3. Middleware helper refactor (optional, separate scope)

    • Review helper/internal methods like respondWithError(...), validateRequest(...), unauthorizedResponse(...).
    • Decide whether to stop passing Response $response through helper chains and use local response() instances.
    • Keep this as a separate commit (or follow-up ticket) if risk/size grows.

Why This Is Worth Doing

  • Cleaner public action signatures.
  • Less DI/parameter boilerplate.
  • Better consistency with existing template code that already uses response().

Risks / Notes

  • Runtime controllers and OpenApi abstract signatures must be updated together to avoid mismatch.
  • Middleware helper changes are not required for the main cleanup and can be staged.

Acceptance Criteria

  • No controller runtime action in module templates requires Response $response as a method argument.
  • OpenApi abstract template signatures are aligned with corresponding runtime actions.
  • Template generation remains functional.
  • Validation passes:
    • vendor/bin/phpunit
    • composer phpstan
    • composer cs:check

Activity

  1. added this to the 3.0.0 milestone on May 1, 2026
  2. changed the title [-]Refactor module templates to remove Response \ action args and use response() helper[/-] [+]Refactor module templates to remove Response action args and use response() helper[/+] on May 1, 2026
  3. self-assigned this
    on May 1, 2026
  4. added 5 commits that reference this issue on May 1, 2026
  5. added 3 commits that reference this issue on May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions