本文整理汇总了PHP中ReflectionFunction::getExtension方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionFunction::getExtension方法的具体用法?PHP ReflectionFunction::getExtension怎么用?PHP ReflectionFunction::getExtension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionFunction
的用法示例。
在下文中一共展示了ReflectionFunction::getExtension方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetExtension
public function testGetExtension()
{
self::assertEquals($this->php_fctM1->getExtension(), $this->fctM1->getExtension());
self::assertEquals($this->php_fctM2->getExtension(), $this->fctM2->getExtension());
self::assertEquals($this->php_fctM3->getExtension(), $this->fctM3->getExtension());
self::assertEquals((string) $this->php_fct_method_exists->getExtension(), (string) $this->fct_method_exists->getExtension());
}
示例2: 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());
}
}
}
示例3: getExtension
/**
* @return ExtensionReflection
*/
public function getExtension()
{
return ($ref = parent::getExtension()) ? ExtensionReflection::import($ref) : NULL;
}
示例4: populate_method_info
/**
* returns an array containing a record for each defined method.
*/
function populate_method_info()
{
$method_info = array();
// get functions
$all_functions = get_defined_functions();
$internal_functions = $all_functions["internal"];
foreach ($internal_functions as $function) {
// populate new method record
$function_record = array();
$function_record[CLASS_NAME] = "Function";
$function_record[METHOD_NAME] = $function;
$function_record[IS_TESTED] = "no";
$function_record[TESTS] = "";
$function_record[IS_DUPLICATE] = false;
// record the extension that the function belongs to
$reflectionFunction = new ReflectionFunction($function);
$extension = $reflectionFunction->getExtension();
if ($extension != null) {
$function_record[EXTENSION_NAME] = $extension->getName();
} else {
$function_record[EXTENSION_NAME] = "";
}
// insert new method record into info array
$method_info[] = $function_record;
}
// get methods
$all_classes = get_declared_classes();
foreach ($all_classes as $class) {
$reflectionClass = new ReflectionClass($class);
$methods = $reflectionClass->getMethods();
foreach ($methods as $method) {
// populate new method record
$new_method_record = array();
$new_method_record[CLASS_NAME] = $reflectionClass->getName();
$new_method_record[METHOD_NAME] = $method->getName();
$new_method_record[IS_TESTED] = "no";
$new_method_record[TESTS] = "";
$extension = $reflectionClass->getExtension();
if ($extension != null) {
$new_method_record[EXTENSION_NAME] = $extension->getName();
} else {
$new_method_record[EXTENSION_NAME] = "";
}
// check for duplicate method names
$new_method_record[IS_DUPLICATE] = false;
foreach ($method_info as &$current_record) {
if (strcmp($current_record[METHOD_NAME], $new_method_record[METHOD_NAME]) == 0) {
$new_method_record[IS_DUPLICATE] = true;
$current_record[IS_DUPLICATE] = true;
}
}
// insert new method record into info array
$method_info[] = $new_method_record;
}
}
return $method_info;
}
示例5: foo
<?php
function foo()
{
}
$function = new ReflectionFunction('sort');
var_dump($function->getExtension());
$function = new ReflectionFunction('foo');
var_dump($function->getExtension());