These notices are printed during PHP shutdown procedures, so it may be difficult to actually catch these in all cases.
A new ticket would make sense if someone has the time to write a test specifically for this purpose that works in all cases, but that is beyond the scope of this PR and this already-huge-test