larastan icon indicating copy to clipboard operation
larastan copied to clipboard

[3.x] fix: collection template types being overwritten

Open calebdw opened this issue 9 months ago • 4 comments

Hello!

This was merged in #2193 and then reverted so reopening.

This closes #2044 by preventing the collection template types from being overwritten.

This has been released on my fork if anyone would like to take advantage of this immediately.

Thanks!

calebdw avatar Apr 03 '25 20:04 calebdw

@calebdw how confident are you about this PR? And that i won't break existing larastan apps?

nunomaduro avatar Apr 04 '25 09:04 nunomaduro

@nunomaduro,

I'm very confident in this PR, as you can see from #2044 PHPStan handles this properly and this is a bug in Larastan.

This is also needed to propagate the pivot property from the BelongsToMany relation into the Collection generics (which is why the tests failed because I forgot to update this PR after #2231 was merged)

That said, sure some users might experience some warnings and need to go update the types, but this is in line with the PHPStan BC promise about PHPStan getting smarter when bugs are fixed causing the output to change

calebdw avatar Apr 04 '25 10:04 calebdw

@nunomaduro is there any chance we could get this merged, there are features we can't use in Laravel (accessing the pivot) without this fix.

AJenbo avatar Jun 05 '25 12:06 AJenbo

Wondering when this will get merged...

CoolDude53 avatar Nov 12 '25 20:11 CoolDude53