diff --git a/src/Commands/TenantList.php b/src/Commands/TenantList.php index 6e6100af..6c865221 100644 --- a/src/Commands/TenantList.php +++ b/src/Commands/TenantList.php @@ -31,7 +31,11 @@ class TenantList extends Command return 0; } - /** Generate the visual CLI output for the tenant name. */ + /** + * Generate the visual CLI output for the tenant name. + * + * @param Model&Tenant $tenant + */ 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 9c7f6374..3ee8f4b5 100644 --- a/src/Database/Concerns/HasPending.php +++ b/src/Database/Concerns/HasPending.php @@ -45,6 +45,7 @@ trait HasPending * Create a pending tenant. * * @param array $attributes + * @return Model&Tenant */ public static function createPending(array $attributes = []): Tenant { @@ -63,7 +64,11 @@ trait HasPending return $tenant; } - /** Pull a pending tenant. */ + /** + * Pull a pending tenant. + * + * @return Model&Tenant + */ public static function pullPending(): Tenant { /** @var Model&Tenant $pendingTenant */ diff --git a/src/Database/DatabaseConfig.php b/src/Database/DatabaseConfig.php index a4df5349..3f0ac809 100644 --- a/src/Database/DatabaseConfig.php +++ b/src/Database/DatabaseConfig.php @@ -6,16 +6,21 @@ namespace Stancl\Tenancy\Database; use Closure; use Illuminate\Database; +use Illuminate\Support\Str; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Hash; -use Illuminate\Support\Str; +use Illuminate\Database\Eloquent\Model; +use Stancl\Tenancy\Database\Exceptions\NoConnectionSetException; use Stancl\Tenancy\Database\Contracts\TenantWithDatabase as Tenant; use Stancl\Tenancy\Database\Exceptions\DatabaseManagerNotRegisteredException; -use Stancl\Tenancy\Database\Exceptions\NoConnectionSetException; class DatabaseConfig { - /** The tenant whose database we're dealing with. */ + /** + * The tenant whose database we're dealing with. + * + * @var Tenant&Model $tenant + */ public Tenant $tenant; /** Database username generator (can be set by the developer.) */ @@ -29,19 +34,23 @@ class DatabaseConfig public static function __constructStatic(): void { + /** @param Model&Tenant $tenant */ static::$usernameGenerator = static::$usernameGenerator ?? function (Tenant $tenant) { return Str::random(16); }; + /** @param Model&Tenant $tenant */ static::$passwordGenerator = static::$passwordGenerator ?? function (Tenant $tenant) { return Hash::make(Str::random(32)); }; + /** @param Model&Tenant $tenant */ static::$databaseNameGenerator = static::$databaseNameGenerator ?? function (Tenant $tenant) { return config('tenancy.database.prefix') . $tenant->getTenantKey() . config('tenancy.database.suffix'); }; } + /** @param Model&Tenant $tenant */ public function __construct(Tenant $tenant) { static::__constructStatic(); diff --git a/src/Jobs/CreateDatabase.php b/src/Jobs/CreateDatabase.php index dcb01ab7..d58761f1 100644 --- a/src/Jobs/CreateDatabase.php +++ b/src/Jobs/CreateDatabase.php @@ -5,19 +5,21 @@ declare(strict_types=1); namespace Stancl\Tenancy\Jobs; use Illuminate\Bus\Queueable; +use Illuminate\Queue\SerializesModels; +use Illuminate\Database\Eloquent\Model; +use Illuminate\Queue\InteractsWithQueue; +use Stancl\Tenancy\Events\DatabaseCreated; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; -use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Queue\SerializesModels; -use Stancl\Tenancy\Database\Contracts\TenantWithDatabase; -use Stancl\Tenancy\Database\DatabaseManager; use Stancl\Tenancy\Events\CreatingDatabase; -use Stancl\Tenancy\Events\DatabaseCreated; +use Stancl\Tenancy\Database\DatabaseManager; +use Stancl\Tenancy\Database\Contracts\TenantWithDatabase; class CreateDatabase implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + /** @param TenantWithDatabase&Model $tenant */ public function __construct( protected TenantWithDatabase $tenant, ) { diff --git a/src/Jobs/DeleteDatabase.php b/src/Jobs/DeleteDatabase.php index c7c927be..5cd03789 100644 --- a/src/Jobs/DeleteDatabase.php +++ b/src/Jobs/DeleteDatabase.php @@ -5,18 +5,23 @@ declare(strict_types=1); namespace Stancl\Tenancy\Jobs; use Illuminate\Bus\Queueable; +use Illuminate\Queue\SerializesModels; +use Illuminate\Database\Eloquent\Model; +use Illuminate\Queue\InteractsWithQueue; +use Stancl\Tenancy\Events\DatabaseDeleted; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; -use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Queue\SerializesModels; -use Stancl\Tenancy\Database\Contracts\TenantWithDatabase; -use Stancl\Tenancy\Events\DatabaseDeleted; use Stancl\Tenancy\Events\DeletingDatabase; +use Stancl\Tenancy\Database\Contracts\TenantWithDatabase; class DeleteDatabase implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + /** + * @var TenantWithDatabase&Model $tenant + * @param TenantWithDatabase&Model $tenant + */ public function __construct( protected TenantWithDatabase $tenant, ) { diff --git a/src/Jobs/DeleteDomains.php b/src/Jobs/DeleteDomains.php index 3b4ef18f..ba954909 100644 --- a/src/Jobs/DeleteDomains.php +++ b/src/Jobs/DeleteDomains.php @@ -5,20 +5,23 @@ declare(strict_types=1); namespace Stancl\Tenancy\Jobs; use Illuminate\Bus\Queueable; -use Illuminate\Foundation\Bus\Dispatchable; -use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; +use Illuminate\Database\Eloquent\Model; +use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Foundation\Bus\Dispatchable; use Stancl\Tenancy\Database\Contracts\TenantWithDatabase; class DeleteDomains { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - protected TenantWithDatabase $tenant; - - public function __construct(TenantWithDatabase $tenant) - { - $this->tenant = $tenant; + /** + * @var TenantWithDatabase&Model $tenant + * @param TenantWithDatabase&Model $tenant + */ + public function __construct( + protected TenantWithDatabase $tenant + ) { } public function handle(): void diff --git a/src/Jobs/MigrateDatabase.php b/src/Jobs/MigrateDatabase.php index dfad9517..b07023d5 100644 --- a/src/Jobs/MigrateDatabase.php +++ b/src/Jobs/MigrateDatabase.php @@ -5,17 +5,22 @@ declare(strict_types=1); namespace Stancl\Tenancy\Jobs; use Illuminate\Bus\Queueable; +use Illuminate\Queue\SerializesModels; +use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\Artisan; +use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; -use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Queue\SerializesModels; -use Illuminate\Support\Facades\Artisan; use Stancl\Tenancy\Database\Contracts\TenantWithDatabase; class MigrateDatabase implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + /** + * @var TenantWithDatabase&Model $tenant + * @param TenantWithDatabase&Model $tenant + */ public function __construct( protected TenantWithDatabase $tenant, ) { diff --git a/src/Jobs/SeedDatabase.php b/src/Jobs/SeedDatabase.php index a882cd3e..3b81242f 100644 --- a/src/Jobs/SeedDatabase.php +++ b/src/Jobs/SeedDatabase.php @@ -5,17 +5,22 @@ declare(strict_types=1); namespace Stancl\Tenancy\Jobs; use Illuminate\Bus\Queueable; +use Illuminate\Queue\SerializesModels; +use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\Artisan; +use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; -use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Queue\SerializesModels; -use Illuminate\Support\Facades\Artisan; use Stancl\Tenancy\Database\Contracts\TenantWithDatabase; class SeedDatabase implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + /** + * @var TenantWithDatabase&Model $tenant + * @param TenantWithDatabase&Model $tenant + */ public function __construct( protected TenantWithDatabase $tenant, ) { diff --git a/src/Listeners/UpdateSyncedResource.php b/src/Listeners/UpdateSyncedResource.php index ffbcc1f8..defe0016 100644 --- a/src/Listeners/UpdateSyncedResource.php +++ b/src/Listeners/UpdateSyncedResource.php @@ -165,6 +165,8 @@ class UpdateSyncedResource extends QueueableListener /** * Split the attribute names (sequential index items) and default values (key => values). + * + * @param Model&Syncable $model */ protected function getAttributeNamesAndDefaultValues(Syncable $model): array { diff --git a/src/Resolvers/DomainTenantResolver.php b/src/Resolvers/DomainTenantResolver.php index 6f9bf81f..65c22f21 100644 --- a/src/Resolvers/DomainTenantResolver.php +++ b/src/Resolvers/DomainTenantResolver.php @@ -49,6 +49,7 @@ class DomainTenantResolver extends Contracts\CachedTenantResolver /** @var Tenant&Model $tenant */ $tenant->unsetRelation('domains'); + /** @param 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 3cf2e416..f726a3b7 100644 --- a/src/Tenancy.php +++ b/src/Tenancy.php @@ -92,6 +92,7 @@ class Tenancy return static::model()->query(); } + /** @return Tenant&Model */ public static function model(): Tenant { /** @var class-string $class */