/**
  * Exports all PHP files for this extension
  *
  * @param string $directory
  * @param bool   $create_sub_directories
  *
  * @throws \Exception
  * @throws \InvalidArgumentException
  */
 public function exportFiles($directory, $create_sub_directories = true)
 {
     $dir = realpath($directory);
     if (empty($dir) || !file_exists($dir)) {
         throw new \InvalidArgumentException("Directory does not exist: {$directory}");
     }
     foreach ($this->_extension->getClasses() as $class) {
         $reflection_class = new ReflectionClass($class);
         $current_dir = $dir;
         if ($create_sub_directories) {
             $namespaces = explode('\\', $class->getNamespaceName());
             array_shift($namespaces);
             $sub_dirs = join(DIRECTORY_SEPARATOR, $namespaces);
             if (!empty($sub_dirs)) {
                 $current_dir = $dir . DIRECTORY_SEPARATOR . $sub_dirs;
                 if (!file_exists($current_dir) && !@mkdir($current_dir, 0755, true)) {
                     throw new \Exception('Could not create sub directories: ' . $sub_dirs);
                 }
             }
         }
         $filename = $reflection_class->getClassName() . '.php';
         $file_path = $current_dir . DIRECTORY_SEPARATOR . $filename;
         $result = file_put_contents($file_path, $reflection_class->exportCode());
         if ($result === false) {
             throw new \Exception('Could not create file: ' . $file_path);
         }
     }
 }
示例#2
0
 /**
  * Returns an array containing ezcReflectionClass objects for all
  * classes of this extension
  * @return ezcReflectionClass[]
  */
 public function getClasses()
 {
     if ($this->reflectionSource) {
         $classes = $this->reflectionSource->getClasses();
     } else {
         $classes = parent::getClasses();
     }
     $result = array();
     foreach ($classes as $class) {
         $result[] = new ezcReflectionClass($class);
     }
     return $result;
 }
示例#3
0
 /**
  * @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;
 }
示例#4
0
 public function prepare_storage()
 {
     // Generate tables
     midgard_storage::create_base_storage();
     // And update as necessary
     $re = new ReflectionExtension('midgard2');
     $classes = $re->getClasses();
     foreach ($classes as $refclass) {
         if ($refclass->isAbstract() || $refclass->isInterface()) {
             continue;
         }
         $type = $refclass->getName();
         if (!is_subclass_of($type, 'MidgardDBObject')) {
             continue;
         }
         if (midgard_storage::class_storage_exists($type)) {
             // FIXME: Skip updates until http://trac.midgard-project.org/ticket/1426 is fixed
             continue;
             if (!midgard_storage::update_class_storage($type)) {
                 $this->markTestSkipped('Could not update ' . $type . ' tables in test database');
             }
             continue;
         }
         if (!midgard_storage::create_class_storage($type)) {
             $this->markTestSkipped('Could not create ' . $type . ' tables in test database');
         }
     }
     // And update as necessary
     return;
     if (!midgard_user::auth('root', 'password')) {
         echo "auth failed\n";
         $this->markTestSkipped('Could not authenticate as ROOT');
     }
 }
 public function getClasses()
 {
     $classes = parent::getClasses();
     $result = array();
     foreach ($classes as $class) {
         $result[] = new MyReflectionClass($class->getName());
     }
     return $result;
 }
示例#6
0
 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());
     }
 }
示例#7
0
文件: Extension.php 项目: lortnus/zf1
 public function getClasses()
 {
     $phpReflections = parent::getClasses();
     $zendReflections = array();
     while ($phpReflections && ($phpReflection = array_shift($phpReflections))) {
         $zendReflections[] = new ZendL_Reflection_Class($phpReflection->getName());
         unset($phpReflection);
     }
     unset($phpReflections);
     return $zendReflections;
 }
示例#8
0
 /**
  * Get all this extensions classes
  *
  * @return    Nerd\Design\Collection     Enumerable array of extension classes
  */
 public function getClasses()
 {
     if ($this->classes === null) {
         $classes = parent::getClasses();
         foreach ($classes as $key => $class) {
             $classes[$key] = new Klass($class->getName());
         }
         $this->classes = new Collection($classes);
     }
     return $this->classes;
 }
