getOption('globals')) { return; } $globals = $this->prepareGlobals($this->getGlobals()); if (empty($globals)) { return; } return [ 'Global Variables' => $globals, ]; } /** * Get defined global variables. * * @return array */ protected function getGlobals() { global $GLOBALS; $names = \array_keys($GLOBALS); \natcasesort($names); $ret = []; foreach ($names as $name) { $ret[$name] = $GLOBALS[$name]; } return $ret; } /** * Prepare formatted global variable array. * * @param array $globals * * @return array */ protected function prepareGlobals($globals) { // My kingdom for a generator. $ret = []; foreach ($globals as $name => $value) { if ($this->showItem($name)) { $fname = '$' . $name; $ret[$fname] = [ 'name' => $fname, 'style' => self::IS_GLOBAL, 'value' => $this->presentRef($value), ]; } } return $ret; } }