jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/363292 )

Change subject: Re-enable disabled sniffs
......................................................................


Re-enable disabled sniffs

Re-enables all sniffs other than those relating to the new rules on
one class per file (with the same name).

Updates documentation where needed to pass enabled sniffs.

Bug: T169483
Change-Id: I5cb39b41720b518db93ff7ddc9d379d47dbaf361
---
M Hooks.php
M includes/ApiWikispeech.php
M includes/CleanedContent.php
M includes/Cleaner.php
M includes/HtmlGenerator.php
M includes/Segmenter.php
M phpcs.xml
M specials/SpecialWikispeech.php
M tests/phpunit/Util.php
9 files changed, 27 insertions(+), 45 deletions(-)

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



diff --git a/Hooks.php b/Hooks.php
index 073deec..7b7e011 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -10,14 +10,13 @@
 
        /**
         * Conditionally register the unit testing module for the ext.wikispeech
-        * module only if that module is loaded
+        * module only if that module is loaded.
         *
-        * @param array $testModules The array of registered test modules
-        * @param ResourceLoader $resourceLoader The reference to the resource
+        * @param array &$testModules The array of registered test modules
+        * @param ResourceLoader &$resourceLoader The reference to the resource
         *  loader
         * @return true
         */
-
        public static function onResourceLoaderTestModules(
                array &$testModules,
                ResourceLoader &$resourceLoader
@@ -46,11 +45,10 @@
         * Adds Wikispeech elements to the HTML, if the page is in the main
         * namespace.
         *
-        * @param $parser Parser object. Can be used to manually parse a portion
-        *  of wiki text from the $text.
-        * @param $text Represents the text for page.
+        * @param Parser &$parser Can be used to manually parse a portion of 
wiki
+        *  text from the $text.
+        * @param string &$text Represents the text for page.
         */
-
        public static function onParserAfterTidy( &$parser, &$text ) {
                if ( self::isValidNamespace( 
$parser->getTitle()->getNamespace() ) &&
                         $text != ""
@@ -93,7 +91,6 @@
         * @return bool true if the namespace id matches one defined in
         *  $wgWikispeechNamespaces, else false.
         */
-
        private static function isValidNamespace( $namespace ) {
                global $wgWikispeechNamespaces;
                foreach ( $wgWikispeechNamespaces as $namespaceId ) {
@@ -110,11 +107,10 @@
         *
         * Enables JavaScript.
         *
-        * @param OutputPage $out The OutputPage object.
-        * @param Skin $skin Skin object that will be used to generate the page,
+        * @param OutputPage &$out The OutputPage object.
+        * @param Skin &$skin Skin object that will be used to generate the 
page,
         *  added in 1.13.
         */
-
        public static function onBeforePageDisplay(
                OutputPage &$out,
                Skin &$skin
@@ -125,6 +121,13 @@
                ] );
        }
 
+       /**
+        * Conditionally register static configuration variables for the
+        * ext.wikispeech module only if that module is loaded.
+        *
+        * @param array &$vars The array of static configuration variables.
+        * @return true
+        */
        public static function onResourceLoaderGetConfigVars( &$vars ) {
                global $wgWikispeechServerUrl;
                $vars['wgWikispeechServerUrl'] = $wgWikispeechServerUrl;
diff --git a/includes/ApiWikispeech.php b/includes/ApiWikispeech.php
index e2b25ce..2862d26 100644
--- a/includes/ApiWikispeech.php
+++ b/includes/ApiWikispeech.php
@@ -13,7 +13,6 @@
         *
         * @since 0.0.1
         */
-
        function execute() {
                $parameters = $this->extractRequestParams();
                if ( empty( $parameters['output'] ) ) {
@@ -32,7 +31,7 @@
         * Process HTML and return it as original, cleaned and/or segmented.
         *
         * @since 0.0.1
-        * @param string $html The HTML string to process.
+        * @param string $pageContent The HTML string to process.
         * @param array $outputFormats Specifies what output formats to
         *  return. Can be any combination of: "originalcontent",
         *  "cleanedtext" and "segments".
@@ -45,7 +44,6 @@
         *  * "cleanedtext": The cleaned HTML, as a string.
         *  * "segments": Cleaned and segmented HTML as an array.
         */
-
        public function processPageContent(
                $pageContent,
                $outputFormats,
@@ -99,7 +97,6 @@
         * @return string The parsed content for the page given in the
         *  request to the Wikispeech API.
         */
-
        private function getPageContent( $pageTitle ) {
                // Get and validate Title
                $title = Title::newFromText( $pageTitle );
@@ -131,7 +128,6 @@
         * @since 0.0.1
         * @return array
         */
-
        public function getAllowedParams() {
                global $wgWikispeechRemoveTags;
                global $wgWikispeechSegmentBreakingTags;
@@ -171,7 +167,6 @@
         * @since 0.0.1
         * @return array
         */
-
        public function getExamplesMessages() {
                return [
                // @codingStandardsIgnoreStart
diff --git a/includes/CleanedContent.php b/includes/CleanedContent.php
index 76b457b..c03e872 100644
--- a/includes/CleanedContent.php
+++ b/includes/CleanedContent.php
@@ -40,7 +40,6 @@
         * @param string $string The string representation of this text.
         * @param array $path The path to the text node this was created from.
         */
-
        function __construct( $string, $path='' ) {
                $this->string = $string;
                $this->path = $path;
@@ -55,7 +54,6 @@
         * @param DOMDocument $dom The DOM Document used to create the element.
         * @return DOMElement The created text element.
         */
-
        function toElement( $dom ) {
                $element = $dom->createElement( 'text', $this->string );
                $element->setAttribute( 'path', $this->path );
diff --git a/includes/Cleaner.php b/includes/Cleaner.php
index 2f2771a..db00de1 100644
--- a/includes/Cleaner.php
+++ b/includes/Cleaner.php
@@ -38,6 +38,12 @@
 
        private $cleanedContent;
 
+       /**
+        * @param array|null $removeTags An array of tags that should be removed
+        *  completely during cleaning.
+        * @param array|null $segmentBreakingTags An array of `CleanedText`s and
+        *  `SegmentBreak`s.
+        */
        function __construct( $removeTags, $segmentBreakingTags ) {
                if ( $removeTags == null ) {
                        $removeTags = [];
@@ -60,7 +66,6 @@
         * @return array An array of `CleanedText`s and `SegmentBreak`s
         *  representing text nodes.
         */
-
        public function cleanHtml( $markedUpText ) {
                $dom = self::createDomDocument( $markedUpText );
                $xpath = new DOMXPath( $dom );
@@ -93,7 +98,6 @@
         *  DOMDocument.
         * @return DOMDocument The created DOMDocument.
         */
-
        private static function createDomDocument( $markedUpText ) {
                $dom = new DOMDocument();
                // Add encoding information and wrap the input text in a dummy
@@ -122,7 +126,6 @@
         * @since 0.0.1
         * @param DOMNode $node The top node to add from.
         */
-
        private function addContent( $node ) {
                if ( !$node instanceof DOMComment && !$this->matchesRemove( 
$node ) ) {
                        foreach ( $node->childNodes as $child ) {
@@ -178,7 +181,6 @@
         * @return bool true if the node match removal criteria, otherwise
         *  false.
         */
-
        private function matchesRemove( $node ) {
                if ( !array_key_exists( $node->nodeName, $this->removeTags ) ) {
                        // The node name isn't found in the removal list.
@@ -216,7 +218,6 @@
         * @return bool true if the node's class attribute contain
         *  $className, otherwise false.
         */
-
        private static function nodeHasClass( $node, $className ) {
                $classNode = $node->attributes->getNamedItem( 'class' );
                if ( $classNode == null ) {
@@ -237,7 +238,6 @@
         * @param array $array The array to get the last element from.
         * @return The last element in the array, null if array is empty.
         */
-
        private static function lastElement( $array ) {
                if ( !count( $array ) ) {
                        return null;
diff --git a/includes/HtmlGenerator.php b/includes/HtmlGenerator.php
index fc40178..2604b70 100644
--- a/includes/HtmlGenerator.php
+++ b/includes/HtmlGenerator.php
@@ -23,7 +23,6 @@
         * @return string An HTML string containing the <utterance> tags,
         *  wrapped in an <utterances> tag.
         */
-
        public static function createUtterancesHtml( $segments ) {
                $dom = new DOMDocument();
                $utterancesElement = self::createUtterancesElement( $dom, 
$segments );
@@ -42,7 +41,6 @@
         *  from.
         * @return DOMElement The utterances element.
         */
-
        private static function createUtterancesElement( $dom, $segments ) {
                if ( count( $segments ) ) {
                        $utterancesElement = $dom->createElement( 'utterances' 
);
@@ -90,7 +88,6 @@
         *  order.
         * @return DOMElement The resulting utterance element.
         */
-
        private static function createUtteranceElement( $dom, $segment, $index 
) {
                $utteranceElement = $dom->createElement( 'utterance' );
                $utteranceElement->setAttribute( 'id', "utterance-$index" );
@@ -119,7 +116,6 @@
         * @param array $content An array of `CleanedText`s.
         * @return DOMNode A content element.
         */
-
        private static function createContentElement( $dom, $content ) {
                $contentElement = $dom->createElement( 'content' );
                foreach ( $content as $item ) {
diff --git a/includes/Segmenter.php b/includes/Segmenter.php
index c909254..0f8047e 100644
--- a/includes/Segmenter.php
+++ b/includes/Segmenter.php
@@ -61,7 +61,6 @@
         * @return array An array of segments, each containing the
         *  `CleanedText's in that segment.
         */
-
        public function segmentSentences( $cleanedContent ) {
                foreach ( $cleanedContent as $item ) {
                        if ( $item instanceof CleanedText ) {
@@ -87,7 +86,6 @@
         * @since 0.0.1
         * @param CleanedText $text The text to segment.
         */
-
        private function addSegments( $text ) {
                $nextStartOffset = 0;
                do {
@@ -116,7 +114,6 @@
         *   sentence. If the sentence didn't end yet, this is the last
         *   character of $text.
         */
-
        private function addSegment( $text, $startOffset=0 ) {
                if ( $this->currentSegment['startOffset'] === null ) {
                        // Move the start offset ahead by the number of leading
@@ -173,7 +170,6 @@
         *  for.
         * @return int The number of whitespaces at the start of $string.
         */
-
        private static function getLeadingWhitespacesLength( $string ) {
                $trimmedString = ltrim( $string );
                return mb_strlen( $string ) - mb_strlen( $trimmedString );
@@ -188,7 +184,6 @@
         * @return int The offset of the first sentence final character
         *  that was found, if any, else null.
         */
-
        private static function getSentenceFinalOffset( $string, $offset ) {
                // For every potentially sentence final character after the
                // first one, we want to start looking from the character
@@ -221,7 +216,6 @@
         * @param int $index The the index in $string of the character to check.
         * @return bool True if the character is sentence final, else false.
         */
-
        private static function isSentenceFinal( $string, $index ) {
                $character = mb_substr( $string, $index, 1 );
                $nextCharacter = null;
@@ -253,7 +247,6 @@
         * @param string $string The string to test.
         * @return bool true if the entire string is upper case, else false.
         */
-
        private static function isUpper( $string ) {
                return mb_strtoupper( $string ) == $string;
        }
@@ -268,7 +261,6 @@
         *  finished one to.
         * @param array $currentCegments The finished segment to add.
         */
-
        private function finishSegment() {
                if ( count( $this->currentSegment['content'] ) ) {
                        array_push( $this->segments, $this->currentSegment );
diff --git a/phpcs.xml b/phpcs.xml
index 10557f1..11931a6 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -1,14 +1,8 @@
 <?xml version="1.0"?>
 <ruleset>
        <rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
-               <exclude 
name="MediaWiki.Commenting.FunctionComment.MissingParamName" />
-               <exclude 
name="MediaWiki.Commenting.FunctionComment.MissingParamTag" />
-               <exclude 
name="MediaWiki.Commenting.FunctionComment.ParamNameNoMatch" />
-               <exclude 
name="MediaWiki.Commenting.FunctionComment.SpacingAfter" />
                <exclude name="MediaWiki.Files.ClassMatchesFilename.NotMatch" />
                <exclude name="MediaWiki.Files.OneClassPerFile.MultipleFound" />
-               <exclude 
name="MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected" />
-               <exclude 
name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic" />
        </rule>
        <file>.</file>
        <arg name="extensions" value="php,php5,inc" />
diff --git a/specials/SpecialWikispeech.php b/specials/SpecialWikispeech.php
index 900bf4c..4c4d3eb 100644
--- a/specials/SpecialWikispeech.php
+++ b/specials/SpecialWikispeech.php
@@ -22,6 +22,11 @@
                $out->addWikiMsg( 'special-wikispeech-intro' );
        }
 
+       /**
+        * @see SpecialPage::getGroupName
+        *
+        * @return string
+        */
        protected function getGroupName() {
                return 'other';
        }
diff --git a/tests/phpunit/Util.php b/tests/phpunit/Util.php
index d60bd0a..8ca7e80 100644
--- a/tests/phpunit/Util.php
+++ b/tests/phpunit/Util.php
@@ -19,7 +19,6 @@
         * @param string $function The name of the function to call
         * @return Whatever $function returns
         */
-
        public static function call( $class, $function ) {
                $reflection = new ReflectionMethod( $class, $function );
                $reflection->setAccessible( true );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I5cb39b41720b518db93ff7ddc9d379d47dbaf361
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Wikispeech
Gerrit-Branch: master
Gerrit-Owner: Lokal Profil <lokal.pro...@gmail.com>
Gerrit-Reviewer: Sebastian Berlin (WMSE) <sebastian.ber...@wikimedia.se>
Gerrit-Reviewer: Umherirrender <umherirrender_de...@web.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to