|  | 
| 22 | 22 | use phpDocumentor\Reflection\Types\Context; | 
| 23 | 23 | use phpDocumentor\Reflection\Types\Expression; | 
| 24 | 24 | use phpDocumentor\Reflection\Types\Integer; | 
|  | 25 | +use phpDocumentor\Reflection\Types\InterfaceString; | 
| 25 | 26 | use phpDocumentor\Reflection\Types\Intersection; | 
| 26 | 27 | use phpDocumentor\Reflection\Types\Iterable_; | 
| 27 | 28 | use phpDocumentor\Reflection\Types\Nullable; | 
| @@ -71,6 +72,7 @@ final class TypeResolver | 
| 71 | 72 |     private $keywords = [ | 
| 72 | 73 |         'string' => Types\String_::class, | 
| 73 | 74 |         'class-string' => Types\ClassString::class, | 
|  | 75 | +        'interface-string' => Types\InterfaceString::class, | 
| 74 | 76 |         'html-escaped-string' => PseudoTypes\HtmlEscapedString::class, | 
| 75 | 77 |         'lowercase-string' => PseudoTypes\LowercaseString::class, | 
| 76 | 78 |         'non-empty-lowercase-string' => PseudoTypes\NonEmptyLowercaseString::class, | 
| @@ -246,6 +248,8 @@ private function parseTypes(ArrayIterator $tokens, Context $context, int $parser | 
| 246 | 248 |                 if ($classType !== null) { | 
| 247 | 249 |                     if ((string) $classType === 'class-string') { | 
| 248 | 250 |                         $types[] = $this->resolveClassString($tokens, $context); | 
|  | 251 | +                    } elseif ((string) $classType === 'interface-string') { | 
|  | 252 | +                        $types[] = $this->resolveInterfaceString($tokens, $context); | 
| 249 | 253 |                     } else { | 
| 250 | 254 |                         $types[] = $this->resolveCollection($tokens, $classType, $context); | 
| 251 | 255 |                     } | 
| @@ -455,6 +459,39 @@ private function resolveClassString(ArrayIterator $tokens, Context $context) : T | 
| 455 | 459 |         return new ClassString($classType->getFqsen()); | 
| 456 | 460 |     } | 
| 457 | 461 | 
 | 
|  | 462 | +    /** | 
|  | 463 | +     * Resolves class string | 
|  | 464 | +     * | 
|  | 465 | +     * @param ArrayIterator<int, (string|null)> $tokens | 
|  | 466 | +     */ | 
|  | 467 | +    private function resolveInterfaceString(ArrayIterator $tokens, Context $context) : Type | 
|  | 468 | +    { | 
|  | 469 | +        $tokens->next(); | 
|  | 470 | + | 
|  | 471 | +        $classType = $this->parseTypes($tokens, $context, self::PARSER_IN_COLLECTION_EXPRESSION); | 
|  | 472 | + | 
|  | 473 | +        if (!$classType instanceof Object_ || $classType->getFqsen() === null) { | 
|  | 474 | +            throw new RuntimeException( | 
|  | 475 | +                $classType . ' is not a interface string' | 
|  | 476 | +            ); | 
|  | 477 | +        } | 
|  | 478 | + | 
|  | 479 | +        $token = $tokens->current(); | 
|  | 480 | +        if ($token !== '>') { | 
|  | 481 | +            if (empty($token)) { | 
|  | 482 | +                throw new RuntimeException( | 
|  | 483 | +                    'interface-string: ">" is missing' | 
|  | 484 | +                ); | 
|  | 485 | +            } | 
|  | 486 | + | 
|  | 487 | +            throw new RuntimeException( | 
|  | 488 | +                'Unexpected character "' . $token . '", ">" is missing' | 
|  | 489 | +            ); | 
|  | 490 | +        } | 
|  | 491 | + | 
|  | 492 | +        return new InterfaceString($classType->getFqsen()); | 
|  | 493 | +    } | 
|  | 494 | + | 
| 458 | 495 |     /** | 
| 459 | 496 |      * Resolves the collection values and keys | 
| 460 | 497 |      * | 
|  | 
0 commit comments