mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 12:54:05 +00:00
phpstan fixes
This commit is contained in:
parent
39bcbda5d0
commit
b01c16f4fc
3 changed files with 20 additions and 5 deletions
|
|
@ -16,6 +16,7 @@ parameters:
|
||||||
ignoreErrors:
|
ignoreErrors:
|
||||||
-
|
-
|
||||||
identifier: missingType.iterableValue
|
identifier: missingType.iterableValue
|
||||||
|
- '#FFI#'
|
||||||
- '#Return type(.*?) of method Stancl\\Tenancy\\Database\\Models\\Tenant\:\:newCollection\(\) should be compatible with return type#'
|
- '#Return type(.*?) of method Stancl\\Tenancy\\Database\\Models\\Tenant\:\:newCollection\(\) should be compatible with return type#'
|
||||||
- '#Method Stancl\\Tenancy\\Database\\Models\\Tenant\:\:newCollection\(\) should return#'
|
- '#Method Stancl\\Tenancy\\Database\\Models\\Tenant\:\:newCollection\(\) should return#'
|
||||||
- '#Cannot access offset (.*?) on Illuminate\\Contracts\\Foundation\\Application#'
|
- '#Cannot access offset (.*?) on Illuminate\\Contracts\\Foundation\\Application#'
|
||||||
|
|
|
||||||
|
|
@ -80,8 +80,12 @@ trait ParallelCommand
|
||||||
// We use the logical core count as it should work best for I/O bound code
|
// We use the logical core count as it should work best for I/O bound code
|
||||||
return match (PHP_OS_FAMILY) {
|
return match (PHP_OS_FAMILY) {
|
||||||
'Windows' => (int) getenv('NUMBER_OF_PROCESSORS'),
|
'Windows' => (int) getenv('NUMBER_OF_PROCESSORS'),
|
||||||
'Linux' => substr_count(file_get_contents('/proc/cpuinfo'), 'processor'),
|
'Linux' => substr_count(
|
||||||
|
file_get_contents('/proc/cpuinfo') ?: throw new Exception('Could not open /proc/cpuinfo for core count detection, please specify -p manually.'),
|
||||||
|
'processor',
|
||||||
|
),
|
||||||
'Darwin', 'BSD' => $this->sysctlGetLogicalCoreCount(PHP_OS_FAMILY === 'Darwin'),
|
'Darwin', 'BSD' => $this->sysctlGetLogicalCoreCount(PHP_OS_FAMILY === 'Darwin'),
|
||||||
|
default => throw new Exception('Core count detection not implemented for ' . PHP_OS_FAMILY . ', please specify -p manually.'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -111,8 +115,8 @@ trait ParallelCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($processes > 1 && ! function_exists('pcntl_fork')) {
|
if ($processes > 1 && ! function_exists('pcntl_fork')) {
|
||||||
exit(1);
|
|
||||||
$this->components->error('The pcntl extension is required for parallel migrations to work.');
|
$this->components->error('The pcntl extension is required for parallel migrations to work.');
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $processes;
|
return $processes;
|
||||||
|
|
@ -143,7 +147,7 @@ trait ParallelCommand
|
||||||
$success = true;
|
$success = true;
|
||||||
$pids = [];
|
$pids = [];
|
||||||
|
|
||||||
if (count($args) < $processes) {
|
if ($args !== null && count($args) < $processes) {
|
||||||
$processes = count($args);
|
$processes = count($args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,10 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Stancl\Tenancy\Overrides;
|
namespace Stancl\Tenancy\Overrides;
|
||||||
|
|
||||||
|
use BackedEnum;
|
||||||
use Illuminate\Routing\UrlGenerator;
|
use Illuminate\Routing\UrlGenerator;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
|
use InvalidArgumentException;
|
||||||
use Stancl\Tenancy\Resolvers\PathTenantResolver;
|
use Stancl\Tenancy\Resolvers\PathTenantResolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -51,7 +53,11 @@ class TenancyUrlGenerator extends UrlGenerator
|
||||||
*/
|
*/
|
||||||
public function route($name, $parameters = [], $absolute = true)
|
public function route($name, $parameters = [], $absolute = true)
|
||||||
{
|
{
|
||||||
[$name, $parameters] = $this->prepareRouteInputs($name, Arr::wrap($parameters));
|
if ($name instanceof BackedEnum && ! is_string($name = $name->value)) { // @phpstan-ignore function.impossibleType
|
||||||
|
throw new InvalidArgumentException('Attribute [name] expects a string backed enum.');
|
||||||
|
}
|
||||||
|
|
||||||
|
[$name, $parameters] = $this->prepareRouteInputs($name, Arr::wrap($parameters)); // @phpstan-ignore argument.type
|
||||||
|
|
||||||
return parent::route($name, $parameters, $absolute);
|
return parent::route($name, $parameters, $absolute);
|
||||||
}
|
}
|
||||||
|
|
@ -62,7 +68,11 @@ class TenancyUrlGenerator extends UrlGenerator
|
||||||
*/
|
*/
|
||||||
public function temporarySignedRoute($name, $expiration, $parameters = [], $absolute = true)
|
public function temporarySignedRoute($name, $expiration, $parameters = [], $absolute = true)
|
||||||
{
|
{
|
||||||
[$name, $parameters] = $this->prepareRouteInputs($name, Arr::wrap($parameters));
|
if ($name instanceof BackedEnum && ! is_string($name = $name->value)) { // @phpstan-ignore function.impossibleType
|
||||||
|
throw new InvalidArgumentException('Attribute [name] expects a string backed enum.');
|
||||||
|
}
|
||||||
|
|
||||||
|
[$name, $parameters] = $this->prepareRouteInputs($name, Arr::wrap($parameters)); // @phpstan-ignore argument.type
|
||||||
|
|
||||||
return parent::temporarySignedRoute($name, $expiration, $parameters, $absolute);
|
return parent::temporarySignedRoute($name, $expiration, $parameters, $absolute);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue