Remove phpcs exclude rules and update PHP code

Change-Id: Ie37deda368a4d163cf324988721033829ae8af77
This commit is contained in:
Fomafix
2022-11-12 19:05:41 +00:00
committed by jenkins-bot
parent 7e8976ecf0
commit e44e4c4c0c
9 changed files with 95 additions and 5 deletions

View File

@@ -28,6 +28,9 @@ use Wikimedia\ParamValidator\ParamValidator;
* @ingroup API
*/
class ApiLanguageSearch extends ApiBase {
/**
* @inheritDoc
*/
public function execute() {
$params = $this->extractRequestParams();
$search = $params['search'];
@@ -37,6 +40,9 @@ class ApiLanguageSearch extends ApiBase {
$result->addValue( null, $this->getModuleName(), $searches );
}
/**
* @inheritDoc
*/
public function getAllowedParams() {
return [
'search' => [

View File

@@ -48,6 +48,9 @@ class ApiULSLocalization extends ApiBase {
$this->languageNameUtils = $languageNameUtils;
}
/**
* @inheritDoc
*/
public function execute() {
$this->getMain()->setCacheMode( 'public' );
$this->getMain()->setCacheMaxAge( 2419200 );
@@ -63,6 +66,9 @@ class ApiULSLocalization extends ApiBase {
$this->getResult()->addValue( null, 'mime', 'application/json' );
}
/**
* @inheritDoc
*/
public function getCustomPrinter() {
return new ApiFormatRaw(
$this->getMain(),
@@ -70,6 +76,9 @@ class ApiULSLocalization extends ApiBase {
);
}
/**
* @inheritDoc
*/
public function getAllowedParams() {
return [
'language' => [
@@ -91,6 +100,9 @@ class ApiULSLocalization extends ApiBase {
];
}
/**
* @inheritDoc
*/
public function isInternal() {
// Try to scare people away from using this externally
return true;

View File

@@ -53,6 +53,9 @@ class ApiULSSetLanguage extends ApiBase {
$this->languageNameUtils = $languageNameUtils;
}
/**
* @inheritDoc
*/
public function execute() {
$request = $this->getRequest();
if ( !$request->wasPosted() ) {
@@ -91,6 +94,9 @@ class ApiULSSetLanguage extends ApiBase {
} );
}
/**
* @inheritDoc
*/
public function getAllowedParams() {
return [
'languagecode' => [
@@ -99,11 +105,17 @@ class ApiULSSetLanguage extends ApiBase {
];
}
/**
* @inheritDoc
*/
public function isInternal() {
// Try to scare people away from using this externally
return true;
}
/**
* @inheritDoc
*/
public function needsToken() {
return 'csrf';
}

View File

@@ -11,14 +11,23 @@ use OutputPage;
* @since 2016.04
*/
class FontRepoCompiler {
/** @var string */
protected $fsPath;
/** @var string */
protected $webPath;
/**
* @param string $fsPath
* @param string $webPath
*/
public function __construct( $fsPath, $webPath ) {
$this->fsPath = $fsPath;
$this->webPath = $webPath;
}
/**
* @return array
*/
public function getRepository() {
$files = $this->getFilesFromPath( $this->fsPath );
@@ -46,14 +55,26 @@ class FontRepoCompiler {
];
}
/**
* @param string $fspath
* @return array|false
*/
public function getFilesFromPath( $fspath ) {
return glob( "$fspath/*/font.ini" );
}
/**
* @param string $filepath
* @return array|false
*/
public function parseFile( $filepath ) {
return parse_ini_file( $filepath, true );
}
/**
* @param array $font
* @return array
*/
public function getLanguages( array $font ) {
if ( !isset( $font['languages'] ) ) {
return [];
@@ -65,6 +86,11 @@ class FontRepoCompiler {
return $languages;
}
/**
* @param array &$languages
* @param array $fontLanguages
* @param string $fontname
*/
public function appendLanguages( &$languages, $fontLanguages, $fontname ) {
foreach ( $fontLanguages as $rcode ) {
$code = str_replace( '*', '', $rcode );
@@ -84,6 +110,11 @@ class FontRepoCompiler {
}
}
/**
* @param array $font
* @param string $fontpath
* @return array
*/
public function getFontInfo( $font, $fontpath ) {
$info = [];
$fontdir = basename( $fontpath );

View File

@@ -421,6 +421,11 @@ class Hooks implements
}
}
/**
* @param User $user User whose preferences are being modified
* @param array &$preferences Preferences description array, to be fed to an HTMLForm object
* @return bool|void True or no return value to continue or false to abort
*/
public function onGetPreferences( $user, &$preferences ) {
// T259037: Does not work well on Minerva
$skin = RequestContext::getMain()->getSkin();
@@ -455,6 +460,10 @@ class Hooks implements
}
}
/**
* @param User $user
* @param array[] &$prefs
*/
public function onGetBetaFeaturePreferences( $user, array &$prefs ) {
if ( $this->config->get( 'ULSCompactLanguageLinksBetaFeature' ) === true &&
$this->config->get( 'InterwikiMagic' ) === true &&
@@ -526,6 +535,10 @@ class Hooks implements
}
}
/**
* @param OutputPage $out
* @return string|null
*/
private function getSetLang( OutputPage $out ): ?string {
$setLangCode = $out->getRequest()->getRawVal( 'setlang' );
if ( $setLangCode && $this->languageNameUtils->isSupportedLanguage( $setLangCode ) ) {

View File

@@ -30,6 +30,7 @@ use ResourceLoaderModule;
* ResourceLoader module for UniversalLanguageSelector
*/
class ResourceLoaderULSModule extends ResourceLoaderModule {
/** @var string[] */
protected $targets = [ 'desktop', 'mobile' ];
/**