Skip to content

Commit e64443b

Browse files
Merge branch '3.4' into 4.4
* 3.4: Enable "native_constant_invocation" CS rule Make AbstractPhpFileCacheWarmer public
2 parents 3dc86fc + 6b70024 commit e64443b

File tree

6 files changed

+40
-40
lines changed

6 files changed

+40
-40
lines changed

DeprecationErrorHandler.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public static function collectDeprecations($outputFile)
9696
{
9797
$deprecations = [];
9898
$previousErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$deprecations, &$previousErrorHandler) {
99-
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type && (E_WARNING !== $type || false === strpos($msg, '" targeting switch is equivalent to "break'))) {
99+
if (\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type && (\E_WARNING !== $type || false === strpos($msg, '" targeting switch is equivalent to "break'))) {
100100
if ($previousErrorHandler) {
101101
return $previousErrorHandler($type, $msg, $file, $line, $context);
102102
}
@@ -128,7 +128,7 @@ public static function collectDeprecations($outputFile)
128128
*/
129129
public function handleError($type, $msg, $file, $line, $context = [])
130130
{
131-
if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type && (E_WARNING !== $type || false === strpos($msg, '" targeting switch is equivalent to "break'))) || !$this->getConfiguration()->isEnabled()) {
131+
if ((\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type && (\E_WARNING !== $type || false === strpos($msg, '" targeting switch is equivalent to "break'))) || !$this->getConfiguration()->isEnabled()) {
132132
return \call_user_func(self::getPhpUnitErrorHandler(), $type, $msg, $file, $line, $context);
133133
}
134134

@@ -338,7 +338,7 @@ private static function getPhpUnitErrorHandler()
338338
return 'PHPUnit\Util\ErrorHandler::handleError';
339339
}
340340

341-
foreach (debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS) as $frame) {
341+
foreach (debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS) as $frame) {
342342
if (isset($frame['object']) && $frame['object'] instanceof TestResult) {
343343
return new ErrorHandler(
344344
$frame['object']->getConvertDeprecationsToExceptions(),
@@ -377,21 +377,21 @@ private static function hasColorSupport()
377377

378378
if (\DIRECTORY_SEPARATOR === '\\') {
379379
return (\function_exists('sapi_windows_vt100_support')
380-
&& sapi_windows_vt100_support(STDOUT))
380+
&& sapi_windows_vt100_support(\STDOUT))
381381
|| false !== getenv('ANSICON')
382382
|| 'ON' === getenv('ConEmuANSI')
383383
|| 'xterm' === getenv('TERM');
384384
}
385385

386386
if (\function_exists('stream_isatty')) {
387-
return stream_isatty(STDOUT);
387+
return stream_isatty(\STDOUT);
388388
}
389389

390390
if (\function_exists('posix_isatty')) {
391-
return posix_isatty(STDOUT);
391+
return posix_isatty(\STDOUT);
392392
}
393393

394-
$stat = fstat(STDOUT);
394+
$stat = fstat(\STDOUT);
395395

396396
// Check if formatted mode is S_IFCHR
397397
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;

Tests/DnsMockTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ public function testDnsGetRecord()
141141

142142
$this->assertFalse(DnsMock::dns_get_record('foobar.com'));
143143
$this->assertSame($records, DnsMock::dns_get_record('example.com'));
144-
$this->assertSame($records, DnsMock::dns_get_record('example.com', DNS_ALL));
145-
$this->assertSame($records, DnsMock::dns_get_record('example.com', DNS_A | DNS_PTR));
146-
$this->assertSame([$ptr], DnsMock::dns_get_record('example.com', DNS_PTR));
144+
$this->assertSame($records, DnsMock::dns_get_record('example.com', \DNS_ALL));
145+
$this->assertSame($records, DnsMock::dns_get_record('example.com', \DNS_A | \DNS_PTR));
146+
$this->assertSame([$ptr], DnsMock::dns_get_record('example.com', \DNS_PTR));
147147
}
148148
}

Tests/ExpectedDeprecationAnnotationTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class ExpectedDeprecationAnnotationTest extends TestCase
2424
*/
2525
public function testOne()
2626
{
27-
@trigger_error('foo', E_USER_DEPRECATED);
27+
@trigger_error('foo', \E_USER_DEPRECATED);
2828
}
2929

