Skip to content

Commit 207d6e8

Browse files
committed
Use modern array syntax
1 parent 228d9d7 commit 207d6e8

File tree

14 files changed

+108
-108
lines changed

14 files changed

+108
-108
lines changed

src/PhpConfig.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class PhpConfig
2626
public function useOriginal()
2727
{
2828
$this->getDataAndReset();
29-
return array();
29+
return [];
3030
}
3131

3232
/**
@@ -38,10 +38,10 @@ public function useStandard()
3838
{
3939
$data = $this->getDataAndReset();
4040
if ($data !== null) {
41-
return array('-n', '-c', $data['tmpIni']);
41+
return ['-n', '-c', $data['tmpIni']];
4242
}
4343

44-
return array();
44+
return [];
4545
}
4646

4747
/**
@@ -57,7 +57,7 @@ public function usePersistent()
5757
$this->updateEnv('PHP_INI_SCAN_DIR', '');
5858
}
5959

60-
return array();
60+
return [];
6161
}
6262

6363
/**

src/Status.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ public function setLogger(LoggerInterface $logger)
8686
public function report($op, $data)
8787
{
8888
if ($this->logger !== null || $this->debug) {
89-
$callable = array($this, 'report'.$op);
89+
$callable = [$this, 'report'.$op];
9090

9191
if (!is_callable($callable)) {
9292
throw new \InvalidArgumentException('Unknown op handler: '.$op);
9393
}
9494

95-
$params = $data !== null ? $data : array();
96-
call_user_func_array($callable, array($params));
95+
$params = $data !== null ? [$data] : [];
96+
call_user_func_array($callable, $params);
9797
}
9898
}
9999

src/XdebugHandler.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public static function getAllIniFiles()
213213
}
214214
}
215215

216-
$paths = array((string) php_ini_loaded_file());
216+
$paths = [(string) php_ini_loaded_file()];
217217
$scanned = php_ini_scanned_files();
218218

219219
if ($scanned !== false) {
@@ -241,14 +241,14 @@ public static function getRestartSettings()
241241
return null;
242242
}
243243

244-
return array(
244+
return [
245245
'tmpIni' => $envArgs[0],
246246
'scannedInis' => (bool) $envArgs[1],
247247
'scanDir' => '*' === $envArgs[2] ? false : $envArgs[2],
248248
'phprc' => '*' === $envArgs[3] ? false : $envArgs[3],
249249
'inis' => explode(PATH_SEPARATOR, $envArgs[4]),
250250
'skipped' => $envArgs[5],
251-
);
251+
];
252252
}
253253

254254
/**
@@ -326,7 +326,7 @@ private function doRestart(array $command)
326326
}
327327
}
328328

329-
$process = proc_open($cmd, array(), $pipes);
329+
$process = proc_open($cmd, [], $pipes);
330330
if (is_resource($process)) {
331331
$exitCode = proc_close($process);
332332
}
@@ -447,15 +447,15 @@ private function writeTmpIni(array $iniFiles, $tmpDir, &$error)
447447
*/
448448
private function getCommand()
449449
{
450-
$php = array(PHP_BINARY);
450+
$php = [PHP_BINARY];
451451
$args = array_slice($_SERVER['argv'], 1);
452452

453453
if (!$this->persistent) {
454454
// Use command-line options
455455
array_push($php, '-n', '-c', $this->tmpIni);
456456
}
457457

458-
return array_merge($php, array($this->script), $args);
458+
return array_merge($php, [$this->script], $args);
459459
}
460460

461461
/**
@@ -486,13 +486,13 @@ private function setEnvironment($scannedInis, array $iniFiles)
486486
}
487487

488488
// Flag restarted process and save values for it to use
489-
$envArgs = array(
489+
$envArgs = [
490490
self::RESTART_ID,
491491
$this->loaded,
492492
(int) $scannedInis,
493493
false === $scanDir ? '*' : $scanDir,
494494
false === $phprc ? '*' : $phprc,
495-
);
495+
];
496496

497497
return putenv($this->envAllowXdebug.'='.implode('|', $envArgs));
498498
}
@@ -575,14 +575,14 @@ private function checkMainScript()
575575
*/
576576
private function setEnvRestartSettings($envArgs)
577577
{
578-
$settings = array(
578+
$settings = [
579579
php_ini_loaded_file(),
580580
$envArgs[2],
581581
$envArgs[3],
582582
$envArgs[4],
583583
getenv($this->envOriginalInis),
584584
self::$skipped,
585-
);
585+
];
586586

587587
Process::setEnv(self::RESTART_SETTINGS, implode('|', $settings));
588588
}

