Skip to content

Remove shared StorageInterface in favor of package-level contracts#434

Merged
armanist merged 2 commits into
quantum-php:masterfrom
armanist:433-Remove-shared-StorageInterface-in-favor-of-package-level-contracts
Mar 22, 2026
Merged

Remove shared StorageInterface in favor of package-level contracts#434
armanist merged 2 commits into
quantum-php:masterfrom
armanist:433-Remove-shared-StorageInterface-in-favor-of-package-level-contracts

Conversation

@armanist

@armanist armanist commented Mar 22, 2026

Copy link
Copy Markdown
Collaborator

Closes #433

Summary by CodeRabbit

  • Refactor
    • Reorganized internal contracts across Config, Cookie, Debugger, and Session to use module-specific interfaces instead of a generic storage contract.
    • Introduced clearer method contracts (including explicit return types and an initialize method for debugger storage) and standardized docblocks; runtime behavior unchanged.

@armanist armanist added the enhancement New feature or request label Mar 22, 2026
@coderabbitai

coderabbitai Bot commented Mar 22, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The shared top-level StorageInterface was removed and replaced by package-specific contracts. New or moved interfaces (ConfigInterface, CookieStorageInterface, SessionStorageInterface, DebuggerStoreInterface) are declared inside their packages and implementing classes were updated to implement those interfaces and use @inheritDoc docblocks.

Changes

Cohort / File(s) Summary
Config Package
src/Config/Contracts/ConfigInterface.php, src/Config/Config.php
Added package-level ConfigInterface (storage methods + load/import). Config now implements Quantum\Config\Contracts\ConfigInterface and docblocks replaced with @inheritDoc.
Cookie Package
src/Cookie/Contracts/CookieStorageInterface.php
Removed dependency on shared StorageInterface; interface now declares core storage methods (all(), has(), get(), set(), delete(), flush()) within package.
Debugger Package
src/Debugger/Contracts/DebuggerStoreInterface.php, src/Debugger/DebuggerStore.php
Renamed/moved storage contract to Quantum\Debugger\Contracts\DebuggerStoreInterface, added init(array $keys): void, and added explicit : void return types for mutators; DebuggerStore updated to implement the new interface with @inheritDoc docblocks.
Session Package
src/Session/Contracts/SessionStorageInterface.php
Decoupled from shared StorageInterface; interface now explicitly declares all core storage methods (all(), has(), get(), set(), delete(), flush()) while keeping session-specific APIs (flash, id) unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰
I hopped through contracts, one by one,
Split shared ties till each package shone,
Docblocks trimmed with tidy grace,
Interfaces now sit in place,
A carrot dance for clearer code 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: removing a shared StorageInterface and replacing it with package-level contracts, which is exactly what the changeset accomplishes.
Linked Issues check ✅ Passed All acceptance criteria from issue #433 are met: src/Contracts/ is removed, package-level contracts are implemented self-contained without external extends, implementing classes use @inheritDoc, and the changes maintain existing functionality without duplicating docblocks.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objective of removing the shared StorageInterface and establishing package-level contracts; no unrelated modifications are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

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

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

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

Tip

You can disable poems in the walkthrough.

Disable the reviews.poem setting to disable the poems in the walkthrough.

@armanist armanist added this to the 3.0.0 milestone Mar 22, 2026
@codecov

codecov Bot commented Mar 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.64%. Comparing base (19c2028) to head (1b4667f).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #434   +/-   ##
=========================================
  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.
📢 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 requested a review from andrey-smaelov March 22, 2026 17:20

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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/Cookie/Contracts/CookieStorageInterface.php`:
- Around line 54-59: Add an explicit void return type to the interface method
flush() in CookieStorageInterface so it matches set(): void and delete(): void
and the implementing class Cookie::flush(): void; update the method signature
from "public function flush();" to include ": void" to ensure consistency
between the interface and its implementation.

In `@src/Session/Contracts/SessionStorageInterface.php`:
- Around line 42-59: Update the SessionStorageInterface by adding explicit ":
void" return types to its method signatures for set(), delete(), and flush() so
they match the implemented signatures (and other interfaces like ConfigInterface
and DebuggerStoreInterface); modify the declarations in SessionStorageInterface
(methods set(string $key, $value), delete(string $key), flush()) to include the
void return type to enforce the contract consistency with the implementations in
SessionTrait.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 626db702-8bf1-4673-8d77-c1b2c59a6b29

📥 Commits

Reviewing files that changed from the base of the PR and between 19c2028 and 8b503f0.

📒 Files selected for processing (6)
  • src/Config/Config.php
  • src/Config/Contracts/ConfigInterface.php
  • src/Cookie/Contracts/CookieStorageInterface.php
  • src/Debugger/Contracts/DebuggerStoreInterface.php
  • src/Debugger/DebuggerStore.php
  • src/Session/Contracts/SessionStorageInterface.php

Comment thread src/Cookie/Contracts/CookieStorageInterface.php Outdated
Comment thread src/Session/Contracts/SessionStorageInterface.php Outdated
…eStorageInterface for consistency across all package contracts.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/Cookie/Contracts/CookieStorageInterface.php (1)

25-29: Tighten all() contract to array instead of mixed.

all() represents full cookie storage and the concrete implementation returns an array; declaring that in the interface improves static guarantees and contract clarity.

Proposed refactor
     /**
      * Gets whole storage data
-     * `@return` mixed
+     * `@return` array<string, mixed>
      */
-    public function all();
+    public function all(): array;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Cookie/Contracts/CookieStorageInterface.php` around lines 25 - 29, The
interface method all() currently returns mixed; tighten its return type to array
by changing the CookieStorageInterface::all() signature to return array, update
its docblock accordingly, and then update every implementing class
(implementations of CookieStorageInterface) to match the new return type on
their all() methods, adjusting any callers or tests that relied on mixed to
accept/expect an array; ensure method signatures remain compatible with PHP
return type rules and run static checks/tests to catch any mismatches.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/Cookie/Contracts/CookieStorageInterface.php`:
- Around line 25-29: The interface method all() currently returns mixed; tighten
its return type to array by changing the CookieStorageInterface::all() signature
to return array, update its docblock accordingly, and then update every
implementing class (implementations of CookieStorageInterface) to match the new
return type on their all() methods, adjusting any callers or tests that relied
on mixed to accept/expect an array; ensure method signatures remain compatible
with PHP return type rules and run static checks/tests to catch any mismatches.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8b341578-ca00-43f9-8e93-99edea259726

📥 Commits

Reviewing files that changed from the base of the PR and between 8b503f0 and 1b4667f.

📒 Files selected for processing (2)
  • src/Cookie/Contracts/CookieStorageInterface.php
  • src/Session/Contracts/SessionStorageInterface.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Session/Contracts/SessionStorageInterface.php

@armanist armanist merged commit efd0249 into quantum-php:master Mar 22, 2026
5 checks passed
@armanist armanist deleted the 433-Remove-shared-StorageInterface-in-favor-of-package-level-contracts branch March 22, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove shared StorageInterface in favor of package-level contracts

2 participants