Skip to content

Commit

Permalink
test: add missing test for class declaring invalid type alias
Browse files Browse the repository at this point in the history
  • Loading branch information
romm committed Mar 27, 2024
1 parent baedd27 commit b5c460c
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,23 @@ public function test_class_with_local_type_alias_name_duplication_throws_excepti
$this->repository->for(new NativeClassType($class, ['T' => new FakeType(), 'AnotherTemplate' => new FakeType()]));
}

public function test_class_with_invalid_type_alias_throws_exception(): void
{
$class =
/**
* @phpstan-type T = array{foo: string
*/
(new class () {
/** @var T */
public $value; // @phpstan-ignore-line
})::class;

$type = $this->repository->for(new NativeClassType($class))->properties->get('value')->type;

self::assertInstanceOf(UnresolvableType::class, $type);
self::assertMatchesRegularExpression('/^The type `array{foo: string` for local alias `T` of the class `.*` could not be resolved: Missing closing curly bracket in shaped array signature `array{foo: string`\.$/', $type->message());
}

public function test_class_with_invalid_type_alias_import_class_throws_exception(): void
{
$class =
Expand Down

0 comments on commit b5c460c

Please sign in to comment.