本文整理汇总了PHP中ReflectionMethod::isInternal方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionMethod::isInternal方法的具体用法?PHP ReflectionMethod::isInternal怎么用?PHP ReflectionMethod::isInternal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionMethod
的用法示例。
在下文中一共展示了ReflectionMethod::isInternal方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isInternal
/**
* Returns whether this is an internal method
*
* @return boolean True if this is an internal method
*/
public function isInternal()
{
if ($this->reflectionSource instanceof ReflectionMethod) {
return $this->reflectionSource->isInternal();
} else {
return parent::isInternal();
}
}
示例2: generateMethodArguments
/**
* @param ReflectionMethod $method
* @return string
*/
function generateMethodArguments(ReflectionMethod $method)
{
if ($method->isInternal()) {
// This code can`t handle constants, it replaces its with value
return implode(', ', array_map(array($this, 'generateMethodArgument'), $method->getParameters()));
} else {
$lines = $this->getFileLines($method->getFileName());
$start_line = $method->getStartLine() - 1;
$function_lines = array_slice($lines, $start_line, $method->getEndLine() - $start_line);
// todo: use code beautifier?
return $this->parseFunctionArgs(implode(PHP_EOL, $function_lines));
}
}
示例3: reflectMethod
function reflectMethod($class, $method)
{
$methodInfo = new ReflectionMethod($class, $method);
echo "**********************************\n";
echo "Reflecting on method {$class}::{$method}()\n\n";
echo "\ngetName():\n";
var_dump($methodInfo->getName());
echo "\nisInternal():\n";
var_dump($methodInfo->isInternal());
echo "\nisUserDefined():\n";
var_dump($methodInfo->isUserDefined());
echo "\n**********************************\n";
}
示例4: handle
/**
* Handles request
*
* @return void
*/
public function handle()
{
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
die('JSON-RPC Server');
}
try {
$request = json_decode(file_get_contents('php://input'));
$reflection = new ReflectionMethod($this->_object, $request->method);
if ($reflection->getNumberOfRequiredParameters() > count($request->params)) {
throw new Exception("Params count doesn't match method signature.");
}
if (!$reflection->isPublic() || $reflection->isInternal()) {
throw new Exception("Method is not callable");
}
$result = call_user_func_array(array($this->_object, $request->method), $request->params);
$response = array('id' => $request->id, 'result' => $result, 'error' => null);
} catch (Exception $e) {
$response = array('id' => $request->id, 'result' => null, 'error' => $e->getMessage());
}
header('content-type: text/javascript');
echo json_encode($response);
}
示例5: methodData
function methodData(ReflectionMethod $method)
{
$details = "";
$name = $method->getName();
if ($method->isUserDefined()) {
$details .= "{$name} is user defined\n";
}
if ($method->isInternal()) {
$details .= "{$name} is built-in\n";
}
if ($method->isAbstract()) {
$details .= "{$name} is abstract\n";
}
if ($method->isPublic()) {
$details .= "{$name} is public\n";
}
if ($method->isProtected()) {
$details .= "{$name} is protected\n";
}
if ($method->isPrivate()) {
$details .= "{$name} is private\n";
}
if ($method->isStatic()) {
$details .= "{$name} is static\n";
}
if ($method->isFinal()) {
$details .= "{$name} is final\n";
}
if ($method->isConstructor()) {
$details .= "{$name} is the constructor\n";
}
if ($method->returnsReference()) {
$details .= "{$name} returns a reference (as opposed to a value)\n";
}
return $details;
}
示例6: increment
<pre>
<?php
class Counter
{
private static $c = 0;
public static final function increment()
{
return ++self::$c;
}
}
// Создание экземпляра класса ReflectionMethod
$method = new ReflectionMethod('Counter', 'increment');
// exit;
// Вывод основной информации
printf("===> %s%s%s%s%s%s%s метод '%s' (который является %s)\n" . " объявлен в %s\n" . " строки с %d по %d\n" . " имеет модификаторы %d[%s]\n", $method->isInternal() ? 'Встроенный' : 'Пользовательский', $method->isAbstract() ? ' абстрактный' : '', $method->isFinal() ? ' финальный' : '', $method->isPublic() ? ' public' : '', $method->isPrivate() ? ' private' : '', $method->isProtected() ? ' protected' : '', $method->isStatic() ? ' статический' : '', $method->getName(), $method->isConstructor() ? 'конструктором' : 'обычным методом', $method->getFileName(), $method->getStartLine(), $method->getEndline(), $method->getModifiers(), implode(' ', Reflection::getModifierNames($method->getModifiers())));
// Вывод статических переменных, если они есть
if ($statics = $method->getStaticVariables()) {
printf("---> Статическая переменная: %s\n", var_export($statics, 1));
}
// Вызов метода
printf("---> Результат вызова: ");
$result = $method->invoke(3);
echo $result;
?>
</pre>
示例7: increment
class Counter
{
private static $c = 0;
/**
* Increment counter
*
* @final
* @static
* @access public
* @return int
*/
public static final function increment()
{
return ++self::$c;
}
}
// Create an instance of the ReflectionMethod class
$method = new ReflectionMethod('Counter', 'increment');
// Print out basic information
printf("===> The %s%s%s%s%s%s%s method '%s' (which is %s)\n" . " declared in %s\n" . " lines %d to %d\n" . " having the modifiers %d[%s]\n", $method->isInternal() ? 'internal' : 'user-defined', $method->isAbstract() ? ' abstract' : '', $method->isFinal() ? ' final' : '', $method->isPublic() ? ' public' : '', $method->isPrivate() ? ' private' : '', $method->isProtected() ? ' protected' : '', $method->isStatic() ? ' static' : '', $method->getName(), $method->isConstructor() ? 'the constructor' : 'a regular method', $method->getFileName(), $method->getStartLine(), $method->getEndline(), $method->getModifiers(), implode(' ', Reflection::getModifierNames($method->getModifiers())));
echo "\n";
// Print documentation comment
printf("---> Documentation:\n %s\n", var_export($method->getDocComment(), 1));
// Print static variables if existant
if ($statics = $method->getStaticVariables()) {
printf("---> Static variables: %s\n", var_export($statics, 1));
}
echo "\n";
// Invoke the method
printf("---> Invocation results in: ");
var_dump($method->invoke(NULL));
示例8: f
} catch (TypeError $re) {
echo "Ok - " . $re->getMessage() . PHP_EOL;
}
try {
new ReflectionMethod('a', 'b', 'c');
} catch (TypeError $re) {
echo "Ok - " . $re->getMessage() . PHP_EOL;
}
class C
{
public function f()
{
}
}
$rm = new ReflectionMethod('C', 'f');
var_dump($rm->isFinal(1));
var_dump($rm->isAbstract(1));
var_dump($rm->isPrivate(1));
var_dump($rm->isProtected(1));
var_dump($rm->isPublic(1));
var_dump($rm->isStatic(1));
var_dump($rm->isConstructor(1));
var_dump($rm->isDestructor(1));
var_dump($rm->getModifiers(1));
var_dump($rm->isInternal(1));
var_dump($rm->isUserDefined(1));
var_dump($rm->getFileName(1));
var_dump($rm->getStartLine(1));
var_dump($rm->getEndLine(1));
var_dump($rm->getStaticVariables(1));
var_dump($rm->getName(1));
示例9: transformMethod
function transformMethod(ReflectionMethod $method)
{
$is_internal = $method->isInternal() ? 'internal' : 'user-defined';
$is_abstract = $method->isAbstract() ? ' abstract' : '';
$is_final = $method->isFinal() ? ' final' : '';
$is_public = $method->isPublic() ? ' public' : '';
$is_private = $method->isPrivate() ? ' private' : '';
$is_protected = $method->isProtected() ? ' protected' : '';
$is_static = $method->isStatic() ? ' static' : '';
$name = $method->getName();
$class = $method->getDeclaringClass()->name;
$is_constructor = $method->isConstructor() ? 'the constructor' : 'a regular method';
$modifiers = Reflection::getModifierNames($method->getModifiers());
extract($this->transformDocBlock($method->getDocComment()));
$parameters = array();
$parameters_concat = "";
$_optional_count = 0;
foreach ($method->getParameters() as $_param) {
$parameters[$_param->getName()] = $this->transformParameter($_param, @$param[$_param->getName()]);
if ($_param->isOptional()) {
$parameters_concat .= " [ ";
$_optional_count++;
}
if ($parameters_concat != "" && $parameters_concat != " [ ") {
$parameters_concat .= ", ";
}
$parameters_concat .= $parameters[$_param->getName()];
}
$parameters_concat .= str_repeat(" ] ", $_optional_count);
ob_start();
include "templates/" . $this->template . "/method.tmpl.php";
return ob_get_clean();
}