From 74cfd2edf24ae36dc3157a7c9d12a2111fbb7e8b Mon Sep 17 00:00:00 2001 From: Katalam Date: Wed, 18 Jan 2023 14:51:58 +0100 Subject: [PATCH] Fix phpstan $this in Blueprint macro is falsly parsed --- src/CreatedByServiceProvider.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/CreatedByServiceProvider.php b/src/CreatedByServiceProvider.php index d6418cc..5c76d46 100644 --- a/src/CreatedByServiceProvider.php +++ b/src/CreatedByServiceProvider.php @@ -25,6 +25,7 @@ public function packageRegistered(): void { if (! Blueprint::hasMacro('createdBy')) { Blueprint::macro('createdBy', function () { + /** @var Blueprint $this */ $this->foreignIdFor(config('auth.providers.users.model', User::class), 'created_by') ->nullable() ->default(null); @@ -32,6 +33,7 @@ public function packageRegistered(): void } if (! Blueprint::hasMacro('updatedBy')) { Blueprint::macro('updatedBy', function () { + /** @var Blueprint $this */ $this->foreignIdFor(config('auth.providers.users.model', User::class), 'updated_by') ->nullable() ->default(null); @@ -39,6 +41,7 @@ public function packageRegistered(): void } if (! Blueprint::hasMacro('deletedBy')) { Blueprint::macro('deletedBy', function () { + /** @var Blueprint $this */ $this->foreignIdFor(config('auth.providers.users.model', User::class), 'deleted_by') ->nullable() ->default(null); @@ -46,6 +49,7 @@ public function packageRegistered(): void } if (! Blueprint::hasMacro('restoredBy')) { Blueprint::macro('restoredBy', function () { + /** @var Blueprint $this */ $this->foreignIdFor(config('auth.providers.users.model', User::class), 'restored_by') ->nullable() ->default(null); @@ -53,31 +57,37 @@ public function packageRegistered(): void } if (! Blueprint::hasMacro('restoredAt')) { Blueprint::macro('restoredAt', function () { + /** @var Blueprint $this */ $this->timestamp('restored_at')->nullable()->default(null); }); } if (! Blueprint::hasMacro('dropCreatedBy')) { Blueprint::macro('dropCreatedBy', function () { + /** @var Blueprint $this */ $this->dropColumn('created_by'); }); } if (! Blueprint::hasMacro('dropUpdatedBy')) { Blueprint::macro('dropUpdatedBy', function () { + /** @var Blueprint $this */ $this->dropColumn('updated_by'); }); } if (! Blueprint::hasMacro('dropDeletedBy')) { Blueprint::macro('dropDeletedBy', function () { + /** @var Blueprint $this */ $this->dropColumn('deleted_by'); }); } if (! Blueprint::hasMacro('dropRestoredBy')) { Blueprint::macro('dropRestoredBy', function () { + /** @var Blueprint $this */ $this->dropColumn('restored_by'); }); } if (! Blueprint::hasMacro('dropRestoredAt')) { Blueprint::macro('dropRestoredAt', function () { + /** @var Blueprint $this */ $this->dropColumn('restored_at'); }); }