Among all extensions known to codesearch, PageForms relies by far the most on global state, in particular the wgOut and wgRequest variables:
https://codesearch.wmcloud.org/things/?q=global%5B%5E%3B%5D%2B%5C%24wg%28Request%7COut%29%5B%2C%3B%5D#Extension:PageForms
Considering current efforts to deprecate the wg variables, these should be removed eventually.
Skimming through the different callsites for a while, I think the best way to deal with this would be to have PFFormPrinter::formHTML accept an IContextSource as an argument, which will usually be available at its callers. As a side-effect, this will get rid of some hacks regarding the request and allow to replace a few calls of RequestContext::getMain()->getUser().
The context (or the associated OutputPage) can then be passed to the various functions called as needed -- most of the other sites using global variables seem to be exclusively called from here. Do you agree?
Of course, this may change quite a few of the method signatures involved, so it would be great to obtain an understanding early whether these can just be changed or whether in some cases, we should be more careful.
In particular, PFFormInput::getHTML and PFFormInput::getHtmlText could be candidates to be assumed stable to overwrite and should be kept compatible for now?