refactoring

  • A baseline is what makes static analysis adoptable

    0.12 shipped in December and the ignoreErrors list can be deleted. A generated debt register, a ratchet that only shrinks, and a level to stop at.

  • array_column on an array of objects needs public properties

    array_column has worked on objects since 7.0, and it reads properties rather than calling getters — so it silently returns nothing for a well-encapsulated class. It does respect…

  • unknown is the type any should have been

    any switches the compiler off for that value and everything derived from it. unknown accepts anything and permits nothing until it has been narrowed. JSON.parse returns any, which…

  • TypeScript on a JavaScript codebase, one file at a time

    3.7 shipped optional chaining in November and the objection got smaller. allowJs, checkJs and a per-file opt-in — and strictNullChecks, which is the flag that pays.

  • expectException replaced the annotation, with a deadline

    The @expectedException annotation asserts the exception happened somewhere in the method, which passes when it is thrown by the arrangement rather than by the thing under test. Placing…

  • is_countable before you call count

    Since 7.2 count() warns on anything that is not an array or Countable, and the guard everybody wrote by hand is now in the standard library. A generator…

  • ArrayAccess on a value object is usually a mistake

    Implementing ArrayAccess so a class can be used with square brackets makes it look like an array to every reader and to no static analyser. The interface predates…

  • intdiv exists so you stop casting a float division

    Integer division was (int) ($a / $b), which converts to float first and back — so for large values the result is wrong in a way that only…

  • Laravel 6 adopted semver, and the upgrade got boring

    5.8 to 6.0 is a smaller change than 5.7 to 5.8 was, which is the point. What semver means for a framework, and what LTS actually promises.

  • The string and array helpers moved out to a package

    6.0’s only real breaking change is that the global str_ and array_ functions are gone, and the replacement is one Composer package away. Installing the compatibility package is…