Skip to content

Commit dc88ebb

Browse files
Merge branch '2.8' into 3.4
* 2.8: Fix Clidumper tests Enable the fixer enforcing fully-qualified calls for compiler-optimized functions Apply fixers Disable the native_constant_invocation fixer until it can be scoped Update the list of excluded files for the CS fixer
2 parents 62c8349 + fe3fca1 commit dc88ebb

File tree

6 files changed

+49
-49
lines changed

6 files changed

+49
-49
lines changed

ClockMock.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static function microtime($asFloat = false)
7171

7272
public static function register($class)
7373
{
74-
$self = get_called_class();
74+
$self = \get_called_class();
7575

7676
$mockedNs = array(substr($class, 0, strrpos($class, '\\')));
7777
if (0 < strpos($class, '\\Tests\\')) {
@@ -81,7 +81,7 @@ public static function register($class)
8181
$mockedNs[] = substr($class, 6, strrpos($class, '\\') - 6);
8282
}
8383
foreach ($mockedNs as $ns) {
84-
if (function_exists($ns.'\time')) {
84+
if (\function_exists($ns.'\time')) {
8585
continue;
8686
}
8787
eval(<<<EOPHP

DeprecationErrorHandler.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static function register($mode = 0)
6868
foreach (get_declared_classes() as $class) {
6969
if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {
7070
$r = new \ReflectionClass($class);
71-
$v = dirname(dirname($r->getFileName()));
71+
$v = \dirname(\dirname($r->getFileName()));
7272
if (file_exists($v.'/composer/installed.json')) {
7373
$vendors[] = $v;
7474
}
@@ -80,7 +80,7 @@ public static function register($mode = 0)
8080
return true;
8181
}
8282
foreach ($vendors as $vendor) {
83-
if (0 === strpos($realPath, $vendor) && false !== strpbrk(substr($realPath, strlen($vendor), 1), '/'.DIRECTORY_SEPARATOR)) {
83+
if (0 === strpos($realPath, $vendor) && false !== strpbrk(substr($realPath, \strlen($vendor), 1), '/'.DIRECTORY_SEPARATOR)) {
8484
return true;
8585
}
8686
}
@@ -112,7 +112,7 @@ public static function register($mode = 0)
112112
$group = 'other';
113113
$isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $inVendors($file);
114114

115-
$i = count($trace);
115+
$i = \count($trace);
116116
while (1 < $i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_') || 0 === strpos($trace[$i]['class'], 'PHPUnit\\')))) {
117117
// No-op
118118
}
@@ -129,7 +129,7 @@ public static function register($mode = 0)
129129
// if the error has been triggered from vendor code.
130130
$isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && isset($parsedMsg['triggering_file']) && $inVendors($parsedMsg['triggering_file']);
131131
} else {
132-
$class = isset($trace[$i]['object']) ? get_class($trace[$i]['object']) : $trace[$i]['class'];
132+
$class = isset($trace[$i]['object']) ? \get_class($trace[$i]['object']) : $trace[$i]['class'];
133133
$method = $trace[$i]['function'];
134134
}
135135

@@ -141,7 +141,7 @@ public static function register($mode = 0)
141141
|| 0 === strpos($method, 'provideLegacy')
142142
|| 0 === strpos($method, 'getLegacy')
143143
|| strpos($class, '\Legacy')
144-
|| in_array('legacy', $Test::getGroups($class, $method), true)
144+
|| \in_array('legacy', $Test::getGroups($class, $method), true)
145145
) {
146146
$group = 'legacy';
147147
} elseif ($isVendor) {
@@ -154,7 +154,7 @@ public static function register($mode = 0)
154154
$e = new \Exception($msg);
155155
$r = new \ReflectionProperty($e, 'trace');
156156
$r->setAccessible(true);
157-
$r->setValue($e, array_slice($trace, 1, $i));
157+
$r->setValue($e, \array_slice($trace, 1, $i));
158158

159159
echo "\n".ucfirst($group).' deprecation triggered by '.$class.'::'.$method.':';
160160
echo "\n".$msg;
@@ -255,12 +255,12 @@ public static function register($mode = 0)
255255

256256
// reset deprecations array
257257
foreach ($deprecations as $group => $arrayOrInt) {
258-
$deprecations[$group] = is_int($arrayOrInt) ? 0 : array();
258+
$deprecations[$group] = \is_int($arrayOrInt) ? 0 : array();
259259
}
260260

261261
register_shutdown_function(function () use (&$deprecations, $isFailing, $displayDeprecations, $mode) {
262262
foreach ($deprecations as $group => $arrayOrInt) {
263-
if (0 < (is_int($arrayOrInt) ? $arrayOrInt : count($arrayOrInt))) {
263+
if (0 < (\is_int($arrayOrInt) ? $arrayOrInt : \count($arrayOrInt))) {
264264
echo "Shutdown-time deprecations:\n";
265265
break;
266266
}
@@ -307,7 +307,7 @@ public static function collectDeprecations($outputFile)
307307
*/
308308
private static function hasColorSupport()
309309
{
310-
if (!defined('STDOUT')) {
310+
if (!\defined('STDOUT')) {
311311
return false;
312312
}
313313

@@ -316,18 +316,18 @@ private static function hasColorSupport()
316316
}
317317

318318
if (DIRECTORY_SEPARATOR === '\\') {
319-
return (function_exists('sapi_windows_vt100_support')
319+
return (\function_exists('sapi_windows_vt100_support')
320320
&& sapi_windows_vt100_support(STDOUT))
321321
|| false !== getenv('ANSICON')
322322
|| 'ON' === getenv('ConEmuANSI')
323323
|| 'xterm' === getenv('TERM');
324324
}
325325

326-
if (function_exists('stream_isatty')) {
326+
if (\function_exists('stream_isatty')) {
327327
return stream_isatty(STDOUT);
328328
}
329329

330-
if (function_exists('posix_isatty')) {
330+
if (\function_exists('posix_isatty')) {
331331
return posix_isatty(STDOUT);
332332
}
333333

DnsMock.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public static function dns_get_record($hostname, $type = DNS_ANY, &$authns = nul
163163

164164
public static function register($class)
165165
{
166-
$self = get_called_class();
166+
$self = \get_called_class();
167167

168168
$mockedNs = array(substr($class, 0, strrpos($class, '\\')));
169169
if (0 < strpos($class, '\\Tests\\')) {
@@ -173,7 +173,7 @@ public static function register($class)
173173
$mockedNs[] = substr($class, 6, strrpos($class, '\\') - 6);
174174
}
175175
foreach ($mockedNs as $ns) {
176-
if (function_exists($ns.'\checkdnsrr')) {
176+
if (\function_exists($ns.'\checkdnsrr')) {
177177
continue;
178178
}
179179
eval(<<<EOPHP

Legacy/CoverageListenerTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function startTest($test)
5858
if (method_exists($test->getTestResultObject(), 'addWarning') && class_exists(Warning::class)) {
5959
$test->getTestResultObject()->addWarning($test, new Warning($message), 0);
6060
} else {
61-
$this->warnings[] = sprintf("%s::%s\n%s", get_class($test), $test->getName(), $message);
61+
$this->warnings[] = sprintf("%s::%s\n%s", \get_class($test), $test->getName(), $message);
6262
}
6363
}
6464

@@ -75,7 +75,7 @@ public function startTest($test)
7575

7676
$cache = $r->getValue();
7777
$cache = array_replace_recursive($cache, array(
78-
get_class($test) => array(
78+
\get_class($test) => array(
7979
'covers' => array($sutFqcn),
8080
),
8181
));
@@ -90,7 +90,7 @@ private function findSutFqcn($test)
9090
return $resolver($test);
9191
}
9292

93-
$class = get_class($test);
93+
$class = \get_class($test);
9494

9595
$sutFqcn = str_replace('\\Tests\\', '\\', $class);
9696
$sutFqcn = preg_replace('{Test$}', '', $sutFqcn);

Legacy/SymfonyTestsListenerTrait.php

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ public function __construct(array $mockedNamespaces = array())
5454

5555
$warn = false;
5656
foreach ($mockedNamespaces as $type => $namespaces) {
57-
if (!is_array($namespaces)) {
57+
if (!\is_array($namespaces)) {
5858
$namespaces = array($namespaces);
5959
}
60-
if (is_int($type)) {
60+
if (\is_int($type)) {
6161
// @deprecated BC with v2.8 to v3.0
6262
$type = 'time-sensitive';
6363
$warn = true;
@@ -107,10 +107,10 @@ public function startTestSuite($suite)
107107
$this->testsWithWarnings = array();
108108

109109
foreach ($suite->tests() as $test) {
110-
if (!($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) {
110+
if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) {
111111
continue;
112112
}
113-
if (null === $Test::getPreserveGlobalStateSettings(get_class($test), $test->getName(false))) {
113+
if (null === $Test::getPreserveGlobalStateSettings(\get_class($test), $test->getName(false))) {
114114
$test->setPreserveGlobalState(false);
115115
}
116116
}
@@ -148,10 +148,10 @@ public function startTestSuite($suite)
148148
continue;
149149
}
150150
$groups = $Test::getGroups($test->getName());
151-
if (in_array('time-sensitive', $groups, true)) {
151+
if (\in_array('time-sensitive', $groups, true)) {
152152
ClockMock::register($test->getName());
153153
}
154-
if (in_array('dns-sensitive', $groups, true)) {
154+
if (\in_array('dns-sensitive', $groups, true)) {
155155
DnsMock::register($test->getName());
156156
}
157157
}
@@ -160,7 +160,7 @@ public function startTestSuite($suite)
160160
} elseif (2 === $this->state) {
161161
$skipped = array();
162162
foreach ($suite->tests() as $test) {
163-
if (!($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)
163+
if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)
164164
|| isset($this->wasSkipped[$suiteName]['*'])
165165
|| isset($this->wasSkipped[$suiteName][$test->getName()])) {
166166
$skipped[] = $test;
@@ -173,8 +173,8 @@ public function startTestSuite($suite)
173173
public function addSkippedTest($test, \Exception $e, $time)
174174
{
175175
if (0 < $this->state) {
176-
if ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase) {
177-
$class = get_class($test);
176+
if ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase) {
177+
$class = \get_class($test);
178178
$method = $test->getName();
179179
} else {
180180
$class = $test->getName();
@@ -187,7 +187,7 @@ public function addSkippedTest($test, \Exception $e, $time)
187187

188188
public function startTest($test)
189189
{
190-
if (-2 < $this->state && ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) {
190+
if (-2 < $this->state && ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) {
191191
if (null !== $test->getTestResultObject()) {
192192
$this->reportUselessTests = $test->getTestResultObject()->isStrictAboutTestsThatDoNotTestAnything();
193193
}
@@ -205,25 +205,25 @@ public function startTest($test)
205205
$Test = 'PHPUnit\Util\Test';
206206
$AssertionFailedError = 'PHPUnit\Framework\AssertionFailedError';
207207
}
208-
$groups = $Test::getGroups(get_class($test), $test->getName(false));
208+
$groups = $Test::getGroups(\get_class($test), $test->getName(false));
209209

210210
if (!$this->runsInSeparateProcess) {
211-
if (in_array('time-sensitive', $groups, true)) {
212-
ClockMock::register(get_class($test));
211+
if (\in_array('time-sensitive', $groups, true)) {
212+
ClockMock::register(\get_class($test));
213213
ClockMock::withClockMock(true);
214214
}
215-
if (in_array('dns-sensitive', $groups, true)) {
216-
DnsMock::register(get_class($test));
215+
if (\in_array('dns-sensitive', $groups, true)) {
216+
DnsMock::register(\get_class($test));
217217
}
218218
}
219219

220-
$annotations = $Test::parseTestMethodAnnotations(get_class($test), $test->getName(false));
220+
$annotations = $Test::parseTestMethodAnnotations(\get_class($test), $test->getName(false));
221221

222222
if (isset($annotations['class']['expectedDeprecation'])) {
223223
$test->getTestResultObject()->addError($test, new $AssertionFailedError('`@expectedDeprecation` annotations are not allowed at the class level.'), 0);
224224
}
225225
if (isset($annotations['method']['expectedDeprecation'])) {
226-
if (!in_array('legacy', $groups, true)) {
226+
if (!\in_array('legacy', $groups, true)) {
227227
$this->error = new $AssertionFailedError('Only tests with the `@group legacy` annotation can have `@expectedDeprecation`.');
228228
}
229229

@@ -237,7 +237,7 @@ public function startTest($test)
237237

238238
public function addWarning($test, $e, $time)
239239
{
240-
if ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase) {
240+
if ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase) {
241241
$this->testsWithWarnings[$test->getName()] = true;
242242
}
243243
}
@@ -253,7 +253,7 @@ public function endTest($test, $time)
253253
$BaseTestRunner = 'PHPUnit\Runner\BaseTestRunner';
254254
$Warning = 'PHPUnit\Framework\Warning';
255255
}
256-
$className = get_class($test);
256+
$className = \get_class($test);
257257
$classGroups = $Test::getGroups($className);
258258
$groups = $Test::getGroups($className, $test->getName(false));
259259

@@ -274,7 +274,7 @@ public function endTest($test, $time)
274274
foreach ($deprecations ? unserialize($deprecations) : array() as $deprecation) {
275275
$error = serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => isset($deprecation[2]) ? $deprecation[2] : null));
276276
if ($deprecation[0]) {
277-
trigger_error($error, E_USER_DEPRECATED);
277+
@trigger_error($error, E_USER_DEPRECATED);
278278
} else {
279279
@trigger_error($error, E_USER_DEPRECATED);
280280
}
@@ -283,13 +283,13 @@ public function endTest($test, $time)
283283
}
284284

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

290290
restore_error_handler();
291291

292-
if (!$errored && !in_array($test->getStatus(), array($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");
@@ -303,24 +303,24 @@ public function endTest($test, $time)
303303
$this->expectedDeprecations = $this->gatheredDeprecations = array();
304304
$this->previousErrorHandler = null;
305305
}
306-
if (!$this->runsInSeparateProcess && -2 < $this->state && ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) {
307-
if (in_array('time-sensitive', $groups, true)) {
306+
if (!$this->runsInSeparateProcess && -2 < $this->state && ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) {
307+
if (\in_array('time-sensitive', $groups, true)) {
308308
ClockMock::withClockMock(false);
309309
}
310-
if (in_array('dns-sensitive', $groups, true)) {
310+
if (\in_array('dns-sensitive', $groups, true)) {
311311
DnsMock::withMockedHosts(array());
312312
}
313313
}
314314

315-
if (($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase) && 0 === strpos($test->getName(), 'testLegacy') && !isset($this->testsWithWarnings[$test->getName()]) && !in_array('legacy', $groups, true)) {
315+
if (($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase) && 0 === strpos($test->getName(), 'testLegacy') && !isset($this->testsWithWarnings[$test->getName()]) && !\in_array('legacy', $groups, true)) {
316316
$result = $test->getTestResultObject();
317317

318318
if (method_exists($result, 'addWarning')) {
319319
$result->addWarning($test, new $Warning('Using the "testLegacy" prefix to mark tests as legacy is deprecated since version 3.3 and will be removed in 4.0. Use the "@group legacy" notation instead to add the test to the legacy group.'), $time);
320320
}
321321
}
322322

323-
if (($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase) && strpos($className, '\Legacy') && !isset($this->testsWithWarnings[$test->getName()]) && !in_array('legacy', $classGroups, true)) {
323+
if (($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase) && strpos($className, '\Legacy') && !isset($this->testsWithWarnings[$test->getName()]) && !\in_array('legacy', $classGroups, true)) {
324324
$result = $test->getTestResultObject();
325325

326326
if (method_exists($result, 'addWarning')) {
@@ -339,7 +339,7 @@ public function handleError($type, $msg, $file, $line, $context = array())
339339
// If the message is serialized we need to extract the message. This occurs when the error is triggered by
340340
// by the isolated test path in \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest().
341341
$parsedMsg = @unserialize($msg);
342-
if (is_array($parsedMsg)) {
342+
if (\is_array($parsedMsg)) {
343343
$msg = $parsedMsg['deprecation'];
344344
}
345345
if (error_reporting()) {

Tests/CoverageListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function test()
1212
$this->markTestSkipped('This test cannot be run on Windows.');
1313
}
1414

15-
if (defined('HHVM_VERSION')) {
15+
if (\defined('HHVM_VERSION')) {
1616
$this->markTestSkipped('This test cannot be run on HHVM.');
1717
}
1818

0 commit comments

Comments
 (0)