Laravel 8.79, weekly updates, and 🔥 tip

Laravel 8.79

Several new methods as well as some important fixes in this week's release of Laravel 8.79.

Here are the highlights:

  • Fix digits_between with fractions in #40278
  • Fix Doctrine type mappings creating too many connections in #40303
  • Add pipeThrough collection method in #40253
  • Add onLastPage to the Paginator in #40265
  • Allow method typed variadics dependencies in #40255
  • Implement full-text search for MySQL & PostgreSQL in #40129
  • Add whenContains and whenContainsAll to Stringable in #40285
  • Support "action_level" log configuration in #40305
  • Automatically add description when scheduling a command in #40286
  • Add method to MigrationsStarted/MigrationEnded events in #40334

You may review the full branch diff on GitHub for a complete list of changes.

This 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 had a bit of a head cold until Sunday, so I didn't get much done last week. I patched some small Shift issues which were reported and did a bit of work for some on-going Human Shifts.

Yesterday I broke ground on the Laravel 9.x Shift. While the Laravel 9 release is still a bit fluid, I do expect it later this month or early February. I like to do a pre-release of the Shift about a week ahead of time. So I want to have that ready soon.

My main focus this week will be building all the tedious automation like config changes, updates to core files, and adopting the latest conventions. I also have a few pairing sessions from those on-going Human Shifts.

In reviewing the changes for Laravel 9, I found some opportunities for consistency. I plan to live stream Thursday to create some last minute PRs. There are also a few tiny features I hope to see within the framework.

🔥 Tip

This tip goes back to things I talk about in BaseCode - nested code and raw booleans.

I came across this little loop that helps me determine an array within a string.

while ($count > 0 && ++$index < $length) {
if ($snippet[$index] === '[') {
++$count;
} elseif ($snippet[$index] === ']') {
--$count;
}
}

This code is fine. It works. But, to the point of BaseCode, it's not very readable. The indentation levels are jarring. The code appears similar in structure, but has important differences.

This specific code provides a rare opportunity to actually condense it to one liners and improve the readability.

while ($count > 0 && ++$index < $length) {
$count += intval($snippet[$index] === '[');
$count -= intval($snippet[$index] === ']');
}

Even though the code is more dense, it better communicates the intention - tracking count. With the assignment statements being uniform it's easy to scan right and glean more information about why the count is changed.

Buried within this refactor is an alternative way to leverage boolean values. In this case, $count is only changed when the condition is true, yielding an integer value of 1. 🔥