当前位置: 首页>>代码示例>>PHP>>正文


PHP ReflectionMethod::isPublic方法代码示例

本文整理汇总了PHP中ReflectionMethod::isPublic方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionMethod::isPublic方法的具体用法?PHP ReflectionMethod::isPublic怎么用?PHP ReflectionMethod::isPublic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ReflectionMethod的用法示例。


在下文中一共展示了ReflectionMethod::isPublic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCallback

 public static function getCallback($callback, $file = null)
 {
     try {
         if ($file) {
             self::loadFile($file);
         }
         if (is_array($callback)) {
             $method = new \ReflectionMethod(array_shift($callback), array_shift($callback));
             if ($method->isPublic()) {
                 if ($method->isStatic()) {
                     $callback = array($method->class, $method->name);
                 } else {
                     $callback = array(new $method->class(), $method->name);
                 }
             }
         } else {
             if (is_string($callback)) {
                 $callback = $callback;
             }
         }
         if (is_callable($callback)) {
             return $callback;
         }
         throw new InvalidCallbackException("Invalid callback");
     } catch (\Exception $ex) {
         throw $ex;
     }
 }
开发者ID:randallsquared,项目名称:zaphpa,代码行数:28,代码来源:Router.php

示例2: run

 public function run($coreClass, $command, $parameters)
 {
     $messenger = new Service_Messenger();
     try {
         $reflection = new ReflectionClass($coreClass);
         $interface = 'Service_Interface';
         if (!$reflection->implementsInterface($interface)) {
             if ($reflection->hasMethod($command)) {
                 $method = new ReflectionMethod($coreClass, $command);
                 if ($method->isPublic() && $command != '__construct') {
                     $core = new $coreClass($messenger);
                     $result = $core->{$command}($parameters);
                     return $this->_output($result, $messenger);
                 }
             }
             $messenger->addMessage('Invalid command');
             return $this->_output(false, $messenger);
         } else {
             throw new Service_Exception('Core Class does not implement ' . $interface);
         }
     } catch (Exception $e) {
         $messenger->addMessage('EXCEPTION' . "\n\n" . 'Exception Type: ' . get_class($e) . "\n" . 'File: ' . $e->getFile() . "\n" . 'Line: ' . $e->getLine() . "\n" . 'Message: ' . $e->getMessage() . "\n" . 'Stack Trace' . "\n" . $e->getTraceAsString());
         return $this->_output(false, $messenger);
     }
 }
开发者ID:Nasty,项目名称:jsMyAdmin,代码行数:25,代码来源:Service.php

示例3: execute

 public function execute($argv)
 {
     if (!is_array($argv)) {
         $argv = array($argv);
     }
     $argc = count($argv);
     if (empty($this->action)) {
         throw new \Jolt\Exception('controller_action_not_set');
     }
     try {
         $action = new \ReflectionMethod($this, $this->action);
     } catch (\ReflectionException $e) {
         throw new \Jolt\Exception('controller_action_not_part_of_class');
     }
     $paramCount = $action->getNumberOfRequiredParameters();
     if ($paramCount != $argc && $paramCount > $argc) {
         $argv = array_pad($argv, $paramCount, NULL);
     }
     ob_start();
     if ($action->isPublic()) {
         if ($action->isStatic()) {
             $action->invokeArgs(NULL, $argv);
         } else {
             $action->invokeArgs($this, $argv);
         }
     }
     $renderedController = ob_get_clean();
     if (!empty($renderedController)) {
         $this->renderedController = $renderedController;
     } else {
         $this->renderedController = $this->renderedView;
     }
     return $this->renderedController;
 }
开发者ID:kennyma,项目名称:Jolt,代码行数:34,代码来源:Controller.php

示例4: _isPrivateAction

 protected function _isPrivateAction(\ReflectionMethod $method)
 {
     if ($method->name[0] === '_' || !$method->isPublic()) {
         return true;
     }
     return false;
 }
开发者ID:exonintrendo,项目名称:Primer,代码行数:7,代码来源:Controller.php

