php

  • Allocation in a loop, and the profiler that shows it

    A CPU profile shows where time is spent and not why, and a loop constructing an object per iteration frequently spends its time in the allocator rather than…

  • SplFixedArray, and the million-element array that halves

    A PHP array is a hash table even when the keys are 0 to n, and for a large numerically indexed list that overhead is most of the…

  • Preloading is a restart, not a cache warm

    Preloaded files are compiled once at server start and are fixed until php-fpm restarts, which makes a deploy a restart rather than a reload. A restart drops in-flight…

  • Http::fake, and a test that never touches the network

    Testing code that makes an HTTP call meant injecting a mock client, which means the code had to accept one — so the test shaped the design rather…

  • Enum-like class constants, and the three things they cannot do

    Enums are 8.1, so a set of allowed values in 2020 is class constants with a validating constructor — and the gaps are worth naming rather than discovering.…

  • Profiling before you optimise

    Two days spent optimising a function that was 3% of the request. The profiler said so in ninety seconds, and nobody had run it.

  • The migration that squashed two hundred files

    A test suite spending ninety seconds replaying six years of schema history. Squashing is a good idea with two failure modes worth knowing first.

  • Covariant returns unblock a factory interface

    A child class overriding a method had to declare exactly the parent’s return type, so an abstract repository could not promise that each implementation returns its own entity.…

  • Composer 2 changed the lock file, and a team upgrades together

    October brought a rewritten solver and parallel downloads, and the lock file format changed in a way that produces a confusing diff when two people are on different…

  • Composer 2 is not a minor upgrade

    A dependency resolver rewritten and parallel downloads, so install went from ninety seconds to eleven. And a plugin API that broke three packages.