Пример #1
0
 /**
  * @param ReflectionParameter $reflectionParameter
  * @param Context             $context
  *
  * @return ParamTag[]
  */
 private function getParamTagsForParameter(ReflectionParameter $reflectionParameter, Context $context)
 {
     $reflectionFunction = $reflectionParameter->getDeclaringFunction();
     $parameterName = $reflectionParameter->getName();
     return array_filter((new DocBlock($reflectionFunction, new DocBlock\Context($context->getNamespace(), $context->getNamespaceAliases())))->getTagsByName('param'), function (ParamTag $paramTag) use($parameterName) {
         return ltrim($paramTag->getVariableName(), '$') === $parameterName;
     });
 }
Пример #2
0
 /**
  * Resolves a partial Structural Element Name (i.e. `Reflection\DocBlock`) to its FQSEN representation
  * (i.e. `\phpDocumentor\Reflection\DocBlock`) based on the Namespace and aliases mentioned in the Context.
  *
  * @param string $type
  * @param Context $context
  *
  * @return Fqsen
  */
 private function resolvePartialStructuralElementName($type, Context $context)
 {
     $typeParts = explode(self::OPERATOR_NAMESPACE, $type, 2);
     $namespaceAliases = $context->getNamespaceAliases();
     // if the first segment is not an alias; prepend namespace name and return
     if (!isset($namespaceAliases[$typeParts[0]])) {
         $namespace = $context->getNamespace();
         if ('' !== $namespace) {
             $namespace .= self::OPERATOR_NAMESPACE;
         }
         return new Fqsen(self::OPERATOR_NAMESPACE . $namespace . $type);
     }
     $typeParts[0] = $namespaceAliases[$typeParts[0]];
     return new Fqsen(self::OPERATOR_NAMESPACE . implode(self::OPERATOR_NAMESPACE, $typeParts));
 }
Пример #3
0
 /**
  * @covers ::__construct
  * @covers ::getNamespace
  */
 public function testInterpretsNamespaceNamedDefaultAsRootNamespace()
 {
     $fixture = new Context('default');
     $this->assertSame('', $fixture->getNamespace());
 }
Пример #4
0
 /**
  * @param ReflectionMethod $reflectionMethod
  * @param Context          $context
  *
  * @return ReturnTag[]
  */
 private function getReturnTagForMethod(ReflectionMethod $reflectionMethod, Context $context)
 {
     return (new DocBlock($reflectionMethod, new DocBlock\Context($context->getNamespace(), $context->getNamespaceAliases())))->getTagsByName('return');
 }
Пример #5
0
 /**
  * Convert TypeResolver Context to DocBlock Context
  *
  * @param Context $context
  * @return DocBlock\Context
  */
 private function convertToDocBlockContext(Context $context)
 {
     return new DocBlock\Context($context->getNamespace(), $context->getNamespaceAliases());
 }