8000 PHPUnit Bridge: Rollback to traditional array syntax. · symfony/symfony@8b330de · GitHub
[go: up one dir, main page]

Skip to content

Commit 8b330de

Browse files
committed
PHPUnit Bridge: Rollback to traditional array syntax.
1 parent 46edcee commit 8b330de

15 files changed

+114
-114
lines changed

src/Symfony/Bridge/PhpUnit/ClockMock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static function register($class)
7373
{
7474
$self = \get_called_class();
7575

76-
$mockedNs = [substr($class, 0, strrpos($class, '\\'))];
76+
$mockedNs = array(substr($class, 0, strrpos($class, '\\')));
7777
if (0 < strpos($class, '\\Tests\\')) {
7878
$ns = str_replace('\\Tests\\', '\\', $class);
7979
$mockedNs[] = substr($ns, 0, strrpos($ns, '\\'));

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,19 @@ public static function register($mode = 0)
9292
return false;
9393
};
9494

95-
$deprecations = [
95+
$deprecations = array(
9696
'unsilencedCount' => 0,
9797
'remainingCount' => 0,
9898
'legacyCount' => 0,
9999
'otherCount' => 0,
100100
'remaining vendorCount' => 0,
101-
'unsilenced' => [],
102-
'remaining' => [],
103-
'legacy' => [],
104-
'other' => [],
105-
'remaining vendor' => [],
106-
];
107-
$deprecationHandler = function ($type, $msg, $file, $line, $context = []) use (&$deprecations, $getMode, $UtilPrefix, $inVendors) {
101+
'unsilenced' => array(),
102+
'remaining' => array(),
103+
'legacy' => array(),
104+
'other' => array(),
105+
'remaining vendor' => array(),
106+
);
107+
$deprecationHandler = function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, $getMode, $UtilPrefix, $inVendors) {
108108
$mode = $getMode();
109109
if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || self::MODE_DISABLED === $mode) {
110110
$ErrorHandler = $UtilPrefix.'ErrorHandler';
@@ -184,7 +184,7 @@ public static function register($mode = 0)
184184

185185
if (null !== $oldErrorHandler) {
186186
restore_error_handler();
187-
if ([$UtilPrefix.'ErrorHandler', 'handleError'] === $oldErrorHandler) {
187+
if (array($UtilPrefix.'ErrorHandler', 'handleError') === $oldErrorHandler) {
188188
restore_error_handler();
189189
self::register($mode);
190190
}
@@ -218,7 +218,7 @@ public static function register($mode = 0)
218218
return $b['count'] - $a['count'];
219219
};
220220

221-
$groups = ['unsilenced', 'remaining'];
221+
$groups = array('unsilenced', 'remaining');
222222
if (self::MODE_WEAK_VENDORS === $mode) {
223223
$groups[] = 'remaining vendor';
224224
}
@@ -259,7 +259,7 @@ public static function register($mode = 0)
259259

260260
// reset deprecations array
261261
foreach ($deprecations as $group => $arrayOrInt) {
262-
$deprecations[$group] = \is_int($arrayOrInt) ? 0 : [];
262+
$deprecations[$group] = \is_int($arrayOrInt) ? 0 : array();
263263
}
264264

265265
register_shutdown_function(function () use (&$deprecations, $isFailing, $displayDeprecations, $mode) {
@@ -280,8 +280,8 @@ public static function register($mode = 0)
280280

281281
public static function collectDeprecations($outputFile)
282282
{
283-
$deprecations = [];
284-
$previousErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$deprecations, &$previousErrorHandler) {
283+
$deprecations = array();
284+
$previousErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, &$previousErrorHandler) {
285285
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) {
286286
if ($previousErrorHandler) {
287287
return $previousErrorHandler($type, $msg, $file, $line, $context);
@@ -293,7 +293,7 @@ public static function collectDeprecations($outputFile)
293293

294294
return $ErrorHandler::handleError($type, $msg, $file, $line, $context);
295295
}
296-
$deprecations[] = [error_reporting(), $msg, $file];
296+
$deprecations[] = array(error_reporting(), $msg, $file);
297297
});
298298

299299
register_shutdown_function(function () use ($outputFile, &$deprecations) {

src/Symfony/Bridge/PhpUnit/DnsMock.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
*/
1717
class DnsMock
1818
{
19-
private static $hosts = [];
20-
private static $dnsTypes = [
19+
private static $hosts = array();
20+
private static $dnsTypes = array(
2121
'A' => DNS_A,
2222
'MX' => DNS_MX,
2323
'NS' => DNS_NS,
@@ -30,7 +30,7 @@ class DnsMock
3030
'NAPTR' => DNS_NAPTR,
3131
'TXT' => DNS_TXT,
3232
'HINFO' => DNS_HINFO,
33-
];
33+
);
3434

3535
/**
3636
* Configures the mock values for DNS queries.
@@ -68,7 +68,7 @@ public static function getmxrr($hostname, &$mxhosts, &$weight = null)
6868
if (!self::$hosts) {
6969
return \getmxrr($hostname, $mxhosts, $weight);
7070
}
71-
$mxhosts = $weight = [];
71+
$mxhosts = $weight = array();
7272

7373
if (isset(self::$hosts[$hostname])) {
7474
foreach (self::$hosts[$hostname] as $record) {
@@ -125,7 +125,7 @@ public static function gethostbynamel($hostname)
125125
$ips = false;
126126

127127
if (isset(self::$hosts[$hostname])) {
128-
$ips = [];
128+
$ips = array();
129129

130130
foreach (self::$hosts[$hostname] as $record) {
131131
if ('A' === $record['type']) {
@@ -149,11 +149,11 @@ public static function dns_get_record($hostname, $type = DNS_ANY, &$authns = nul
149149
if (DNS_ANY === $type) {
150150
$type = DNS_ALL;
151151
}
152-
$records = [];
152+
$records = array();
153153

154154
foreach (self::$hosts[$hostname] as $record) {
155155
if (isset(self::$dnsTypes[$record['type']]) && (self::$dnsTypes[$record['type']] & $type)) {
156-
$records[] = array_merge(['host' => $hostname, 'class' => 'IN', 'ttl' => 1, 'type' => $record['type']], $record);
156+
$records[] = array_merge(array('host' => $hostname, 'class' => 'IN', 'ttl' => 1, 'type' => $record['type']), $record);
157157
}
158158
}
159159
}
@@ -165,7 +165,7 @@ public static function register($class)
165165
{
166166
$self = \get_called_class();
167167

168-
$mockedNs = [substr($class, 0, strrpos($class, '\\'))];
168+
$mockedNs = array(substr($class, 0, strrpos($class, '\\')));
169169
if (0 < strpos($class, '\\Tests\\')) {
170170
$ns = str_replace('\\Tests\\', '\\', $class);
171171
$mockedNs[] = substr($ns, 0, strrpos($ns, '\\'));

src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct(callable $sutFqcnResolver = null, $warningOnSutNotFo
3131
{
3232
$this->sutFqcnResolver = $sutFqcnResolver;
3333
$this->warningOnSutNotFound = $warningOnSutNotFound;
34-
$this->warnings = [];
34+
$this->warnings = array();
3535
}
3636

3737
public function startTest($test)
@@ -42,7 +42,7 @@ public function startTest($test)
4242

4343
$annotations = $test->getAnnotations();
4444

45-
$ignoredAnnotations = ['covers', 'coversDefaultClass', 'coversNothing'];
45+
$ignoredAnnotations = array('covers', 'coversDefaultClass', 'coversNothing');
4646

4747
foreach ($ignoredAnnotations as $annotation) {
4848
if (isset($annotations['class'][$annotation]) || isset($annotations['method'][$annotation])) {
@@ -74,11 +74,11 @@ public function startTest($test)
7474
$r->setAccessible(true);
7575

7676
$cache = $r->getValue();
77-
$cache = array_replace_recursive($cache, [
78-
\get_class($test) => [
79-
'covers' => [$sutFqcn],
80-
],
81-
]);
77+
$cache = array_replace_recursive($cache, array(
78+
\get_class($test) => array(
79+
'covers' => array($sutFqcn),
80+
),
81+
));
8282
$r->setValue($testClass, $cache);
8383
}
8484

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV5.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class SymfonyTestsListenerForV5 extends \PHPUnit_Framework_BaseTestListener
2222
{
2323
private $trait;
2424

25-
public function __construct(array $mockedNamespaces = [])
25+
public function __construct(array $mockedNamespaces = array())
2626
{
2727
$this->trait = new SymfonyTestsListenerTrait($mockedNamespaces);
2828
}

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV6.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class SymfonyTestsListenerForV6 extends BaseTestListener
2727
{
2828
private $trait;
2929

30-
public function __construct(array $mockedNamespaces = [])
30+
public function __construct(array $mockedNamespaces = array())
3131
{
3232
$this->trait = new SymfonyTestsListenerTrait($mockedNamespaces);
3333
}

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV7.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class SymfonyTestsListenerForV7 implements TestListener
3030

3131
private $trait;
3232

33-
public function __construct(array $mockedNamespaces = [])
33+
public function __construct(array $mockedNamespaces = array())
3434
{
3535
$this->trait = new SymfonyTestsListenerTrait($mockedNamespaces);
3636
}

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ class SymfonyTestsListenerTrait
3131
private static $globallyEnabled = false;
3232
private $state = -1;
3333
private $skippedFile = false;
34-
private $wasSkipped = [];
35-
private $isSkipped = [];
36-
private $expectedDeprecations = [];
37-
private $gatheredDeprecations = [];
34+
private $wasSkipped = array();
35+
private $isSkipped = array();
36+
private $expectedDeprecations = array();
37+
private $gatheredDeprecations = array();
3838
private $previousErrorHandler;
3939
private $testsWithWarnings;
4040
private $reportUselessTests;
@@ -44,7 +44,7 @@ class SymfonyTestsListenerTrait
4444
/**
4545
* @param array $mockedNamespaces List of namespaces, indexed by mocked features (time-sensitive or dns-sensitive)
4646
*/
47-
public function __construct(array $mockedNamespaces = [])
47+
public function __construct(array $mockedNamespaces = array())
4848
{
4949
if (class_exists('PHPUnit_Util_Blacklist')) {
5050
\PHPUnit_Util_Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 2;
@@ -55,7 +55,7 @@ public function __construct(array $mockedNamespaces = [])
5555
$warn = false;
5656
foreach ($mockedNamespaces as $type => $namespaces) {
5757
if (!\is_array($namespaces)) {
58-
$namespaces = [$namespaces];
58+
$namespaces = array($namespaces);
5959
}
6060
if (\is_int($type)) {
6161
// @deprecated BC with v2.8 to v3.0
@@ -104,7 +104,7 @@ public function startTestSuite($suite)
104104
$Test = 'PHPUnit\Util\Test';
105105
}
106106
$suiteName = $suite->getName();
107-
$this->testsWithWarnings = [];
107+
$this->testsWithWarnings = array();
108108

109109
foreach ($suite->tests() as $test) {
110110
if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) {
@@ -135,11 +135,11 @@ public function startTestSuite($suite)
135135

136136
if (!$this->wasSkipped = require $this->skippedFile) {
137137
echo "All tests already ran successfully.\n";
138-
$suite->setTests([]);
138+
$suite->setTests(array());
139139
}
140140
}
141141
}
142-
$testSuites = [$suite];
142+
$testSuites = array($suite);
143143
for ($i = 0; isset($testSuites[$i]); ++$i) {
144144
foreach ($testSuites[$i]->tests() as $test) {
145145
if ($test instanceof \PHPUnit_Framework_TestSuite || $test instanceof TestSuite) {
@@ -158,7 +158,7 @@ public function startTestSuite($suite)
158158
}
159159
}
160160
} elseif (2 === $this->state) {
161-
$skipped = [];
161+
$skipped = array();
162162
foreach ($suite->tests() as $test) {
163163
if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)
164164
|| isset($this->wasSkipped[$suiteName]['*'])
@@ -230,7 +230,7 @@ public function startTest($test)
230230
$test->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything(false);
231231

232232
$this->expectedDeprecations = $annotations['method']['expectedDeprecation'];
233-
$this->previousErrorHandler = set_error_handler([$this, 'handleError']);
233+
$this->previousErrorHandler = set_error_handler(array($this, 'handleError'));
234234
}
235235
}
236236
}
@@ -271,8 +271,8 @@ public function endTest($test, $time)
271271
$deprecations = file_get_contents($this->runsInSeparateProcess);
272272
unlink($this->runsInSeparateProcess);
273273
putenv('SYMFONY_DEPRECATIONS_SERIALIZE');
274-
foreach ($deprecations ? unserialize($deprecations) : [] as $deprecation) {
275-
$error = serialize(['deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => isset($deprecation[2]) ? $deprecation[2] : null]);
274+
foreach ($deprecations ? unserialize($deprecations) : array() as $deprecation) {
275+
$error = serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => isset($deprecation[2]) ? $deprecation[2] : null));
276276
if ($deprecation[0]) {
277277
@trigger_error($error, E_USER_DEPRECATED);
278278
} else {
@@ -283,13 +283,13 @@ public function endTest($test, $time)
283283
}
284284

285285
if ($this->expectedDeprecations) {
286-
if (!\in_array($test->getStatus(), [$BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE], true)) {
286+
if (!\in_array($test->getStatus(), array($BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE), true)) {
287287
$test->addToAssertionCount(\count($this->expectedDeprecations));
288288
}
289289

290290
restore_error_handler();
291291

292-
if (!$errored && !\in_array($test->getStatus(), [$BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE, $BaseTestRunner::STATUS_FAILURE, $BaseTestRunner::STATUS_ERROR], true)) {
292+
if (!$errored && !\in_array($test->getStatus(), array($BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE, $BaseTestRunner::STATUS_FAILURE, $BaseTestRunner::STATUS_ERROR), true)) {
293293
try {
294294
$prefix = "@expectedDeprecation:\n";
295295
$test->assertStringMatchesFormat($prefix.'%A '.implode("\n%A ", $this->expectedDeprecations)."\n%A", $prefix.' '.implode("\n ", $this->gatheredDeprecations)."\n");
@@ -300,15 +300,15 @@ public function endTest($test, $time)
300300
}
301301
}
302302

303-
$this->expectedDeprecations = $this->gatheredDeprecations = [];
303+
$this->expectedDeprecations = $this->gatheredDeprecations = array();
304304
$this->previousErrorHandler = null;
305305
}
306306
if (!$this->runsInSeparateProcess && -2 < $this->state && ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) {
307307
if (\in_array('time-sensitive', $groups, true)) {
308308
ClockMock::withClockMock(false);
309309
}
310310
if (\in_array('dns-sensitive', $groups, true)) {
311-
DnsMock::withMockedHosts([]);
311+
DnsMock::withMockedHosts(array());
312312
}
313313
}
314314

@@ -329,7 +329,7 @@ public function endTest($test, $time)
329329
}
330330
}
331331

332-
public function handleError($type, $msg, $file, $line, $context = [])
332+
public function handleError($type, $msg, $file, $line, $context = array())
333333
{
334334
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) {
335335
$h = $this->previousErrorHandler;

src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV5.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected function handleConfiguration(array &$arguments)
2727

2828
$result = parent::handleConfiguration($arguments);
2929

30-
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : [];
30+
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
3131

3232
$registeredLocally = false;
3333

src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV6.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function handleConfiguration(array &$arguments)
3030

3131
parent::handleConfiguration($arguments);
3232

33-
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : [];
33+
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
3434

3535
$registeredLocally = false;
3636

src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV7.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function handleConfiguration(array &$arguments): void
3030

3131
parent::handleConfiguration($arguments);
3232

33-
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : [];
33+
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
3434

3535
$registeredLocally = false;
3636

src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/default.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class PHPUnit_Util_Test
3535
{
3636
public static function getGroups()
3737
{
38-
return [];
38+
return array();
3939
}
4040
}
4141

src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/shutdown_deprecations.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class PHPUnit_Util_Test
3535
{
3636
public static function getGroups()
3737
{
38-
return [];
38+
return array();
3939
}
4040
}
4141

0 commit comments

Comments
 (0)
0