示例5: runActionWithParams

 /**
  * 执行当前控制器方法
  *
  * @param string $actionName 方法名
  * @param array $params 参数列表
  * @return Response|mixed
  * @throws AppException
  */
 public function runActionWithParams($actionName, $params = array())
 {
     if (empty($actionName)) {
         $actionName = $this->defaultAction;
     }
     if (!method_exists($this, $actionName)) {
         throw new \BadMethodCallException("方法不存在: {$actionName}");
     }
     $method = new \ReflectionMethod($this, $actionName);
     if (!$method->isPublic()) {
         throw new \BadMethodCallException("调用非公有方法: {$actionName}");
     }
     $args = array();
     $methodParams = $method->getParameters();
     if (!empty($methodParams)) {
         foreach ($methodParams as $key => $p) {
             $default = $p->isOptional() ? $p->getDefaultValue() : null;
             $value = isset($params[$key]) ? $params[$key] : $default;
             if (null === $value && !$p->isOptional()) {
                 throw new AppException(get_class($this) . "::{$actionName}() 缺少参数: " . $p->getName());
             }
             $args[] = $value;
         }
     }
     $result = $method->invokeArgs($this, $args);
     if ($result instanceof Response) {
         return $result;
     } elseif (null !== $result) {
         $this->response->setContent(strval($result));
     }
     return $this->response;
 }
开发者ID:saoyor,项目名称:php-framework,代码行数:40,代码来源:CliController.php

示例6: start

 private static function start()
 {
     $control = control(CONTROL);
     if (!$control) {
         if (IS_GROUP and !is_dir(GROUP_PATH . GROUP_NAME)) {
             _404('应用组' . GROUP_PATH . GROUP_NAME . '不存在');
         }
         if (!is_dir(APP_PATH)) {
             _404('应用' . APP . '不存在');
         }
         $control = Control("Empty");
         if (!$control) {
             _404('模块' . CONTROL . C("CONTROL_FIX") . '不存在');
         }
     }
     try {
         $method = new ReflectionMethod($control, METHOD);
         if ($method->isPublic()) {
             $method->invoke($control);
         } else {
             throw new ReflectionException();
         }
     } catch (ReflectionException $e) {
         $method = new ReflectionMethod($control, '__call');
         $method->invokeArgs($control, array(METHOD, ''));
     }
 }
开发者ID:jyht,项目名称:v5,代码行数:27,代码来源:~boot.php

示例7: Invoke

 /**
  * Вызывает действие, контролируя его наличие и публичный доступ к нему.
  * Действие запускается через ReflectionMethod->invokeArgs() что позволяет самому действию
  * контролировать принимаемые на вход параметры. Все прочие параметры отсеиваются.
  *
  * @param string $action действие - название публичного метода в классе контроллера
  * @param array $request данные запроса - ассоциативный массив данных пришедших по любому каналу
  * @return array результат выполнения действия (зачастую действие самостоятельно редиректит дальше)
  * @throws Exception
  */
 private function Invoke($action, $request)
 {
     if (!method_exists($this, $action)) {
         throw new Exception("Неизвестное действие - '{$action}'");
     }
     //$this->Debug($action, 'Invoke $action');
     //$this->Debug($request, 'Invoke $request');
     $reflection = new \ReflectionMethod($this, $action);
     if (!$reflection->isPublic()) {
         throw new Exception("Действие '{$action}' запрещено вызывать из контроллера публичной части");
     }
     $request = array_change_key_case($request);
     $parameters = $reflection->getParameters();
     //$this->Debug($parameters, 'Invoke $parameters');
     $arguments = array();
     foreach ($parameters as $parameter) {
         $code = strtolower($parameter->name);
         if (isset($request[$code])) {
             $arguments[$code] = $request[$code];
         } else {
             try {
                 $arguments[$code] = $parameter->getDefaultValue();
             } catch (Exception $error) {
                 $arguments[$code] = null;
             }
         }
     }
     //$this->Debug($arguments, 'Invoke $arguments');
     return $reflection->invokeArgs($this, $arguments);
 }
开发者ID:Reuniko,项目名称:SiteCore,代码行数:40,代码来源:component.php

