mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-13 09:44: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 @@ trait BelongsToPrimaryModel
|
|||
{
|
||||
abstract public function getRelationshipToPrimaryModel(): string;
|
||||
|
||||
public static function bootBelongsToPrimaryModel()
|
||||
public static function bootBelongsToPrimaryModel(): void
|
||||
{
|
||||
static::addGlobalScope(new ParentModelScope);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ trait BelongsToTenant
|
|||
return $this->belongsTo(config('tenancy.tenant_model'), BelongsToTenant::$tenantIdColumn);
|
||||
}
|
||||
|
||||
public static function bootBelongsToTenant()
|
||||
public static function bootBelongsToTenant(): void
|
||||
{
|
||||
static::addGlobalScope(new TenantScope);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace Stancl\Tenancy\Database\Concerns;
|
|||
|
||||
trait ConvertsDomainsToLowercase
|
||||
{
|
||||
public static function bootConvertsDomainsToLowercase()
|
||||
public static function bootConvertsDomainsToLowercase(): void
|
||||
{
|
||||
static::saving(function ($model) {
|
||||
$model->domain = strtolower($model->domain);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use Stancl\Tenancy\Exceptions\DomainOccupiedByOtherTenantException;
|
|||
|
||||
trait EnsuresDomainIsNotOccupied
|
||||
{
|
||||
public static function bootEnsuresDomainIsNotOccupied()
|
||||
public static function bootEnsuresDomainIsNotOccupied(): void
|
||||
{
|
||||
static::saving(function ($self) {
|
||||
if ($domain = $self->newQuery()->where('domain', $self->domain)->first()) {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use Stancl\Tenancy\Contracts\UniqueIdentifierGenerator;
|
|||
|
||||
trait GeneratesIds
|
||||
{
|
||||
public static function bootGeneratesIds()
|
||||
public static function bootGeneratesIds(): void
|
||||
{
|
||||
static::creating(function (self $model) {
|
||||
if (! $model->getKey() && $model->shouldGenerateId()) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ trait InvalidatesResolverCache
|
|||
Resolvers\RequestDataTenantResolver::class,
|
||||
];
|
||||
|
||||
public static function bootInvalidatesResolverCache()
|
||||
public static function bootInvalidatesResolverCache(): void
|
||||
{
|
||||
static::saved(function (Tenant $tenant) {
|
||||
foreach (static::$resolvers as $resolver) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ trait InvalidatesTenantsResolverCache
|
|||
Resolvers\RequestDataTenantResolver::class,
|
||||
];
|
||||
|
||||
public static function bootInvalidatesTenantsResolverCache()
|
||||
public static function bootInvalidatesTenantsResolverCache(): void
|
||||
{
|
||||
static::saved(function (Model $model) {
|
||||
foreach (static::$resolvers as $resolver) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use Stancl\Tenancy\Events\SyncedResourceSaved;
|
|||
|
||||
trait ResourceSyncing
|
||||
{
|
||||
public static function bootResourceSyncing()
|
||||
public static function bootResourceSyncing(): void
|
||||
{
|
||||
static::saved(function (Syncable $model) {
|
||||
/** @var ResourceSyncing $model */
|
||||
|
|
@ -27,7 +27,7 @@ trait ResourceSyncing
|
|||
});
|
||||
}
|
||||
|
||||
public function triggerSyncEvent()
|
||||
public function triggerSyncEvent(): void
|
||||
{
|
||||
/** @var Syncable $this */
|
||||
event(new SyncedResourceSaved($this, tenant()));
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class DatabaseManager
|
|||
/**
|
||||
* Connect to a tenant's database.
|
||||
*/
|
||||
public function connectToTenant(TenantWithDatabase $tenant)
|
||||
public function connectToTenant(TenantWithDatabase $tenant): void
|
||||
{
|
||||
$this->purgeTenantConnection();
|
||||
$this->createTenantConnection($tenant);
|
||||
|
|
@ -44,7 +44,7 @@ class DatabaseManager
|
|||
/**
|
||||
* Reconnect to the default non-tenant connection.
|
||||
*/
|
||||
public function reconnectToCentral()
|
||||
public function reconnectToCentral(): void
|
||||
{
|
||||
$this->purgeTenantConnection();
|
||||
$this->setDefaultConnection($this->config->get('tenancy.database.central_connection'));
|
||||
|
|
@ -53,7 +53,7 @@ class DatabaseManager
|
|||
/**
|
||||
* Change the default database connection config.
|
||||
*/
|
||||
public function setDefaultConnection(string $connection)
|
||||
public function setDefaultConnection(string $connection): void
|
||||
{
|
||||
$this->config['database.default'] = $connection;
|
||||
$this->database->setDefaultConnection($connection);
|
||||
|
|
@ -62,7 +62,7 @@ class DatabaseManager
|
|||
/**
|
||||
* Create the tenant database connection.
|
||||
*/
|
||||
public function createTenantConnection(TenantWithDatabase $tenant)
|
||||
public function createTenantConnection(TenantWithDatabase $tenant): void
|
||||
{
|
||||
$this->config['database.connections.tenant'] = $tenant->database()->connection();
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ class DatabaseManager
|
|||
/**
|
||||
* Purge the tenant database connection.
|
||||
*/
|
||||
public function purgeTenantConnection()
|
||||
public function purgeTenantConnection(): void
|
||||
{
|
||||
if (array_key_exists('tenant', $this->database->getConnections())) {
|
||||
$this->database->purge('tenant');
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use Exception;
|
|||
|
||||
class NoConnectionSetException extends Exception
|
||||
{
|
||||
public function __construct($manager)
|
||||
public function __construct(string $manager)
|
||||
{
|
||||
parent::__construct("No connection was set on this $manager instance.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace Stancl\Tenancy\Database\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Stancl\Tenancy\Contracts;
|
||||
use Stancl\Tenancy\Contracts\Tenant;
|
||||
use Stancl\Tenancy\Database\Concerns;
|
||||
|
|
@ -25,7 +26,7 @@ class Domain extends Model implements Contracts\Domain
|
|||
|
||||
protected $guarded = [];
|
||||
|
||||
public function tenant()
|
||||
public function tenant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(config('tenancy.tenant_model'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ use Illuminate\Support\Str;
|
|||
use Stancl\Tenancy\Database\Concerns\CentralConnection;
|
||||
|
||||
/**
|
||||
* @param string $token
|
||||
* @param string $tenant_id
|
||||
* @param string $user_id
|
||||
* @param string $auth_guard
|
||||
* @param string $redirect_url
|
||||
* @param Carbon $created_at
|
||||
* @property string $token
|
||||
* @property string $tenant_id
|
||||
* @property string $user_id
|
||||
* @property string $auth_guard
|
||||
* @property string $redirect_url
|
||||
* @property Carbon $created_at
|
||||
*/
|
||||
class ImpersonationToken extends Model
|
||||
{
|
||||
|
|
@ -35,7 +35,7 @@ class ImpersonationToken extends Model
|
|||
'created_at',
|
||||
];
|
||||
|
||||
public static function booted()
|
||||
public static function booted(): void
|
||||
{
|
||||
static::creating(function ($model) {
|
||||
$model->created_at = $model->created_at ?? $model->freshTimestamp();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use Stancl\Tenancy\Contracts\Syncable;
|
|||
|
||||
class TenantPivot extends Pivot
|
||||
{
|
||||
public static function booted()
|
||||
public static function booted(): void
|
||||
{
|
||||
static::saved(function (self $pivot) {
|
||||
$parent = $pivot->pivotParent;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue