/** * Returns an associative array containing this extension's INI entries and * their values * @return array<string,string> */ public function getINIEntries() { if ($this->reflectionSource) { return $this->reflectionSource->getINIEntries(); } else { return parent::getINIEntries(); } }
/** * @return array */ public function opcodeCacheData() { $cacheData = array(); foreach (static::$opcacheExtenstions as $name => $data) { list($title, $iniSetting) = $data; if ($this->hasCache($name, $iniSetting)) { $cacheData['title'] = $title; $cacheData['name'] = $name; $ref = new \ReflectionExtension($name); $cacheData['version'] = $ref->getVersion(); $cacheData['settings'] = $ref->getINIEntries(); break; } } return $cacheData; }
foreach ($settings as $name => $info) { $w = str_repeat('-', 77); $xhtml = new ezcDocumentXhtml(); $xhtml->loadString(ignore_links($info[3])); $docbook = $xhtml->getAsDocbook(); // echo $docbook->save(), "\n\n"; $convertor = new drDocumentDoctookToTextConvertor(); $rst = $convertor->convert($docbook); $d = $rst->save(); $d = join("\n; ", explode("\n", $d)); echo <<<ENDL ; {$w} ; xdebug.{$name} ; ; Type: {$info[0]}, Default value: {$info[1]} ; ; {$d} ; ;xdebug.{$name} = {$info[1]} ENDL; } /* Check for missing settings */ $extensionSettings = array_keys($ext->getINIEntries()); foreach ($extensionSettings as $settingName) { $sanitizedSettingName = preg_replace('/^xdebug\\./', '', $settingName); if (!isset($settings[$sanitizedSettingName])) { fprintf(STDERR, "{$settingName} is missing\n"); } }
} function fe($file) { global $doc; return file_exists("{$doc}/{$file}"); } function fg($path, &$g = NULL) { global $doc; return count($g = glob("{$doc}/{$path}")); } $ext = "http"; $doc = "/home/mike/Development/src/php/phpdoc/en/trunk/reference/{$ext}"; $ref = new ReflectionExtension($ext); printf("Undocumented INI options:\n"); 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) {
/** * 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; }
<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>
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"; }
/** * Test that each ini entries are defined in reference * * @depends testReference * @group reference * @return void */ public function testGetIniEntriesFromExtension() { $extname = self::$ext; if ('internal' == $extname) { // only Core is a valid extension name for API reflection return; } $dict = self::$obj->getIniEntries(); $extension = new \ReflectionExtension($extname); $iniEntries = array_keys($extension->getINIEntries()); $this->assertTrue(is_array($dict)); foreach ($iniEntries as $iniEntry) { if (!in_array($iniEntry, self::$ignoredcfgs)) { $this->assertArrayHasKey($iniEntry, $dict, "Defined INI '{$iniEntry}' not known in Reference."); } } }
<?php $ext = new ReflectionExtension("standard"); $inis = $ext->getINIEntries(); var_dump($inis["user_agent"]);
/** * php-mecab/examples * show module dependencies, ini entries, constants, functions * and methods provided by mecab extension (use ReflectionExtension) * charset=utf-8 */ require_once dirname(__FILE__) . '/common.inc.php'; $linebreak = PHP_EOL . PHP_EOL; $reflector = new ReflectionExtension('mecab'); $mapper = create_function('$m', 'return $m->getName();'); border(); echo 'Module dependencies:', $linebreak; print_r($reflector->getDependencies()); border(); echo 'INI entries:', $linebreak; print_r($reflector->getINIEntries()); border(); echo 'Constants:', $linebreak; print_r($reflector->getConstants()); border(); echo 'Functions:', $linebreak; print_r(array_keys($reflector->getFunctions())); border(); echo 'Classes:', $linebreak; $classes = array(); foreach ($reflector->getClasses() as $className => $class) { $classes[$className] = array('interfaces' => null, 'constants' => $class->getConstants(), 'properties' => $class->getProperties(), 'methods' => array_map($mapper, $class->getMethods())); if (method_exists($class, 'getInterfaceNames')) { $classes[$className]['interfaces'] = $class->getInterfaceNames(); } else { $classes[$className]['interfaces'] = array_keys($class->getInterfaces());
/** * The entry method. * * @return int */ public function main() { $sections = []; $mail = null; $diagnostic = []; while (false !== ($c = $this->getOption($v))) { switch ($c) { case 's': $sections = $this->parser->parseSpecialValue($v); break; case 'm': $mail = $v; break; case 'h': case '?': return $this->usage(); case '__ambiguous': $this->resolveOptionAmbiguity($v); break; } } $store = function ($sections, $key, $value = null) use(&$diagnostic) { if (is_array($key) && null === $value) { foreach ($key as $i => $name) { $diagnostic[$sections][$i] = $name; } } else { $diagnostic[$sections][$key] = $value; } return; }; $store('version', 'php', phpversion()); $store('version', 'zend_engine', zend_version()); $store('system', 'platform', php_uname()); $store('system', 'architecture', true === S_32_BITS ? '32bits' : '64bits'); $store('system', 'lang', isset($_SERVER['LANG']) ? $_SERVER['LANG'] : 'unknown'); $store('bin', 'self', $_SERVER['PHP_SELF']); $store('bin', 'hoa', resolve('hoa://Library/Cli/Bin')); $store('bin', 'php_dir', PHP_BINDIR); $store('bin', 'php', defined('PHP_BINARY') ? PHP_BINARY : 'unknown'); foreach (get_loaded_extensions() as $extension) { $reflection = new \ReflectionExtension($extension); $entry = 'extension-' . strtolower($extension); if ('extension-standard' !== $entry && 'extension-core' !== $entry) { $entries = []; foreach ($reflection->getINIEntries() as $key => $value) { $entries[substr($key, strpos($key, '.') + 1)] = $value; } } else { $entries = $reflection->getINIEntries(); } $store($entry, 'version', $reflection->getVersion() ?: 'unknown'); $store($entry, $entries); } if (empty($sections) || in_array('all', $sections)) { $ini = $this->arrayToIni($diagnostic); } else { $handle = []; foreach ($sections as $section) { if (false === array_key_exists($section, $diagnostic)) { return 1; } $handle[$section] = $diagnostic[$section]; } $ini = $this->arrayToIni($handle); } echo $ini, "\n"; if (null !== $mail) { $subject = 'Diagnostic from ' . get_current_user(); return mail($mail, $subject, $ini) ? 0 : 1; } return; }