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

@ -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;
}