refactor: fix PHPStan errors, remove unused code, replace shell_exec with Process

- Fix all 54 PHPStan errors (strict comparisons, unused methods, nullsafe)
- Remove unused HasPermissionColumns trait, checkGitHubUpdates, getGitHubLatestCommit
- Replace all 31 shell_exec calls with Process facade in Commandocentrum
- Add helper methods: runCommand, fileExists, dirExists, readFile
- Fix EmulatorJarService and EmulatorSqlService type issues
This commit is contained in:
root
2026-05-19 20:44:21 +02:00
parent f5666c104d
commit 976b990a8a
4 changed files with 74 additions and 145 deletions
@@ -1,29 +0,0 @@
<?php
namespace App\Services\Emulator\Concerns;
use Illuminate\Support\Facades\Schema;
trait HasPermissionColumns
{
protected function getPermissionColumnsFromSchema(): array
{
if (! Schema::hasTable('permissions')) {
return [];
}
$columns = Schema::getColumns('permissions');
return collect($columns)->filter(function (array $column) {
$columnName = $column['name'] ?? null;
if (! $columnName) {
return false;
}
return str_starts_with($columnName, 'cmd')
|| str_starts_with($columnName, 'acc')
|| str_ends_with($columnName, 'cmd');
})->values()->toArray();
}
}
View File
+5 -5
View File
@@ -162,11 +162,11 @@ class EmulatorJarService
$installedJarCommit = $this->settings->getOrDefault('emulator_jar_commit', null);
$isUpdate = false;
if ($installedJarCommit !== null && $commitSha !== null) {
if ($installedJarCommit !== null) {
$isUpdate = $installedJarCommit !== $commitSha;
} elseif ($installedDate !== null && $commitDate) {
} elseif ($installedDate !== null && $commitDate !== null) {
$isUpdate = (int) $installedDate < $commitDate;
} elseif ($installedDate === null && $commitDate) {
} elseif ($installedDate === null && $commitDate !== null) {
$isUpdate = true;
}
@@ -222,7 +222,7 @@ class EmulatorJarService
}
return [
'update_available' => $hasJarUpdates || $hasSourceUpdates,
'update_available' => $hasJarUpdates,
'current_version' => $this->settings->getOrDefault('emulator_version', '0.0.0'),
'latest_version' => $jarInfo['version'],
'release_name' => $hasSourceUpdates ? 'Source Update' : 'Direct URL',
@@ -307,7 +307,7 @@ class EmulatorJarService
}
return [
'update_available' => $hasJarUpdates || $hasSourceUpdates,
'update_available' => $hasJarUpdates,
'current_version' => $this->settings->getOrDefault('emulator_version', '0.0.0'),
'latest_version' => $hasSourceUpdates ? ($sourceInfo['latest_timestamp'] ? date('Y.m.d', $sourceInfo['latest_timestamp']) : $version) : $version,
'release_name' => $hasSourceUpdates ? 'Source Update' : 'Latest from GitHub',