Add phpstan level 7(#544)

This commit is contained in:
Saeed Vaziry
2025-03-12 13:31:10 +01:00
committed by GitHub
parent c22bb1fa80
commit 493cbb0849
437 changed files with 4505 additions and 2193 deletions

View File

@ -3,6 +3,7 @@
namespace App\Actions\ServerProvider;
use App\Models\Project;
use App\Models\Server;
use App\Models\ServerProvider;
use App\Models\User;
use App\ServerProviders\ServerProvider as ServerProviderContract;
@ -13,11 +14,13 @@
class CreateServerProvider
{
/**
* @param array<string, mixed> $input
*
* @throws ValidationException
*/
public function create(User $user, Project $project, array $input): ServerProvider
{
$provider = static::getProvider($input['provider']);
$provider = self::getProvider($input['provider']);
try {
$provider->connect($input);
@ -40,13 +43,19 @@ public function create(User $user, Project $project, array $input): ServerProvid
return $serverProvider;
}
private static function getProvider($name): ServerProviderContract
private static function getProvider(string $name): ServerProviderContract
{
$providerClass = config('core.server_providers_class.'.$name);
/** @var ServerProviderContract $provider */
$provider = new $providerClass(new ServerProvider, new Server);
return new $providerClass;
return $provider;
}
/**
* @param array<string, mixed> $input
* @return array<string, mixed>
*/
public static function rules(array $input): array
{
$rules = [
@ -60,15 +69,19 @@ public static function rules(array $input): array
],
];
return array_merge($rules, static::providerRules($input));
return array_merge($rules, self::providerRules($input));
}
/**
* @param array<string, mixed> $input
* @return array<string, array<string>>
*/
private static function providerRules(array $input): array
{
if (! isset($input['provider'])) {
return [];
}
return static::getProvider($input['provider'])->credentialValidationRules($input);
return self::getProvider($input['provider'])->credentialValidationRules($input);
}
}