Laravel 8.65, weekly updates, and 🔥 tip

Laravel 8.65

Since I missed last week, I'm going to cover the changes in both the 8.64.0 and 8.65.0 release.

Here are the highlights:

  • Add reduceMany to Collection in #39078
  • Add stripTags to Stringable in #39098
  • Add getOutput to Console output in #39099
  • Add lang_path helper function in #39103
  • Add @aware blade directive in #39100
  • Dispatch new JobRetrying event in #39097
  • Add throwIf to Client Response in #39148
  • Add hasAny to Collection in #39155
  • Ability to validate multiple date formats in #39170
  • Add gate policy callback in #39185
  • Allow Remember Me cookie expiration to be overriden in #39186
  • Add --test and --pest options to various make commands in #38997
  • Add assertions for notifications sent on-demand in #39203
  • Ability to retrieve a subset from Request::collect in #39191
  • Add assertRedirectContains in #39233
  • Add headline to Stringable in #39174
  • Log deprecations instead of treating them as exceptions in #39219

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

Last week I was off for my honeymoon which provided some time away from the computer to relax in beautiful Sedona. I also doglegged the trip home by attending LonghornPHP. The conference allowed me to catch up with some devs, including Taylor, as well as give a talk on testing.

Testing seemed to have an increased focus at the conference. Joel Clement also gave a talk on tooling to improve code quality. Of course, the Shift Workbench got an honorable mention alongside other tools like PHP CS Fixer and PHPStan.

This is timely as last week Jess continued working on a new Shift to configure CI build. I hope to launch the MVP tomorrow, which will initially support GitHub via GitHub Actions.

As this receives more usage, I plan to configure CI for Bitbucket and GitLab as well.

As I noted in a Twitter thread, I've been working on making the Shift experience more holistic. While upgrading is the main part, having tests and CI is the other part. The Tests Generator was the first step, the CI Generator is the next. Together these will give you more confidence when merging future Shifts by providing a nice green checkbox.

This week I will focus on launching the CI Generator and complete the remaining Human Shifts from last week.

🔥 Tip

As always, completing the Human Shifts gives me an opportunity to dog food Shift. I noticed something in the Laravel 5.0 Shift where some folders were not renamed according to PSR-4.

Seems like there's been a bug when nested folders were being renamed after the parent folder had already been renamed. Although I had logic in place to track renamed folders, there must have been some edge case.

After review, it dawned on me that if I sorted the folders by depth, I would avoid any scenarios where I renamed the parent folder first.

To do so, I had the opportunity to use PHP usort, as well as the spaceship operator to compare path depths (with a unary negation for descending order). 🔥

usort($lowercase_directories, function ($a, $b) {
return -(substr_count($a, DIRECTORY_SEPARATOR) <=> substr_count($b, DIRECTORY_SEPARATOR));
});