@@ -32,10 +32,10 @@ class SymfonyTestsListenerTrait
32
32
private static $ globallyEnabled = false ;
33
33
private $ state = -1 ;
34
34
private $ skippedFile = false ;
35
- private $ wasSkipped = array () ;
36
- private $ isSkipped = array () ;
37
- private $ expectedDeprecations = array () ;
38
- private $ gatheredDeprecations = array () ;
35
+ private $ wasSkipped = [] ;
36
+ private $ isSkipped = [] ;
37
+ private $ expectedDeprecations = [] ;
38
+ private $ gatheredDeprecations = [] ;
39
39
private $ previousErrorHandler ;
40
40
private $ testsWithWarnings ;
41
41
private $ reportUselessTests ;
@@ -45,7 +45,7 @@ class SymfonyTestsListenerTrait
45
45
/**
46
46
* @param array $mockedNamespaces List of namespaces, indexed by mocked features (time-sensitive or dns-sensitive)
47
47
*/
48
- public function __construct (array $ mockedNamespaces = array () )
48
+ public function __construct (array $ mockedNamespaces = [] )
49
49
{
50
50
if (class_exists ('PHPUnit_Util_Blacklist ' )) {
51
51
\PHPUnit_Util_Blacklist::$ blacklistedClassNames ['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait ' ] = 2 ;
@@ -57,7 +57,7 @@ public function __construct(array $mockedNamespaces = array())
57
57
58
58
foreach ($ mockedNamespaces as $ type => $ namespaces ) {
59
59
if (!\is_array ($ namespaces )) {
60
- $ namespaces = array ( $ namespaces) ;
60
+ $ namespaces = [ $ namespaces] ;
61
61
}
62
62
if ('time-sensitive ' === $ type ) {
63
63
foreach ($ namespaces as $ ns ) {
@@ -114,7 +114,7 @@ public function startTestSuite($suite)
114
114
$ Test = 'PHPUnit\Util\Test ' ;
115
115
}
116
116
$ suiteName = $ suite ->getName ();
117
- $ this ->testsWithWarnings = array () ;
117
+ $ this ->testsWithWarnings = [] ;
118
118
119
119
foreach ($ suite ->tests () as $ test ) {
120
120
if (!($ test instanceof \PHPUnit \Framework \TestCase || $ test instanceof TestCase)) {
@@ -145,11 +145,11 @@ public function startTestSuite($suite)
145
145
146
146
if (!$ this ->wasSkipped = require $ this ->skippedFile ) {
147
147
echo "All tests already ran successfully. \n" ;
148
- $ suite ->setTests (array () );
148
+ $ suite ->setTests ([] );
149
149
}
150
150
}
151
151
}
152
- $ testSuites = array ( $ suite) ;
152
+ $ testSuites = [ $ suite] ;
153
153
for ($ i = 0 ; isset ($ testSuites [$ i ]); ++$ i ) {
154
154
foreach ($ testSuites [$ i ]->tests () as $ test ) {
155
155
if ($ test instanceof \PHPUnit_Framework_TestSuite || $ test instanceof TestSuite) {
@@ -168,7 +168,7 @@ public function startTestSuite($suite)
168
168
}
169
169
}
170
170
} elseif (2 === $ this ->state ) {
171
- $ skipped = array () ;
171
+ $ skipped = [] ;
172
172
foreach ($ suite ->tests () as $ test ) {
173
173
if (!($ test instanceof \PHPUnit \Framework \TestCase || $ test instanceof TestCase)
174
174
|| isset ($ this ->wasSkipped [$ suiteName ]['* ' ])
@@ -240,7 +240,7 @@ public function startTest($test)
240
240
$ test ->getTestResultObject ()->beStrictAboutTestsThatDoNotTestAnything (false );
241
241
242
242
$ this ->expectedDeprecations = $ annotations ['method ' ]['expectedDeprecation ' ];
243
- $ this ->previousErrorHandler = set_error_handler (array ( $ this , 'handleError ' ) );
243
+ $ this ->previousErrorHandler = set_error_handler ([ $ this , 'handleError ' ] );
244
244
}
245
245
}
246
246
}
@@ -281,8 +281,14 @@ public function endTest($test, $time)
281
281
$ deprecations = file_get_contents ($ this ->runsInSeparateProcess );
282
282
unlink ($ this ->runsInSeparateProcess );
283
283
putenv ('SYMFONY_DEPRECATIONS_SERIALIZE ' );
284
- foreach ($ deprecations ? unserialize ($ deprecations ) : array () as $ deprecation ) {
285
- $ error = serialize (array ('deprecation ' => $ deprecation [1 ], 'class ' => $ className , 'method ' => $ test ->getName (false ), 'triggering_file ' => isset ($ deprecation [2 ]) ? $ deprecation [2 ] : null ));
284
+ foreach ($ deprecations ? unserialize ($ deprecations ) : [] as $ deprecation ) {
285
+ $ error = serialize ([
286
+ 'deprecation ' => $ deprecation [1 ],
287
+ 'class ' => $ className ,
288
+ 'method ' => $ test ->getName (false ),
289
+ 'triggering_file ' => isset ($ deprecation [2 ]) ? $ deprecation [2 ] : null ,
290
+ 'files_stack ' => $ deprecation [3 ],
291
+ ]);
286
292
if ($ deprecation [0 ]) {
287
293
@trigger_error ($ error , E_USER_DEPRECATED );
288
294
} else {
@@ -293,13 +299,13 @@ public function endTest($test, $time)
293
299
}
294
300
295
301
if ($ this ->expectedDeprecations ) {
296
- if (!\in_array ($ test ->getStatus (), array ( $ BaseTestRunner ::STATUS_SKIPPED , $ BaseTestRunner ::STATUS_INCOMPLETE ) , true )) {
302
+ if (!\in_array ($ test ->getStatus (), [ $ BaseTestRunner ::STATUS_SKIPPED , $ BaseTestRunner ::STATUS_INCOMPLETE ] , true )) {
297
303
$ test ->addToAssertionCount (\count ($ this ->expectedDeprecations ));
298
304
}
299
305
300
306
restore_error_handler ();
301
307
302
- if (!$ errored && !\in_array ($ test ->getStatus (), array ( $ BaseTestRunner ::STATUS_SKIPPED , $ BaseTestRunner ::STATUS_INCOMPLETE , $ BaseTestRunner ::STATUS_FAILURE , $ BaseTestRunner ::STATUS_ERROR ) , true )) {
308
+ if (!$ errored && !\in_array ($ test ->getStatus (), [ $ BaseTestRunner ::STATUS_SKIPPED , $ BaseTestRunner ::STATUS_INCOMPLETE , $ BaseTestRunner ::STATUS_FAILURE , $ BaseTestRunner ::STATUS_ERROR ] , true )) {
303
309
try {
304
310
$ prefix = "@expectedDeprecation: \n" ;
305
311
$ test ->assertStringMatchesFormat ($ prefix .'%A ' .implode ("\n%A " , $ this ->expectedDeprecations )."\n%A " , $ prefix .' ' .implode ("\n " , $ this ->gatheredDeprecations )."\n" );
@@ -310,20 +316,20 @@ public function endTest($test, $time)
310
316
}
311
317
}
312
318
313
- $ this ->expectedDeprecations = $ this ->gatheredDeprecations = array () ;
319
+ $ this ->expectedDeprecations = $ this ->gatheredDeprecations = [] ;
314
320
$ this ->previousErrorHandler = null ;
315
321
}
316
322
if (!$ this ->runsInSeparateProcess && -2 < $ this ->state && ($ test instanceof \PHPUnit \Framework \TestCase || $ test instanceof TestCase)) {
317
323
if (\in_array ('time-sensitive ' , $ groups , true )) {
318
324
ClockMock::withClockMock (false );
319
325
}
320
326
if (\in_array ('dns-sensitive ' , $ groups , true )) {
321
- DnsMock::withMockedHosts (array () );
327
+ DnsMock::withMockedHosts ([] );
322
328
}
323
329
}
324
330
}
325
331
326
- public function handleError ($ type , $ msg , $ file , $ line , $ context = array () )
332
+ public function handleError ($ type , $ msg , $ file , $ line , $ context = [] )
327
333
{
328
334
if (E_USER_DEPRECATED !== $ type && E_DEPRECATED !== $ type ) {
329
335
$ h = $ this ->previousErrorHandler ;
0 commit comments