Laravel 8.48, weekly updates, and π₯ tip
Laravel 8.48
More new features in Laravel 8 this week, bringing us to 8.48. Here are the highlights:
- Add a
queue:prune-failed
command in #37696 - Ability to build "on-demand" filesystem disks in #37720
- Allow customising the
event.stub
file in #37761 - Add
sliding
collection method in #37751 - Make
Illuminate\Http\Client\Request
macroable in #37744 - Add GIF, WEBP, WBMP, BMP support to
FileFactory::image()
in #37743 - Dispatch "connection failed" event in HTTP client in #37740
You may review the full branch diff on GitHub for a complete list of changes.
This minor version bump and update is automated for subscribers to a Shifty Plan. If you don't have one of those, be sure to bump your constraint and run composer update
to get the latest features.
Weekly Journal
I spent last Wednesday and Thursday working on the Human Shifts which came in last week. There were actually a few more which came in over the weekend. So I've been working on those with the first part of this week.
I ended last week trying to finish the new Shift Workbench desktop application. I hoped to release a public alpha last week. However, I ran into an incredible amount of pain attempting to publish the "production" application.
Apple specifically has many code signing and notarization requirements to avoid the various security warnings which prevent you from opening the application.
In addition, there were some platform specific bugs for Windows. I haven't use Windows in over a decade. So I got some help from Joel Claremont to test on one of his Windows boxes. Most of the issues we found have been resolved.
The final thing to do is add a few more tasks to the Workbench to ensure we have "over 40 tasks" as advertised. ππ»
One of these tasks is to remove the native Laravel docblocks included in generated code (e.g. artisan make:controller
). This is really to scratch my own itch as I find myself removing these from my old projects.
I had the opportunity to live stream today to quickly demo the Workbench, but also to build this specific task.
My goal this week will be to finish these tasks and ensure we actually launch the alpha release of the Workbench desktop app early next week.
π₯ Tip
I stumbled upon something last week which relates to Symmetry - one of the practices from BaseCode.
In this case, code for multiple, related conditional checks. I'm sure there's a real name for this, but I am calling it waterfall conditionals.
Let me explain with some code:
1public function convertMethod($name, array $parameters) 2{ 3 $update_signature = false; 4 5 // ... 6 7 if (isset($parameters['request'])) { 8 $request = $parameters['request']; 9 }10 11 // ...12 13 if (isset($request)) {14 $update_signature = true;15 }16 17 // ...18 19 if ($update_signature && count($parameters) > 1) {20 // ...21 }22 23 // ...24}
Notice each of the conditionals check a different variable. But really they are all based on the original variable. Each assignment just spills over into the next.
It would be much cleaner to remain consistent. Especially for longer blocks of code, more variables, or multiple code paths.
Being consistent with the conditional expression allows the reader to simply keep track of the single, original variable value, rather than tracking all the variables and remembering ultimately they have the same value.
So rewriting the code above to avoid these waterfall conditionals, we would have:
1public function convertMethod($name, array $parameters) 2{ 3 $update_signature = false; 4 5 // ... 6 7 if (isset($parameters['request'])) { 8 $request = $parameters['request']; 9 }10 11 // ...12 13 if (isset($parameters['request'])) {14 $update_signature = true;15 }16 17 // ...18 19 if (isset($parameters['request']) && count($parameters) > 1) {20 // ...21 }22 23 // ...24}
Remember, refactoring is an iterative process. Now that we unified these conditionals, we could take another pass to remove any unnecessary variables (i.e. $update_signature
). Then another pass for early returns. Then anotherβ¦ π₯