Generic inference inconsistent

Bug report

(Probably known or otherwise reported in a way, but found it hard to search for)

After upgrading to 1.12, our custom map function with generic & inferred input/output types breaks... sometimes, seemingly dependent on the complexity of the input parameter:

// Works
$x = map([1,2,3], fn ($value) => ['n' => $value]);
\PHPStan\dumpType($x);

// Works too:
$x = map(range(1,3), fn ($value) => ['n' => $value]);
\PHPStan\dumpType($x);

// Does not work:
$x = map(range(1,100), fn ($value) => ['n' => $value]);
\PHPStan\dumpType($x);

We noticed before that type inference for mapper functions, especially with fat arrow callbacks where you can't re-specify the input/output types specifically is a quite messy, also in 1.11. It would be nice if we could have our own mapper function work as array_map, for which specific support is built into phpstan.

Code snippet that reproduces the problem

https://phpstan.org/r/65d699b3-65df-4d4c-8967-11a9b83b5665 (with some more cases)

Expected output

Should infer the proper return type list<array{n: int<1,100>}>

Did PHPStan help you today? Did it make you happy in any way?

Helps us release confidently, every day :)