Entering a malformed string (like "pHoRgE rOcKs!!") into the "Raw Diff" field, Arcanist's tryMatchHeader() function is first called in $ok = $this->tryMatchHeader($patterns, $line, $match) with a non-null $line value (the first line entered in the "Raw Diff" field) being passed.
Afterwards, tryMatchHeader() is called for a second time after assigning $line = $this->nextLineThatLooksLikeDiffStart().
This time $line is null and a RuntimeException is thrown, as tryMatchHeader() calls preg_match() which does not accept passing null as the $subject string parameter in PHP 8.1.
Thus add a phutil_nonempty_string() check if the $subject parameter (in this case, $line) is a non-empty string.
Arcanist's tryMatchHeader() function is not called outside of the file in which it is defined.
Thus catch the exception in the second call to tryMatchHeader() and not in the code of the tryMatchHeader() function itself.