From 4eb944b50e609a24cb8dda152d298bc1ff431b40 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Mon, 27 Feb 2023 13:35:53 +0100 Subject: [PATCH] Add tests for https://github.com/CuyZ/Valinor/issues/353 --- .../Object/LocalTypeAliasMappingTest.php | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/tests/Integration/Mapping/Object/LocalTypeAliasMappingTest.php b/tests/Integration/Mapping/Object/LocalTypeAliasMappingTest.php index 2c1dcb10..65d18ab9 100644 --- a/tests/Integration/Mapping/Object/LocalTypeAliasMappingTest.php +++ b/tests/Integration/Mapping/Object/LocalTypeAliasMappingTest.php @@ -40,7 +40,12 @@ public function test_values_are_mapped_properly(): void public function test_type_aliases_are_imported_correctly(): void { - foreach ([PhpStanAliasImport::class, PsalmAliasImport::class] as $class) { + foreach ([ + PhpStanAliasImport::class, + PsalmAliasImport::class, + PhpStanAliasImportFromInterface::class, + PsalmAliasImportFromInterface::class + ] as $class) { try { $result = (new MapperBuilder()) ->mapper() @@ -85,6 +90,16 @@ class PhpStanLocalAliases public GenericObjectWithPhpStanLocalAlias $aliasGeneric; } +/** + * @phpstan-type AliasWithEqualsSign = int + * @phpstan-type AliasWithoutEqualsSign int + * @phpstan-type AliasShapedArray = array{foo: string, bar: int} + * @phpstan-type AliasGeneric = GenericObjectWithPhpStanLocalAlias + */ +interface PhpStanLocalAliasesInterface +{ +} + /** * @phpstan-import-type AliasWithEqualsSign from PhpStanLocalAliases */ @@ -94,6 +109,16 @@ class PhpStanAliasImport public int $importedType; } + +/** + * @phpstan-import-type AliasWithEqualsSign from PhpStanLocalAliasesInterface + */ +class PhpStanAliasImportFromInterface +{ + /** @var AliasWithEqualsSign */ + public int $importedType; +} + /** * @template T * @psalm-type AliasArray = T[] @@ -125,6 +150,16 @@ class PsalmLocalAliases public GenericObjectWithPsalmLocalAlias $aliasGeneric; } +/** + * @psalm-type AliasWithEqualsSign = int + * @psalm-type AliasWithoutEqualsSign int + * @psalm-type AliasShapedArray = array{foo: string, bar: int} + * @psalm-type AliasGeneric = GenericObjectWithPsalmLocalAlias + */ +interface PsalmLocalAliasesInterface +{ +} + /** * @psalm-import-type AliasWithEqualsSign from PsalmLocalAliases */ @@ -133,3 +168,12 @@ class PsalmAliasImport /** @var AliasWithEqualsSign */ public int $importedType; } + +/** + * @psalm-import-type AliasWithEqualsSign from PsalmLocalAliasesInterface + */ +class PsalmAliasImportFromInterface +{ + /** @var AliasWithEqualsSign */ + public int $importedType; +} \ No newline at end of file