refactoring

  • 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…

  • webpack resolve.alias removes the ../../..

    A deep component importing a helper writes ../../../lib/money, and the path breaks the moment the file moves — which makes reorganising a tree a mechanical exercise in fixing…

  • Extracting a service without a rewrite

    The reporting code had one caller and a six-hour test run. Finding the seam, dealing with the shared schema honestly, and routing traffic gradually rather than switching.

  • Collections: pipe and tap keep a chain readable

    A collection chain reads well until it needs one step that is not a collection method — a log line, a total computed from the whole set —…