File tree Expand file tree Collapse file tree 4 files changed +13
-4
lines changed
Expand file tree Collapse file tree 4 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 1919
2020final class TagReferenceExtractor
2121{
22+ /**
23+ * @return array{ReferenceInterface, string|null}
24+ */
2225 public function extract (string $ body ): array
2326 {
2427 $ description = \strpbrk ($ body , " \t\n\r\0\x0B" );
@@ -47,9 +50,11 @@ private function parseReference(string $body): ReferenceInterface
4750 }
4851
4952 if (\str_contains ($ body , ':: ' )) {
50- return \str_contains ($ body , '$ ' )
53+ $ result = \str_contains ($ body , '$ ' )
5154 ? $ this ->tryParseClassProperty ($ body )
5255 : $ this ->tryParseClassConst ($ body );
56+
57+ return $ result ?? new GenericReference ($ body );
5358 }
5459
5560 if ($ result = $ this ->tryParseNameReference ($ body )) {
Original file line number Diff line number Diff line change 44
55namespace TypeLang \PhpDocParser \DocBlock \Tag ;
66
7+ use TypeLang \Parser \Node \Name ;
78use TypeLang \Parser \Node \Stmt \TypeStatement ;
89use TypeLang \Printer \PrettyPrinter ;
910
@@ -32,7 +33,9 @@ public function __toString(): string
3233 {
3334 $ type = $ this ->type ::class;
3435
35- if (\property_exists ($ this ->type , 'name ' )) {
36+ /** @psalm-suppress UndefinedPropertyFetch : Psalm false-positive */
37+ if (\property_exists ($ this ->type , 'name ' )
38+ && $ this ->type ->name instanceof Name) {
3639 $ type = (string )$ this ->type ->name ;
3740 }
3841
Original file line number Diff line number Diff line change 77use TypeLang \Parser \Parser ;
88use TypeLang \PhpDocParser \Description \DescriptionFactoryInterface ;
99use TypeLang \PhpDocParser \DocBlock \Tag \CreatableFromTagAndDescriptionInterface ;
10- use TypeLang \PhpDocParser \DocBlock \Tag \TypedTag ;
1110use TypeLang \PhpDocParser \Exception \InvalidTagException ;
1211
1312/**
@@ -27,7 +26,7 @@ public function __construct(
2726 parent ::__construct ($ parser , $ descriptions );
2827 }
2928
30- public function create (string $ tag ): TypedTag
29+ public function create (string $ tag ): CreatableFromTagAndDescriptionInterface
3130 {
3231 [$ type , $ description ] = $ this ->types ->extractTypeOrMixed ($ tag );
3332
Original file line number Diff line number Diff line change @@ -180,6 +180,8 @@ private function getAllTags(): iterable
180180
181181 /**
182182 * @return iterable<non-empty-lowercase-string, TagFactoryInterface>
183+ *
184+ * @psalm-suppress MoreSpecificReturnType : Psalm false-positive
183185 */
184186 public function getTags (): iterable
185187 {
You can’t perform that action at this time.
0 commit comments