Skip to content

Commit

Permalink
Treat array key int literals same way we treat string literals
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Jan 14, 2020
1 parent 887a635 commit c77f2cd
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/ArrayAssignmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,28 @@ public function override(int $offset): void {
}
}',
],
'propertyAssignmentToObjectLikeIntKeys' => [
'<?php
class Bar {
/** @var array{0: string, 1:string} */
private array $baz = ["a", "b"];
public function append(string $str) : void {
$this->baz[rand(0, 1) ? 0 : 1] = $str;
}
}'
],
'propertyAssignmentToObjectLikeStringKeys' => [
'<?php
class Bar {
/** @var array{a: string, b:string} */
private array $baz = ["a" => "c", "b" => "d"];
public function append(string $str) : void {
$this->baz[rand(0, 1) ? "a" : "b"] = $str;
}
}',
],
];
}

Expand Down

0 comments on commit c77f2cd

Please sign in to comment.