Skip to content

refactor(types): add a reference state enum and precise return types - #103

Merged
jfrosorio merged 1 commit into
masterfrom
refactor-99
Sep 26, 2026
Merged

jfrosorio merged 1 commit into
masterfrom
refactor-99

Conversation

@jfrosorio

Copy link
Copy Markdown
Contributor

Description

Code-quality cleanup with no behaviour change and no break of the public API.

  • A new ReferenceState enum (Pending = 0, Paid = 1) replaces the raw 0/1 in the callback controllers and the paid() scopes. The stored values, and what $reference->state returns, are unchanged.
  • The seven @return mixed docblocks now give the real types: Builder<static> for the paid() scopes and array|null for Dispatchable::dispatch().
  • The private service provider methods and the transaction closures get native return types, and so does 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.

Copilot AI lite review requested due to automatic review settings September 26, 2026 17:00
@jfrosorio jfrosorio self-assigned this Sep 26, 2026

Copilot AI 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.

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 Low severity

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 and scopePaid() query scopes instead of raw literals.
  • Replaces several @return mixed docblocks with more specific types (notably Builder<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.

Comment thread src/Events/Dispatchable.php
@jfrosorio
jfrosorio merged commit 321e8ad into master Sep 26, 2026
18 checks passed
@jfrosorio
jfrosorio deleted the refactor-99 branch September 26, 2026 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean up raw state values and imprecise return types

2 participants