1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +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]); self::refineArrayKey($clone_type->type_params[0]);
$object_types[] = new TArray($clone_type->type_params); $object_types[] = new Type\Atomic\TGenericObject('ArrayAccess', $clone_type->type_params);
$object_types[] = new TNamedObject('ArrayAccess');
$did_remove_type = true; $did_remove_type = true;
} else { } else {

View File

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