This Week I Learned: 2021-07-11

  1. How to write better regexes in PHP. I’m looking forward to my next opportunity to use regexes in the “real world” so that I can try out some of the suggestions in this great post.
  2. I already knew about the PHPStorm “Run Anything” widget (CTRL + CTRL), but I did not know there was a similar feature for code actions – SHIFT + SHIFT. This is one of several new shortcuts I discovered with this Laraval Daily video and Christoph Rumpel’s great list of PHPStorm Tips & Tricks. I’m so happy because now I can rename variables without using my mouse (a big win when working with legacy code) and also because I now know that PHPStorm has multiple cursors so there’s no reason for anybody to still be using SublimeText.
  3. This quick summary of 5 Doctrine performance pitfalls has given me some food for thought about the balance between overuse of fetch joins and N+1 queries. I had not realised that Doctrine’s internal processing of rows returned via fetch joins had its inefficiencies, and it’s inspired me to revisit one of my projects and see whether two queries might be better than one.
  4. If you attempt to array_unshift() an element onto the start of an array which is indexed by integer-like strings, these indexes will all get reset starting from 1 as if they were integers. This wasn’t what I meant to do anyway, but it always makes my day when I spot a weird PHP quirk in the wild on a debugging safari.
  5. This delightful photo gallery of HTTP status codes illustrated by dogs brings together the two loves of my life. I particularly love the 502, which reminds me of my dog’s tireless efforts at cramming herself through various undersized escape portals after we moved to a new house this year.