Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit777e91a

Browse files
bug#61004 [TypeInfo] Fix imported-only alias resolving (mtarld)
This PR was merged into the 7.3 branch.Discussion----------[TypeInfo] Fix imported-only alias resolving| Q | A| ------------- | ---| Branch? | 7.3| Bug fix? | yes| New feature? | no| Deprecations? | no| Issues |Fix#60997| License | MITFix type alias resolving when aliases are only coming from imports.Commits-------d19800f [TypeInfo] Fix imported-only alias resolving
2 parents3ba5d5e +d19800f commit777e91a

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

‎src/Symfony/Component/TypeInfo/Tests/Fixtures/DummyWithTypeAliases.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ final class DummyWithTypeAliases
5757
publicmixed$psalmOtherAliasedExternalAlias;
5858
}
5959

60+
/**
61+
* @phpstan-import-type CustomInt from DummyWithPhpDoc
62+
*/
63+
finalclass DummyWithImportedOnlyTypeAliases
64+
{
65+
/**
66+
* @var CustomInt
67+
*/
68+
publicmixed$externalAlias;
69+
}
70+
6071
/**
6172
* @phpstan-type Foo = array{0: Bar}
6273
* @phpstan-type Bar = array{0: Foo}

‎src/Symfony/Component/TypeInfo/Tests/TypeContext/TypeContextFactoryTest.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
useSymfony\Component\TypeInfo\Exception\LogicException;
1616
useSymfony\Component\TypeInfo\Tests\Fixtures\AbstractDummy;
1717
useSymfony\Component\TypeInfo\Tests\Fixtures\Dummy;
18+
useSymfony\Component\TypeInfo\Tests\Fixtures\DummyWithImportedOnlyTypeAliases;
1819
useSymfony\Component\TypeInfo\Tests\Fixtures\DummyWithInvalidTypeAlias;
1920
useSymfony\Component\TypeInfo\Tests\Fixtures\DummyWithInvalidTypeAliasImport;
2021
useSymfony\Component\TypeInfo\Tests\Fixtures\DummyWithRecursiveTypeAliases;
@@ -179,6 +180,10 @@ public function testCollectTypeAliases()
179180
'PsalmCustomArray' => Type::arrayShape([0 => Type::int(),1 => Type::string(),2 => Type::bool()]),
180181
'PsalmAliasedCustomInt' => Type::int(),
181182
],$this->typeContextFactory->createFromReflection(new \ReflectionProperty(DummyWithTypeAliases::class,'localAlias'))->typeAliases);
183+
184+
$this->assertEquals([
185+
'CustomInt' => Type::int(),
186+
],$this->typeContextFactory->createFromReflection(new \ReflectionClass(DummyWithImportedOnlyTypeAliases::class))->typeAliases);
182187
}
183188

184189
publicfunctiontestDoNotCollectTypeAliasesWhenToStringTypeResolver()

‎src/Symfony/Component/TypeInfo/TypeContext/TypeContextFactory.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ private function collectTypeAliases(\ReflectionClass $reflection, TypeContext $t
241241
privatefunctionresolveTypeAliases(array$toResolve,array$resolved,TypeContext$typeContext):array
242242
{
243243
if (!$toResolve) {
244-
return[];
244+
return$resolved;
245245
}
246246

247247
$typeContext =newTypeContext(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp