refactoring

  • WooCommerce 3.0 turned products into objects

    Every plugin reading _price from post meta is now reading a private field. The mechanical half, the half that is not, and the compatibility layer for code you…

  • Object.entries and Object.values, finally

    Iterating an object has meant Object.keys() and an index lookup, which names the key twice and reads badly next to the array methods it sits beside. Both return…

  • CSS Grid arrived, and the layout hacks can go

    Chrome 57 and Firefox 52 shipped it a fortnight apart in March. Replacing a grid system of nested rows, negative margins and a clearfix with fourteen lines.

  • Negative string offsets read from the end

    Reading the last character of a string has been $s[strlen($s) – 1] for two decades, which computes the length to throw it away and reads badly next to…

  • Static analysis on a codebase that has never had any

    Four thousand errors on the first run is a number nobody can act on. Starting at level 0, ignoring by pattern, and raising the floor one level at…

  • The asset pipeline Laravel 5.4 shipped

    Elixir wrapped gulp, which wrapped everything else. Mix wraps webpack directly — and leaves the configuration reachable when the abstraction runs out.

  • Ignore a PHPStan error by pattern

  • API resources replaced the transformer package

    Shaping a model for JSON has meant a transformer library or toArray() on the model, and the second couples the wire format to the database columns — so…

  • nginx map is a lookup table, not a conditional

    if inside a location is famously unreliable, and most uses of it are really a lookup — this value maps to that value — which map expresses directly…

  • define() takes an array constant now

    const has accepted arrays since 5.6, but define() had not — which mattered because const cannot be used conditionally or inside a function, so anything computed at bootstrap…