Laravel 9.28, weekly updates, and 🔥 tip

Laravel 9.28

Couple fixes and several new features this week bumping us to Laravel 9.28. Here are the highlights:

  • Add view data assertions to TestView in #43923
  • Allow invokable rules to specify custom messsages in #43925
  • Add getIntendedUrl() to Redirector in #43938
  • Fix support objects like GMP for custom Model casts in #43959
  • Fix 404 message on denyAsNotFound in #43901
  • Add Eloquent mode to prevent silently discarding fills in #43893
  • Add assertOk() to PendingCommand in #43968
  • Make Application macroable in #43966
  • Add Signal Traps in #43933
  • Allow validator messages to use nested arrays in #43981
  • Support enumerables in Stringable in #44012

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 continued to make tweaks to Shift based on the recent Human Shifts I completed. I also had two more come in which I worked to complete before the long weekend.

In between, I launched an initial release of the curl converter. I had worked on this in my recent live streams. The package provides a shift:curl command which acts as a wrapper for curl. In doing so, it parses the options and arguments and outputs them as a Laravel Http request.

In the coming weeks, I'll create page for this similar to caniupgradelaravel.com to provide a simple web UI so you don't have to install it yourself.

I'm on vacation this week. So short of answering support emails, I'm trying to stay away from the computer and enjoy or last family vacation as a threesome before we become a foursome.

🔥 Tip

The new TestView assertions reminded me of a tiny papercut I experience sometimes when testing view data - I can't explicitly assert view data is null.

This is because null is the default value for assertViewHas. When the value is null, it doesn't test the view data value - only that the key exists.

Unfortunately, there isn't an obvious way to check if a value is passed in or the default is used. This got me thinking about alternatives. You could inspect func_get_args() to determine the arguments passed. It works for named arguments too.

Something else I have seen in other languages is the use of a constant. For example, Objective-C uses a NOT_FOUND constant for some of its string search methods. Laravel could introduce a similar constant, such as LARAVEL_UNDEFINED. This could be used as a default value to differentiate between an undefined argument and a defined argument (even if null).