What I’ve Learned This Week (2018-11-25)

  1. SilverStripe 4 brings our homegrown PHP framework and CMS into the 21st century, with namespacing and Composer, the inclusion of a few Symfony components, heavy use of ReactJS, and a more modern Bootstrap-powered look for the admin panel. Almost all of my SilverStripe experience has been with 2.4 – this looks a lot nicer to work with! I’ll have to play around with it next time I have a free weekend.
  2. Unit test “coverage” isn’t useful if your code is just executing the code rather than testing it. I’ve never used coverage reports as it’s usually easy to spot the holes with a quick glance at the project – but it’s a useful reminder that just because something appears to be well-tested, it may not actually be.
  3. A little hack in PHP where you can use variable length arguments to mimic a typehinted array argument. It’s not a perfect solution; neither is my current approach (scatter docblocks everywhere and hope that PHPStorm will spit out a warning if I pass the wrong thing).
  4. Symfony is leaving the PHP Framework Interoperability Group. Founder Fabien Potencier explained the reasons via Twitter, complaining that the PSRs have become too opinionated, and described PHP-FIG’s work as designing a “framework by committee”. With Laravel and Symfony both out, this seems like the beginning of a slow painful death for PHP-FIG.
  5. Java 8 has introduced Streams, which makes me very happy because I can bring my functional programming habits from PHP and underscore.js into Java code. Naturally I had to do some Saturday morning hacking to see it in action. Who wants to write a boring for loop when they can:
        MyObject bestMatch = parent.getChildren().stream()
                .filter(o -> isPerfectMatch(o))
                .findFirst()
                .orElse(parent.getChildren().stream()
                    .filter(o -> isGoodEnoughMatch(o))
                    .findFirst()
                    .orElse(null)
                );