FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Merge pull request #11418 from laravel/scopes · JavaDevl/framework@74cbbff · GitHub

Commit 74cbbff

Browse files
committed
Merge pull request laravel#11418 from laravel/scopes
[5.2] Actually use the new scope interface
2 parents 697da2c + 834e5e0 commit 74cbbff

4 files changed

Lines changed: 13 additions & 13 deletions

File tree

‎src/Illuminate/Database/Eloquent/Builder.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function __construct(QueryBuilder $query)
8080
* Register a new global scope.
8181
*
8282
* @param string $identifier
83-
* @param \Illuminate\Database\Eloquent\ScopeInterface|\Closure $scope
83+
* @param \Illuminate\Database\Eloquent\Scope|\Closure $scope
8484
* @return $this
8585
*/
8686
public function withGlobalScope($identifier, $scope)
@@ -93,7 +93,7 @@ public function withGlobalScope($identifier, $scope)
9393
/**
9494
* Remove a registered global scope.
9595
*
96-
* @param \Illuminate\Database\Eloquent\ScopeInterface|string $scope
96+
* @param \Illuminate\Database\Eloquent\Scope|string $scope
9797
* @return $this
9898
*/
9999
public function withoutGlobalScope($scope)
@@ -940,15 +940,15 @@ public function applyScopes()
940940
/**
941941
* Apply a single scope on the given builder instance.
942942
*
943-
* @param \Illuminate\Database\Eloquent\ScopeInterface|\Closure $scope
943+
* @param \Illuminate\Database\Eloquent\Scope|\Closure $scope
944944
* @param \Illuminate\Database\Eloquent\Builder $builder
945945
* @return void
946946
*/
947947
protected function applyScope($scope, $builder)
948948
{
949949
if ($scope instanceof Closure) {
950950
$scope($builder);
951-
} elseif ($scope instanceof ScopeInterface) {
951+
} elseif ($scope instanceof Scope) {
952952
$scope->apply($builder, $this->getModel());
953953
}
954954
}

‎src/Illuminate/Database/Eloquent/Model.php‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ public static function clearBootedModels()
338338
/**
339339
* Register a new global scope on the model.
340340
*
341-
* @param \Illuminate\Database\Eloquent\ScopeInterface|\Closure|string $scope
341+
* @param \Illuminate\Database\Eloquent\Scope|\Closure|string $scope
342342
* @param \Closure|null $implementation
343343
* @return mixed
344344
*
@@ -354,17 +354,17 @@ public static function addGlobalScope($scope, Closure $implementation = null)
354354
return static::$globalScopes[get_called_class()][uniqid('scope')] = $scope;
355355
}
356356

357-
if ($scope instanceof ScopeInterface) {
357+
if ($scope instanceof Scope) {
358358
return static::$globalScopes[get_called_class()][get_class($scope)] = $scope;
359359
}
360360

361-
throw new InvalidArgumentException('Global scope must be an instance of Closure or ScopeInterface.');
361+
throw new InvalidArgumentException('Global scope must be an instance of Closure or Scope.');
362362
}
363363

364364
/**
365365
* Determine if a model has a global scope.
366366
*
367-
* @param \Illuminate\Database\Eloquent\ScopeInterface|string $scope
367+
* @param \Illuminate\Database\Eloquent\Scope|string $scope
368368
* @return bool
369369
*/
370370
public static function hasGlobalScope($scope)
@@ -375,8 +375,8 @@ public static function hasGlobalScope($scope)
375375
/**
376376
* Get a global scope registered with the model.
377377
*
378-
* @param \Illuminate\Database\Eloquent\ScopeInterface|string $scope
379-
* @return \Illuminate\Database\Eloquent\ScopeInterface|\Closure|null
378+
* @param \Illuminate\Database\Eloquent\Scope|string $scope
379+
* @return \Illuminate\Database\Eloquent\Scope|\Closure|null
380380
*/
381381
public static function getGlobalScope($scope)
382382
{
@@ -1882,7 +1882,7 @@ public function newQuery()
18821882
/**
18831883
* Get a new query instance without a given scope.
18841884
*
1885-
* @param \Illuminate\Database\Eloquent\ScopeInterface|string $scope
1885+
* @param \Illuminate\Database\Eloquent\Scope|string $scope
18861886
* @return \Illuminate\Database\Eloquent\Builder
18871887
*/
18881888
public function newQueryWithoutScope($scope)

‎src/Illuminate/Database/Eloquent/SoftDeletingScope.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Illuminate\Database\Eloquent;
44

5-
class SoftDeletingScope implements ScopeInterface
5+
class SoftDeletingScope implements Scope
66
{
77
/**
88
* All of the extensions to be added to the builder.

‎tests/Database/DatabaseEloquentGlobalScopesTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public static function boot()
134134
}
135135
}
136136

137-
class ActiveScope implements \Illuminate\Database\Eloquent\ScopeInterface
137+
class ActiveScope implements \Illuminate\Database\Eloquent\Scope
138138
{
139139
public function apply(\Illuminate\Database\Eloquent\Builder $builder, \Illuminate\Database\Eloquent\Model $model)
140140
{

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL