refactor(types): add a reference state enum and precise return types - #103
Merged
Merged
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The updated Dispatchable::dispatch() return PHPDoc appears to be imprecise (array|null) for how event() is invoked here, which conflicts with the PR’s goal of more precise typing.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
This PR is a type-safety/clarity refactor that replaces raw state integers (0/1) with a dedicated ReferenceState enum at call sites (while keeping stored values unchanged), and tightens several previously-imprecise return type annotations/signatures.
Changes:
- Introduces
ReferenceState(Pending=0,Paid=1) and uses it in callback controllers andscopePaid()query scopes instead of raw literals. - Replaces several
@return mixeddocblocks with more specific types (notablyBuilder<static>for scopes, and a concrete return type description for event dispatch). - Adds native return types to private service-provider methods and to an unreleased scope (
scopeAccepting()), plus explicit closure return types inside DB transactions.
| File | Description |
|---|---|
| src/Providers/EuPagoServiceProvider.php | Adds : void return types to private boot helper methods. |
| src/Models/PayShopReference.php | Uses ReferenceState::Paid->value in scopePaid() and tightens PHPDoc types. |
| src/Models/PaysafeCardReference.php | Uses ReferenceState::Paid->value in scopePaid() and tightens PHPDoc types. |
| src/Models/MbwayReference.php | Uses ReferenceState::Paid->value in scopePaid() and tightens PHPDoc types. |
| src/Models/MbReference.php | Uses ReferenceState in scopePaid(), and adds native types to scopeAccepting(). |
| src/Models/CreditCardReference.php | Uses ReferenceState::Paid->value in scopePaid() and tightens PHPDoc types. |
| src/Http/Controllers/MBController.php | Uses ReferenceState and adds explicit transaction closure return type. |
| src/Http/Controllers/Controller.php | Uses ReferenceState and adds explicit transaction closure return type. |
| src/Events/Dispatchable.php | Updates the documented return type of dispatch(). |
| src/Enums/ReferenceState.php | Adds the new enum used to replace raw state constants. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Code-quality cleanup with no behaviour change and no break of the public API.
ReferenceStateenum (Pending = 0,Paid = 1) replaces the raw0/1in the callback controllers and thepaid()scopes. The stored values, and what$reference->statereturns, are unchanged.@return mixeddocblocks now give the real types:Builder<static>for thepaid()scopes andarray|nullforDispatchable::dispatch().scopeAccepting(), which is unreleased.Native return types on public and protected methods, the
broadcastOn()placeholders on the paid events, and the public class renames break the public API, so they are left for v4.Fixes
This fixes #99.