tests/ClassTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function testConstructorThrowsOnInvalidEnvPrefix()
3333
{
3434
$this->expectException('RuntimeException');
3535
/** @phpstan-ignore-next-line */
36-
new XdebugHandler(array('name'));
36+
new XdebugHandler(['name']);
3737
}
3838

3939
/**
@@ -47,7 +47,7 @@ public function testSettersAreFluent($setter, $value)
4747
{
4848
$xdebug = new XdebugHandler('myapp');
4949

50-
$params = null !== $value ? array($value) : array();
50+
$params = null !== $value ? [$value] : [];
5151
$result = BaseTestCase::safeCall($xdebug, $setter, $params, $this);
5252
self::assertInstanceOf(get_class($xdebug), $result);
5353
}
@@ -58,11 +58,11 @@ public function testSettersAreFluent($setter, $value)
5858
public function setterProvider()
5959
{
6060
// $setter, $value
61-
return array(
62-
'setLogger' => array('setLogger', new Logger()),
63-
'setMainScript' => array('setMainScript', '--'),
64-
'setPersistent' => array('setPersistent', null),
65-
);
61+
return [
62+
'setLogger' => ['setLogger', new Logger()],
63+
'setMainScript' => ['setMainScript', '--'],
64+
'setPersistent' => ['setPersistent', null],
65+
];
6666
}
6767

6868
/**
@@ -88,9 +88,9 @@ public function testNoTypeHintingOnMethod($method)
8888
*/
8989
public function methodProvider()
9090
{
91-
return array(
92-
array('requiresRestart'),
93-
array('restart'),
94-
);
91+
return [
92+
['requiresRestart'],
93+
['restart'],
94+
];
9595
}
9696
}

tests/EnvironmentTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ public function testEnvAllowBeforeRestart($iniFunc, $scanDir, $phprc)
3939

4040
PartialMock::createAndCheck($loaded);
4141

42-
$args = array(
42+
$args = [
4343
PartialMock::RESTART_ID,
4444
PartialMock::TEST_VERSION,
4545
$ini->hasScannedInis() ? '1' : '0',
4646
false !== $scanDir ? $scanDir : '*',
4747
false !== $phprc ? $phprc : '*',
48-
);
48+
];
4949

