當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。