PHPStan will infer the result of using the Spread Operator in Array Expressions as non-empty-array but the result can still be an empty array.
/**
* @return list<\stdClass>
*/
function returnMaybeEmptyList(): array
{
return [];
}
PHPStan\dumpType(returnMaybeEmptyList()); // Dumped type: array<int, stdClass>
$options = [
...returnMaybeEmptyList(),
];
PHPStan\dumpType($options); // Dumped type: non-empty-array<int, stdClass>
PHPStan\dumpType($options); // Dumped type: array<int, stdClass>