示例8: __get

 /**
  * Magic function to read a data value
  *
  * @param $name string Name of the property to be returned
  * @throws Exception
  * @return mixed
  */
 public function __get($name)
 {
     if (isset($this->_valueMap[$name])) {
         $key = $this->_valueMap[$name];
     } else {
         $key = $name;
     }
     if (!is_array($this->_primaryKey) && $key == $this->_primaryKey) {
         return $this->getId();
     }
     if (!array_key_exists($key, $this->_data)) {
         // Is there a public getter function for this value?
         $functionName = $this->composeGetterName($key);
         if (method_exists($this, $functionName)) {
             $reflection = new \ReflectionMethod($this, $functionName);
             if ($reflection->isPublic()) {
                 return $this->{$functionName}();
             }
         }
         throw new Exception('Column not found in data: ' . $name);
     }
     $result = $this->_data[$key];
     if (isset($this->_formatMap[$key])) {
         $result = Format::fromSql($this->_formatMap[$key], $result);
     }
     return $result;
 }
开发者ID:lastzero,项目名称:sympathy,代码行数:34,代码来源:Entity.php

示例9: setMethod

 /**
  * @param mixed $method
  * @return mixed|void
  */
 public function setMethod(\ReflectionMethod $method)
 {
     if (!$method->isPublic()) {
         throw new Exception("You can not use the Register or Subscribe annotation on a non-public method");
     }
     $this->method = $method;
 }
开发者ID:trajedy,项目名称:ThruwayBundle,代码行数:11,代码来源:URIClassMapping.php

示例10: __construct

 public function __construct($callable, array $annotations = array())
 {
     if (is_array($callable)) {
         list($this->class, $method) = $callable;
         $reflMethod = new \ReflectionMethod($this->class, $method);
         if (!$reflMethod->isPublic()) {
             throw new \InvalidArgumentException('Class method must be public');
         } elseif ($reflMethod->isStatic()) {
             $this->staticMethod = $method;
         } else {
             $this->method = $method;
             $class = $this->class;
             $this->instance = new $class();
         }
     } elseif ($callable instanceof \Closure) {
         $this->closure = $callable;
     } elseif (is_string($callable)) {
         if (!function_exists($callable)) {
             throw new \InvalidArgumentException('Function does not exist');
         }
         $this->function = $callable;
     } else {
         throw new \InvalidArgumentException('Invalid callable type');
     }
     $this->annotations = $annotations;
 }
开发者ID:anlutro,项目名称:phpbench,代码行数:26,代码来源:Callback.php

示例11: moduleHasMethod

 /**
  * Check to see if said module has method and is publically callable
  * @param {string} $module The raw module name
  * @param {string} $method The method name
  */
 public function moduleHasMethod($module, $method)
 {
     $this->getActiveModules();
     $module = ucfirst(strtolower($module));
     if (!empty($this->moduleMethods[$module]) && in_array($method, $this->moduleMethods[$module])) {
         return true;
     }
     $amods = array();
     foreach (array_keys($this->active_modules) as $mod) {
         $amods[] = $this->cleanModuleName($mod);
     }
     if (in_array($module, $amods)) {
         try {
             $rc = new \ReflectionClass($this->FreePBX->{$module});
             if ($rc->hasMethod($method)) {
                 $reflection = new \ReflectionMethod($this->FreePBX->{$module}, $method);
                 if ($reflection->isPublic()) {
                     $this->moduleMethods[$module][] = $method;
                     return true;
                 }
             }
         } catch (\Exception $e) {
         }
     }
     return false;
 }
开发者ID:umjinsun12,项目名称:dngshin,代码行数:31,代码来源:Modules.class.php

示例12: __construct

 public function __construct($argv)
 {
     $this->verbose = $this->verbose == true ? true : false;
     $argv[] = '-clean';
     $argv[] = '';
     $this->args = $argv;
     // get the systems username and set the home dir.
     $this->user = get_current_user();
     $this->home = '/home/' . $this->user . '/';
     foreach ($this->args as $location => $args) {
         $chars = str_split($args);
         if ($chars[0] === '-') {
             $tmp = explode('-', $args);
             $function = end($tmp);
             unset($tmp);
             // this does a check to make sure we can only
             // run public functions via this constructor.
             $check = new ReflectionMethod($this, $function);
             if (!$check->isPublic()) {
                 continue;
             }
             $this->{$function}($argv[++$location]);
         }
     }
 }
开发者ID:ErdMutter92,项目名称:linux-file-sweaper,代码行数:25,代码来源:main.php

