1 | <?php |
||
24 | class BackgroundProcess |
||
25 | { |
||
26 | const OS_WINDOWS = 1; |
||
27 | const OS_NIX = 2; |
||
28 | const OS_OTHER = 3; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | private $command; |
||
34 | |||
35 | /** |
||
36 | * @var int |
||
37 | */ |
||
38 | private $pid; |
||
39 | |||
40 | /** |
||
41 | * @var int |
||
42 | */ |
||
43 | protected $serverOS; |
||
44 | |||
45 | /** |
||
46 | * @param string $command The command to execute |
||
|
|||
47 | * |
||
48 | * @codeCoverageIgnore |
||
49 | */ |
||
50 | public function __construct($command = null) |
||
55 | |||
56 | /** |
||
57 | * Runs the command in a background process. |
||
58 | * |
||
59 | * @param string $outputFile File to write the output of the process to; defaults to /dev/null |
||
60 | * currently $outputFile has no effect when used in conjunction with a Windows server |
||
61 | * @param bool $append - set to true if output should be appended to $outputfile |
||
62 | */ |
||
63 | 2 | public function run($outputFile = '/dev/null', $append = false) |
|
85 | |||
86 | /** |
||
87 | * Returns if the process is currently running. |
||
88 | * |
||
89 | * @return bool TRUE if the process is running, FALSE if not. |
||
90 | */ |
||
91 | 1 | public function isRunning() |
|
106 | |||
107 | /** |
||
108 | * Stops the process. |
||
109 | * |
||
110 | * @return bool `true` if the processes was stopped, `false` otherwise. |
||
111 | */ |
||
112 | 1 | public function stop() |
|
127 | |||
128 | /** |
||
129 | * Returns the ID of the process. |
||
130 | * |
||
131 | * @return int The ID of the process |
||
132 | */ |
||
133 | 1 | public function getPid() |
|
140 | |||
141 | /** |
||
142 | * Set the process id. |
||
143 | * |
||
144 | * @param $pid |
||
145 | */ |
||
146 | protected function setPid($pid) |
||
150 | |||
151 | /** |
||
152 | * @return int |
||
153 | */ |
||
154 | 5 | protected function getOS() |
|
166 | |||
167 | /** |
||
168 | * @param string $message Exception message if the OS is not supported |
||
169 | * |
||
170 | * @throws RuntimeException if the operating system is not supported by Cocur\BackgroundProcess |
||
171 | * |
||
172 | * @codeCoverageIgnore |
||
173 | */ |
||
174 | protected function checkSupportingOS($message) |
||
180 | |||
181 | /** |
||
182 | * @param int $pid PID of process to resume |
||
183 | * |
||
184 | * @return Cocur\BackgroundProcess\BackgroundProcess |
||
185 | */ |
||
186 | 1 | static public function createFromPID($pid) { |
|
192 | } |
||
193 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.