437 extract adapter type constants from main classes into dedicated enum classes#438
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (14)
✅ Files skipped from review due to trivial changes (13)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughExtracted adapter-type string constants from 13 facade classes into dedicated enum-like classes under each package's Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #438 +/- ##
=========================================
Coverage 82.64% 82.64%
Complexity 2721 2721
=========================================
Files 241 241
Lines 7305 7305
=========================================
Hits 6037 6037
Misses 1268 1268 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
src/Database/Enums/DatabaseType.php (1)
20-22: Align class docblock package with namespace.At Line 21,
@package Quantum\Databaseis slightly inconsistent withQuantum\Database\Enums. Consider updating the package tag for clearer generated docs.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Database/Enums/DatabaseType.php` around lines 20 - 22, The docblock for class DatabaseType has an inaccurate `@package` tag; update the phpdoc above the DatabaseType class so the `@package` value matches the namespace (Quantum\Database\Enums) or remove the `@package` tag entirely; locate the DatabaseType class declaration in the file and modify its docblock accordingly.src/Paginator/Factories/PaginatorFactory.php (1)
62-77: Consider documenting accepted enum values.The
create()method acceptsstring $typebut should only receivePaginatorType::ARRAYorPaginatorType::MODEL. Since PHP 7.4 doesn't support native enums, the current approach is appropriate, but a brief PHPDoc note would improve clarity.📝 Suggested documentation improvement
/** * Creates a new paginator instance using the selected adapter type. + * `@param` string $type One of PaginatorType::ARRAY or PaginatorType::MODEL * `@param` array<string, mixed> $params * `@throws` BaseException * `@throws` PaginatorException */ public static function create(string $type, array $params): Paginator🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Paginator/Factories/PaginatorFactory.php` around lines 62 - 77, Add a PHPDoc block to PaginatorFactory::create explaining that the $type parameter must be one of the supported paginator types (PaginatorType::ARRAY or PaginatorType::MODEL), document the expected shape of $params and reference the ADAPTERS map; update the doc to show examples or a `@param` annotation like "string $type One of PaginatorType::ARRAY|PaginatorType::MODEL" and mention that other values will throw PaginatorException::adapterNotSupported, so callers know the valid enum-like values without native enum support.tests/Unit/Captcha/Factories/CaptchaFactoryTest.php (1)
29-34: Pre-existing naming inconsistency: test methods use "CacheFactory" instead of "CaptchaFactory".The test methods
testCacheFactoryDefaultAdapter,testCacheFactoryRecaptchaAdapter,testCacheFactoryHcaptchaAdapter, andtestCacheFactoryInvalidTypeAdapterappear to have been copy-pasted from cache tests and not renamed. Consider renaming these totestCaptchaFactory*for clarity.This is not introduced by this PR but worth noting for future cleanup.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/Unit/Captcha/Factories/CaptchaFactoryTest.php` around lines 29 - 34, Rename the misnamed test methods in CaptchaFactoryTest so they reflect CaptchaFactory rather than CacheFactory: change testCacheFactoryDefaultAdapter to testCaptchaFactoryDefaultAdapter, testCacheFactoryRecaptchaAdapter to testCaptchaFactoryRecaptchaAdapter, testCacheFactoryHcaptchaAdapter to testCaptchaFactoryHcaptchaAdapter, and testCacheFactoryInvalidTypeAdapter to testCaptchaFactoryInvalidTypeAdapter; update any references to these method names (e.g., in test suites or docblocks) to ensure consistency while leaving the assertions (like usage of CaptchaFactory::get and assertions on getAdapter() / RecaptchaAdapter/HcaptchaAdapter) unchanged.
🤖 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/Logger/Factories/LoggerFactory.php`:
- Around line 66-70: Resolve the effective adapter before enforcing the
non-debug rejection: move the adapter default resolution using "$adapter =
$isDebug ? LoggerType::MESSAGE : ($adapter ?? config()->get('logging.default'))"
to run before the guard, then perform the check "if (!$isDebug && $adapter ===
LoggerType::MESSAGE) { throw
LoggerException::adapterNotSupported(LoggerType::MESSAGE); }" so the guard
validates the final adapter value instead of the raw nullable $adapter.
In `@tests/Unit/Session/Factories/SessionFactoryTest.php`:
- Around line 115-121: Rename the PHPUnit test method named
testMailerFactoryReturnsSameInstance to testSessionFactoryReturnsSameInstance in
the SessionFactoryTest class so the method name matches the behavior (it
exercises SessionFactory::get with SessionType::NATIVE); update the method
declaration only (preserve the body asserting $this->assertSame($session1,
$session2)) to avoid copy-paste confusion and ensure the test runner recognizes
it as the correct test.
---
Nitpick comments:
In `@src/Database/Enums/DatabaseType.php`:
- Around line 20-22: The docblock for class DatabaseType has an inaccurate
`@package` tag; update the phpdoc above the DatabaseType class so the `@package`
value matches the namespace (Quantum\Database\Enums) or remove the `@package` tag
entirely; locate the DatabaseType class declaration in the file and modify its
docblock accordingly.
In `@src/Paginator/Factories/PaginatorFactory.php`:
- Around line 62-77: Add a PHPDoc block to PaginatorFactory::create explaining
that the $type parameter must be one of the supported paginator types
(PaginatorType::ARRAY or PaginatorType::MODEL), document the expected shape of
$params and reference the ADAPTERS map; update the doc to show examples or a
`@param` annotation like "string $type One of
PaginatorType::ARRAY|PaginatorType::MODEL" and mention that other values will
throw PaginatorException::adapterNotSupported, so callers know the valid
enum-like values without native enum support.
In `@tests/Unit/Captcha/Factories/CaptchaFactoryTest.php`:
- Around line 29-34: Rename the misnamed test methods in CaptchaFactoryTest so
they reflect CaptchaFactory rather than CacheFactory: change
testCacheFactoryDefaultAdapter to testCaptchaFactoryDefaultAdapter,
testCacheFactoryRecaptchaAdapter to testCaptchaFactoryRecaptchaAdapter,
testCacheFactoryHcaptchaAdapter to testCaptchaFactoryHcaptchaAdapter, and
testCacheFactoryInvalidTypeAdapter to testCaptchaFactoryInvalidTypeAdapter;
update any references to these method names (e.g., in test suites or docblocks)
to ensure consistency while leaving the assertions (like usage of
CaptchaFactory::get and assertions on getAdapter() /
RecaptchaAdapter/HcaptchaAdapter) unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f3e792c1-2860-49f9-bda5-e629a65c2bb2
📒 Files selected for processing (64)
src/App/App.phpsrc/App/Enums/AppType.phpsrc/App/Factories/AppFactory.phpsrc/Archive/Archive.phpsrc/Archive/Enums/ArchiveType.phpsrc/Archive/Factories/ArchiveFactory.phpsrc/Auth/Auth.phpsrc/Auth/Enums/AuthType.phpsrc/Auth/Factories/AuthFactory.phpsrc/Cache/Cache.phpsrc/Cache/Enums/CacheType.phpsrc/Cache/Factories/CacheFactory.phpsrc/Captcha/Captcha.phpsrc/Captcha/Enums/CaptchaType.phpsrc/Captcha/Factories/CaptchaFactory.phpsrc/Cron/CronManager.phpsrc/Database/Database.phpsrc/Database/Enums/DatabaseType.phpsrc/Encryption/Cryptor.phpsrc/Encryption/Enums/CryptorType.phpsrc/Encryption/Factories/CryptorFactory.phpsrc/Encryption/Helpers/encryption.phpsrc/Logger/Enums/LoggerType.phpsrc/Logger/Factories/LoggerFactory.phpsrc/Logger/Logger.phpsrc/Mailer/Enums/MailerType.phpsrc/Mailer/Factories/MailerFactory.phpsrc/Mailer/Mailer.phpsrc/Model/DbModel.phpsrc/Module/Templates/Toolkit/src/Services/EmailService.php.tplsrc/Module/Templates/Toolkit/src/Services/LogsService.php.tplsrc/Paginator/Enums/PaginatorType.phpsrc/Paginator/Factories/PaginatorFactory.phpsrc/Paginator/Paginator.phpsrc/Renderer/Enums/RendererType.phpsrc/Renderer/Factories/RendererFactory.phpsrc/Renderer/Renderer.phpsrc/Session/Enums/SessionType.phpsrc/Session/Factories/SessionFactory.phpsrc/Session/Session.phpsrc/Storage/Enums/FileSystemType.phpsrc/Storage/Factories/FileSystemFactory.phpsrc/Storage/FileSystem.phptests/Unit/App/Factories/AppFactoryTest.phptests/Unit/AppTestCase.phptests/Unit/Archive/Factories/ArchiveFactoryTest.phptests/Unit/Auth/Factories/AuthFactoryTest.phptests/Unit/Auth/Helpers/AuthHelperFunctionsTest.phptests/Unit/Cache/Factories/CacheFactoryTest.phptests/Unit/Cache/Helpers/CacheHelperFunctionsTest.phptests/Unit/Captcha/Factories/CaptchaFactoryTest.phptests/Unit/Captcha/Helpers/CaptchaHelperFunctionsTest.phptests/Unit/Encryption/Factories/CryptorFactoryTest.phptests/Unit/Encryption/Helpers/CryptorHelperFunctionsTest.phptests/Unit/Logger/Factories/LoggerFactoryTest.phptests/Unit/Logger/Helpers/LoggerHelperFunctionsTest.phptests/Unit/Mailer/Factories/MailerFactoryTest.phptests/Unit/Mailer/Helpers/MailerHelperFunctionsTest.phptests/Unit/Paginator/Factories/PaginatorFactoryTest.phptests/Unit/Renderer/Factories/RendererFactoryTest.phptests/Unit/Session/Factories/SessionFactoryTest.phptests/Unit/Session/Helpers/SessionHelperFunctionsTest.phptests/Unit/Storage/Factories/FileSystemFactoryTest.phptests/Unit/Storage/Helpers/FileSystemHelperFunctionsTest.php
💤 Files with no reviewable changes (12)
- src/App/App.php
- src/Archive/Archive.php
- src/Encryption/Cryptor.php
- src/Captcha/Captcha.php
- src/Logger/Logger.php
- src/Paginator/Paginator.php
- src/Session/Session.php
- src/Auth/Auth.php
- src/Renderer/Renderer.php
- src/Cache/Cache.php
- src/Storage/FileSystem.php
- src/Mailer/Mailer.php
Closes #437
Summary by CodeRabbit