Legoktm has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/363477 )
Change subject: build: Updating mediawiki/mediawiki-codesniffer to 0.10.0 ...................................................................... build: Updating mediawiki/mediawiki-codesniffer to 0.10.0 Also add a "composer fix" command, and output the sniff code when running phpcs. Change-Id: Ie9e3ed31b07bf2d503fc0504cefd429f06e33f81 --- M composer.json M src/HtmlFormatter.php M tests/HtmlFormatterTest.php 3 files changed, 19 insertions(+), 17 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/HtmlFormatter refs/changes/77/363477/1 diff --git a/composer.json b/composer.json index 73901a7..23a6297 100644 --- a/composer.json +++ b/composer.json @@ -20,13 +20,14 @@ "require-dev": { "jakub-onderka/php-parallel-lint": "0.9.2", "phpunit/phpunit": "4.7.2", - "mediawiki/mediawiki-codesniffer": "0.7.1" + "mediawiki/mediawiki-codesniffer": "0.10.0" }, "scripts": { "test": [ "parallel-lint . --exclude vendor", "phpunit", - "phpcs -p" - ] + "phpcs -sp" + ], + "fix": "phpcbf" } } diff --git a/src/HtmlFormatter.php b/src/HtmlFormatter.php index e93ab1f..1e64564 100644 --- a/src/HtmlFormatter.php +++ b/src/HtmlFormatter.php @@ -25,7 +25,7 @@ class HtmlFormatter { /** - * @var DOMDocument + * @var \DOMDocument */ private $doc; @@ -45,7 +45,7 @@ /** * Turns a chunk of HTML into a proper document - * @param string $html + * @param string $html HTML to wrap * @return string */ public static function wrapHTML( $html ) { @@ -62,7 +62,7 @@ } /** - * @return DOMDocument DOM to manipulate + * @return \DOMDocument DOM to manipulate */ public function getDoc() { if ( !$this->doc ) { @@ -88,7 +88,7 @@ /** * Sets whether images/videos/sounds should be removed from output - * @param bool $flag + * @param bool $flag Whether to remove or not */ public function setRemoveMedia( $flag = true ) { $this->removeMedia = $flag; @@ -182,7 +182,7 @@ foreach ( $removals['CLASS'] as $classToRemove ) { $elements = $xpath->query( '//*[contains(@class, "' . $classToRemove . '")]' ); - /** @var $element DOMElement */ + /** @var $element \DOMElement */ foreach ( $elements as $element ) { $classes = $element->getAttribute( 'class' ); if ( \preg_match( "/\b$classToRemove\b/", $classes ) && $element->parentNode ) { @@ -207,7 +207,7 @@ /** * Removes a list of elelments from DOMDocument - * @param array|DOMNodeList $elements + * @param array|\DOMNodeList $elements * @return array Array of removed elements */ private function removeElements( $elements ) { @@ -218,7 +218,7 @@ $list[] = $element; } } - /** @var $element DOMElement */ + /** @var $element \DOMElement */ foreach ( $list as $element ) { if ( $element->parentNode ) { $element->parentNode->removeChild( $element ); @@ -260,12 +260,11 @@ * specify the $element in the method it'll change the underlying dom and you won't be able to get * it back. * - * @param DOMElement|string|null $element ID of element to get HTML from or + * @param \DOMElement|string|null $element ID of element to get HTML from or * false to get it from the whole tree * @return string Processed HTML */ public function getText( $element = null ) { - if ( $this->doc ) { if ( $element !== null && !( $element instanceof \DOMElement ) ) { $element = $this->doc->getElementById( $element ); @@ -309,10 +308,10 @@ * values to parameters passed by reference. For example, if given '#toc' as the * $selector parameter, it will assign 'ID' as the $type and 'toc' as the $rawName. * @param string $selector CSS selector to parse - * @param string $type The type of selector (ID, CLASS, TAG_CLASS, or TAG) - * @param string $rawName The raw name of the selector + * @param string &$type The type of selector (ID, CLASS, TAG_CLASS, or TAG) + * @param string &$rawName The raw name of the selector * @return bool Whether the selector was successfully recognised - * @throws MWException + * @throws \Exception */ protected function parseSelector( $selector, &$type, &$rawName ) { if ( strpos( $selector, '.' ) === 0 ) { diff --git a/tests/HtmlFormatterTest.php b/tests/HtmlFormatterTest.php index 038a632..98f59d2 100644 --- a/tests/HtmlFormatterTest.php +++ b/tests/HtmlFormatterTest.php @@ -39,7 +39,8 @@ private static function normalize( $s ) { return str_replace( "\n", '', - str_replace( "\r", '', $s ) // "yay" to Windows! + // "yay" to Windows! + str_replace( "\r", '', $s ) ); } @@ -102,7 +103,8 @@ '<span title="" \' &"><Тест!></span> &<&&&&', '<span title="" \' &"><Тест!></span> &<&&&&', [], - $removeTags, // Have some rules to trigger a DOM parse + // Have some rules to trigger a DOM parse + $removeTags, ], // https://phabricator.wikimedia.org/T55086 [ -- To view, visit https://gerrit.wikimedia.org/r/363477 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie9e3ed31b07bf2d503fc0504cefd429f06e33f81 Gerrit-PatchSet: 1 Gerrit-Project: HtmlFormatter Gerrit-Branch: master Gerrit-Owner: Legoktm <lego...@member.fsf.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits