getOption('functions')) { return; } if ($input->getOption('user')) { $label = 'User Functions'; $functions = $this->getFunctions('user'); } elseif ($input->getOption('internal')) { $label = 'Internal Functions'; $functions = $this->getFunctions('internal'); } else { $label = 'Functions'; $functions = $this->getFunctions(); } $functions = $this->prepareFunctions($functions); if (empty($functions)) { return; } $ret = []; $ret[$label] = $functions; return $ret; } /** * Get defined functions. * * Optionally limit functions to "user" or "internal" functions. * * @param null|string $type "user" or "internal" (default: both) * * @return array */ protected function getFunctions($type = null) { $funcs = get_defined_functions(); if ($type) { return $funcs[$type]; } else { return array_merge($funcs['internal'], $funcs['user']); } } /** * Prepare formatted function array. * * @param array $functions * * @return array */ protected function prepareFunctions(array $functions) { natcasesort($functions); // My kingdom for a generator. $ret = []; foreach ($functions as $name) { if ($this->showItem($name)) { $ret[$name] = [ 'name' => $name, 'style' => self::IS_FUNCTION, 'value' => $this->presentSignature($name), ]; } } return $ret; } }