mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 17:24:03 +00:00
get phpstan errors down from 252 to 189
This commit is contained in:
parent
fb8b9c1614
commit
8af354c20e
40 changed files with 119 additions and 115 deletions
|
|
@ -10,7 +10,7 @@ use Stancl\Tenancy\Events\TenancyInitialized;
|
|||
|
||||
class BootstrapTenancy
|
||||
{
|
||||
public function handle(TenancyInitialized $event)
|
||||
public function handle(TenancyInitialized $event): void
|
||||
{
|
||||
event(new BootstrappingTenancy($event->tenancy));
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class CreateTenantConnection
|
|||
$this->database = $database;
|
||||
}
|
||||
|
||||
public function handle(TenantEvent $event)
|
||||
public function handle(TenantEvent $event): void
|
||||
{
|
||||
$this->database->createTenantConnection($event->tenant);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
|||
*/
|
||||
abstract class QueueableListener implements ShouldQueue
|
||||
{
|
||||
public static $shouldQueue = false;
|
||||
public static bool $shouldQueue = false;
|
||||
|
||||
public function shouldQueue($event)
|
||||
public function shouldQueue($event): bool
|
||||
{
|
||||
if (static::$shouldQueue) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use Stancl\Tenancy\Events\TenancyEnded;
|
|||
|
||||
class RevertToCentralContext
|
||||
{
|
||||
public function handle(TenancyEnded $event)
|
||||
public function handle(TenancyEnded $event): void
|
||||
{
|
||||
event(new RevertingToCentralContext($event->tenancy));
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue