mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-03 23:12:35 +00:00
Add phpstan level 7(#544)
This commit is contained in:
@ -11,6 +11,9 @@
|
||||
|
||||
abstract class AbstractDatabase extends AbstractService implements Database
|
||||
{
|
||||
/**
|
||||
* @var array<string>
|
||||
*/
|
||||
protected array $systemDbs = [];
|
||||
|
||||
protected string $defaultCharset;
|
||||
@ -21,8 +24,12 @@ abstract class AbstractDatabase extends AbstractService implements Database
|
||||
|
||||
protected bool $removeLastRow = false;
|
||||
|
||||
/**
|
||||
* @phpstan-return view-string
|
||||
*/
|
||||
protected function getScriptView(string $script): string
|
||||
{
|
||||
/** @phpstan-ignore-next-line */
|
||||
return 'ssh.services.database.'.$this->service->name.'.'.$script;
|
||||
}
|
||||
|
||||
@ -31,7 +38,7 @@ public function creationRules(array $input): array
|
||||
return [
|
||||
'type' => [
|
||||
'required',
|
||||
function (string $attribute, mixed $value, Closure $fail) {
|
||||
function (string $attribute, mixed $value, Closure $fail): void {
|
||||
$databaseExists = $this->service->server->database();
|
||||
if ($databaseExists) {
|
||||
$fail('You already have a database service on the server.');
|
||||
@ -62,7 +69,7 @@ public function deletionRules(): array
|
||||
{
|
||||
return [
|
||||
'service' => [
|
||||
function (string $attribute, mixed $value, Closure $fail) {
|
||||
function (string $attribute, mixed $value, Closure $fail): void {
|
||||
$hasDatabase = $this->service->server->databases()->exists();
|
||||
if ($hasDatabase) {
|
||||
$fail('You have database(s) on the server.');
|
||||
@ -306,6 +313,7 @@ public function syncDatabases(bool $createNew = true): void
|
||||
continue;
|
||||
}
|
||||
|
||||
/** @var ?\App\Models\Database $db */
|
||||
$db = $this->service->server->databases()
|
||||
->where('name', $database[0])
|
||||
->first();
|
||||
@ -331,6 +339,9 @@ public function syncDatabases(bool $createNew = true): void
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<array<string>>
|
||||
*/
|
||||
protected function tableToArray(string $data, bool $keepHeader = false): array
|
||||
{
|
||||
$lines = explode("\n", trim($data));
|
||||
@ -347,7 +358,8 @@ protected function tableToArray(string $data, bool $keepHeader = false): array
|
||||
|
||||
$rows = [];
|
||||
foreach ($lines as $line) {
|
||||
$row = explode($this->separator, $line);
|
||||
$separator = $this->separator === '' || $this->separator === '0' ? "\t" : $this->separator;
|
||||
$row = explode($separator, $line);
|
||||
$row = array_map('trim', $row);
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
Reference in New Issue
Block a user