Here's a random example:
includes/Output/IframeSandbox.php:240 SecurityCheck-DoubleEscaped Calling method \MediaWiki\Html\Html::element() in \MediaWiki\Output\IframeSandbox::getHtml that outputs using tainted argument #2. (Caused by: includes/Html/Html.php +264) (Caused by: includes/Output/OutputPage.php +2988; includes/Output/OutputPage.php +2974; includes/Output/OutputPage.php +2973)
I can't for the life of me tell what Phan thinks is being double-escaped here. The code snippet is
public function getHtml(): string { return Html::element( 'iframe', [ // bunch of attributes ] ); }
Is "argument #2" 1-based or 0-based? Is it even claiming that the double-escaping happens in argument #2, or is that only mentioned in passing? Does "outputs using tainted argument" refer to Html::element or IframeSandbox::getHtml? (I guess the former because the other doesn't have arguments, but the phrasing is ambiguous.) What are the two "Caused by" remarks trying to say?
Now imagine a new developer (who is unfamiliar with Phan and with MediaWiki) having to interpret this error message.
Some ideas of how it could be improved:
- Say what's going on, do not rely on the error code. An error message can't be too verbose of course, but it can include a short URL to a wiki page which explains what this type of error is about.
- Use something more understandable instead of "tainted". (What does it even mean in this context? That it's unsafe input? That it's already escaped?)
- Be clear about 0-based vs. 1-based indexes.
- If the parent method (IframeSandbox::getHtml in this case) is only mentioned to orient the reader to where this is happening , and isn't related to the actual problem, move it to the error prefix (after the filename / line number).
- Instead of "Caused by", say something like "Call stack for method1", "Call stack for method 2". Also if the call stack can include method names, that would make it more convenient to follow.

