Replies: 7 comments 7 replies
-
This is a control that the developer should have, not the framework. If Laravel sets out to solve all the thousands of problems that exist, it will grow to such an extent that the team will likely spin out of control. When I started using Laravel I thought: "Why doesn't Laravel have helpers to solve math problems, equations, operations and other things?" Today I think: "Did I really think that? LOL" What kind of math problem can't we solve using normal expressions without resorting to tools? |
Beta Was this translation helpful? Give feedback.
-
Having thousands of add-on packages to choose from is a headache for sure. Before you decide to go with a package you need to be sure that it will be supported as Laravel goes from version to version, and that bugs you find will be fixed. And indeed, have some idea that the functionality will meet your needs. And IME sometimes these judgements can be very difficult making package selection a major headache. But however bad this is, IMO having everything included in Laravel instead would be far, far worse. |
Beta Was this translation helpful? Give feedback.
-
Guys, I'm not asking for oranges here. I'm asking why has the core team not adopted strict mode for internal use and encourage users (developers) to adopt it as well. That's all. |
Beta Was this translation helpful? Give feedback.
-
Now that the summer vacations are over, is there anyone competent to answer my question or engage in discussion? |
Beta Was this translation helpful? Give feedback.
-
Since most of the framework isn't using type declarations but docblocks, it would be pretty useless. That, and I believe Taylor isn't a big fan of strong typing.... they say he said it in one of his Laravel Snippet podcast episodes, but I can't find that episode. |
Beta Was this translation helpful? Give feedback.
-
Let me put it this way: Would Laravel get stricter it become Nette. Laravel is in a early stage of strict typing. I think it is because Laravel tries to have as low an input level and to be as friendly as possible. And loose type are better for beginners for sure. And it is useless and impossible to strict permissiveness. Personally, I count Laravel as RAD for web dev, but they going away from it in recent releases. All the code is about duck-typing. All this All this stuff is great for prototyping and rapid development. PHP had loose type at start, but it got stricter in age. JavaScript had no strict types, but TypeScript appeared over time. As far as you need to do something quickly - loose type are great. As far as you work with a huge aged project - strict types are great. PHPUnit, Psalm, Phpstan, PHP_CodeSniffer and etc are good maturity indicators. They show, when you hit drawbacks of loose typing (like spending a day or week trying to track some nasty bag in other developers or your own code) and start to rigid your application. And Laravel is not only about starterkit. It is good for matured projects as well. You just need to use good practices by yourself. Fell free to publish default templates and override them as you wish. Split your code, instead of placing all in the controller. Introduce you interfaces. Write sniffer snippets. Write portable code. Tests are out of box. These abilities are still up to you. Sometimes, I lack strong typing in Laravel. But Laravel provides a good compromise. And, to be honest, most cases in web dev are quick development without supporting, and that way Laravel is winning on it's duck-typing. P.S.: I feel more inconvenience from the lack of generics in PHP in general. |
Beta Was this translation helpful? Give feedback.
-
What's the current feeling in the Laravel Core team on introducing strict types into the Laravel codebase? I personally find it a more reliable way of developing with PHP. The contribution docs don't discourage using types. I appreciate adding types across the entire codebase would be a big job, but this could be used progressively for new code. Since Laravel only supports PHP 8.2+ now and is clearly also used for larger web applications, it feels more realistic. Another useful option (maybe an easier starting point) would be to add the ability for the make console command to generate code with |
Beta Was this translation helpful? Give feedback.
-
Hello,
I recently started with Laravel again after 6 years and can't help but wonder why
declare(strict_types=1);
is not used throughout the framework and is not default in the artisan stubs...I've been using and enforcing strict mode in all of my apps for years and happen to find this a downgrade.
Admittedly, I've been working with custom stacks, mostly, and I know Symfony is not using strict mode either. But I also know that Nette does.
I've been criticesed once for not using strict mode back when PHP 7 was fresh, I gradually started using it and never looked back. Now I'm dumbfounded that the prevalent frameworks have not caught up and started using strict mode in 8 years since introduction. Why?
Beta Was this translation helpful? Give feedback.
All reactions