diff --git a/src/Actions/CreateStorageSymlinksAction.php b/src/Actions/CreateStorageSymlinksAction.php index 779a42af..eac5d933 100644 --- a/src/Actions/CreateStorageSymlinksAction.php +++ b/src/Actions/CreateStorageSymlinksAction.php @@ -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; diff --git a/src/Actions/RemoveStorageSymlinksAction.php b/src/Actions/RemoveStorageSymlinksAction.php index bfbcfa0a..a3660e7a 100644 --- a/src/Actions/RemoveStorageSymlinksAction.php +++ b/src/Actions/RemoveStorageSymlinksAction.php @@ -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; diff --git a/src/Concerns/DealsWithTenantSymlinks.php b/src/Concerns/DealsWithTenantSymlinks.php index a4c972bb..d6d6f5f2 100644 --- a/src/Concerns/DealsWithTenantSymlinks.php +++ b/src/Concerns/DealsWithTenantSymlinks.php @@ -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 */ 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. */ diff --git a/src/Exceptions/DomainOccupiedByOtherTenantException.php b/src/Exceptions/DomainOccupiedByOtherTenantException.php index 00d42f3e..c0860ca8 100644 --- a/src/Exceptions/DomainOccupiedByOtherTenantException.php +++ b/src/Exceptions/DomainOccupiedByOtherTenantException.php @@ -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."); } diff --git a/src/Exceptions/TenancyNotInitializedException.php b/src/Exceptions/TenancyNotInitializedException.php index d2744499..be936747 100644 --- a/src/Exceptions/TenancyNotInitializedException.php +++ b/src/Exceptions/TenancyNotInitializedException.php @@ -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.'); } diff --git a/src/Jobs/CreateDatabase.php b/src/Jobs/CreateDatabase.php index f143f399..dbc4b097 100644 --- a/src/Jobs/CreateDatabase.php +++ b/src/Jobs/CreateDatabase.php @@ -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; } } diff --git a/src/Jobs/CreateStorageSymlinks.php b/src/Jobs/CreateStorageSymlinks.php index 4f18bb03..2e1db88a 100644 --- a/src/Jobs/CreateStorageSymlinks.php +++ b/src/Jobs/CreateStorageSymlinks.php @@ -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); } diff --git a/src/Jobs/DeleteDomains.php b/src/Jobs/DeleteDomains.php index 8d89ce9e..15fff779 100644 --- a/src/Jobs/DeleteDomains.php +++ b/src/Jobs/DeleteDomains.php @@ -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) diff --git a/src/Middleware/IdentificationMiddleware.php b/src/Middleware/IdentificationMiddleware.php index ed582c93..12aa4a16 100644 --- a/src/Middleware/IdentificationMiddleware.php +++ b/src/Middleware/IdentificationMiddleware.php @@ -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( diff --git a/src/Middleware/ScopeSessions.php b/src/Middleware/ScopeSessions.php index a72146d7..dc302ee5 100644 --- a/src/Middleware/ScopeSessions.php +++ b/src/Middleware/ScopeSessions.php @@ -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