Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. GlobalState.php

function GlobalState::getGlobalsAsString

1 call to GlobalState::getGlobalsAsString()
TestRunner::runInSeparateProcess in vendor/phpunit/phpunit/src/Framework/TestRunner.php

File

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

Class

GlobalState
@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit

Namespace

PHPUnit\Util

Code

public static function getGlobalsAsString() : string {
    $result = '';
    foreach (self::SUPER_GLOBAL_ARRAYS 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]));
            }
        }
    }
    $excludeList = self::SUPER_GLOBAL_ARRAYS;
    $excludeList[] = 'GLOBALS';
    foreach (array_keys($GLOBALS) as $key) {
        if (!$GLOBALS[$key] instanceof Closure && !in_array($key, $excludeList, true)) {
            $result .= sprintf('$GLOBALS[\'%s\'] = %s;' . "\n", $key, self::exportVariable($GLOBALS[$key]));
        }
    }
    return $result;
}
RSS feed
Powered by Drupal