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


PHP ReflectionFunctionAbstract::getDocComment方法代码示例

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


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

示例1: __construct

 public function __construct(ReflectionFunctionAbstract $method)
 {
     $this->name = $method->getShortName();
     $this->filename = $method->getFilename();
     $this->startline = $method->getStartLine();
     $this->endline = $method->getEndLine();
     $this->docstring = $method->getDocComment();
     $this->operator = $this->static ? Kint_Object::OPERATOR_STATIC : Kint_Object::OPERATOR_OBJECT;
     $this->access = Kint_Object::ACCESS_PUBLIC;
     if ($method instanceof ReflectionMethod) {
         $this->static = $method->isStatic();
         $this->abstract = $method->isAbstract();
         $this->final = $method->isFinal();
         $this->owner_class = $method->getDeclaringClass()->name;
         if ($method->isProtected()) {
             $this->access = Kint_Object::ACCESS_PROTECTED;
         } elseif ($method->isPrivate()) {
             $this->access = Kint_Object::ACCESS_PRIVATE;
         }
     }
     foreach ($method->getParameters() as $param) {
         $this->parameters[] = new Kint_Object_Parameter($param);
     }
     if ($this->docstring) {
         if (preg_match('/@return\\s+(.*)\\r?\\n/m', $this->docstring, $matches)) {
             if (!empty($matches[1])) {
                 $this->returntype = $matches[1];
             }
         }
     }
     $docstring = new Kint_Object_Representation_Docstring($this->docstring, $this->filename, $this->startline);
     $docstring->implicit_label = true;
     $this->addRepresentation($docstring);
 }
开发者ID:jnvsor,项目名称:kint,代码行数:34,代码来源:Method.php

示例2: generateCollaborators

 /**
  * @param CollaboratorManager $collaborators
  * @param \ReflectionFunctionAbstract $function
  */
 private function generateCollaborators(CollaboratorManager $collaborators, \ReflectionFunctionAbstract $function)
 {
     if ($comment = $function->getDocComment()) {
         $comment = str_replace("\r\n", "\n", $comment);
         foreach (explode("\n", trim($comment)) as $line) {
             if (preg_match(self::$docex, $line, $match)) {
                 $collaborator = $this->getOrCreateCollaborator($collaborators, $match[2]);
                 $collaborator->beADoubleOf($match[1]);
             }
         }
     }
     foreach ($function->getParameters() as $parameter) {
         $collaborator = $this->getOrCreateCollaborator($collaborators, $parameter->getName());
         try {
             if (null !== ($class = $parameter->getClass())) {
                 $collaborator->beADoubleOf($class->getName());
             }
         } catch (ReflectionException $e) {
             throw new CollaboratorNotFoundException(sprintf('Collaborator does not exist '), 0, $e, $parameter);
         }
     }
 }
开发者ID:edwardricardo,项目名称:zenska,代码行数:26,代码来源:CollaboratorsMaintainer.php

示例3: parseDocComment

 /**
  * @param \ReflectionFunctionAbstract $function
  *
  * @return ReturnComment|false
  */
 public function parseDocComment(\ReflectionFunctionAbstract $function)
 {
     $docComment = $function->getDocComment();
     if (!$docComment) {
         return false;
     }
     if (preg_match('/\\*\\s*@return\\s(.*)/i', $docComment, $matches)) {
         return $this->parseReturnString($matches[1], $function);
     } elseif ($function instanceof \ReflectionMethod && false !== strpos($docComment, '{@inheritdoc}')) {
         /** @var \ReflectionMethod $function */
         $class = $function->getDeclaringClass();
         foreach ($class->getInterfaces() as $interface) {
             $result = $this->parseClassMethod($interface, $function->getName());
             if (false !== $result) {
                 return $result;
             }
         }
         if ($parent = $class->getParentClass()) {
             return $this->parseClassMethod($parent, $function->getName());
         }
     }
     return false;
 }
开发者ID:dchesterton,项目名称:phpdoc-to-return,代码行数:28,代码来源:Parser.php

示例4: generateCollaborators

 /**
  * @param CollaboratorManager         $collaborators
  * @param \ReflectionFunctionAbstract $function
  */
 private function generateCollaborators(CollaboratorManager $collaborators, \ReflectionFunctionAbstract $function)
 {
     if ($comment = $function->getDocComment()) {
         $comment = str_replace("\r\n", "\n", $comment);
         foreach (explode("\n", trim($comment)) as $line) {
             if (preg_match(self::$docex, $line, $match)) {
                 $collaborator = $this->getOrCreateCollaborator($collaborators, $match[2]);
                 $collaborator->beADoubleOf($match[1]);
             }
         }
     }
     foreach ($function->getParameters() as $parameter) {
         $collaborator = $this->getOrCreateCollaborator($collaborators, $parameter->getName());
         if (null !== ($class = $parameter->getClass())) {
             $collaborator->beADoubleOf($class->getName());
         }
     }
 }
开发者ID:umpirsky,项目名称:phpspec,代码行数:22,代码来源:CollaboratorsMaintainer.php

示例5: generateCollaborators

 /**
  * @param CollaboratorManager         $collaborators
  * @param \ReflectionFunctionAbstract $function
  * @param \ReflectionClass            $classRefl
  */
 private function generateCollaborators(CollaboratorManager $collaborators, \ReflectionFunctionAbstract $function, \ReflectionClass $classRefl)
 {
     if ($comment = $function->getDocComment()) {
         $comment = str_replace("\r\n", "\n", $comment);
         foreach (explode("\n", trim($comment)) as $line) {
             if (preg_match(self::$docex, $line, $match)) {
                 $collaborator = $this->getOrCreateCollaborator($collaborators, $match[2]);
                 $collaborator->beADoubleOf($match[1]);
             }
         }
     }
     foreach ($function->getParameters() as $parameter) {
         $collaborator = $this->getOrCreateCollaborator($collaborators, $parameter->getName());
         try {
             if ($this->isUnsupportedTypeHinting($parameter)) {
                 throw new InvalidCollaboratorTypeException($parameter, $function);
             }
             if (($indexedClass = $this->getParameterTypeFromIndex($classRefl, $parameter)) || ($indexedClass = $this->getParameterTypeFromReflection($parameter))) {
                 $collaborator->beADoubleOf($indexedClass);
             }
         } catch (ClassNotFoundException $e) {
             $this->throwCollaboratorNotFound($e, null, $e->getClassname());
         } catch (DisallowedScalarTypehintException $e) {
             throw new InvalidCollaboratorTypeException($parameter, $function);
         }
     }
 }
开发者ID:nix9,项目名称:laracasts,代码行数:32,代码来源:CollaboratorsMaintainer.php

示例6: parseCallable

 /**
  *
  * @param EntityFunction $callable
  * @param \ReflectionFunctionAbstract $reflection
  * @return $this
  */
 public static function parseCallable(EntityFunction $callable, \ReflectionFunctionAbstract $reflection)
 {
     $doc = $reflection->getDocComment();
     $params = [];
     if ($doc) {
         $info = ToolKit::parseDoc($doc);
         $callable->setDescription($info['desc']);
         $callable->setReturnInfo($info['return']['type'], $reflection->returnsReference(), $info['return']['desc']);
         $callable->setOptions($info['options']);
         $params = $info["params"];
     } else {
         $info = [];
     }
     /* @var \ReflectionParameter[] $params */
     foreach ($reflection->getParameters() as $param) {
         $argument = new EntityArgument($param->name);
         if (isset($params[$param->name]["desc"])) {
             $argument->description = $params[$param->name]["desc"];
         }
         if ($callable->getLine()) {
             $argument->setLine($callable->getLine());
         }
         $argument->setOptional($param->isOptional());
         $argument->setNullAllowed($param->allowsNull());
         $argument->setValue($param->isDefaultValueAvailable() ? $param->getDefaultValue() : null, $param->isPassedByReference());
         $argument->setByRef($param->isPassedByReference());
         /** @var \ReflectionParameter $param */
         if ($param->isArray()) {
             $argument->setCast(Types::ARR);
         }
         if ($c = $param->getClass()) {
             $argument->setCast(Types::OBJECT, $c->name);
         } elseif (isset($info['params'][$param->name])) {
             $_type = $info['params'][$param->name]["type"];
             if (strpos($_type, "|") || $_type === "mixed") {
                 // multiple types or mixed
                 $argument->setCast(Types::MIXED);
             } else {
                 if (strpos($_type, "[]")) {
                     $argument->setCast(Types::ARR, rtrim($_type, '[]'));
                 }
                 if (isset(Types::$codes[$_type])) {
                     $argument->setCast(Types::getType($_type));
                 } else {
                     $argument->setCast(Types::OBJECT, ltrim($_type, '\\'));
                 }
             }
         } else {
             $argument->warning("not documented");
         }
         $callable->pushArgument($argument);
     }
 }
开发者ID:sergeyk-jomedia,项目名称:koda,代码行数:59,代码来源:EntityFile.php

示例7: admin_mnet_method_get_docblock

/**
 * Given some sort of reflection function/method object, return an array of docblock lines, where each line is an array of
 * keywords/descriptions
 *
 * @param ReflectionFunctionAbstract $function reflection function/method object from which to extract information
 *
 * @return array docblock converted in to an array
 */
function admin_mnet_method_get_docblock(ReflectionFunctionAbstract $function)
{
    return array_map(function ($line) {
        $text = trim($line, " \t\n\r\v*/");
        if (strpos($text, '@param') === 0) {
            return preg_split('/\\s+/', $text, 4);
        }
        if (strpos($text, '@return') === 0) {
            return preg_split('/\\s+/', $text, 3);
        }
        return array($text);
    }, explode("\n", $function->getDocComment()));
}
开发者ID:dg711,项目名称:moodle,代码行数:21,代码来源:upgradelib.php

示例8: setDocBlockFromReflection

 /**
  * @param \ReflectionFunctionAbstract $reflection
  */
 public function setDocBlockFromReflection(\ReflectionFunctionAbstract $reflection)
 {
     $docBlock = $reflection->getDocComment();
     if ($docBlock) {
         $docBlock = preg_replace('/([\\n\\r])(' . self::$_indentation . ')+/', '$1', $docBlock);
         $this->setDocBlock($docBlock);
     }
 }
开发者ID:tomaszdurka,项目名称:codegenerator,代码行数:11,代码来源:FunctionBlock.php

示例9: mapMethod

 /**
  * map a class method using reflection doc comment to get all comments to map
  * parameter type and method return value
  *
  * @error 14107
  * @param ReflectionFunctionAbstract $method expects the method to map
  * @return XO
  */
 protected function mapMethod(ReflectionFunctionAbstract $method)
 {
     $obj = new XO();
     $tmp = array();
     if (($comment = $method->getDocComment()) !== false) {
         $lines = preg_split('/\\n/', trim($comment));
         if (sizeof($lines) > 1) {
             $obj->description = array();
             $obj->params = array();
             $i = -1;
             foreach ($lines as $line) {
                 $i++;
                 if ($i === 0 || $i === sizeof($lines) - 1) {
                     continue;
                 }
                 if (stripos($line, '@') === false || stripos($line, '@desc') !== false) {
                     $line = str_replace(array("\n", "\r\n", "\t"), '', trim($line));
                     $line = preg_replace(array('/\\@desc/i', '/^\\*\\/?\\s*/'), array('', ''), $line);
                     if (!empty($line)) {
                         $tmp[] = $line;
                     }
                 }
                 if (stripos($line, '@param') !== false || stripos($line, '@return') !== false) {
                     $line = str_replace(array("\t", "\n", "\r"), '', trim($line));
                     $line = substr($line, strpos($line, '@'));
                     $line = preg_replace(array('/[ \\s]+/', '/[ \\s]\\|[ \\s]/'), array(' ', '|'), $line);
                     $word = preg_split('/\\s+/i', $line);
                     $word = strtolower($word[1]);
                     if (stripos($word, '|') !== false) {
                         $word = explode('|', $word);
                     }
                     if (stripos($line, '@param') !== false) {
                         if (preg_match('/\\$\\w+\\b(.*)$/isD', $line, $m)) {
                             $obj->params['description'][] = trim($m[1]);
                         } else {
                             $obj->params['description'][] = null;
                         }
                         if (is_string($word) && stripos($word, '$') !== false) {
                             $obj->params['type'][] = 'mixed';
                         } else {
                             $obj->params['type'][] = self::mapType($word);
                         }
                     }
                     if (stripos($line, '@return') !== false) {
                         $obj->returns = self::mapType($word);
                     }
                 }
             }
             if (!empty($tmp)) {
                 $obj->description = implode(" ", $tmp);
             }
         }
     }
     return $obj;
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:63,代码来源:Smd.php

示例10: _importFromReflection

 /**
  * Import callable info from reflection
  *
  * @param \ReflectionFunctionAbstract $method
  *
  * @return static
  */
 protected function _importFromReflection(\ReflectionFunctionAbstract $method)
 {
     $doc = $method->getDocComment();
     $doc_params = [];
     $this->return = new ReturnInfo($this);
     if ($doc) {
         $doc = preg_replace('/^\\s*(\\*\\s*)+/mS', '', trim($doc, "*/ \t\n\r"));
         if (strpos($doc, "@") !== false) {
             $doc = explode("@", $doc, 2);
             if ($doc[0] = trim($doc[0])) {
                 $this->desc = $doc[0];
             }
             if ($doc[1]) {
                 foreach (preg_split('/\\r?\\n@/mS', $doc[1]) as $param) {
                     $param = preg_split('/\\s+/S', $param, 2);
                     if (!isset($param[1])) {
                         $param[1] = "";
                     }
                     switch (strtolower($param[0])) {
                         case 'description':
                             if (empty($this->desc)) {
                                 $this->desc = $param[1];
                             }
                             break;
                         case 'param':
                             if (preg_match('/^(.*?)\\s+\\$(\\w+)\\s*(?:\\(([^\\)]+)\\))?/mS', $param[1], $matches)) {
                                 $this->params[$matches[2]] = ["type" => $matches[1], "desc" => trim(substr($param[1], strlen($matches[0]))), "filters" => isset($matches[3]) ? Filter::parseDoc($matches[3]) : []];
                             }
                             break;
                         case 'return':
                             $return = preg_split('~\\s+~mS', $param[1], 2);
                             if ($return) {
                                 $this->return->type = $return[0];
                                 if (count($return) == 2) {
                                     $this->return->desc = $return[1];
                                 }
                             }
                             break;
                         default:
                             if (isset($this->options[$param[0]])) {
                                 $this->options[$param[0]][] = $param[1];
                             } else {
                                 $this->options[$param[0]] = [$param[1]];
                             }
                     }
                 }
             }
         } else {
             $this->desc = $doc;
         }
     }
     foreach ($method->getParameters() as $param) {
         $this->args[$param->name] = $arg = new ArgumentInfo($this);
         $arg->import($param);
     }
     return $this;
 }
开发者ID:bzick,项目名称:koda,代码行数:64,代码来源:CallableInfo.php


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