refactoring

  • app/Models is optional and worth doing anyway

    8.0 puts models in app/Models by default, and an existing project can move them or not — but the reason to move is not the convention. Forty-one files…

  • PHPUnit 9 and the assertions that finally went

    What 8 deprecated, 9 removes, and the deadline was a year. Rector does the renames; the one it cannot decide is the one that changed behaviour.

  • The PHPStan baseline is a debt register

    A generated file recording every existing error is the thing that makes static analysis adoptable on a codebase that has never had any. Reading it once by directory…

  • Blade components and the partial that had eleven parameters

    An @include with eleven variables and no way to know which are required. A partial is a file rather than a contract, and 7.0 makes the constructor the…

  • as const, and the literal type it preserves

    An object literal widens to its general types, so a configuration object loses exactly the information that would have made it useful. The last two lines are the…

  • Arrow functions capture by value, and only one expression

    A closure needing three variables from the enclosing scope required a use clause listing all three, which is why a one-line callback was four lines. The capture is…

  • __toString cannot throw before 7.4, and then it can

    Throwing from __toString was a fatal error, which meant a value object that could not render itself had to return a placeholder string and hope somebody noticed. 7.4…

  • Typed properties and the constructor that got shorter

    7.4 landed on 28 November and the docblock is no longer the only type. Uninitialised is a new state, and arrow functions remove the use() clause.

  • The PHPStan baseline is a debt register, not configuration

    0.12 shipped in December with a baseline generator, and it is the feature that makes static analysis adoptable on a codebase that has never had any. The file…

  • The null coalescing assignment operator

    Setting a default only when a key is missing was $a[‘k’] = $a[‘k’] ?? $v;, which evaluates the subscript twice and reads as a statement about itself. The…