Skip to content

Commit

Permalink
Merge pull request #7 from Laragear/fix/builder-contracts
Browse files Browse the repository at this point in the history
[1.x] Uses builder contracts
  • Loading branch information
DarkGhostHunter authored Apr 10, 2024
2 parents 446978f + 8f9d75a commit 49a670f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/RefineQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Laragear\Refine;

use Illuminate\Contracts\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Contracts\Database\Query\Builder;
use Illuminate\Contracts\Validation\Factory as ValidationFactory;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Query\Builder;
use Illuminate\Foundation\Precognition;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
Expand Down Expand Up @@ -74,7 +74,7 @@ public function match(array $keys = null): void
/**
* Validate the refiner.
*/
protected function validateRefiner()
protected function validateRefiner(): void
{
$validator = app(ValidationFactory::class)->make(
$this->request->query(),
Expand Down
6 changes: 4 additions & 2 deletions src/RefineServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Laragear\Refine;

use Illuminate\Contracts\Database\Eloquent\Builder as EloquentBuilderContract;
use Illuminate\Contracts\Database\Query\Builder as BuilderContract;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Query\Builder;
use Illuminate\Support\ServiceProvider;
Expand All @@ -15,8 +17,8 @@ class RefineServiceProvider extends ServiceProvider
*/
public function boot(): void
{
$callback = function (object|string $refiner, array $keys = null): Builder|EloquentBuilder {
/** @var \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder $this */
$callback = function (object|string $refiner, array $keys = null): BuilderContract|EloquentBuilderContract {
/** @var \Illuminate\Contracts\Database\Query\Builder|\Illuminate\Contracts\Database\Eloquent\Builder $this */
return RefineQuery::refine($this, $refiner, $keys);
};

Expand Down
12 changes: 2 additions & 10 deletions src/Refiner.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Laragear\Refine;

use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Query\Builder;
use Illuminate\Contracts\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Contracts\Database\Query\Builder;
use Illuminate\Http\Request;

abstract class Refiner
Expand All @@ -30,10 +30,6 @@ public function getObligatoryKeys(Request $request): array

/**
* Run before the refiner executes its matched methods.
*
* @param \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Http\Request $request
* @return void
*/
public function runBefore(Builder|EloquentBuilder $query, Request $request): void
{
Expand All @@ -42,10 +38,6 @@ public function runBefore(Builder|EloquentBuilder $query, Request $request): voi

/**
* Run after the refiner has executed all its matched methods.
*
* @param \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder $query
* @param \Illuminate\Http\Request $request
* @return void
*/
public function runAfter(Builder|EloquentBuilder $query, Request $request): void
{
Expand Down

0 comments on commit 49a670f

Please sign in to comment.