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

Breadcrumb

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

function CodeExporter::globalVariables

File

vendor/sebastian/global-state/src/CodeExporter.php, line 37

Class

CodeExporter

Namespace

SebastianBergmann\GlobalState

Code

public function globalVariables(Snapshot $snapshot) : string {
    $result = <<<'EOT'
call_user_func(
    function ()
    {
        foreach (array_keys($GLOBALS) as $key) {
            unset($GLOBALS[$key]);
        }
    }
);


EOT;
    foreach ($snapshot->globalVariables() as $name => $value) {
        $result .= sprintf('$GLOBALS[%s] = %s;' . PHP_EOL, $this->exportVariable($name), $this->exportVariable($value));
    }
    return $result;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal