php

  • Route model binding with a custom key per route

    getRouteKeyName() changes the binding column for a model everywhere, which is wrong when the admin addresses an order by id and the customer addresses it by reference. An…

  • Read a JSON config file with a fallback in PHP

  • PHPStan levels are a ratchet, not a target

    The levels run 0 to 7 and the instinct is to aim for the top, which on an existing codebase produces thousands of errors and no way to…

  • The cron event that schedules itself twice

    wp_schedule_event() does not check whether the hook is already scheduled, so calling it on init — which is where it usually ends up — adds another entry on…

  • The each() deprecation is a whole class of loop

    each() is deprecated in 7.2 and the notice appears once per call, which on a loop means once per iteration and a log file measured in megabytes. The…

  • The 7.2 object type hint, and what it is not

    November’s release adds object as a type, which sounds like it should let a function accept “any class” and be checked. It does exactly that and nothing more.…

  • Multi-stage builds cut the image in half

    17.05 made the two-Dockerfile trick unnecessary. Named stages, what to copy forward, and why the build cache still rewards the order of instructions.

  • iterable accepts an array or a Traversable

    Type-hinting array rejects a generator, and hinting Traversable rejects an array — so a function meant to consume a sequence either had no hint or forced the caller…

  • Package auto-discovery, and how to opt a package out

    5.5 reads a package’s extra.laravel block and registers its providers and aliases automatically, which removes two config edits from every installation and removes them from view as well.…

  • Closure::fromCallable turns a string into a closure

    PHP has several callable syntaxes — a string, an array of object and method, an invokable — and functions accepting callable have to tolerate all of them. Converting…