mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-03 15:02:34 +00:00
Add phpstan level 7(#544)
This commit is contained in:
@ -7,15 +7,11 @@
|
||||
use App\Models\Site;
|
||||
use App\SSH\Services\PHP\PHP;
|
||||
use Illuminate\Support\Str;
|
||||
use RuntimeException;
|
||||
|
||||
abstract class AbstractSiteType implements SiteType
|
||||
{
|
||||
protected Site $site;
|
||||
|
||||
public function __construct(Site $site)
|
||||
{
|
||||
$this->site = $site;
|
||||
}
|
||||
public function __construct(protected Site $site) {}
|
||||
|
||||
public function createRules(array $input): array
|
||||
{
|
||||
@ -82,12 +78,15 @@ protected function isolate(): void
|
||||
|
||||
// Generate the FPM pool
|
||||
if ($this->site->php_version) {
|
||||
$service = $this->site->php();
|
||||
if (! $service instanceof \App\Models\Service) {
|
||||
throw new RuntimeException('PHP service not found');
|
||||
}
|
||||
/** @var PHP $php */
|
||||
$php = $this->site->php()->handler();
|
||||
$php = $service->handler();
|
||||
$php->createFpmPool(
|
||||
$this->site->user,
|
||||
$this->site->php_version,
|
||||
$this->site->id
|
||||
$this->site->php_version
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
use App\Enums\LoadBalancerMethod;
|
||||
use App\Enums\SiteFeature;
|
||||
use App\Exceptions\SSHError;
|
||||
use App\SSH\Services\Webserver\Webserver;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class LoadBalancer extends AbstractSiteType
|
||||
@ -46,9 +45,7 @@ public function install(): void
|
||||
{
|
||||
$this->isolate();
|
||||
|
||||
/** @var Webserver $webserver */
|
||||
$webserver = $this->site->server->webserver()->handler();
|
||||
$webserver->createVHost($this->site);
|
||||
$this->site->webserver()->createVHost($this->site);
|
||||
}
|
||||
|
||||
public function edit(): void
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
use App\Enums\SiteFeature;
|
||||
use App\Exceptions\SSHError;
|
||||
use App\SSH\Services\Webserver\Webserver;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class PHPBlank extends PHPSite
|
||||
@ -49,10 +48,7 @@ public function data(array $input): array
|
||||
public function install(): void
|
||||
{
|
||||
$this->isolate();
|
||||
|
||||
/** @var Webserver $webserver */
|
||||
$webserver = $this->site->server->webserver()->handler();
|
||||
$webserver->createVHost($this->site);
|
||||
$this->site->webserver()->createVHost($this->site);
|
||||
$this->progress(65);
|
||||
$this->site->php()?->restart();
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
use App\Enums\SiteFeature;
|
||||
use App\Exceptions\SSHError;
|
||||
use App\SSH\Services\Webserver\Webserver;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class PHPMyAdmin extends PHPSite
|
||||
@ -48,10 +47,7 @@ public function data(array $input): array
|
||||
public function install(): void
|
||||
{
|
||||
$this->isolate();
|
||||
|
||||
/** @var Webserver $webserver */
|
||||
$webserver = $this->site->server->webserver()->handler();
|
||||
$webserver->createVHost($this->site);
|
||||
$this->site->webserver()->createVHost($this->site);
|
||||
$this->progress(30);
|
||||
app(\App\SSH\PHPMyAdmin\PHPMyAdmin::class)->install($this->site);
|
||||
$this->progress(65);
|
||||
|
@ -7,7 +7,6 @@
|
||||
use App\Exceptions\SSHError;
|
||||
use App\SSH\Composer\Composer;
|
||||
use App\SSH\Git\Git;
|
||||
use App\SSH\Services\Webserver\Webserver;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class PHPSite extends AbstractSiteType
|
||||
@ -90,10 +89,7 @@ public function data(array $input): array
|
||||
public function install(): void
|
||||
{
|
||||
$this->isolate();
|
||||
|
||||
/** @var Webserver $webserver */
|
||||
$webserver = $this->site->server->webserver()->handler();
|
||||
$webserver->createVHost($this->site);
|
||||
$this->site->webserver()->createVHost($this->site);
|
||||
$this->progress(15);
|
||||
$this->deployKey();
|
||||
$this->progress(30);
|
||||
|
@ -6,19 +6,41 @@ interface SiteType
|
||||
{
|
||||
public function language(): string;
|
||||
|
||||
/**
|
||||
* @return array<string>
|
||||
*/
|
||||
public function supportedFeatures(): array;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function createRules(array $input): array;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function createFields(array $input): array;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function data(array $input): array;
|
||||
|
||||
public function install(): void;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function editRules(array $input): array;
|
||||
|
||||
public function edit(): void;
|
||||
|
||||
/**
|
||||
* @return array<array<string, string>>
|
||||
*/
|
||||
public function baseCommands(): array;
|
||||
}
|
||||
|
@ -9,7 +9,6 @@
|
||||
use App\Exceptions\SSHError;
|
||||
use App\Models\Database;
|
||||
use App\Models\DatabaseUser;
|
||||
use App\SSH\Services\Webserver\Webserver;
|
||||
use Closure;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
@ -44,10 +43,8 @@ public function createRules(array $input): array
|
||||
],
|
||||
'database' => [
|
||||
'required',
|
||||
Rule::unique('databases', 'name')->where(function ($query) {
|
||||
return $query->where('server_id', $this->site->server_id);
|
||||
}),
|
||||
function (string $attribute, mixed $value, Closure $fail) {
|
||||
Rule::unique('databases', 'name')->where(fn ($query) => $query->where('server_id', $this->site->server_id)),
|
||||
function (string $attribute, mixed $value, Closure $fail): void {
|
||||
if (! $this->site->server->database()) {
|
||||
$fail(__('Database is not installed'));
|
||||
}
|
||||
@ -55,9 +52,7 @@ function (string $attribute, mixed $value, Closure $fail) {
|
||||
],
|
||||
'database_user' => [
|
||||
'required',
|
||||
Rule::unique('database_users', 'username')->where(function ($query) {
|
||||
return $query->where('server_id', $this->site->server_id);
|
||||
}),
|
||||
Rule::unique('database_users', 'username')->where(fn ($query) => $query->where('server_id', $this->site->server_id)),
|
||||
],
|
||||
'database_password' => 'required',
|
||||
];
|
||||
@ -94,9 +89,7 @@ public function install(): void
|
||||
{
|
||||
$this->isolate();
|
||||
|
||||
/** @var Webserver $webserver */
|
||||
$webserver = $this->site->server->webserver()->handler();
|
||||
$webserver->createVHost($this->site);
|
||||
$this->site->webserver()->createVHost($this->site);
|
||||
$this->progress(30);
|
||||
|
||||
/** @var Database $database */
|
||||
|
Reference in New Issue
Block a user