Skip to content

Commit

Permalink
Add tests for CuyZ#353
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Feb 27, 2023
1 parent 3d3f670 commit 4eb944b
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion tests/Integration/Mapping/Object/LocalTypeAliasMappingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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<int>
*/
interface PhpStanLocalAliasesInterface
{
}

/**
* @phpstan-import-type AliasWithEqualsSign from PhpStanLocalAliases
*/
Expand All @@ -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[]
Expand Down Expand Up @@ -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<int>
*/
interface PsalmLocalAliasesInterface
{
}

/**
* @psalm-import-type AliasWithEqualsSign from PsalmLocalAliases
*/
Expand All @@ -133,3 +168,12 @@ class PsalmAliasImport
/** @var AliasWithEqualsSign */
public int $importedType;
}

/**
* @psalm-import-type AliasWithEqualsSign from PsalmLocalAliasesInterface
*/
class PsalmAliasImportFromInterface
{
/** @var AliasWithEqualsSign */
public int $importedType;
}

0 comments on commit 4eb944b

Please sign in to comment.