jenkins-bot has submitted this change and it was merged.

Change subject: Update formatting
......................................................................


Update formatting

Reduces PHP CodeSniffer warnings.

Change-Id: If42cef712e5242f39cec3f907934dfd7f6ea1109
---
M MessageChecks.php
M api/ApiAggregateGroups.php
M api/ApiGroupReview.php
M ffs/MediaWikiComplexMessages.php
M scripts/sync-group.php
M utils/StatsTable.php
6 files changed, 73 insertions(+), 27 deletions(-)

Approvals:
  Nikerabbit: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/MessageChecks.php b/MessageChecks.php
index 27a2c97..58ad1f7 100644
--- a/MessageChecks.php
+++ b/MessageChecks.php
@@ -297,7 +297,8 @@
         * @param array $warnings Array where warnings are appended to.
         */
        protected function pythonInterpolationCheck( $messages, $code, array 
&$warnings ) {
-               $this->parameterCheck( $messages, $code, $warnings, 
'/\%\([a-zA-Z0-9]*?\)[diouxXeEfFgGcrs]/U' );
+               $pattern = '/\%\([a-zA-Z0-9]*?\)[diouxXeEfFgGcrs]/U';
+               $this->parameterCheck( $messages, $code, $warnings, $pattern );
        }
 
        /**
diff --git a/api/ApiAggregateGroups.php b/api/ApiAggregateGroups.php
index ed85c68..f5e8475 100644
--- a/api/ApiAggregateGroups.php
+++ b/api/ApiAggregateGroups.php
@@ -75,7 +75,9 @@
                         * aggregate message groups, the message group object 
$group
                         * might not always be available. In this case we need 
to fake
                         * some title. */
-                       $title = $group ? $group->getTitle() : 
Title::newFromText( "Special:Translate/$subgroupId" );
+                       $title = $group ?
+                               $group->getTitle() :
+                               Title::newFromText( 
"Special:Translate/$subgroupId" );
 
                        $entry = new ManualLogEntry( 'pagetranslation', $action 
);
                        $entry->setPerformer( $this->getUser() );
@@ -121,7 +123,6 @@
                        $output['groups'] = self::getAllPages();
                        $output['aggregategroupId'] = $aggregateGroupId;
                        // @todo Logging
-
                }
 
                // If we got this far, nothing has failed
@@ -137,7 +138,8 @@
                if ( strlen( $aggregateGroupName ) + strlen( $prefix ) >= 200 ) 
{
                        return $prefix . substr( sha1( $aggregateGroupName ), 
0, 5 );
                } else {
-                       return $prefix . preg_replace( 
'/[\x00-\x1f\x23\x27\x2c\x2e\x3c\x3e\x5b\x5d\x7b\x7c\x7d\x7f\s]+/i', '_', 
$aggregateGroupName );
+                       $pattern = 
'/[\x00-\x1f\x23\x27\x2c\x2e\x3c\x3e\x5b\x5d\x7b\x7c\x7d\x7f\s]+/i';
+                       return $prefix . preg_replace( $pattern, '_', 
$aggregateGroupName );
                }
        }
 
