-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
Description
Bug report
PHPStan is not determining the data type of resultant array when merging array with + operator, when there are values of multiple types.
Code snippet that reproduces the problem
<?php
class Test
{
/**
* @phpstan-var array{
* prop1?: int, prop2?: bool, prop3?: float,
* prop4?: string, prop5?: string, prop6?: string,
* prop7?: string
* }
*/
protected array $updateData = [];
/**
* @phpstan-param array{
* prop1?: int, prop2?: bool, prop3?: float,
* prop4?: string, prop5?: string, prop6?: string,
* prop7?: string
* } $data
*/
public function update(array $data): void
{
$this->updateData = $data + $this->updateData;
}
}
Expected output
Does Not Work
https://phpstan.org/r/0117678d-c523-442a-8975-7ad2d03fe92c (7+ optional keys)
Works
- https://phpstan.org/r/f3e2865a-cf82-4648-ada2-615e42f8513c (<7 optional keys)
- https://phpstan.org/r/17784fe4-e75c-4629-8f98-cc5a854e82e8 (7+ optional keys of same data type)
Metadata
Metadata
Assignees
Labels
No labels