Object.assign() copies enumerable own properties from one object onto another, which reads like a deep clone and is not one. Nested objects are copied by reference, so mutating…
A function returning a generator cannot be passed to anything expecting an array — count(), array_map(), json_encode() all fail or produce nonsense. iterator_to_array() is the escape hatch, and…
The principle is abstract until you write the test. If exercising one method means stubbing five others that the code under test never calls, the interface is doing…
Before 5.6, a constant or a default parameter value had to be a literal. Anything computed — even multiplying two numbers you had already defined — was a…
Collecting a variable number of arguments used to mean func_get_args(), which hides the signature from anyone reading the function and from every IDE. 5.6 gives the language a…
Two hundred and forty require_once calls where load order was load-bearing, moved onto an autoloader one namespace at a time without a big-bang rewrite.
Floating point cannot represent 0.1 exactly, so money arithmetic accumulates error that shows up as a total that is one cent off. The usual response is to round…
DateTime::modify() mutates the object and returns it. Because it returns something, it reads like a pure function, so it gets assigned to a new variable — and then…