/** * Returns an array of this extension's fuctions * @return ezcReflectionFunction[] */ public function getFunctions() { if ($this->reflectionSource) { $functs = $this->reflectionSource->getFunctions(); } else { $functs = parent::getFunctions(); } $result = array(); foreach ($functs as $func) { $result[] = new ezcReflectionFunction($func); } return $result; }
public function getFunctions() { foreach ($res = parent::getFunctions() as $key => $val) { $res[$key] = new FunctionReflection($key); } return $res; }
/** * @return array */ protected function getTagsForExtension($name) { if (!extension_loaded($name)) { return array(); } $tags = array(); $module = new \ReflectionExtension($name); // Export constants. foreach ($module->getConstants() as $name => $value) { $tags[] = new Tag($name, 'constant', Tag::DEFINITION); } // Export functions. foreach ($module->getFunctions() as $function) { $tags[] = new Tag($function->getName(), 'function', TAG::DEFINITION); } // Export classes. foreach ($module->getClasses() as $class) { $tags[] = new Tag($class->getName(), 'class', TAG::DEFINITION); foreach ($class->getMethods() as $method) { $tags[] = new Tag(sprintf('%s::%s', $class->getName(), $method->getName()), 'function', TAG::DEFINITION); } foreach ($class->getProperties() as $property) { $tags[] = new Tag(sprintf('%s::%s', $class->getName(), $property->getName()), 'variable', TAG::DEFINITION); } foreach ($class->getConstants() as $constant => $value) { $tags[] = new Tag(sprintf('%s::%s', $class->getName(), $constant), 'constant', TAG::DEFINITION); } } return $tags; }
public function getFunctions() { $functs = parent::getFunctions(); $result = array(); foreach ($functs as $func) { $result[] = new MyReflectionFunction($func->getName()); } return $result; }
public function __construct() { parent::__construct(); foreach (get_loaded_extensions() as $ext) { $re = new \ReflectionExtension($ext); $extensions = $this->append(NULL, array($ext, $re)); $this->addFunctions($extensions, $re->getFunctions()); $this->addClasses($extensions, $re->getClasses()); } }
public function getFunctions() { $phpReflections = parent::getFunctions(); $zendReflections = array(); while ($phpReflections && ($phpReflection = array_shift($phpReflections))) { $zendReflections[] = new ZendL_Reflection_Function($phpReflection->getName()); unset($phpReflection); } unset($phpReflections); return $zendReflections; }
/** * Get all this extensions functions * * @return Nerd\Design\Collection Enumerable array of extension functions */ public function getFunctions() { if ($this->functions === null) { $functions = parent::getFunctions(); foreach ($functions as $key => $function) { $functions[$key] = new Funktion($function->getName()); } $this->functions = new Collection($functions); } return $this->functions; }
/** * @param string[] $extensionNames * @return string[] * @throws UnknownExtensionException if the extension cannot be found */ public function __invoke(array $extensionNames) : array { $definedSymbols = []; foreach ($extensionNames as $extensionName) { try { $extensionReflection = new \ReflectionExtension($extensionName); $definedSymbols = array_merge($definedSymbols, array_keys($extensionReflection->getConstants()), array_keys($extensionReflection->getFunctions()), $extensionReflection->getClassNames()); } catch (\Exception $e) { throw new UnknownExtensionException($e->getMessage()); } } return $definedSymbols; }
/** * Get extension function reflection objects * * @param string $reflectionClass Name of reflection class to use * @return array Array of Zend_Reflection_Function objects */ public function getFunctions($reflectionClass = 'Zend_Reflection_Function') { $phpReflections = parent::getFunctions(); $zendReflections = array(); while ($phpReflections && ($phpReflection = array_shift($phpReflections))) { $instance = new $reflectionClass($phpReflection->getName()); if (!$instance instanceof Zend_Reflection_Function) { throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend Zend_Reflection_Function'); } $zendReflections[] = $instance; unset($phpReflection); } unset($phpReflections); return $zendReflections; }
private static function mustHaveExtension($ext) { if (!extension_loaded($ext)) { echo "ERROR: The PHP extension '{$ext}' is not installed. You must " . "install it to run aphlict on this machine.\n"; exit(1); } $extension = new ReflectionExtension($ext); foreach ($extension->getFunctions() as $function) { $function = $function->name; if (!function_exists($function)) { echo "ERROR: The PHP function {$function}() is disabled. You must " . "enable it to run aphlict on this machine.\n"; exit(1); } } }
private static function mustHaveExtension($ext) { if (!extension_loaded($ext)) { echo pht("ERROR: The PHP extension '%s' is not installed. You must " . "install it to run Aphlict on this machine.", $ext) . "\n"; exit(1); } $extension = new ReflectionExtension($ext); foreach ($extension->getFunctions() as $function) { $function = $function->name; if (!function_exists($function)) { echo pht('ERROR: The PHP function %s is disabled. You must ' . 'enable it to run Aphlict on this machine.', $function . '()') . "\n"; exit(1); } } }
function expectArgumentError($message) { try { $extension = new \ReflectionExtension('functional'); $extensionFunctions = array_keys($extension->getFunctions()); $isDefinedInExtension = F\every($this->functions, function ($function) use($extensionFunctions) { return in_array($function, $extensionFunctions, true); }); if ($isDefinedInExtension) { $this->setExpectedException('PHPUnit_Framework_Error_Warning', $message); } else { $this->setExpectedException('Functional\\Exceptions\\InvalidArgumentException', $message); } } catch (\ReflectionException $e) { $this->setExpectedException('Functional\\Exceptions\\InvalidArgumentException', $message); } }
public function introspect(\ReflectionExtension $extension) { $classes = $functions = $constants = array(); foreach ($extension->getClasses() as $class) { assert($class instanceof \ReflectionClass); $phpClass = PhpClass::fromReflection($class); $classes[] = $phpClass; } foreach ($extension->getFunctions() as $function) { assert($function instanceof \ReflectionFunction); $phpFunction = PhpFunction::fromReflection($function); $functions[] = $phpFunction; } foreach ($extension->getConstants() as $name => $value) { $phpConstant = new PhpConstant($name); $phpConstant->setValue($value); $constants[] = $phpConstant; } return array('classes' => $classes, 'functions' => $functions, 'constants' => $constants); }
function export_ext($ext) { $rf_ext = new ReflectionExtension($ext); $funcs = $rf_ext->getFunctions(); $classes = $rf_ext->getClasses(); $consts = $rf_ext->getConstants(); $version = $rf_ext->getVersion(); $defines = ''; $sp4 = str_repeat(' ', 4); $fdefs = getFuncDef($funcs, $version); $class_def = ''; foreach ($consts as $k => $v) { if (!is_numeric($v)) { $v = "'{$v}'"; } $defines .= "define('{$k}',{$v});\n"; } foreach ($classes as $k => $v) { $prop_str = ''; $props = $v->getProperties(); array_walk($props, function ($v, $k) { global $prop_str, $sp4; $modifiers = implode(' ', Reflection::getModifierNames($v->getModifiers())); $prop_str .= "{$sp4}/**\n{$sp4}*@var \$" . $v->name . " " . $v->class . "\n{$sp4}*/\n{$sp4} {$modifiers} \$" . $v->name . ";\n\n"; }); if ($v->getParentClass()) { $k .= ' extends ' . $v->getParentClass()->name; } $modifier = 'class'; if ($v->isInterface()) { $modifier = 'interface'; } $mdefs = getMethodsDef($v->getMethods(), $version); $class_def .= sprintf("/**\n*@since %s\n*/\n%s %s{\n%s%s\n}\n", $version, $modifier, $k, $prop_str, $mdefs); } if (!file_exists('./ext')) { mkdir('./ext', 777, TRUE); } file_put_contents("./ext/" . $ext . ".php", "<?php\n" . $defines . $fdefs . $class_def); }
function export() { /** * 获取所有define常量 */ $consts = $this->rf_ext->getConstants(); $defines = ''; foreach ($consts as $className => $ref) { if (!is_numeric($ref)) { $ref = "'{$ref}'"; } $defines .= "define('{$className}', {$ref});\n"; } file_put_contents(OUTPUT_DIR . '/constants.php', "<?php\n" . $defines); /** * 获取所有函数 */ $funcs = $this->rf_ext->getFunctions(); $fdefs = $this->getFunctionsDef($funcs); file_put_contents(OUTPUT_DIR . '/functions.php', "<?php\n" . $fdefs); /** * 获取所有类 */ $classes = $this->rf_ext->getClasses(); $class_alias = "<?php\n"; foreach ($classes as $className => $ref) { //命名空间 if (strchr($className, '\\')) { $this->exportNamespaceClass($className, $ref); continue; } else { $class_alias .= sprintf("\nclass %s extends %s\n{\n\n}\n", $className, self::getNamespaceAlias($className)); } } file_put_contents(OUTPUT_DIR . '/classes.php', $class_alias); }
public function getFunctions() { return array_map('FunctionReflection::import', parent::getFunctions()); }
/** * Get all info about function * @param string|function $extensionName Function or function name * @return array|bool */ protected static function _getExtension($extensionName) { if (!extension_loaded($extensionName)) { return false; } $ext = new ReflectionExtension($extensionName); $result = array(); $result['name'] = $ext->name; $result['version'] = $ext->getVersion(); if ($constants = $ext->getConstants()) { $result['constants'] = $constants; } if ($classesName = $ext->getClassNames()) { $result['classesName'] = $classesName; } if ($functions = $ext->getFunctions()) { $result['functions'] = $functions; } if ($dependencies = $ext->getDependencies()) { $result['dependencies'] = $dependencies; } if ($INIEntries = $ext->getINIEntries()) { $result['INIEntries'] = $INIEntries; } $functions = $ext->getFunctions(); if (is_array($functions) && count($functions) > 0) { $result['functions'] = array(); foreach ($functions as $function) { $funcName = $function->getName(); $result['functions'][$funcName] = self::_getFunction($funcName); } } return $result; }
/** * Returns functions defined by this extension. * * @return array */ public function getFunctions() { if (null === $this->functions) { $broker = $this->broker; $this->classes = array_map(function ($functionName) use($broker) { return $broker->getFunction($functionName); }, array_keys(parent::getFunctions())); } return $this->functions; }
break; case 1: die(sprintf($out, "Usage: %s <ext>\n", $argv[0])); } fprintf($out, "<?php\n\n"); $ext = new ReflectionExtension($ext); $constants = array(); $functions = array(); $structures = array(); // split up by namespace first foreach ($ext->getConstants() as $constant => $value) { $ns = ($nsend = strrpos($constant, "\\")) ? substr($constant, 0, $nsend++) : ""; $cn = substr($constant, $nsend); $constants[$ns][$cn] = $value; } foreach ($ext->getFunctions() as $f) { /* @var $f ReflectionFunction */ $ns = $f->inNamespace() ? $f->getNamespaceName() : ""; $functions[$ns][$f->getShortName()] = $f; } foreach ($ext->getClasses() as $c) { /* @var $c ReflectionClass */ $ns = $c->inNamespace() ? $c->getNamespaceName() : ""; $structures[$ns][$c->getShortName()] = $c; } $namespaces = array_unique(array_merge(array_keys($constants), array_keys($functions), array_keys($structures))); // simple sort natsort($namespaces); foreach ($namespaces as $ns) { fprintf($out, "namespace %s%s\n{\n", $ns, strlen($ns) ? " " : ""); //
<pre> <?php // Создание экземпляра класса ReflectionProperty $ext = new ReflectionExtension('standard'); // Вывод основной информации printf("Имя : %s\n" . "Версия : %s\n" . "Функции : [%d] %s\n" . "Константы : [%d] %s\n" . "Директивы INI : [%d] %s\n" . "Классы : [%d] %s\n", $ext->getName(), $ext->getVersion() ? $ext->getVersion() : 'NO_VERSION', sizeof($ext->getFunctions()), var_export($ext->getFunctions(), 1), sizeof($ext->getConstants()), var_export($ext->getConstants(), 1), sizeof($ext->getINIEntries()), var_export($ext->getINIEntries(), 1), sizeof($ext->getClassNames()), var_export($ext->getClassNames(), 1)); ?> </pre>
function gen_extension_markup(ReflectionExtension $obj, $content, $xml_file) { /* {{{ */ global $INFO, $OPTION; switch ($xml_file) { case 'ini.xml': if ($ini = ini_get_all($obj->name)) { $visibility = array(INI_USER => 'PHP_INI_USER', INI_PERDIR => 'PHP_INI_PERDIR', INI_SYSTEM => 'PHP_INI_SYSTEM', INI_ALL => 'PHP_INI_ALL'); $ident = get_ident_size('INI_ENTRIES', $content); $markup = "<tbody>" . PHP_EOL; $markup2 = ''; foreach ($ini as $config => $value) { $id = "ini." . format_config($config); $markup .= str_repeat(' ', $ident + 1) . "<row>" . PHP_EOL; $markup .= str_repeat(' ', $ident + 2) . "<entry><link linkend=\"" . $id . "\">" . $config . "</link></entry>" . PHP_EOL; $markup .= str_repeat(' ', $ident + 2) . "<entry>" . $value['global_value'] . "</entry>" . PHP_EOL; $markup .= str_repeat(' ', $ident + 2) . "<entry>" . (isset($visibility[$value['access']]) ? $visibility[$value['access']] : $value['access']) . "</entry>" . PHP_EOL; $markup .= str_repeat(' ', $ident + 2) . "<entry><!-- leave empty, this will be filled by an automatic script --></entry>" . PHP_EOL; $markup .= str_repeat(' ', $ident + 1) . "</row>" . PHP_EOL; $markup2 .= ($markup2 ? str_repeat(' ', $ident) : '') . "<varlistentry xml:id=\"" . $id . "\">" . PHP_EOL; $markup2 .= str_repeat(' ', $ident + 1) . "<term>" . PHP_EOL; $markup2 .= str_repeat(' ', $ident + 2) . "<parameter>" . $config . "</parameter>" . PHP_EOL; $markup2 .= str_repeat(' ', $ident + 2) . "<type>" . get_type_by_string($value['global_value']) . "</type>" . PHP_EOL; $markup2 .= str_repeat(' ', $ident + 1) . "</term>" . PHP_EOL; $markup2 .= str_repeat(' ', $ident + 1) . "<listitem>" . PHP_EOL; $markup2 .= str_repeat(' ', $ident + 2) . "<para>" . PHP_EOL; $markup2 .= str_repeat(' ', $ident + 3) . PHP_EOL; $markup2 .= str_repeat(' ', $ident + 2) . "</para>" . PHP_EOL; $markup2 .= str_repeat(' ', $ident + 1) . "</listitem>" . PHP_EOL; $markup2 .= str_repeat(' ', $ident) . "</varlistentry>" . PHP_EOL; } $markup .= str_repeat(' ', $ident) . "</tbody>"; /* {INI_ENTRIES} */ $content = preg_replace('/\\{INI_ENTRIES\\}/', $markup, $content, 1); /* {INI_ENTRIES_DESCRIPTION} */ $content = preg_replace('/\\{INI_ENTRIES_DESCRIPTION\\}/', $markup2, $content, 1); } else { return false; /* Abort */ } break; case 'constants.xml': if ($constants = $obj->getConstants()) { $ident = get_ident_size('CONSTANTS', $content); $markup = "&extension.constants;" . PHP_EOL; $markup .= str_repeat(' ', $ident) . "<para>" . PHP_EOL; $markup .= str_repeat(' ', $ident + 1) . "<variablelist>" . PHP_EOL; foreach ($constants as $name => $value) { $markup .= str_repeat(' ', $ident + 2) . '<varlistentry xml:id="constant.' . format_id($name) . '">' . PHP_EOL; $markup .= str_repeat(' ', $ident + 3) . "<term>" . PHP_EOL; $markup .= str_repeat(' ', $ident + 4) . "<constant>" . $name . "</constant>" . PHP_EOL; $markup .= str_repeat(' ', $ident + 4) . "(<type>" . gettype($value) . "</type>)" . PHP_EOL; $markup .= str_repeat(' ', $ident + 3) . "</term>" . PHP_EOL; $markup .= str_repeat(' ', $ident + 3) . "<listitem>" . PHP_EOL; $markup .= str_repeat(' ', $ident + 4) . "<simpara>" . PHP_EOL; $markup .= str_repeat(' ', $ident + 4) . "</simpara>" . PHP_EOL; $markup .= str_repeat(' ', $ident + 3) . "</listitem>" . PHP_EOL; $markup .= str_repeat(' ', $ident + 2) . "</varlistentry>" . PHP_EOL; } $markup .= str_repeat(' ', $ident + 1) . "</variablelist>" . PHP_EOL; $markup .= str_repeat(' ', $ident) . "</para>"; $content = preg_replace('/\\{CONSTANTS\\}/', $markup, $content, 1); } else { $content = preg_replace('/\\{CONSTANTS\\}/', '&no.constants;', $content, 1); } break; case 'configure.xml': $ident = get_ident_size('EXT_INSTALL_MAIN', $content); $ident2 = get_ident_size('EXT_INSTALL_WIN', $content); $markup = ''; $markup2 = ''; if ($OPTION['pecl'] === true) { $markup .= "<para>" . PHP_EOL; $markup .= str_repeat(' ', $ident + 1) . "&pecl.info;" . PHP_EOL; $markup .= str_repeat(' ', $ident + 1) . "<link xlink:href=\"&url.pecl.package;{EXT_NAME_ID}\">&url.pecl.package;{EXT_NAME_ID}</link>" . PHP_EOL; $markup .= str_repeat(' ', $ident) . "</para>" . PHP_EOL; /* $markup2 .= "<para>". PHP_EOL; $markup2 .= str_repeat(' ', $ident2 + 1) ."The latest PECL/{EXT_NAME_ID} Win32 DLL is available here:". PHP_EOL; $markup2 .= str_repeat(' ', $ident2 + 1) ."<link xlink:href=\"&url.pecl.win.ext;php_{EXT_NAME_ID}.dll\">php_{EXT_NAME_ID}.dll</link>". PHP_EOL; $markup2 .= str_repeat(' ', $ident2) ."</para>". PHP_EOL; */ } else { $markup .= "<para>" . PHP_EOL; $markup .= str_repeat(' ', $ident + 1) . "Use <option role=\"configure\">--with-{EXT_NAME_ID}[=DIR]</option> when compiling PHP." . PHP_EOL; $markup .= str_repeat(' ', $ident) . "</para>" . PHP_EOL; $markup2 .= "<para>" . PHP_EOL; $markup2 .= str_repeat(' ', $ident2 + 1) . "Windows users should include <filename>php_{EXT_NAME_ID}.dll</filename> into &php.ini;" . PHP_EOL; $markup2 .= str_repeat(' ', $ident2) . "</para>" . PHP_EOL; } $content = str_replace('{EXT_INSTALL_MAIN}', $markup, $content); $content = str_replace('{EXT_INSTALL_WIN}', $markup2, $content); break; case 'versions.xml': $version_default = 'PHP 5 >= Unknown'; if ($OPTION['pecl'] === true) { $version_default = 'PECL {EXT_NAME_ID} >= Unknown'; } $markup = ""; /* Function list */ if ($functions = $obj->getFunctions()) { $markup .= "<!-- Functions -->" . PHP_EOL; foreach ($functions as $function) { $markup .= " <function name='" . strtolower($function->getName()) . "' from='{$version_default}'/>" . PHP_EOL; } } /* Method list */ if ($classes = $obj->getClasses()) { $markup .= " <!-- Classes and Methods -->" . PHP_EOL; foreach ($classes as $class) { $markup .= PHP_EOL; $markup .= " <function name='" . strtolower($class->name) . "' from='{$version_default}'/>" . PHP_EOL; foreach ($class->getMethods() as $method) { $markup .= " <function name='" . strtolower($class->name . '::' . $method->getName()) . "' from='{$version_default}'/>" . PHP_EOL; } } } $content = preg_replace('/\\{VERSIONS\\}/', rtrim($markup), $content); break; case 'book.developer.xml': if ($OPTION['docbase'] && $OPTION['phpdoc']) { $content = preg_replace('/\\{PATH_TO_DOCBASE\\}/', $OPTION['docbase'], $content); $content = preg_replace('/\\{PATH_TO_DOC\\}/', $OPTION['phpdoc'], $content); } break; } return $content; }
* enabled in your php.ini file. * * NOTE: mysqlnd is not included because it exposes no functions, classes, or constants. * The pdo_* extensions are not included in the list because they do not expose any * functions, classes, or constants themselves. The constants and methods specific * to that driver are exposed though the PDO extension itself. The pdo_* extensions * must still be enabled (compiled in or loaded as shared) for these constants to show up. */ $allowed_extensions = array('bcmath', 'bz2', 'core', 'curl', 'date', 'dom', 'ereg', 'gd', 'gettext', 'hash', 'iconv', 'json', 'libxml', 'mbstring', 'mcrypt', 'mhash', 'mysql', 'mysqli', 'openssl', 'pcre', 'pdo', 'pgsql', 'phar', 'reflection', 'session', 'simplexml', 'soap', 'sockets', 'spl', 'sqlite3', 'standard', 'tokenizer', 'wddx', 'xml', 'xmlreader', 'xmlwriter', 'zip', 'zlib'); $processed = array(); foreach ($allowed_extensions as $extension) { try { $details = array(); $options = new ReflectionExtension($extension); $classes = array(); $functions = array_keys($options->getFunctions()); $constants = array_keys($options->getConstants()); foreach ($options->getClasses() as $class) { $classes[] = $class->getName(); $constants = array_merge($constants, array_keys($class->getConstants())); } $constants = array_unique($constants); $details['name'] = $options->getName(); if (sizeof($functions)) { $details['functions'] = implode(' ', $functions); } if (sizeof($constants)) { $details['constants'] = implode(' ', $constants); } if (sizeof($classes)) { $details['classes'] = implode(' ', $classes);
public function printInfo() { $info = []; $ion = new \ReflectionExtension('ion'); $info[] = $ion->info(); foreach ($ion->getINIEntries() as $ini => $value) { $info[] = "ini {$ini} = " . var_export($value, true); } foreach ($ion->getConstants() as $constant => $value) { $info[] = "const {$constant} = " . var_export($value, true); } foreach ($ion->getFunctions() as $function) { $info[] = $this->_scanFunction($function); } foreach ($ion->getClasses() as $class) { $mods = []; if ($class->isFinal()) { $mods[] = "final"; } if ($class->isInterface()) { $mods[] = "interface"; } elseif ($class->isTrait()) { $mods[] = "trait"; } else { if ($class->isAbstract()) { $mods[] = "abstract"; } $mods[] = "class"; } $info[] = implode(' ', $mods) . " {$class->name} {"; if ($class->getParentClass()) { $info[] = " extends {$class->getParentClass()->name}"; } foreach ($class->getInterfaceNames() as $interface) { $info[] = " implements {$interface}"; } foreach ($class->getTraitNames() as $trait) { $info[] = " use {$trait}"; } foreach ($class->getConstants() as $constant => $value) { $info[] = " const {$class->name}::{$constant} = " . var_export($value, true); } foreach ($class->getProperties() as $prop_name => $prop) { /** @var ReflectionProperty $prop */ $mods = implode(' ', Reflection::getModifierNames($prop->getModifiers())); if ($prop->class !== $class->name) { $info[] = " prop {$mods} {$prop->class}::\${$prop->name}"; } else { $info[] = " prop {$mods} \${$prop->name}"; } } foreach ($class->getMethods() as $method) { $info[] = $this->_scanFunction($method, $class->name); } $info[] = "}"; } echo implode("\n", $info) . "\n"; }
* to that driver are exposed though the PDO extension itself. The pdo_* extensions * must still be enabled (compiled in or loaded as shared) for these constants to show up. */ $extensions = array('core', 'bcmath', 'bz2', 'calendar', 'com_dotnet', 'ctype', 'curl', 'date', 'dba', 'dom', 'enchant', 'ereg', 'exif', 'fileinfo', 'filter', 'ftp', 'gd', 'gettext', 'gmp', 'hash', 'iconv', 'imap', 'intl', 'json', 'ldap', 'libxml', 'mbstring', 'mcrypt', 'mhash', 'mysql', 'mysqli', 'oci8', 'oci8_11g', 'odbc', 'openssl', 'pcntl', 'pcre', 'pdo', 'pgsql', 'phar', 'posix', 'pspell', 'readline', 'recode', 'reflection', 'session', 'shmop', 'simplexml', 'snmp', 'soap', 'sockets', 'spl', 'standard', 'sqlite', 'sqlite3', 'sybase_ct', 'sysvmsg', 'sysvsem', 'sysvshm', 'tidy', 'tokenizer', 'xml', 'xmlreader', 'xmlwriter', 'xmlrpc', 'xsl', 'zip', 'zlib', 'yaf', 'yar', 'taint'); $out_file = 'php_vimgen_out.vim'; // Pick your output file & location. $out_str = ''; $store = array(); $errors = array(); foreach ($extensions as $ext) { echo "Processing extension '{$ext}'." . PHP_EOL; try { $extension = new ReflectionExtension($ext); $ext_info = array(); $ext_info['name'] = $extension->getName(); $ext_functions = array_keys($extension->getFunctions()); $ext_constants = array_keys($extension->getConstants()); $classes = $extension->getClasses(); $ext_classes = array(); foreach ($classes as $class) { $ext_classes[] = $class->getName(); $ext_constants = array_merge($ext_constants, array_keys($class->getConstants())); } $ext_constants = array_unique($ext_constants); if (count($ext_functions)) { $ext_info['functions'] = implode(' ', $ext_functions); } if (count($ext_constants)) { $ext_info['constants'] = implode(' ', $ext_constants); } if (count($ext_classes)) {
# Housekeeping. error_reporting(E_ALL | E_DEPRECATED | E_STRICT); ini_set('display_errors', 'On'); date_default_timezone_set('UTC'); $blocks = array('extensions' => array(), 'last-modified' => sprintf('" %s, PHP %s', date('r'), PHP_VERSION)); # Parse the configuration file associated with this script. $configuration = parse_ini_file(__DIR__ . '/syntax.ini', true); # Process extensions and generate built-in functions, constants, classes and interfaces. $extensions = array(); foreach ($configuration['extensions'] as $extensionName => $isEnabled) { if (!$isEnabled) { continue; } try { $reflect = new ReflectionExtension($extensionName); $options = array('name' => $reflect->getName(), 'classes' => array(), 'functions' => array_keys($reflect->getFunctions()), 'constants' => array_diff(array_keys($reflect->getConstants()), array('TRUE', 'FALSE', 'NULL'))); foreach ($reflect->getClasses() as $extensionClass) { $options['classes'][] = $extensionClass->getName(); $options['constants'] = array_unique(array_merge($options['constants'], array_keys($extensionClass->getConstants()))); } sort($options['classes'], SORT_NATURAL); sort($options['functions'], SORT_NATURAL); sort($options['constants'], SORT_NATURAL); $extensions[$extensionName] = $options; } catch (ReflectionException $e) { file_put_contents('php://stderr', sprintf('[ERROR] %s: %s.' . PHP_EOL, $extensionName, rtrim($e->getMessage(), ' ?!.'))); } } $blocks['extensions'][] = 'if ! exists("g:php_syntax_extensions_enabled")'; $blocks['extensions'][] = sprintf(' let g:php_syntax_extensions_enabled = ["%s"]', implode('", "', array_map('strtolower', array_keys($extensions)))); $blocks['extensions'][] = 'endif';
foreach ($ref->getINIEntries() as $name => $tmp) { re("configuration.xml", "#<entry>{$name}</entry>#") or printf("\t%s (%s)\n", $name, $tmp); } printf("\n"); printf("Undocumented stream filters:\n"); foreach (preg_grep("/^{$ext}\\./", stream_get_filters()) as $filter) { fe(sprintf("streamfilters/%s.xml", substr($filter, 5))) or printf("\t%s\n", $filter); } printf("\n"); printf("Undocumented constants:\n"); foreach ($ref->getConstants() as $name => $tmp) { re("constants.xml", "#<constant>{$name}</constant>#") or printf("\t%s (%s)\n", $name, $tmp); } printf("\n"); printf("Undocumented functions:\n"); foreach ($ref->getFunctions() as $func) { /* @var $func ReflectionFunction */ fg(sprintf("functions/*/%s.xml", strtr($func->getName(), '_', '-'))) or printf("\t%s()\n", $func->getName()); } printf("\n"); printf("Undocumented classes/members:\n"); foreach ($ref->getClasses() as $class) { if (substr($class->getName(), -strlen("Exception")) === "Exception") { continue; } /* @var $class ReflectionClass */ fg(sprintf("%s.xml", $class->getName())) or printf(" %s\n", $class->getName()); foreach ($class->getConstants() as $name => $tmp) { re($class->getName() . ".xml", "#>{$name}<#") or printf("\t%s::%s (%s)\n", $class->getName(), $name, $tmp); } foreach ($class->getProperties() as $prop) {
<?php $r = new ReflectionExtension("mysql"); $ignore = array(); $functions = $r->getFunctions(); asort($functions); printf("Functions:\n"); foreach ($functions as $func) { if (isset($ignore[$func->name])) { continue; } printf(" %s\n", $func->name); $rf = new ReflectionFunction($func->name); printf(" Deprecated: %s\n", $rf->isDeprecated() ? "yes" : "no"); printf(" Accepted parameters: %d\n", $rf->getNumberOfParameters()); printf(" Required parameters: %d\n", $rf->getNumberOfRequiredParameters()); foreach ($rf->getParameters() as $param) { printf(" %s\n", $param); } } print "done!";
function getFunctions() { foreach ($res = parent::getFunctions() as $key => $val) { $res[$key] = new GlobalFunction($key); } return $res; }
<?php $r = new ReflectionExtension('standard'); $t = $r->getFunctions(); var_dump($t['dl']); ?> Done
public function getFunctions() { return array_map(array('FunctionReflection', 'import'), parent::getFunctions()); }