@@ -46,7 +46,7 @@ |
||
| 46 | 46 | $serverName = $io->ask( |
| 47 | 47 | 'Please provide the name of the server (default: ' . $defaultName . ')', |
| 48 | 48 | $defaultName, |
| 49 | - function (?string $value) { |
|
| 49 | + function(?string $value) { |
|
| 50 | 50 | if (strlen($value ?? '') < 3) { |
| 51 | 51 | throw new \RuntimeException('The server name has to be at least three characters long.'); |
| 52 | 52 | } |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | } elseif ($os === 'Linux') { |
| 53 | 53 | $memInfo = file_get_contents("/proc/meminfo"); |
| 54 | 54 | preg_match("/MemTotal:\s+(\d+)\skB/", $memInfo, $matches); |
| 55 | - return isset($matches[1]) ? round((float)$matches[1] / 1024, 2) :0; |
|
| 55 | + return isset($matches[1]) ? round((float)$matches[1] / 1024, 2) : 0; |
|
| 56 | 56 | } |
| 57 | 57 | return 0; |
| 58 | 58 | } |
@@ -44,7 +44,9 @@ |
||
| 44 | 44 | $packages = []; |
| 45 | 45 | |
| 46 | 46 | foreach ($lines as $line) { |
| 47 | - if (trim($line) === '') continue; |
|
| 47 | + if (trim($line) === '') { |
|
| 48 | + continue; |
|
| 49 | + } |
|
| 48 | 50 | |
| 49 | 51 | if (preg_match('/^([^\s\/]+)\/[^\s]+\s+([^\s]+).*upgradable from: ([^\]]+)/', $line, $matches)) { |
| 50 | 52 | $packages[$matches[1]] = [ |
@@ -23,14 +23,18 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | public function collect(): array |
| 25 | 25 | { |
| 26 | - if (!file_exists(self::INI_FILE)) return []; |
|
| 26 | + if (!file_exists(self::INI_FILE)) { |
|
| 27 | + return []; |
|
| 28 | + } |
|
| 27 | 29 | |
| 28 | 30 | $config = file(self::INI_FILE); |
| 29 | 31 | |
| 30 | 32 | $configArray = []; |
| 31 | 33 | |
| 32 | 34 | foreach ($config as $line) { |
| 33 | - if (str_starts_with($line, '[')) continue; |
|
| 35 | + if (str_starts_with($line, '[')) { |
|
| 36 | + continue; |
|
| 37 | + } |
|
| 34 | 38 | $element = explode('=', $line); |
| 35 | 39 | $configArray[$element[0]] = trim($element[1]); |
| 36 | 40 | } |
@@ -84,7 +84,9 @@ |
||
| 84 | 84 | |
| 85 | 85 | foreach ($lines as $line) { |
| 86 | 86 | $line = trim(preg_replace('/#.*/', '', $line)); // Kommentare entfernen |
| 87 | - if ($line === '') continue; |
|
| 87 | + if ($line === '') { |
|
| 88 | + continue; |
|
| 89 | + } |
|
| 88 | 90 | |
| 89 | 91 | if (preg_match('/^\s*(\w+)\s+(yes|no)\s*$/i', $line, $matches)) { |
| 90 | 92 | $key = strtolower($matches[1]); |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | // Extract username, UID, and home directory |
| 28 | - [$username, , $uid, , , $homeDirectory] = array_slice($parts, 0, 6); |
|
| 28 | + [$username,, $uid,,, $homeDirectory] = array_slice($parts, 0, 6); |
|
| 29 | 29 | |
| 30 | 30 | // Only consider regular users (UID >= 1000) with a valid home directory |
| 31 | 31 | if (!is_dir($homeDirectory)) { |
@@ -43,7 +43,9 @@ |
||
| 43 | 43 | // Step 2: Extract managed log paths from logrotate config files |
| 44 | 44 | $explicitManaged = []; |
| 45 | 45 | foreach ($logrotateConfs as $confFile) { |
| 46 | - if (!is_readable($confFile)) continue; |
|
| 46 | + if (!is_readable($confFile)) { |
|
| 47 | + continue; |
|
| 48 | + } |
|
| 47 | 49 | $lines = file($confFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
| 48 | 50 | foreach ($lines as $line) { |
| 49 | 51 | if (preg_match('#^\s*/[^\s{}]+\.log#', $line, $matches)) { |
@@ -21,7 +21,9 @@ discard block |
||
| 21 | 21 | { |
| 22 | 22 | if (!array_key_exists(ApacheServerNameCollector::COLLECTION_IDENTIFIER, $this->inventory) |
| 23 | 23 | || !is_array($this->inventory[ApacheServerNameCollector::COLLECTION_IDENTIFIER]) |
| 24 | - ) return []; |
|
| 24 | + ) { |
|
| 25 | + return []; |
|
| 26 | + } |
|
| 25 | 27 | |
| 26 | 28 | $configs = $this->inventory[ApacheServerNameCollector::COLLECTION_IDENTIFIER]; |
| 27 | 29 | |
@@ -51,7 +53,9 @@ discard block |
||
| 51 | 53 | private function extractPlugins(string $documentRoot): array |
| 52 | 54 | { |
| 53 | 55 | $pluginDir = $documentRoot . 'wp-content/plugins'; |
| 54 | - if (!is_dir($pluginDir)) return []; |
|
| 56 | + if (!is_dir($pluginDir)) { |
|
| 57 | + return []; |
|
| 58 | + } |
|
| 55 | 59 | |
| 56 | 60 | $plugins = array_diff(scandir($pluginDir), ['.', '..']); |
| 57 | 61 | $pluginArray = []; |
@@ -59,7 +63,9 @@ discard block |
||
| 59 | 63 | foreach ($plugins as $pluginFolder) { |
| 60 | 64 | $path = $pluginDir . '/' . $pluginFolder; |
| 61 | 65 | |
| 62 | - if (!is_dir($path)) continue; |
|
| 66 | + if (!is_dir($path)) { |
|
| 67 | + continue; |
|
| 68 | + } |
|
| 63 | 69 | |
| 64 | 70 | $phpFiles = glob("$path/*.php"); |
| 65 | 71 | foreach ($phpFiles as $phpFile) { |
@@ -91,7 +97,9 @@ discard block |
||
| 91 | 97 | ]; |
| 92 | 98 | |
| 93 | 99 | $fp = fopen($file, 'r'); |
| 94 | - if (!$fp) return []; |
|
| 100 | + if (!$fp) { |
|
| 101 | + return []; |
|
| 102 | + } |
|
| 95 | 103 | |
| 96 | 104 | $data = fread($fp, 8192); |
| 97 | 105 | fclose($fp); |
@@ -114,7 +122,9 @@ discard block |
||
| 114 | 122 | if (isset($urlParts['path'])) { |
| 115 | 123 | $segments = explode('/', trim($urlParts['path'], '/')); |
| 116 | 124 | $lastSegment = end($segments); |
| 117 | - if ($lastSegment) return $lastSegment; |
|
| 125 | + if ($lastSegment) { |
|
| 126 | + return $lastSegment; |
|
| 127 | + } |
|
| 118 | 128 | } |
| 119 | 129 | } |
| 120 | 130 | |
@@ -126,10 +136,14 @@ discard block |
||
| 126 | 136 | { |
| 127 | 137 | $url = "https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request[slug]=" . urlencode($slug); |
| 128 | 138 | $response = @file_get_contents($url); |
| 129 | - if (!$response) return null; |
|
| 139 | + if (!$response) { |
|
| 140 | + return null; |
|
| 141 | + } |
|
| 130 | 142 | |
| 131 | 143 | $pluginData = json_decode($response, true); |
| 132 | - if (!isset($pluginData['version'])) return null; |
|
| 144 | + if (!isset($pluginData['version'])) { |
|
| 145 | + return null; |
|
| 146 | + } |
|
| 133 | 147 | |
| 134 | 148 | $latestVersion = $pluginData['version']; |
| 135 | 149 | |
@@ -10,7 +10,9 @@ |
||
| 10 | 10 | { |
| 11 | 11 | if (!array_key_exists(ApacheServerNameCollector::COLLECTION_IDENTIFIER, $inventory) |
| 12 | 12 | || !is_array($inventory[ApacheServerNameCollector::COLLECTION_IDENTIFIER]) |
| 13 | - ) return []; |
|
| 13 | + ) { |
|
| 14 | + return []; |
|
| 15 | + } |
|
| 14 | 16 | |
| 15 | 17 | $configs = $inventory[ApacheServerNameCollector::COLLECTION_IDENTIFIER]; |
| 16 | 18 | |