@@ -56,18 +56,18 @@ discard block |
||
56 | 56 | /** |
57 | 57 | * Set STDOUT output stream. |
58 | 58 | * |
59 | - * @param mixed $stdout standard output |
|
59 | + * @param mixed $stdout standard output |
|
60 | 60 | * @return object |
61 | 61 | */ |
62 | 62 | final public function set_output($stdout) |
63 | 63 | { |
64 | - $this->stdout = $stdout; |
|
64 | + $this->stdout = $stdout; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
68 | 68 | * Set STDERR output stream. |
69 | 69 | * |
70 | - * @param string $stderr standard error |
|
70 | + * @param string $stderr standard error |
|
71 | 71 | * @return object |
72 | 72 | */ |
73 | 73 | final public function set_error($stderr) |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | /** |
79 | 79 | * Set exit status code. |
80 | 80 | * |
81 | - * @param int $exitstatus exit status code |
|
81 | + * @param int $exitstatus exit status code |
|
82 | 82 | * @return object |
83 | 83 | */ |
84 | 84 | final public function set_exitstatus($exitstatus) |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | final public function get_output() |
95 | 95 | { |
96 | - return $this->stdout; |
|
96 | + return $this->stdout; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | final public function get_error() |
105 | 105 | { |
106 | - return $this->stderr; |
|
106 | + return $this->stderr; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | final public function get_exitstatus() |
115 | 115 | { |
116 | - return $this->exitstatus; |
|
116 | + return $this->exitstatus; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -37,21 +37,21 @@ |
||
37 | 37 | * |
38 | 38 | * @var string |
39 | 39 | */ |
40 | - protected $error_message = null; |
|
40 | + protected $error_message = NULL; |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Last known error line number. |
44 | 44 | * |
45 | 45 | * @var int |
46 | 46 | */ |
47 | - protected $error_line_no = null; |
|
47 | + protected $error_line_no = NULL; |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Last known error filename. |
51 | 51 | * |
52 | 52 | * @var string |
53 | 53 | */ |
54 | - protected $error_file = null; |
|
54 | + protected $error_file = NULL; |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Set STDOUT output stream. |
@@ -16,7 +16,7 @@ |
||
16 | 16 | * |
17 | 17 | * @var string |
18 | 18 | */ |
19 | - private $pty = null; |
|
19 | + private $pty = NULL; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Environmental variables (associative array). |
@@ -35,7 +35,7 @@ |
||
35 | 35 | */ |
36 | 36 | final public function authenticate($resource) |
37 | 37 | { |
38 | - if (@ssh2_auth_agent($resource, $this->username) === false) |
|
38 | + if (@ssh2_auth_agent($resource, $this->username) === FALSE) |
|
39 | 39 | { |
40 | 40 | throw new \RuntimeException('Agent based authentication failed.'); |
41 | 41 | } |
@@ -82,7 +82,7 @@ |
||
82 | 82 | $this->privkeyfile, |
83 | 83 | $this->passphrase, |
84 | 84 | $this->local_username |
85 | - ) === false) |
|
85 | + ) === FALSE) |
|
86 | 86 | { |
87 | 87 | throw new \RuntimeException('Hostbased file authentication failed.'); |
88 | 88 | } |
@@ -65,7 +65,7 @@ |
||
65 | 65 | $this->pubkeyfile, |
66 | 66 | $this->privkeyfile, |
67 | 67 | $this->passphrase |
68 | - ) === false) |
|
68 | + ) === FALSE) |
|
69 | 69 | { |
70 | 70 | throw new \RuntimeException('Public key based authentication failed.'); |
71 | 71 | } |
@@ -43,7 +43,7 @@ |
||
43 | 43 | */ |
44 | 44 | final public function authenticate($resource) |
45 | 45 | { |
46 | - if (@ssh2_auth_password($resource, $this->username, $this->password) === false) |
|
46 | + if (@ssh2_auth_password($resource, $this->username, $this->password) === FALSE) |
|
47 | 47 | { |
48 | 48 | throw new \RuntimeException('Password based authentication failed.'); |
49 | 49 | } |
@@ -11,35 +11,35 @@ discard block |
||
11 | 11 | class Configuration |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
14 | + /** |
|
15 | 15 | * Username. |
16 | 16 | * |
17 | 17 | * @var string |
18 | 18 | */ |
19 | 19 | protected $username = null; |
20 | 20 | |
21 | - /** |
|
21 | + /** |
|
22 | 22 | * User password. |
23 | 23 | * |
24 | 24 | * @var string |
25 | 25 | */ |
26 | 26 | protected $password = null; |
27 | 27 | |
28 | - /** |
|
28 | + /** |
|
29 | 29 | * RSA public key. |
30 | 30 | * |
31 | 31 | * @var string |
32 | 32 | */ |
33 | 33 | protected $publickey = null; |
34 | 34 | |
35 | - /** |
|
35 | + /** |
|
36 | 36 | * RSA private key. |
37 | 37 | * |
38 | 38 | * @var string |
39 | 39 | */ |
40 | 40 | protected $privatekey = null; |
41 | 41 | |
42 | - /** |
|
42 | + /** |
|
43 | 43 | * Passphrase. |
44 | 44 | * |
45 | 45 | * @var string |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | protected $methods = []; |
69 | 69 | |
70 | - /** |
|
70 | + /** |
|
71 | 71 | * SSH tunnel requested. |
72 | 72 | * |
73 | 73 | * @var boolean |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | protected $tunnel_port = 22; |
90 | 90 | |
91 | - /** |
|
91 | + /** |
|
92 | 92 | * Sets username. |
93 | 93 | * |
94 | 94 | * @param string $username username |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | return $this; |
101 | 101 | } |
102 | 102 | |
103 | - /** |
|
103 | + /** |
|
104 | 104 | * Sets user password. |
105 | 105 | * |
106 | 106 | * @param string $password password |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | return $this; |
113 | 113 | } |
114 | 114 | |
115 | - /** |
|
115 | + /** |
|
116 | 116 | * Sets RSA public key. |
117 | 117 | * |
118 | 118 | * @param string $publickey RSA public key |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | return $this; |
125 | 125 | } |
126 | 126 | |
127 | - /** |
|
127 | + /** |
|
128 | 128 | * Sets RSA private key. |
129 | 129 | * |
130 | 130 | * @param string $privatekey RSA private key |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | return $this; |
137 | 137 | } |
138 | 138 | |
139 | - /** |
|
139 | + /** |
|
140 | 140 | * Sets passphrase. |
141 | 141 | * |
142 | 142 | * @param string $passphrase passphrase |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | return $this; |
188 | 188 | } |
189 | 189 | |
190 | - /** |
|
190 | + /** |
|
191 | 191 | * Sets tunnel. |
192 | 192 | * |
193 | 193 | * @return object \LibSSH2\Configuration object |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | final public function set_tunnel_host($host) |
208 | 208 | { |
209 | - $this->set_tunnel(); |
|
209 | + $this->set_tunnel(); |
|
210 | 210 | $this->tunnel_host = $host; |
211 | 211 | return $this; |
212 | 212 | } |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | return $this; |
224 | 224 | } |
225 | 225 | |
226 | - /** |
|
226 | + /** |
|
227 | 227 | * Returns username. |
228 | 228 | * |
229 | 229 | * @return string username |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | return $this->username; |
238 | 238 | } |
239 | 239 | |
240 | - /** |
|
240 | + /** |
|
241 | 241 | * Returns user's password. |
242 | 242 | * |
243 | 243 | * @return string password |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | return $this->password; |
252 | 252 | } |
253 | 253 | |
254 | - /** |
|
254 | + /** |
|
255 | 255 | * Returns RSA public key. |
256 | 256 | * |
257 | 257 | * @return string RSA public key |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | return $this->publickey; |
266 | 266 | } |
267 | 267 | |
268 | - /** |
|
268 | + /** |
|
269 | 269 | * Returns RSA private key. |
270 | 270 | * |
271 | 271 | * @return string privatekey |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | return $this->privatekey; |
280 | 280 | } |
281 | 281 | |
282 | - /** |
|
282 | + /** |
|
283 | 283 | * Returns passphrase. |
284 | 284 | * |
285 | 285 | * @return string passphrase |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | } |
327 | 327 | } |
328 | 328 | |
329 | - /** |
|
329 | + /** |
|
330 | 330 | * Returns tunnel. |
331 | 331 | * |
332 | 332 | * @return boolean |
@@ -16,42 +16,42 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @var string |
18 | 18 | */ |
19 | - protected $username = null; |
|
19 | + protected $username = NULL; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * User password. |
23 | 23 | * |
24 | 24 | * @var string |
25 | 25 | */ |
26 | - protected $password = null; |
|
26 | + protected $password = NULL; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * RSA public key. |
30 | 30 | * |
31 | 31 | * @var string |
32 | 32 | */ |
33 | - protected $publickey = null; |
|
33 | + protected $publickey = NULL; |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * RSA private key. |
37 | 37 | * |
38 | 38 | * @var string |
39 | 39 | */ |
40 | - protected $privatekey = null; |
|
40 | + protected $privatekey = NULL; |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Passphrase. |
44 | 44 | * |
45 | 45 | * @var string |
46 | 46 | */ |
47 | - protected $passphrase = null; |
|
47 | + protected $passphrase = NULL; |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Hostname. |
51 | 51 | * |
52 | 52 | * @var string |
53 | 53 | */ |
54 | - protected $host = null; |
|
54 | + protected $host = NULL; |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Port. |
@@ -72,14 +72,14 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @var boolean |
74 | 74 | */ |
75 | - protected $tunnel = false; |
|
75 | + protected $tunnel = FALSE; |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * SSH tunnel hostname. |
79 | 79 | * |
80 | 80 | * @var string |
81 | 81 | */ |
82 | - protected $tunnel_host = null; |
|
82 | + protected $tunnel_host = NULL; |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * SSH tunnel port. |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | * @param array $methods remote connection methods |
179 | 179 | * @return object \LibSSH2\Configuration object |
180 | 180 | */ |
181 | - final public function set_methods(array $methods = null) |
|
181 | + final public function set_methods(array $methods = NULL) |
|
182 | 182 | { |
183 | - if ($methods !== null) |
|
183 | + if ($methods !== NULL) |
|
184 | 184 | { |
185 | 185 | $this->methods = $methods; |
186 | 186 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | */ |
195 | 195 | final public function set_tunnel() |
196 | 196 | { |
197 | - $this->tunnel = true; |
|
197 | + $this->tunnel = TRUE; |
|
198 | 198 | return $this; |
199 | 199 | } |
200 | 200 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | */ |
231 | 231 | final public function get_username() |
232 | 232 | { |
233 | - if ($this->username === null) |
|
233 | + if ($this->username === NULL) |
|
234 | 234 | { |
235 | 235 | throw new \RuntimeException('A username is required to authenticate to the remote server.'); |
236 | 236 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | final public function get_password() |
246 | 246 | { |
247 | - if ($this->password === null) |
|
247 | + if ($this->password === NULL) |
|
248 | 248 | { |
249 | 249 | throw new \RuntimeException('Password is not currently set.'); |
250 | 250 | } |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | */ |
259 | 259 | final public function get_publickey() |
260 | 260 | { |
261 | - if ($this->publickey === null) |
|
261 | + if ($this->publickey === NULL) |
|
262 | 262 | { |
263 | 263 | throw new \RuntimeException('No RSA public key found.'); |
264 | 264 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | */ |
273 | 273 | final public function get_privatekey() |
274 | 274 | { |
275 | - if ($this->privatekey === null) |
|
275 | + if ($this->privatekey === NULL) |
|
276 | 276 | { |
277 | 277 | throw new \RuntimeException('No RSA private key found.'); |
278 | 278 | } |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | */ |
287 | 287 | final public function get_passphrase() |
288 | 288 | { |
289 | - return ($this->passphrase === null) ? '' : $this->passphrase; |
|
289 | + return ($this->passphrase === NULL) ? '' : $this->passphrase; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | */ |
297 | 297 | final public function get_host() |
298 | 298 | { |
299 | - if ($this->host === null) |
|
299 | + if ($this->host === NULL) |
|
300 | 300 | { |
301 | 301 | throw new \RuntimeException('Unable to create remote connection; no hostname was set.'); |
302 | 302 | } |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | */ |
321 | 321 | final public function get_methods() |
322 | 322 | { |
323 | - if ($this->methods !== null || !empty($this->methods)) |
|
323 | + if ($this->methods !== NULL || !empty($this->methods)) |
|
324 | 324 | { |
325 | 325 | return $this->methods; |
326 | 326 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | */ |
344 | 344 | final public function get_tunnel_host() |
345 | 345 | { |
346 | - if ($this->tunnel_host === null) |
|
346 | + if ($this->tunnel_host === NULL) |
|
347 | 347 | { |
348 | 348 | throw new \RuntimeException('A valid hostname must be set prior to attempting a tunnel connection.'); |
349 | 349 | } |
@@ -15,12 +15,12 @@ discard block |
||
15 | 15 | class SFTP extends Connection |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * SFTP connection resource. |
|
20 | - * |
|
21 | - * @var resource |
|
22 | - */ |
|
23 | - private $sftp; |
|
18 | + /** |
|
19 | + * SFTP connection resource. |
|
20 | + * |
|
21 | + * @var resource |
|
22 | + */ |
|
23 | + private $sftp; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Constructor. |
@@ -33,14 +33,14 @@ discard block |
||
33 | 33 | { |
34 | 34 | parent::__construct($configuration, $authentication); |
35 | 35 | |
36 | - $this->sftp = @ssh2_sftp($this->connection); |
|
37 | - if(!$this->sftp) |
|
38 | - { |
|
39 | - throw new \RuntimeException($this->get_error_message()); |
|
40 | - } |
|
36 | + $this->sftp = @ssh2_sftp($this->connection); |
|
37 | + if(!$this->sftp) |
|
38 | + { |
|
39 | + throw new \RuntimeException($this->get_error_message()); |
|
40 | + } |
|
41 | 41 | } |
42 | 42 | |
43 | - /** |
|
43 | + /** |
|
44 | 44 | * Copies file. |
45 | 45 | * |
46 | 46 | * @param string $srcfile path to the source file |
@@ -50,23 +50,23 @@ discard block |
||
50 | 50 | final public function copy($srcfile, $destfile) |
51 | 51 | { |
52 | 52 | if ($this->is_file($srcfile) === false) |
53 | - { |
|
54 | - $this->set_error('Local file ' . $srcfile . ' does not exist.'); |
|
55 | - $this->set_exitstatus(1); |
|
56 | - return; |
|
57 | - } |
|
53 | + { |
|
54 | + $this->set_error('Local file ' . $srcfile . ' does not exist.'); |
|
55 | + $this->set_exitstatus(1); |
|
56 | + return; |
|
57 | + } |
|
58 | 58 | |
59 | - if (@copy($this->sftp_url($srcfile), $this->sftp_url($destfile)) === false) |
|
60 | - { |
|
61 | - $this->set_error($this->get_error_message()); |
|
62 | - $this->set_exitstatus(1); |
|
63 | - return; |
|
64 | - } |
|
65 | - $this->set_output('Successfully copied file at: ' . $srcfile . ' to ' . $destfile); |
|
66 | - $this->set_exitstatus(0); |
|
59 | + if (@copy($this->sftp_url($srcfile), $this->sftp_url($destfile)) === false) |
|
60 | + { |
|
61 | + $this->set_error($this->get_error_message()); |
|
62 | + $this->set_exitstatus(1); |
|
63 | + return; |
|
64 | + } |
|
65 | + $this->set_output('Successfully copied file at: ' . $srcfile . ' to ' . $destfile); |
|
66 | + $this->set_exitstatus(0); |
|
67 | 67 | } |
68 | 68 | |
69 | - /** |
|
69 | + /** |
|
70 | 70 | * Removes files. |
71 | 71 | * |
72 | 72 | * Caveats: |
@@ -77,96 +77,96 @@ discard block |
||
77 | 77 | */ |
78 | 78 | final public function delete($files) |
79 | 79 | { |
80 | - $files = !is_array($files) ? [$files] : $files; |
|
81 | - foreach ($files as $file) |
|
82 | - { |
|
83 | - if ($this->is_file($file)) |
|
84 | - { |
|
85 | - if (@unlink($this->sftp_url($file)) === false) |
|
86 | - { |
|
87 | - $this->set_error($this->get_error_message()); |
|
88 | - $this->set_exitstatus(1); |
|
89 | - return; |
|
90 | - } |
|
91 | - continue; |
|
92 | - } |
|
93 | - } |
|
94 | - $this->set_output('Successfully deleted remote file(s) at: ' . implode(', ', $files)); |
|
95 | - $this->set_exitstatus(0); |
|
80 | + $files = !is_array($files) ? [$files] : $files; |
|
81 | + foreach ($files as $file) |
|
82 | + { |
|
83 | + if ($this->is_file($file)) |
|
84 | + { |
|
85 | + if (@unlink($this->sftp_url($file)) === false) |
|
86 | + { |
|
87 | + $this->set_error($this->get_error_message()); |
|
88 | + $this->set_exitstatus(1); |
|
89 | + return; |
|
90 | + } |
|
91 | + continue; |
|
92 | + } |
|
93 | + } |
|
94 | + $this->set_output('Successfully deleted remote file(s) at: ' . implode(', ', $files)); |
|
95 | + $this->set_exitstatus(0); |
|
96 | 96 | } |
97 | 97 | |
98 | - /** |
|
99 | - * Tells whether the filename is a directory. |
|
100 | - * |
|
101 | - * @param string $path directory path |
|
102 | - * @return boolean |
|
103 | - */ |
|
104 | - final public function is_dir($path) |
|
105 | - { |
|
106 | - return is_dir($this->sftp_url($path)); |
|
107 | - } |
|
98 | + /** |
|
99 | + * Tells whether the filename is a directory. |
|
100 | + * |
|
101 | + * @param string $path directory path |
|
102 | + * @return boolean |
|
103 | + */ |
|
104 | + final public function is_dir($path) |
|
105 | + { |
|
106 | + return is_dir($this->sftp_url($path)); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Tells whether the filename is a file. |
|
111 | - * |
|
112 | - * @param string $path directory path |
|
113 | - * @return boolean |
|
114 | - */ |
|
115 | - final public function is_file($path) |
|
116 | - { |
|
117 | - return is_file($this->sftp_url($path)); |
|
118 | - } |
|
109 | + /** |
|
110 | + * Tells whether the filename is a file. |
|
111 | + * |
|
112 | + * @param string $path directory path |
|
113 | + * @return boolean |
|
114 | + */ |
|
115 | + final public function is_file($path) |
|
116 | + { |
|
117 | + return is_file($this->sftp_url($path)); |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * Directory listing. |
|
122 | - * |
|
123 | - * @param string $path directory path |
|
124 | - * @return void |
|
125 | - */ |
|
126 | - final public function ls($path) |
|
127 | - { |
|
128 | - $files = []; |
|
129 | - if ($handle = @opendir($this->sftp_url($path))) |
|
130 | - { |
|
131 | - while (($file = @readdir($handle)) !== false) |
|
132 | - { |
|
133 | - if ($file != '.' && $file != '..') |
|
134 | - { |
|
135 | - $filename = rtrim($path, '/') . '/' . $file; |
|
136 | - if ($this->is_dir($filename)) |
|
137 | - { |
|
138 | - $files['directories'][] = $filename; |
|
139 | - } |
|
120 | + /** |
|
121 | + * Directory listing. |
|
122 | + * |
|
123 | + * @param string $path directory path |
|
124 | + * @return void |
|
125 | + */ |
|
126 | + final public function ls($path) |
|
127 | + { |
|
128 | + $files = []; |
|
129 | + if ($handle = @opendir($this->sftp_url($path))) |
|
130 | + { |
|
131 | + while (($file = @readdir($handle)) !== false) |
|
132 | + { |
|
133 | + if ($file != '.' && $file != '..') |
|
134 | + { |
|
135 | + $filename = rtrim($path, '/') . '/' . $file; |
|
136 | + if ($this->is_dir($filename)) |
|
137 | + { |
|
138 | + $files['directories'][] = $filename; |
|
139 | + } |
|
140 | 140 | |
141 | - if ($this->is_dir($filename) === false) |
|
142 | - { |
|
143 | - $files['files'][] = $filename; |
|
144 | - } |
|
145 | - } |
|
146 | - } |
|
147 | - closedir($handle); |
|
148 | - } |
|
149 | - $this->set_output($files); |
|
150 | - $this->set_exitstatus(0); |
|
151 | - } |
|
141 | + if ($this->is_dir($filename) === false) |
|
142 | + { |
|
143 | + $files['files'][] = $filename; |
|
144 | + } |
|
145 | + } |
|
146 | + } |
|
147 | + closedir($handle); |
|
148 | + } |
|
149 | + $this->set_output($files); |
|
150 | + $this->set_exitstatus(0); |
|
151 | + } |
|
152 | 152 | |
153 | - /** |
|
154 | - * Returns pathnames matching a pattern (for files only & hidden files). |
|
155 | - * |
|
156 | - * @param string $directory directory |
|
157 | - * @param mixed $pattern pattern (does not support tilde expansion) |
|
158 | - * @return mixed matched files or null |
|
159 | - */ |
|
160 | - final public function glob($directory, $pattern = '') |
|
161 | - { |
|
162 | - if ($this->is_dir($directory) == false) |
|
163 | - { |
|
164 | - $this->set_error($this->get_error_message()); |
|
165 | - $this->set_exitstatus(1); |
|
166 | - return; |
|
167 | - } |
|
153 | + /** |
|
154 | + * Returns pathnames matching a pattern (for files only & hidden files). |
|
155 | + * |
|
156 | + * @param string $directory directory |
|
157 | + * @param mixed $pattern pattern (does not support tilde expansion) |
|
158 | + * @return mixed matched files or null |
|
159 | + */ |
|
160 | + final public function glob($directory, $pattern = '') |
|
161 | + { |
|
162 | + if ($this->is_dir($directory) == false) |
|
163 | + { |
|
164 | + $this->set_error($this->get_error_message()); |
|
165 | + $this->set_exitstatus(1); |
|
166 | + return; |
|
167 | + } |
|
168 | 168 | |
169 | - $handle = opendir($this->sftp_url($directory)); |
|
169 | + $handle = opendir($this->sftp_url($directory)); |
|
170 | 170 | while (($file = readdir($handle)) !== false) |
171 | 171 | { |
172 | 172 | $files[] = preg_grep('/(^.*' . $pattern . '.*$)/', explode(PHP_EOL, $file)); |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | |
175 | 175 | if (empty($files)) |
176 | 176 | { |
177 | - $this->set_output([]); |
|
178 | - $this->set_exitstatus(0); |
|
179 | - return; |
|
180 | - } |
|
177 | + $this->set_output([]); |
|
178 | + $this->set_exitstatus(0); |
|
179 | + return; |
|
180 | + } |
|
181 | 181 | |
182 | 182 | $files = array_reduce($files, 'array_merge', []); |
183 | 183 | $files = array_diff($files, ['.', '..']); |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | $_files = []; |
186 | 186 | foreach ($files as $file) |
187 | 187 | { |
188 | - $_files[] = rtrim($directory, '/') . '/' . $file; |
|
188 | + $_files[] = rtrim($directory, '/') . '/' . $file; |
|
189 | 189 | } |
190 | - $this->set_output($_files); |
|
191 | - $this->set_exitstatus(0); |
|
192 | - } |
|
190 | + $this->set_output($_files); |
|
191 | + $this->set_exitstatus(0); |
|
192 | + } |
|
193 | 193 | |
194 | - /** |
|
194 | + /** |
|
195 | 195 | * Create new directory. |
196 | 196 | * |
197 | 197 | * @param mizxed $directories path to the directory |
@@ -205,18 +205,18 @@ discard block |
||
205 | 205 | $directories = !is_array($directories) ? [$directories] : $directories; |
206 | 206 | foreach ($directories as $directory) |
207 | 207 | { |
208 | - if (@mkdir($this->sftp_url($directory), $mode, $recursive) === false) |
|
209 | - { |
|
210 | - $this->set_error($this->get_error_message()); |
|
211 | - $this->set_exitstatus(1); |
|
212 | - return; |
|
213 | - } |
|
208 | + if (@mkdir($this->sftp_url($directory), $mode, $recursive) === false) |
|
209 | + { |
|
210 | + $this->set_error($this->get_error_message()); |
|
211 | + $this->set_exitstatus(1); |
|
212 | + return; |
|
213 | + } |
|
214 | 214 | } |
215 | - $this->set_output('Successfully created remote directory(ies) at: ' . implode(', ', $directories)); |
|
216 | - $this->set_exitstatus(0); |
|
215 | + $this->set_output('Successfully created remote directory(ies) at: ' . implode(', ', $directories)); |
|
216 | + $this->set_exitstatus(0); |
|
217 | 217 | } |
218 | 218 | |
219 | - /** |
|
219 | + /** |
|
220 | 220 | * Moves file to different path (rename). |
221 | 221 | * |
222 | 222 | * @param string $oldfile path to the old file |
@@ -226,23 +226,23 @@ discard block |
||
226 | 226 | final public function rename($oldfile, $newfile) |
227 | 227 | { |
228 | 228 | if ($this->is_file($oldfile) === false) |
229 | - { |
|
230 | - $this->set_error('Local file ' . $oldfile . ' does not exist.'); |
|
231 | - $this->set_exitstatus(1); |
|
232 | - return; |
|
233 | - } |
|
229 | + { |
|
230 | + $this->set_error('Local file ' . $oldfile . ' does not exist.'); |
|
231 | + $this->set_exitstatus(1); |
|
232 | + return; |
|
233 | + } |
|
234 | 234 | |
235 | - if (!@ssh2_sftp_rename($this->sftp, $oldfile, $newfile)) |
|
235 | + if (!@ssh2_sftp_rename($this->sftp, $oldfile, $newfile)) |
|
236 | 236 | { |
237 | 237 | $this->set_error($this->get_error_message()); |
238 | - $this->set_exitstatus(1); |
|
239 | - return; |
|
238 | + $this->set_exitstatus(1); |
|
239 | + return; |
|
240 | 240 | } |
241 | - $this->set_output('Successfully renamed remote file at: ' . $oldfile . ' to ' . $newfile); |
|
242 | - $this->set_exitstatus(0); |
|
241 | + $this->set_output('Successfully renamed remote file at: ' . $oldfile . ' to ' . $newfile); |
|
242 | + $this->set_exitstatus(0); |
|
243 | 243 | } |
244 | 244 | |
245 | - /** |
|
245 | + /** |
|
246 | 246 | * Removes directory. |
247 | 247 | * |
248 | 248 | * Caveats: |
@@ -252,40 +252,40 @@ discard block |
||
252 | 252 | * @param mixed $directories directory or directories to remove |
253 | 253 | * @return boolean |
254 | 254 | */ |
255 | - final public function rmdir($directories) |
|
256 | - { |
|
257 | - $directories = !is_array($directories) ? [$directories] : $directories; |
|
258 | - foreach ($directories as $directory) |
|
255 | + final public function rmdir($directories) |
|
256 | + { |
|
257 | + $directories = !is_array($directories) ? [$directories] : $directories; |
|
258 | + foreach ($directories as $directory) |
|
259 | 259 | { |
260 | - if ($this->is_dir($directory)) |
|
261 | - { |
|
262 | - start: |
|
263 | - $this->ls($directory)['files']; |
|
264 | - $stdout = $this->get_output(); |
|
265 | - $files = array_key_exists('files', $stdout) ? $stdout['files'] : []; |
|
266 | - if (count($files) == 0) |
|
267 | - { |
|
268 | - if (@rmdir($this->sftp_url($directory)) === false) |
|
269 | - { |
|
270 | - $this->set_error($this->get_error_message()); |
|
271 | - $this->set_exitstatus(1); |
|
272 | - return; |
|
273 | - } |
|
274 | - continue; |
|
275 | - } |
|
260 | + if ($this->is_dir($directory)) |
|
261 | + { |
|
262 | + start: |
|
263 | + $this->ls($directory)['files']; |
|
264 | + $stdout = $this->get_output(); |
|
265 | + $files = array_key_exists('files', $stdout) ? $stdout['files'] : []; |
|
266 | + if (count($files) == 0) |
|
267 | + { |
|
268 | + if (@rmdir($this->sftp_url($directory)) === false) |
|
269 | + { |
|
270 | + $this->set_error($this->get_error_message()); |
|
271 | + $this->set_exitstatus(1); |
|
272 | + return; |
|
273 | + } |
|
274 | + continue; |
|
275 | + } |
|
276 | 276 | |
277 | - if (count($files) != 0) |
|
278 | - { |
|
279 | - $this->delete($files); |
|
280 | - goto start; |
|
281 | - } |
|
282 | - } |
|
277 | + if (count($files) != 0) |
|
278 | + { |
|
279 | + $this->delete($files); |
|
280 | + goto start; |
|
281 | + } |
|
282 | + } |
|
283 | 283 | } |
284 | - $this->set_output('Successfully removed remote directory(ies) at: ' . implode(', ', $directories)); |
|
285 | - $this->set_exitstatus(0); |
|
286 | - } |
|
284 | + $this->set_output('Successfully removed remote directory(ies) at: ' . implode(', ', $directories)); |
|
285 | + $this->set_exitstatus(0); |
|
286 | + } |
|
287 | 287 | |
288 | - /** |
|
288 | + /** |
|
289 | 289 | * Sends a file via SCP. |
290 | 290 | * |
291 | 291 | * @param mixed $local source file(s) (local) |
@@ -295,21 +295,21 @@ discard block |
||
295 | 295 | */ |
296 | 296 | final public function put($local_files, $remote_dir, $mode = 0750) |
297 | 297 | { |
298 | - $local_files = !is_array($local_files) ? [$local_files] : $local_files; |
|
298 | + $local_files = !is_array($local_files) ? [$local_files] : $local_files; |
|
299 | 299 | foreach ($local_files as $local_file) |
300 | 300 | { |
301 | - if (!@ssh2_scp_send($this->connection, $local_file, rtrim($remote_dir, '/') . '/' . basename($local_file), $mode)) |
|
302 | - { |
|
303 | - $this->set_error($this->get_error_message()); |
|
304 | - $this->set_exitstatus(1); |
|
305 | - return; |
|
306 | - } |
|
301 | + if (!@ssh2_scp_send($this->connection, $local_file, rtrim($remote_dir, '/') . '/' . basename($local_file), $mode)) |
|
302 | + { |
|
303 | + $this->set_error($this->get_error_message()); |
|
304 | + $this->set_exitstatus(1); |
|
305 | + return; |
|
306 | + } |
|
307 | 307 | } |
308 | - $this->set_output('Successfully sent local files to remote host at: ' . implode(', ', $local_files)); |
|
308 | + $this->set_output('Successfully sent local files to remote host at: ' . implode(', ', $local_files)); |
|
309 | 309 | $this->set_exitstatus(0); |
310 | 310 | } |
311 | 311 | |
312 | - /** |
|
312 | + /** |
|
313 | 313 | * Recieves a file via SCP. |
314 | 314 | * |
315 | 315 | * @param mixed $local source file(s) (local) |
@@ -318,58 +318,58 @@ discard block |
||
318 | 318 | */ |
319 | 319 | final public function get($remote_files, $local_dir) |
320 | 320 | { |
321 | - $remote_files = !is_array($remote_files) ? [$remote_files] : $remote_files; |
|
321 | + $remote_files = !is_array($remote_files) ? [$remote_files] : $remote_files; |
|
322 | 322 | foreach ($remote_files as $remote_file) |
323 | 323 | { |
324 | - if (!@ssh2_scp_recv($this->connection, $remote_file, rtrim($local_dir, '/') . '/' . basename($remote_file))) |
|
325 | - { |
|
326 | - $this->set_error($this->get_error_message()); |
|
327 | - $this->set_exitstatus(1); |
|
328 | - return; |
|
329 | - } |
|
324 | + if (!@ssh2_scp_recv($this->connection, $remote_file, rtrim($local_dir, '/') . '/' . basename($remote_file))) |
|
325 | + { |
|
326 | + $this->set_error($this->get_error_message()); |
|
327 | + $this->set_exitstatus(1); |
|
328 | + return; |
|
329 | + } |
|
330 | 330 | } |
331 | - $this->set_output('Successfully received remote files: ' . implode(', ', $remote_files)); |
|
331 | + $this->set_output('Successfully received remote files: ' . implode(', ', $remote_files)); |
|
332 | 332 | $this->set_exitstatus(0); |
333 | 333 | } |
334 | 334 | |
335 | - /** |
|
336 | - * Returns stat a file on a remote filesystem. |
|
337 | - * |
|
338 | - * @param string $path directory path |
|
339 | - * @return void |
|
340 | - */ |
|
341 | - final public function stat($path) |
|
342 | - { |
|
343 | - $statinfo = ssh2_sftp_stat($this->sftp, $path); |
|
335 | + /** |
|
336 | + * Returns stat a file on a remote filesystem. |
|
337 | + * |
|
338 | + * @param string $path directory path |
|
339 | + * @return void |
|
340 | + */ |
|
341 | + final public function stat($path) |
|
342 | + { |
|
343 | + $statinfo = ssh2_sftp_stat($this->sftp, $path); |
|
344 | 344 | |
345 | - if ($statinfo === false) |
|
346 | - { |
|
347 | - $this->set_error($this->get_error_message()); |
|
348 | - $this->set_exitstatus(0); |
|
349 | - return; |
|
350 | - } |
|
345 | + if ($statinfo === false) |
|
346 | + { |
|
347 | + $this->set_error($this->get_error_message()); |
|
348 | + $this->set_exitstatus(0); |
|
349 | + return; |
|
350 | + } |
|
351 | 351 | |
352 | - $statinfo = [ |
|
353 | - 'size' => $statinfo['size'], |
|
354 | - 'groupid' => $statinfo['gid'], |
|
355 | - 'userid' => $statinfo['uid'], |
|
356 | - 'atime' => date('c', $statinfo['atime']), |
|
357 | - 'mtime' => date('c', $statinfo['mtime']), |
|
358 | - 'mode' => $statinfo['mode'], |
|
359 | - ]; |
|
360 | - $this->set_output($statinfo); |
|
361 | - $this->set_exitstatus(0); |
|
362 | - } |
|
352 | + $statinfo = [ |
|
353 | + 'size' => $statinfo['size'], |
|
354 | + 'groupid' => $statinfo['gid'], |
|
355 | + 'userid' => $statinfo['uid'], |
|
356 | + 'atime' => date('c', $statinfo['atime']), |
|
357 | + 'mtime' => date('c', $statinfo['mtime']), |
|
358 | + 'mode' => $statinfo['mode'], |
|
359 | + ]; |
|
360 | + $this->set_output($statinfo); |
|
361 | + $this->set_exitstatus(0); |
|
362 | + } |
|
363 | 363 | |
364 | - /** |
|
365 | - * Create SFTP URL wrapper for unsupported commands. |
|
366 | - * |
|
367 | - * @param string $path directory path |
|
368 | - * @return string SFTP connection wrapprer |
|
369 | - */ |
|
370 | - final private function sftp_url($path = '') |
|
371 | - { |
|
372 | - return 'ssh2.sftp://' . $this->sftp . $path; |
|
373 | - } |
|
364 | + /** |
|
365 | + * Create SFTP URL wrapper for unsupported commands. |
|
366 | + * |
|
367 | + * @param string $path directory path |
|
368 | + * @return string SFTP connection wrapprer |
|
369 | + */ |
|
370 | + final private function sftp_url($path = '') |
|
371 | + { |
|
372 | + return 'ssh2.sftp://' . $this->sftp . $path; |
|
373 | + } |
|
374 | 374 | |
375 | 375 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | parent::__construct($configuration, $authentication); |
35 | 35 | |
36 | 36 | $this->sftp = @ssh2_sftp($this->connection); |
37 | - if(!$this->sftp) |
|
37 | + if (!$this->sftp) |
|
38 | 38 | { |
39 | 39 | throw new \RuntimeException($this->get_error_message()); |
40 | 40 | } |
@@ -256,7 +256,7 @@ |
||
256 | 256 | { |
257 | 257 | $directories = !is_array($directories) ? [$directories] : $directories; |
258 | 258 | foreach ($directories as $directory) |
259 | - { |
|
259 | + { |
|
260 | 260 | if ($this->is_dir($directory)) |
261 | 261 | { |
262 | 262 | start: |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | */ |
50 | 50 | final public function copy($srcfile, $destfile) |
51 | 51 | { |
52 | - if ($this->is_file($srcfile) === false) |
|
52 | + if ($this->is_file($srcfile) === FALSE) |
|
53 | 53 | { |
54 | 54 | $this->set_error('Local file ' . $srcfile . ' does not exist.'); |
55 | 55 | $this->set_exitstatus(1); |
56 | 56 | return; |
57 | 57 | } |
58 | 58 | |
59 | - if (@copy($this->sftp_url($srcfile), $this->sftp_url($destfile)) === false) |
|
59 | + if (@copy($this->sftp_url($srcfile), $this->sftp_url($destfile)) === FALSE) |
|
60 | 60 | { |
61 | 61 | $this->set_error($this->get_error_message()); |
62 | 62 | $this->set_exitstatus(1); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | { |
83 | 83 | if ($this->is_file($file)) |
84 | 84 | { |
85 | - if (@unlink($this->sftp_url($file)) === false) |
|
85 | + if (@unlink($this->sftp_url($file)) === FALSE) |
|
86 | 86 | { |
87 | 87 | $this->set_error($this->get_error_message()); |
88 | 88 | $this->set_exitstatus(1); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $files = []; |
129 | 129 | if ($handle = @opendir($this->sftp_url($path))) |
130 | 130 | { |
131 | - while (($file = @readdir($handle)) !== false) |
|
131 | + while (($file = @readdir($handle)) !== FALSE) |
|
132 | 132 | { |
133 | 133 | if ($file != '.' && $file != '..') |
134 | 134 | { |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $files['directories'][] = $filename; |
139 | 139 | } |
140 | 140 | |
141 | - if ($this->is_dir($filename) === false) |
|
141 | + if ($this->is_dir($filename) === FALSE) |
|
142 | 142 | { |
143 | 143 | $files['files'][] = $filename; |
144 | 144 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | final public function glob($directory, $pattern = '') |
161 | 161 | { |
162 | - if ($this->is_dir($directory) == false) |
|
162 | + if ($this->is_dir($directory) == FALSE) |
|
163 | 163 | { |
164 | 164 | $this->set_error($this->get_error_message()); |
165 | 165 | $this->set_exitstatus(1); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | } |
168 | 168 | |
169 | 169 | $handle = opendir($this->sftp_url($directory)); |
170 | - while (($file = readdir($handle)) !== false) |
|
170 | + while (($file = readdir($handle)) !== FALSE) |
|
171 | 171 | { |
172 | 172 | $files[] = preg_grep('/(^.*' . $pattern . '.*$)/', explode(PHP_EOL, $file)); |
173 | 173 | } |
@@ -200,12 +200,12 @@ discard block |
||
200 | 200 | * @param int $chgrp change gid for directory |
201 | 201 | * @return bool |
202 | 202 | */ |
203 | - final public function mkdir($directories, $mode = 0777, $recursive = false) |
|
203 | + final public function mkdir($directories, $mode = 0777, $recursive = FALSE) |
|
204 | 204 | { |
205 | 205 | $directories = !is_array($directories) ? [$directories] : $directories; |
206 | 206 | foreach ($directories as $directory) |
207 | 207 | { |
208 | - if (@mkdir($this->sftp_url($directory), $mode, $recursive) === false) |
|
208 | + if (@mkdir($this->sftp_url($directory), $mode, $recursive) === FALSE) |
|
209 | 209 | { |
210 | 210 | $this->set_error($this->get_error_message()); |
211 | 211 | $this->set_exitstatus(1); |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | final public function rename($oldfile, $newfile) |
227 | 227 | { |
228 | - if ($this->is_file($oldfile) === false) |
|
228 | + if ($this->is_file($oldfile) === FALSE) |
|
229 | 229 | { |
230 | 230 | $this->set_error('Local file ' . $oldfile . ' does not exist.'); |
231 | 231 | $this->set_exitstatus(1); |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | $files = array_key_exists('files', $stdout) ? $stdout['files'] : []; |
266 | 266 | if (count($files) == 0) |
267 | 267 | { |
268 | - if (@rmdir($this->sftp_url($directory)) === false) |
|
268 | + if (@rmdir($this->sftp_url($directory)) === FALSE) |
|
269 | 269 | { |
270 | 270 | $this->set_error($this->get_error_message()); |
271 | 271 | $this->set_exitstatus(1); |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | { |
343 | 343 | $statinfo = ssh2_sftp_stat($this->sftp, $path); |
344 | 344 | |
345 | - if ($statinfo === false) |
|
345 | + if ($statinfo === FALSE) |
|
346 | 346 | { |
347 | 347 | $this->set_error($this->get_error_message()); |
348 | 348 | $this->set_exitstatus(0); |
@@ -122,19 +122,19 @@ discard block |
||
122 | 122 | switch ($this->get_mode()) |
123 | 123 | { |
124 | 124 | case 'execute.wait': |
125 | - $stream = $this->get_stream($command, $terminal); |
|
125 | + $stream = $this->get_stream($command, $terminal); |
|
126 | 126 | $this->exec_wait($stream); |
127 | 127 | break; |
128 | 128 | |
129 | 129 | case 'execute.realtime': |
130 | - $command .= ' 2>&1'; |
|
131 | - $stream = $this->get_stream($command, $terminal); |
|
130 | + $command .= ' 2>&1'; |
|
131 | + $stream = $this->get_stream($command, $terminal); |
|
132 | 132 | $this->exec_realtime($stream); |
133 | 133 | break; |
134 | 134 | |
135 | 135 | case 'execute.file': |
136 | - $command .= ' 2>&1'; |
|
137 | - $stream = $this->get_stream($command, $terminal); |
|
136 | + $command .= ' 2>&1'; |
|
137 | + $stream = $this->get_stream($command, $terminal); |
|
138 | 138 | $this->exec_file($stream); |
139 | 139 | break; |
140 | 140 | |
@@ -159,19 +159,19 @@ discard block |
||
159 | 159 | |
160 | 160 | $command .= '; echo "RETURN_CODE:[$?]"'; |
161 | 161 | $stream = @ssh2_exec( |
162 | - $this->connection, |
|
163 | - $command, |
|
164 | - $terminal->get_pty(), |
|
165 | - $terminal->get_env(), |
|
166 | - $terminal->get_width(), |
|
167 | - $terminal->get_height() |
|
168 | - ); |
|
162 | + $this->connection, |
|
163 | + $command, |
|
164 | + $terminal->get_pty(), |
|
165 | + $terminal->get_env(), |
|
166 | + $terminal->get_width(), |
|
167 | + $terminal->get_height() |
|
168 | + ); |
|
169 | 169 | |
170 | - if ($stream === false) |
|
170 | + if ($stream === false) |
|
171 | 171 | { |
172 | 172 | throw new \RuntimeException($this->get_error_message()); |
173 | 173 | } |
174 | - stream_set_blocking($stream, true); |
|
174 | + stream_set_blocking($stream, true); |
|
175 | 175 | return $stream; |
176 | 176 | } |
177 | 177 | |
@@ -217,13 +217,13 @@ discard block |
||
217 | 217 | */ |
218 | 218 | final private function exec_realtime($stream) |
219 | 219 | { |
220 | - while ($buffer = fgets($stream)) |
|
220 | + while ($buffer = fgets($stream)) |
|
221 | 221 | { |
222 | 222 | if (!preg_match('/RETURN_CODE:\[([0-9]+)\]/', $buffer, $retval)) |
223 | 223 | { |
224 | - print $buffer; |
|
224 | + print $buffer; |
|
225 | 225 | } |
226 | - flush(); |
|
226 | + flush(); |
|
227 | 227 | } |
228 | 228 | fclose($stream); |
229 | 229 | $this->set_exitstatus($retval[1]); |
@@ -218,7 +218,7 @@ |
||
218 | 218 | final private function exec_realtime($stream) |
219 | 219 | { |
220 | 220 | while ($buffer = fgets($stream)) |
221 | - { |
|
221 | + { |
|
222 | 222 | if (!preg_match('/RETURN_CODE:\[([0-9]+)\]/', $buffer, $retval)) |
223 | 223 | { |
224 | 224 | print $buffer; |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @var string |
44 | 44 | */ |
45 | - public $mode = null; |
|
45 | + public $mode = NULL; |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Filename path. |
49 | 49 | * |
50 | 50 | * @var string |
51 | 51 | */ |
52 | - public $filename = null; |
|
52 | + public $filename = NULL; |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Constructor. |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | final public function get_mode() |
94 | 94 | { |
95 | - return ($this->mode === null) ? self::WAIT : $this->mode; |
|
95 | + return ($this->mode === NULL) ? self::WAIT : $this->mode; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @param instance $terminal Terminal instance |
113 | 113 | * @return void |
114 | 114 | */ |
115 | - final public function exec($command, Terminal $terminal = null) |
|
115 | + final public function exec($command, Terminal $terminal = NULL) |
|
116 | 116 | { |
117 | 117 | if (!$terminal instanceof Terminal) |
118 | 118 | { |
@@ -167,11 +167,11 @@ discard block |
||
167 | 167 | $terminal->get_height() |
168 | 168 | ); |
169 | 169 | |
170 | - if ($stream === false) |
|
170 | + if ($stream === FALSE) |
|
171 | 171 | { |
172 | 172 | throw new \RuntimeException($this->get_error_message()); |
173 | 173 | } |
174 | - stream_set_blocking($stream, true); |
|
174 | + stream_set_blocking($stream, TRUE); |
|
175 | 175 | return $stream; |
176 | 176 | } |
177 | 177 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | do |
192 | 192 | { |
193 | 193 | sleep(1); |
194 | - if ($out === false || $err === false) |
|
194 | + if ($out === FALSE || $err === FALSE) |
|
195 | 195 | { |
196 | 196 | $stderr .= 'STDOUT and/or STDERR stream(s) closed unexpectedly.'; |
197 | 197 | return 1; |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | */ |
238 | 238 | final private function exec_file($stream) |
239 | 239 | { |
240 | - if ($this->get_filename() === null) |
|
240 | + if ($this->get_filename() === NULL) |
|
241 | 241 | { |
242 | 242 | throw new \RuntimeException('A valid filename path must be provided.'); |
243 | 243 | } |