No release, weekly updates, and weekly tip
No release
No release this week. There were a few minor releases since last week, so I'm assuming those took its place.
Weekly Journal
Last week I finished up a Human Shift that had been in review. I took it the rest of the way from Laravel 9 to Laravel 12.
I also completed the conversion of the order flow on laravelshift.com to Livewire. I actually launched this at the beginning of the month. However, I kind of forced it out on a Friday, before the holiday weekend. When I didn't see any orders come in, I reverted. While it was functional, there were some minor UI issues. So more of a better safe than sorry.
Anyway, in between I was helping with the Pest Browser Plugin. There were a lot of good PRs that hadn't been merged since the release of Pest v4. Some I would consider critical. Especially coming from Dusk. So I, selfishly, tried to help Nuno get those reviewed, merged, and tagged.
This week I'm giving some love to WP Static. It's had a few paying customers. They offered a bit of feedback. So we're implementing that, as well as some tools to ease support.
Weekly Tip
Ok, so my mind was blown in my livestream last week. I've been working with PHP for 25 years. I'm familiar with some of its nuances. But this one had me spinning.
I try not to call things bugs. But I will call this unexpected behavior. PHP calls it trickery.
Anyway, my Laravel Additions FindBy
trait adds a magic method (__callStatic
) to your model classes which allows you to make findBy*
calls (like Rails).
What I discovered was that within an instance method, the following line of code called __call
, instead of __callStatic
.
public function nextShift(){ // ... Product::findBySku($sku);}
This is a static call. So, naturally, I would expect PHP to call a static method. If that method did not exist, I would expect PHP to fallback to the magic method __callStatic
.
But nope, that's not how PHP works. Well, it does if you're in a "static context". So this code within a static
method would behave that way. But this code within an "object context" behaves differently.
In an "object context", this code first tries to call an instance method named findBySku
. Then a static
method findBySku
. Then __call
. Then __callStatic
.
All of this is inferred from just one line of PHP documentation. Hence my "object context". But more importantly, it is indeed how it works. As demonstrated in this 3v4l.
A shoutout to Daniel, Patrick, and Prashank. Their combined feedback helped me piece all this together.