@@ -60,7 +60,7 @@ class Process implements \IteratorAggregate
60
60
private $ timeout ;
61
61
private $ idleTimeout ;
62
62
private $ exitcode ;
63
- private $ fallbackStatus = array () ;
63
+ private $ fallbackStatus = [] ;
64
64
private $ processInformation ;
65
65
private $ outputDisabled = false ;
66
66
private $ stdout ;
@@ -85,7 +85,7 @@ class Process implements \IteratorAggregate
85
85
*
86
86
* User-defined errors must use exit codes in the 64-113 range.
87
87
*/
88
- public static $ exitCodes = array (
88
+ public static $ exitCodes = [
89
89
0 => 'OK ' ,
90
90
1 => 'General error ' ,
91
91
2 => 'Misuse of shell builtins ' ,
@@ -126,7 +126,7 @@ class Process implements \IteratorAggregate
126
126
157 => 'Pollable event ' ,
127
127
// 158 - not defined
128
128
159 => 'Bad syscall ' ,
129
- ) ;
129
+ ] ;
130
130
131
131
/**
132
132
* @param string|array $commandline The command line to run
@@ -195,7 +195,7 @@ public function __clone()
195
195
*
196
196
* @final
197
197
*/
198
- public function run (callable $ callback = null , array $ env = array () ): int
198
+ public function run (callable $ callback = null , array $ env = [] ): int
199
199
{
200
200
$ this ->start ($ callback , $ env );
201
201
@@ -217,7 +217,7 @@ public function run(callable $callback = null, array $env = array()): int
217
217
*
218
218
* @final
219
219
*/
220
- public function mustRun (callable $ callback = null , array $ env = array () )
220
+ public function mustRun (callable $ callback = null , array $ env = [] )
221
221
{
222
222
if (0 !== $ this ->run ($ callback , $ env )) {
223
223
throw new ProcessFailedException ($ this );
@@ -246,7 +246,7 @@ public function mustRun(callable $callback = null, array $env = array())
246
246
* @throws RuntimeException When process is already running
247
247
* @throws LogicException In case a callback is provided and output has been disabled
248
248
*/
249
- public function start (callable $ callback = null , array $ env = array () )
249
+ public function start (callable $ callback = null , array $ env = [] )
250
250
{
251
251
if ($ this ->isRunning ()) {
252
252
throw new RuntimeException ('Process is already running ' );
@@ -259,7 +259,7 @@ public function start(callable $callback = null, array $env = array())
259
259
$ descriptors = $ this ->getDescriptors ();
260
260
261
261
if (\is_array ($ commandline = $ this ->commandline )) {
262
- $ commandline = implode (' ' , array_map (array ( $ this , 'escapeArgument ' ) , $ commandline ));
262
+ $ commandline = implode (' ' , array_map ([ $ this , 'escapeArgument ' ] , $ commandline ));
263
263
264
264
if ('\\' !== \DIRECTORY_SEPARATOR ) {
265
265
// exec is mandatory to deal with sending a signal to the process
@@ -272,14 +272,14 @@ public function start(callable $callback = null, array $env = array())
272
272
}
273
273
$ env += $ this ->getDefaultEnv ();
274
274
275
- $ options = array ( 'suppress_errors ' => true ) ;
275
+ $ options = [ 'suppress_errors ' => true ] ;
276
276
277
277
if ('\\' === \DIRECTORY_SEPARATOR ) {
278
278
$ options ['bypass_shell ' ] = true ;
279
279
$ commandline = $ this ->prepareWindowsCommandLine ($ commandline , $ env );
280
280
} elseif (!$ this ->useFileHandles && $ this ->isSigchildEnabled ()) {
281
281
// last exit code is output on the fourth pipe and caught to work around --enable-sigchild
282
- $ descriptors [3 ] = array ( 'pipe ' , 'w ' ) ;
282
+ $ descriptors [3 ] = [ 'pipe ' , 'w ' ] ;
283
283
284
284
// See https://unix.stackexchange.com/questions/71205/background-process-pipe-input
285
285
$ commandline = '{ ( ' .$ commandline .') <&3 3<&- 3>/dev/null & } 3<&0; ' ;
@@ -290,7 +290,7 @@ public function start(callable $callback = null, array $env = array())
290
290
$ ptsWorkaround = fopen (__FILE__ , 'r ' );
291
291
}
292
292
293
- $ envPairs = array () ;
293
+ $ envPairs = [] ;
294
294
foreach ($ env as $ k => $ v ) {
295
295
if (false !== $ v ) {
296
296
$ envPairs [] = $ k .'= ' .$ v ;
@@ -338,7 +338,7 @@ public function start(callable $callback = null, array $env = array())
338
338
*
339
339
* @final
340
340
*/
341
- public function restart (callable $ callback = null , array $ env = array () )
341
+ public function restart (callable $ callback = null , array $ env = [] )
342
342
{
343
343
if ($ this ->isRunning ()) {
344
344
throw new RuntimeException ('Process is already running ' );
@@ -883,7 +883,7 @@ public function addErrorOutput(string $line)
883
883
*/
884
884
public function getCommandLine ()
885
885
{
886
- return \is_array ($ this ->commandline ) ? implode (' ' , array_map (array ( $ this , 'escapeArgument ' ) , $ this ->commandline )) : $ this ->commandline ;
886
+ return \is_array ($ this ->commandline ) ? implode (' ' , array_map ([ $ this , 'escapeArgument ' ] , $ this ->commandline )) : $ this ->commandline ;
887
887
}
888
888
889
889
/**
@@ -1169,7 +1169,7 @@ public static function isTtySupported(): bool
1169
1169
static $ isTtySupported ;
1170
1170
1171
1171
if (null === $ isTtySupported ) {
1172
- $ isTtySupported = (bool ) @proc_open ('echo 1 >/dev/null ' , array ( array ( 'file ' , '/dev/tty ' , 'r ' ), array ( 'file ' , '/dev/tty ' , 'w ' ), array ( 'file ' , '/dev/tty ' , 'w ' )) , $ pipes );
1172
+ $ isTtySupported = (bool ) @proc_open ('echo 1 >/dev/null ' , [[ 'file ' , '/dev/tty ' , 'r ' ], [ 'file ' , '/dev/tty ' , 'w ' ], [ 'file ' , '/dev/tty ' , 'w ' ]] , $ pipes );
1173
1173
}
1174
1174
1175
1175
return $ isTtySupported ;
@@ -1192,7 +1192,7 @@ public static function isPtySupported()
1192
1192
return $ result = false ;
1193
1193
}
1194
1194
1195
- return $ result = (bool ) @proc_open ('echo 1 >/dev/null ' , array ( array ( 'pty ' ), array ( 'pty ' ), array ( 'pty ' )) , $ pipes );
1195
+ return $ result = (bool ) @proc_open ('echo 1 >/dev/null ' , [[ 'pty ' ], [ 'pty ' ], [ 'pty ' ]] , $ pipes );
1196
1196
}
1197
1197
1198
1198
/**
@@ -1390,7 +1390,7 @@ private function resetProcessData()
1390
1390
$ this ->starttime = null ;
1391
1391
$ this ->callback = null ;
1392
1392
$ this ->exitcode = null ;
1393
- $ this ->fallbackStatus = array () ;
1393
+ $ this ->fallbackStatus = [] ;
1394
1394
$ this ->processInformation = null ;
1395
1395
$ this ->stdout = fopen ('php://temp/maxmemory: ' .(1024 * 1024 ), 'w+b ' );
1396
1396
$ this ->stderr = fopen ('php://temp/maxmemory: ' .(1024 * 1024 ), 'w+b ' );
@@ -1437,7 +1437,7 @@ private function doSignal(int $signal, bool $throwException): bool
1437
1437
$ ok = @proc_terminate ($ this ->process , $ signal );
1438
1438
} elseif (\function_exists ('posix_kill ' )) {
1439
1439
$ ok = @posix_kill ($ pid , $ signal );
1440
- } elseif ($ ok = proc_open (sprintf ('kill -%d %d ' , $ signal , $ pid ), array ( 2 => array ( 'pipe ' , 'w ' )) , $ pipes )) {
1440
+ } elseif ($ ok = proc_open (sprintf ('kill -%d %d ' , $ signal , $ pid ), [ 2 => [ 'pipe ' , 'w ' ]] , $ pipes )) {
1441
1441
$ ok = false === fgets ($ pipes [2 ]);
1442
1442
}
1443
1443
if (!$ ok ) {
@@ -1461,7 +1461,7 @@ private function prepareWindowsCommandLine(string $cmd, array &$env)
1461
1461
{
1462
1462
$ uid = uniqid ('' , true );
1463
1463
$ varCount = 0 ;
1464
- $ varCache = array () ;
1464
+ $ varCache = [] ;
1465
1465
$ cmd = preg_replace_callback (
1466
1466
'/"(?:(
1467
1467
[^"%!^]*+
@@ -1484,7 +1484,7 @@ function ($m) use (&$env, &$varCache, &$varCount, $uid) {
1484
1484
return '" ' .$ value .'" ' ;
1485
1485
}
1486
1486
1487
- $ value = str_replace (array ( '!LF! ' , '"^!" ' , '"^%" ' , '"^^" ' , '"" ' ), array ( "\n" , '! ' , '% ' , '^ ' , '" ' ) , $ value );
1487
+ $ value = str_replace ([ '!LF! ' , '"^!" ' , '"^%" ' , '"^^" ' , '"" ' ], [ "\n" , '! ' , '% ' , '^ ' , '" ' ] , $ value );
1488
1488
$ value = '" ' .preg_replace ('/( \\\\*)"/ ' , '$1$1 \\" ' , $ value ).'" ' ;
1489
1489
$ var = $ uid .++$ varCount ;
1490
1490
@@ -1546,12 +1546,12 @@ private function escapeArgument(?string $argument): string
1546
1546
}
1547
1547
$ argument = preg_replace ('/( \\\\+)$/ ' , '$1$1 ' , $ argument );
1548
1548
1549
- return '" ' .str_replace (array ( '" ' , '^ ' , '% ' , '! ' , "\n" ), array ( '"" ' , '"^^" ' , '"^%" ' , '"^!" ' , '!LF! ' ) , $ argument ).'" ' ;
1549
+ return '" ' .str_replace ([ '" ' , '^ ' , '% ' , '! ' , "\n" ], [ '"" ' , '"^^" ' , '"^%" ' , '"^!" ' , '!LF! ' ] , $ argument ).'" ' ;
1550
1550
}
1551
1551
1552
1552
private function getDefaultEnv ()
1553
1553
{
1554
- $ env = array () ;
1554
+ $ env = [] ;
1555
1555
1556
1556
foreach ($ _SERVER as $ k => $ v ) {
1557
1557
if (\is_string ($ v ) && false !== $ v = getenv ($ k )) {
0 commit comments