Apply some minor PHP code modernizations

* Make use of the ?? syntax.
* Use an upstream function.
* Fix an incomplete type hint.

Change-Id: I7b1916418f4b1e65cc8396cfd646224f55c137a4
This commit is contained in:
Thiemo Kreuz 2022-09-28 16:34:34 +02:00 committed by Kunal Mehta
parent 408f4d0bc6
commit 912324993f
4 changed files with 5 additions and 12 deletions

View file

@ -13,6 +13,7 @@ use MWException;
use ObjectCache;
use Parser;
use PPFrame;
use TextContent;
use Title;
use Wikimedia\ScopedCallback;
@ -927,7 +928,7 @@ abstract class LuaEngine extends ScribuntoEngineBase {
}
if ( is_scalar( $input ) ) {
$input = str_replace( [ "\r\n", "\r" ], "\n", $input );
$input = TextContent::normalizeLineEndings( $input );
$dom = $this->parser->getPreprocessor()->preprocessToObj(
$input, $frame->depth ? Parser::PTD_FOR_INCLUSION : 0 );
} else {

View file

@ -584,11 +584,7 @@ class UstringLibrary extends LibraryBase {
if ( $i >= $len ) {
break;
}
if ( isset( $brcharsets[$pat[$i]] ) ) {
$re .= $brcharsets[$pat[$i]];
} else {
$re .= preg_quote( $pat[$i], '/' );
}
$re .= $brcharsets[$pat[$i]] ?? preg_quote( $pat[$i], '/' );
} elseif ( $i + 2 < $len &&
$pat[$i + 1] === '-' && $pat[$i + 2] !== ']' && $pat[$i + 2] !== '%'
) {

View file

@ -412,7 +412,7 @@ class Hooks {
/**
* @param Article $article
* @param bool &$outputDone
* @param bool|ParserOutput|null &$outputDone
* @param bool &$pcache
* @return bool
*/

View file

@ -31,11 +31,7 @@ class ScribuntoException extends MWException {
* @param array $params
*/
public function __construct( $messageName, $params = [] ) {
if ( isset( $params['args'] ) ) {
$this->messageArgs = $params['args'];
} else {
$this->messageArgs = [];
}
$this->messageArgs = $params['args'] ?? [];
if ( isset( $params['module'] ) && isset( $params['line'] ) ) {
$codeLocation = false;
if ( isset( $params['title'] ) ) {