Umherirrender has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/356229 )
Change subject: Add phpcs and make pass
......................................................................
Add phpcs and make pass
Change-Id: I02b7f85f54ffaf8a1c9d5bed6fa20abb1627afe5
---
M GadgetHooks.php
M Gadgets.alias.php
M Gadgets_body.php
M SpecialGadgetUsage.php
M composer.json
M includes/GadgetDefinitionNamespaceRepo.php
M includes/content/GadgetDefinitionContent.php
M includes/content/GadgetDefinitionValidator.php
A phpcs.xml
M tests/phpunit/GadgetTest.php
10 files changed, 35 insertions(+), 19 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Gadgets
refs/changes/29/356229/1
diff --git a/GadgetHooks.php b/GadgetHooks.php
index e91c911..029d894 100644
--- a/GadgetHooks.php
+++ b/GadgetHooks.php
@@ -103,7 +103,7 @@
if ( $section !== '' ) {
$section = wfMessage( "gadget-section-$section"
)->parse();
- if ( count ( $available ) ) {
+ if ( count( $available ) ) {
$options[$section] = $available;
}
} else {
@@ -253,7 +253,8 @@
if ( !$content instanceof GadgetDefinitionContent ) {
// This should not be possible?
- throw new Exception( "Tried to save
non-GadgetDefinitionContent to {$title->getPrefixedText()}" );
+ throw new Exception(
+ "Tried to save non-GadgetDefinitionContent to
{$title->getPrefixedText()}" );
}
$status = $content->validate();
diff --git a/Gadgets.alias.php b/Gadgets.alias.php
index eae233e..c71b820 100644
--- a/Gadgets.alias.php
+++ b/Gadgets.alias.php
@@ -5,7 +5,6 @@
* @file
* @ingroup Extensions
*/
-// @codingStandardsIgnoreFile
$specialPageAliases = [];
diff --git a/Gadgets_body.php b/Gadgets_body.php
index ec5e615..a821869 100644
--- a/Gadgets_body.php
+++ b/Gadgets_body.php
@@ -11,7 +11,6 @@
* @license GNU General Public Licence 2.0 or later
*/
-
/**
* Wrapper for one gadget.
*/
@@ -117,7 +116,6 @@
return strlen( $id ) > 0 && ResourceLoader::isValidModuleName(
Gadget::getModuleName( $id ) );
}
-
/**
* @return String: Gadget name
*/
@@ -171,12 +169,17 @@
* @return Boolean
*/
public function isAllowed( $user ) {
- return count( array_intersect( $this->requiredRights,
$user->getRights() ) ) == count( $this->requiredRights )
- && ( $this->requiredSkins === true || !count(
$this->requiredSkins ) || in_array( $user->getOption( 'skin' ),
$this->requiredSkins ) );
+ return count( array_intersect( $this->requiredRights,
$user->getRights() ) ) ==
+ count( $this->requiredRights )
+ && ( $this->requiredSkins === true
+ || !count( $this->requiredSkins )
+ || in_array( $user->getOption( 'skin' ),
$this->requiredSkins )
+ );
}
/**
- * @return Boolean: Whether this gadget is on by default for everyone
(but can be disabled in preferences)
+ * @return bool Whether this gadget is on by default for everyone
+ * (but can be disabled in preferences)
*/
public function isOnByDefault() {
return $this->onByDefault;
diff --git a/SpecialGadgetUsage.php b/SpecialGadgetUsage.php
index 5bfe60f..a8a4720 100644
--- a/SpecialGadgetUsage.php
+++ b/SpecialGadgetUsage.php
@@ -36,14 +36,12 @@
$this->activeUsers = $this->getConfig()->get(
'SpecialGadgetUsageActiveUsers' );
}
-
/**
* Flag for holding the value of config variable
SpecialGadgetUsageActiveUsers
*
* @var bool $activeUsers
*/
public $activeUsers;
-
public function isExpensive() {
return true;
@@ -132,7 +130,7 @@
if ( $this->activeUsers ) {
$headers[] = 'gadgetusage-activeusers';
}
- foreach( $headers as $h ) {
+ foreach ( $headers as $h ) {
if ( $h == 'gadgetusage-gadget' ) {
$html .= Html::element( 'th', [], $this->msg(
$h )->text() );
} else {
@@ -201,7 +199,8 @@
$defaultGadgets = $this->getDefaultGadgets( $gadgetRepo,
$gadgetIds );
if ( $this->activeUsers ) {
$out->addHtml(
- $this->msg( 'gadgetusage-intro' )->numParams(
$this->getConfig()->get( 'ActiveUserDays' ) )->parseAsBlock()
+ $this->msg( 'gadgetusage-intro' )
+ ->numParams( $this->getConfig()->get(
'ActiveUserDays' ) )->parseAsBlock()
);
} else {
$out->addHtml(
diff --git a/composer.json b/composer.json
index a3aecbe..e4e502f 100644
--- a/composer.json
+++ b/composer.json
@@ -1,11 +1,14 @@
{
"require-dev": {
"jakub-onderka/php-parallel-lint": "0.9.2",
- "jakub-onderka/php-console-highlighter": "0.3.2"
+ "jakub-onderka/php-console-highlighter": "0.3.2",
+ "mediawiki/mediawiki-codesniffer": "0.7.2"
},
"scripts": {
+ "fix": "phpcbf",
"test": [
- "parallel-lint . --exclude node_modules --exclude
vendor"
+ "parallel-lint . --exclude node_modules --exclude
vendor",
+ "phpcs -p -s"
]
}
}
diff --git a/includes/GadgetDefinitionNamespaceRepo.php
b/includes/GadgetDefinitionNamespaceRepo.php
index f56873c..6808db3 100644
--- a/includes/GadgetDefinitionNamespaceRepo.php
+++ b/includes/GadgetDefinitionNamespaceRepo.php
@@ -19,7 +19,7 @@
*/
private $wanCache;
- public function __construct () {
+ public function __construct() {
$this->wanCache =
MediaWikiServices::getInstance()->getMainWANObjectCache();
}
diff --git a/includes/content/GadgetDefinitionContent.php
b/includes/content/GadgetDefinitionContent.php
index 6a76b9d..c7b90b0 100644
--- a/includes/content/GadgetDefinitionContent.php
+++ b/includes/content/GadgetDefinitionContent.php
@@ -67,7 +67,6 @@
}
}
-
/**
* @return Status
*/
diff --git a/includes/content/GadgetDefinitionValidator.php
b/includes/content/GadgetDefinitionValidator.php
index 7f6e444..2be7578 100644
--- a/includes/content/GadgetDefinitionValidator.php
+++ b/includes/content/GadgetDefinitionValidator.php
@@ -8,7 +8,8 @@
class GadgetDefinitionValidator {
/**
* Validation metadata.
- * 'foo.bar.baz' => [ 'type check callback', 'type name' [, 'member
type check callback', 'member type name'] ]
+ * 'foo.bar.baz' => [ 'type check callback',
+ * 'type name' [, 'member type check callback', 'member type name'] ]
*/
protected static $propertyValidation = [
'settings' => [ 'is_array', 'array' ],
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..4ffde0b
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ruleset>
+ <rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki"/>
+ <file>.</file>
+ <arg name="extensions" value="php,php5,inc"/>
+ <arg name="encoding" value="UTF-8"/>
+ <exclude-pattern>vendor</exclude-pattern>
+ <exclude-pattern>node_modules</exclude-pattern>
+</ruleset>
diff --git a/tests/phpunit/GadgetTest.php b/tests/phpunit/GadgetTest.php
index 25f1ef7..8dacc50 100644
--- a/tests/phpunit/GadgetTest.php
+++ b/tests/phpunit/GadgetTest.php
@@ -160,10 +160,12 @@
$this->assertGreaterThanOrEqual( 2, count( $gadgets ), "Gadget
list parsed" );
$repo->definitionCache = $gadgets;
- $this->assertTrue( GadgetHooks::getPreferences( new User,
$prefs ), 'GetPrefences hook should return true' );
+ $this->assertTrue( GadgetHooks::getPreferences( new User,
$prefs ),
+ 'GetPrefences hook should return true' );
$options = $prefs['gadgets']['options'];
- $this->assertFalse( isset(
$options['⧼gadget-section-remove-section⧽'] ), 'Must not show empty sections' );
+ $this->assertFalse( isset(
$options['⧼gadget-section-remove-section⧽'] ),
+ 'Must not show empty sections' );
$this->assertTrue( isset(
$options['⧼gadget-section-keep-section1⧽'] ) );
$this->assertTrue( isset(
$options['⧼gadget-section-keep-section2⧽'] ) );
}
--
To view, visit https://gerrit.wikimedia.org/r/356229
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I02b7f85f54ffaf8a1c9d5bed6fa20abb1627afe5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Gadgets
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits