本文整理汇总了PHP中ReflectionFunction::getShortName方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionFunction::getShortName方法的具体用法?PHP ReflectionFunction::getShortName怎么用?PHP ReflectionFunction::getShortName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionFunction
的用法示例。
在下文中一共展示了ReflectionFunction::getShortName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import
public function import(\ReflectionFunction $function)
{
$this->name = $function->name;
$this->function = $function->getShortName();
$this->namespace = $function->getNamespaceName();
$this->_importFromReflection($function);
}
示例2: definition
function definition($functionName)
{
$details = new \ReflectionFunction("JREAM\\{$functionName}");
$output = '<div>';
$output .= "<strong>{$details->getShortName()}</strong>( ";
foreach ($details->getParameters() as $reflectObj) {
foreach ($reflectObj as $arg) {
$output .= "\${$arg}, ";
}
}
$output = rtrim($output, ' ,');
$output .= " )";
$output .= '</div>';
return $output;
}
示例3: forFunction
/**
* @param $function
* @return BuildParameterArray
* @throws \ReflectionException
*/
public static function forFunction($function)
{
if (!is_callable($function)) {
$template = 'Error building parameters, Function {$method_name} does not exist';
$message = (new ReplaceVarsFromArray($template))->apply(['method_name' => $function]);
throw new \ReflectionException($message);
}
// Allow for [$class, $method] callable syntax which doesn't work with
// ReflectionFunction.
if (is_array($function)) {
list($class, $method) = $function;
return static::forMethod($class, $method);
}
$reflection_function = new \ReflectionFunction($function);
$reflection_parameters = $reflection_function->getParameters();
return new static($reflection_parameters, $reflection_function->getShortName());
}
示例4: fromCallable
/**
* @param callable $function
*
* @return \ReflectionFunctionAbstract
* @throws InvalidFunctionException
*/
public static final function fromCallable(callable $function)
{
// If is array it could be an instance or static method:
// ['class', 'method'] or [$instance, 'method'];
if (is_array($function)) {
return new \ReflectionMethod($function[0], $function[1]);
} elseif ($function instanceof \Closure) {
$reflection = new \ReflectionFunction($function);
// If the name is {closure} it as an actual closure
if ($reflection->getShortName() === '{closure}') {
return $reflection;
}
// Bail out, no (sane) way of determining the actual function
// represented by the closure
throw InvalidFunctionException::invalidFunctionMessage('The function has been wrapped in closure ' . '(most likely via ReflectionFunction::getClosure or \\ReflectionMethod::getClosure) ' . 'and this is not supported', $reflection);
} elseif (is_object($function)) {
return new \ReflectionMethod($function, '__invoke');
} else {
$name = null;
is_callable($function, false, $name);
return new \ReflectionFunction($name);
}
}
示例5: foo
<?php
namespace A\B;
function foo()
{
}
$function = new \ReflectionFunction('sort');
var_dump($function->inNamespace());
var_dump($function->getName());
var_dump($function->getNamespaceName());
var_dump($function->getShortName());
$function = new \ReflectionFunction('A\\B\\foo');
var_dump($function->inNamespace());
var_dump($function->getName());
var_dump($function->getNamespaceName());
var_dump($function->getShortName());
示例6: test
$staticX++;
$x = $staticX;
return $x;
}
class Test
{
public function test()
{
}
}
$rf = new \ReflectionFunction('\\foo\\bar\\f');
print "--- getShortName(\"\\foo\\bar\\f\") ---\n";
var_dump($rf->getShortName());
print "\n";
print "--- getNamespaceName(\"\\foo\\bar\\f\") ---\n";
var_dump($rf->getNamespaceName());
print "\n";
$rf = new \ReflectionMethod('\\foo\\bar\\Test', 'test');
print "--- getShortName(\"\\foo\\bar\\Test::test\") ---\n";
var_dump($rf->getShortName());
print "\n";
print "--- getNamespaceName(\"\\foo\\bar\\Test::test\") ---\n";
var_dump($rf->getNamespaceName());
print "\n";
$rf = new \ReflectionFunction('\\strlen');
print "--- getShortName(\"strlen\") ---\n";
var_dump($rf->getShortName());
print "\n";
print "--- getNamespaceName(\"strlen\") ---\n";
var_dump($rf->getNamespaceName());
print "\n";