diff --git a/src/Psalm/Internal/PhpVisitor/AssignmentMapVisitor.php b/src/Psalm/Internal/PhpVisitor/AssignmentMapVisitor.php index d9117e606..a1221bdbd 100644 --- a/src/Psalm/Internal/PhpVisitor/AssignmentMapVisitor.php +++ b/src/Psalm/Internal/PhpVisitor/AssignmentMapVisitor.php @@ -6,6 +6,11 @@ use Psalm\Internal\Analyzer\Statements\Expression\ExpressionIdentifier; /** * @internal + * + * This produces a graph of probably assignments inside a loop + * + * With this map we can calculate how many times the loop analysis must + * be run before all variables have the correct types */ class AssignmentMapVisitor extends PhpParser\NodeVisitorAbstract { diff --git a/src/Psalm/Type/Atomic/TArray.php b/src/Psalm/Type/Atomic/TArray.php index 948fb532e..f97e1471d 100644 --- a/src/Psalm/Type/Atomic/TArray.php +++ b/src/Psalm/Type/Atomic/TArray.php @@ -83,6 +83,8 @@ class TArray extends \Psalm\Type\Atomic public function getAssertionString(): string { - return $this->getKey(); + return 'array<' + . $this->type_params[0]->getAssertionString() . ', ' . $this->type_params[1]->getAssertionString() + . '>' ; } } diff --git a/src/Psalm/Type/Atomic/TList.php b/src/Psalm/Type/Atomic/TList.php index 3c382600f..a6480d30c 100644 --- a/src/Psalm/Type/Atomic/TList.php +++ b/src/Psalm/Type/Atomic/TList.php @@ -192,7 +192,7 @@ class TList extends \Psalm\Type\Atomic public function getAssertionString(): string { - return 'list'; + return 'list<' . $this->type_param->getAssertionString() . '>'; } public function getChildNodes() : array diff --git a/tests/TypeReconciliation/ValueTest.php b/tests/TypeReconciliation/ValueTest.php index bab7052eb..7f7268a8b 100644 --- a/tests/TypeReconciliation/ValueTest.php +++ b/tests/TypeReconciliation/ValueTest.php @@ -836,6 +836,24 @@ class ValueTest extends \Psalm\Tests\TestCase if (!in_array(A::ACTION_ONE, $case_actions, true)) {} }' ], + 'checkIdenticalArray' => [ + ' \is_string($value)); + + if ($array === $filtered) { + foreach ($array as $obj) { + echo strlen($obj); + } + } + }', + [], + [], + '7.4' + ], ]; }