diff --git a/api/ApiGroupReview.php b/api/ApiGroupReview.php
index d447517..0a9ca75 100644
--- a/api/ApiGroupReview.php
+++ b/api/ApiGroupReview.php
@@ -169,9 +169,12 @@
 
                return array_merge( parent::getPossibleErrors(), array(
                        array( 'code' => 'permissiondenied', 'info' => "You 
must have $right right" ),
-                       array( 'code' => 'disabled', 'info' => "Message group 
workflows are not in use" ),
-                       array( 'code' => 'sameworkflowstate', 'info' => "The 
requested state is identical to the current state" ),
-                       array( 'code' => 'invalidstate', 'info' => "The 
requested state is invalid" ),
+                       array( 'code' => 'disabled', 'info' => 'Message group 
workflows are not in use' ),
+                       array(
+                               'code' => 'sameworkflowstate',
+                               'info' => 'The requested state is identical to 
the current state'
+                       ),
+                       array( 'code' => 'invalidstate', 'info' => 'The 
requested state is invalid' ),
                ) );
        }
 
diff --git a/ffs/MediaWikiComplexMessages.php b/ffs/MediaWikiComplexMessages.php
index d3ba150..2fede42 100644
--- a/ffs/MediaWikiComplexMessages.php
+++ b/ffs/MediaWikiComplexMessages.php
@@ -296,7 +296,9 @@
                                $rowContents .= '<td>' . $this->formatElement( 
$value ) . '</td>';
 
                                $value = $this->val( $group, 
self::LANG_CURRENT, $key );
-                               $rowContents .= '<td>' . $this->editElement( 
$key, $this->formatElement( $value ) ) . '</td>';
+                               $rowContents .= '<td>';
+                               $rowContents .= $this->editElement( $key, 
$this->formatElement( $value ) );
+                               $rowContents .= '</td>';
 
                                $s .= Xml::tags( 'tr', array( 'id' => 
"mw-sp-magic-$key" ), $rowContents );
                        }
@@ -321,9 +323,15 @@
        }
 
        public function getButtons() {
-               return
-                       Xml::inputLabel( wfMessage( 
'translate-magic-cm-comment' )->text(), 'comment', 'sp-translate-magic-comment' 
) .
-                       Xml::submitButton( wfMessage( 'translate-magic-cm-save' 
)->text(), array( 'name' => 'savetodb' ) );
+               return Xml::inputLabel(
+                       wfMessage( 'translate-magic-cm-comment' )->text(),
+                       'comment',
+                       'sp-translate-magic-comment'
+               ) .
+               Xml::submitButton(
+                       wfMessage( 'translate-magic-cm-save' )->text(),
+                       array( 'name' => 'savetodb' )
+               );
        }
 
        public function formatElement( $element ) {
@@ -398,9 +406,13 @@
                $title = Title::newFromText( 'MediaWiki:' . 
$this->getKeyForSave() );
                $article = new Article( $title );
 
-               $data = "# DO NOT EDIT THIS PAGE DIRECTLY! Use 
[[Special:AdvancedTranslate]].\n<pre>\n" . $this->formatForSave( $request ) . 
"\n</pre>";
+               $data = "# DO NOT EDIT THIS PAGE DIRECTLY! Use 
[[Special:AdvancedTranslate]].\n<pre>\n" .
+                       $this->formatForSave( $request ) . "\n</pre>";
 
-               $comment = $request->getText( 'comment', wfMessage( 
'translate-magic-cm-updatedusing' )->inContentLanguage()->text() );
+               $comment = $request->getText(
+                       'comment',
+                       wfMessage( 'translate-magic-cm-updatedusing' 
)->inContentLanguage()->text()
+               );
                $status = $article->doEdit( $data, $comment, 0 );
 
                if ( $status === false || ( is_object( $status ) && 
!$status->isOK() ) ) {
@@ -441,8 +453,13 @@
                        foreach ( $values as $v ) {
                                if ( isset( $used[$v] ) ) {
                                        $otherkey = $used[$v];
-                                       $first = Xml::element( 'a', array( 
'href' => "#mw-sp-magic-$otherkey" ), $otherkey );
-                                       $errors[] = "Translation 
<strong>$v</strong> is used more than once for $first and $link.";
+                                       $first = Xml::element(
+                                               'a',
+                                               array( 'href' => 
"#mw-sp-magic-$otherkey" ),
+                                               $otherkey
+                                       );
+                                       $errors[] = "Translation 
<strong>$v</strong> is used more than once " .
+                                               "for $first and $link.";
                                } else {
                                        $used[$v] = $key;
                                }
@@ -477,7 +494,9 @@
 
                $indexKeys = array();
                foreach ( array_keys( $items[self::LANG_MASTER] ) as $key ) {
-                       $indexKeys[$key] = isset( $this->constants[$key] ) ? 
$this->constants[$key] : "'$key'";
+                       $indexKeys[$key] = isset( $this->constants[$key] ) ?
+                               $this->constants[$key] :
+                               "'$key'";
                }
 
                $padTo = max( array_map( 'strlen', $indexKeys ) ) + 3;
@@ -608,7 +627,8 @@
        public function highlight( $key, $values ) {
                if ( count( $values ) ) {
                        if ( !isset( $values[0] ) ) {
-                               throw new MWException( "Something missing from 
values: " . print_r( $values, true ) );
+                               throw new MWException( "Something missing from 
values: " .
+                                       print_r( $values, true ) );
                        }
 
                        $values[0] = "<strong>$values[0]</strong>";
@@ -636,7 +656,8 @@
                                        $text = $title->getText();
                                        $dbkey = $title->getDBkey();
                                        if ( $text !== $_ && $dbkey !== $_ ) {
-                                               $errors[] = "Translation 
<strong>$_</strong> for $link is not in normalised form, which is 
<strong>$text</strong>";
+                                               $errors[] = "Translation 
<strong>$_</strong> for $link is not in " .
+                                                       "normalised form, which 
is <strong>$text</strong>";
                                        }
                                }
                        }
@@ -743,7 +764,8 @@
 
                        if ( count( $values ) > 1 ) {
                                $link = Xml::element( 'a', array( 'href' => 
"#mw-sp-magic-$key" ), $key );
-                               $errors[] = "Namespace $link can have only one 
translation. Replace the translation with a new one, and notify staff about the 
change.";
+                               $errors[] = "Namespace $link can have only one 
translation. Replace the " .
+                                       "translation with a new one, and notify 
staff about the change.";
                        }
                }
        }
diff --git a/scripts/sync-group.php b/scripts/sync-group.php
index 1bce00e..6ec9b53 100644
--- a/scripts/sync-group.php
+++ b/scripts/sync-group.php
@@ -1,6 +1,7 @@
 <?php
 /**
- * Command line script to import/update source messages and translations into 
the wiki database.
+ * Command line script to import/update source messages and translations into
+ * the wiki database.
  *
  * @author Niklas Laxström
  * @author Siebrand Mazeland
@@ -63,7 +64,8 @@
 $start = isset( $options['start'] ) ? strtotime( $options['start'] ) : false;
 $end = isset( $options['end'] ) ? strtotime( $options['end'] ) : false;
 
-STDOUT( "Conflict times: " . wfTimestamp( TS_ISO_8601, $start ) . " - " . 
wfTimestamp( TS_ISO_8601, $end ) );
+STDOUT( "Conflict times: " . wfTimestamp( TS_ISO_8601, $start ) . " - " .
+       wfTimestamp( TS_ISO_8601, $end ) );
 
 $codes = array_filter( array_map( 'trim', explode( ',', $options['lang'] ) ) );
 
@@ -223,8 +225,10 @@
        /**
         * Do some conflict resolution for translations.
         * @param string $code Language code.
-        * @param bool|int $startTs Time of the last export (changes in wiki 
after this will conflict)
-        * @param bool|int $endTs Time of the last export (changes in source 
before this wont conflict)
+        * @param bool|int $startTs Time of the last export (changes in wiki 
after
+        * this will conflict)
+        * @param bool|int $endTs Time of the last export (changes in source 
before
+        * this won't conflict)
         * @param bool|int $changeTs When change happened in the source.
         */
        public function checkConflicts( $code, $startTs = false, $endTs = 
false, $changeTs = false ) {
@@ -300,7 +304,11 @@
                                        continue;
                                } elseif ( !$wikiTs || ( $changeTs > $endTs && 
$wikiTs < $startTs ) ) {
                                        STDOUT( " →Changed in source after 
export: IMPORT", $page );
-                                       $this->import( $title, $translation, 
'Updating translation from external source' );
+                                       $this->import(
+                                               $title,
+                                               $translation,
+                                               'Updating translation from 
external source'
+                                       );
                                        continue;
                                }
                        }
@@ -325,12 +333,20 @@
                                }
 
                                if ( $action === 'I' ) {
-                                       $this->import( $title, $translation, 
'Updating translation from external source' );
+                                       $this->import(
+                                               $title,
+                                               $translation,
+                                               'Updating translation from 
external source'
+                                       );
                                        break;
                                }
 
                                if ( $action === 'C' ) {
-                                       $this->import( $title, TRANSLATE_FUZZY 
. $translation, 'Edit conflict between wiki and source' );
+                                       $this->import(
+                                               $title,
+                                               TRANSLATE_FUZZY . $translation,
+                                               'Edit conflict between wiki and 
source'
+                                       );
                                        break;
                                }
                        } while ( true );
diff --git a/utils/StatsTable.php b/utils/StatsTable.php
index 065bff3..d28176b 100644
--- a/utils/StatsTable.php
+++ b/utils/StatsTable.php
@@ -61,7 +61,9 @@
        }
 
        public function getBackgroundColor( $subset, $total, $fuzzy = false ) {
-               $v = @round( 255 * $subset / $total );
+               wfSuppressWarnings();
+               $v = round( 255 * $subset / $total );
+               wfRestoreWarnings();
 
                if ( $fuzzy ) {
                        // Weigh fuzzy with factor 20.

-- 
To view, visit https://gerrit.wikimedia.org/r/65450
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If42cef712e5242f39cec3f907934dfd7f6ea1109
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to