Skip to content

Commit dced713

Browse files
authored
Merge pull request #1 from Wikia/PLATFORM-6983
PLATFORM-6983 - Code reformatting
2 parents a937c17 + 71c3c9b commit dced713

18 files changed

+36159
-35551
lines changed

.phpcs.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<ruleset name="MediaWiki">
3-
<rule ref="./vendor/hydrawiki/hydrawiki-codesniffer/HydraWiki" />
4-
<file>.</file>
5-
<arg name="encoding" value="utf8"/>
6-
<arg name="extensions" value="php"/>
3+
<rule ref="./vendor/hydrawiki/hydrawiki-codesniffer/HydraWiki"/>
4+
<file>.</file>
5+
<arg name="encoding" value="utf8"/>
6+
<arg name="extensions" value="php"/>
77
</ruleset>

PvXCode.hooks.php

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
<?php
2+
23
/**
34
* Curse Inc.
45
* PvX Code
56
* Guild Wars Template to PvXCode Handling
67
*
7-
* @author Cameron Chunn
8-
* @copyright (c) 2015 Curse Inc.
9-
* @license GNU General Public License v2.0 or later
10-
* @package PvXCode
11-
* @link https://gitlab.com/hydrawiki
8+
* @author Cameron Chunn
9+
* @copyright (c) 2015 Curse Inc.
10+
* @license GPL-2.0-or-later
11+
* @package PvXCode
12+
* @link https://gitlab.com/hydrawiki
1213
*
1314
* Purpose of this file:
1415
* Declares how the extension will interpret pvxbig tag
1516
* Loads the gwbbcode.inc.php file for builds and tooltips
16-
**/
17+
*/
1718
class PvXCodeHooks {
1819
/**
1920
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ParserFirstCallInit
20-
* @param Parser $parser
21+
* @param Parser &$parser
2122
* @return true
23+
* @throws MWException
2224
*/
23-
public static function onParserFirstCallInit( Parser &$parser ) {
25+
public static function onParserFirstCallInit( Parser &$parser ): bool {
2426
// Calls PvXCode.php within the classes folder
25-
$parser->setHook('pvxbig', 'PvXCode::ParserRender');
27+
$parser->setHook( 'pvxbig', 'PvXCode::parserRender' );
28+
2629
return true;
2730
}
2831

@@ -31,23 +34,25 @@ public static function onParserFirstCallInit( Parser &$parser ) {
3134
* @return void
3235
*/
3336
public static function onRegistration() {
34-
// Retrieve config settings from localSettings.php - probably a better way of doing this via "use MediaWiki\MediaWikiServices;"
37+
// Retrieve config settings from localSettings.php -
38+
// probably a better way of doing this via "use MediaWiki\MediaWikiServices;"
3539
global $wgServer, $wgScriptPath, $wgExtensionAssetsPath;
3640

3741
// Local file path for includes
38-
define('GWBBCODE_ROOT', __DIR__.'/gwbbcode');
42+
define( 'GWBBCODE_ROOT', __DIR__ . '/gwbbcode' );
3943

40-
// Website URL for the image folder within extension/PvXCode folder, e.g. '/extensions/PvXCode/images'/img_skills/83.jpg
41-
define('GWBBCODE_IMAGES_FOLDER_URL', $wgExtensionAssetsPath.'/PvXCode/images');
44+
// Website URL for the image folder within extension/PvXCode folder,
45+
//e.g. '/extensions/PvXCode/images'/img_skills/83.jpg
46+
define( 'GWBBCODE_IMAGES_FOLDER_URL', $wgExtensionAssetsPath . '/PvXCode/images' );
4247

43-
// Website URL for the page prefix, e.g. 'https://gwpvx.gamepedia.com/index.php?title='/Archive:Team_-_Frostmaw_Searing_Spike
44-
define('PVX_WIKI_PAGE_URL', $wgServer.$wgScriptPath );
48+
// Website URL for the page prefix,
49+
// e.g. 'https://gwpvx.gamepedia.com/index.php?title='/Archive:Team_-_Frostmaw_Searing_Spike
50+
define( 'PVX_WIKI_PAGE_URL', $wgServer . $wgScriptPath );
4551

4652
// Website URL for the page prefix on the prefered wiki database
47-
define('GW_WIKI_PAGE_URL', 'https://wiki.guildwars.com/wiki');
53+
define( 'GW_WIKI_PAGE_URL', 'https://wiki.guildwars.com/wiki' );
4854

4955
// Load main script
50-
require_once(GWBBCODE_ROOT.'/gwbbcode.inc.php');
56+
require_once( GWBBCODE_ROOT . '/gwbbcode.inc.php' );
5157
}
52-
5358
}

PvXCode.php

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,27 @@
44
* PvX Code
55
* Guildwiki / Guild Wars Template to PvXCode Handling
66
*
7-
* @author Cameron Chunn
8-
* @copyright (c) 2015 Curse Inc.
9-
* @license GNU General Public License v2.0 or later
10-
* @package PvXCode
11-
* @link https://gitlab.com/hydrawiki
7+
* @author Cameron Chunn
8+
* @copyright (c) 2015 Curse Inc.
9+
* @license GPL-2.0-or-later
10+
* @package PvXCode
11+
* @link https://gitlab.com/hydrawiki
1212
*
1313
* Purpose of this file:
1414
* Allows the extension to be loaded from localSettings.php
15-
**/
15+
*/
1616
if ( function_exists( 'wfLoadExtension' ) ) {
17-
// The following line seeks the PvXCode/extension.json file
18-
wfLoadExtension( 'PvXCode' );
17+
// The following line seeks the PvXCode/extension.json file
18+
wfLoadExtension( 'PvXCode' );
1919

20-
// Keep i18n globals so mergeMessageFileList.php doesn't break
21-
$wgMessagesDirs['PvXCode'] = __DIR__ . '/i18n';
22-
wfWarn(
23-
'Deprecated PHP entry point used for PvX Vote extension. Please use wfLoadExtension instead, ' .
24-
'see https://www.mediawiki.org/wiki/Extension_registration for more details.'
25-
);
26-
return;
20+
// Keep i18n globals so mergeMessageFileList.php doesn't break
21+
$wgMessagesDirs['PvXCode'] = __DIR__ . '/i18n';
22+
wfWarn(
23+
'Deprecated PHP entry point used for PvX Vote extension. Please use wfLoadExtension instead, ' .
24+
'see https://www.mediawiki.org/wiki/Extension_registration for more details.'
25+
);
26+
27+
return;
2728
} else {
28-
die( 'This version of the PvXCode extension requires MediaWiki 1.25+' );
29+
die( 'This version of the PvXCode extension requires MediaWiki 1.25+' );
2930
}

classes/PvXCode.php

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,32 @@
44
* PvX Code
55
* Guildwiki / Guild Wars Template to PvXCode Handling
66
*
7-
* @author Cameron Chunn
8-
* @copyright (c) 2015 Curse Inc.
9-
* @license GNU General Public License v2.0 or later
10-
* @package PvXCode
11-
* @link https://gitlab.com/hydrawiki
7+
* @author Cameron Chunn
8+
* @copyright (c) 2015 Curse Inc.
9+
* @license GPL-2.0-or-later
10+
* @package PvXCode
11+
* @link https://gitlab.com/hydrawiki
1212
*
13-
**/
13+
*/
1414

1515
class PvXCode {
1616
/**
1717
* Parser Renderer
18-
* @param string $input text input into parser
19-
* @param array $args parsing arguements, not used in this function, but neaded by mediawiki.
20-
* @param Parser $parser reference to the parser
21-
* @param string $frame not used in this function, but needed by mediawiki.
18+
* @param string $input text input into parser
19+
* @param array $args parsing arguements, not used in this function, but neaded by mediawiki.
20+
* @param Parser $parser reference to the parser
21+
* @param string $frame not used in this function, but needed by mediawiki.
22+
* @return array|string|string[]|null
2223
*/
23-
public static function ParserRender($input, $args, $parser, $frame) {
24-
$parser->getOutput()->addModuleStyles('ext.PvXCode.css');
25-
$parser->getOutput()->addModules('ext.PvXCode.js');
24+
public static function parserRender( string $input, array $args, Parser $parser, string $frame ) {
25+
$parser->getOutput()->addModuleStyles( 'ext.PvXCode.css' );
26+
$parser->getOutput()->addModules( 'ext.PvXCode.js' );
2627
$title = $parser->getTitle()->getText();
2728

28-
// Using recursiveTagParse() instead of parse() to avoid wrapping result in a div and the associated processing time hidden HTML comment
29-
$parsed_input = $parser->recursiveTagParse($input, $frame = false);
30-
$results = parse_gwbbcode($parsed_input, $title);
31-
return $results;
29+
// Using recursiveTagParse() instead of parse() to avoid wrapping result
30+
// in a div and the associated processing time hidden HTML comment
31+
$parsed_input = $parser->recursiveTagParse( $input, $frame = false );
32+
33+
return parseGwbbcode( $parsed_input, $title );
3234
}
3335
}

0 commit comments

Comments
 (0)