Example #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;
     });
 }
 /**
  * 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));
 }
Example #3
0
 /**
  * @covers ::__construct
  * @covers ::getNamespaceAliases
  */
 public function testProvidesNormalizedNamespaceAliases()
 {
     $fixture = new Context('', ['Space' => '\\My\\Space']);
     $this->assertSame(['Space' => 'My\\Space'], $fixture->getNamespaceAliases());
 }
Example #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');
 }
 /**
  * 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());
 }