fix PHP 5.3 compatibility

This commit is contained in:
Christian Flothmann 2019-03-26 21:16:42 +01:00
parent 8d7e002168
commit dccf1ee354
17 changed files with 123 additions and 123 deletions

View File

@ -83,7 +83,7 @@ class ClockMock
{ {
$self = \get_called_class(); $self = \get_called_class();
$mockedNs = [substr($class, 0, strrpos($class, '\\'))]; $mockedNs = array(substr($class, 0, strrpos($class, '\\')));
if (0 < strpos($class, '\\Tests\\')) { if (0 < strpos($class, '\\Tests\\')) {
$ns = str_replace('\\Tests\\', '\\', $class); $ns = str_replace('\\Tests\\', '\\', $class);
$mockedNs[] = substr($ns, 0, strrpos($ns, '\\')); $mockedNs[] = substr($ns, 0, strrpos($ns, '\\'));

View File

@ -54,9 +54,9 @@ class DeprecationErrorHandler
if (false === $mode) { if (false === $mode) {
$mode = getenv('SYMFONY_DEPRECATIONS_HELPER'); $mode = getenv('SYMFONY_DEPRECATIONS_HELPER');
} }
if (self::MODE_DISABLED !== $mode if (DeprecationErrorHandler::MODE_DISABLED !== $mode
&& self::MODE_WEAK !== $mode && DeprecationErrorHandler::MODE_WEAK !== $mode
&& self::MODE_WEAK_VENDORS !== $mode && DeprecationErrorHandler::MODE_WEAK_VENDORS !== $mode
&& (!isset($mode[0]) || '/' !== $mode[0]) && (!isset($mode[0]) || '/' !== $mode[0])
) { ) {
$mode = preg_match('/^[1-9][0-9]*$/', $mode) ? (int) $mode : 0; $mode = preg_match('/^[1-9][0-9]*$/', $mode) ? (int) $mode : 0;
@ -92,7 +92,7 @@ class DeprecationErrorHandler
return false; return false;
}; };
$deprecations = [ $deprecations = array(
'unsilencedCount' => 0, 'unsilencedCount' => 0,
'remainingCount' => 0, 'remainingCount' => 0,
'legacyCount' => 0, 'legacyCount' => 0,
@ -103,7 +103,7 @@ class DeprecationErrorHandler
'legacy' => array(), 'legacy' => array(),
'other' => array(), 'other' => array(),
'remaining vendor' => array(), 'remaining vendor' => array(),
]; );
$deprecationHandler = function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, $getMode, $UtilPrefix, $inVendors) { $deprecationHandler = function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, $getMode, $UtilPrefix, $inVendors) {
if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || DeprecationErrorHandler::MODE_DISABLED === $mode = $getMode()) { if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || DeprecationErrorHandler::MODE_DISABLED === $mode = $getMode()) {
$ErrorHandler = $UtilPrefix.'ErrorHandler'; $ErrorHandler = $UtilPrefix.'ErrorHandler';
@ -113,7 +113,7 @@ class DeprecationErrorHandler
$trace = debug_backtrace(); $trace = debug_backtrace();
$group = 'other'; $group = 'other';
$isVendor = self::MODE_WEAK_VENDORS === $mode && $inVendors($file); $isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $inVendors($file);
$i = \count($trace); $i = \count($trace);
while (1 < $i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_') || 0 === strpos($trace[$i]['class'], 'PHPUnit\\')))) { while (1 < $i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_') || 0 === strpos($trace[$i]['class'], 'PHPUnit\\')))) {
@ -130,7 +130,7 @@ class DeprecationErrorHandler
// \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest() // \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest()
// then we need to use the serialized information to determine // then we need to use the serialized information to determine
// if the error has been triggered from vendor code. // if the error has been triggered from vendor code.
$isVendor = self::MODE_WEAK_VENDORS === $mode && isset($parsedMsg['triggering_file']) && $inVendors($parsedMsg['triggering_file']); $isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && isset($parsedMsg['triggering_file']) && $inVendors($parsedMsg['triggering_file']);
} else { } else {
$class = isset($trace[$i]['object']) ? \get_class($trace[$i]['object']) : $trace[$i]['class']; $class = isset($trace[$i]['object']) ? \get_class($trace[$i]['object']) : $trace[$i]['class'];
$method = $trace[$i]['function']; $method = $trace[$i]['function'];
@ -167,13 +167,13 @@ class DeprecationErrorHandler
exit(1); exit(1);
} }
if ('legacy' !== $group && self::MODE_WEAK !== $mode) { if ('legacy' !== $group && DeprecationErrorHandler::MODE_WEAK !== $mode) {
$ref = &$deprecations[$group][$msg]['count']; $ref = &$deprecations[$group][$msg]['count'];
++$ref; ++$ref;
$ref = &$deprecations[$group][$msg][$class.'::'.$method]; $ref = &$deprecations[$group][$msg][$class.'::'.$method];
++$ref; ++$ref;
} }
} elseif (self::MODE_WEAK !== $mode) { } elseif (DeprecationErrorHandler::MODE_WEAK !== $mode) {
$ref = &$deprecations[$group][$msg]['count']; $ref = &$deprecations[$group][$msg]['count'];
++$ref; ++$ref;
} }
@ -183,7 +183,7 @@ class DeprecationErrorHandler
if (null !== $oldErrorHandler) { if (null !== $oldErrorHandler) {
restore_error_handler(); restore_error_handler();
if ([$UtilPrefix.'ErrorHandler', 'handleError'] === $oldErrorHandler) { if (array($UtilPrefix.'ErrorHandler', 'handleError') === $oldErrorHandler) {
restore_error_handler(); restore_error_handler();
self::register($mode); self::register($mode);
} }
@ -206,7 +206,7 @@ class DeprecationErrorHandler
$currErrorHandler = set_error_handler('var_dump'); $currErrorHandler = set_error_handler('var_dump');
restore_error_handler(); restore_error_handler();
if (self::MODE_WEAK === $mode) { if (DeprecationErrorHandler::MODE_WEAK === $mode) {
$colorize = function ($str) { return $str; }; $colorize = function ($str) { return $str; };
} }
if ($currErrorHandler !== $deprecationHandler) { if ($currErrorHandler !== $deprecationHandler) {
@ -217,8 +217,8 @@ class DeprecationErrorHandler
return $b['count'] - $a['count']; return $b['count'] - $a['count'];
}; };
$groups = ['unsilenced', 'remaining']; $groups = array('unsilenced', 'remaining');
if (self::MODE_WEAK_VENDORS === $mode) { if (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode) {
$groups[] = 'remaining vendor'; $groups[] = 'remaining vendor';
} }
array_push($groups, 'legacy', 'other'); array_push($groups, 'legacy', 'other');
@ -254,11 +254,11 @@ class DeprecationErrorHandler
$displayDeprecations($deprecations); $displayDeprecations($deprecations);
// store failing status // store failing status
$isFailing = self::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']; $isFailing = DeprecationErrorHandler::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount'];
// reset deprecations array // reset deprecations array
foreach ($deprecations as $group => $arrayOrInt) { foreach ($deprecations as $group => $arrayOrInt) {
$deprecations[$group] = \is_int($arrayOrInt) ? 0 : []; $deprecations[$group] = \is_int($arrayOrInt) ? 0 : array();
} }
register_shutdown_function(function () use (&$deprecations, $isFailing, $displayDeprecations, $mode) { register_shutdown_function(function () use (&$deprecations, $isFailing, $displayDeprecations, $mode) {
@ -269,7 +269,7 @@ class DeprecationErrorHandler
} }
} }
$displayDeprecations($deprecations); $displayDeprecations($deprecations);
if ($isFailing || self::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']) { if ($isFailing || DeprecationErrorHandler::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']) {
exit(1); exit(1);
} }
}); });
@ -279,8 +279,8 @@ class DeprecationErrorHandler
public static function collectDeprecations($outputFile) public static function collectDeprecations($outputFile)
{ {
$deprecations = []; $deprecations = array();
$previousErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$deprecations, &$previousErrorHandler) { $previousErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = array()) use (&$deprecations, &$previousErrorHandler) {
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) { if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) {
if ($previousErrorHandler) { if ($previousErrorHandler) {
return $previousErrorHandler($type, $msg, $file, $line, $context); return $previousErrorHandler($type, $msg, $file, $line, $context);
@ -292,7 +292,7 @@ class DeprecationErrorHandler
return $ErrorHandler::handleError($type, $msg, $file, $line, $context); return $ErrorHandler::handleError($type, $msg, $file, $line, $context);
} }
$deprecations[] = [error_reporting(), $msg, $file]; $deprecations[] = array(error_reporting(), $msg, $file);
}); });
register_shutdown_function(function () use ($outputFile, &$deprecations) { register_shutdown_function(function () use ($outputFile, &$deprecations) {

View File

@ -16,8 +16,8 @@ namespace Symfony\Bridge\PhpUnit;
*/ */
class DnsMock class DnsMock
{ {
private static $hosts = []; private static $hosts = array();
private static $dnsTypes = [ private static $dnsTypes = array(
'A' => DNS_A, 'A' => DNS_A,
'MX' => DNS_MX, 'MX' => DNS_MX,
'NS' => DNS_NS, 'NS' => DNS_NS,
@ -30,7 +30,7 @@ class DnsMock
'NAPTR' => DNS_NAPTR, 'NAPTR' => DNS_NAPTR,
'TXT' => DNS_TXT, 'TXT' => DNS_TXT,
'HINFO' => DNS_HINFO, 'HINFO' => DNS_HINFO,
]; );
/** /**
* Configures the mock values for DNS queries. * Configures the mock values for DNS queries.
@ -68,7 +68,7 @@ class DnsMock
if (!self::$hosts) { if (!self::$hosts) {
return \getmxrr($hostname, $mxhosts, $weight); return \getmxrr($hostname, $mxhosts, $weight);
} }
$mxhosts = $weight = []; $mxhosts = $weight = array();
if (isset(self::$hosts[$hostname])) { if (isset(self::$hosts[$hostname])) {
foreach (self::$hosts[$hostname] as $record) { foreach (self::$hosts[$hostname] as $record) {
@ -125,7 +125,7 @@ class DnsMock
$ips = false; $ips = false;
if (isset(self::$hosts[$hostname])) { if (isset(self::$hosts[$hostname])) {
$ips = []; $ips = array();
foreach (self::$hosts[$hostname] as $record) { foreach (self::$hosts[$hostname] as $record) {
if ('A' === $record['type']) { if ('A' === $record['type']) {
@ -149,11 +149,11 @@ class DnsMock
if (DNS_ANY === $type) { if (DNS_ANY === $type) {
$type = DNS_ALL; $type = DNS_ALL;
} }
$records = []; $records = array();
foreach (self::$hosts[$hostname] as $record) { foreach (self::$hosts[$hostname] as $record) {
if (isset(self::$dnsTypes[$record['type']]) && (self::$dnsTypes[$record['type']] & $type)) { if (isset(self::$dnsTypes[$record['type']]) && (self::$dnsTypes[$record['type']] & $type)) {
$records[] = array_merge(['host' => $hostname, 'class' => 'IN', 'ttl' => 1, 'type' => $record['type']], $record); $records[] = array_merge(array('host' => $hostname, 'class' => 'IN', 'ttl' => 1, 'type' => $record['type']), $record);
} }
} }
} }
@ -165,7 +165,7 @@ class DnsMock
{ {
$self = \get_called_class(); $self = \get_called_class();
$mockedNs = [substr($class, 0, strrpos($class, '\\'))]; $mockedNs = array(substr($class, 0, strrpos($class, '\\')));
if (0 < strpos($class, '\\Tests\\')) { if (0 < strpos($class, '\\Tests\\')) {
$ns = str_replace('\\Tests\\', '\\', $class); $ns = str_replace('\\Tests\\', '\\', $class);
$mockedNs[] = substr($ns, 0, strrpos($ns, '\\')); $mockedNs[] = substr($ns, 0, strrpos($ns, '\\'));

View File

@ -31,7 +31,7 @@ class CoverageListenerTrait
{ {
$this->sutFqcnResolver = $sutFqcnResolver; $this->sutFqcnResolver = $sutFqcnResolver;
$this->warningOnSutNotFound = $warningOnSutNotFound; $this->warningOnSutNotFound = $warningOnSutNotFound;
$this->warnings = []; $this->warnings = array();
} }
public function startTest($test) public function startTest($test)
@ -42,7 +42,7 @@ class CoverageListenerTrait
$annotations = $test->getAnnotations(); $annotations = $test->getAnnotations();
$ignoredAnnotations = ['covers', 'coversDefaultClass', 'coversNothing']; $ignoredAnnotations = array('covers', 'coversDefaultClass', 'coversNothing');
foreach ($ignoredAnnotations as $annotation) { foreach ($ignoredAnnotations as $annotation) {
if (isset($annotations['class'][$annotation]) || isset($annotations['method'][$annotation])) { if (isset($annotations['class'][$annotation]) || isset($annotations['method'][$annotation])) {
@ -74,11 +74,11 @@ class CoverageListenerTrait
$r->setAccessible(true); $r->setAccessible(true);
$cache = $r->getValue(); $cache = $r->getValue();
$cache = array_replace_recursive($cache, [ $cache = array_replace_recursive($cache, array(
\get_class($test) => [ \get_class($test) => array(
'covers' => [$sutFqcn], 'covers' => array($sutFqcn),
], ),
]); ));
$r->setValue($testClass, $cache); $r->setValue($testClass, $cache);
} }

View File

@ -22,7 +22,7 @@ class SymfonyTestsListenerForV5 extends \PHPUnit_Framework_BaseTestListener
{ {
private $trait; private $trait;
public function __construct(array $mockedNamespaces = []) public function __construct(array $mockedNamespaces = array())
{ {
$this->trait = new SymfonyTestsListenerTrait($mockedNamespaces); $this->trait = new SymfonyTestsListenerTrait($mockedNamespaces);
} }

View File

@ -27,7 +27,7 @@ class SymfonyTestsListenerForV6 extends BaseTestListener
{ {
private $trait; private $trait;
public function __construct(array $mockedNamespaces = []) public function __construct(array $mockedNamespaces = array())
{ {
$this->trait = new SymfonyTestsListenerTrait($mockedNamespaces); $this->trait = new SymfonyTestsListenerTrait($mockedNamespaces);
} }

View File

@ -30,7 +30,7 @@ class SymfonyTestsListenerForV7 implements TestListener
private $trait; private $trait;
public function __construct(array $mockedNamespaces = []) public function __construct(array $mockedNamespaces = array())
{ {
$this->trait = new SymfonyTestsListenerTrait($mockedNamespaces); $this->trait = new SymfonyTestsListenerTrait($mockedNamespaces);
} }

View File

@ -32,10 +32,10 @@ class SymfonyTestsListenerTrait
private static $globallyEnabled = false; private static $globallyEnabled = false;
private $state = -1; private $state = -1;
private $skippedFile = false; private $skippedFile = false;
private $wasSkipped = []; private $wasSkipped = array();
private $isSkipped = []; private $isSkipped = array();
private $expectedDeprecations = []; private $expectedDeprecations = array();
private $gatheredDeprecations = []; private $gatheredDeprecations = array();
private $previousErrorHandler; private $previousErrorHandler;
private $testsWithWarnings; private $testsWithWarnings;
private $reportUselessTests; private $reportUselessTests;
@ -45,7 +45,7 @@ class SymfonyTestsListenerTrait
/** /**
* @param array $mockedNamespaces List of namespaces, indexed by mocked features (time-sensitive or dns-sensitive) * @param array $mockedNamespaces List of namespaces, indexed by mocked features (time-sensitive or dns-sensitive)
*/ */
public function __construct(array $mockedNamespaces = []) public function __construct(array $mockedNamespaces = array())
{ {
if (class_exists('PHPUnit_Util_Blacklist')) { if (class_exists('PHPUnit_Util_Blacklist')) {
\PHPUnit_Util_Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 2; \PHPUnit_Util_Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 2;
@ -57,7 +57,7 @@ class SymfonyTestsListenerTrait
foreach ($mockedNamespaces as $type => $namespaces) { foreach ($mockedNamespaces as $type => $namespaces) {
if (!\is_array($namespaces)) { if (!\is_array($namespaces)) {
$namespaces = [$namespaces]; $namespaces = array($namespaces);
} }
if ('time-sensitive' === $type) { if ('time-sensitive' === $type) {
foreach ($namespaces as $ns) { foreach ($namespaces as $ns) {
@ -104,7 +104,7 @@ class SymfonyTestsListenerTrait
$Test = 'PHPUnit\Util\Test'; $Test = 'PHPUnit\Util\Test';
} }
$suiteName = $suite->getName(); $suiteName = $suite->getName();
$this->testsWithWarnings = []; $this->testsWithWarnings = array();
foreach ($suite->tests() as $test) { foreach ($suite->tests() as $test) {
if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) { if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) {
@ -135,11 +135,11 @@ class SymfonyTestsListenerTrait
if (!$this->wasSkipped = require $this->skippedFile) { if (!$this->wasSkipped = require $this->skippedFile) {
echo "All tests already ran successfully.\n"; echo "All tests already ran successfully.\n";
$suite->setTests([]); $suite->setTests(array());
} }
} }
} }
$testSuites = [$suite]; $testSuites = array($suite);
for ($i = 0; isset($testSuites[$i]); ++$i) { for ($i = 0; isset($testSuites[$i]); ++$i) {
foreach ($testSuites[$i]->tests() as $test) { foreach ($testSuites[$i]->tests() as $test) {
if ($test instanceof \PHPUnit_Framework_TestSuite || $test instanceof TestSuite) { if ($test instanceof \PHPUnit_Framework_TestSuite || $test instanceof TestSuite) {
@ -158,7 +158,7 @@ class SymfonyTestsListenerTrait
} }
} }
} elseif (2 === $this->state) { } elseif (2 === $this->state) {
$skipped = []; $skipped = array();
foreach ($suite->tests() as $test) { foreach ($suite->tests() as $test) {
if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase) if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)
|| isset($this->wasSkipped[$suiteName]['*']) || isset($this->wasSkipped[$suiteName]['*'])
@ -230,7 +230,7 @@ class SymfonyTestsListenerTrait
$test->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything(false); $test->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything(false);
$this->expectedDeprecations = $annotations['method']['expectedDeprecation']; $this->expectedDeprecations = $annotations['method']['expectedDeprecation'];
$this->previousErrorHandler = set_error_handler([$this, 'handleError']); $this->previousErrorHandler = set_error_handler(array($this, 'handleError'));
} }
} }
} }
@ -271,8 +271,8 @@ class SymfonyTestsListenerTrait
$deprecations = file_get_contents($this->runsInSeparateProcess); $deprecations = file_get_contents($this->runsInSeparateProcess);
unlink($this->runsInSeparateProcess); unlink($this->runsInSeparateProcess);
putenv('SYMFONY_DEPRECATIONS_SERIALIZE'); putenv('SYMFONY_DEPRECATIONS_SERIALIZE');
foreach ($deprecations ? unserialize($deprecations) : [] as $deprecation) { foreach ($deprecations ? unserialize($deprecations) : array() as $deprecation) {
$error = serialize(['deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => isset($deprecation[2]) ? $deprecation[2] : null]); $error = serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => isset($deprecation[2]) ? $deprecation[2] : null));
if ($deprecation[0]) { if ($deprecation[0]) {
@trigger_error($error, E_USER_DEPRECATED); @trigger_error($error, E_USER_DEPRECATED);
} else { } else {
@ -283,13 +283,13 @@ class SymfonyTestsListenerTrait
} }
if ($this->expectedDeprecations) { if ($this->expectedDeprecations) {
if (!\in_array($test->getStatus(), [$BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE], true)) { if (!\in_array($test->getStatus(), array($BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE), true)) {
$test->addToAssertionCount(\count($this->expectedDeprecations)); $test->addToAssertionCount(\count($this->expectedDeprecations));
} }
restore_error_handler(); restore_error_handler();
if (!$errored && !\in_array($test->getStatus(), [$BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE, $BaseTestRunner::STATUS_FAILURE, $BaseTestRunner::STATUS_ERROR], true)) { if (!$errored && !\in_array($test->getStatus(), array($BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE, $BaseTestRunner::STATUS_FAILURE, $BaseTestRunner::STATUS_ERROR), true)) {
try { try {
$prefix = "@expectedDeprecation:\n"; $prefix = "@expectedDeprecation:\n";
$test->assertStringMatchesFormat($prefix.'%A '.implode("\n%A ", $this->expectedDeprecations)."\n%A", $prefix.' '.implode("\n ", $this->gatheredDeprecations)."\n"); $test->assertStringMatchesFormat($prefix.'%A '.implode("\n%A ", $this->expectedDeprecations)."\n%A", $prefix.' '.implode("\n ", $this->gatheredDeprecations)."\n");
@ -300,7 +300,7 @@ class SymfonyTestsListenerTrait
} }
} }
$this->expectedDeprecations = $this->gatheredDeprecations = []; $this->expectedDeprecations = $this->gatheredDeprecations = array();
$this->previousErrorHandler = null; $this->previousErrorHandler = null;
} }
if (!$this->runsInSeparateProcess && -2 < $this->state && ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) { if (!$this->runsInSeparateProcess && -2 < $this->state && ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) {
@ -308,12 +308,12 @@ class SymfonyTestsListenerTrait
ClockMock::withClockMock(false); ClockMock::withClockMock(false);
} }
if (\in_array('dns-sensitive', $groups, true)) { if (\in_array('dns-sensitive', $groups, true)) {
DnsMock::withMockedHosts([]); DnsMock::withMockedHosts(array());
} }
} }
} }
public function handleError($type, $msg, $file, $line, $context = []) public function handleError($type, $msg, $file, $line, $context = array())
{ {
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) { if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) {
$h = $this->previousErrorHandler; $h = $this->previousErrorHandler;

View File

@ -27,7 +27,7 @@ class TestRunnerForV5 extends \PHPUnit_TextUI_TestRunner
$result = parent::handleConfiguration($arguments); $result = parent::handleConfiguration($arguments);
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : []; $arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
$registeredLocally = false; $registeredLocally = false;

View File

@ -30,7 +30,7 @@ class TestRunnerForV6 extends BaseRunner
parent::handleConfiguration($arguments); parent::handleConfiguration($arguments);
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : []; $arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
$registeredLocally = false; $registeredLocally = false;

View File

@ -30,7 +30,7 @@ class TestRunnerForV7 extends BaseRunner
parent::handleConfiguration($arguments); parent::handleConfiguration($arguments);
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : []; $arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
$registeredLocally = false; $registeredLocally = false;

View File

@ -25,7 +25,7 @@ class Test
{ {
public static function getGroups() public static function getGroups()
{ {
return []; return array();
} }
} }
EOPHP EOPHP
@ -35,7 +35,7 @@ class PHPUnit_Util_Test
{ {
public static function getGroups() public static function getGroups()
{ {
return []; return array();
} }
} }

View File

@ -7,7 +7,7 @@ class Test
{ {
public static function getGroups() public static function getGroups()
{ {
return []; return array();
} }
} }
EOPHP EOPHP

View File

@ -25,7 +25,7 @@ class Test
{ {
public static function getGroups() public static function getGroups()
{ {
return []; return array();
} }
} }
EOPHP EOPHP
@ -35,7 +35,7 @@ class PHPUnit_Util_Test
{ {
public static function getGroups() public static function getGroups()
{ {
return []; return array();
} }
} }

View File

@ -25,7 +25,7 @@ class Test
{ {
public static function getGroups() public static function getGroups()
{ {
return []; return array();
} }
} }
EOPHP EOPHP

View File

@ -18,15 +18,15 @@ class DnsMockTest extends TestCase
{ {
protected function tearDown() protected function tearDown()
{ {
DnsMock::withMockedHosts([]); DnsMock::withMockedHosts(array());
} }
public function testCheckdnsrr() public function testCheckdnsrr()
{ {
DnsMock::withMockedHosts(['example.com' => [['type' => 'MX']]]); DnsMock::withMockedHosts(array('example.com' => array(array('type' => 'MX'))));
$this->assertTrue(DnsMock::checkdnsrr('example.com')); $this->assertTrue(DnsMock::checkdnsrr('example.com'));
DnsMock::withMockedHosts(['example.com' => [['type' => 'A']]]); DnsMock::withMockedHosts(array('example.com' => array(array('type' => 'A'))));
$this->assertFalse(DnsMock::checkdnsrr('example.com')); $this->assertFalse(DnsMock::checkdnsrr('example.com'));
$this->assertTrue(DnsMock::checkdnsrr('example.com', 'a')); $this->assertTrue(DnsMock::checkdnsrr('example.com', 'a'));
$this->assertTrue(DnsMock::checkdnsrr('example.com', 'any')); $this->assertTrue(DnsMock::checkdnsrr('example.com', 'any'));
@ -35,34 +35,34 @@ class DnsMockTest extends TestCase
public function testGetmxrr() public function testGetmxrr()
{ {
DnsMock::withMockedHosts([ DnsMock::withMockedHosts(array(
'example.com' => [[ 'example.com' => array(array(
'type' => 'MX', 'type' => 'MX',
'host' => 'mx.example.com', 'host' => 'mx.example.com',
'pri' => 10, 'pri' => 10,
]], )),
]); ));
$this->assertFalse(DnsMock::getmxrr('foobar.com', $mxhosts, $weight)); $this->assertFalse(DnsMock::getmxrr('foobar.com', $mxhosts, $weight));
$this->assertTrue(DnsMock::getmxrr('example.com', $mxhosts, $weight)); $this->assertTrue(DnsMock::getmxrr('example.com', $mxhosts, $weight));
$this->assertSame(['mx.example.com'], $mxhosts); $this->assertSame(array('mx.example.com'), $mxhosts);
$this->assertSame([10], $weight); $this->assertSame(array(10), $weight);
} }
public function testGethostbyaddr() public function testGethostbyaddr()
{ {
DnsMock::withMockedHosts([ DnsMock::withMockedHosts(array(
'example.com' => [ 'example.com' => array(
[ array(
'type' => 'A', 'type' => 'A',
'ip' => '1.2.3.4', 'ip' => '1.2.3.4',
], ),
[ array(
'type' => 'AAAA', 'type' => 'AAAA',
'ipv6' => '::12', 'ipv6' => '::12',
], ),
], ),
]); ));
$this->assertSame('::21', DnsMock::gethostbyaddr('::21')); $this->assertSame('::21', DnsMock::gethostbyaddr('::21'));
$this->assertSame('example.com', DnsMock::gethostbyaddr('::12')); $this->assertSame('example.com', DnsMock::gethostbyaddr('::12'));
@ -71,18 +71,18 @@ class DnsMockTest extends TestCase
public function testGethostbyname() public function testGethostbyname()
{ {
DnsMock::withMockedHosts([ DnsMock::withMockedHosts(array(
'example.com' => [ 'example.com' => array(
[ array(
'type' => 'AAAA', 'type' => 'AAAA',
'ipv6' => '::12', 'ipv6' => '::12',
], ),
[ array(
'type' => 'A', 'type' => 'A',
'ip' => '1.2.3.4', 'ip' => '1.2.3.4',
], ),
], ),
]); ));
$this->assertSame('foobar.com', DnsMock::gethostbyname('foobar.com')); $this->assertSame('foobar.com', DnsMock::gethostbyname('foobar.com'));
$this->assertSame('1.2.3.4', DnsMock::gethostbyname('example.com')); $this->assertSame('1.2.3.4', DnsMock::gethostbyname('example.com'));
@ -90,59 +90,59 @@ class DnsMockTest extends TestCase
public function testGethostbynamel() public function testGethostbynamel()
{ {
DnsMock::withMockedHosts([ DnsMock::withMockedHosts(array(
'example.com' => [ 'example.com' => array(
[ array(
'type' => 'A', 'type' => 'A',
'ip' => '1.2.3.4', 'ip' => '1.2.3.4',
], ),
[ array(
'type' => 'A', 'type' => 'A',
'ip' => '2.3.4.5', 'ip' => '2.3.4.5',
], ),
], ),
]); ));
$this->assertFalse(DnsMock::gethostbynamel('foobar.com')); $this->assertFalse(DnsMock::gethostbynamel('foobar.com'));
$this->assertSame(['1.2.3.4', '2.3.4.5'], DnsMock::gethostbynamel('example.com')); $this->assertSame(array('1.2.3.4', '2.3.4.5'), DnsMock::gethostbynamel('example.com'));
} }
public function testDnsGetRecord() public function testDnsGetRecord()
{ {
DnsMock::withMockedHosts([ DnsMock::withMockedHosts(array(
'example.com' => [ 'example.com' => array(
[ array(
'type' => 'A', 'type' => 'A',
'ip' => '1.2.3.4', 'ip' => '1.2.3.4',
], ),
[ array(
'type' => 'PTR', 'type' => 'PTR',
'ip' => '2.3.4.5', 'ip' => '2.3.4.5',
], ),
], ),
]); ));
$records = [ $records = array(
[ array(
'host' => 'example.com', 'host' => 'example.com',
'class' => 'IN', 'class' => 'IN',
'ttl' => 1, 'ttl' => 1,
'type' => 'A', 'type' => 'A',
'ip' => '1.2.3.4', 'ip' => '1.2.3.4',
], ),
$ptr = [ $ptr = array(
'host' => 'example.com', 'host' => 'example.com',
'class' => 'IN', 'class' => 'IN',
'ttl' => 1, 'ttl' => 1,
'type' => 'PTR', 'type' => 'PTR',
'ip' => '2.3.4.5', 'ip' => '2.3.4.5',
], ),
]; );
$this->assertFalse(DnsMock::dns_get_record('foobar.com')); $this->assertFalse(DnsMock::dns_get_record('foobar.com'));
$this->assertSame($records, DnsMock::dns_get_record('example.com')); $this->assertSame($records, DnsMock::dns_get_record('example.com'));
$this->assertSame($records, DnsMock::dns_get_record('example.com', DNS_ALL)); $this->assertSame($records, DnsMock::dns_get_record('example.com', DNS_ALL));
$this->assertSame($records, DnsMock::dns_get_record('example.com', DNS_A | DNS_PTR)); $this->assertSame($records, DnsMock::dns_get_record('example.com', DNS_A | DNS_PTR));
$this->assertSame([$ptr], DnsMock::dns_get_record('example.com', DNS_PTR)); $this->assertSame(array($ptr), DnsMock::dns_get_record('example.com', DNS_PTR));
} }
} }

View File

@ -124,7 +124,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
$prevRoot = getenv('COMPOSER_ROOT_VERSION'); $prevRoot = getenv('COMPOSER_ROOT_VERSION');
putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99"); putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99");
// --no-suggest is not in the list to keep compat with composer 1.0, which is shipped with Ubuntu 16.04LTS // --no-suggest is not in the list to keep compat with composer 1.0, which is shipped with Ubuntu 16.04LTS
$exit = proc_close(proc_open("$COMPOSER install --no-dev --prefer-dist --no-progress --ansi", [], $p, getcwd(), null, ['bypass_shell' => true])); $exit = proc_close(proc_open("$COMPOSER install --no-dev --prefer-dist --no-progress --ansi", array(), $p, getcwd(), null, array('bypass_shell' => true)));
putenv('COMPOSER_ROOT_VERSION'.(false !== $prevRoot ? '='.$prevRoot : '')); putenv('COMPOSER_ROOT_VERSION'.(false !== $prevRoot ? '='.$prevRoot : ''));
if ($exit) { if ($exit) {
exit($exit); exit($exit);
@ -157,9 +157,9 @@ EOPHP
} }
global $argv, $argc; global $argv, $argc;
$argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : []; $argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : array();
$argc = isset($_SERVER['argc']) ? $_SERVER['argc'] : 0; $argc = isset($_SERVER['argc']) ? $_SERVER['argc'] : 0;
$components = []; $components = array();
$cmd = array_map('escapeshellarg', $argv); $cmd = array_map('escapeshellarg', $argv);
$exit = 0; $exit = 0;
@ -194,7 +194,7 @@ if ('\\' === DIRECTORY_SEPARATOR) {
if ($components) { if ($components) {
$skippedTests = isset($_SERVER['SYMFONY_PHPUNIT_SKIPPED_TESTS']) ? $_SERVER['SYMFONY_PHPUNIT_SKIPPED_TESTS'] : false; $skippedTests = isset($_SERVER['SYMFONY_PHPUNIT_SKIPPED_TESTS']) ? $_SERVER['SYMFONY_PHPUNIT_SKIPPED_TESTS'] : false;
$runningProcs = []; $runningProcs = array();
foreach ($components as $component) { foreach ($components as $component) {
// Run phpunit tests in parallel // Run phpunit tests in parallel
@ -205,7 +205,7 @@ if ($components) {
$c = escapeshellarg($component); $c = escapeshellarg($component);
if ($proc = proc_open(sprintf($cmd, $c, " > $c/phpunit.stdout 2> $c/phpunit.stderr"), [], $pipes)) { if ($proc = proc_open(sprintf($cmd, $c, " > $c/phpunit.stdout 2> $c/phpunit.stderr"), array(), $pipes)) {
$runningProcs[$component] = $proc; $runningProcs[$component] = $proc;
} else { } else {
$exit = 1; $exit = 1;
@ -215,7 +215,7 @@ if ($components) {
while ($runningProcs) { while ($runningProcs) {
usleep(300000); usleep(300000);
$terminatedProcs = []; $terminatedProcs = array();
foreach ($runningProcs as $component => $proc) { foreach ($runningProcs as $component => $proc) {
$procStatus = proc_get_status($proc); $procStatus = proc_get_status($proc);
if (!$procStatus['running']) { if (!$procStatus['running']) {
@ -226,7 +226,7 @@ if ($components) {
} }
foreach ($terminatedProcs as $component => $procStatus) { foreach ($terminatedProcs as $component => $procStatus) {
foreach (['out', 'err'] as $file) { foreach (array('out', 'err') as $file) {
$file = "$component/phpunit.std$file"; $file = "$component/phpunit.std$file";
readfile($file); readfile($file);
unlink($file); unlink($file);
@ -236,7 +236,7 @@ if ($components) {
// STATUS_STACK_BUFFER_OVERRUN (-1073740791/0xC0000409) // STATUS_STACK_BUFFER_OVERRUN (-1073740791/0xC0000409)
// STATUS_ACCESS_VIOLATION (-1073741819/0xC0000005) // STATUS_ACCESS_VIOLATION (-1073741819/0xC0000005)
// STATUS_HEAP_CORRUPTION (-1073740940/0xC0000374) // STATUS_HEAP_CORRUPTION (-1073740940/0xC0000374)
if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN) || !in_array($procStatus, [-1073740791, -1073741819, -1073740940]))) { if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN) || !in_array($procStatus, array(-1073740791, -1073741819, -1073740940)))) {
$exit = $procStatus; $exit = $procStatus;
echo "\033[41mKO\033[0m $component\n\n"; echo "\033[41mKO\033[0m $component\n\n";
} else { } else {
@ -248,7 +248,7 @@ if ($components) {
if (!class_exists('SymfonyBlacklistSimplePhpunit', false)) { if (!class_exists('SymfonyBlacklistSimplePhpunit', false)) {
class SymfonyBlacklistSimplePhpunit {} class SymfonyBlacklistSimplePhpunit {}
} }
array_splice($argv, 1, 0, ['--colors=always']); array_splice($argv, 1, 0, array('--colors=always'));
$_SERVER['argv'] = $argv; $_SERVER['argv'] = $argv;
$_SERVER['argc'] = ++$argc; $_SERVER['argc'] = ++$argc;
include "$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit"; include "$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit";