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) |
|
82 | |||
83 | /** |
||
84 | * Returns if the process is currently running. |
||
85 | * |
||
86 | * @return bool TRUE if the process is running, FALSE if not. |
||
87 | */ |
||
88 | 1 | public function isRunning() |
|
103 | |||
104 | /** |
||
105 | * Stops the process. |
||
106 | * |
||
107 | * @return bool `true` if the processes was stopped, `false` otherwise. |
||
108 | */ |
||
109 | 1 | public function stop() |
|
124 | |||
125 | /** |
||
126 | * Returns the ID of the process. |
||
127 | * |
||
128 | * @return int The ID of the process |
||
129 | */ |
||
130 | 1 | public function getPid() |
|
137 | |||
138 | /** |
||
139 | * Set the process id. |
||
140 | * |
||
141 | * @param $pid |
||
142 | */ |
||
143 | public function setPid($pid) |
||
147 | |||
148 | /** |
||
149 | * @return int |
||
150 | */ |
||
151 | 5 | protected function getOS() |
|
163 | |||
164 | /** |
||
165 | * @param string $message Exception message if the OS is not supported |
||
166 | * |
||
167 | * @throws RuntimeException if the operating system is not supported by Cocur\BackgroundProcess |
||
168 | * |
||
169 | * @codeCoverageIgnore |
||
170 | */ |
||
171 | protected function checkSupportingOS($message) |
||
177 | } |
||
178 |
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.