Skip to content

Commit

Permalink
ignore (psalm) pseudo types
Browse files Browse the repository at this point in the history
  • Loading branch information
smoench committed Jul 24, 2020
1 parent 1bf348f commit b0797bb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/AstRunner/Resolver/TypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@

class TypeResolver
{
private const PSEUDO_TYPES = [
'array-key',
'trait-string',
'callable-string',
'numeric-string',
];

/**
* @var \phpDocumentor\Reflection\TypeResolver
*/
Expand Down Expand Up @@ -124,6 +131,10 @@ public function resolvePHPStanDocParserType(TypeNode $type, TypeScope $typeScope
*/
public function resolveString(string $type, TypeScope $nameScope): array
{
if (in_array($type, self::PSEUDO_TYPES, true)) {
return [];
}

$context = new Context($nameScope->getNamespace(), $nameScope->getUses());
$resolvedType = $this->typeResolver->resolve($type, $context);

Expand Down
4 changes: 4 additions & 0 deletions tests/AstRunner/Resolver/TypeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,9 @@ public function docBlockProvider(): iterable
yield ['doc' => 'callable(A&...$a=, B&...=, C): Foo', 'types' => ['\\Test\\Foo', '\\Test\\A', '\\Test\\B', '\\Test\\C']];
yield ['doc' => 'Foo::FOO_CONSTANT', 'types' => ['\\Test\\Foo']];
yield ['doc' => 'array{a: Foo}', 'types' => ['\\Test\\Foo']];
yield ['doc' => 'array-key', 'types' => []];
yield ['doc' => 'trait-string', 'types' => []];
yield ['doc' => 'callable-string', 'types' => []];
yield ['doc' => 'numeric-string', 'types' => []];
}
}

0 comments on commit b0797bb

Please sign in to comment.