refactoring

  • list() with keys unpacks an associative row

    Destructuring only worked positionally, so a row fetched as an associative array had to be unpacked by hand — three assignments and a typo waiting to happen. A…

  • ignoreErrors is how you adopt this on old code

    Four thousand errors on the first run is a number nobody can act on, and the usual outcome is that the tool is removed. Ignoring the existing ones…

  • Signed numeric strings compare differently now

    PHP 7.1 changed how a string with a leading sign is treated in a numeric context, which is a correctness fix and a behaviour change in code that…

  • Laravel 5.5 and the packages that install themselves

    The first release where installing a package is one command. Auto-discovery removes two config edits per package, and hides the fact that they happened.

  • Parameter type widening in 7.2

    A child class could never remove a parameter type from a method it overrides, even though accepting more than the parent is safe by the same rule that…

  • Blade components before they were components

    @include passes variables and shares the parent scope, which means a partial silently depends on whatever happened to be defined where it was included. @component takes a slot…

  • Read a JSON config file with a fallback in PHP

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

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

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