Certainly a variable passed to a function shouldn't be changed unless the API explicitly declares it as pass by reference, and it should really explain why it's changed and what you should expect back as well, but mPDF isn't particularly well documented. In this case (having read through the relevant mPDF code) it seems like an arbitrary decision by the developers of mPDF, and totally unnecessary.
But thanks for the investigative work