本文整理汇总了PHP中ReflectionClass::GetMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionClass::GetMethod方法的具体用法?PHP ReflectionClass::GetMethod怎么用?PHP ReflectionClass::GetMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionClass
的用法示例。
在下文中一共展示了ReflectionClass::GetMethod方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetTaskData
public function GetTaskData(Task $task)
{
$data = new \phalanx\base\Dictionary();
$output_list = $task::OutputList();
$output_list[] = 'input';
foreach ($output_list as $key) {
$class = new \ReflectionClass(get_class($task));
if ($class->HasProperty($key) && $class->GetProperty($key)->IsPublic()) {
$data->Set($key, $task->{$key});
} else {
if ($class->HasMethod($key) && $class->GetMethod($key)->IsPublic()) {
$data->Set($key, $task->{$key}());
}
}
}
return $data;
}
示例2: GetDetailsOfModuleMethods
/**
* Get info and details about the methods of a module.
*
* @param $module string with the module name.
* @returns array with information on the methods.
*/
private function GetDetailsOfModuleMethods($module)
{
$methods = array();
if (class_exists($module)) {
$rc = new ReflectionClass($module);
$classMethods = $rc->getMethods();
foreach ($classMethods as $val) {
$methodName = $val->name;
$rm = $rc->GetMethod($methodName);
$methods[$methodName]['name'] = $rm->getName();
$methods[$methodName]['doccomment'] = $rm->getDocComment();
$methods[$methodName]['startline'] = $rm->getStartLine();
$methods[$methodName]['endline'] = $rm->getEndLine();
$methods[$methodName]['isPublic'] = $rm->isPublic();
$methods[$methodName]['isProtected'] = $rm->isProtected();
$methods[$methodName]['isPrivate'] = $rm->isPrivate();
$methods[$methodName]['isStatic'] = $rm->isStatic();
}
}
ksort($methods, SORT_LOCALE_STRING);
return $methods;
}
示例3: load
//.........这里部分代码省略.........
$controller_type = Controller::TYPE_REPORT;
break;
} else {
if ($redirected === true && file_exists(SOFTWARE_HOME . "{$redirect_path}/{$controller_path}/{$p}/{$baseClassName}Controller.php")) {
$controller_class_name = $baseClassName . "Controller";
$controller_name = $p;
$controller_path .= "/{$p}";
$controller_type = Controller::TYPE_MODULE;
$package_main .= $p;
add_include_path("{$redirect_path}/{$controller_path}/");
break;
} else {
$controller_path .= "/{$p}";
if ($redirected) {
$package_main .= "{$p}.";
}
}
}
}
}
}
}
}
}
}
// Check the type of controller and load it.
switch ($controller_type) {
case Controller::TYPE_MODULE:
// Load a module controller which would be a subclass of this
// class
if ($controller_class_name == "") {
require_once SOFTWARE_HOME . "app/modules{$controller_path}/{$controller_name}.php";
$controller = new $controller_name();
} else {
$controller_name = $controller_class_name;
$controller = new $controller_class_name();
$controller->redirected = $redirected;
$controller->redirectPath = $redirect_path;
$controller->redirectedPackage = $package_path;
$controller->mainRedirectedPackage = $package_main;
$controller->redirectedPackageName = $package_name;
}
break;
case Controller::TYPE_MODEL:
// Load the ModelController wrapper around an existing model class.
$model = substr(str_replace("/", ".", $controller_path), 1);
$controller_name = "ModelController";
$controller = new ModelController($model, $package_path);
break;
case Controller::TYPE_REPORT:
$controller = new XmlDefinedReportController($redirect_path . $controller_path . "/report.xml", $redirected);
$controller_name = "XmlDefinedReportController";
break;
default:
// Load a package controller for this folder
if (is_dir("app/modules{$controller_path}")) {
$controller = new PackageController($path);
$controller_name = "PackageController";
$get_contents = true;
$force_output = true;
} else {
if ($redirected === true && is_dir(SOFTWARE_HOME . "{$redirect_path}/{$controller_path}")) {
$controller = new PackageController($path);
$controller_name = "PackageController";
$get_contents = true;
$force_output = true;
} else {
$controller = new ErrorController();
$controller_name = "ErrorController";
}
}
}
// If the get contents flag has been set return all the contents of this
// controller.
$controller->path = $previousControllerPath . $controller_path;
if ($get_contents) {
if ($i == count($path) - 1 || $force_output) {
$ret = $controller->getContents();
} else {
if (method_exists($controller, $path[$i + 1])) {
$controller_class = new ReflectionClass($controller_name);
$method = $controller_class->GetMethod($path[$i + 1]);
$ret = $method->invoke($controller, array_slice($path, $i + 2));
} else {
$ret = "<h2>Error</h2> Method does not exist. [" . $path[$i + 1] . "]";
}
}
if (is_array($ret)) {
$t = new TemplateEngine();
$t->assign('controller_path', $controller_path);
$t->assign($ret["data"]);
$controller->content = $t->fetch(isset($ret["template"]) ? $ret["template"] : $path[$i + 1] . ".tpl");
} else {
if (is_string($ret)) {
$controller->content = $ret;
}
}
}
return $controller;
}
示例4: WillFire
public function WillFire()
{
// Make sure the client is only performing an allowed action.
$actions = array(self::ACTION_FETCH, self::ACTION_DELETE, self::ACTION_VALIDATE, self::ACTION_INSERT, self::ACTION_UPDATE);
if (!in_array($this->input->action, $actions)) {
$this->_Error(-1, 'Action not supported');
return;
}
// Make sure the Model exists and can be validated.
$classes = get_declared_classes();
foreach ($classes as $class) {
$mirror = new \ReflectionClass($class);
if ($mirror->ImplementsInterface('\\phalanx\\data\\ValidatingModel')) {
$validator_name = $mirror->GetMethod('ValidatorName')->Invoke(NULL);
if ($validator_name == $this->input->model) {
if (is_array($this->input->data)) {
$this->model = $mirror->NewInstance(NULL);
$this->model->SetFrom($this->input->data);
} else {
$this->model = $mirror->NewInstance($this->input->data);
}
break;
}
}
}
if (!$this->model) {
$this->_Error(-2, 'The model could not be created');
return;
}
// Make sure the validator exists.
$this->validator = $this->model->GetValidator();
if (!$this->validator || !$this->validator instanceof ModelValidator) {
$this->_Error(-3, 'The validator could not be created');
return;
}
}