@@ -29,7 +29,7 @@ |
||
29 | 29 | } |
30 | 30 | |
31 | 31 | // Extract username, UID, and home directory |
32 | - [$username, , $uid, , , $homeDirectory] = array_slice($parts, 0, 6); |
|
32 | + [$username,, $uid,,, $homeDirectory] = array_slice($parts, 0, 6); |
|
33 | 33 | |
34 | 34 | // Only consider regular users (UID >= 1000) with a valid home directory |
35 | 35 | if (!File::getInstance()->isDir($homeDirectory)) { |
@@ -45,7 +45,9 @@ |
||
45 | 45 | // Step 2: Extract managed log paths from logrotate config files |
46 | 46 | $explicitManaged = []; |
47 | 47 | foreach ($logrotateConfs as $confFile) { |
48 | - if (!File::getInstance()->isReadable($confFile)) continue; |
|
48 | + if (!File::getInstance()->isReadable($confFile)) { |
|
49 | + continue; |
|
50 | + } |
|
49 | 51 | $lines = file($confFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
50 | 52 | foreach ($lines as $line) { |
51 | 53 | if (preg_match('#^\s*/[^\s{}]+\.log#', $line, $matches)) { |
@@ -23,7 +23,9 @@ discard block |
||
23 | 23 | { |
24 | 24 | if (!array_key_exists(ApacheServerNameCollector::COLLECTION_IDENTIFIER, $this->inventory) |
25 | 25 | || !is_array($this->inventory[ApacheServerNameCollector::COLLECTION_IDENTIFIER]) |
26 | - ) return []; |
|
26 | + ) { |
|
27 | + return []; |
|
28 | + } |
|
27 | 29 | |
28 | 30 | $configs = $this->inventory[ApacheServerNameCollector::COLLECTION_IDENTIFIER]; |
29 | 31 | |
@@ -55,7 +57,9 @@ discard block |
||
55 | 57 | private function extractPlugins(string $documentRoot): array |
56 | 58 | { |
57 | 59 | $pluginDir = $documentRoot . 'wp-content/plugins'; |
58 | - if (!File::getInstance()->isDir($pluginDir)) return []; |
|
60 | + if (!File::getInstance()->isDir($pluginDir)) { |
|
61 | + return []; |
|
62 | + } |
|
59 | 63 | |
60 | 64 | $plugins = array_diff(scandir($pluginDir), ['.', '..']); |
61 | 65 | $pluginArray = []; |
@@ -63,7 +67,9 @@ discard block |
||
63 | 67 | foreach ($plugins as $pluginFolder) { |
64 | 68 | $path = $pluginDir . '/' . $pluginFolder; |
65 | 69 | |
66 | - if (!File::getInstance()->isDir($path)) continue; |
|
70 | + if (!File::getInstance()->isDir($path)) { |
|
71 | + continue; |
|
72 | + } |
|
67 | 73 | |
68 | 74 | $phpFiles = glob("$path/*.php"); |
69 | 75 | foreach ($phpFiles as $phpFile) { |
@@ -95,7 +101,9 @@ discard block |
||
95 | 101 | ]; |
96 | 102 | |
97 | 103 | $fp = fopen($file, 'r'); |
98 | - if (!$fp) return []; |
|
104 | + if (!$fp) { |
|
105 | + return []; |
|
106 | + } |
|
99 | 107 | |
100 | 108 | $data = fread($fp, 8192); |
101 | 109 | fclose($fp); |
@@ -118,7 +126,9 @@ discard block |
||
118 | 126 | if (isset($urlParts['path'])) { |
119 | 127 | $segments = explode('/', trim($urlParts['path'], '/')); |
120 | 128 | $lastSegment = end($segments); |
121 | - if ($lastSegment) return $lastSegment; |
|
129 | + if ($lastSegment) { |
|
130 | + return $lastSegment; |
|
131 | + } |
|
122 | 132 | } |
123 | 133 | } |
124 | 134 | |
@@ -130,10 +140,14 @@ discard block |
||
130 | 140 | { |
131 | 141 | $url = "https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request[slug]=" . urlencode($slug); |
132 | 142 | $response = @file_get_contents($url); |
133 | - if (!$response) return null; |
|
143 | + if (!$response) { |
|
144 | + return null; |
|
145 | + } |
|
134 | 146 | |
135 | 147 | $pluginData = json_decode($response, true); |
136 | - if (!isset($pluginData['version'])) return null; |
|
148 | + if (!isset($pluginData['version'])) { |
|
149 | + return null; |
|
150 | + } |
|
137 | 151 | |
138 | 152 | $latestVersion = $pluginData['version']; |
139 | 153 |
@@ -125,7 +125,9 @@ discard block |
||
125 | 125 | |
126 | 126 | $output = Runner::getInstance()->run($command)->getOutput(); |
127 | 127 | |
128 | - if ($output === null) return []; |
|
128 | + if ($output === null) { |
|
129 | + return []; |
|
130 | + } |
|
129 | 131 | |
130 | 132 | $lines = explode("\n", trim($output)); |
131 | 133 | $services = []; |
@@ -133,7 +135,9 @@ discard block |
||
133 | 135 | $systemServices = array_flip($this->systemServices); |
134 | 136 | |
135 | 137 | foreach ($lines as $line) { |
136 | - if (empty($line)) continue; |
|
138 | + if (empty($line)) { |
|
139 | + continue; |
|
140 | + } |
|
137 | 141 | $parts = explode('|', $line); |
138 | 142 | |
139 | 143 | if (count($parts) >= 5) { |
@@ -20,7 +20,9 @@ |
||
20 | 20 | { |
21 | 21 | if (!array_key_exists(WordPressCollector::COLLECTOR_IDENTIFIER, $this->inventory) |
22 | 22 | || !is_array($this->inventory[WordPressCollector::COLLECTOR_IDENTIFIER]) |
23 | - ) return []; |
|
23 | + ) { |
|
24 | + return []; |
|
25 | + } |
|
24 | 26 | |
25 | 27 | $credentials = []; |
26 | 28 |
@@ -45,7 +45,7 @@ |
||
45 | 45 | return file_exists($path); |
46 | 46 | } |
47 | 47 | |
48 | - public function getContents(string $path, bool $asArray = false): string|false|array |
|
48 | + public function getContents(string $path, bool $asArray = false): string | false | array |
|
49 | 49 | { |
50 | 50 | if ($asArray) { |
51 | 51 | return file($path); |
@@ -25,7 +25,9 @@ discard block |
||
25 | 25 | |
26 | 26 | $file = new File(); |
27 | 27 | |
28 | - if (!$file->fileExists('/proc/net/dev')) return 0; |
|
28 | + if (!$file->fileExists('/proc/net/dev')) { |
|
29 | + return 0; |
|
30 | + } |
|
29 | 31 | |
30 | 32 | $lines = $file->getContents('/proc/net/dev', true); |
31 | 33 | foreach ($lines as $line) { |
@@ -38,12 +40,16 @@ discard block |
||
38 | 40 | } |
39 | 41 | } |
40 | 42 | |
41 | - if (!isset($total)) return 0; |
|
43 | + if (!isset($total)) { |
|
44 | + return 0; |
|
45 | + } |
|
42 | 46 | |
43 | 47 | $history = $memory->getData(self::MEMORY_KEY) ?? []; |
44 | 48 | $lastTotal = end($history); |
45 | 49 | |
46 | - if (!$lastTotal) $lastTotal = 0; |
|
50 | + if (!$lastTotal) { |
|
51 | + $lastTotal = 0; |
|
52 | + } |
|
47 | 53 | |
48 | 54 | if (!empty($history) && $total < $lastTotal) { |
49 | 55 | $memory->addData(self::MEMORY_KEY, $total); |
@@ -58,7 +58,9 @@ discard block |
||
58 | 58 | if ($metric->isApplicable()) { |
59 | 59 | $lastValue = Memory::getInstance()->getLastData($metric->getName(), -1); |
60 | 60 | $currentValue = $metric->getValue($lastValue); |
61 | - if ($currentValue >= 0) Memory::getInstance()->addData($metric->getName(), $currentValue); |
|
61 | + if ($currentValue >= 0) { |
|
62 | + Memory::getInstance()->addData($metric->getName(), $currentValue); |
|
63 | + } |
|
62 | 64 | $metricResults[$metric->getName()] = max(0, $currentValue); |
63 | 65 | } |
64 | 66 | } |
@@ -72,7 +74,9 @@ discard block |
||
72 | 74 | |
73 | 75 | $file = new File(); |
74 | 76 | |
75 | - if (!$file->fileExists('/proc/net/dev')) return 0; |
|
77 | + if (!$file->fileExists('/proc/net/dev')) { |
|
78 | + return 0; |
|
79 | + } |
|
76 | 80 | |
77 | 81 | $lines = $file->getContents('/proc/net/dev', true); |
78 | 82 | foreach ($lines as $line) { |
@@ -85,7 +89,9 @@ discard block |
||
85 | 89 | } |
86 | 90 | } |
87 | 91 | |
88 | - if (!isset($total)) return 0; |
|
92 | + if (!isset($total)) { |
|
93 | + return 0; |
|
94 | + } |
|
89 | 95 | |
90 | 96 | $history = $memory->getData(self::MEMORY_KEY) ?? []; |
91 | 97 |