本文整理匯總了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);
}
}