本文整理汇总了PHP中ReflectionFunction::isInternal方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionFunction::isInternal方法的具体用法?PHP ReflectionFunction::isInternal怎么用?PHP ReflectionFunction::isInternal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionFunction
的用法示例。
在下文中一共展示了ReflectionFunction::isInternal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isInternal
/**
* Returns whether this is an internal function
*
* @return boolean True if this is an internal function
*/
public function isInternal()
{
if ($this->reflectionSource instanceof ReflectionFunction) {
return $this->reflectionSource->isInternal();
} else {
return parent::isInternal();
}
}
示例2: dumpFuncInfo
function dumpFuncInfo($name)
{
$funcInfo = new ReflectionFunction($name);
var_dump($funcInfo->getName());
var_dump($funcInfo->isInternal());
var_dump($funcInfo->isUserDefined());
var_dump($funcInfo->getStartLine());
var_dump($funcInfo->getEndLine());
var_dump($funcInfo->getStaticVariables());
}
示例3: isInternalFunction
/**
* @param string $name
* @return bool
*/
protected function isInternalFunction($name)
{
try {
$ref_func = new ReflectionFunction($name);
return $ref_func->isInternal();
} catch (ReflectionException $e) {
// ReflectionException: Function xxx() does not exist
return false;
}
}
示例4: isPhpFunction
private function isPhpFunction(Link $link)
{
$functionName = $link->getDestination();
if (!$this->isMethodLink($functionName)) {
return;
}
$functionName = substr($functionName, 0, -2);
if (!function_exists($functionName)) {
return false;
}
$functionReflection = new \ReflectionFunction($functionName);
return $functionReflection->isInternal();
}
示例5: addFunctions
protected function addFunctions($parent, array $functions)
{
if (!empty($functions['internal'])) {
$functions = $functions['internal'];
}
foreach ($functions as $ref) {
if (is_string($ref)) {
$ref = new \ReflectionFunction($ref);
}
if (!$ref->isInternal()) {
return;
}
$name = getFunctionString($ref);
$this->append($parent, array($name, $ref));
}
}
示例6: testRegisterResetAndValues
public function testRegisterResetAndValues()
{
$this->assertFalse(Manager::overridden('natcasesort'));
Manager::register('\\Skeetr\\Tests\\Runtime\\Example');
$function = new \ReflectionFunction('natcasesort');
$this->assertFalse($function->isInternal());
$this->assertSame('foo', natcasesort('foo'));
$this->assertTrue(Manager::overridden('natcasesort'));
$this->assertSame(1, Example::$test);
Example::$test = 0;
Manager::reset();
$this->assertSame(1, Example::$test);
Example::$test = 0;
Manager::reset('\\Skeetr\\Tests\\Runtime\\Example');
$this->assertSame(1, Example::$test);
$this->assertTrue(false === Manager::reset('NotExists'));
$expected = array('example' => array('test' => 1));
$this->assertSame($expected, Manager::values('\\Skeetr\\Tests\\Runtime\\Example'));
$values = Manager::values('\\Skeetr\\Tests\\Runtime\\Example');
$this->assertSame(1, $values['example']['test']);
}
示例7: ouptutUnusedFunctionsReport
/**
* @return string
*/
private function ouptutUnusedFunctionsReport()
{
//prepare unused functions report
$functions = get_defined_functions();
$functions = array_filter($functions['user'], 'strtolower');
$calledFunctions = array_filter($this->calledFunctions, 'strtolower');
$deprecatedFunctions = array_filter(array_keys(code_review::getDeprecatedFunctionsList($this->maxVersion)), 'strtolower');
$functions = array_diff($functions, $calledFunctions, $deprecatedFunctions);
foreach ($functions as $key => $function) {
if (function_exists($function)) {
$reflectionFunction = new ReflectionFunction($function);
if (!$reflectionFunction->isInternal()) {
continue;
}
unset($reflectionFunction);
}
unset($functions[$key]);
}
sort($functions);
//unused functions report
$result = "Not called but defined funcions:\n";
$baseLenght = strlen(elgg_get_root_path());
foreach (array_values($functions) as $functionName) {
$reflectionFunction = new ReflectionFunction($functionName);
$path = substr($reflectionFunction->getFileName(), $baseLenght);
if (strpos($path, 'engine') !== 0) {
continue;
}
$result .= "{$functionName} \t{$path}:{$reflectionFunction->getStartLine()}\n";
}
return $result;
}
示例8: checkRule
//.........这里部分代码省略.........
$args[0] = isset($args[0]) && $args[0] == 'true' ? TRUE : false;
return !empty($val) ? preg_match('/^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$/', $val) : $args[0];
case 'url':
$args[0] = isset($args[0]) && $args[0] == 'true' ? TRUE : false;
return !empty($val) ? preg_match('/^http[s]?:\\/\\/[A-Za-z0-9]+\\.[A-Za-z0-9]+[\\/=\\?%\\-&_~`@[\\]\':+!]*([^<>\\"])*$/', $val) : $args[0];
case 'qq':
$args[0] = isset($args[0]) && $args[0] == 'true' ? TRUE : false;
return !empty($val) ? preg_match('/^[1-9][0-9]{4,}$/', $val) : $args[0];
case 'phone':
$args[0] = isset($args[0]) && $args[0] == 'true' ? TRUE : false;
return !empty($val) ? preg_match('/^(?:\\d{3}-?\\d{8}|\\d{4}-?\\d{7})$/', $val) : $args[0];
case 'mobile':
$args[0] = isset($args[0]) && $args[0] == 'true' ? TRUE : false;
return !empty($val) ? preg_match('/^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(14[0-9]{1}))+\\d{8})$/', $val) : $args[0];
case 'zipcode':
$args[0] = isset($args[0]) && $args[0] == 'true' ? TRUE : false;
return !empty($val) ? preg_match('/^[1-9]\\d{5}(?!\\d)$/', $val) : $args[0];
case 'idcard':
$args[0] = isset($args[0]) && $args[0] == 'true' ? TRUE : false;
return !empty($val) ? preg_match('/^\\d{14}(\\d{4}|(\\d{3}[xX])|\\d{1})$/', $val) : $args[0];
case 'ip':
$args[0] = isset($args[0]) && $args[0] == 'true' ? TRUE : false;
return !empty($val) ? preg_match('/^((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$/', $val) : $args[0];
case 'chs':
$count = implode(',', array_slice($args, 1, 2));
$count = empty($count) ? '1,' : $count;
$can_empty = isset($args[0]) && $args[0] == 'true';
return !empty($val) ? preg_match('/^[\\x{4e00}-\\x{9fa5}]{' . $count . '}$/u', $val) : $can_empty;
case 'date':
$args[0] = isset($args[0]) && $args[0] == 'true' ? TRUE : false;
return !empty($val) ? preg_match('/^[0-9]{4}-(((0[13578]|(10|12))-(0[1-9]|[1-2][0-9]|3[0-1]))|(02-(0[1-9]|[1-2][0-9]))|((0[469]|11)-(0[1-9]|[1-2][0-9]|30)))$/', $val) : $args[0];
case 'time':
$args[0] = isset($args[0]) && $args[0] == 'true' ? TRUE : false;
return !empty($val) ? preg_match('/^(([0-1][0-9])|([2][0-3])):([0-5][0-9])(:([0-5][0-9]))$/', $val) : $args[0];
case 'datetime':
$args[0] = isset($args[0]) && $args[0] == 'true' ? TRUE : false;
return !empty($val) ? preg_match('/^[0-9]{4}-(((0[13578]|(10|12))-(0[1-9]|[1-2][0-9]|3[0-1]))|(02-(0[1-9]|[1-2][0-9]))|((0[469]|11)-(0[1-9]|[1-2][0-9]|30))) (([0-1][0-9])|([2][0-3])):([0-5][0-9])(:([0-5][0-9]))$/', $val) : $args[0];
case 'reg':
#正则表达式验证,reg[/^[\]]$/i]
/**
* 模式修正符说明:
i 表示在和模式进行匹配进不区分大小写
m 将模式视为多行,使用^和$表示任何一行都可以以正则表达式开始或结束
s 如果没有使用这个模式修正符号,元字符中的"."默认不能表示换行符号,将字符串视为单行
x 表示模式中的空白忽略不计
e 正则表达式必须使用在preg_replace替换字符串的函数中时才可以使用(讲这个函数时再说)
A 以模式字符串开头,相当于元字符^
Z 以模式字符串结尾,相当于元字符$
U 正则表达式的特点:就是比较“贪婪”,使用该模式修正符可以取消贪婪模式
*/
return !empty($args[0]) ? preg_match($args[0], $val) : false;
/**
* set set_post不参与验证,返回true跳过
*
* 说明:
* set用于设置在验证数据前对数据进行处理的函数或者方法
* set_post用于设置在验证数据后对数据进行处理的函数或者方法
* 如果设置了set,数据在验证的时候验证的是处理过的数据
* 如果设置了set_post,可以通过第三个参数$data接收数据:$this->checkData($rule, $_POST, $data),$data是验证通过并经过set_post处理后的数据
* set和set_post后面是一个或者多个函数或者方法,多个逗号分割
* 注意:
* 1.无论是函数或者方法都必须有一个字符串返回
* 2.如果是系统函数,系统会传递当前值给系统函数,因此系统函数必须是至少接受一个字符串参数,比如md5,trim
* 3.如果是自定义的函数,系统会传递当前值和全部数据给自定义的函数,因此自定义函数可以接收两个参数第一个是值,第二个是全部数据$data
* 4.如果是类的方法写法是:类名称::方法名 (方法静态动态都可以,public,private,都可以)
*/
/**
* set set_post不参与验证,返回true跳过
*
* 说明:
* set用于设置在验证数据前对数据进行处理的函数或者方法
* set_post用于设置在验证数据后对数据进行处理的函数或者方法
* 如果设置了set,数据在验证的时候验证的是处理过的数据
* 如果设置了set_post,可以通过第三个参数$data接收数据:$this->checkData($rule, $_POST, $data),$data是验证通过并经过set_post处理后的数据
* set和set_post后面是一个或者多个函数或者方法,多个逗号分割
* 注意:
* 1.无论是函数或者方法都必须有一个字符串返回
* 2.如果是系统函数,系统会传递当前值给系统函数,因此系统函数必须是至少接受一个字符串参数,比如md5,trim
* 3.如果是自定义的函数,系统会传递当前值和全部数据给自定义的函数,因此自定义函数可以接收两个参数第一个是值,第二个是全部数据$data
* 4.如果是类的方法写法是:类名称::方法名 (方法静态动态都可以,public,private,都可以)
*/
case 'set':
case 'set_post':
return true;
default:
$_args = array_merge(array($val, $data), $args);
$matches = self::getCheckRuleInfo($_rule);
$func = $matches[1];
$args = $matches[2];
if (function_exists($func)) {
$reflection = new ReflectionFunction($func);
//如果是系统函数
if ($reflection->isInternal()) {
$_args = isset($_args[0]) ? array($_args[0]) : array();
}
}
return self::callFunc($_rule, $_args);
}
return false;
}
示例9: 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);
}
});
示例10: sayHello
<pre>
<?php
function sayHello($name, $h)
{
static $count = 0;
return "<h{$h}>Hello, {$name}</h{$h}>";
}
// Обзор функции
Reflection::export(new ReflectionFunction('sayHello'));
// Создание экземпляра класса ReflectionFunction
$func = new ReflectionFunction('sayHello');
// Вывод основной информации
printf("<p>===> %s функция '%s'\n" . " объявлена в %s\n" . " строки с %d по %d\n", $func->isInternal() ? 'Internal' : 'User-defined', $func->getName(), $func->getFileName(), $func->getStartLine(), $func->getEndline());
// Вывод статических переменных, если они есть
if ($statics = $func->getStaticVariables()) {
printf("<p>---> Статическая переменная: %s\n", var_export($statics, 1));
}
// Вызов функции
printf("<p>---> Результат вызова: ");
$result = $func->invoke("John", "1");
echo $result;
?>
</pre>
示例11: test
<?php
/**
hoho
*/
function test($a, $b = 1, $c = "")
{
static $var = 1;
}
$func = new ReflectionFunction("test");
var_dump($func->export("test"));
echo "--getName--\n";
var_dump($func->getName());
echo "--isInternal--\n";
var_dump($func->isInternal());
echo "--isUserDefined--\n";
var_dump($func->isUserDefined());
echo "--getFilename--\n";
var_dump($func->getFilename());
echo "--getStartline--\n";
var_dump($func->getStartline());
echo "--getEndline--\n";
var_dump($func->getEndline());
echo "--getDocComment--\n";
var_dump($func->getDocComment());
echo "--getStaticVariables--\n";
var_dump($func->getStaticVariables());
echo "--invoke--\n";
var_dump($func->invoke(array(1, 2, 3)));
echo "--invokeArgs--\n";
var_dump($func->invokeArgs(array(1, 2, 3)));
示例12: _getFunction
/**
* Get all info about function
* @param string|function $functionName Function or function name
* @return array|bool
*/
protected static function _getFunction($functionName)
{
if (is_string($functionName) && !function_exists($functionName)) {
return false;
} elseif (empty($functionName)) {
return false;
}
// create ReflectionFunction instance
$func = new ReflectionFunction($functionName);
// get basic function info
$result = array();
$result['name'] = $func->getName();
$result['type'] = $func->isInternal() ? 'internal' : 'user-defined';
if (method_exists($func, 'getNamespaceName') && ($namespace = $func->getNamespaceName())) {
$result['namespace'] = $namespace;
}
if ($func->isDeprecated()) {
$result['deprecated'] = true;
}
if ($static = $func->getStaticVariables()) {
$result['static'] = $static;
}
if ($reference = $func->returnsReference()) {
$result['reference'] = $reference;
}
if ($path = $func->getFileName()) {
$result['path'] = $path . ' ' . $func->getStartLine() . '/' . $func->getEndLine();
}
if ($parameters = $func->getParameters()) {
$result['parameters'] = self::_getParams($parameters, $func->isInternal());
}
// get function source
if (isset($result['path']) && $result['path']) {
$result['comment'] = $func->getDocComment();
$startLine = $func->getStartLine();
$endLine = $func->getEndLine();
$source = @file($func->getFileName());
if ($startLine && $source) {
$from = (int) ($startLine - 1);
$to = (int) ($endLine - $startLine + 1);
$slice = array_slice($source, $from, $to);
$result['source::source'] = implode('', $slice);
}
}
return $result;
}
示例13: wrap_php_function
//.........这里部分代码省略.........
$xmlrpcfuncname = $newfuncname;
}
while ($buildit && function_exists($xmlrpcfuncname)) {
$xmlrpcfuncname .= 'x';
}
// start to introspect PHP code
if (is_array($funcname)) {
$func = new ReflectionMethod($funcname[0], $funcname[1]);
if ($func->isPrivate()) {
error_log('XML-RPC: method to be wrapped is private: ' . $plainfuncname);
return false;
}
if ($func->isProtected()) {
error_log('XML-RPC: method to be wrapped is protected: ' . $plainfuncname);
return false;
}
if ($func->isConstructor()) {
error_log('XML-RPC: method to be wrapped is the constructor: ' . $plainfuncname);
return false;
}
// php 503 always says isdestructor = true...
if (version_compare(phpversion(), '5.0.3') != 0 && $func->isDestructor()) {
error_log('XML-RPC: method to be wrapped is the destructor: ' . $plainfuncname);
return false;
}
if ($func->isAbstract()) {
error_log('XML-RPC: method to be wrapped is abstract: ' . $plainfuncname);
return false;
}
/// @todo add more checks for static vs. nonstatic?
} else {
$func = new ReflectionFunction($funcname);
}
if ($func->isInternal()) {
// Note: from PHP 5.1.0 onward, we will possibly be able to use invokeargs
// instead of getparameters to fully reflect internal php functions ?
error_log('XML-RPC: function to be wrapped is internal: ' . $plainfuncname);
return false;
}
// retrieve parameter names, types and description from javadoc comments
// function description
$desc = '';
// type of return val: by default 'any'
$returns = $GLOBALS['xmlrpcValue'];
// desc of return val
$returnsDocs = '';
// type + name of function parameters
$paramDocs = array();
$docs = $func->getDocComment();
if ($docs != '') {
$docs = explode("\n", $docs);
$i = 0;
foreach ($docs as $doc) {
$doc = trim($doc, " \r\t/*");
if (strlen($doc) && strpos($doc, '@') !== 0 && !$i) {
if ($desc) {
$desc .= "\n";
}
$desc .= $doc;
} elseif (strpos($doc, '@param') === 0) {
// syntax: @param type [$name] desc
if (preg_match('/@param\\s+(\\S+)(\\s+\\$\\S+)?\\s+(.+)/', $doc, $matches)) {
if (strpos($matches[1], '|')) {
//$paramDocs[$i]['type'] = explode('|', $matches[1]);
$paramDocs[$i]['type'] = 'mixed';
} else {
示例14: _showTraceItem
/**
* Shows a backtrace item.
*
* @param int $n Count.
* @param array $trace Trace result.
*
* @return void
*/
protected function _showTraceItem($n, $trace)
{
echo '<tr><td align="right" valign="top" class="error-number">#', $n, '</td><td>';
if (isset($trace['class'])) {
if (preg_match('/^Phalcon/', $trace['class'])) {
echo '<span class="error-class"><a target="_new" href="http://docs.phalconphp.com/en/latest/api/', str_replace('\\', '_', $trace['class']), '.html">', $trace['class'], '</a></span>';
} else {
$classReflection = new \ReflectionClass($trace['class']);
if ($classReflection->isInternal()) {
echo '<span class="error-class"><a target="_new" href="http://php.net/manual/en/class.', str_replace('_', '-', strtolower($trace['class'])), '.php">', $trace['class'], '</a></span>';
} else {
echo '<span class="error-class">', $trace['class'], '</span>';
}
}
echo $trace['type'];
}
if (isset($trace['class'])) {
echo '<span class="error-function">', $trace['function'], '</span>';
} else {
if (function_exists($trace['function'])) {
$functionReflection = new \ReflectionFunction($trace['function']);
if ($functionReflection->isInternal()) {
echo '<span class="error-function"><a target="_new" href="http://php.net/manual/en/function.', str_replace('_', '-', $trace['function']), '.php">', $trace['function'], '</a></span>';
} else {
echo '<span class="error-function">', $trace['function'], '</span>';
}
} else {
echo '<span class="error-function">', $trace['function'], '</span>';
}
}
if (isset($trace['args'])) {
$this->_echoArgs($trace['args']);
}
if (isset($trace['file'])) {
echo '<br/><span class="error-file">', $trace['file'], ' (', $trace['line'], ')</span>';
}
echo '</td></tr>';
if ($this->_showFiles) {
if (isset($trace['file'])) {
$this->_echoFile($trace['file'], $trace['line']);
}
}
}
示例15: mapFunction
/**
* maps function and all parameters of function using reflection. returns object map
* as object throws error if mapping was not successful
*
* @error 14105
* @param string $function expects function name
* @return null|XO
* @throws Xapp_Rpc_Smd_Exception
*/
protected function mapFunction($function)
{
try {
$tmp = array();
$obj = new XO();
$function = new ReflectionFunction($function);
if ($function->isInternal()) {
throw new Xapp_Rpc_Smd_Exception(xapp_sprintf(_("function: %s can not be mapped since it is internal"), $function), 1410502);
}
$obj->transport = null;
$obj->target = null;
$method = $this->mapMethod($function);
if (xapp_get_option(self::SERVICE_DESCRIPTION, $this) && isset($method->description)) {
$obj->description = $method->description;
}
if (isset($method->returns)) {
$obj->returns = $method->returns;
}
$i = 0;
foreach ($function->getParameters() as $p) {
$params = $this->mapParameter($p);
if (isset($method->params) && isset($method->params['type'][$i])) {
$params->type = $method->params['type'][$i];
}
if (isset($method->params) && isset($method->params['description'][$i]) && xapp_get_option(self::SERVICE_DESCRIPTION, $this)) {
$params->description = $method->params['description'][$i];
}
$tmp[] = $params;
$i++;
}
$obj->parameters = $tmp;
return $obj;
} catch (ReflectionException $e) {
throw new Xapp_Rpc_Smd_Exception(xapp_sprintf(_("unable to map function: %s due to reflection error: %d, %s"), $function, $e->getCode(), $e->getMessage()), 1410501);
}
}