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:
parent
1966766a79
commit
9539c0f27f
@ -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 {
|
||||
|
@ -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>'],
|
||||
];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user