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


PHP ReflectionMethod::getDocComment方法代码示例

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


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

示例1: create

 public static function create($name, ReflectionMethod $method)
 {
     $result = new ckWsdlOperation();
     $result->setName($name);
     $params = ckDocBlockParser::parseParameters($method->getDocComment());
     $headers = ckDocBlockParser::parseHeader($method->getDocComment());
     $return = ckDocBlockParser::parseReturn($method->getDocComment());
     $result->input = new ckWsdlMessage($name . 'Request');
     foreach ($params as $param) {
         $type = ckXsdType::get($param['type']);
         $result->input->addPart(new ckWsdlPart($param['name'], $type));
     }
     foreach ($headers as $header) {
         $type = ckXsdType::get($header['type']);
         $type->setName($header['name']);
         $type->setIsElement(true);
         ckXsdType::set($header['name'], $type);
         ckXsdType::set($header['type'], null);
         $result->input->addPart(new ckWsdlPart($header['name'], $type, true));
     }
     if (!empty($return)) {
         $type = ckXsdType::get($return['type']);
         $result->output = new ckWsdlMessage($name . 'Response');
         $result->output->addPart(new ckWsdlPart('return', $type));
     }
     return $result;
 }
开发者ID:psskhal,项目名称:symfony-sample,代码行数:27,代码来源:ckWsdlOperation.class.php

示例2: createClassDefinition

 private function createClassDefinition()
 {
     $fullClassName = $this->getClass();
     if (class_exists($fullClassName)) {
         return;
     }
     $parts = explode('\\', $fullClassName);
     $shortName = array_pop($parts);
     $namespace = implode('\\', $parts);
     $properties = [];
     $parameters = [];
     $body = [];
     $getters = [];
     foreach ($this->method->getParameters() as $parameter) {
         $name = $parameter->getName();
         $parameters[] = '$' . $name . ($parameter->isDefaultValueAvailable() ? ' = ' . var_export($parameter->getDefaultValue(), true) : '');
         $body[] = '$this->' . $name . ' = $' . $name . ';';
         $properties[] = 'private $' . $name . ';';
         $hint = null;
         $matches = [];
         if ($parameter->getClass()) {
             $hint = $parameter->getClass()->getName();
         } else {
             if (preg_match('/@param\\s+(\\S+)\\s+\\$' . $name . '/', $this->method->getDocComment(), $matches)) {
                 $hint = $matches[1];
             }
         }
         $getters[] = ($hint ? "/**\n   * @return " . $hint . "\n   */\n  " : '') . 'function get' . ucfirst($name) . '() { return $this->' . $name . '; }';
     }
     $code = ($namespace ? "namespace {$namespace};\n" : '') . "class {$shortName} {\n" . '  ' . implode("\n  ", $properties) . "\n" . '  function __construct(' . implode(', ', $parameters) . ") {\n" . '    ' . implode("\n    ", $body) . "\n" . '  }' . "\n" . '  ' . implode("\n  ", $getters) . "\n" . '}';
     eval($code);
 }
开发者ID:watoki,项目名称:qrator,代码行数:32,代码来源:MethodActionRepresenter.php

示例3: getAnnotationReflection

 /**
  * @return IAnnotationReflection
  */
 public function getAnnotationReflection()
 {
     if ($this->annotationReflection === null) {
         $this->annotationReflection = AnnotationReflection::build($this->reflectionMethod->getDocComment());
     }
     return $this->annotationReflection;
 }
开发者ID:edde-framework,项目名称:edde,代码行数:10,代码来源:MethodReflection.php

示例4: __construct

 public function __construct(Controller $controller, $action)
 {
     $this->controller = $controller;
     $this->name = $action;
     $this->reflector = new \ReflectionMethod($controller, $action);
     $this->docComment = $this->reflector->getDocComment();
     $this->parameters = $this->reflector->getParameters();
     $this->initializeAttributes();
 }
开发者ID:sanzhumu,项目名称:xaircraft1.1,代码行数:9,代码来源:ActionInfo.php

示例5: extractCommentWithoutLeadingShashesAndStars

 public function extractCommentWithoutLeadingShashesAndStars()
 {
     $this->comment = explode("\n", $this->reflector->getDocComment());
     foreach ($this->comment as &$line) {
         $line = preg_replace('#^\\s*(/\\*+|\\*+/|\\*)\\s?#', '', $line);
     }
     $this->trimLeadingBlankLinesFromComment();
     $this->trimTrailingBlankLinesFromComment();
 }
开发者ID:Ceciceciceci,项目名称:MySJSU-Class-Registration,代码行数:9,代码来源:FactoryMethod.php

示例6: getAnnotationType

 private function getAnnotationType($annotation)
 {
     $matches = array();
     $found = preg_match('/@' . $annotation . '\\s+(\\S+)/', $this->reflection->getDocComment(), $matches);
     if (!$found) {
         return new UnknownType();
     }
     $type = new TypeFactory($this->reflection->getDeclaringClass());
     return $type->fromTypeHints(explode("|", $matches[1]));
 }
开发者ID:rtens,项目名称:mockster3,代码行数:10,代码来源:ReturnTypeInferer.php

示例7: description

 /**
  * @return string|null
  */
 public function description()
 {
     $lines = array_slice(explode("\n", $this->method->getDocComment()), 1, -1);
     $lines = array_map(function ($line) {
         return ltrim($line, ' *');
     }, $lines);
     $lines = array_filter($lines, function ($line) {
         return substr($line, 0, 1) != '@';
     });
     return $this->parser->parse(trim(implode("\n", $lines)));
 }
开发者ID:jonfm,项目名称:domin,代码行数:14,代码来源:MethodAction.php

示例8: getParsedDocs

 /**
  * Returns an array with parsed lines from PHPDoc.
  *
  * @return array
  */
 protected function getParsedDocs()
 {
     $lines_docs = explode("\n", $this->reflection->getDocComment());
     // Remove first line (/**)
     array_shift($lines_docs);
     // Remove last line (*/)
     array_pop($lines_docs);
     return array_map(function ($item) {
         return ltrim($item, '* ');
     }, $lines_docs);
 }
开发者ID:pomek,项目名称:path2api,代码行数:16,代码来源:PhpDocParser.php

