-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Labels
Milestone
Description
Bug report
Hi,
after upgrading PHPStan from 2.1.29 to 2.1.32, I noticed a change in how list types are displayed.
<?php declare(strict_types = 1);
use function PHPStan\dumpType;
use function PHPStan\Testing\assertType;
class Transaction {
public function __construct(public int $value) {}
public function withValue(int $value): self { return new self($value); }
}
/**
* @return array<string, non-empty-list<Transaction>>
*/
function getPositions(): array
{
return ['AAPL' => [new Transaction(50)], 'TSLA' => [new Transaction(50), new Transaction(100)]];
}
$positions = getPositions();
foreach ($positions as $symbol => &$transactions) {
foreach ($transactions as &$transaction) {
$transaction = $transaction->withValue(60);
}
}
dumpType($positions);Behavior in 2.1.29
The type was displayed as:
array<string, non-empty-list<Transaction>>
Behavior in 2.1.32
After upgrading to 2.1.32, it is displayed as:
array<string, non-empty-array<int<0, max>, Transaction>>
Code snippet that reproduces the problem
https://phpstan.org/r/4b38f403-d1d2-446a-b920-ddb0e45a096f
Expected output
array<string, non-empty-list>
Did PHPStan help you today? Did it make you happy in any way?
No response
Reactions are currently unavailable