Skip to content

Commit

Permalink
fix: phpstan level max errors (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkaser authored Oct 16, 2024
1 parent 266a977 commit 238ddfb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 8
level: max
fileExtensions:
- php
- page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public static function refreshWebGuiCert(bool $restartIfChanged = true): void

public static function applyGRO(): void
{
$ip_route = json_decode(implode(self::run_command('ip -j route get 8.8.8.8')), true);
/** @var array<int, array<string>> $ip_route */
$ip_route = (array) json_decode(implode(self::run_command('ip -j route get 8.8.8.8')), true);

// Check if a device was returned
if ( ! isset($ip_route[0]['dev'])) {
Expand All @@ -112,7 +113,8 @@ public static function applyGRO(): void

$dev = $ip_route[0]['dev'];

$ethtool = json_decode(implode(self::run_command("ethtool --json -k {$dev}")), true)[0];
/** @var array<string, array<string>> $ethtool */
$ethtool = ((array) json_decode(implode(self::run_command("ethtool --json -k {$dev}")), true))[0];

if (isset($ethtool['rx-udp-gro-forwarding']) && ! $ethtool['rx-udp-gro-forwarding']['active']) {
self::run_command("ethtool -K {$dev} rx-udp-gro-forwarding on");
Expand All @@ -139,7 +141,8 @@ public static function getPluginConfig(): array
}

// Load default settings and assign values
$settings_config = json_decode(file_get_contents($defaults_file) ?: "{}", true);
/** @var array<string, array<string>> $settings_config */
$settings_config = (array) json_decode(file_get_contents($defaults_file) ?: "{}", true);
foreach ($settings_config as $key => $value) {
if ( ! isset($tailscale_config[$key])) {
$tailscale_config[$key] = $value['default'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class Translator
{
/** @var array<string> $tailscale_lang */
/** @var array<string, string> $tailscale_lang */
private array $tailscale_lang;

public function __construct()
Expand All @@ -12,10 +12,10 @@ public function __construct()
$dynamix = parse_ini_file('/boot/config/plugins/dynamix/dynamix.cfg', true) ?: array();

$locale = $_SESSION['locale'] ?? ($login_locale ?? $dynamix['display']['locale']);
$tailscale_locale = json_decode(file_get_contents("/usr/local/emhttp/plugins/tailscale/locales/en_US.json") ?: "{}", true);
$tailscale_locale = (array) json_decode(file_get_contents("/usr/local/emhttp/plugins/tailscale/locales/en_US.json") ?: "{}", true);

if (file_exists("/usr/local/emhttp/plugins/tailscale/locales/{$locale}.json")) {
$current_locale = json_decode(file_get_contents("/usr/local/emhttp/plugins/tailscale/locales/{$locale}.json") ?: "{}", true);
$current_locale = (array) json_decode(file_get_contents("/usr/local/emhttp/plugins/tailscale/locales/{$locale}.json") ?: "{}", true);
$tailscale_locale = array_replace_recursive($tailscale_locale, $current_locale);
}

Expand All @@ -26,7 +26,9 @@ public function __construct()
foreach (range(0, $ritit->getDepth()) as $depth) {
$keys[] = $ritit->getSubIterator($depth)->key();
}
$tailscale_lang[ strtolower(join('.', $keys)) ] = $leafValue;
if (is_string($leafValue)) {
$tailscale_lang[ strtolower(join('.', $keys)) ] = $leafValue;
}
}

$this->tailscale_lang = $tailscale_lang;
Expand Down

0 comments on commit 238ddfb

Please sign in to comment.