Skip to content

Commit

Permalink
Add extra array assignment tests
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Dec 5, 2016
1 parent 2376964 commit 9a2edd6
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/ArrayAssignmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,4 +460,37 @@ public function testAdditionDifferentType()
$this->assertEquals('array<int, string|int>', (string) $context->vars_in_scope['$a']);
$this->assertEquals('array<int, string|int>', (string) $context->vars_in_scope['$b']);
}

public function testPreset1DArrayTypeWithVarKeys()
{
$stmts = self::$parser->parse('<?php
/** @var array<string, array<int, string>> */
$a = [];
$foo = "foo";
$a[$foo][] = "bat";
');

$file_checker = new \Psalm\Checker\FileChecker('somefile.php', $stmts);
$context = new Context('somefile.php');
$file_checker->check(true, true, $context);
}

public function testPreset2DArrayTypeWithVarKeys()
{
$stmts = self::$parser->parse('<?php
/** @var array<string, array<string, array<int, string>>> */
$b = [];
$foo = "foo";
$bar = "bar";
$b[$foo][$bar][] = "bat";
');

$file_checker = new \Psalm\Checker\FileChecker('somefile.php', $stmts);
$context = new Context('somefile.php');
$file_checker->check(true, true, $context);
}
}

0 comments on commit 9a2edd6

Please sign in to comment.