Example #1
0
 /**
  * Returns this extension's name
  * @return string
  */
 public function getName()
 {
     if ($this->reflectionSource) {
         return $this->reflectionSource->getName();
     } else {
         return parent::getName();
     }
 }
Example #2
0
 public static function tExtension($test, $ext)
 {
     try {
         $ref = new ReflectionExtension($ext);
         $v = $ref->getVersion();
         self::setTestData($test, '%s found%s', $ref->getName(), $v ? ' v' . $v : '');
         return true;
     } catch (ReflectionException $e) {
         self::setTestData($test, $e->getMessage());
     }
     return false;
 }
Example #3
0
 /**
  * @return ExtensionReflection
  * @ignore internal
  */
 public static function import(ReflectionExtension $ref)
 {
     return new self($ref->getName());
 }
Example #4
0
<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>
Example #5
0
 public static function ListPackage()
 {
     foreach (get_loaded_extensions() as $ext) {
         $reflection = new ReflectionExtension($ext);
         foreach ($reflection->getClassNames() as $class) {
             echo $reflection->getName() . ': ' . $class . "\n";
         }
     }
 }
Example #6
0
" Version:      0.0.1
"
" List of constants, functions and classes of PHP\'s extensions
" Generated ' . date('m/d/Y') . ' by ' . __FILE__ . '.php

';
$vim_end = '';
$groups = array();
$types = array('Constants', 'Functions', 'Classes');
foreach ($types as $type) {
    $groups[$type] = array();
}
$extensions = get_loaded_extensions(false);
foreach ($extensions as $extension) {
    $reflex = new ReflectionExtension($extension);
    $name = $reflex->getName();
    $vim_end .= "\n" . '" ' . $name . "\n";
    foreach ($types as $type) {
        $elements = call_user_func(array($reflex, 'get' . $type));
        if (count($elements) == 0) {
            continue;
        }
        $group = 'phpExtension' . $type . '_' . $name;
        $groups[$type][] = $group;
        $vim_end .= 'syntax keyword ' . $group . ' contained ' . implode(' ', array_keys($elements)) . "\n" . 'highlight link ' . $group . ' phpExtension' . $type . "\n\n";
    }
    unset($reflex);
}
$vim_middle = '';
foreach ($types as $type) {
    $vim_middle .= 'syntax cluster phpClExtension' . $type . ' contains=' . implode(',', $groups[$type]) . "\n";
# 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';
Example #8
0
 * 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.
 */
$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);
        }
--TEST--
Reflection Extension -> basic
--FILE--
<?php 
$r = new ReflectionExtension("core");
var_dump($r->getName());
var_dump($r->getVersion());
try {
    $r = new ReflectionExtension("unknown");
} catch (ReflectionException $e) {
    var_dump($e->getMessage());
}
?>
--EXPECTF--
string(4) "Core"
string(%d) "%d.%s
string(32) "Extension unknown does not exist"
Example #10
0
 */
$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;
    } catch (Exception $e) {
        print "ERROR: '{$extension}' -- " . $e->getMessage() . "\n";
    }
}
$code = "syn case match\n\n";
<?php

$obj = new ReflectionExtension('reflection');
var_dump($obj->getName());
?>
==DONE==
Example #12
0
<?php

// Test native property handling with ReflectionExtension
$x = new ReflectionExtension("mysqli");
var_dump($x->getName());
var_dump($x->name);
// This should fatal since $name is technically a read only prop
$x->name = "Bad";
// We should never get here
var_dump($x->name);