Skip to content

Conversation

@sumaiazaman
Copy link
Contributor

This PR removes unused $app parameters from closures that don't use the application container instance.

Changes:

  • db.transactions singleton: Remove unused $app parameter
  • ConcurrencyErrorDetectorContract singleton: Remove unused $app parameter
  • LostConnectionDetectorContract singleton: Remove unused $app parameter

Benefits:

  • Cleaner code that clearly shows when container access is not needed
  • Eliminates unused parameter warnings in static analysis tools
  • More explicit about closure dependencies
  • Consistent with Laravel's coding standards

Rationale:
These closures only instantiate classes without dependencies (DatabaseTransactionsManager, ConcurrencyErrorDetector, LostConnectionDetector), so they don't need access to the application container.

Testing:

  • All existing tests continue to pass
  • No functional changes to service registration
  • Services are still properly registered as singletons

Before:

$this->app->singleton('db.transactions', function ($app) {
    return new DatabaseTransactionsManager;
});

After:

$this->app->singleton('db.transactions', function () {
    return new DatabaseTransactionsManager;
});

Remove unused $app parameters from closures that don't use the
application container instance. These closures only instantiate
classes without dependencies, so the container parameter is not needed.

- db.transactions singleton
- ConcurrencyErrorDetectorContract singleton
- LostConnectionDetectorContract singleton
@sumaiazaman sumaiazaman changed the title Remove unused closure parameters in DatabaseServiceProvider [12.x] Remove unused closure parameters in DatabaseServiceProvider Nov 3, 2025
@taylorotwell taylorotwell merged commit 8583094 into laravel:12.x Nov 3, 2025
68 checks passed
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.

2 participants