@@ -94,17 +94,17 @@ discard block |
||
94 | 94 | SIGALRM => self::FX_SIGNAL_ALARM, // Alarm signal. Sent by pcntl_alarm when the time is over. |
95 | 95 | SIGHUP => self::FX_SIGNAL_HANG_UP, // Hangup signal. Sent to a process when its controlling terminal is closed. |
96 | 96 | SIGINT => self::FX_SIGNAL_INTERRUPT, // Interrupt signal. Typically generated by pressing Ctrl+C. |
97 | - SIGQUIT => self::FX_SIGNAL_QUIT, // Quit signal. Similar to SIGINT but produces a core dump when received by the process. |
|
98 | - SIGTRAP => self::FX_SIGNAL_TRAP, // Trace/breakpoint trap signal. Used by debuggers to catch trace and breakpoint conditions. |
|
97 | + SIGQUIT => self::FX_SIGNAL_QUIT, // Quit signal. Similar to SIGINT but produces a core dump when received by the process. |
|
98 | + SIGTRAP => self::FX_SIGNAL_TRAP, // Trace/breakpoint trap signal. Used by debuggers to catch trace and breakpoint conditions. |
|
99 | 99 | SIGABRT => self::FX_SIGNAL_ABORT, // Abort signal. Sent by the process itself to terminate due to a critical error condition. |
100 | 100 | SIGUSR1 => self::FX_SIGNAL_USER1, // User-defined signal 1. |
101 | 101 | SIGUSR2 => self::FX_SIGNAL_USER2, // User-defined signal 2. |
102 | 102 | SIGTERM => self::FX_SIGNAL_TERMINATE, // Termination signal. Typically used to request graceful termination of a process. |
103 | 103 | SIGCHLD => self::FX_SIGNAL_CHILD, // Child signal. Sent to a parent process when a child process terminates. |
104 | - SIGCONT => self::FX_SIGNAL_CONTINUE, // Continue signal. Sent to resume a process that has been stopped. |
|
104 | + SIGCONT => self::FX_SIGNAL_CONTINUE, // Continue signal. Sent to resume a process that has been stopped. |
|
105 | 105 | SIGTSTP => self::FX_SIGNAL_TERMINAL_STOP, // Terminal stop signal. Sent by pressing Ctrl+Z to suspend the process. |
106 | - SIGTTIN => self::FX_SIGNAL_BACKGROUND_READ, // Background read signal. Sent to a process when it attempts to read from the terminal while in the background. |
|
107 | - SIGTTOU => self::FX_SIGNAL_BACKGROUND_WRITE, // Background write signal. Sent to a process when it attempts to write to the terminal while in the background. |
|
106 | + SIGTTIN => self::FX_SIGNAL_BACKGROUND_READ, // Background read signal. Sent to a process when it attempts to read from the terminal while in the background. |
|
107 | + SIGTTOU => self::FX_SIGNAL_BACKGROUND_WRITE, // Background write signal. Sent to a process when it attempts to write to the terminal while in the background. |
|
108 | 108 | SIGURG => self::FX_SIGNAL_URGENT, // Urgent condition signal. Indicates the arrival of out-of-band data on a socket. |
109 | 109 | ]; |
110 | 110 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | static::setAsyncSignals(true); |
224 | 224 | } |
225 | 225 | |
226 | - foreach(static::SIGNAL_MAP as $signal => $event) { |
|
226 | + foreach (static::SIGNAL_MAP as $signal => $event) { |
|
227 | 227 | $handler = pcntl_signal_get_handler($signal); |
228 | 228 | |
229 | 229 | if ($handler instanceof self) { |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | |
234 | 234 | $callable = is_callable($handler); |
235 | 235 | if ($callable) { |
236 | - $handler = function ($sender, $param) use ($handler) { |
|
236 | + $handler = function($sender, $param) use ($handler) { |
|
237 | 237 | return $handler($param->getSignal(), $param->getParameter()); |
238 | 238 | }; |
239 | 239 | self::$_priorHandlers[$signal][1] = $handler; |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | return false; |
278 | 278 | } |
279 | 279 | |
280 | - foreach(self::$_priorHandlers as $signal => $originalCallback) { |
|
280 | + foreach (self::$_priorHandlers as $signal => $originalCallback) { |
|
281 | 281 | pcntl_signal($signal, $originalCallback[0]); |
282 | 282 | $uninstallHandler = true; |
283 | 283 | switch ($signal) { |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | { |
326 | 326 | if (isset(static::SIGNAL_MAP[$name])) { |
327 | 327 | $name = static::SIGNAL_MAP[$name]; |
328 | - } elseif(strncasecmp('pid:', $name, 4) === 0) { |
|
328 | + } elseif (strncasecmp('pid:', $name, 4) === 0) { |
|
329 | 329 | if (is_numeric($pid = trim(substr($name, 4)))) { |
330 | 330 | return TProcessHelper::isRunning((int) $pid); |
331 | 331 | } |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | { |
348 | 348 | if (isset(static::SIGNAL_MAP[$name])) { |
349 | 349 | $name = static::SIGNAL_MAP[$name]; |
350 | - } elseif(strncasecmp('pid:', $name, 4) === 0) { |
|
350 | + } elseif (strncasecmp('pid:', $name, 4) === 0) { |
|
351 | 351 | if (is_numeric($pid = trim(substr($name, 4)))) { |
352 | 352 | $pid = (int) $pid; |
353 | 353 | return isset(self::$_pidHandlers[$pid]) && self::$_pidHandlers[$pid]->getCount() > 0; |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | { |
371 | 371 | if (isset(static::SIGNAL_MAP[$name])) { |
372 | 372 | $name = static::SIGNAL_MAP[$name]; |
373 | - } elseif(strncasecmp('pid:', $name, 4) === 0) { |
|
373 | + } elseif (strncasecmp('pid:', $name, 4) === 0) { |
|
374 | 374 | if (!is_numeric($pid = trim(substr($name, 4)))) { |
375 | 375 | throw new TInvalidOperationException('signalsdispatcher_bad_pid', $pid); |
376 | 376 | } |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | $callback = self::$_priorHandlers[SIGALRM][1]; |
621 | 621 | } |
622 | 622 | |
623 | - foreach($alarmTime !== null ? [$alarmTime] : array_keys(static::$_alarms) as $time) { |
|
623 | + foreach ($alarmTime !== null ? [$alarmTime] : array_keys(static::$_alarms) as $time) { |
|
624 | 624 | if (($key = array_search($callback, static::$_alarms[$time] ?? [], true)) !== false) { |
625 | 625 | unset(static::$_alarms[$time][$key]); |
626 | 626 | if (is_array(static::$_alarms[$time] ?? false)) { |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | $nextTime = null; |
662 | 662 | $startTime = time(); |
663 | 663 | $signalParam->setAlarmTime($startTime); |
664 | - foreach(static::$_alarms as $alarmTime => $alarms) { |
|
664 | + foreach (static::$_alarms as $alarmTime => $alarms) { |
|
665 | 665 | if ($alarmTime <= $startTime) { |
666 | 666 | array_map(fn ($alarm) => $alarm($this, $signalParam), static::$_alarms[$alarmTime]); |
667 | 667 | unset(static::$_alarms[$alarmTime]); |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | |
162 | 162 | if (TProcessHelper::isSystemWindows()) { |
163 | 163 | if (is_string($command)) { |
164 | - $command = '"' . $command . '"'; //Windows, better command support |
|
164 | + $command = '"' . $command . '"'; //Windows, better command support |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | return $command; |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | $output = shell_exec("wmic process where ProcessId={$pid} get priority"); |
232 | 232 | preg_match('/^\s*Priority\s*\r?\n\s*(\d+)/m', $output, $matches); |
233 | 233 | if (isset($matches[1])) { |
234 | - $priorityValues = [ // Map Windows Priority Numbers to Linux style Numbers |
|
234 | + $priorityValues = [// Map Windows Priority Numbers to Linux style Numbers |
|
235 | 235 | TProcessWindowsPriority::Idle => static::WINDOWS_IDLE_PRIORITY, |
236 | 236 | TProcessWindowsPriority::BelowNormal => static::WINDOWS_BELOW_NORMAL_PRIORITY, |
237 | 237 | TProcessWindowsPriority::Normal => static::WINDOWS_NORMAL_PRIORITY, |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | $pid = getmypid(); |
264 | 264 | } |
265 | 265 | if (static::isSystemWindows()) { |
266 | - $priorityValues = [ // The priority cap to windows text priority. |
|
266 | + $priorityValues = [// The priority cap to windows text priority. |
|
267 | 267 | -15 => TProcessWindowsPriorityName::Realtime, |
268 | 268 | -10 => TProcessWindowsPriorityName::HighPriority, |
269 | 269 | -5 => TProcessWindowsPriorityName::AboveNormal, |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | 9 => TProcessWindowsPriorityName::BelowNormal, |
272 | 272 | PHP_INT_MAX => TProcessWindowsPriorityName::Idle, |
273 | 273 | ]; |
274 | - foreach($priorityValues as $keyPriority => $priorityName) { |
|
274 | + foreach ($priorityValues as $keyPriority => $priorityName) { |
|
275 | 275 | if ($priority <= $keyPriority) { |
276 | 276 | break; |
277 | 277 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $logger->deleteLogs(); |
146 | 146 | $logs = $logger->deleteProfileLogs(); |
147 | 147 | $pid = getmypid(); |
148 | - foreach(array_keys($logs) as $key) { // Reset PROFILE_BEGIN to pid. |
|
148 | + foreach (array_keys($logs) as $key) { // Reset PROFILE_BEGIN to pid. |
|
149 | 149 | $logs[$key][TLogger::LOG_LEVEL] &= ~TLogger::LOGGED; |
150 | 150 | $logs[$key][TLogger::LOG_PID] = $pid; |
151 | 151 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | if (!$this->_parentConnections) { |
177 | 177 | return; |
178 | 178 | } |
179 | - if($pid && !isset($this->_parentConnections[$pid])) { |
|
179 | + if ($pid && !isset($this->_parentConnections[$pid])) { |
|
180 | 180 | return; |
181 | 181 | } |
182 | 182 | |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | do { |
188 | 188 | $read = $connections; |
189 | 189 | if (stream_select($read, $write, $except, ($wait || count($childLogs)) ? 1 : 0, 0)) { |
190 | - foreach($read as $pid => $socket) { |
|
190 | + foreach ($read as $pid => $socket) { |
|
191 | 191 | $data = fread($socket, 8192); |
192 | 192 | do { |
193 | 193 | $iterate = false; |
194 | - if($data !== false) { |
|
194 | + if ($data !== false) { |
|
195 | 195 | if (array_key_exists($pid, $childLogs)) { |
196 | 196 | $childLogs[$pid][0] .= $data; |
197 | 197 | } else { |
@@ -234,12 +234,12 @@ discard block |
||
234 | 234 | } while ($iterate); |
235 | 235 | } |
236 | 236 | } |
237 | - } while(count($childLogs) || $wait && ($pid && isset($connections[$pid]) || $pid === null && $connections)); |
|
237 | + } while (count($childLogs) || $wait && ($pid && isset($connections[$pid]) || $pid === null && $connections)); |
|
238 | 238 | |
239 | 239 | if (!$completeLogs) { |
240 | 240 | return; |
241 | 241 | } |
242 | - foreach(array_merge(...$completeLogs) as $pid => $logs) { |
|
242 | + foreach (array_merge(...$completeLogs) as $pid => $logs) { |
|
243 | 243 | Prado::getLogger()->mergeLogs(unserialize($logs)); |
244 | 244 | } |
245 | 245 | } |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | return; |
258 | 258 | } |
259 | 259 | |
260 | - if(!($logger instanceof TLogger)) { |
|
260 | + if (!($logger instanceof TLogger)) { |
|
261 | 261 | $logger = Prado::getLogger(); |
262 | 262 | } |
263 | 263 | |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | $data = substr($data, $count); |
295 | 295 | } |
296 | 296 | } |
297 | - } while($count !== false && strlen($data) > 0); |
|
297 | + } while ($count !== false && strlen($data) > 0); |
|
298 | 298 | |
299 | 299 | if ($final) { |
300 | 300 | stream_socket_shutdown($this->_childConnection, STREAM_SHUT_RDWR); |