Ladsgroup has uploaded a new change for review.
https://gerrit.wikimedia.org/r/312708
Change subject: Made PHPStorm happy on includes/Hooks.php
......................................................................
Made PHPStorm happy on includes/Hooks.php
Mostly doc fixes
Change-Id: I52f71ee35918becfdeded3c1de4988dd53c85535
---
M includes/Hooks.php
1 file changed, 63 insertions(+), 29 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ORES
refs/changes/08/312708/1
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 7692089..6150347 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -40,6 +40,9 @@
/**
* Ask the ORES server for scores on this recent change
+ *
+ * @param RecentChange $rc
+ * @return bool|null
*/
public static function onRecentChange_save( RecentChange $rc ) {
global $wgOresExcludeBots, $wgOresEnabledNamespaces;
@@ -50,8 +53,8 @@
// Check if we actually want score for this namespace
$ns = $rc->getAttribute( 'rc_namespace' );
if ( $wgOresEnabledNamespaces &&
- !( isset( $wgOresEnabledNamespaces[$ns] ) &&
- $wgOresEnabledNamespaces[$ns] ) ) {
+ !( isset( $wgOresEnabledNamespaces[$ns] ) &&
+ $wgOresEnabledNamespaces[$ns] ) ) {
return true;
}
@@ -109,7 +112,7 @@
/**
* Pull in ORES score columns during recent changes queries
*
- * @param $name
+ * @param string $name
* @param array $tables
* @param array $fields
* @param array $conds
@@ -138,28 +141,28 @@
$fields[] = $dbr->addQuotes( $threshold ) . ' AS
ores_threshold';
$conds[] = '(oresm_name = ' . $dbr->addQuotes( 'damaging' ) .
- ' OR oresm_name IS NULL)';
+ ' OR oresm_name IS NULL)';
$conds[] = '(oresm_is_current != 0 OR oresm_is_current IS
NULL)';
$join_conds['ores_classification'] = [ 'LEFT JOIN',
- 'rc_this_oldid = oresc_rev ' .
- 'AND oresc_class = 1' ];
+ 'rc_this_oldid =
oresc_rev ' .
+ 'AND oresc_class = 1' ];
$join_conds['ores_model'] = [ 'LEFT JOIN',
- 'oresc_model = oresm_id ' .
- 'AND oresm_is_current = 1'
+ 'oresc_model = oresm_id ' .
+ 'AND oresm_is_current = 1'
];
if ( $opts->getValue( 'hidenondamaging' ) ) {
// Override the join conditions.
$join_conds['ores_classification'] = [ 'INNER JOIN',
- 'rc_this_oldid = oresc_rev ' .
- 'AND oresc_class = 1' ];
+ 'rc_this_oldid =
oresc_rev ' .
+ 'AND oresc_class
= 1' ];
// Filter out non-damaging edits.
$conds[] = 'oresc_probability > '
- . $dbr->addQuotes( $threshold );
+ . $dbr->addQuotes( $threshold );
$conds['rc_patrolled'] = 0;
$query_options[] = 'STRAIGHT_JOIN';
}
@@ -174,10 +177,15 @@
* @param array $data
* @param RCCacheEntry[] $block
* @param RCCacheEntry $rcObj
+ * @param string[] $classes
* @return bool
*/
- public static function onEnhancedChangesListModifyLineData(
EnhancedChangesList $ecl, array &$data,
- array $block, RCCacheEntry $rcObj, array &$classes
+ public static function onEnhancedChangesListModifyLineData(
+ EnhancedChangesList $ecl,
+ array &$data,
+ array $block,
+ RCCacheEntry $rcObj,
+ array &$classes
) {
if ( self::oresEnabled( $ecl->getUser() ) === false ) {
return true;
@@ -197,7 +205,7 @@
* @return bool
*/
public static function onEnhancedChangesListModifyBlockLineData(
EnhancedChangesList $ecl,
- array &$data, RCCacheEntry $rcObj
+ array
&$data, RCCacheEntry $rcObj
) {
if ( self::oresEnabled( $ecl->getUser() ) === false ) {
return true;
@@ -220,7 +228,7 @@
* @return bool
*/
public static function onOldChangesListRecentChangesLine( ChangesList
&$changesList, &$s,
- $rc, &$classes = []
+ $rc,
&$classes = []
) {
if ( self::oresEnabled( $changesList->getUser() ) === false ) {
return true;
@@ -234,7 +242,7 @@
}
$classes[] = 'damaging';
$parts = explode( $separator, $s );
- $parts[1] = $changesList->flag( 'damaging' ) .
$parts[1];
+ $parts[1] = ChangesList::flag( 'damaging' ) . $parts[1];
$s = implode( $separator, $parts );
}
@@ -246,6 +254,7 @@
*
* @param ContribsPager $pager
* @param array $query
+ * @return bool|null
*/
public static function onContribsGetQueryInfo( ContribsPager $pager,
&$query ) {
if ( self::oresEnabled( $pager->getUser() ) === false ) {
@@ -263,28 +272,29 @@
$query['fields'][] = $dbr->addQuotes( $threshold ) . ' AS
ores_threshold';
$query['conds'][] = '(oresm_name = ' . $dbr->addQuotes(
'damaging' ) .
- ' OR oresm_name IS NULL)';
+ ' OR oresm_name IS NULL)';
$query['conds'][] = '(oresm_is_current != 0 OR oresm_is_current
IS NULL)';
$query['join_conds']['ores_classification'] = [ 'LEFT JOIN',
- 'rev_id = oresc_rev ' .
- 'AND oresc_class = 1' ];
+ 'rev_id =
oresc_rev ' .
+ 'AND
oresc_class = 1' ];
$query['join_conds']['ores_model'] = [ 'LEFT JOIN',
- 'oresc_model = oresm_id ' .
- 'AND oresm_is_current = 1' ];
+ 'oresc_model = oresm_id
' .
+ 'AND oresm_is_current =
1' ];
if ( $pager->getContext()->getRequest()->getVal(
'hidenondamaging' ) ) {
// Override the join conditions.
$join_conds['ores_classification'] = [ 'INNER JOIN',
- 'rc_this_oldid = oresc_rev ' .
- 'AND oresc_class = 1' ];
+ 'rc_this_oldid =
oresc_rev ' .
+ 'AND oresc_class
= 1' ];
// Filter out non-damaging edits.
$query['conds'][] = 'oresc_probability > '
- . $dbr->addQuotes( $threshold );
+ . $dbr->addQuotes( $threshold );
}
+ return true;
}
public static function onSpecialContributionsFormatRowFlags(
@@ -303,6 +313,7 @@
// Prepend the "r" flag
array_unshift( $flags, ChangesList::flag( 'damaging' )
);
}
+ return true;
}
public static function onContributionsLineEnding(
@@ -321,13 +332,19 @@
// Add the damaging class
$classes[] = 'damaging';
}
+ return true;
}
/**
* Hook into Special:Contributions filters
+ *
+ * @param SpecialContributions $page
+ * @param string HTML[] $filters
+ * @return bool
*/
public static function onSpecialContributionsGetFormFilters(
- SpecialContributions $page, array &$filters
+ SpecialContributions $page,
+ array &$filters
) {
if ( self::oresEnabled( $page->getUser() ) === false ) {
return true;
@@ -350,9 +367,15 @@
/**
* Internal helper to label matching rows
+ *
+ * @param RCCacheEntry $rcObj
+ * @param string[]
+ * @param string[]
*/
- protected static function processRecentChangesList( RCCacheEntry $rcObj,
- array &$data, array &$classes = []
+ protected static function processRecentChangesList(
+ RCCacheEntry $rcObj,
+ array &$data,
+ array &$classes = []
) {
$damaging = self::getScoreRecentChangesList( $rcObj );
if ( $damaging ) {
@@ -394,8 +417,12 @@
/**
* GetPreferences hook, adding ORES section, letting people choose a
threshold
* Also let people make hidenondamaging default
+ *
+ * @param User $user
+ * @param string[] $preferences
+ * @return bool
*/
- public static function onGetPreferences( $user, &$preferences ) {
+ public static function onGetPreferences( User $user, array
&$preferences ) {
global $wgOresDamagingThresholds;
if ( self::oresEnabled( $user ) === false ) {
@@ -430,6 +457,10 @@
/**
* Add CSS styles to output page
+ *
+ * @param OutputPage $out
+ * @param Skin $skin
+ * @return bool
*/
public static function onBeforePageDisplay( OutputPage &$out, Skin
&$skin ) {
if ( self::oresEnabled( $out->getUser() ) === false ) {
@@ -441,8 +472,11 @@
/**
* Make a beta feature
+ *
+ * @param User $user
+ * @param string[]
*/
- public static function onGetBetaFeaturePreferences( $user, &$prefs ) {
+ public static function onGetBetaFeaturePreferences( User $user, array
&$prefs ) {
global $wgExtensionAssetsPath;
$prefs['ores-enabled'] = [
--
To view, visit https://gerrit.wikimedia.org/r/312708
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I52f71ee35918becfdeded3c1de4988dd53c85535
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ORES
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits