Uncategorized

  • expectException replaced the annotation

    The @expectedException annotation and setExpectedException() are both deprecated in favour of methods, which is more than a rename — the annotation asserted only that the exception was thrown…

  • Uniform variable syntax changed what $$a means

    PHP 7 made variable-variable expressions evaluate consistently left to right. That is an improvement and it silently changed the meaning of expressions that had been working for a…

  • The container binds interfaces, not only concrete classes

    The container resolves concrete classes automatically, which is convenient enough that most code type-hints the concrete class and the abstraction never happens. Contextual binding is the part worth…

  • wc_get_orders is the query you should be using

    Orders are posts, so WP_Query works and every example on the internet uses it — with a post_type of shop_order, a meta query for the customer, and a…

  • Null coalescing chains, and where null still gets through

    ?? chains left to right and returns the first operand that is not null, which reads like a safe navigation operator and is not one. It only guards…

  • The outbox pattern for a write and a message

    Saving an order and publishing an event are two systems, and there is no transaction across them. Whichever order they happen in, a failure between them leaves the…

  • Group use declarations shorten the import block

    A file importing six classes from the same namespace repeats the namespace six times, which is noise that grows with the depth of the tree. It is purely…

  • One large autoloaded option is on every single request

    The failure mode is not a slow query. It is one option holding a megabyte of serialised data, fetched and unserialised on every request, quietly adding both to…

  • The N+1 queries you did not write

    1,400 queries on a page showing 40 rows. Eager loading, the difference between with() and load(), and the accessor that no eager load can fix.

  • rsync over one persistent SSH connection

    A deploy that runs rsync three times and then a handful of remote commands opens a new SSH connection each time, and each one pays the full handshake…