3030
/**
@@ -37,7 +37,7 @@ public function testOne()
3737
*/
3838
public function testMany()
3939
{
40-
@trigger_error('foo', E_USER_DEPRECATED);
41-
@trigger_error('bar', E_USER_DEPRECATED);
40+
@trigger_error('foo', \E_USER_DEPRECATED);
41+
@trigger_error('bar', \E_USER_DEPRECATED);
4242
}
4343
}

Tests/ProcessIsolationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ProcessIsolationTest extends TestCase
1818
*/
1919
public function testIsolation()
2020
{
21-
@trigger_error('Test abc', E_USER_DEPRECATED);
21+
@trigger_error('Test abc', \E_USER_DEPRECATED);
2222
$this->addToAssertionCount(1);
2323
}
2424

@@ -27,6 +27,6 @@ public function testCallingOtherErrorHandler()
2727
$this->expectException('PHPUnit\Framework\Exception');
2828
$this->expectExceptionMessage('Test that PHPUnit\'s error handler fires.');
2929

30-
trigger_error('Test that PHPUnit\'s error handler fires.', E_USER_WARNING);
30+
trigger_error('Test that PHPUnit\'s error handler fires.', \E_USER_WARNING);
3131
}
3232
}

bin/simple-phpunit.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
return null;
3131
}
3232
if (is_dir($probableConfig)) {
33-
return $getPhpUnitConfig($probableConfig.DIRECTORY_SEPARATOR.'phpunit.xml');
33+
return $getPhpUnitConfig($probableConfig.\DIRECTORY_SEPARATOR.'phpunit.xml');
3434
}
3535

3636
if (file_exists($probableConfig)) {
@@ -93,27 +93,27 @@
9393
}
9494
};
9595

96-
if (PHP_VERSION_ID >= 80000) {
96+
if (\PHP_VERSION_ID >= 80000) {
9797
// PHP 8 requires PHPUnit 9.3+
9898
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '9.3');
99-
} elseif (PHP_VERSION_ID >= 70200) {
99+
} elseif (\PHP_VERSION_ID >= 70200) {
100100
// PHPUnit 8 requires PHP 7.2+
101101
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '8.3');
102-
} elseif (PHP_VERSION_ID >= 70100) {
102+
} elseif (\PHP_VERSION_ID >= 70100) {
103103
// PHPUnit 7 requires PHP 7.1+
104104
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '7.5');
105-
} elseif (PHP_VERSION_ID >= 70000) {
105+
} elseif (\PHP_VERSION_ID >= 70000) {
106106
// PHPUnit 6 requires PHP 7.0+
107107
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '6.5');
108-
} elseif (PHP_VERSION_ID >= 50600) {
108+
} elseif (\PHP_VERSION_ID >= 50600) {
109109
// PHPUnit 4 does not support PHP 7
110110
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '5.7');
111111
} else {
112112
// PHPUnit 5.1 requires PHP 5.6+
113113
$PHPUNIT_VERSION = '4.8';
114114
}
115115

116-
$PHPUNIT_REMOVE_RETURN_TYPEHINT = filter_var($getEnvVar('SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT', '0'), FILTER_VALIDATE_BOOLEAN);
116+
$PHPUNIT_REMOVE_RETURN_TYPEHINT = filter_var($getEnvVar('SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT', '0'), \FILTER_VALIDATE_BOOLEAN);
117117

118118
$COMPOSER_JSON = getenv('COMPOSER') ?: 'composer.json';
119119

@@ -127,9 +127,9 @@
127127

128128
$oldPwd = getcwd();
129129
$PHPUNIT_DIR = $getEnvVar('SYMFONY_PHPUNIT_DIR', $root.'/vendor/bin/.phpunit');
130-
$PHP = defined('PHP_BINARY') ? PHP_BINARY : 'php';
130+
$PHP = defined('PHP_BINARY') ? \PHP_BINARY : 'php';
131131
$PHP = escapeshellarg($PHP);
132-
if ('phpdbg' === PHP_SAPI) {
132+
if ('phpdbg' === \PHP_SAPI) {
133133
$PHP .= ' -qrr';
134134
}
135135

@@ -147,24 +147,24 @@
147147
}
148148

