jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/401625 )
Change subject: Fix and restrict sniffs to certain files
......................................................................
Fix and restrict sniffs to certain files
Rather than disabling all sniffs globally, limit certain
sniffs to certain "special" PHP files.
Fix remaining documentation and visibility sniffs to add
context to various methods.
Bug: T170579
Change-Id: Idd9ab3c0764b31b1e682a0a79b1e7c3ba8f06c61
---
M .phpcs.xml
M includes/MobileContext.php
M includes/MobileFormatter.php
M includes/api/ApiMobileView.php
M includes/devices/DeviceDetector.php
M includes/devices/DeviceDetectorService.php
M includes/diff/InlineDiffFormatter.php
M includes/specials/SpecialMobileLanguages.php
M includes/specials/SpecialMobileWatchlist.php
9 files changed, 40 insertions(+), 24 deletions(-)
Approvals:
jenkins-bot: Verified
Thiemo Kreuz (WMDE): Looks good to me, approved
diff --git a/.phpcs.xml b/.phpcs.xml
index 6948f7c..823e11a 100644
--- a/.phpcs.xml
+++ b/.phpcs.xml
@@ -1,14 +1,20 @@
<?xml version="1.0"?>
<ruleset>
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
- <exclude
name="Generic.Files.OneObjectStructurePerFile.MultipleFound" />
- <exclude
name="MediaWiki.Commenting.FunctionComment.MissingParamComment" />
- <exclude name="MediaWiki.Files.ClassMatchesFilename.NotMatch" />
- <exclude name="Squiz.Scope.MethodScope.Missing" />
</rule>
<rule ref="Generic.Files.LineLength">
<exclude-pattern>MobileFrontend\.alias\.php</exclude-pattern>
</rule>
+ <rule ref="MediaWiki.Files.ClassMatchesFilename.NotMatch">
+ <exclude-pattern>tests/phpunit/*</exclude-pattern>
+
<exclude-pattern>includes/MobileFrontend\.*\.php</exclude-pattern>
+ </rule>
+ <rule ref="Generic.Files.OneObjectStructurePerFile.MultipleFound">
+ <exclude-pattern>tests/phpunit/*</exclude-pattern>
+ </rule>
+ <rule ref="MediaWiki.Commenting.FunctionComment.MissingParamComment">
+
<exclude-pattern>includes/MobileFrontend\.*\.php</exclude-pattern>
+ </rule>
<file>.</file>
<arg name="extensions" value="php,php5,inc"/>
<arg name="encoding" value="UTF-8"/>
diff --git a/includes/MobileContext.php b/includes/MobileContext.php
index a788387..6a3f819 100644
--- a/includes/MobileContext.php
+++ b/includes/MobileContext.php
@@ -815,8 +815,8 @@
/**
* Take a URL and return a copy that removes any mobile tokens
- * @param string $url
- * @return string
+ * @param string $url representing a page on the mobile domain e.g.
`https://en.m.wikipedia.org/`
+ * @return string (absolute url)
*/
public function getDesktopUrl( $url ) {
$parsedUrl = wfParseUrl( $url );
@@ -1050,8 +1050,8 @@
/**
* Add key/value pairs for analytics purposes to
$this->analyticsLogItems
- * @param string $key
- * @param string $val
+ * @param string $key for <key> in `X-Analytics: <key>=<value>`
+ * @param string $val for <value> in `X-Analytics: <key>=<value>`
*/
public function addAnalyticsLogItem( $key, $val ) {
$key = trim( $key );
diff --git a/includes/MobileFormatter.php b/includes/MobileFormatter.php
index e64249c..a4ada4d 100644
--- a/includes/MobileFormatter.php
+++ b/includes/MobileFormatter.php
@@ -92,7 +92,8 @@
/**
* Creates and returns a MobileFormatter
*
- * @param MobileContext $context
+ * @param MobileContext $context in which the page is being rendered.
Needed to access page title
+ * and MobileFrontend configuration.
* @param IContentProvider $provider ContentProvider interface
* @param bool $enableSections (optional)
* whether to wrap the content of sections
@@ -555,7 +556,8 @@
* that the section bodies are clearly defined (to be "expandable" for
* example).
*
- * @param DOMDocument $doc
+ * @param DOMDocument $doc representing the HTML of the current
article. In the HTML the sections
+ * should not be wrapped.
* @param DOMElement[] $headings The headings returned by
* {@see MobileFormatter::getHeadings}
* @param array $transformOptions Options to pass when transforming
content per section
diff --git a/includes/api/ApiMobileView.php b/includes/api/ApiMobileView.php
index 5653b7a..51448b9 100644
--- a/includes/api/ApiMobileView.php
+++ b/includes/api/ApiMobileView.php
@@ -469,7 +469,8 @@
}
/**
- * @param WikiPage $wikiPage
+ * Call makeParserOptions on a WikiPage with the wrapper output class
disabled.
+ * @param WikiPage $wikiPage to call makeParserOptions on.
* @return ParserOptions
*/
protected function makeParserOptions( WikiPage $wikiPage ) {
diff --git a/includes/devices/DeviceDetector.php
b/includes/devices/DeviceDetector.php
index aa5399a..f5ff466 100644
--- a/includes/devices/DeviceDetector.php
+++ b/includes/devices/DeviceDetector.php
@@ -41,9 +41,10 @@
* `$_SERVER` superglobal within its API, it's expected to be passed as
* additional context.
*
- * @param WebRequest $request
+ * @param WebRequest $request for the current page view. The HTTP
headers of this request
+ * will be used to determine whether the page view should redirect to
mobile
* @param array $server Per the above, the `$_SERVER` superglobal
* @return DeviceProperties|null
*/
- function detectDeviceProperties( WebRequest $request, array $server );
+ public function detectDeviceProperties( WebRequest $request, array
$server );
}
diff --git a/includes/devices/DeviceDetectorService.php
b/includes/devices/DeviceDetectorService.php
index af44657..152dfcc 100644
--- a/includes/devices/DeviceDetectorService.php
+++ b/includes/devices/DeviceDetectorService.php
@@ -23,7 +23,7 @@
* If `$wgMFAutodetectMobileView` is falsy, then no device detection
will
* occur.
*
- * @param Config $config
+ * @param Config $config containing values forq MFAutodetectMobileView
and MFMobileHeader
* @return DeviceDetectorService
*/
public static function factory( Config $config ) {
diff --git a/includes/diff/InlineDiffFormatter.php
b/includes/diff/InlineDiffFormatter.php
index 783060e..351003e 100644
--- a/includes/diff/InlineDiffFormatter.php
+++ b/includes/diff/InlineDiffFormatter.php
@@ -10,22 +10,24 @@
/**
* Get the header of diff block. Remember: Given line numbers will not
be visible,
* it's a one column diff style.
+ * @inheritDoc
* @param int $xbeg line number of left side to compare with
* @param int $xlen Number of trailing lines after the changed line on
left side
* @param int $ybeg right side line number to compare with
* @param int $ylen Number of trailing lines after the changed line on
right side
* @return string
*/
- function blockHeader( $xbeg, $xlen, $ybeg, $ylen ) {
+ protected function blockHeader( $xbeg, $xlen, $ybeg, $ylen ) {
return "<div class=\"mw-diff-inline-header\"><!-- LINES
$xbeg,$ybeg --></div>\n";
}
/**
* Get a div element with a complete new added line as content.
* Complete line will be appear with green background.
+ * @inheritDoc
* @param array $lines With changed lines
*/
- function added( $lines ) {
+ protected function added( $lines ) {
foreach ( $lines as $line ) {
$this->writeOutput( '<div
class="mw-diff-inline-added"><ins>'
. $this->lineOrNbsp( htmlspecialchars( $line ) )
@@ -36,9 +38,10 @@
/**
* Get a div with a line which is deleted completly.
* This line will be appear with complete red background.
+ * @inheritDoc
* @param array $lines With deleted lines
*/
- function deleted( $lines ) {
+ protected function deleted( $lines ) {
foreach ( $lines as $line ) {
$this->writeOutput( '<div
class="mw-diff-inline-deleted"><del>'
. $this->lineOrNbsp( htmlspecialchars( $line ) )
@@ -50,9 +53,10 @@
* Get a div with some changed content.
* Line will appear with white and the changed context in
* red (for deleted chars) and green (for added chars) background.
+ * @inheritDoc
* @param array $lines With edited lines
*/
- function context( $lines ) {
+ protected function context( $lines ) {
foreach ( $lines as $line ) {
$this->writeOutput( "<div
class=\"mw-diff-inline-context\">" .
"{$this->contextLine( htmlspecialchars( $line )
)}</div>\n" );
@@ -90,10 +94,11 @@
/**
* Get a div with changed content (not complete added or deleted line)
+ * @inheritDoc
* @param string[] $orig Old content to compare with
* @param string[] $closing New content to compare with
*/
- function changed( $orig, $closing ) {
+ protected function changed( $orig, $closing ) {
$this->writeOutput( '<div class="mw-diff-inline-changed">' );
$diff = new WordLevelDiff( $orig, $closing );
$edits = $this->inlineWordDiff( $diff );
diff --git a/includes/specials/SpecialMobileLanguages.php
b/includes/specials/SpecialMobileLanguages.php
index 088c48e..d282319 100644
--- a/includes/specials/SpecialMobileLanguages.php
+++ b/includes/specials/SpecialMobileLanguages.php
@@ -81,7 +81,8 @@
* @see https://phabricator.wikimedia.org/T93500
* @see https://phabricator.wikimedia.org/T172316
* @param array $languageMap array of language names, indexed by code.
- * @param array $langObject
+ * @param array $langObject with lang and url keys. If url key is not
present a warning
+ * will be logged.
* @return bool
*/
private function isLanguageObjectValid( $languageMap, $langObject ) {
diff --git a/includes/specials/SpecialMobileWatchlist.php
b/includes/specials/SpecialMobileWatchlist.php
index 39767cc..ce15ec6 100644
--- a/includes/specials/SpecialMobileWatchlist.php
+++ b/includes/specials/SpecialMobileWatchlist.php
@@ -52,7 +52,7 @@
* Render the special page
* @param string $par parameter submitted as subpage
*/
- function executeWhenAvailable( $par ) {
+ public function executeWhenAvailable( $par ) {
// Anons don't get a watchlist
$this->requireLogin( 'mobile-frontend-watchlist-purpose' );
@@ -139,7 +139,7 @@
/**
* Get the header for the watchlist page
- * @param User $user
+ * @param User $user the current user for obtaining default view and
filter preferences
* @param string|null $view the name of the view to show (optional)
* If absent user preferences will be consulted.
* @return string Parsed HTML
@@ -188,7 +188,7 @@
/**
* Render "second" header for filter in feed view of watchlist
*/
- function showRecentChangesHeader() {
+ private function showRecentChangesHeader() {
$filters = [
'all' => 'mobile-frontend-watchlist-filter-all',
'articles' =>
'mobile-frontend-watchlist-filter-articles',
@@ -331,7 +331,7 @@
* If the user doesn't watch any page, show information how to watch
some.
* @param bool $feed Render as feed (true) or list (false) view?
*/
- function showEmptyList( $feed ) {
+ private function showEmptyList( $feed ) {
$this->getOutput()->addHtml( self::getEmptyListHtml( $feed,
$this->getLanguage() ) );
}
--
To view, visit https://gerrit.wikimedia.org/r/401625
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Idd9ab3c0764b31b1e682a0a79b1e7c3ba8f06c61
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Pmiazga <[email protected]>
Gerrit-Reviewer: Thiemo Kreuz (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits