mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-27 17:50:06 +00:00
Upgrade to newer phan
Bug: T216940 Change-Id: If8c2027f6bb7b91504fb51a3d2668b6d929b5da1
This commit is contained in:
parent
017d6a133b
commit
8328acb9b1
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -22,4 +22,3 @@ project.index
|
|||
## Sublime
|
||||
sublime-*
|
||||
sftp-config.json
|
||||
tests/phan/issues
|
||||
|
|
30
.phan/config.php
Normal file
30
.phan/config.php
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
$cfg = require __DIR__ . '/../vendor/mediawiki/mediawiki-phan-config/src/config.php';
|
||||
|
||||
$cfg['file_list'][] = 'Scribunto.php';
|
||||
|
||||
$cfg['directory_list'] = array_merge(
|
||||
$cfg['directory_list'],
|
||||
[
|
||||
'vendor/mediawiki/lua-sandbox/stubs',
|
||||
'../../extensions/SyntaxHighlight_GeSHi',
|
||||
]
|
||||
);
|
||||
|
||||
$cfg['exclude_analysis_directory_list'] = array_merge(
|
||||
$cfg['exclude_analysis_directory_list'],
|
||||
[
|
||||
'vendor/mediawiki/lua-sandbox/stubs',
|
||||
'../../extensions/SyntaxHighlight_GeSHi',
|
||||
]
|
||||
);
|
||||
$cfg['suppress_issue_types'] = array_merge(
|
||||
$cfg['suppress_issue_types'],
|
||||
[
|
||||
// \Parser->scribunto_engine
|
||||
'PhanUndeclaredProperty',
|
||||
]
|
||||
);
|
||||
|
||||
return $cfg;
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
|
||||
// @phan-file-suppress PhanUndeclaredVariableDim false positive
|
||||
if ( function_exists( 'wfLoadExtension' ) ) {
|
||||
wfLoadExtension( 'Scribunto' );
|
||||
// Keep i18n globals so mergeMessageFileList.php doesn't break
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"mediawiki/lua-sandbox": "3.0.1",
|
||||
"mediawiki/minus-x": "0.3.1",
|
||||
"jakub-onderka/php-console-highlighter": "0.3.2",
|
||||
"mediawiki/mediawiki-phan-config": "0.3.0"
|
||||
"mediawiki/mediawiki-phan-config": "0.5.0"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
|
|
|
@ -41,6 +41,7 @@ class Scribunto {
|
|||
throw new MWException( 'Invalid scripting engine is specified in $wgScribuntoDefaultEngine' );
|
||||
}
|
||||
$options = $extraOptions + $wgScribuntoEngineConf[$wgScribuntoDefaultEngine];
|
||||
// @phan-suppress-next-line PhanTypeMismatchArgument false positive
|
||||
return self::newEngine( $options );
|
||||
}
|
||||
|
||||
|
|
|
@ -363,7 +363,6 @@ class ScribuntoHooks {
|
|||
return true;
|
||||
}
|
||||
|
||||
/** @suppress PhanUndeclaredMethod */
|
||||
$validateStatus = $content->validate( $title );
|
||||
if ( $validateStatus->isOK() ) {
|
||||
return true;
|
||||
|
|
|
@ -567,7 +567,7 @@ abstract class Scribunto_LuaEngine extends ScribuntoEngineBase {
|
|||
|
||||
$module = $this->fetchModuleFromParser( $title );
|
||||
if ( $module ) {
|
||||
/** @suppress PhanUndeclaredMethod */
|
||||
// @phan-suppress-next-line PhanUndeclaredMethod
|
||||
return [ $module->getInitChunk() ];
|
||||
} else {
|
||||
return [];
|
||||
|
@ -1045,27 +1045,27 @@ class Scribunto_LuaError extends ScribuntoException {
|
|||
}
|
||||
|
||||
if ( strval( $info['namewhat'] ) !== '' ) {
|
||||
$function = wfMessage( 'scribunto-lua-in-function', wfEscapeWikiText( $info['name'] ) );
|
||||
$functionMsg = wfMessage( 'scribunto-lua-in-function', wfEscapeWikiText( $info['name'] ) );
|
||||
in_array( 'content', $msgOptions ) ?
|
||||
$function = $function->inContentLanguage()->plain() :
|
||||
$function = $function->plain();
|
||||
$function = $functionMsg->inContentLanguage()->plain() :
|
||||
$function = $functionMsg->plain();
|
||||
} elseif ( $info['what'] == 'main' ) {
|
||||
$function = wfMessage( 'scribunto-lua-in-main' );
|
||||
$functionMsg = wfMessage( 'scribunto-lua-in-main' );
|
||||
in_array( 'content', $msgOptions ) ?
|
||||
$function = $function->inContentLanguage()->plain() :
|
||||
$function = $function->plain();
|
||||
$function = $functionMsg->inContentLanguage()->plain() :
|
||||
$function = $functionMsg->plain();
|
||||
} else {
|
||||
// C function, tail call, or a Lua function where Lua can't
|
||||
// guess the name
|
||||
$function = '?';
|
||||
}
|
||||
|
||||
$backtraceLine = wfMessage( 'scribunto-lua-backtrace-line' )
|
||||
$backtraceLineMsg = wfMessage( 'scribunto-lua-backtrace-line' )
|
||||
->rawParams( "<strong>$src</strong>" )
|
||||
->params( $function );
|
||||
in_array( 'content', $msgOptions ) ?
|
||||
$backtraceLine = $backtraceLine->inContentLanguage()->parse() :
|
||||
$backtraceLine = $backtraceLine->parse();
|
||||
$backtraceLine = $backtraceLineMsg->inContentLanguage()->parse() :
|
||||
$backtraceLine = $backtraceLineMsg->parse();
|
||||
|
||||
$s .= "<li>$backtraceLine</li>";
|
||||
}
|
||||
|
|
|
@ -476,6 +476,7 @@ class Scribunto_LuaUstringLibrary extends Scribunto_LuaLibraryBase {
|
|||
// Because %f considers the beginning and end of the string
|
||||
// to be \0, determine if $re2 matches that and take it
|
||||
// into account with "^" and "$".
|
||||
// @phan-suppress-next-line PhanParamSuspiciousOrder
|
||||
if ( preg_match( "/$re2/us", "\0" ) ) {
|
||||
$re .= "(?<!^)(?<!$re2)(?=$re2|$)";
|
||||
} else {
|
||||
|
|
|
@ -6,6 +6,7 @@ use Psr\Log\NullLogger;
|
|||
|
||||
class Scribunto_LuaStandaloneEngine extends Scribunto_LuaEngine {
|
||||
protected static $clockTick;
|
||||
/** @var array|bool */
|
||||
public $initialStatus;
|
||||
|
||||
/**
|
||||
|
@ -73,7 +74,7 @@ class Scribunto_LuaStandaloneEngine extends Scribunto_LuaEngine {
|
|||
$value = array_map( [ $lang, 'formatSize' ], $value );
|
||||
break;
|
||||
case 'scribunto-limitreport-estmemusage':
|
||||
/** @suppress PhanTypeMismatchArgument */
|
||||
// @phan-suppress-next-line PhanTypeMismatchArgument
|
||||
$value = $lang->formatSize( $value );
|
||||
break;
|
||||
}
|
||||
|
@ -130,7 +131,7 @@ class Scribunto_LuaStandaloneInterpreter extends Scribunto_LuaInterpreter {
|
|||
public $enableDebug;
|
||||
|
||||
/**
|
||||
* @var resource
|
||||
* @var resource|bool
|
||||
*/
|
||||
public $proc;
|
||||
|
||||
|
@ -684,6 +685,9 @@ class Scribunto_LuaStandaloneInterpreter extends Scribunto_LuaInterpreter {
|
|||
proc_terminate( $this->proc );
|
||||
while ( true ) {
|
||||
$status = proc_get_status( $this->proc );
|
||||
// XXX: Should proc_get_status docs be changed so that
|
||||
// its documented as possibly returning false?
|
||||
// @phan-suppress-next-line PhanTypeComparisonFromArray
|
||||
if ( $status === false ) {
|
||||
// WTF? Let the caller throw an appropriate error.
|
||||
return;
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
$cfg = require __DIR__ . '/../../vendor/mediawiki/mediawiki-phan-config/src/config.php';
|
||||
|
||||
$cfg['directory_list'] = array_merge(
|
||||
$cfg['directory_list'],
|
||||
[
|
||||
'./vendor/mediawiki/lua-sandbox/stubs',
|
||||
'./../../extensions/SyntaxHighlight_GeSHi',
|
||||
]
|
||||
);
|
||||
$cfg['file_list'][] = './Scribunto.php';
|
||||
|
||||
$cfg['exclude_analysis_directory_list'] = array_merge(
|
||||
$cfg['exclude_analysis_directory_list'],
|
||||
[
|
||||
'./vendor/mediawiki/lua-sandbox/stubs',
|
||||
'./../../extensions/SyntaxHighlight_GeSHi',
|
||||
]
|
||||
);
|
||||
$cfg['suppress_issue_types'] = array_merge(
|
||||
$cfg['suppress_issue_types'],
|
||||
[
|
||||
// \Parser->scribunto_engine
|
||||
'PhanUndeclaredProperty',
|
||||
// \Scribunto_LuaInterpreter::callFunction()
|
||||
'PhanParamTooMany',
|
||||
// our version of phan doesn't support inheriting doc yet
|
||||
'PhanParamSignatureMismatch',
|
||||
]
|
||||
);
|
||||
|
||||
return $cfg;
|
Loading…
Reference in a new issue