@@ -35,26 +35,26 @@ class SymfonyTestsListenerTrait
3535 private static $ globallyEnabled = false ;
3636 private $ state = -1 ;
3737 private $ skippedFile = false ;
38- private $ wasSkipped = array () ;
39- private $ isSkipped = array () ;
40- private $ expectedDeprecations = array () ;
41- private $ gatheredDeprecations = array () ;
38+ private $ wasSkipped = [] ;
39+ private $ isSkipped = [] ;
40+ private $ expectedDeprecations = [] ;
41+ private $ gatheredDeprecations = [] ;
4242 private $ previousErrorHandler ;
4343 private $ error ;
4444 private $ runsInSeparateProcess = false ;
4545
4646 /**
4747 * @param array $mockedNamespaces List of namespaces, indexed by mocked features (time-sensitive or dns-sensitive)
4848 */
49- public function __construct (array $ mockedNamespaces = array () )
49+ public function __construct (array $ mockedNamespaces = [] )
5050 {
5151 Blacklist::$ blacklistedClassNames ['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait ' ] = 2 ;
5252
5353 $ enableDebugClassLoader = class_exists (DebugClassLoader::class) || class_exists (LegacyDebugClassLoader::class);
5454
5555 foreach ($ mockedNamespaces as $ type => $ namespaces ) {
5656 if (!\is_array ($ namespaces )) {
57- $ namespaces = array ( $ namespaces) ;
57+ $ namespaces = [ $ namespaces] ;
5858 }
5959 if ('time-sensitive ' === $ type ) {
6060 foreach ($ namespaces as $ ns ) {
@@ -140,11 +140,11 @@ public function startTestSuite($suite)
140140
141141 if (!$ this ->wasSkipped = require $ this ->skippedFile ) {
142142 echo "All tests already ran successfully. \n" ;
143- $ suite ->setTests (array () );
143+ $ suite ->setTests ([] );
144144 }
145145 }
146146 }
147- $ testSuites = array ( $ suite) ;
147+ $ testSuites = [ $ suite] ;
148148 for ($ i = 0 ; isset ($ testSuites [$ i ]); ++$ i ) {
149149 foreach ($ testSuites [$ i ]->tests () as $ test ) {
150150 if ($ test instanceof TestSuite) {
@@ -163,7 +163,7 @@ public function startTestSuite($suite)
163163 }
164164 }
165165 } elseif (2 === $ this ->state ) {
166- $ skipped = array () ;
166+ $ skipped = [] ;
167167 foreach ($ suite ->tests () as $ test ) {
168168 if (!($ test instanceof \PHPUnit \Framework \TestCase || $ test instanceof TestCase)
169169 || isset ($ this ->wasSkipped [$ suiteName ]['* ' ])
@@ -228,7 +228,7 @@ public function startTest($test)
228228 $ test ->getTestResultObject ()->beStrictAboutTestsThatDoNotTestAnything (false );
229229
230230 $ this ->expectedDeprecations = $ annotations ['method ' ]['expectedDeprecation ' ];
231- $ this ->previousErrorHandler = set_error_handler (array ( $ this , 'handleError ' ) );
231+ $ this ->previousErrorHandler = set_error_handler ([ $ this , 'handleError ' ] );
232232 }
233233 }
234234 }
@@ -251,8 +251,8 @@ public function endTest($test, $time)
251251 $ deprecations = file_get_contents ($ this ->runsInSeparateProcess );
252252 unlink ($ this ->runsInSeparateProcess );
253253 putenv ('SYMFONY_DEPRECATIONS_SERIALIZE ' );
254- foreach ($ deprecations ? unserialize ($ deprecations ) : array () as $ deprecation ) {
255- $ error = serialize (array ( 'deprecation ' => $ deprecation [1 ], 'class ' => $ className , 'method ' => $ test ->getName (false ), 'triggering_file ' => isset ($ deprecation [2 ]) ? $ deprecation [2 ] : null ) );
254+ foreach ($ deprecations ? unserialize ($ deprecations ) : [] as $ deprecation ) {
255+ $ error = serialize ([ 'deprecation ' => $ deprecation [1 ], 'class ' => $ className , 'method ' => $ test ->getName (false ), 'triggering_file ' => isset ($ deprecation [2 ]) ? $ deprecation [2 ] : null ] );
256256 if ($ deprecation [0 ]) {
257257 // unsilenced on purpose
258258 trigger_error ($ error , E_USER_DEPRECATED );
@@ -264,13 +264,13 @@ public function endTest($test, $time)
264264 }
265265
266266 if ($ this ->expectedDeprecations ) {
267- if (!\in_array ($ test ->getStatus (), array ( BaseTestRunner::STATUS_SKIPPED , BaseTestRunner::STATUS_INCOMPLETE ) , true )) {
267+ if (!\in_array ($ test ->getStatus (), [ BaseTestRunner::STATUS_SKIPPED , BaseTestRunner::STATUS_INCOMPLETE ] , true )) {
268268 $ test ->addToAssertionCount (\count ($ this ->expectedDeprecations ));
269269 }
270270
271271 restore_error_handler ();
272272
273- if (!$ errored && !\in_array ($ test ->getStatus (), array ( BaseTestRunner::STATUS_SKIPPED , BaseTestRunner::STATUS_INCOMPLETE , BaseTestRunner::STATUS_FAILURE , BaseTestRunner::STATUS_ERROR ) , true )) {
273+ if (!$ errored && !\in_array ($ test ->getStatus (), [ BaseTestRunner::STATUS_SKIPPED , BaseTestRunner::STATUS_INCOMPLETE , BaseTestRunner::STATUS_FAILURE , BaseTestRunner::STATUS_ERROR ] , true )) {
274274 try {
275275 $ prefix = "@expectedDeprecation: \n" ;
276276 $ test ->assertStringMatchesFormat ($ prefix .'%A ' .implode ("\n%A " , $ this ->expectedDeprecations )."\n%A " , $ prefix .' ' .implode ("\n " , $ this ->gatheredDeprecations )."\n" );
@@ -279,20 +279,20 @@ public function endTest($test, $time)
279279 }
280280 }
281281
282- $ this ->expectedDeprecations = $ this ->gatheredDeprecations = array () ;
282+ $ this ->expectedDeprecations = $ this ->gatheredDeprecations = [] ;
283283 $ this ->previousErrorHandler = null ;
284284 }
285285 if (!$ this ->runsInSeparateProcess && -2 < $ this ->state && ($ test instanceof \PHPUnit \Framework \TestCase || $ test instanceof TestCase)) {
286286 if (\in_array ('time-sensitive ' , $ groups , true )) {
287287 ClockMock::withClockMock (false );
288288 }
289289 if (\in_array ('dns-sensitive ' , $ groups , true )) {
290- DnsMock::withMockedHosts (array () );
290+ DnsMock::withMockedHosts ([] );
291291 }
292292 }
293293 }
294294
295- public function handleError ($ type , $ msg , $ file , $ line , $ context = array () )
295+ public function handleError ($ type , $ msg , $ file , $ line , $ context = [] )
296296 {
297297 if (E_USER_DEPRECATED !== $ type && E_DEPRECATED !== $ type ) {
298298 $ h = $ this ->previousErrorHandler ;
0 commit comments