mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 20:54:04 +00:00
phpstan improvements
This commit is contained in:
parent
87212e5390
commit
d463e2da61
10 changed files with 18 additions and 27 deletions
|
|
@ -8,7 +8,7 @@ use Exception;
|
|||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\LazyCollection;
|
||||
use Stancl\Tenancy\Concerns\DealsWithTenantSymlinks;
|
||||
use Stancl\Tenancy\Database\Models\Tenant;
|
||||
use Stancl\Tenancy\Contracts\Tenant;
|
||||
use Stancl\Tenancy\Events\CreatingStorageSymlink;
|
||||
use Stancl\Tenancy\Events\StorageSymlinkCreated;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Stancl\Tenancy\Actions;
|
|||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\LazyCollection;
|
||||
use Stancl\Tenancy\Concerns\DealsWithTenantSymlinks;
|
||||
use Stancl\Tenancy\Database\Models\Tenant;
|
||||
use Stancl\Tenancy\Contracts\Tenant;
|
||||
use Stancl\Tenancy\Events\RemovingStorageSymlink;
|
||||
use Stancl\Tenancy\Events\StorageSymlinkRemoved;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ trait DealsWithTenantSymlinks
|
|||
* Tenants can have a symlink for each disk registered in the tenancy.filesystem.url_override config.
|
||||
*
|
||||
* This is used for creating all possible tenant symlinks and removing all existing tenant symlinks.
|
||||
*
|
||||
* @return Collection<string, string>
|
||||
*/
|
||||
protected static function possibleTenantSymlinks(Tenant $tenant): Collection
|
||||
{
|
||||
|
|
@ -33,7 +35,7 @@ trait DealsWithTenantSymlinks
|
|||
});
|
||||
}
|
||||
|
||||
return $symlinks->mapWithKeys(fn ($item) => $item);
|
||||
return $symlinks->mapWithKeys(fn ($item) => $item); // [[a => b], [c => d]] -> [a => b, c => d]
|
||||
}
|
||||
|
||||
/** Determine if the provided path is an existing symlink. */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use Exception;
|
|||
|
||||
class DomainOccupiedByOtherTenantException extends Exception
|
||||
{
|
||||
public function __construct($domain)
|
||||
public function __construct(string $domain)
|
||||
{
|
||||
parent::__construct("The $domain domain is occupied by another tenant.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use Exception;
|
|||
|
||||
class TenancyNotInitializedException extends Exception
|
||||
{
|
||||
public function __construct($message = '')
|
||||
public function __construct(string $message = '')
|
||||
{
|
||||
parent::__construct($message ?: 'Tenancy is not initialized.');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class CreateDatabase implements ShouldQueue
|
|||
) {
|
||||
}
|
||||
|
||||
public function handle(DatabaseManager $databaseManager)
|
||||
public function handle(DatabaseManager $databaseManager): bool
|
||||
{
|
||||
event(new CreatingDatabase($this->tenant));
|
||||
|
||||
|
|
@ -38,5 +38,7 @@ class CreateDatabase implements ShouldQueue
|
|||
$this->tenant->database()->manager()->createDatabase($this->tenant);
|
||||
|
||||
event(new DatabaseCreated($this->tenant));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,24 +16,11 @@ class CreateStorageSymlinks implements ShouldQueue
|
|||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public Tenant $tenant;
|
||||
public function __construct(
|
||||
public Tenant $tenant,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Tenant $tenant)
|
||||
{
|
||||
$this->tenant = $tenant;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): void
|
||||
{
|
||||
CreateStorageSymlinksAction::handle($this->tenant);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,14 +9,12 @@ use Illuminate\Database\Eloquent\Model;
|
|||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Stancl\Tenancy\Database\Concerns\HasDomains;
|
||||
use Stancl\Tenancy\Database\Contracts\TenantWithDatabase;
|
||||
|
||||
class DeleteDomains
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var TenantWithDatabase&Model&HasDomains */ // todo unresolvable type for phpstan
|
||||
protected TenantWithDatabase&Model $tenant;
|
||||
|
||||
public function __construct(TenantWithDatabase&Model $tenant)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace Stancl\Tenancy\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Stancl\Tenancy\Contracts\TenantCouldNotBeIdentifiedException;
|
||||
use Stancl\Tenancy\Contracts\TenantResolver;
|
||||
use Stancl\Tenancy\Tenancy;
|
||||
|
|
@ -17,7 +18,8 @@ abstract class IdentificationMiddleware
|
|||
{
|
||||
public static ?Closure $onFail = null;
|
||||
|
||||
public function initializeTenancy($request, $next, ...$resolverArguments)
|
||||
/** @return \Illuminate\Http\Response|mixed */
|
||||
public function initializeTenancy(Request $request, Closure $next, mixed ...$resolverArguments): mixed
|
||||
{
|
||||
try {
|
||||
$this->tenancy->initialize(
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use Stancl\Tenancy\Exceptions\TenancyNotInitializedException;
|
|||
|
||||
class ScopeSessions
|
||||
{
|
||||
public static $tenantIdKey = '_tenant_id';
|
||||
public static string $tenantIdKey = '_tenant_id';
|
||||
|
||||
/** @return \Illuminate\Http\Response|mixed */
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue