Use
$request->getRawVal( 'key' ) ?? 'default'
instead of
$request->getRawVal( 'key', 'default' )
The ?? is more flexible, avoids a wrong type detection by phan and avoids the evaluation of the default value if not needed.
Demonstration of the expensive evaluation:
function expensive() { for ( $i = 0; $i < 1e8; $i++ ) {} return $i; } $request = new MediaWiki\Request\WebRequest(); $request->setVal( 'foo', 'bar' ); echo $request->getRawVal( 'foo' ) ?? expensive(); echo $request->getRawVal( 'foo', expensive() );