1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-13 03:54:02 +00:00

get phpstan errors down from 252 to 189

This commit is contained in:
Samuel Štancl 2022-08-30 05:44:23 +02:00
parent fb8b9c1614
commit 8af354c20e
40 changed files with 119 additions and 115 deletions

View file

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Stancl\Tenancy\Listeners;
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\Pivot;
use Stancl\Tenancy\Contracts\SyncMaster;
@ -13,9 +14,9 @@ use Stancl\Tenancy\Exceptions\ModelNotSyncMasterException;
class UpdateSyncedResource extends QueueableListener
{
public static $shouldQueue = false;
public static bool $shouldQueue = false;
public function handle(SyncedResourceSaved $event)
public function handle(SyncedResourceSaved $event): void
{
$syncedAttributes = $event->model->only($event->model->getSyncedAttributeNames());
@ -29,7 +30,7 @@ class UpdateSyncedResource extends QueueableListener
$this->updateResourceInTenantDatabases($tenants, $event, $syncedAttributes);
}
protected function getTenantsForCentralModel($centralModel)
protected function getTenantsForCentralModel($centralModel): EloquentCollection
{
if (! $centralModel instanceof SyncMaster) {
// If we're trying to use a tenant User model instead of the central User model, for example.
@ -45,7 +46,7 @@ class UpdateSyncedResource extends QueueableListener
return $centralModel->tenants;
}
protected function updateResourceInCentralDatabaseAndGetTenants($event, $syncedAttributes)
protected function updateResourceInCentralDatabaseAndGetTenants($event, $syncedAttributes): EloquentCollection
{
/** @var Model|SyncMaster $centralModel */
$centralModel = $event->model->getCentralModelName()::where($event->model->getGlobalIdentifierKeyName(), $event->model->getGlobalIdentifierKey())
@ -85,7 +86,7 @@ class UpdateSyncedResource extends QueueableListener
});
}
protected function updateResourceInTenantDatabases($tenants, $event, $syncedAttributes)
protected function updateResourceInTenantDatabases($tenants, $event, $syncedAttributes): void
{
tenancy()->runForMultiple($tenants, function ($tenant) use ($event, $syncedAttributes) {
// Forget instance state and find the model,