本文整理汇总了PHP中ReflectionExtension::getFunctions方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionExtension::getFunctions方法的具体用法?PHP ReflectionExtension::getFunctions怎么用?PHP ReflectionExtension::getFunctions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionExtension
的用法示例。
在下文中一共展示了ReflectionExtension::getFunctions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFunctions
/**
* Returns an array of this extension's fuctions
* @return ezcReflectionFunction[]
*/
public function getFunctions()
{
if ($this->reflectionSource) {
$functs = $this->reflectionSource->getFunctions();
} else {
$functs = parent::getFunctions();
}
$result = array();
foreach ($functs as $func) {
$result[] = new ezcReflectionFunction($func);
}
return $result;
}
示例2: getFunctions
public function getFunctions()
{
foreach ($res = parent::getFunctions() as $key => $val) {
$res[$key] = new FunctionReflection($key);
}
return $res;
}
示例3: getTagsForExtension
/**
* @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: getFunctions
public function getFunctions()
{
$functs = parent::getFunctions();
$result = array();
foreach ($functs as $func) {
$result[] = new MyReflectionFunction($func->getName());
}
return $result;
}
示例5: __construct
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());
}
}
示例6: getFunctions
public function getFunctions()
{
$phpReflections = parent::getFunctions();
$zendReflections = array();
while ($phpReflections && ($phpReflection = array_shift($phpReflections))) {
$zendReflections[] = new ZendL_Reflection_Function($phpReflection->getName());
unset($phpReflection);
}
unset($phpReflections);
return $zendReflections;
}
示例7: getFunctions
/**
* Get all this extensions functions
*
* @return Nerd\Design\Collection Enumerable array of extension functions
*/
public function getFunctions()
{
if ($this->functions === null) {
$functions = parent::getFunctions();
foreach ($functions as $key => $function) {
$functions[$key] = new Funktion($function->getName());
}
$this->functions = new Collection($functions);
}
return $this->functions;
}
示例8: __invoke
/**
* @param string[] $extensionNames
* @return string[]
* @throws UnknownExtensionException if the extension cannot be found
*/
public function __invoke(array $extensionNames) : array
{
$definedSymbols = [];
foreach ($extensionNames as $extensionName) {
try {
$extensionReflection = new \ReflectionExtension($extensionName);
$definedSymbols = array_merge($definedSymbols, array_keys($extensionReflection->getConstants()), array_keys($extensionReflection->getFunctions()), $extensionReflection->getClassNames());
} catch (\Exception $e) {
throw new UnknownExtensionException($e->getMessage());
}
}
return $definedSymbols;
}
示例9: getFunctions
/**
* Get extension function reflection objects
*
* @param string $reflectionClass Name of reflection class to use
* @return array Array of Zend_Reflection_Function objects
*/
public function getFunctions($reflectionClass = 'Zend_Reflection_Function')
{
$phpReflections = parent::getFunctions();
$zendReflections = array();
while ($phpReflections && ($phpReflection = array_shift($phpReflections))) {
$instance = new $reflectionClass($phpReflection->getName());
if (!$instance instanceof Zend_Reflection_Function) {
throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend Zend_Reflection_Function');
}
$zendReflections[] = $instance;
unset($phpReflection);
}
unset($phpReflections);
return $zendReflections;
}
示例10: mustHaveExtension
private static function mustHaveExtension($ext)
{
if (!extension_loaded($ext)) {
echo "ERROR: The PHP extension '{$ext}' is not installed. You must " . "install it to run aphlict on this machine.\n";
exit(1);
}
$extension = new ReflectionExtension($ext);
foreach ($extension->getFunctions() as $function) {
$function = $function->name;
if (!function_exists($function)) {
echo "ERROR: The PHP function {$function}() is disabled. You must " . "enable it to run aphlict on this machine.\n";
exit(1);
}
}
}
示例11: mustHaveExtension
private static function mustHaveExtension($ext)
{
if (!extension_loaded($ext)) {
echo pht("ERROR: The PHP extension '%s' is not installed. You must " . "install it to run Aphlict on this machine.", $ext) . "\n";
exit(1);
}
$extension = new ReflectionExtension($ext);
foreach ($extension->getFunctions() as $function) {
$function = $function->name;
if (!function_exists($function)) {
echo pht('ERROR: The PHP function %s is disabled. You must ' . 'enable it to run Aphlict on this machine.', $function . '()') . "\n";
exit(1);
}
}
}
示例12: expectArgumentError
function expectArgumentError($message)
{
try {
$extension = new \ReflectionExtension('functional');
$extensionFunctions = array_keys($extension->getFunctions());
$isDefinedInExtension = F\every($this->functions, function ($function) use($extensionFunctions) {
return in_array($function, $extensionFunctions, true);
});
if ($isDefinedInExtension) {
$this->setExpectedException('PHPUnit_Framework_Error_Warning', $message);
} else {
$this->setExpectedException('Functional\\Exceptions\\InvalidArgumentException', $message);
}
} catch (\ReflectionException $e) {
$this->setExpectedException('Functional\\Exceptions\\InvalidArgumentException', $message);
}
}
示例13: introspect
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);
}
示例14: 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);
}
示例15: export
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);
}