1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-15 06:44:03 +00:00

fix phpstan errors

This commit is contained in:
Samuel Štancl 2024-08-06 04:35:25 +02:00
parent 18a16e6a74
commit 4372e1bef2
20 changed files with 105 additions and 16 deletions

View file

@ -42,6 +42,9 @@ class Link extends Command
return 0;
}
/**
* @param LazyCollection<covariant int|string, \Stancl\Tenancy\Contracts\Tenant&\Illuminate\Database\Eloquent\Model> $tenants
*/
protected function removeLinks(LazyCollection $tenants): void
{
(new RemoveStorageSymlinksAction)($tenants);
@ -49,6 +52,9 @@ class Link extends Command
$this->components->info('The links have been removed.');
}
/**
* @param LazyCollection<covariant int|string, \Stancl\Tenancy\Contracts\Tenant&\Illuminate\Database\Eloquent\Model> $tenants
*/
protected function createLinks(LazyCollection $tenants): void
{
(new CreateStorageSymlinksAction)(

View file

@ -52,20 +52,23 @@ class Migrate extends MigrateCommand
if ($this->getProcesses() > 1) {
return $this->runConcurrently($this->getTenantChunks()->map(function ($chunk) {
return $this->getTenants(array_values($chunk->all()));
return $this->getTenants($chunk->all());
}));
}
return $this->migrateTenants($this->getTenants()) ? 0 : 1;
}
protected function childHandle(...$args): bool
protected function childHandle(mixed ...$args): bool
{
$chunk = $args[0];
return $this->migrateTenants($chunk);
}
/**
* @param LazyCollection<covariant int|string, \Stancl\Tenancy\Contracts\Tenant&\Illuminate\Database\Eloquent\Model> $tenants
*/
protected function migrateTenants(LazyCollection $tenants): bool
{
$success = true;

View file

@ -38,14 +38,18 @@ class MigrateFresh extends BaseCommand
if ($this->getProcesses() > 1) {
return $this->runConcurrently($this->getTenantChunks()->map(function ($chunk) {
return $this->getTenants(array_values($chunk->all()));
return $this->getTenants($chunk->all());
}));
}
tenancy()->runForMultiple($this->getTenants(), function ($tenant) use (&$success) {
$this->components->info("Tenant: {$tenant->getTenantKey()}");
$this->components->task('Dropping tables', fn () => $success = $success && $this->wipeDB());
$this->components->task('Migrating', fn () => $success = $success && $this->migrateTenant($tenant));
$this->components->task('Dropping tables', function () use (&$success) {
$success = $success && $this->wipeDB();
});
$this->components->task('Migrating', function () use ($tenant, &$success) {
$success = $success && $this->migrateTenant($tenant);
});
});
return $success ? 0 : 1;
@ -69,13 +73,16 @@ class MigrateFresh extends BaseCommand
]) === 0;
}
protected function childHandle(...$args): bool
protected function childHandle(mixed ...$args): bool
{
$chunk = $args[0];
return $this->migrateFreshTenants($chunk);
}
/**
* @param LazyCollection<covariant int|string, \Stancl\Tenancy\Contracts\Tenant&\Illuminate\Database\Eloquent\Model> $tenants
*/
protected function migrateFreshTenants(LazyCollection $tenants): bool
{
$success = true;

View file

@ -42,7 +42,7 @@ class Rollback extends RollbackCommand
if ($this->getProcesses() > 1) {
return $this->runConcurrently($this->getTenantChunks()->map(function ($chunk) {
return $this->getTenants(array_values($chunk->all()));
return $this->getTenants($chunk->all());
}));
}
@ -54,13 +54,16 @@ class Rollback extends RollbackCommand
return 'tenants:rollback';
}
protected function childHandle(...$args): bool
protected function childHandle(mixed ...$args): bool
{
$chunk = $args[0];
return $this->rollbackTenants($chunk);
}
/**
* @param LazyCollection<covariant int|string, \Stancl\Tenancy\Contracts\Tenant&\Illuminate\Database\Eloquent\Model> $tenants
*/
protected function rollbackTenants(LazyCollection $tenants): bool
{
$success = true;

View file

@ -41,6 +41,9 @@ class TenantList extends Command
}
/** Generate the visual CLI output for the domain names. */
/**
* @param Collection<int|string, string>|null $domains
*/
protected function domainsCLI(?Collection $domains): ?string
{
if (! $domains) {