本文整理汇总了PHP中ReflectionFunction::getExtensionName方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionFunction::getExtensionName方法的具体用法?PHP ReflectionFunction::getExtensionName怎么用?PHP ReflectionFunction::getExtensionName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionFunction
的用法示例。
在下文中一共展示了ReflectionFunction::getExtensionName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetExtensionName
public function testGetExtensionName()
{
self::assertEquals($this->php_fctM1->getExtensionName(), $this->fctM1->getExtensionName());
self::assertEquals($this->php_fctM2->getExtensionName(), $this->fctM2->getExtensionName());
self::assertEquals($this->php_fctM3->getExtensionName(), $this->fctM3->getExtensionName());
self::assertEquals($this->php_fct_method_exists->getExtensionName(), $this->fct_method_exists->getExtensionName());
}
示例2: importSelected
/**
* Import a single function
*
* @param string extension
* @param string function
* @return [:bool] import
* @throws lang.IllegalArgumentException if extension or function don't exist
*/
public function importSelected($extension, $function)
{
try {
$f = new \ReflectionFunction($function);
} catch (\ReflectionException $e) {
throw new IllegalArgumentException($e->getMessage());
}
if ($extension === strtolower($fe = $f->getExtensionName())) {
return [$function => true];
} else {
throw new IllegalArgumentException('Function ' . $function . ' is not inside extension ' . $extension . ' (but ' . ($fe ?: '(n/a)') . ')');
}
}
示例3: generateFunction
/**
* Called for every reflected function
*
* @param \ReflectionFunction $function
* @param string $generated
* @param $generated
*/
public function generateFunction(\ReflectionFunction $function, $generated)
{
$this->addToExtension($function->getExtensionName(), $generated);
}
示例4: gen_docs
function gen_docs($name, $type)
{
/* {{{ */
global $OPTION, $INFO;
if ($type & DOC_EXTENSION) {
try {
$extension = new ReflectionExtension($name);
$INFO['actual_extension'] = $name;
write_doc($extension, DOC_EXTENSION);
foreach ($extension->getClasses() as $class) {
gen_docs($class->name, DOC_CLASS);
}
foreach ($extension->getFunctions() as $function) {
gen_docs($function->name, DOC_FUNCTION);
}
} catch (Exception $e) {
die('Error: ' . $e->getMessage() . "\n");
}
} else {
if ($type & DOC_FUNCTION) {
try {
$function = new ReflectionFunction($name);
if (!$INFO['actual_extension']) {
if ($extname = $function->getExtensionName()) {
$INFO['actual_extension'] = $extname;
} else {
add_warning("The function {$name} lacks Reflection information");
}
}
write_doc($function, DOC_FUNCTION);
} catch (Exception $e) {
die('Error: ' . $e->getMessage() . "\n");
}
} else {
if ($type & DOC_METHOD) {
try {
$class = new ReflectionClass($OPTION['class']);
if (!$INFO['actual_extension']) {
if ($extname = $class->getExtensionName()) {
$INFO['actual_extension'] = $extname;
} else {
add_warning("The method {$name} lacks Reflection information");
}
}
foreach ($class->getMethods() as $method) {
/* Don't get the inherited methods */
if ($method->getDeclaringClass()->name == $class->name && (is_array($OPTION['method']) && in_array(strtolower($method->getName()), $OPTION['method']) || $OPTION['method'] == strtolower($method->getName()))) {
write_doc($method, $method->isConstructor() ? DOC_CONSTRUCTOR : DOC_METHOD);
}
}
} catch (Exception $e) {
die('Error: ' . $e->getMessage() . "\n");
}
} else {
if ($type & DOC_CLASS) {
try {
$class = new ReflectionClass($name);
if (!$INFO['actual_extension']) {
if ($extname = $class->getExtensionName()) {
$INFO['actual_extension'] = $extname;
} else {
add_warning("The class {$name} lacks Reflection information");
}
}
write_doc($class, DOC_CLASS);
foreach ($class->getMethods() as $method) {
/* Don't get the inherited methods */
if ($method->getDeclaringClass()->name == $class->name) {
write_doc($method, $method->isConstructor() ? DOC_CONSTRUCTOR : DOC_METHOD);
}
}
} catch (Exception $e) {
die('Error: ' . $e->getMessage() . "\n");
}
}
}
}
}
}
示例5: foreach
$funcs = get_defined_functions();
foreach ($funcs['internal'] as $func) {
$rf = new ReflectionFunction($func);
$info = array('kind' => 'f', 'namespace' => $rf->getNamespaceName());
$params = array();
foreach ($rf->getParameters() as $rp) {
$class = '';
if (!defined('HHVM_VERSION')) {
$class = $rp->getClass();
}
$param = '';
if ($class) {
$param = $class->getName() . ' ';
} elseif ($rp->isArray()) {
$param = 'array ';
}
$param .= '$' . $rp->getName();
if ($rp->isOptional() && $rf->isUserDefined()) {
$param .= '=' . json_encode($rp->getDefaultValue());
}
$params[] = $param;
}
$info['type'] = '(' . implode(', ', $params) . ')';
if ($rf->isInternal()) {
$filename = '(ext-' . $rf->getExtensionName() . ')';
} else {
$filename = str_replace($base, '', $rf->getFileName());
}
fwrite($fp, implode("\t", array($rf->getName(), $filename, $rf->getStartLine() . ';"', '')) . $build($info) . PHP_EOL);
}
});
示例6: getExtension
/**
* Returns NULL or the extension the function belongs to
*
* @return ezcReflectionExtension Extension the function belongs to
*/
public function getExtension()
{
if ($this->getExtensionName() === false) {
return null;
} else {
if ($this->reflectionSource instanceof ReflectionFunction) {
return new ezcReflectionExtension($this->reflectionSource->getExtension());
} else {
// using the name, since otherwhise the object would be treated like an
// external reflection implementation and that would decrease performance
return new ezcReflectionExtension(parent::getExtensionName());
}
}
}
示例7: foo
<?php
function foo()
{
}
$function = new ReflectionFunction('sort');
var_dump($function->getExtensionName());
$function = new ReflectionFunction('foo');
var_dump($function->getExtensionName());
示例8: ReflectionFunction
<?php
$f = new ReflectionFunction("sleep");
var_dump($f->getExtensionName());