You are here

public static function PHPUnit_Util_GlobalState::getGlobalsAsString in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/src/Util/GlobalState.php \PHPUnit_Util_GlobalState::getGlobalsAsString()
1 call to PHPUnit_Util_GlobalState::getGlobalsAsString()
PHPUnit_Framework_TestCase::run in vendor/phpunit/phpunit/src/Framework/TestCase.php
Runs the test case and collects the results in a TestResult object. If no TestResult object is passed a new one will be created.

File

vendor/phpunit/phpunit/src/Util/GlobalState.php, line 111

Class

PHPUnit_Util_GlobalState
@since Class available since Release 3.4.0

Code

public static function getGlobalsAsString() {
  $result = '';
  $superGlobalArrays = self::getSuperGlobalArrays();
  foreach ($superGlobalArrays as $superGlobalArray) {
    if (isset($GLOBALS[$superGlobalArray]) && is_array($GLOBALS[$superGlobalArray])) {
      foreach (array_keys($GLOBALS[$superGlobalArray]) as $key) {
        if ($GLOBALS[$superGlobalArray][$key] instanceof Closure) {
          continue;
        }
        $result .= sprintf('$GLOBALS[\'%s\'][\'%s\'] = %s;' . "\n", $superGlobalArray, $key, self::exportVariable($GLOBALS[$superGlobalArray][$key]));
      }
    }
  }
  $blacklist = $superGlobalArrays;
  $blacklist[] = 'GLOBALS';
  foreach (array_keys($GLOBALS) as $key) {
    if (!in_array($key, $blacklist) && !$GLOBALS[$key] instanceof Closure) {
      $result .= sprintf('$GLOBALS[\'%s\'] = %s;' . "\n", $key, self::exportVariable($GLOBALS[$key]));
    }
  }
  return $result;
}