示例#9
0
 /**
  * Get extension class reflection objects
  *
  * @param  string $reflectionClass Name of reflection class to use
  * @return array Array of Zend_Reflection_Class objects
  */
 public function getClasses($reflectionClass = 'Zend_Reflection_Class')
 {
     $phpReflections = parent::getClasses();
     $zendReflections = array();
     while ($phpReflections && ($phpReflection = array_shift($phpReflections))) {
         $instance = new $reflectionClass($phpReflection->getName());
         if (!$instance instanceof Zend_Reflection_Class) {
             throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend Zend_Reflection_Class');
         }
         $zendReflections[] = $instance;
         unset($phpReflection);
     }
     unset($phpReflections);
     return $zendReflections;
 }
示例#10
0
 private function getTypes()
 {
     $mgdschemas = array();
     $re = new \ReflectionExtension('midgard2');
     $classes = $re->getClasses();
     foreach ($classes as $refclass) {
         $parent_class = $refclass->getParentClass();
         if (!$parent_class) {
             continue;
         }
         if ($parent_class->getName() != 'midgard_object') {
             continue;
         }
         $mgdschemas[$include_views][] = $refclass->getName();
     }
     return $mgdschemas;
 }
示例#11
0
 public function get_mgdschema_classes()
 {
     static $mgdschemas = array();
     if (empty($mgdschemas)) {
         // Get the classes from PHP5 reflection
         $re = new ReflectionExtension('midgard2');
         $classes = $re->getClasses();
         foreach ($classes as $refclass) {
             $parent_class = $refclass->getParentClass();
             if (!$parent_class) {
                 continue;
             }
             if ($parent_class->getName() == 'midgard_object') {
                 $mgdschemas[] = $refclass->getName();
             }
         }
     }
     return $mgdschemas;
 }
示例#12
0
 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);
}
示例#14
0
/**
 * Prepares a mgd2 database
 */
function openpsa_prepare_database($config)
{
    if (!$config->create_blobdir()) {
        throw new Exception("Failed to create file attachment storage directory to {$config->blobdir}:" . midgard_connection::get_instance()->get_error_string());
    }
    // Create storage
    if (!midgard_storage::create_base_storage()) {
        if (midgard_connection::get_instance()->get_error_string() != 'MGD_ERR_OK') {
            throw new Exception("Failed to create base database structures" . midgard_connection::get_instance()->get_error_string());
        }
    }
    $re = new ReflectionExtension('midgard2');
    $classes = $re->getClasses();
    foreach ($classes as $refclass) {
        if (!$refclass->isSubclassOf('midgard_object')) {
            continue;
        }
        $type = $refclass->getName();
        midgard_storage::create_class_storage($type);
        midgard_storage::update_class_storage($type);
    }
}
示例#15
0
 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);
 }
示例#16
0
$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) ? " " : "");
    //
    if (isset($constants[$ns])) {
        ksort($constants[$ns], SORT_NATURAL);
        foreach ($constants[$ns] as $cn => $value) {
            fprintf($out, "\tconst %s = %s;\n", $cn, var_export($value, true));
        }
示例#17
0
 * 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);
        }
        $processed[$extension] = $details;
<?php

$r = new ReflectionExtension("mysql");
printf("Name: %s\n", $r->name);
printf("Version: %s\n", $r->getVersion());
$classes = $r->getClasses();
if (!empty($classes)) {
    printf("[002] Expecting no class\n");
    asort($classes);
    var_dump($classes);
}
$ignore = array();
$functions = $r->getFunctions();
asort($functions);
printf("Functions:\n");
foreach ($functions as $func) {
    if (isset($ignore[$func->name])) {
        unset($ignore[$func->name]);
    } else {
        printf("  %s\n", $func->name);
    }
}
if (!empty($ignore)) {
    printf("Dumping version dependent and missing functions\n");
    var_dump($ignore);
}
print "done!";
示例#19
0
if (!extension_loaded('midgard2')) {
    throw new midcom_error("This script requires Midgard2");
}
midcom::get('auth')->require_valid_user('basic');
midcom::get('auth')->require_admin_user();
midcom::get()->disable_limits();
while (@ob_end_flush()) {
}
echo "<pre>\n";
echo "<h1>Update Class Storage</h1>\n";
flush();
midgard_storage::create_base_storage();
echo "  Created base storage\n";
$re = new ReflectionExtension('midgard2');
$classes = $re->getClasses();
$counter = 0;
$start = microtime(true);
foreach ($classes as $refclass) {
    if (!$refclass->isSubclassOf('midgard_object')) {
        continue;
    }
    $type = $refclass->getName();
    $counter++;
    if (midgard_storage::class_storage_exists($type)) {
        midgard_storage::update_class_storage($type);
        echo "  Updated storage for {$type}\n";
    } else {
        midgard_storage::create_class_storage($type);
        echo "  Created storage for {$type}\n";
    }
示例#20
0
 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";
 }