5050
$expected = implode('|', $args);
5151
self::assertSame($expected, getenv(PartialMock::ALLOW_XDEBUG));
@@ -77,7 +77,7 @@ public function testEnvironmentBeforeRestart($iniFunc, $scanDir, $phprc, $standa
7777
$ini = EnvHelper::setInis($iniFunc, $scanDir, $phprc);
7878
$loaded = true;
7979

80-
$settings = $standard ? array() : array('setPersistent' => array());
80+
$settings = $standard ? [] : ['setPersistent' => []];
8181

8282
$xdebug = PartialMock::createAndCheck($loaded, null, $settings);
8383

@@ -99,7 +99,7 @@ public function environmentProvider()
9999
{
100100
// $iniFunc, $scanDir, $phprc, $standard (added below)
101101
$data = EnvHelper::dataProvider();
102-
$result = array();
102+
$result = [];
103103

104104
foreach ($data as $test => $params) {
105105
$params[3] = true;

tests/Helpers/BaseTestCase.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ abstract class BaseTestCase extends TestCase
2727
* @var array
2828
* @phpstan-var array<string, string|false>
2929
*/
30-
private static $env = array();
30+
private static $env = [];
3131

3232
/** @var string[] */
33-
private static $argv = array();
33+
private static $argv = [];
3434

3535
/** @var string[] */
36-
private static $names = array(
36+
private static $names = [
3737
CoreMock::ALLOW_XDEBUG,
3838
CoreMock::ORIGINAL_INIS,
3939
'PHP_INI_SCAN_DIR',
4040
'PHPRC',
4141
XdebugHandler::RESTART_SETTINGS,
42-
);
42+
];
4343

4444
/**
4545
* Saves the current environment and argv state
@@ -90,8 +90,8 @@ public static function afterClass()
9090
*/
9191
public static function safeCall($instance, $method, array $params = null, $self = null)
9292
{
93-
$callable = array($instance, $method);
94-
$params = $params !== null ? $params : array();
93+
$callable = [$instance, $method];
94+
$params = $params !== null ? $params : [];
9595

9696
if (is_callable($callable)) {
9797
return call_user_func_array($callable, $params);

tests/Helpers/EnvHelper.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class EnvHelper
3232
*/
3333
public static function setInis($iniFunc, $scanDir, $phprc)
3434
{
35-
$ini = new IniHelper(array($scanDir, $phprc));
35+
$ini = new IniHelper([$scanDir, $phprc]);
3636
BaseTestCase::safeCall($ini, $iniFunc);
3737

3838
return $ini;
@@ -49,11 +49,11 @@ public static function dataProvider()
4949
$scanDir = $ini->getScanDir();
5050

5151
// $iniFunc, $scanDir, $phprc
52-
return array(
53-
'loaded false myini' => array('setLoadedIni', false, '/my.ini'),
54-
'loaded empty false' => array('setLoadedIni', '', false),
55-
'scanned false file' => array('setScannedInis', false, $loaded),
56-
'scanned dir false' => array('setScannedInis', $scanDir, false),
57-
);
52+
return [
53+
'loaded false myini' => ['setLoadedIni', false, '/my.ini'],
54+
'loaded empty false' => ['setLoadedIni', '', false],
55+
'scanned false file' => ['setScannedInis', false, $loaded],
56+
'scanned dir false' => ['setScannedInis', $scanDir, false],
57+
];
5858
}
5959
}

tests/Helpers/IniHelper.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function __construct($envOptions = null)
5555
public function setNoInis()
5656
{
5757
// Must have at least one entry
58-
$this->files = array('');
58+
$this->files = [''];
5959
$this->setEnvironment();
6060
}
6161

@@ -64,9 +64,9 @@ public function setNoInis()
6464
*/
6565
public function setLoadedIni()
6666
{
67-
$this->files = array(
67+
$this->files = [
6868
$this->loadedIni,
69-
);
69+
];
7070

7171
$this->setEnvironment();
7272
}
@@ -76,12 +76,12 @@ public function setLoadedIni()
7676
*/
7777
public function setScannedInis()
7878
{
79-
$this->files = array(
79+
$this->files = [
8080
'',
8181
$this->scanDir.DIRECTORY_SEPARATOR.'scan-one.ini',
8282
$this->scanDir.DIRECTORY_SEPARATOR.'scan-two.ini',
8383
$this->scanDir.DIRECTORY_SEPARATOR.'scan-empty.ini',
84-
);
84+
];
8585

8686
$this->setEnvironment();
8787
}
@@ -91,12 +91,12 @@ public function setScannedInis()
9191
*/
9292
public function setAllInis()
9393
{
94-
$this->files = array(
94+
$this->files = [
9595
$this->loadedIni,
9696
$this->scanDir.DIRECTORY_SEPARATOR.'scan-one.ini',
9797
$this->scanDir.DIRECTORY_SEPARATOR.'scan-two.ini',
9898
$this->scanDir.DIRECTORY_SEPARATOR.'scan-empty.ini',
99-
);
99+
];
100100

101101
$this->setEnvironment();
102102
}
@@ -106,12 +106,12 @@ public function setAllInis()
106106
*/
107107
public function setInaccessibleIni()
108108
{
109-
$this->files = array(
109+
$this->files = [
110110
'',
111111
$this->scanDir.DIRECTORY_SEPARATOR.'scan-one.ini',
112112
$this->scanDir.DIRECTORY_SEPARATOR.'scan-two.ini',
113113
$this->scanDir.DIRECTORY_SEPARATOR.'scan-missing.ini',
114-
);
114+
];
115115

116116
$this->setEnvironment();
117117
}
@@ -122,11 +122,11 @@ public function setInaccessibleIni()
122122
*/
123123
public function setSectionInis($sectionName)
124124
{
125-
$this->files = array(
125+
$this->files = [
126126
$this->loadedIni,
127127
$this->scanDir.DIRECTORY_SEPARATOR.'section-first.ini',
128128
$this->scanDir.DIRECTORY_SEPARATOR.'section-'.$sectionName.'.ini',
129-
);
129+
];
130130

131131
$this->setEnvironment();
132132
}

tests/Helpers/Logger.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
class Logger extends AbstractLogger
2020
{
2121
/** @var string[]*/
22-
protected $output = array();
22+
protected $output = [];
2323

2424
/**
2525
* @inheritdoc
2626
* @phpstan-param mixed[] $context
2727
*/
28-
public function log($level, $message, array $context = array()): void
28+
public function log($level, $message, array $context = []): void
2929
{
3030
$this->output[] = $message;
3131
}

0 commit comments

Comments
 (0)