Replies: 5 comments 28 replies
-
Never:) |
Beta Was this translation helpful? Give feedback.
-
The reason it Returns Eloquent builder instead of int: #56664 |
Beta Was this translation helpful? Give feedback.
-
@mikield we started applying PSR12 but we did not touch the return types or the parameters types. |
Beta Was this translation helpful? Give feedback.
-
@mikield We saw some attempts on putting return types that generated bugs and were either patched or reverted in version 12. So the community is trying to improve the framework but the legacy is a big stopper for that. |
Beta Was this translation helpful? Give feedback.
-
As is very common in the real world (rather than theory) there is a balance to be had here. In general terms, introducing strict types are going to create (at least potentially) breaking changes - and there are three separate situations to consider:
So you might introduce these at separate times and in separate ways. Breaking changes are painful - but sometimes the pain is justified in order to provide a future path. Compare PHP4 with PHP8 - and think about how many breaking changes were successfully introduced to get from one to the other - and they were done because they were necessary for the long-term success of PHP. Breaking changes necessary for the long-term success of Laravel are equally justified IMO, but of course which changes are "necessary" is going to be subjective. There are many many ways to mitigate / reduce the pain:
So, for example, in Laravel 13 you could introduce static-analysis and/or or run-time and/or automated test code to test parameter types and warn users when their code will create a breaking change in L14, and you could provide a Rector ruleset and an artisan command to refactor such code. And of course, some parts of Laravel are used in a greater number of different ways than others, so introducing strict typing in lower levels and functions which are normally internal only will create less pain than for areas which are used widely and in many different ways. And finally, new calls are introduced in many releases, and although these are a very small proportion of the overall code base, they could (and perhaps should) be introduced with strict typing wherever possible. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
It's 2024, and PHP 8.4 has been released.
Strong typed codebases have been proven stability over non strong typed code.
I am asking myself, when we can see such big tool as Laravel that's used by billions of web apps to be strong typed?!
Do Laravel team has some plans on it?
If yes - I would like to contribute :)
Beta Was this translation helpful? Give feedback.
All reactions