Skip to content

Commit 60db4bc

Browse files
committed
Fix PHPStan errors against Laravel 13 + larastan 3.9
Bump targets for Laravel 13's generic Scope interface and remove a dead null check that larastan now flags. - PublishingScope: add @implements Scope<TModel> and switch apply() param to Builder<covariant TModel> to match the parent signature variance. - HasDrafts::newRevision: hoist the $updatingModel null guard to an early return so $revision is non-null at use site, silencing identical.alwaysFalse on the redundant check.
1 parent ce44f4c commit 60db4bc

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/Concerns/HasDrafts.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,15 @@ protected function newRevision(): void
117117
}
118118

119119
$updatingModel = $this->fresh();
120-
$revision = $updatingModel?->replicate();
120+
121+
if ($updatingModel === null) {
122+
return;
123+
}
124+
125+
$revision = $updatingModel->replicate();
121126

122127
static::saved(function (Model $model) use ($updatingModel, $revision): void {
123-
if ($model->isNot($this) || $revision === null || $updatingModel === null) {
128+
if ($model->isNot($this)) {
124129
return;
125130
}
126131

src/Scopes/PublishingScope.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
/**
1111
* @template TModel of Model
12+
*
13+
* @implements Scope<TModel>
1214
*/
1315
class PublishingScope implements Scope
1416
{
@@ -20,7 +22,7 @@ class PublishingScope implements Scope
2022
protected $extensions = [/*'Publish', 'Unpublish', 'Schedule', */'Published', 'WithDrafts', 'WithoutDrafts', 'OnlyDrafts'];
2123

2224
/**
23-
* @param Builder<TModel> $builder
25+
* @param Builder<covariant TModel> $builder
2426
* @param TModel $model
2527
*/
2628
public function apply(Builder $builder, Model $model): void

0 commit comments

Comments
 (0)