Archive
refactoring
-
The pipe operator, five months in
PHP 8.5 shipped the pipe operator in November. After five months of using it on real import code, here is the chain it improved, the two steps it made worse, and the rule I settled on.
-
Property hooks, and the three places they earn their keep
PHP 8.4 shipped in November. Three weeks of converting getter and setter pairs to property hooks got me to nine, and Doctrine ORM throws if you put one on an entity. Notes on where the feature actually pays.
-
Enums replaced forty class constants
PHP 8.1 shipped on 25 November. A status class holding 41 constants, a static validator and a switch with a throwing default became one backed enum, and Doctrine still needed thirty lines of custom type to store it.
-
The tests we stopped writing
I deleted 212 tests from a 912-test suite and the build halved. Notes on which tests earn their place: getter assertions and mock transcripts went, money arithmetic and timezone boundaries stayed.