php

  • Composer 2.2 and the allow-plugins prompt

    2.2 in December stops running Composer plugins that have not been explicitly permitted, and a non-interactive install refuses rather than prompting. A Composer plugin runs arbitrary code during…

  • Backed enums, and the column type that finally matches

    A status column had held strings for six years, with no constraint anywhere and three spellings of shipped in production. The backing type must be int or string…

  • array_is_list, and twenty years of guessing

    Deciding whether an array was a list or a map had been done with array_keys($a) === range(0, count($a) – 1), which allocates two arrays to answer a question…

  • Methods on an enum replace a match in six places

    The same match over order status appeared in a controller, two Blade templates, a mailer and an exporter, and adding a case updated four of the five. Moving…

  • A readonly array is not deeply immutable

    readonly prevents reassignment of the property and says nothing about what the property points at, which is obvious for objects and surprising for arrays. The array case works…

  • final on a class constant, which was previously impossible

    A class constant could always be overridden by a subclass, silently, and there was no way to say it should not be. This matters most for a constant…

  • An enum can implement an interface but cannot extend

    Enums are final, cannot extend anything and cannot be extended, which removes a set of designs that class constants had allowed. Implementing an interface is what makes an…

  • readonly locks on first write, not at construction

    A readonly property is not initialised-at-declaration; it is write-once from inside the declaring class, and the difference decides what a wither method can do. The property has no…

  • never is not void, and the analyser knows

    void means the function returns nothing and never means it does not return, and the second is information a static analyser can act on. The practical value is…

  • Enums, and the string column that was pretending

    8.1 on 25 November, and the feature PHP had been simulating with class constants for a decade. A status column holding three spellings of the same thing.