From e84de66dfa9cd4e1972c74de3f12e1322a3624b3 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Tue, 9 Mar 2021 15:18:28 +0100 Subject: [PATCH] PSR 2 compliance --- bin/i3_switch_focus_container.php | 8 ++++---- bin/i3_switch_window.php | 3 +-- bin/i3_switch_workspace.php | 8 ++++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/bin/i3_switch_focus_container.php b/bin/i3_switch_focus_container.php index 72d7f98..47da97a 100755 --- a/bin/i3_switch_focus_container.php +++ b/bin/i3_switch_focus_container.php @@ -47,15 +47,15 @@ function getDefaultFocusWindowNumber($container) function setFocusToWindow($window) { - shell_exec(sprintf("i3-msg '[con_id=\"%s\"] focus'", $window->id)); + shell_exec(sprintf("i3-msg '[con_id=\"%s\"] focus'", $window->id)); } $container = getFocusedWindowContainer(getTree()); -if ($container !== null) { +if (null !== $container) { $number = getFocusWindowNumber(getDefaultFocusWindowNumber($container), count($container)); - - foreach ($container as $k => $window) { + + foreach ($container as $k => $window) { if ($k == $number) { setFocusToWindow($window); } diff --git a/bin/i3_switch_window.php b/bin/i3_switch_window.php index b65b3f7..51fdf56 100755 --- a/bin/i3_switch_window.php +++ b/bin/i3_switch_window.php @@ -45,7 +45,7 @@ function getVisibleWorkspacesNodes(array $tree, array $workspaces): array $nodes, $tree['floating_nodes'] ); - } elseif ($output === '__i3' && isset($tree['window'])) { + } elseif ('__i3' === $output && isset($tree['window'])) { $nodes[] = $tree; } } @@ -70,7 +70,6 @@ function getVisibleWorkspacesNodes(array $tree, array $workspaces): array foreach ($n['floating_nodes'] as $node) { $nodes[] = $node; } - } } diff --git a/bin/i3_switch_workspace.php b/bin/i3_switch_workspace.php index 57f5ce3..6a7f4b0 100755 --- a/bin/i3_switch_workspace.php +++ b/bin/i3_switch_workspace.php @@ -6,7 +6,7 @@ function getOrderedWorkspaces() $json = shell_exec('i3-msg -t get_workspaces'); $workspaces = json_decode($json); - $ordered = array(); + $ordered = []; foreach ($workspaces as $w) { $ordered[] = $w->name; @@ -34,7 +34,7 @@ function getMoveOption() $argv[1] = 'next'; } - return in_array($argv[1], array('next', 'previous')) ? $argv[1] : 'next'; + return in_array($argv[1], ['next', 'previous']) ? $argv[1] : 'next'; } function getNextWorkspace($workspaces) @@ -61,7 +61,7 @@ function getPreviousWorkspace($workspaces) } } - return $workspaces[ --$key >= 0 ? $key : $count - 1 ]; + return $workspaces[--$key >= 0 ? $key : $count - 1]; } function moveToWorkspace($workspace) @@ -70,4 +70,4 @@ function moveToWorkspace($workspace) } $workspaces = getOrderedWorkspaces(); -moveToWorkspace(getMoveOption() === 'next' ? getNextWorkspace($workspaces) : getPreviousWorkspace($workspaces)); +moveToWorkspace('next' === getMoveOption() ? getNextWorkspace($workspaces) : getPreviousWorkspace($workspaces));