Skip to content

Commit 20123ec

Browse files
committed
fixed CS
1 parent 13b9e99 commit 20123ec

File tree

5 files changed

+123
-123
lines changed

5 files changed

+123
-123
lines changed

PhpExecutableFinder.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function find($includeArgs = true)
4747
$args = $includeArgs && $args ? ' '.implode(' ', $args) : '';
4848

4949
// PHP_BINARY return the current sapi executable
50-
if (PHP_BINARY && \in_array(\PHP_SAPI, array('cli', 'cli-server', 'phpdbg'), true)) {
50+
if (PHP_BINARY && \in_array(\PHP_SAPI, ['cli', 'cli-server', 'phpdbg'], true)) {
5151
return PHP_BINARY.$args;
5252
}
5353

@@ -69,7 +69,7 @@ public function find($includeArgs = true)
6969
return $php;
7070
}
7171

72-
$dirs = array(PHP_BINDIR);
72+
$dirs = [PHP_BINDIR];
7373
if ('\\' === \DIRECTORY_SEPARATOR) {
7474
$dirs[] = 'C:\xampp\php\\';
7575
}
@@ -84,7 +84,7 @@ public function find($includeArgs = true)
8484
*/
8585
public function findArguments()
8686
{
87-
$arguments = array();
87+
$arguments = [];
8888
if ('phpdbg' === \PHP_SAPI) {
8989
$arguments[] = '-qrr';
9090
}

PhpProcess.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(string $script, string $cwd = null, array $env = nul
3636
if (false === $php = $executableFinder->find(false)) {
3737
$php = null;
3838
} else {
39-
$php = array_merge(array($php), $executableFinder->findArguments());
39+
$php = array_merge([$php], $executableFinder->findArguments());
4040
}
4141
if ('phpdbg' === \PHP_SAPI) {
4242
$file = tempnam(sys_get_temp_dir(), 'dbg');
@@ -60,7 +60,7 @@ public function setPhpBinary($php)
6060
/**
6161
* {@inheritdoc}
6262
*/
63-
public function start(callable $callback = null, array $env = array())
63+
public function start(callable $callback = null, array $env = [])
6464
{
6565
if (null === $this->getCommandLine()) {
6666
throw new RuntimeException('Unable to find the PHP executable.');

Process.php

+20-20
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Process implements \IteratorAggregate
6060
private $timeout;
6161
private $idleTimeout;
6262
private $exitcode;
63-
private $fallbackStatus = array();
63+
private $fallbackStatus = [];
6464
private $processInformation;
6565
private $outputDisabled = false;
6666
private $stdout;
@@ -85,7 +85,7 @@ class Process implements \IteratorAggregate
8585
*
8686
* User-defined errors must use exit codes in the 64-113 range.
8787
*/
88-
public static $exitCodes = array(
88+
public static $exitCodes = [
8989
0 => 'OK',
9090
1 => 'General error',
9191
2 => 'Misuse of shell builtins',
@@ -126,7 +126,7 @@ class Process implements \IteratorAggregate
126126
157 => 'Pollable event',
127127
// 158 - not defined
128128
159 => 'Bad syscall',
129-
);
129+
];
130130

131131
/**
132132
* @param string|array $commandline The command line to run
@@ -195,7 +195,7 @@ public function __clone()
195195
*
196196
* @final
197197
*/
198-
public function run(callable $callback = null, array $env = array()): int
198+
public function run(callable $callback = null, array $env = []): int
199199
{
200200
$this->start($callback, $env);
201201

@@ -217,7 +217,7 @@ public function run(callable $callback = null, array $env = array()): int
217217
*
218218
* @final
219219
*/
220-
public function mustRun(callable $callback = null, array $env = array())
220+
public function mustRun(callable $callback = null, array $env = [])
221221
{
222222
if (0 !== $this->run($callback, $env)) {
223223
throw new ProcessFailedException($this);
@@ -246,7 +246,7 @@ public function mustRun(callable $callback = null, array $env = array())
246246
* @throws RuntimeException When process is already running
247247
* @throws LogicException In case a callback is provided and output has been disabled
248248
*/
249-
public function start(callable $callback = null, array $env = array())
249+
public function start(callable $callback = null, array $env = [])
250250
{
251251
if ($this->isRunning()) {
252252
throw new RuntimeException('Process is already running');
@@ -259,7 +259,7 @@ public function start(callable $callback = null, array $env = array())
259259
$descriptors = $this->getDescriptors();
260260

261261
if (\is_array($commandline = $this->commandline)) {
262-
$commandline = implode(' ', array_map(array($this, 'escapeArgument'), $commandline));
262+
$commandline = implode(' ', array_map([$this, 'escapeArgument'], $commandline));
263263

264264
if ('\\' !== \DIRECTORY_SEPARATOR) {
265265
// 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())
272272
}
273273
$env += $this->getDefaultEnv();
274274

275-
$options = array('suppress_errors' => true);
275+
$options = ['suppress_errors' => true];
276276

277277
if ('\\' === \DIRECTORY_SEPARATOR) {
278278
$options['bypass_shell'] = true;
279279
$commandline = $this->prepareWindowsCommandLine($commandline, $env);
280280
} elseif (!$this->useFileHandles && $this->isSigchildEnabled()) {
281281
// 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'];
283283

284284
// See https://unix.stackexchange.com/questions/71205/background-process-pipe-input
285285
$commandline = '{ ('.$commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
@@ -290,7 +290,7 @@ public function start(callable $callback = null, array $env = array())
290290
$ptsWorkaround = fopen(__FILE__, 'r');
291291
}
292292

293-
$envPairs = array();
293+
$envPairs = [];
294294
foreach ($env as $k => $v) {
295295
if (false !== $v) {
296296
$envPairs[] = $k.'='.$v;
@@ -338,7 +338,7 @@ public function start(callable $callback = null, array $env = array())
338338
*
339339
* @final
340340
*/
341-
public function restart(callable $callback = null, array $env = array())
341+
public function restart(callable $callback = null, array $env = [])
342342
{
343343
if ($this->isRunning()) {
344344
throw new RuntimeException('Process is already running');
@@ -883,7 +883,7 @@ public function addErrorOutput(string $line)
883883
*/
884884
public function getCommandLine()
885885
{
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;
887887
}
888888

889889
/**
@@ -1169,7 +1169,7 @@ public static function isTtySupported(): bool
11691169
static $isTtySupported;
11701170

11711171
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);
11731173
}
11741174

11751175
return $isTtySupported;
@@ -1192,7 +1192,7 @@ public static function isPtySupported()
11921192
return $result = false;
11931193
}
11941194

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);
11961196
}
11971197

11981198
/**
@@ -1390,7 +1390,7 @@ private function resetProcessData()
13901390
$this->starttime = null;
13911391
$this->callback = null;
13921392
$this->exitcode = null;
1393-
$this->fallbackStatus = array();
1393+
$this->fallbackStatus = [];
13941394
$this->processInformation = null;
13951395
$this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b');
13961396
$this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b');
@@ -1437,7 +1437,7 @@ private function doSignal(int $signal, bool $throwException): bool
14371437
$ok = @proc_terminate($this->process, $signal);
14381438
} elseif (\function_exists('posix_kill')) {
14391439
$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)) {
14411441
$ok = false === fgets($pipes[2]);
14421442
}
14431443
if (!$ok) {
@@ -1461,7 +1461,7 @@ private function prepareWindowsCommandLine(string $cmd, array &$env)
14611461
{
14621462
$uid = uniqid('', true);
14631463
$varCount = 0;
1464-
$varCache = array();
1464+
$varCache = [];
14651465
$cmd = preg_replace_callback(
14661466
'/"(?:(
14671467
[^"%!^]*+
@@ -1484,7 +1484,7 @@ function ($m) use (&$env, &$varCache, &$varCount, $uid) {
14841484
return '"'.$value.'"';
14851485
}
14861486

1487-
$value = str_replace(array('!LF!', '"^!"', '"^%"', '"^^"', '""'), array("\n", '!', '%', '^', '"'), $value);
1487+
$value = str_replace(['!LF!', '"^!"', '"^%"', '"^^"', '""'], ["\n", '!', '%', '^', '"'], $value);
14881488
$value = '"'.preg_replace('/(\\\\*)"/', '$1$1\\"', $value).'"';
14891489
$var = $uid.++$varCount;
14901490

@@ -1546,12 +1546,12 @@ private function escapeArgument(?string $argument): string
15461546
}
15471547
$argument = preg_replace('/(\\\\+)$/', '$1$1', $argument);
15481548

1549-
return '"'.str_replace(array('"', '^', '%', '!', "\n"), array('""', '"^^"', '"^%"', '"^!"', '!LF!'), $argument).'"';
1549+
return '"'.str_replace(['"', '^', '%', '!', "\n"], ['""', '"^^"', '"^%"', '"^!"', '!LF!'], $argument).'"';
15501550
}
15511551

15521552
private function getDefaultEnv()
15531553
{
1554-
$env = array();
1554+
$env = [];
15551555

15561556
foreach ($_SERVER as $k => $v) {
15571557
if (\is_string($v) && false !== $v = getenv($k)) {

Tests/PhpExecutableFinderTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ public function testFindArguments()
4141
$f = new PhpExecutableFinder();
4242

4343
if ('phpdbg' === \PHP_SAPI) {
44-
$this->assertEquals($f->findArguments(), array('-qrr'), '::findArguments() returns phpdbg arguments');
44+
$this->assertEquals($f->findArguments(), ['-qrr'], '::findArguments() returns phpdbg arguments');
4545
} else {
46-
$this->assertEquals($f->findArguments(), array(), '::findArguments() returns no arguments');
46+
$this->assertEquals($f->findArguments(), [], '::findArguments() returns no arguments');
4747
}
4848
}
4949
}

0 commit comments

Comments
 (0)