php

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

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

  • Content filters run in an order plugins fight over

    the_content is a queue every plugin joins, and priority decides the outcome. A shortcode that renders as text, a paragraph tag wrapped around a block element, and an…

  • Mix is webpack with the config already written

    Elixir wrapped gulp, which wrapped everything else. Mix wraps webpack directly, which removes a layer and — more usefully — leaves the underlying configuration reachable when the abstraction…

  • Multi-catch for two exceptions with one handler

    Handling two unrelated exceptions the same way meant either duplicating the catch block or introducing a common interface for the sole purpose of catching them together. The variable…

  • An array shape annotation the analyser understands

    A function returning an associative array returns array as far as any type system is concerned, so nothing can check the keys. A docblock with a shape gives…

  • 4.7 added a settings API for the REST API

    Options registered with register_setting() can now appear on /wp/v2/settings, which turns a plugin’s configuration into something an admin interface elsewhere can read and write without a bespoke endpoint.…

  • wp_json_encode over json_encode, for the charset

    json_encode() returns false on invalid UTF-8 and gives no indication why, which on a site with content pasted from Word is a JSON response that is silently empty.…