refactor: apply rector
Some checks are pending
tests / ci (push) Waiting to run

This commit is contained in:
Benjamin Nussbaum 2025-09-24 20:31:32 +02:00
parent c67a182cf2
commit b4b6286172
89 changed files with 672 additions and 666 deletions

View file

@ -23,7 +23,7 @@ class FirmwareCheckCommand extends Command
);
$latestFirmware = Firmware::getLatest();
if ($latestFirmware) {
if ($latestFirmware instanceof Firmware) {
table(
rows: [
['Latest Version', $latestFirmware->version_tag],

View file

@ -42,15 +42,14 @@ class FirmwareUpdateCommand extends Command
label: 'Which devices should be updated?',
options: [
'all' => 'ALL Devices',
...Device::all()->mapWithKeys(function ($device) {
...Device::all()->mapWithKeys(fn ($device): array =>
// without _ returns index
return ["_$device->id" => "$device->name (Current version: $device->last_firmware_version)"];
})->toArray(),
["_$device->id" => "$device->name (Current version: $device->last_firmware_version)"])->toArray(),
],
scroll: 10
);
if (empty($devices)) {
if ($devices === []) {
$this->error('No devices selected. Aborting.');
return;
@ -59,9 +58,7 @@ class FirmwareUpdateCommand extends Command
if (in_array('all', $devices)) {
$devices = Device::pluck('id')->toArray();
} else {
$devices = array_map(function ($selected) {
return (int) str_replace('_', '', $selected);
}, $devices);
$devices = array_map(fn ($selected): int => (int) str_replace('_', '', $selected), $devices);
}
foreach ($devices as $deviceId) {

View file

@ -28,17 +28,17 @@ class MashupCreateCommand extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): int
{
// Select device
$device = $this->selectDevice();
if (! $device) {
if (! $device instanceof Device) {
return 1;
}
// Select playlist
$playlist = $this->selectPlaylist($device);
if (! $playlist) {
if (! $playlist instanceof Playlist) {
return 1;
}
@ -87,7 +87,7 @@ class MashupCreateCommand extends Command
$deviceId = $this->choice(
'Select a device',
$devices->mapWithKeys(fn ($device) => [$device->id => $device->name])->toArray()
$devices->mapWithKeys(fn ($device): array => [$device->id => $device->name])->toArray()
);
return $devices->firstWhere('id', $deviceId);
@ -105,7 +105,7 @@ class MashupCreateCommand extends Command
$playlistId = $this->choice(
'Select a playlist',
$playlists->mapWithKeys(fn (Playlist $playlist) => [$playlist->id => $playlist->name])->toArray()
$playlists->mapWithKeys(fn (Playlist $playlist): array => [$playlist->id => $playlist->name])->toArray()
);
return $playlists->firstWhere('id', $playlistId);
@ -123,13 +123,13 @@ class MashupCreateCommand extends Command
{
$name = $this->ask('Enter a name for this mashup', 'Mashup');
if (mb_strlen($name) < 2) {
if (mb_strlen((string) $name) < 2) {
$this->error('The name must be at least 2 characters.');
return null;
}
if (mb_strlen($name) > 50) {
if (mb_strlen((string) $name) > 50) {
$this->error('The name must not exceed 50 characters.');
return null;
@ -150,7 +150,7 @@ class MashupCreateCommand extends Command
}
$selectedPlugins = collect();
$availablePlugins = $plugins->mapWithKeys(fn ($plugin) => [$plugin->id => $plugin->name])->toArray();
$availablePlugins = $plugins->mapWithKeys(fn ($plugin): array => [$plugin->id => $plugin->name])->toArray();
for ($i = 0; $i < $requiredCount; ++$i) {
$position = match ($i) {

View file

@ -26,7 +26,7 @@ class OidcTestCommand extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): int
{
$this->info('Testing OIDC Configuration...');
$this->newLine();

View file

@ -25,7 +25,7 @@ class ScreenGeneratorCommand extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): int
{
$deviceId = $this->argument('deviceId');
$view = $this->argument('view');