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