diff --git a/src/Commands/TenantList.php b/src/Commands/TenantList.php index c008ba59..6e6100af 100644 --- a/src/Commands/TenantList.php +++ b/src/Commands/TenantList.php @@ -32,7 +32,7 @@ class TenantList extends Command } /** Generate the visual CLI output for the tenant name. */ - protected function tenantCLI(Model&Tenant $tenant): string + protected function tenantCLI(Tenant $tenant): string { return "{$tenant->getTenantKeyName()}: {$tenant->getTenantKey()}"; } diff --git a/src/Database/Concerns/HasPending.php b/src/Database/Concerns/HasPending.php index 4d72486f..9c7f6374 100644 --- a/src/Database/Concerns/HasPending.php +++ b/src/Database/Concerns/HasPending.php @@ -46,7 +46,7 @@ trait HasPending * * @param array $attributes */ - public static function createPending(array $attributes = []): Model&Tenant + public static function createPending(array $attributes = []): Tenant { $tenant = static::create($attributes); @@ -64,7 +64,7 @@ trait HasPending } /** Pull a pending tenant. */ - public static function pullPending(): Model&Tenant + public static function pullPending(): Tenant { /** @var Model&Tenant $pendingTenant */ $pendingTenant = static::pullPendingFromPool(true); diff --git a/src/Database/DatabaseConfig.php b/src/Database/DatabaseConfig.php index 52cb464c..a4df5349 100644 --- a/src/Database/DatabaseConfig.php +++ b/src/Database/DatabaseConfig.php @@ -6,7 +6,6 @@ namespace Stancl\Tenancy\Database; use Closure; use Illuminate\Database; -use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Str; @@ -17,7 +16,7 @@ use Stancl\Tenancy\Database\Exceptions\NoConnectionSetException; class DatabaseConfig { /** The tenant whose database we're dealing with. */ - public Tenant&Model $tenant; + public Tenant $tenant; /** Database username generator (can be set by the developer.) */ public static Closure|null $usernameGenerator = null; @@ -30,20 +29,20 @@ class DatabaseConfig public static function __constructStatic(): void { - static::$usernameGenerator = static::$usernameGenerator ?? function (Model&Tenant $tenant) { + static::$usernameGenerator = static::$usernameGenerator ?? function (Tenant $tenant) { return Str::random(16); }; - static::$passwordGenerator = static::$passwordGenerator ?? function (Model&Tenant $tenant) { + static::$passwordGenerator = static::$passwordGenerator ?? function (Tenant $tenant) { return Hash::make(Str::random(32)); }; - static::$databaseNameGenerator = static::$databaseNameGenerator ?? function (Model&Tenant $tenant) { + static::$databaseNameGenerator = static::$databaseNameGenerator ?? function (Tenant $tenant) { return config('tenancy.database.prefix') . $tenant->getTenantKey() . config('tenancy.database.suffix'); }; } - public function __construct(Model&Tenant $tenant) + public function __construct(Tenant $tenant) { static::__constructStatic(); diff --git a/src/Events/SyncedResourceSaved.php b/src/Events/SyncedResourceSaved.php index 5c3b1334..a634503d 100644 --- a/src/Events/SyncedResourceSaved.php +++ b/src/Events/SyncedResourceSaved.php @@ -10,8 +10,9 @@ use Stancl\Tenancy\Database\Contracts\TenantWithDatabase; class SyncedResourceSaved { + /** @param Syncable|Model $model */ public function __construct( - public Syncable&Model $model, + public Syncable $model, public TenantWithDatabase|null $tenant, ) { } diff --git a/src/Jobs/CreateDatabase.php b/src/Jobs/CreateDatabase.php index dbc4b097..dcb01ab7 100644 --- a/src/Jobs/CreateDatabase.php +++ b/src/Jobs/CreateDatabase.php @@ -6,7 +6,6 @@ namespace Stancl\Tenancy\Jobs; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; @@ -20,7 +19,7 @@ class CreateDatabase implements ShouldQueue use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; public function __construct( - protected TenantWithDatabase&Model $tenant, + protected TenantWithDatabase $tenant, ) { } diff --git a/src/Jobs/DeleteDatabase.php b/src/Jobs/DeleteDatabase.php index 71358f74..c7c927be 100644 --- a/src/Jobs/DeleteDatabase.php +++ b/src/Jobs/DeleteDatabase.php @@ -6,7 +6,6 @@ namespace Stancl\Tenancy\Jobs; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; @@ -19,7 +18,7 @@ class DeleteDatabase implements ShouldQueue use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; public function __construct( - protected TenantWithDatabase&Model $tenant, + protected TenantWithDatabase $tenant, ) { } diff --git a/src/Jobs/DeleteDomains.php b/src/Jobs/DeleteDomains.php index 15fff779..3b4ef18f 100644 --- a/src/Jobs/DeleteDomains.php +++ b/src/Jobs/DeleteDomains.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace Stancl\Tenancy\Jobs; use Illuminate\Bus\Queueable; -use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; @@ -15,9 +14,9 @@ class DeleteDomains { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - protected TenantWithDatabase&Model $tenant; + protected TenantWithDatabase $tenant; - public function __construct(TenantWithDatabase&Model $tenant) + public function __construct(TenantWithDatabase $tenant) { $this->tenant = $tenant; } diff --git a/src/Jobs/MigrateDatabase.php b/src/Jobs/MigrateDatabase.php index 4624f212..dfad9517 100644 --- a/src/Jobs/MigrateDatabase.php +++ b/src/Jobs/MigrateDatabase.php @@ -6,7 +6,6 @@ namespace Stancl\Tenancy\Jobs; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; @@ -18,7 +17,7 @@ class MigrateDatabase implements ShouldQueue use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; public function __construct( - protected TenantWithDatabase&Model $tenant, + protected TenantWithDatabase $tenant, ) { } diff --git a/src/Jobs/SeedDatabase.php b/src/Jobs/SeedDatabase.php index e1bae0c7..a882cd3e 100644 --- a/src/Jobs/SeedDatabase.php +++ b/src/Jobs/SeedDatabase.php @@ -6,7 +6,6 @@ namespace Stancl\Tenancy\Jobs; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Database\Eloquent\Model; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; @@ -18,7 +17,7 @@ class SeedDatabase implements ShouldQueue use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; public function __construct( - protected TenantWithDatabase&Model $tenant, + protected TenantWithDatabase $tenant, ) { } diff --git a/src/Listeners/UpdateSyncedResource.php b/src/Listeners/UpdateSyncedResource.php index 38245a80..ffbcc1f8 100644 --- a/src/Listeners/UpdateSyncedResource.php +++ b/src/Listeners/UpdateSyncedResource.php @@ -138,7 +138,8 @@ class UpdateSyncedResource extends QueueableListener }); } - protected function getAttributesForCreation(Model&Syncable $model): array + /** @param Syncable&Model $model */ + protected function getAttributesForCreation(Syncable $model): array { if (! $model->getSyncedCreationAttributes()) { // Creation attributes are not specified so create the model as 1:1 copy @@ -165,7 +166,7 @@ class UpdateSyncedResource extends QueueableListener /** * Split the attribute names (sequential index items) and default values (key => values). */ - protected function getAttributeNamesAndDefaultValues(Model&Syncable $model): array + protected function getAttributeNamesAndDefaultValues(Syncable $model): array { $syncedCreationAttributes = $model->getSyncedCreationAttributes() ?? []; diff --git a/src/Resolvers/DomainTenantResolver.php b/src/Resolvers/DomainTenantResolver.php index ceecd0b6..6f9bf81f 100644 --- a/src/Resolvers/DomainTenantResolver.php +++ b/src/Resolvers/DomainTenantResolver.php @@ -49,7 +49,7 @@ class DomainTenantResolver extends Contracts\CachedTenantResolver /** @var Tenant&Model $tenant */ $tenant->unsetRelation('domains'); - return $tenant->domains->map(function (Domain&Model $domain) { + return $tenant->domains->map(function (Domain $domain) { return [$domain->domain]; })->toArray(); } diff --git a/src/Tenancy.php b/src/Tenancy.php index 6de52c42..3cf2e416 100644 --- a/src/Tenancy.php +++ b/src/Tenancy.php @@ -92,7 +92,7 @@ class Tenancy return static::model()->query(); } - public static function model(): Tenant&Model + public static function model(): Tenant { /** @var class-string $class */ $class = config('tenancy.models.tenant');