示例9: handleMockSubscribers

 public function handleMockSubscribers()
 {
     $reflection = new \ReflectionMethod(get_class($this), $this->getName());
     if (false == ($mockFile = self::parseDocBlock($reflection->getDocComment()))) {
         return;
     }
     $mockPath = self::parseDocBlock($reflection->getDocComment(), self::ANNOTATION_PATH);
     $mockFilePath = $this->getTestFilePath($mockFile, $mockPath);
     if (file_exists($mockFilePath)) {
         $this->getClient()->getEventDispatcher()->removeListener('request.before_send', 'onRequestBeforeSend');
         $this->addMockSubscriber($mockFilePath, 0);
     }
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:13,代码来源:OpenCloudTestCase.php

示例10: loadParameters

 /**
  * This method is used to return an iteration-friendly list of parameters for a given method.
  *
  * @param string $className
  * @param string $method
  * @return array
  */
 protected function loadParameters($className, $method)
 {
     // dig for data on the chosen method, in the chosen class
     $parameters = array();
     $reflectionMethod = new ReflectionMethod($className, $method);
     $PHPDoc = $reflectionMethod->getDocComment();
     /*
      * This regex filters out all parameters, along with their PHPDoc. We use this instead
      * of $reflectionMethod->getParameters(), since that returns ReflectionParameter objects
      * that, rather shamefully, do not contain PHPDoc.
      */
     preg_match_all('/@param[\\s\\t]+(.*)[\\s\\t]+\\$(.*)[\\s\\t]+(.*)$/Um', $PHPDoc, $matches);
     if (array_key_exists(0, $matches) && empty($matches[0])) {
         continue;
     }
     $phpdoc = array();
     // we have to build up a custom stack of parameters
     foreach ($matches[0] as $i => $row) {
         $name = $matches[2][$i];
         if ($name === 'language') {
             continue;
         }
         $parameters[] = array('name' => $name, 'label' => $name . '-' . rand(1, 99999), 'optional' => substr_count($matches[2][$i], '[optional]') > 0, 'description' => $matches[3][$i]);
     }
     return $parameters;
 }
开发者ID:nickmancol,项目名称:forkcms-rhcloud,代码行数:33,代码来源:client.php

示例11: testAutoload

 /**
  * Test valid public function/method names.
  *
  * @return void
  */
 public function testAutoload()
 {
     try {
         $object = new SQLI_CodeSniffer();
         $this->assertTrue($object instanceof SQLI_CodeSniffer);
     } catch (Exception $e) {
         $this->fail('Autoload an SQLI_CodeSniffer Core class');
     }
     try {
         $object = new PHP_CodeSniffer_Exception("test");
         $this->assertTrue($object instanceof PHP_CodeSniffer_Exception);
     } catch (Exception $e) {
         $this->fail('Autoload a PHP_CodeSniffer Core class ' . $e->getMessage());
     }
     try {
         $object = new Generic_Sniffs_Classes_DuplicateClassNameSniff();
         // trick to recognize SQLI implemented sniffer
         $method = new ReflectionMethod('Generic_Sniffs_Classes_DuplicateClassNameSniff', 'process');
         $this->assertContains('SQLI_CodeSniffer_File', $method->getDocComment());
     } catch (Exception $e) {
         $this->fail('Autoload an SQLI_CodeSniffer sniffer');
     }
     try {
         $object = new Generic_Sniffs_CodeAnalysis_UnnecessaryFinalModifierSniff();
         // trick to recognize classical sniffer
         $method = new ReflectionMethod('Generic_Sniffs_CodeAnalysis_UnnecessaryFinalModifierSniff', 'process');
         $this->assertContains('PHP_CodeSniffer_File', $method->getDocComment());
     } catch (Exception $e) {
         $this->fail('Autoload a PHP_CodeSniffer sniffer');
     }
 }
开发者ID:proofek,项目名称:SQLI_CodeSniffer,代码行数:36,代码来源:CodeSnifferTest.php

示例12: getActionAuthorization

 public function getActionAuthorization($class, $action)
 {
     $refMethod = new \ReflectionMethod($class, $action);
     $doc = $refMethod->getDocComment();
     preg_match_all("/@Authorize/", $doc, $authorizations);
     return $authorizations[0];
 }
开发者ID:Web-Development-PHP,项目名称:E-Shop,代码行数:7,代码来源:ReflectionService.php

示例13: getDocAttribute

 public static function getDocAttribute(\ReflectionMethod $reflectionMethod, $attributeName)
 {
     $doc = $reflectionMethod->getDocComment();
     if ($doc && preg_match('/\\* @' . $attributeName . '\\s?(.*)\\r?\\n/', $doc, $matches)) {
         return $matches[1];
     }
 }
开发者ID:farafiri,项目名称:class-generator-for-php,代码行数:7,代码来源:Utils.php

示例14: extractFeature

 private function extractFeature(\PHPUnit_Framework_Test $test)
 {
     $class = get_class($test);
     $method = $test->getName();
     $reflection = new \ReflectionMethod($class, $method);
     return $this->parseDocBlock($reflection->getDocComment(), '@feature');
 }
开发者ID:php-http,项目名称:adapter-integration-tests,代码行数:7,代码来源:FeatureTestListener.php

示例15: generate

 /**
  * 
  * @param GenerationContext $context
  * @param \Nucleus\IService\CommandLine\Consolable $annotation
  */
 public function generate(GenerationContext $context, $annotation)
 {
     $docParser = new DocBlockParser();
     $serviceName = $context->getServiceName();
     $methodName = $context->getParsingContextName();
     $definition = $context->getContainerBuilder()->getDefinition($serviceName);
     $shortDesc = 'N/A';
     $reflectedMethod = new \ReflectionMethod($definition->getClass(), $methodName);
     $methodComment = $reflectedMethod->getDocComment();
     if ($methodComment !== false) {
         $docMethod = $docParser->parse($methodComment);
         $shortDesc = $docMethod->getShortDesc();
     }
     $paramsArray = array();
     $paramArrayComments = self::extractParamDocComment($docMethod->getTag('param'));
     foreach ($reflectedMethod->getParameters() as $reflectionParameter) {
         $paramComment = 'N/A';
         if (isset($paramArrayComments[$reflectionParameter->getName()])) {
             $paramComment = $paramArrayComments[$reflectionParameter->getName()]['comment'];
         }
         $paramsArray[$reflectionParameter->getName()]['optional'] = false;
         if ($reflectionParameter->isDefaultValueAvailable()) {
             $paramsArray[$reflectionParameter->getName()]['optional'] = true;
         }
         $paramsArray[$reflectionParameter->getName()]['comment'] = $paramComment;
     }
     if (!empty($annotation->name)) {
         $name = $annotation->name;
     } else {
         $name = $serviceName . ':' . $methodName;
     }
     $context->getContainerBuilder()->getDefinition("console")->addMethodCall("addCommand", array("applicatiomName" => $name, "serviceName" => $serviceName, "methodName" => $methodName, "shortDesc" => $shortDesc, "paramsMethod" => $paramsArray));
 }
开发者ID:mpoiriert,项目名称:nucleus,代码行数:38,代码来源:ConsolableContainerGenerator.php


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