Skip to content

Commit eb44d7d

Browse files
committed
Don't pass null to parameters where it is deprecated to do so.
1 parent 39ebc04 commit eb44d7d

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

TPCParse.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static function parseVer( $str ) {
6969
*/
7070
public static function parseCSV( &$param ) {
7171
$REGEX_CSV = '/\s*,\s*/';
72-
$ret = preg_split( $REGEX_CSV, $param, null, PREG_SPLIT_NO_EMPTY );
72+
$ret = preg_split( $REGEX_CSV, $param, -1, PREG_SPLIT_NO_EMPTY );
7373
if ( count( $ret ) == 1 ) {
7474
return $ret[0];
7575
} else {
@@ -80,27 +80,27 @@ public static function parseCSV( &$param ) {
8080
/**
8181
* Parses a wikitext string into an array of lines.
8282
*
83-
* @param string &$param The string to split.
83+
* @param ?string &$param The string to split.
8484
* @param bool $escape_percents Keep literal percent signs for a printf format string.
8585
* @return array Array of lines.
8686
*/
8787
public static function parseLines( &$param, $escape_percents = true ) {
8888
$REGEX_LINE = '#<br\s*/?>|\n#';
8989

9090
// Important! Breaks patch stacking otherwise!
91-
if ( strlen( $param ) == 0 ) {
91+
if ( ( $param === null ) || ( strlen( $param ) == 0 ) ) {
9292
return null;
9393
}
9494
$param = TPCUtil::sanitize( $param, $escape_percents );
9595
$tlnotePos = strpos( $param, json_decode( '"\u0014"' ) );
9696
if( $tlnotePos !== FALSE ) {
9797
$tlnote = substr( $param, $tlnotePos );
9898
$regular = substr( $param, 0, $tlnotePos );
99-
$ret = preg_split( $REGEX_LINE, $regular, null ) ;
99+
$ret = preg_split( $REGEX_LINE, $regular ) ;
100100
$ret[ count($ret) - 1] .= preg_replace("#<br\s*/?>#", "", $tlnote);
101101
return $ret;
102102
}
103-
return preg_split( $REGEX_LINE, $param, null );
103+
return preg_split( $REGEX_LINE, $param );
104104
}
105105

106106
/**

TPCState.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ public function getCurFile() {
6767
/**
6868
* Removes potentially dangerous stuff from a file name.
6969
*
70-
* @param string $fn File name
70+
* @param string File name
7171
* @return string Sanitized file name
7272
*/
73-
public static function sanitizeFileName( $fn ) {
73+
public static function sanitizeFileName( string $fn ): string {
7474
// This _will_ need to be changed once we patch Tasofro games, since they
7575
// tend to use Japanese characters in their file names...
7676
$ret = preg_replace( '/[^a-z0-9\._\- \/]/i', '', $fn );
@@ -87,9 +87,9 @@ public static function sanitizeFileName( $fn ) {
8787
*/
8888
public function getFileName( $game, $build, $file ) {
8989
// Wave the magic wand
90-
$this->curGame = self::sanitizeFileName( $game );
91-
$this->curBuild = self::sanitizeFileName( $build );
92-
$this->curFile = self::sanitizeFileName( $file );
90+
$this->curGame = ( $game ? self::sanitizeFileName( $game ) : null );
91+
$this->curBuild = ( $build ? self::sanitizeFileName( $build ) : null );
92+
$this->curFile = ( $file ? self::sanitizeFileName( $file ) : null );
9393

9494
if ( !$this->curFile ) {
9595
$fn = $this->curGame . '.js';

hooks/TPCFmtMsg.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected static function renderRuby( &$lines ) {
5757

5858
public static function onMsg( &$tpcState, &$title, &$temp ) {
5959
$code = ( $temp->params['code'] ?? null );
60-
if ( !preg_match( self::REGEX_CODE, $code, $m ) ) {
60+
if ( ( $code === null ) || !preg_match( self::REGEX_CODE, $code, $m ) ) {
6161
return true;
6262
}
6363
$lang = $title->getPageLanguage();

0 commit comments

Comments
 (0)