示例13: setRoute

 /**
  *
  */
 public function setRoute()
 {
     $segments = $this->getSegments();
     $this->moduleName = isset($segments[0]) ? $segments[0] : self::DEFAULT_MODULE;
     $this->controllerName = isset($segments[1]) ? $segments[1] : self::DEFAULT_CONTROLLER;
     $this->methodName = isset($segments[2]) ? $segments[2] : self::DEFAULT_METHOD;
     $className = sprintf('%s\\Controller\\%s\\%s\\%s', $GLOBALS['appNameSpace'], ucwords($this->moduleName), ucwords($this->controllerName), ucwords($this->methodName));
     if (class_exists($className)) {
         if (method_exists($className, self::FUNCTIONNAME)) {
             $method = new \ReflectionMethod($className, self::FUNCTIONNAME);
             if ($method->isPublic() && $method->getName() === self::FUNCTIONNAME) {
                 $this->controller = new $className();
                 return true;
             }
         }
     }
     //退到/module/index.php
     $this->methodName = self::DEFAULT_METHOD;
     $this->controllerName = self::DEFAULT_CONTROLLER;
     $className = sprintf('%s\\Controller\\%s\\%s', $GLOBALS['appNameSpace'], ucwords($this->moduleName), ucwords($this->controllerName));
     if (class_exists($className) && method_exists($className, self::FUNCTIONNAME)) {
         $this->controller = new $className();
         return true;
     }
     $this->moduleName = self::DEFAULT_MODULE;
     $className = sprintf('%s\\Controller\\%s', $GLOBALS['appNameSpace'], ucwords($this->moduleName));
     if (class_exists($className) && method_exists($className, self::FUNCTIONNAME)) {
         $this->controller = new $className();
         return true;
     }
     if (is_null($this->controller)) {
         throw new \BadMethodCallException('wrong route path', -1);
     }
 }
开发者ID:Whispersong,项目名称:phputils,代码行数:37,代码来源:router.php

示例14: __try

 public function __try($method)
 {
     if (!$this->app->is_admin() && $method !== 'auth') {
         throw new \exception('denied');
     }
     try {
         if (!method_exists($this, $method)) {
             throw new \exception('method not found');
         } else {
             $reflection = new \ReflectionMethod($this, $method);
             if (!$reflection->isPublic()) {
                 throw new \exception('method not found');
             }
         }
         $msg = call_user_func([$this, $method]);
     } catch (\exception $e) {
         if ($this->app->debug === true) {
             $err = $e->getMessage() . '<br/><hr>' . $e->getFile() . ' @ Line ' . $e->getLine() . '<br/><hr>STACK TRACE:<br/>' . $e->getTraceAsString();
         } else {
             $err = $e->getMessage();
         }
         $msg = ['error' => 1, 'message' => $err];
     }
     echo json_encode($msg, JSON_HEX_QUOT | JSON_HEX_TAG);
 }
开发者ID:StudsPro,项目名称:island-peeps-2.0,代码行数:25,代码来源:AdminAPI.php

示例15: run

 /**
  * @param App\Request $request
  * @return App\IResponse
  */
 public function run(App\Request $request)
 {
     $this->request = $request;
     $this->startup();
     if (!$this->startupCheck) {
         $class = (new \ReflectionClass($this))->getMethod('startup')->getDeclaringClass()->getName();
         throw new Nette\InvalidStateException("'{$class}::startup()' or its descendant does not call parent method");
     }
     try {
         $rm = new \ReflectionMethod($this, $this->getAction());
     } catch (\ReflectionException $e) {
     }
     if (isset($e) || $rm->isAbstract() || $rm->isStatic() || !$rm->isPublic()) {
         throw new App\BadRequestException("Method '{$request->getMethod()}' not allowed", 405);
     }
     $params = $this->getParameters();
     $args = App\UI\PresenterComponentReflection::combineArgs($rm, $params);
     $response = $rm->invokeArgs($this, $args);
     if ($response === null) {
         $response = new Responses\NullResponse();
     } elseif (!$response instanceof App\IResponse) {
         throw new Nette\InvalidStateException("Action '{$this->getAction(true)}' does not return instance of Nette\\Application\\IResponse");
     }
     return $response;
 }
开发者ID:dzibma,项目名称:rest-api,代码行数:29,代码来源:Presenter.php


注:本文中的ReflectionMethod::isPublic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。