Skip to content

Issue/500 qt prefix class rename#501

Merged
armanist merged 6 commits intosoftberg:masterfrom
armanist:issue/500-qt-prefix-class-rename
May 4, 2026
Merged

Issue/500 qt prefix class rename#501
armanist merged 6 commits intosoftberg:masterfrom
armanist:issue/500-qt-prefix-class-rename

Conversation

@armanist
Copy link
Copy Markdown
Member

@armanist armanist commented May 4, 2026

Closes #500

Summary by CodeRabbit

Release Notes

  • Refactor
    • Simplified naming conventions for core framework base classes (Service, Middleware, Migration, and Console Command). Updated all framework implementations, module templates, and tests accordingly. This is a breaking change in v3.0.0 requiring updates to custom implementations extending these base classes.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

📝 Walkthrough

Walkthrough

The PR renames four framework base classes throughout the codebase: QtCommandCliCommand, QtServiceService, QtMiddlewareMiddleware, and QtMigrationMigration. All usages, templates, type constraints, factory validations, and tests are systematically updated to reference the new class names.

Changes

Base Class Renaming & Migration

Layer / File(s) Summary
Base Class Definitions
src/Console/CliCommand.php, src/Service/Service.php, src/Middleware/Middleware.php, src/Migration/Migration.php
The four abstract base classes are renamed (docblocks updated), and exception messages are updated to reference Service instead of QtService.
Framework Validations & Type Constraints
src/Console/CommandDiscovery.php, src/Middleware/MiddlewareManager.php, src/Migration/MigrationManager.php, src/Service/Factories/ServiceFactory.php, src/Service/Helpers/service.php, src/Storage/Factories/FileSystemFactory.php, src/Auth/Factories/AuthFactory.php
instanceof checks, return type docblocks, factory template constraints, and exception class references are updated from Qt* to new class names across discovery, validation, and factory layers.
Console Commands
src/Console/Commands/*.php
All 13 built-in commands (CronRun, DebugBar, Env, InstallToolkit, KeyGenerate, MigrationGenerate, MigrationMigrate, ModuleGenerate, OpenApi, ResourceCacheClear, RouteList, Serve, Version) update their imports and class inheritance to extend CliCommand instead of QtCommand.
Migration System
src/Migration/MigrationTable.php, src/Migration/MigrationManager.php, src/Migration/Enums/ExceptionMessages.php, src/Migration/Templates/MigrationTemplate.php
MigrationTable extends Migration; MigrationManager validates against Migration; exception messages reference Migration; MigrationTemplate generates migration classes extending Migration.
Module Templates
src/Module/Templates/DemoApi/src/**, src/Module/Templates/DemoWeb/src/**, src/Module/Templates/Toolkit/src/**
Template files (.tpl) for services, middlewares, and controllers are updated: service imports/extensions changed from QtService to Service, middleware from QtMiddleware to Middleware. Additionally, missing Response import added to DemoWeb CommentController.tpl, and EmailsController.tpl fixed to return the redirect response.
Test Classes & Assertions
tests/Unit/Console/CliCommandTest.php, tests/Unit/Console/CommandDiscoveryTest.php, tests/Unit/Middleware/MiddlewareManagerTest.php, tests/Unit/Migration/**, tests/Unit/Service/**, tests/Unit/Di/DiTest.php, tests/_root/shared/**, tests/_root/modules/Test/**
Test class names and method names updated (e.g., QtCommandTestCliCommandTest, test method assertions updated to validate against new class names); test fixture services and commands updated to extend new base classes; exception message assertions updated to reference new class names.
Changelog
CHANGELOG.md
Four BREAKING entries added documenting the class renames.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Possibly related issues

  • #500: Rename Qt-prefixed base classes and migrate all usages/templates with backward compatibility — This PR fully addresses the objectives of introducing new class names and migrating all framework internals and templates to use them.

Possibly related PRs

  • #499: Both PRs modify DemoWeb CommentController.tpl to add the missing Response import and Toolkit EmailsController.tpl to return the redirect result — directly related template fixes.
  • #466: Both PRs update MiddlewareManager::getMiddleware() validation and return type handling — related middleware system changes.
  • #487: Both PRs affect migration class base types and test validations — related migration subsystem changes.

Suggested labels

refactoring, enhancement

Suggested reviewers

  • andrey-smaelov
  • charoyan88
  • live-soft
  • grigoryanmartin20

🐰 Hop along, dear framework!
Old names fade to Qt no more,
Service, Command, Middleware, Migration—clean and pure.
Templates fresh, exceptions clear,
A brighter path, the future's here!

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR does not implement backward compatibility by creating new classes first and keeping old Qt* classes as thin aliases as required by issue #500. Add backward-compatible alias classes (QtCommand, QtService, QtMiddleware, QtMigration) that extend the new classes with deprecation docblocks before merging.
Out of Scope Changes check ⚠️ Warning Changes to src/Module/Templates/Toolkit/src/Controllers/EmailsController.php.tpl (redirect return statement) and src/Module/Templates/DemoWeb/src/Controllers/CommentController.php.tpl (missing Response import) appear unrelated to the Qt-prefix class rename objective. Either justify these controller template changes as separate scope or move them to a distinct PR focused on controller/response handling improvements.
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% 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 'Issue/500 qt prefix class rename' accurately describes the main change: renaming Qt-prefixed base classes throughout the framework.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.87%. Comparing base (28a6bd9) to head (667c989).
⚠️ Report is 9 commits behind head on master.

Files with missing lines Patch % Lines
src/Service/Factories/ServiceFactory.php 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master     #501   +/-   ##
=========================================
  Coverage     90.87%   90.87%           
  Complexity     2926     2926           
=========================================
  Files           255      255           
  Lines          7703     7703           
=========================================
  Hits           7000     7000           
  Misses          703      703           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@armanist armanist added enhancement New feature or request help wanted Extra attention is needed refactoring labels May 4, 2026
@armanist armanist added this to the 3.0.0 milestone May 4, 2026
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/Module/Templates/DemoWeb/src/Middlewares/Auth.php.tpl (1)

17-35: ⚠️ Potential issue | 🔴 Critical

Add a constructor to match MiddlewareManager's instantiation pattern.

MiddlewareManager::getMiddleware() instantiates middleware with new $middlewareClass($request), but this template lacks a constructor. Generated middleware classes will fail at runtime with an argument-count error.

Suggested fix
 class Auth extends Middleware
 {
+    public function __construct(Request $request)
+    {
+    }
+
     public function apply(Request $request, Closure $next): Response
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Module/Templates/DemoWeb/src/Middlewares/Auth.php.tpl` around lines 17 -
35, The Auth middleware template must accept the Request argument because
MiddlewareManager::getMiddleware() instantiates middleware with new
$middlewareClass($request); add a public constructor to the Auth class that
accepts Request $request (typed), and either call parent::__construct($request)
or store it on a private property (e.g., $this->request) so the class can be
instantiated without an argument-count error; ensure the constructor signature
matches the Request type used in apply().
src/Migration/Templates/MigrationTemplate.php (1)

28-50: ⚠️ Potential issue | 🔴 Critical

Emit void return type and use non-nullable parameter in all generated migration methods.

Quantum\Migration\Migration requires up(TableFactory $tableFactory): void and down(TableFactory $tableFactory): void, but the templates emit up(?TableFactory $tableFactory) and down(?TableFactory $tableFactory) instead—missing both the : void return type and using a nullable parameter. Generated migrations will not satisfy the abstract contract.

Suggested fix
-    public function up(?TableFactory $tableFactory) {
+    public function up(TableFactory $tableFactory): void {
         $table = $tableFactory->create(\'' . $tableName . '\');
     }
     
-    public function down(?TableFactory $tableFactory)
+    public function down(TableFactory $tableFactory): void
     {
         $tableFactory->drop(\'' . $tableName . '\');
     }

Also applies to lines 56–78, 83–105, 110–132.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Migration/Templates/MigrationTemplate.php` around lines 28 - 50, The
generated migration method signatures in MigrationTemplate::create currently use
nullable parameters and omit the void return type; update the template strings
so both methods use a non-nullable TableFactory parameter and a void return type
(change "public function up(?TableFactory $tableFactory)" to "public function
up(TableFactory $tableFactory): void" and likewise for "down") and apply the
same change to the other template occurrences in this file (the other
create/template-returning blocks referenced around lines 56–78, 83–105, 110–132)
so generated migrations match Quantum\Migration\Migration's contract.
🧹 Nitpick comments (1)
tests/Unit/Migration/Templates/MigrationTemplateTest.php (1)

10-46: ⚡ Quick win

Cover the generated method headers too.

The current assertions only verify the new import and class name. They will still pass if up() / down() regress away from the Migration contract again, so the test suite won't catch the main compatibility break.

Suggested addition
 $this->assertStringContainsString('use Quantum\Migration\Migration;', $template);
 $this->assertStringContainsString('class Create_table_users_1001 extends Migration', $template);
+$this->assertStringContainsString('public function up(TableFactory $tableFactory): void', $template);
+$this->assertStringContainsString('public function down(TableFactory $tableFactory): void', $template);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/Unit/Migration/Templates/MigrationTemplateTest.php` around lines 10 -
46, The tests for MigrationTemplate::create/alter/rename/drop only assert
imports and class names; add assertions to each test
(testCreateTemplateContainsExpectedOperations,
testAlterTemplateContainsExpectedOperations,
testRenameTemplateContainsExpectedOperations,
testDropTemplateContainsExpectedOperations) that the generated template includes
the migration method headers (e.g. the exact strings for the up() and down()
signatures used by the Migration contract such as "public function up(): void"
and "public function down(): void" or the project's exact signatures) so
regressions to the up/down method signatures will be caught.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/Unit/Migration/MigrationManagerTest.php`:
- Around line 211-215: The test suite lost coverage of legacy QtMigration
because createValidMigrationFile always generates classes extending
\\Quantum\\Migration\\Migration; update tests to also generate a legacy fixture
extending \\Quantum\\Migration\\QtMigration and assert MigrationManager::upgrade
(or the test method that runs upgrades) still succeeds. either enhance
createValidMigrationFile to accept a parent-class parameter (defaulting to
Migration) or add a new helper createLegacyMigrationFile that writes a class
extending \\Quantum\\Migration\\QtMigration, then add a test case that uses this
helper and runs the existing upgrade/assert logic from the MigrationManagerTest
to verify backward compatibility.

---

Outside diff comments:
In `@src/Migration/Templates/MigrationTemplate.php`:
- Around line 28-50: The generated migration method signatures in
MigrationTemplate::create currently use nullable parameters and omit the void
return type; update the template strings so both methods use a non-nullable
TableFactory parameter and a void return type (change "public function
up(?TableFactory $tableFactory)" to "public function up(TableFactory
$tableFactory): void" and likewise for "down") and apply the same change to the
other template occurrences in this file (the other create/template-returning
blocks referenced around lines 56–78, 83–105, 110–132) so generated migrations
match Quantum\Migration\Migration's contract.

In `@src/Module/Templates/DemoWeb/src/Middlewares/Auth.php.tpl`:
- Around line 17-35: The Auth middleware template must accept the Request
argument because MiddlewareManager::getMiddleware() instantiates middleware with
new $middlewareClass($request); add a public constructor to the Auth class that
accepts Request $request (typed), and either call parent::__construct($request)
or store it on a private property (e.g., $this->request) so the class can be
instantiated without an argument-count error; ensure the constructor signature
matches the Request type used in apply().

---

Nitpick comments:
In `@tests/Unit/Migration/Templates/MigrationTemplateTest.php`:
- Around line 10-46: The tests for MigrationTemplate::create/alter/rename/drop
only assert imports and class names; add assertions to each test
(testCreateTemplateContainsExpectedOperations,
testAlterTemplateContainsExpectedOperations,
testRenameTemplateContainsExpectedOperations,
testDropTemplateContainsExpectedOperations) that the generated template includes
the migration method headers (e.g. the exact strings for the up() and down()
signatures used by the Migration contract such as "public function up(): void"
and "public function down(): void" or the project's exact signatures) so
regressions to the up/down method signatures will be caught.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 80faa52f-dbc6-44b3-9bb2-838084f31d48

📥 Commits

Reviewing files that changed from the base of the PR and between a21747f and 667c989.

📒 Files selected for processing (60)
  • CHANGELOG.md
  • src/Auth/Factories/AuthFactory.php
  • src/Console/CliCommand.php
  • src/Console/CommandDiscovery.php
  • src/Console/Commands/CronRunCommand.php
  • src/Console/Commands/DebugBarCommand.php
  • src/Console/Commands/EnvCommand.php
  • src/Console/Commands/InstallToolkitCommand.php
  • src/Console/Commands/KeyGenerateCommand.php
  • src/Console/Commands/MigrationGenerateCommand.php
  • src/Console/Commands/MigrationMigrateCommand.php
  • src/Console/Commands/ModuleGenerateCommand.php
  • src/Console/Commands/OpenApiCommand.php
  • src/Console/Commands/ResourceCacheClearCommand.php
  • src/Console/Commands/RouteListCommand.php
  • src/Console/Commands/ServeCommand.php
  • src/Console/Commands/VersionCommand.php
  • src/Middleware/Middleware.php
  • src/Middleware/MiddlewareManager.php
  • src/Migration/Enums/ExceptionMessages.php
  • src/Migration/Migration.php
  • src/Migration/MigrationManager.php
  • src/Migration/MigrationTable.php
  • src/Migration/Templates/MigrationTemplate.php
  • src/Module/Templates/DemoApi/src/Middlewares/BaseMiddleware.php.tpl
  • src/Module/Templates/DemoApi/src/Services/AuthService.php.tpl
  • src/Module/Templates/DemoApi/src/Services/CommentService.php.tpl
  • src/Module/Templates/DemoApi/src/Services/PostService.php.tpl
  • src/Module/Templates/DemoWeb/src/Controllers/CommentController.php.tpl
  • src/Module/Templates/DemoWeb/src/Middlewares/Auth.php.tpl
  • src/Module/Templates/DemoWeb/src/Middlewares/BaseMiddleware.php.tpl
  • src/Module/Templates/DemoWeb/src/Middlewares/Guest.php.tpl
  • src/Module/Templates/DemoWeb/src/Services/AuthService.php.tpl
  • src/Module/Templates/DemoWeb/src/Services/CommandService.php.tpl
  • src/Module/Templates/DemoWeb/src/Services/CommentService.php.tpl
  • src/Module/Templates/DemoWeb/src/Services/PostService.php.tpl
  • src/Module/Templates/Toolkit/src/Controllers/EmailsController.php.tpl
  • src/Module/Templates/Toolkit/src/Middlewares/BaseMiddleware.php.tpl
  • src/Module/Templates/Toolkit/src/Middlewares/BasicAuth.php.tpl
  • src/Module/Templates/Toolkit/src/Services/DashboardService.php.tpl
  • src/Module/Templates/Toolkit/src/Services/DatabaseService.php.tpl
  • src/Module/Templates/Toolkit/src/Services/EmailService.php.tpl
  • src/Module/Templates/Toolkit/src/Services/LogsService.php.tpl
  • src/Service/Factories/ServiceFactory.php
  • src/Service/Helpers/service.php
  • src/Service/Service.php
  • src/Storage/Factories/FileSystemFactory.php
  • tests/Unit/Console/CliCommandTest.php
  • tests/Unit/Console/CommandDiscoveryTest.php
  • tests/Unit/Di/DiTest.php
  • tests/Unit/Middleware/MiddlewareManagerTest.php
  • tests/Unit/Migration/Exceptions/MigrationExceptionTest.php
  • tests/Unit/Migration/MigrationManagerTest.php
  • tests/Unit/Migration/Templates/MigrationTemplateTest.php
  • tests/Unit/Service/Factories/ServiceFactoryTest.php
  • tests/Unit/Service/Helpers/ServiceHelperFunctionTest.php
  • tests/Unit/Service/ServiceTest.php
  • tests/_root/modules/Test/Services/AuthService.php
  • tests/_root/shared/Commands/TestCommand.php
  • tests/_root/shared/Services/TokenService.php

Comment thread tests/Unit/Migration/MigrationManagerTest.php
@armanist armanist merged commit c476902 into softberg:master May 4, 2026
7 checks passed
@armanist armanist deleted the issue/500-qt-prefix-class-rename branch May 4, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request help wanted Extra attention is needed refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rename Qt-prefixed base classes and migrate all usages/templates with backward compatibility

2 participants