15
15
error_reporting (-1 );
16
16
17
17
global $ argv , $ argc ;
18
- $ argv = isset ($ _SERVER ['argv ' ]) ? $ _SERVER ['argv ' ] : array () ;
18
+ $ argv = isset ($ _SERVER ['argv ' ]) ? $ _SERVER ['argv ' ] : [] ;
19
19
$ argc = isset ($ _SERVER ['argc ' ]) ? $ _SERVER ['argc ' ] : 0 ;
20
20
$ getEnvVar = function ($ name , $ default = false ) use ($ argv ) {
21
21
if (false !== $ value = getenv ($ name )) {
130
130
$ PHP .= ' -qrr ' ;
131
131
}
132
132
133
- $ defaultEnvs = array (
133
+ $ defaultEnvs = [
134
134
'COMPOSER ' => 'composer.json ' ,
135
135
'COMPOSER_VENDOR_DIR ' => 'vendor ' ,
136
136
'COMPOSER_BIN_DIR ' => 'bin ' ,
137
- ) ;
137
+ ] ;
138
138
139
139
foreach ($ defaultEnvs as $ envName => $ envValue ) {
140
140
if ($ envValue !== getenv ($ envName )) {
147
147
|| ($ COMPOSER = rtrim ('\\' === DIRECTORY_SEPARATOR ? preg_replace ('/[\r\n].*/ ' , '' , `where.exe composer.phar `) : `which composer.phar 2> /dev/null `))
148
148
|| ($ COMPOSER = rtrim ('\\' === DIRECTORY_SEPARATOR ? preg_replace ('/[\r\n].*/ ' , '' , `where.exe composer `) : `which composer 2> /dev/null `))
149
149
|| file_exists ($ COMPOSER = rtrim ('\\' === DIRECTORY_SEPARATOR ? `git rev-parse --show-toplevel 2> NUL ` : `git rev-parse --show-toplevel 2> /dev/null `).DIRECTORY_SEPARATOR .'composer.phar ' )
150
- ? (file_get_contents ($ COMPOSER , false , null , 0 , 18 ) === ' #!/usr/bin/env php ' ? $ PHP : '' ).' ' .escapeshellarg ($ COMPOSER ) // detect shell wrappers by looking at the shebang
150
+ ? (' #!/usr/bin/env php ' === file_get_contents ($ COMPOSER , false , null , 0 , 18 ) ? $ PHP : '' ).' ' .escapeshellarg ($ COMPOSER ) // detect shell wrappers by looking at the shebang
151
151
: 'composer ' ;
152
152
153
- $ SYMFONY_PHPUNIT_REMOVE = $ getEnvVar ('SYMFONY_PHPUNIT_REMOVE ' , 'phpspec/prophecy ' .($ PHPUNIT_VERSION < 6.0 ? ' symfony/yaml ' : '' ));
154
- $ configurationHash = md5 (implode (PHP_EOL , array ( md5_file (__FILE__ ), $ SYMFONY_PHPUNIT_REMOVE , (int ) $ PHPUNIT_REMOVE_RETURN_TYPEHINT ) ));
155
- $ PHPUNIT_VERSION_DIR = sprintf ('phpunit-%s-%d ' , $ PHPUNIT_VERSION , $ PHPUNIT_REMOVE_RETURN_TYPEHINT );
153
+ $ SYMFONY_PHPUNIT_REMOVE = $ getEnvVar ('SYMFONY_PHPUNIT_REMOVE ' , 'phpspec/prophecy ' .($ PHPUNIT_VERSION < 6.0 ? ' symfony/yaml ' : '' ));
154
+ $ configurationHash = md5 (implode (PHP_EOL , [ md5_file (__FILE__ ), $ SYMFONY_PHPUNIT_REMOVE , (int ) $ PHPUNIT_REMOVE_RETURN_TYPEHINT ] ));
155
+ $ PHPUNIT_VERSION_DIR = sprintf ('phpunit-%s-%d ' , $ PHPUNIT_VERSION , $ PHPUNIT_REMOVE_RETURN_TYPEHINT );
156
156
if (!file_exists ("$ PHPUNIT_DIR / $ PHPUNIT_VERSION_DIR /phpunit " ) || $ configurationHash !== @file_get_contents ("$ PHPUNIT_DIR /. $ PHPUNIT_VERSION_DIR .md5 " )) {
157
157
// Build a standalone phpunit without symfony/yaml nor prophecy by default
158
158
159
159
@mkdir ($ PHPUNIT_DIR , 0777 , true );
160
160
chdir ($ PHPUNIT_DIR );
161
161
if (file_exists ("$ PHPUNIT_VERSION_DIR " )) {
162
- passthru (sprintf ('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s > NUL ' : 'rm -rf %s ' , "$ PHPUNIT_VERSION_DIR .old " ));
162
+ passthru (sprintf ('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s > NUL ' : 'rm -rf %s ' , "$ PHPUNIT_VERSION_DIR .old " ));
163
163
rename ("$ PHPUNIT_VERSION_DIR " , "$ PHPUNIT_VERSION_DIR .old " );
164
- passthru (sprintf ('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s ' : 'rm -rf %s ' , "$ PHPUNIT_VERSION_DIR .old " ));
164
+ passthru (sprintf ('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s ' : 'rm -rf %s ' , "$ PHPUNIT_VERSION_DIR .old " ));
165
165
}
166
166
$ passthruOrFail ("$ COMPOSER create-project --no-install --prefer-dist --no-scripts --no-plugins --no-progress --ansi phpunit/phpunit $ PHPUNIT_VERSION_DIR \"$ PHPUNIT_VERSION .* \"" );
167
167
@copy ("$ PHPUNIT_VERSION_DIR /phpunit.xsd " , 'phpunit.xsd ' );
187
187
putenv ("COMPOSER_ROOT_VERSION= $ PHPUNIT_VERSION .99 " );
188
188
$ q = '\\' === DIRECTORY_SEPARATOR ? '" ' : '' ;
189
189
// --no-suggest is not in the list to keep compat with composer 1.0, which is shipped with Ubuntu 16.04LTS
190
- $ exit = proc_close (proc_open ("$ q$ COMPOSER install --no-dev --prefer-dist --no-progress --ansi $ q " , array () , $ p , getcwd ()));
190
+ $ exit = proc_close (proc_open ("$ q$ COMPOSER install --no-dev --prefer-dist --no-progress --ansi $ q " , [] , $ p , getcwd ()));
191
191
putenv ('COMPOSER_ROOT_VERSION ' .(false !== $ prevRoot ? '= ' .$ prevRoot : '' ));
192
192
if ($ exit ) {
193
193
exit ($ exit );
@@ -233,13 +233,20 @@ class SymfonyBlacklistPhpunit {}
233
233
}
234
234
235
235
if ($ PHPUNIT_VERSION < 8.0 ) {
236
- $ argv = array_filter ($ argv , function ($ v ) use (&$ argc ) { if ('--do-not-cache-result ' !== $ v ) return true ; --$ argc ; return false ; });
236
+ $ argv = array_filter ($ argv , function ($ v ) use (&$ argc ) {
237
+ if ('--do-not-cache-result ' !== $ v ) {
238
+ return true ;
239
+ }
240
+ --$ argc ;
241
+
242
+ return false ;
243
+ });
237
244
} elseif (filter_var (getenv ('SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE ' ), FILTER_VALIDATE_BOOLEAN )) {
238
245
$ argv [] = '--do-not-cache-result ' ;
239
246
++$ argc ;
240
247
}
241
248
242
- $ components = array () ;
249
+ $ components = [] ;
243
250
$ cmd = array_map ('escapeshellarg ' , $ argv );
244
251
$ exit = 0 ;
245
252
@@ -274,7 +281,7 @@ class SymfonyBlacklistPhpunit {}
274
281
275
282
if ($ components ) {
276
283
$ skippedTests = isset ($ _SERVER ['SYMFONY_PHPUNIT_SKIPPED_TESTS ' ]) ? $ _SERVER ['SYMFONY_PHPUNIT_SKIPPED_TESTS ' ] : false ;
277
- $ runningProcs = array () ;
284
+ $ runningProcs = [] ;
278
285
279
286
foreach ($ components as $ component ) {
280
287
// Run phpunit tests in parallel
@@ -285,7 +292,7 @@ class SymfonyBlacklistPhpunit {}
285
292
286
293
$ c = escapeshellarg ($ component );
287
294
288
- if ($ proc = proc_open (sprintf ($ cmd , $ c , " > $ c/phpunit.stdout 2> $ c/phpunit.stderr " ), array () , $ pipes )) {
295
+ if ($ proc = proc_open (sprintf ($ cmd , $ c , " > $ c/phpunit.stdout 2> $ c/phpunit.stderr " ), [] , $ pipes )) {
289
296
$ runningProcs [$ component ] = $ proc ;
290
297
} else {
291
298
$ exit = 1 ;
@@ -295,7 +302,7 @@ class SymfonyBlacklistPhpunit {}
295
302
296
303
while ($ runningProcs ) {
297
304
usleep (300000 );
298
- $ terminatedProcs = array () ;
305
+ $ terminatedProcs = [] ;
299
306
foreach ($ runningProcs as $ component => $ proc ) {
300
307
$ procStatus = proc_get_status ($ proc );
301
308
if (!$ procStatus ['running ' ]) {
@@ -306,7 +313,7 @@ class SymfonyBlacklistPhpunit {}
306
313
}
307
314
308
315
foreach ($ terminatedProcs as $ component => $ procStatus ) {
309
- foreach (array ( 'out ' , 'err ' ) as $ file ) {
316
+ foreach ([ 'out ' , 'err ' ] as $ file ) {
310
317
$ file = "$ component/phpunit.std $ file " ;
311
318
readfile ($ file );
312
319
unlink ($ file );
@@ -316,7 +323,7 @@ class SymfonyBlacklistPhpunit {}
316
323
// STATUS_STACK_BUFFER_OVERRUN (-1073740791/0xC0000409)
317
324
// STATUS_ACCESS_VIOLATION (-1073741819/0xC0000005)
318
325
// STATUS_HEAP_CORRUPTION (-1073740940/0xC0000374)
319
- if ($ procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded ('apcu ' ) || !filter_var (ini_get ('apc.enable_cli ' ), FILTER_VALIDATE_BOOLEAN ) || !in_array ($ procStatus , array ( -1073740791 , -1073741819 , -1073740940 ) ))) {
326
+ if ($ procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded ('apcu ' ) || !filter_var (ini_get ('apc.enable_cli ' ), FILTER_VALIDATE_BOOLEAN ) || !in_array ($ procStatus , [ -1073740791 , -1073741819 , -1073740940 ] ))) {
320
327
$ exit = $ procStatus ;
321
328
echo "\033[41mKO \033[0m $ component \n\n" ;
322
329
} else {
@@ -326,9 +333,11 @@ class SymfonyBlacklistPhpunit {}
326
333
}
327
334
} elseif (!isset ($ argv [1 ]) || 'install ' !== $ argv [1 ] || file_exists ('install ' )) {
328
335
if (!class_exists ('SymfonyBlacklistSimplePhpunit ' , false )) {
329
- class SymfonyBlacklistSimplePhpunit {}
336
+ class SymfonyBlacklistSimplePhpunit
337
+ {
338
+ }
330
339
}
331
- array_splice ($ argv , 1 , 0 , array ( '--colors=always ' ) );
340
+ array_splice ($ argv , 1 , 0 , [ '--colors=always ' ] );
332
341
$ _SERVER ['argv ' ] = $ argv ;
333
342
$ _SERVER ['argc ' ] = ++$ argc ;
334
343
include "$ PHPUNIT_DIR / $ PHPUNIT_VERSION_DIR /phpunit " ;
0 commit comments