Skip to content

Commit af21e23

Browse files
committed
Skip invalid class names in phpDocs
1 parent 76f8760 commit af21e23

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/PhpDoc/TypeNodeResolver.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,12 @@ private function resolveIdentifierTypeNode(IdentifierTypeNode $typeNode, NameSco
219219
return $templateType;
220220
}
221221

222-
return new ObjectType($nameScope->resolveStringName($typeNode->name));
222+
$stringName = $nameScope->resolveStringName($typeNode->name);
223+
if (strpos($stringName, '-') !== false && strpos($stringName, 'OCI-') !== 0) {
224+
return new ErrorType();
225+
}
226+
227+
return new ObjectType($stringName);
223228
}
224229

225230
private function resolveThisTypeNode(ThisTypeNode $typeNode, NameScope $nameScope): Type

tests/PHPStan/Analyser/data/psalm-prefix-unresolvable.php

+12
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,16 @@ public function doBar(): void
2121
assertType('array<int, string>', $this->doFoo());
2222
}
2323

24+
/**
25+
* @param Foo $param
26+
* @param Foo $param2
27+
* @psalm-param foo-bar $param
28+
* @psalm-param foo-bar<Test> $param2
29+
*/
30+
public function doBaz($param, $param2)
31+
{
32+
assertType('PsalmPrefixedTagsWithUnresolvableTypes\Foo', $param);
33+
assertType('PsalmPrefixedTagsWithUnresolvableTypes\Foo', $param2);
34+
}
35+
2436
}

0 commit comments

Comments
 (0)