149149
$COMPOSER = file_exists($COMPOSER = $oldPwd.'/composer.phar')
150-
|| ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar`) : `which composer.phar 2> /dev/null`))
151-
|| ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer`) : `which composer 2> /dev/null`))
152-
|| 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+
|| ($COMPOSER = rtrim('\\' === \DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar`) : `which composer.phar 2> /dev/null`))
151+
|| ($COMPOSER = rtrim('\\' === \DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer`) : `which composer 2> /dev/null`))
152+
|| 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')
153153
? ('#!/usr/bin/env php' === file_get_contents($COMPOSER, false, null, 0, 18) ? $PHP : '').' '.escapeshellarg($COMPOSER) // detect shell wrappers by looking at the shebang
154154
: 'composer';
155155

156156
$SYMFONY_PHPUNIT_REMOVE = $getEnvVar('SYMFONY_PHPUNIT_REMOVE', 'phpspec/prophecy'.($PHPUNIT_VERSION < 6.0 ? ' symfony/yaml' : ''));
157-
$configurationHash = md5(implode(PHP_EOL, [md5_file(__FILE__), $SYMFONY_PHPUNIT_REMOVE, (int) $PHPUNIT_REMOVE_RETURN_TYPEHINT]));
157+
$configurationHash = md5(implode(\PHP_EOL, [md5_file(__FILE__), $SYMFONY_PHPUNIT_REMOVE, (int) $PHPUNIT_REMOVE_RETURN_TYPEHINT]));
158158
$PHPUNIT_VERSION_DIR = sprintf('phpunit-%s-%d', $PHPUNIT_VERSION, $PHPUNIT_REMOVE_RETURN_TYPEHINT);
159159
if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationHash !== @file_get_contents("$PHPUNIT_DIR/.$PHPUNIT_VERSION_DIR.md5")) {
160160
// Build a standalone phpunit without symfony/yaml nor prophecy by default
161161

162162
@mkdir($PHPUNIT_DIR, 0777, true);
163163
chdir($PHPUNIT_DIR);
164164
if (file_exists("$PHPUNIT_VERSION_DIR")) {
165-
passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s > NUL' : 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old"));
165+
passthru(sprintf('\\' === \DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s > NUL' : 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old"));
166166
rename("$PHPUNIT_VERSION_DIR", "$PHPUNIT_VERSION_DIR.old");
167-
passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s' : 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old"));
167+
passthru(sprintf('\\' === \DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s' : 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old"));
168168
}
169169

170170
$info = [];
@@ -215,23 +215,23 @@
215215
$passthruOrFail("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\"");
216216
}
217217

218-
if (preg_match('{\^((\d++\.)\d++)[\d\.]*$}', $info['requires']['php'], $phpVersion) && version_compare($phpVersion[2].'99', PHP_VERSION, '<')) {
218+
if (preg_match('{\^((\d++\.)\d++)[\d\.]*$}', $info['requires']['php'], $phpVersion) && version_compare($phpVersion[2].'99', \PHP_VERSION, '<')) {
219219
$passthruOrFail("$COMPOSER config platform.php \"$phpVersion[1].99\"");
220220
} else {
221221
$passthruOrFail("$COMPOSER config --unset platform.php");
222222
}
223223
if (file_exists($path = $root.'/vendor/symfony/phpunit-bridge')) {
224224
$passthruOrFail("$COMPOSER require --no-update symfony/phpunit-bridge \"*@dev\"");
225-
$passthruOrFail("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $path)));
226-
if ('\\' === DIRECTORY_SEPARATOR) {
225+
$passthruOrFail("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', \DIRECTORY_SEPARATOR, $path)));
226+
if ('\\' === \DIRECTORY_SEPARATOR) {
227227
file_put_contents('composer.json', preg_replace('/^( {8})"phpunit-bridge": \{$/m', "$0\n$1 ".'"options": {"symlink": false},', file_get_contents('composer.json')));
228228
}
229229
} else {
230230
$passthruOrFail("$COMPOSER require --no-update symfony/phpunit-bridge \"*\"");
231231
}
232232
$prevRoot = getenv('COMPOSER_ROOT_VERSION');
233233
putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99");
234-
$q = '\\' === DIRECTORY_SEPARATOR ? '"' : '';
234+
$q = '\\' === \DIRECTORY_SEPARATOR ? '"' : '';
235235
// --no-suggest is not in the list to keep compat with composer 1.0, which is shipped with Ubuntu 16.04LTS
236236
$exit = proc_close(proc_open("$q$COMPOSER install --no-dev --prefer-dist --no-progress $q", [], $p, getcwd()));
237237
putenv('COMPOSER_ROOT_VERSION'.(false !== $prevRoot ? '='.$prevRoot : ''));
@@ -244,12 +244,12 @@
244244
if ($PHPUNIT_REMOVE_RETURN_TYPEHINT) {
245245
$alteredCode = preg_replace('/^ ((?:protected|public)(?: static)? function \w+\(\)): void/m', ' $1', $alteredCode);
246246
}
247-
$alteredCode = preg_replace('/abstract class (?:TestCase|PHPUnit_Framework_TestCase)[^\{]+\{/', '$0 '.PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillTestCaseTrait;", $alteredCode, 1);
247+
$alteredCode = preg_replace('/abstract class (?:TestCase|PHPUnit_Framework_TestCase)[^\{]+\{/', '$0 '.\PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillTestCaseTrait;", $alteredCode, 1);
248248
file_put_contents($alteredFile, $alteredCode);
249249

250250
// Mutate Assert code
251251
$alteredCode = file_get_contents($alteredFile = './src/Framework/Assert.php');
252-
$alteredCode = preg_replace('/abstract class (?:Assert|PHPUnit_Framework_Assert)[^\{]+\{/', '$0 '.PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillAssertTrait;", $alteredCode, 1);
252+
$alteredCode = preg_replace('/abstract class (?:Assert|PHPUnit_Framework_Assert)[^\{]+\{/', '$0 '.\PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillAssertTrait;", $alteredCode, 1);
253253
file_put_contents($alteredFile, $alteredCode);
254254

255255
file_put_contents('phpunit', <<<'EOPHP'
@@ -302,7 +302,7 @@ class SymfonyExcludeListPhpunit {}
302302

303303
return false;
304304
});
305-
} elseif (filter_var(getenv('SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE'), FILTER_VALIDATE_BOOLEAN)) {
305+
} elseif (filter_var(getenv('SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE'), \FILTER_VALIDATE_BOOLEAN)) {
306306
$argv[] = '--do-not-cache-result';
307307
++$argc;
308308
}
@@ -334,7 +334,7 @@ class SymfonyExcludeListPhpunit {}
334334
$cmd[0] = sprintf('%s %s --colors=always', $PHP, escapeshellarg("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit"));
335335
$cmd = str_replace('%', '%%', implode(' ', $cmd)).' %1$s';
336336

337-
if ('\\' === DIRECTORY_SEPARATOR) {
337+
if ('\\' === \DIRECTORY_SEPARATOR) {
338338
$cmd = 'cmd /v:on /d /c "('.$cmd.')%2$s"';
339339
} else {
340340
$cmd .= '%2$s';
@@ -384,7 +384,7 @@ class SymfonyExcludeListPhpunit {}
384384
// STATUS_STACK_BUFFER_OVERRUN (-1073740791/0xC0000409)
385385
// STATUS_ACCESS_VIOLATION (-1073741819/0xC0000005)
386386
// STATUS_HEAP_CORRUPTION (-1073740940/0xC0000374)
387-
if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN) || !in_array($procStatus, [-1073740791, -1073741819, -1073740940]))) {
387+
if ($procStatus && ('\\' !== \DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN) || !in_array($procStatus, [-1073740791, -1073741819, -1073740940]))) {
388388
$exit = $procStatus;
389389
echo "\033[41mKO\033[0m $component\n\n";
390390
} else {

bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class_alias('PHPUnit_Framework_Constraint_Xor', 'PHPUnit\Framework\Constraint\Lo
115115
}
116116

117117
// Enforce a consistent locale
118-
setlocale(LC_ALL, 'C');
118+
setlocale(\LC_ALL, 'C');
119119

120120
if (!class_exists('Doctrine\Common\Annotations\AnnotationRegistry', false) && class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) {
121121
if (method_exists('Doctrine\Common\Annotations\AnnotationRegistry', 'registerUniqueLoader')) {

0 commit comments

Comments
 (0)