1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Fix generic ArrayAccess creation cc @orklah

This commit is contained in:
Matt Brown 2020-11-26 10:00:03 -05:00 committed by Daniil Gentili
parent 1966766a79
commit 9539c0f27f
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 6 additions and 11 deletions

View File

@ -1213,8 +1213,7 @@ class SimpleAssertionReconciler extends \Psalm\Type\Reconciler
self::refineArrayKey($clone_type->type_params[0]);
$object_types[] = new TArray($clone_type->type_params);
$object_types[] = new TNamedObject('ArrayAccess');
$object_types[] = new Type\Atomic\TGenericObject('ArrayAccess', $clone_type->type_params);
$did_remove_type = true;
} else {

View File

@ -37,16 +37,12 @@ class ReconcilerTest extends \Psalm\Tests\TestCase
/**
* @dataProvider providerTestReconcilation
*
* @param string $expected
* @param string $type
* @param string $string
*
*/
public function testReconcilation($expected, $type, $string): void
public function testReconcilation(string $expected_type, string $assertion, string $original_type): void
{
$reconciled = \Psalm\Internal\Type\AssertionReconciler::reconcile(
$type,
Type::parseString($string),
$assertion,
Type::parseString($original_type),
null,
$this->statements_analyzer,
false,
@ -54,7 +50,7 @@ class ReconcilerTest extends \Psalm\Tests\TestCase
);
$this->assertSame(
$expected,
$expected_type,
$reconciled->getId()
);
@ -134,7 +130,7 @@ class ReconcilerTest extends \Psalm\Tests\TestCase
'traversableToIntersection' => ['Countable&Traversable', 'Traversable', 'Countable'],
'iterableWithoutParamsToTraversableWithoutParams' => ['Traversable', '!array', 'iterable'],
'iterableWithParamsToTraversableWithParams' => ['Traversable<int, string>', '!array', 'iterable<int, string>'],
'iterableAndObject' => ['ArrayAccess|array<int, string>', 'object', 'iterable<int, string>'],
'iterableAndObject' => ['ArrayAccess<int, string>', 'object', 'iterable<int, string>'],
'iterableAndNotObject' => ['array<int, string>', '!object', 'iterable<int, string>'],
];
}