Some constructors return values (e.g. empty strings) if the object can not be initialized properly. This is not possible, they should throw an exception instead. Reference
Type Hinting - a common concept of wordpress core developers for function I/O in the past was: "shit in shit out". Type hints can be used to lightweightly hint the type functions do accept of a parameter. next to no type this can be array or object, read more.
scandir - scandir can be used instead the known opendir() / readdir() operations we currently have in.
foreach - can use references now. that will help to reduce code where in php iteration needed to differ between array or object (post data, comment data and the like). Do not forget to unset iterating value variable in case of reference after the foreach-loop. (#16684)