示例#21
0
 */
$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)) {
            $ext_info['classes'] = implode(' ', $ext_classes);
        }
示例#22
0
 public function get_mgdschema_classes($include_views = false)
 {
     static $mgdschemas = array();
     if (isset($mgdschemas[$include_views])) {
         return $mgdschemas[$include_views];
     }
     $mgdschemas[$include_views] = array();
     // Get the classes from PHP5 reflection
     $re = new ReflectionExtension('midgard2');
     $classes = $re->getClasses();
     foreach ($classes as $refclass) {
         $parent_class = $refclass->getParentClass();
         if (!$parent_class) {
             continue;
         }
         if ($parent_class->getName() == 'MidgardObject') {
             $mgdschemas[$include_views][] = $refclass->getName();
             continue;
         }
         if ($include_views) {
             if ($parent_class->getName() == 'MidgardView') {
                 $mgdschemas[$include_views][] = $refclass->getName();
             }
         }
     }
     return $mgdschemas[$include_views];
 }
示例#23
0
 public function getClasses()
 {
     return array_map('ClassReflection::import', parent::getClasses());
 }
示例#24
0
 private function _prepare_database(\midgard_config $config)
 {
     $this->_io->write('Preparing storage <comment>(this may take a while)</comment>');
     $midgard = \midgard_connection::get_instance();
     $midgard->open_config($config);
     if (!$midgard->is_connected()) {
         throw new \Exception("Failed to open config {$config->database}:" . $midgard->get_error_string());
     }
     if (!$config->create_blobdir()) {
         throw new \Exception("Failed to create file attachment storage directory to {$config->blobdir}:" . $midgard->get_error_string());
     }
     // Create storage
     if (!\midgard_storage::create_base_storage()) {
         if ($midgard->get_error_string() != 'MGD_ERR_OK') {
             throw new \Exception("Failed to create base database structures" . $midgard->get_error_string());
         }
     }
     $re = new \ReflectionExtension('midgard2');
     $classes = $re->getClasses();
     foreach ($classes as $refclass) {
         if (!$refclass->isSubclassOf('midgard_object')) {
             continue;
         }
         $type = $refclass->getName();
         \midgard_storage::create_class_storage($type);
         \midgard_storage::update_class_storage($type);
     }
     $this->_io->write('Storage created');
 }
 public function getClasses()
 {
     return array_map(array('ClassReflection', 'import'), parent::getClasses());
 }
示例#26
0
文件: docgen.php 项目: guoyu07/NYAF
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 &gt;= Unknown';
            if ($OPTION['pecl'] === true) {
                $version_default = 'PECL {EXT_NAME_ID} &gt;= 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;
}
示例#27
0
    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) {
        /* @var $prop ReflectionProperty */
        $prop->isPrivate() or re($class->getName() . ".xml", "#>{$prop->getName()}<#") or printf("\t%s::\$%s\n", $class->getName(), $prop->getName());
    }
    foreach ($class->getMethods() as $meth) {
        /* @var $meth ReflectionMethod */
        try {
示例#28
0
 * 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());
    }
}
print_r($classes);
border();
示例#29
0
 /**
  * Lists all available MgdSchema types
  *
  * @return array A list of class names
  */
 static function get_schema_types()
 {
     if (isset(self::$_data['schema_types'])) {
         return self::$_data['schema_types'];
     }
     if (null === self::_get('schema', 'types')) {
         // Superglobal is off, Midgard 9.09 or newer
         // Get the classes from PHP5 reflection
         $re = new ReflectionExtension('midgard2');
         $classes = $re->getClasses();
         foreach ($classes as $refclass) {
             if ($refclass->isSubclassOf('midgard_object')) {
                 self::$_data['schema_types'][] = $refclass->getName();
             }
         }
     } else {
         // Midgard 8.09 or 9.03
         self::$_data['schema_types'] = array_keys(self::_get('schema', 'types'));
     }
     return self::$_data['schema_types'];
 }
示例#30
0
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';
$blocks['extensions'][] = 'if ! exists("g:php_syntax_extensions_disabled")';