Type hint &$defaultPreferences & clean onResourceLoaderTestModules

* Per https://www.mediawiki.org/wiki/Manual:Hooks/GetPreferences, it is
  strict on $preferences being an array, so type hinted it to conform.

* Remove legacy hook behavior for onResourceLoaderTestModules() hook in
  CodeMirrorHooks. See: https://w.wiki/3Az for more information. Also,
  added `@see` with link to the documentation of the hook used.

Change-Id: I0a2fac4b4d491abf8d2f661be32bf2e0d791c90b
This commit is contained in:
Derick Alangi 2019-05-07 15:44:14 +01:00
parent fdbf91ddeb
commit 4b17eb952c

View file

@ -48,7 +48,7 @@ class CodeMirrorHooks {
* @param User $user
* @param array &$defaultPreferences
*/
public static function onGetPreferences( User $user, &$defaultPreferences ) {
public static function onGetPreferences( User $user, array &$defaultPreferences ) {
// CodeMirror is enabled by default for users. It can
// be changed by adding '$wgDefaultUserOptions['usecodemirror'] = 0;' into LocalSettings.php
$defaultPreferences['usecodemirror'] = [
@ -59,9 +59,11 @@ class CodeMirrorHooks {
/**
* Register test modules for CodeMirror.
*
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderTestModules
*
* @param array &$modules
* @param ResourceLoader $rl
* @return bool
*/
public static function onResourceLoaderTestModules( array &$modules, ResourceLoader $rl ) {
$modules['qunit']['ext.CodeMirror.test'] = [
@ -76,8 +78,6 @@ class CodeMirrorHooks {
'localBasePath' => __DIR__ . '/../',
'remoteExtPath' => 'CodeMirror',
];
return true;
}
}