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


PHP Inspector::invokeMethod方法代码示例

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


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

示例1: _methods

 /**
  * Get the methods for the class
  *
  * @param string $class
  * @param array $options
  * @return array
  */
 protected function _methods($class, $options = array())
 {
     $defaults = array('name' => null);
     $options += $defaults;
     $methods = Inspector::methods($class)->map(function ($item) {
         if ($item->name[0] === '_') {
             return;
         }
         $modifiers = array_values(Inspector::invokeMethod('_modifiers', array($item)));
         $setAccess = array_intersect($modifiers, array('private', 'protected')) != array();
         if ($setAccess) {
             $item->setAccessible(true);
         }
         $result = compact('modifiers') + array('docComment' => $item->getDocComment(), 'name' => $item->getName());
         if ($setAccess) {
             $item->setAccessible(false);
         }
         return $result;
     }, array('collect' => false));
     $results = array();
     foreach ($methods as $method) {
         $comment = Docblock::comment($method['docComment']);
         $name = $method['name'];
         $description = $comment['description'];
         $args = !isset($comment['tags']['params']) ? null : $comment['tags']['params'];
         $return = !isset($comment['tags']['return']) ? null : trim(strtok($comment['tags']['return'], ' '));
         $command = $name === 'run' ? null : $name;
         $command = !$command && !empty($args) ? '[ARGS]' : $command;
         $usage = "{$command} ";
         $usage .= empty($args) ? null : join(' ', array_map(function ($a) {
             return '[' . str_replace('$', '', trim($a)) . ']';
         }, array_keys($args)));
         $results[$name] = compact('name', 'description', 'return', 'args', 'usage');
         if ($name && $name == $options['name']) {
             return array($name => $results[$name]);
         }
     }
     return $results;
 }
开发者ID:EHER,项目名称:chegamos,代码行数:46,代码来源:Help.php

示例2: _methods

 /**
  * Get the methods for the class.
  *
  * @param string $class
  * @param array $options
  * @return array
  */
 protected function _methods($class, $options = array())
 {
     $defaults = array('name' => null);
     $options += $defaults;
     $map = function ($item) {
         if ($item->name[0] === '_') {
             return;
         }
         $modifiers = array_values(Inspector::invokeMethod('_modifiers', array($item)));
         $setAccess = array_intersect($modifiers, array('private', 'protected')) != array();
         if ($setAccess) {
             $item->setAccessible(true);
         }
         $args = array();
         foreach ($item->getParameters() as $arg) {
             $args[] = array('name' => $arg->getName(), 'optional' => $arg->isOptional(), 'description' => null);
         }
         $result = compact('modifiers', 'args') + array('docComment' => $item->getDocComment(), 'name' => $item->getName());
         if ($setAccess) {
             $item->setAccessible(false);
         }
         return $result;
     };
     $methods = Inspector::methods($class)->map($map, array('collect' => false));
     $results = array();
     foreach (array_filter($methods) as $method) {
         $comment = Docblock::comment($method['docComment']);
         $name = $method['name'];
         $description = trim($comment['description'] . PHP_EOL . $comment['text']);
         $args = $method['args'];
         $return = null;
         foreach ($args as &$arg) {
             if (isset($comment['tags']['params']['$' . $arg['name']])) {
                 $arg['description'] = $comment['tags']['params']['$' . $arg['name']]['text'];
             }
             $arg['usage'] = $arg['optional'] ? "[<{$arg['name']}>]" : "<{$arg['name']}>";
         }
         if (isset($comment['tags']['return'])) {
             $return = trim(strtok($comment['tags']['return'], ' '));
         }
         $results[$name] = compact('name', 'description', 'return', 'args');
         if ($name && $name == $options['name']) {
             return array($name => $results[$name]);
         }
     }
     return $results;
 }
开发者ID:fedeisas,项目名称:lithium,代码行数:54,代码来源:Help.php


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