本文整理汇总了PHP中ReflectionExtension::getVersion方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionExtension::getVersion方法的具体用法?PHP ReflectionExtension::getVersion怎么用?PHP ReflectionExtension::getVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionExtension
的用法示例。
在下文中一共展示了ReflectionExtension::getVersion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _generateFileStructure
/**
* @return void
*/
protected function _generateFileStructure()
{
$classes = $this->_extension->getClassNames();
foreach ($classes as $class) {
$reflectionClass = new \ReflectionClass($class);
$output = "<?php\n\n";
$output .= $this->_exportNamespace($reflectionClass);
$output .= $this->_exportDefinition($reflectionClass);
$output .= "\n{\n\n";
$output .= $this->_exportClassConstants($reflectionClass);
$output .= $this->_exportClassProperties($reflectionClass);
$output .= $this->_exportClassMethods($reflectionClass);
$output .= "}";
$dir_class = str_replace('\\', DIRECTORY_SEPARATOR, $reflectionClass->getNamespaceName());
$dir = $this->_targetDir . DIRECTORY_SEPARATOR . $this->_extension->getVersion() . DIRECTORY_SEPARATOR . $dir_class;
if (!is_dir($dir)) {
mkdir($dir, 0777, true);
}
$file = str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
$path = $this->_targetDir . DIRECTORY_SEPARATOR . $this->_extension->getVersion() . DIRECTORY_SEPARATOR . $file;
$fp = fopen($path, 'w+');
fputs($fp, $output);
fclose($fp);
}
}
示例2: initialize
protected function initialize()
{
parent::initialize();
$versionParser = new VersionParser();
try {
$prettyVersion = PHP_VERSION;
$version = $versionParser->normalize($prettyVersion);
} catch (\UnexpectedValueException $e) {
$prettyVersion = preg_replace('#^(.+?)(-.+)?$#', '$1', PHP_VERSION);
$version = $versionParser->normalize($prettyVersion);
}
$php = new MemoryPackage('php', $version, $prettyVersion);
$php->setDescription('The PHP interpreter');
parent::addPackage($php);
foreach (get_loaded_extensions() as $name) {
if (in_array($name, array('standard', 'Core'))) {
continue;
}
$reflExt = new \ReflectionExtension($name);
try {
$prettyVersion = $reflExt->getVersion();
$version = $versionParser->normalize($prettyVersion);
} catch (\UnexpectedValueException $e) {
$prettyVersion = '0';
$version = $versionParser->normalize($prettyVersion);
}
$ext = new MemoryPackage('ext-' . $name, $version, $prettyVersion);
$ext->setDescription('The ' . $name . ' PHP extension');
parent::addPackage($ext);
}
}
示例3: welcomeOp
/**
* 欢迎页面
*/
public function welcomeOp()
{
/**
* 管理员信息
*/
$model_admin = Model('admin');
$tmp = $this->getAdminInfo();
$condition['admin_id'] = $tmp['id'];
$admin_info = $model_admin->infoAdmin($condition);
$admin_info['admin_login_time'] = date('Y-m-d H:i:s', $admin_info['admin_login_time'] == '' ? time() : $admin_info['admin_login_time']);
/**
* 系统信息
*/
$version = C('version');
$setup_date = C('setup_date');
$statistics['os'] = PHP_OS;
$statistics['web_server'] = $_SERVER['SERVER_SOFTWARE'];
$statistics['php_version'] = PHP_VERSION;
$statistics['sql_version'] = Db::getServerInfo();
$statistics['shop_version'] = $version;
$statistics['setup_date'] = substr($setup_date, 0, 10);
// 运维舫 c extension
try {
$r = new ReflectionExtension('shopnc');
$statistics['php_version'] .= ' / ' . $r->getVersion();
} catch (ReflectionException $ex) {
}
Tpl::output('statistics', $statistics);
Tpl::output('admin_info', $admin_info);
Tpl::showpage('welcome');
}
示例4: ReflectionExtension
function __construct()
{
if (!extension_loaded(self::EXTENSION_NAME)) {
throw new \Exception("no " . self::EXTENSION_NAME . " extension.");
}
$this->rf_ext = new ReflectionExtension(self::EXTENSION_NAME);
$this->version = $this->rf_ext->getVersion();
}
示例5: getVersion
/**
* Returns this extension's version
* @return string
*/
public function getVersion()
{
if ($this->reflectionSource) {
return $this->reflectionSource->getVersion();
} else {
return parent::getVersion();
}
}
示例6: tExtension
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;
}
示例7: __construct
/**
* Constructor.
*/
protected function __construct()
{
$this->memcached = new \Memcached();
$this->memcached->addServer(Config::getCacheHost(), Config::getCachePort());
$this->memcached->setOption(\Memcached::OPT_PREFIX_KEY, Config::getCachePrefix());
//determine if deleteMulti() is supported
if (defined('HHVM_VERSION')) {
$this->hasMultiDelete = false;
} else {
$ext = new \ReflectionExtension('memcached');
$this->hasMultiDelete = version_compare($ext->getVersion(), '2.0.0', '>=');
}
}
示例8: opcodeCacheData
/**
* @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;
}
示例9: export_ext
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);
}
示例10: initialize
protected function initialize()
{
parent::initialize();
$versionParser = new VersionParser();
// Add each of the override versions as options.
// Later we might even replace the extensions instead.
foreach ($this->overrides as $override) {
// Check that it's a platform package.
if (!preg_match(self::PLATFORM_PACKAGE_REGEX, $override['name'])) {
throw new \InvalidArgumentException('Invalid platform package name in config.platform: ' . $override['name']);
}
$version = $versionParser->normalize($override['version']);
$package = new CompletePackage($override['name'], $version, $override['version']);
$package->setDescription('Package overridden via config.platform');
$package->setExtra(array('config.platform' => true));
parent::addPackage($package);
}
$prettyVersion = PluginInterface::PLUGIN_API_VERSION;
$version = $versionParser->normalize($prettyVersion);
$composerPluginApi = new CompletePackage('composer-plugin-api', $version, $prettyVersion);
$composerPluginApi->setDescription('The Composer Plugin API');
$this->addPackage($composerPluginApi);
try {
$prettyVersion = PHP_VERSION;
$version = $versionParser->normalize($prettyVersion);
} catch (\UnexpectedValueException $e) {
$prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', PHP_VERSION);
$version = $versionParser->normalize($prettyVersion);
}
$php = new CompletePackage('php', $version, $prettyVersion);
$php->setDescription('The PHP interpreter');
$this->addPackage($php);
if (PHP_INT_SIZE === 8) {
$php64 = new CompletePackage('php-64bit', $version, $prettyVersion);
$php64->setDescription('The PHP interpreter, 64bit');
$this->addPackage($php64);
}
$loadedExtensions = get_loaded_extensions();
// Extensions scanning
foreach ($loadedExtensions as $name) {
if (in_array($name, array('standard', 'Core'))) {
continue;
}
$reflExt = new \ReflectionExtension($name);
try {
$prettyVersion = $reflExt->getVersion();
$version = $versionParser->normalize($prettyVersion);
} catch (\UnexpectedValueException $e) {
$prettyVersion = '0';
$version = $versionParser->normalize($prettyVersion);
}
$packageName = $this->buildPackageName($name);
$ext = new CompletePackage($packageName, $version, $prettyVersion);
$ext->setDescription('The ' . $name . ' PHP extension');
$this->addPackage($ext);
}
// Another quick loop, just for possible libraries
// Doing it this way to know that functions or constants exist before
// relying on them.
foreach ($loadedExtensions as $name) {
$prettyVersion = null;
$description = 'The ' . $name . ' PHP library';
switch ($name) {
case 'curl':
$curlVersion = curl_version();
$prettyVersion = $curlVersion['version'];
break;
case 'iconv':
$prettyVersion = ICONV_VERSION;
break;
case 'intl':
$name = 'ICU';
if (defined('INTL_ICU_VERSION')) {
$prettyVersion = INTL_ICU_VERSION;
} else {
$reflector = new \ReflectionExtension('intl');
ob_start();
$reflector->info();
$output = ob_get_clean();
preg_match('/^ICU version => (.*)$/m', $output, $matches);
$prettyVersion = $matches[1];
}
break;
case 'libxml':
$prettyVersion = LIBXML_DOTTED_VERSION;
break;
case 'openssl':
$prettyVersion = preg_replace_callback('{^(?:OpenSSL\\s*)?([0-9.]+)([a-z]*).*}', function ($match) {
if (empty($match[2])) {
return $match[1];
}
// OpenSSL versions add another letter when they reach Z.
// e.g. OpenSSL 0.9.8zh 3 Dec 2015
if (!preg_match('{^z*[a-z]$}', $match[2])) {
// 0.9.8abc is garbage
return 0;
}
$len = strlen($match[2]);
$patchVersion = ($len - 1) * 26;
// All Z
//.........这里部分代码省略.........
示例11: ReflectionExtension
<?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!";
示例12: check
echo "Environment Check{$n}";
echo "-----------------{$n}{$n}";
echo "\"-\" indicates success.{$n}";
echo "\"*\" indicates error.{$n}{$n}";
// check version
check('You have a supported version of PHP (>= 5.3.3).', 'You need PHP 5.3.3 or greater.', function () {
return version_compare(PHP_VERSION, '5.3.3', '>=');
});
// check phar extension
check('You have the "phar" extension installed.', 'You need to have the "phar" extension installed.', function () {
return extension_loaded('phar');
});
// check phar extension version
check('You have a supported version of the "phar" extension.', 'You need a newer version of the "phar" extension (>=2.0).', function () {
$phar = new ReflectionExtension('phar');
return version_compare($phar->getVersion(), '2.0', '>=');
});
// check openssl extension
check('You have the "openssl" extension installed.', 'Notice: The "openssl" extension will be needed to sign with private keys.', function () {
return extension_loaded('openssl');
}, false);
// check phar readonly setting
check('The "phar.readonly" setting is off.', 'Notice: The "phar.readonly" setting needs to be off to create Phars.', function () {
return false == ini_get('phar.readonly');
}, false);
// check detect unicode setting
check('The "detect_unicode" setting is off.', 'The "detect_unicode" setting needs to be off.', function () {
return false == ini_get('detect_unicode');
});
// check suhosin setting
if (extension_loaded('suhosin')) {
示例13: checkZkState
public function checkZkState()
{
/*{{{*/
$ext = new ReflectionExtension('zookeeper');
$ver = $ext->getVersion();
if (version_compare($ver, '0.2.0') < 0) {
//throw new LogConfException("Required version of extension($name) is at least $version_min!");
return;
}
$state = getState($this->zkClient_);
if (ZOK != $state) {
throw new LogConfException("zookeeper connection state wrong: {$state}");
}
}
示例14: ReflectionExtension
--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"
示例15: loadModuleIfAbsent
/**
* Load PHP extension (module) if absent
* @param string $mod
* @param string $version
* @param string $compare
* @return bool $success
*/
public static function loadModuleIfAbsent($mod, $version = null, $compare = '>=')
{
if (!extension_loaded($mod)) {
if (!get_cfg_var('enable_dl')) {
return false;
}
if (!@dl(basename($mod) . '.so')) {
return false;
}
}
if (!$version) {
return true;
}
try {
$ext = new \ReflectionExtension($mod);
return version_compare($ext->getVersion(), $version, $compare);
} catch (\ReflectionException $e) {
return false;
}
}