1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-15 06:44:03 +00:00

[4.x] General code cleanup (#1278)

* Declare sensitive parameters as sensitive

... just so that they don't show up in logs

* Remove unnecessary null-coalescing

* Simplify return

* Merge isset() calls

* Inline return

* Use nullsafe operator

* Simplify if-else branches

* Use direct empty string comparison instead of strlen()

* Add missing type

* Change interface as events expect a TenantWithDatabase not just a Tenant

* Narrow typehint

* Remove redundant type casts

* Fix style with php-cs-fixer

* Fix typos

* Revert unwanted if-else simplification

* fix phpstan errors

* narrow type

---------

Co-authored-by: Samuel Štancl <samuel@archte.ch>
This commit is contained in:
Márk Magyar 2024-12-31 00:35:46 +01:00 committed by GitHub
parent 05b602e37f
commit 79f740d057
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 45 additions and 53 deletions

View file

@ -66,6 +66,7 @@ class CreateUserWithRLSPolicies extends Command
protected function makeDatabaseConfig(
PermissionControlledPostgreSQLSchemaManager $manager,
string $username,
#[\SensitiveParameter]
string $password,
): DatabaseConfig {
/** @var TenantWithDatabase $tenantModel */

View file

@ -81,7 +81,7 @@ class Migrate extends MigrateCommand
$tenant->run(function ($tenant) use (&$success) {
event(new MigratingDatabase($tenant));
$verbosity = (int) $this->output->getVerbosity();
$verbosity = $this->output->getVerbosity();
if ($this->runningConcurrently) {
// The output gets messy when multiple processes are writing to the same stdout

View file

@ -76,7 +76,7 @@ class Rollback extends RollbackCommand
$tenant->run(function ($tenant) use (&$success) {
event(new RollingBackDatabase($tenant));
$verbosity = (int) $this->output->getVerbosity();
$verbosity = $this->output->getVerbosity();
if ($this->runningConcurrently) {
// The output gets messy when multiple processes are writing to the same stdout

View file

@ -47,7 +47,7 @@ class Tinker extends BaseTinker
/** @var string $tenantKey */
$tenantKey = search(
'Enter the tenant key:',
fn (string $search) => strlen($search) > 0
fn (string $search) => $search !== ''
? tenancy()->model()::where(tenancy()->model()->getTenantKeyName(), 'like', "$search%")->pluck(tenancy()->model()->getTenantKeyName())->all()
: []
);
@ -57,7 +57,7 @@ class Tinker extends BaseTinker
/** @var string $domain */
$domain = search(
'Enter the tenant domain:',
fn (string $search) => strlen($search) > 0
fn (string $search) => $search !== ''
? config('tenancy.models.domain')::where('domain', 'like', "$search%")->pluck('domain')->all()
: []
);